|
|
package cn.com.ebewin.ysr.dialog;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
import java.awt.Dimension;
|
|
|
import java.awt.FlowLayout;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
import javax.swing.JLabel;
|
|
|
import javax.swing.JPanel;
|
|
|
import javax.swing.JTextField;
|
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
import com.teamcenter.rac.kernel.TCUserService;
|
|
|
import com.teamcenter.rac.util.DateButton;
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
import com.teamcenter.rac.util.PropertyLayout;
|
|
|
|
|
|
import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog.EditObjectInfo;
|
|
|
import cn.com.ebewin.ysr.util.KUtil;
|
|
|
import cn.com.ebewin.ysr.util.TCUtil;
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
public class MachiningDynamicsExWarehouseDialog extends AbstractAIFDialog {
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
private JButton okBtn;
|
|
|
private JButton cancelBtn;
|
|
|
private JTextField person;
|
|
|
private DateButton date;
|
|
|
|
|
|
public MachiningDynamicsExWarehouseDialog(MachiningDynamicsManageDialog mdm, EditObjectInfo editObjectInfo) throws Exception {
|
|
|
super(mdm);
|
|
|
setTitle("出库信息");
|
|
|
JPanel propPanel = new JPanel(new PropertyLayout(70, 20, 10, 5, 20, 5));
|
|
|
// TCComponentListOfValues[] lov = lovType.find("ML8_ProjectCategory_LOV");
|
|
|
// String[] vals = getDynamicLOV(lov[0]);
|
|
|
// System.out.println("ML8_ProjectCategory_LOV:"+lov[0].getType()+"=="+vals.length);
|
|
|
JLabel label1 = new JLabel(" 出库日期");
|
|
|
propPanel.add("1.1.left.center", label1);
|
|
|
date = new DateButton(null, "yyyy-MM-dd", false, false, false);
|
|
|
date.setPreferredSize(new Dimension(150, 23));
|
|
|
date.setDate(new Date());
|
|
|
propPanel.add("1.2.left.center", date);
|
|
|
JLabel label2 = new JLabel(" 领料人");
|
|
|
propPanel.add("2.1.left.center", label2);
|
|
|
person = new JTextField();
|
|
|
person.setPreferredSize(new Dimension(150, 23));
|
|
|
propPanel.add("2.2.left.center", person);
|
|
|
okBtn = new JButton("确定");
|
|
|
cancelBtn = new JButton("取消");
|
|
|
JPanel btnPanel = new JPanel(new FlowLayout());
|
|
|
btnPanel.add(okBtn);
|
|
|
btnPanel.add(cancelBtn);
|
|
|
setLayout(new BorderLayout());
|
|
|
add(BorderLayout.CENTER, propPanel);
|
|
|
add(BorderLayout.SOUTH, btnPanel);
|
|
|
// add(new JLabel(""));
|
|
|
addActionListener(mdm, editObjectInfo);
|
|
|
|
|
|
pack();
|
|
|
setSize(new Dimension(370, 180));
|
|
|
setDefaultLookAndFeelDecorated(true);
|
|
|
Dimension screen = getToolkit().getScreenSize();
|
|
|
setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
|
|
|
// setAlwaysOnTop(true);
|
|
|
setVisible(true);
|
|
|
}
|
|
|
|
|
|
private void addActionListener(final MachiningDynamicsManageDialog mdm, final EditObjectInfo editObjectInfo) {
|
|
|
okBtn.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
try {
|
|
|
String ysr8_ExWarehousePerson = person.getText();
|
|
|
Date ysr8_ExWarehouseDate = date.getDate();
|
|
|
if(ysr8_ExWarehousePerson.isEmpty() || ysr8_ExWarehouseDate==null)
|
|
|
throw new Exception("有属性未填写,请检查");
|
|
|
String keys = "ysr8_ExWarehousePerson@@@@ysr8_ExWarehouseDate@@@@ysr8_ExWarehouseState@@@@ysr8_ExWarehouseQuantity",
|
|
|
date1 = getDateTimeString2(ysr8_ExWarehouseDate), date2 = String.format("%tF", ysr8_ExWarehouseDate);
|
|
|
for(int i=0; i<editObjectInfo.editObjects.size(); i++) {
|
|
|
TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(i);
|
|
|
TCComponentForm form = TCUtil.getItemRevisionMasterForm(item.getLatestItemRevision());
|
|
|
StringBuilder vals = new StringBuilder(""), params = new StringBuilder("");
|
|
|
int n = editObjectInfo.editObjectListIdxs.get(i);
|
|
|
vals.append(n).append("$$$$").append(ysr8_ExWarehousePerson).append("@@@@")
|
|
|
.append(n).append("$$$$").append(date1).append("@@@@").append(n).append("$$$$").append("2").append("@@@@")
|
|
|
.append(n).append("$$$$").append(editObjectInfo.editObjectQuantity.get(i));
|
|
|
|
|
|
KUtil.setNewArrayProperty(form);
|
|
|
params.append(item.getProperty("item_id")).append("^^^^").append(keys).append("^^^^").append(vals.toString());
|
|
|
|
|
|
TCUserService userService = mdm.fu.session.getUserService();
|
|
|
Object[] objParams = new Object[2];
|
|
|
String cmd = "Update_ItemRevForm_TCProperty";
|
|
|
objParams[0] = cmd;
|
|
|
objParams[1] = params.toString();
|
|
|
System.out.println(objParams[1]);
|
|
|
long startime = System.currentTimeMillis();
|
|
|
String result = (String) userService.call("YSR8UserService", objParams);
|
|
|
long endtime = System.currentTimeMillis();
|
|
|
System.out.println(item.getProperty("item_id") + " " + editObjectInfo.editObjectMaterialID.get(i)
|
|
|
+ " 调用C,耗时:" + (endtime - startime) + "毫秒 " + result);
|
|
|
Thread.sleep(1000);
|
|
|
form.refresh();
|
|
|
mdm.updateExWarehouseValue(ysr8_ExWarehousePerson, date2, editObjectInfo.rows.get(i), false);
|
|
|
}
|
|
|
|
|
|
dispose();
|
|
|
}catch(Exception e1) {
|
|
|
e1.printStackTrace();
|
|
|
MessageBox.post(MachiningDynamicsExWarehouseDialog.this, "错误:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
cancelBtn.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
dispose();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private String getDateTimeString2(Date date) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
|
|
if (date != null) {
|
|
|
return sdf.format(date);
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
} |