|
|
@ -32,7 +32,6 @@ import com.connor.chint.sap2.util.KUtil;
|
|
|
|
import com.connor.chint.sap2.util.MyProgressBarCompent;
|
|
|
|
import com.connor.chint.sap2.util.MyProgressBarCompent;
|
|
|
|
import com.connor.chint.sap2.util.SAPMessageUtil;
|
|
|
|
import com.connor.chint.sap2.util.SAPMessageUtil;
|
|
|
|
import com.connor.chint.sap2.util.SAPUtil;
|
|
|
|
import com.connor.chint.sap2.util.SAPUtil;
|
|
|
|
import com.connor.chint.sap2.util.SqlUtil;
|
|
|
|
|
|
|
|
import com.connor.chint.sap2.util.TXTUtil;
|
|
|
|
import com.connor.chint.sap2.util.TXTUtil;
|
|
|
|
import com.squareup.okhttp.Credentials;
|
|
|
|
import com.squareup.okhttp.Credentials;
|
|
|
|
import com.squareup.okhttp.MediaType;
|
|
|
|
import com.squareup.okhttp.MediaType;
|
|
|
@ -63,411 +62,375 @@ import com.teamcenter.rac.util.MessageBox;
|
|
|
|
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
|
|
|
|
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
|
|
|
|
|
|
|
|
|
|
|
|
public class BomSendSapController {
|
|
|
|
public class BomSendSapController {
|
|
|
|
|
|
|
|
|
|
|
|
public static final String TYPE_REV_PART = "Part Revision";
|
|
|
|
public static final String TYPE_REV_PART = "Part Revision";
|
|
|
|
public TCComponent project; // 项目信息
|
|
|
|
public TCComponent project; //项目信息
|
|
|
|
public String groupName;
|
|
|
|
public String groupName;
|
|
|
|
public String zt2_ProjectNo;
|
|
|
|
public String zt2_ProjectNo;
|
|
|
|
public String wbs;
|
|
|
|
public String wbs;
|
|
|
|
public AbstractAIFApplication app;
|
|
|
|
public AbstractAIFApplication app;
|
|
|
|
private TCSession session;
|
|
|
|
private TCSession session;
|
|
|
|
public List<PartBean> partList = new ArrayList<>();
|
|
|
|
public List<PartBean> partList = new ArrayList<>();
|
|
|
|
public BomSendSapWhFram dialog;
|
|
|
|
public BomSendSapWhFram dialog;
|
|
|
|
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
|
|
|
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
|
|
|
|
|
|
|
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) {
|
|
|
|
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) {
|
|
|
|
this.app = app;
|
|
|
|
this.app = app;
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 检查选定项目下是否存在产成品
|
|
|
|
// 检查选定项目下是否存在产成品
|
|
|
|
public boolean checkTargets() throws Exception {
|
|
|
|
public boolean checkTargets() throws Exception {
|
|
|
|
InterfaceAIFComponent target = app.getTargetComponent();
|
|
|
|
InterfaceAIFComponent target = app.getTargetComponent();
|
|
|
|
if (target == null || !(target instanceof TCComponent)) {
|
|
|
|
if (target == null || !(target instanceof TCComponent)) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
project = (TCComponent) target;
|
|
|
|
project = (TCComponent) target;
|
|
|
|
|
|
|
|
|
|
|
|
zt2_ProjectNo = project.getProperty("zt2_ProjectNo");
|
|
|
|
zt2_ProjectNo = project.getProperty("zt2_ProjectNo");
|
|
|
|
wbs = project.getProperty("zt2_WBSNo");
|
|
|
|
wbs = project.getProperty("zt2_WBSNo");
|
|
|
|
System.out.println("检查对象:" + target);
|
|
|
|
System.out.println("检查对象:" + target);
|
|
|
|
List<TCComponentItemRevision> partRevList = KUtil.getCCPFromProject(project);
|
|
|
|
List<TCComponentItemRevision> partRevList = KUtil.getCCPFromProject(project);
|
|
|
|
|
|
|
|
|
|
|
|
for(TCComponentItemRevision rev:partRevList) {
|
|
|
|
for (TCComponentItemRevision rev : partRevList) {
|
|
|
|
String cType = rev.getType();
|
|
|
|
String cType = rev.getType();
|
|
|
|
|
|
|
|
// System.out.println(">> 找到子对象:" + cName + "|" + cType);
|
|
|
|
// System.out.println(">> 找到子对象:" + cName + "|" + cType);
|
|
|
|
if (TYPE_REV_PART.equals(cType)) {
|
|
|
|
if (TYPE_REV_PART.equals(cType)) {
|
|
|
|
PartBean bean = new PartBean(rev, partList.size() + 1, "");
|
|
|
|
PartBean bean = new PartBean(rev, partList.size() + 1,"");
|
|
|
|
SAPPushBOMBean.readUser(bean, rev, groupName, session);
|
|
|
|
SAPPushBOMBean.readUser(bean, rev, groupName, session);
|
|
|
|
bean.setPSPID(project.getProperty("zt2_ProjectNo"));
|
|
|
|
bean.setPSPID(project.getProperty("zt2_ProjectNo"));
|
|
|
|
partList.add(bean);
|
|
|
|
partList.add(bean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (partList.size() == 0) {
|
|
|
|
if (partList.size() == 0) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String sapState = "";
|
|
|
|
public String sapState = "";
|
|
|
|
private TCComponent released_Red;
|
|
|
|
private TCComponent released_Red;
|
|
|
|
private TCComponent released_Yellow;
|
|
|
|
private TCComponent released_Yellow;
|
|
|
|
private TCComponent released_Green;
|
|
|
|
private TCComponent released_Green;
|
|
|
|
|
|
|
|
|
|
|
|
public void getSapState() throws TCException {
|
|
|
|
public void getSapState() throws TCException {
|
|
|
|
TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState");
|
|
|
|
TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState");
|
|
|
|
if (unitLov != null) {
|
|
|
|
if (unitLov != null) {
|
|
|
|
ListOfValuesInfo listOfValues = unitLov.getListOfValues();
|
|
|
|
ListOfValuesInfo listOfValues = unitLov.getListOfValues();
|
|
|
|
String[] realval = listOfValues.getStringListOfValues();
|
|
|
|
String[] realval = listOfValues.getStringListOfValues();
|
|
|
|
for (int i = 0; i < realval.length; i++) {
|
|
|
|
for (int i = 0; i < realval.length; i++) {
|
|
|
|
String disval = listOfValues.getDisplayableValue(realval[i]);
|
|
|
|
String disval = listOfValues.getDisplayableValue(realval[i]);
|
|
|
|
System.out.println("显示值:" + disval + ";真实值:" + realval[i]);
|
|
|
|
System.out.println("显示值:" + disval + ";真实值:" + realval[i]);
|
|
|
|
if (disval.equals("已传")) {
|
|
|
|
if (disval.equals("已传")) {
|
|
|
|
sapState = realval[i];
|
|
|
|
sapState = realval[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TCComponentReleaseStatusType releaseType = (TCComponentReleaseStatusType) session
|
|
|
|
TCComponentReleaseStatusType releaseType = (TCComponentReleaseStatusType) session
|
|
|
|
.getTypeComponent("ReleaseStatus");
|
|
|
|
.getTypeComponent("ReleaseStatus");
|
|
|
|
|
|
|
|
|
|
|
|
released_Green = releaseType.create("ZT2_Green");
|
|
|
|
released_Green = releaseType.create("ZT2_Green");
|
|
|
|
released_Green.save();
|
|
|
|
released_Green.save();
|
|
|
|
released_Green.unlock();
|
|
|
|
released_Green.unlock();
|
|
|
|
released_Red = releaseType.create("ZT2_Red");
|
|
|
|
released_Red = releaseType.create("ZT2_Red");
|
|
|
|
released_Red.save();
|
|
|
|
released_Red.save();
|
|
|
|
released_Red.unlock();
|
|
|
|
released_Red.unlock();
|
|
|
|
released_Yellow = releaseType.create("ZT2_Yellow");
|
|
|
|
released_Yellow = releaseType.create("ZT2_Yellow");
|
|
|
|
released_Yellow.save();
|
|
|
|
released_Yellow.save();
|
|
|
|
released_Yellow.unlock();
|
|
|
|
released_Yellow.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
|
|
public static String getXML(){
|
|
|
|
public static String getXML() {
|
|
|
|
|
|
|
|
String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n"
|
|
|
|
String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n"
|
|
|
|
+ " <soapenv:Header/>\r\n" + " <soapenv:Body>\r\n" + " <urn:MT_MATERIAL_BOP_REQ>\r\n"
|
|
|
|
+ " <soapenv:Header/>\r\n"
|
|
|
|
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n" + " </soapenv:Body>\r\n" + "</soapenv:Envelope>";
|
|
|
|
+ " <soapenv:Body>\r\n"
|
|
|
|
|
|
|
|
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
|
|
|
|
|
|
|
|
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
|
|
|
|
|
|
|
|
+ " </soapenv:Body>\r\n"
|
|
|
|
|
|
|
|
+ "</soapenv:Envelope>";
|
|
|
|
return soapXML;
|
|
|
|
return soapXML;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
|
|
|
|
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
|
|
|
|
|
|
|
|
|
|
|
|
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
|
|
|
|
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
|
|
|
|
if(rev2.getType().equals("Part Revision")) {
|
|
|
|
if (rev2.getType().equals("Part Revision")) {
|
|
|
|
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
|
|
|
|
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
|
|
|
|
if(zt2_ifpbom.equals("P")) {
|
|
|
|
if (zt2_ifpbom.equals("P")) {
|
|
|
|
return rev2;
|
|
|
|
return rev2;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
|
|
|
|
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
|
|
|
|
if(designRev!=null) {
|
|
|
|
if (designRev != null) {
|
|
|
|
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
|
|
|
|
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
|
|
|
|
for(TCComponent matnr:matnrs) {
|
|
|
|
for (TCComponent matnr : matnrs) {
|
|
|
|
String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
|
|
|
|
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" });
|
|
|
|
if(properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) {
|
|
|
|
if (properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) {
|
|
|
|
return (TCComponentItemRevision)matnr;
|
|
|
|
return (TCComponentItemRevision) matnr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rev2;
|
|
|
|
return rev2;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public String getUserName(TCSession session) throws TCException {
|
|
|
|
|
|
|
|
TCComponentUser user = session.getUser();
|
|
|
|
public String getUserName(TCSession session) throws TCException {
|
|
|
|
session.getUserName();
|
|
|
|
TCComponentUser user = session.getUser();
|
|
|
|
return user.getTCProperty("user_name").getDisplayValue();
|
|
|
|
session.getUserName();
|
|
|
|
}
|
|
|
|
return user.getTCProperty("user_name").getDisplayValue();
|
|
|
|
public void sendSap() {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<PartBean> selectedParts = getSelectedParts();
|
|
|
|
public void sendSap() {
|
|
|
|
String now = format.format(new Date());
|
|
|
|
try {
|
|
|
|
MyProgressBarCompent comp = null;
|
|
|
|
|
|
|
|
// try {
|
|
|
|
String strs[] = session.getPreferenceService().getStringValues("database_tc");
|
|
|
|
String txtName = format2.format(new Date()) + getUserName(session);
|
|
|
|
if (SqlUtil.getTCDataConnection(strs) == null) {
|
|
|
|
String txtPath = TXTUtil.createTxt(txtName);
|
|
|
|
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
|
|
|
|
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
|
|
|
|
return;
|
|
|
|
StringBuffer errMessageAll = new StringBuffer("");
|
|
|
|
}
|
|
|
|
StringBuffer sendMessageAll = new StringBuffer("");
|
|
|
|
List<PartBean> selectedParts = getSelectedParts();
|
|
|
|
|
|
|
|
// 记录SUM表信息
|
|
|
|
//2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
|
|
|
|
String userName = session.getUser().getProperty("user_name");
|
|
|
|
project.getProperty("zt2_WBSNo");
|
|
|
|
String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
|
//产成品BOM组织时除了产成品不同,其他相同 BOM结构是一样的
|
|
|
|
String zt2_WBSNo = project.getStringProperty("zt2_WBSNo");
|
|
|
|
for(PartBean bean : selectedParts) {
|
|
|
|
String object_name = project.getStringProperty("object_name");
|
|
|
|
|
|
|
|
String userId = session.getUser().getUserId();
|
|
|
|
Document document = DocumentHelper.parseText(getXML());
|
|
|
|
String code = BomUtilWh.getCode().toString();
|
|
|
|
Element rootElement = document.getRootElement();
|
|
|
|
StringBuilder productNosBuild = new StringBuilder("");
|
|
|
|
Element body = rootElement.element("Body");
|
|
|
|
StringBuilder productUidsBuild = new StringBuilder("");
|
|
|
|
Element element = body.element("MT_MATERIAL_BOP_REQ");
|
|
|
|
for (PartBean cppItem : selectedParts) {
|
|
|
|
Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST");
|
|
|
|
String property = cppItem.part.getProperty(BomUtilWh.ZT2_MATERIALNO);
|
|
|
|
|
|
|
|
productNosBuild.append(property).append(";");
|
|
|
|
TCComponentItemRevision rev2 = getPRevision(bean.part);
|
|
|
|
productUidsBuild.append(cppItem.part.getUid()).append(";");
|
|
|
|
|
|
|
|
}
|
|
|
|
StringBuffer errMessage = new StringBuffer("");
|
|
|
|
String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1);
|
|
|
|
|
|
|
|
String serverHostname = session.getServerHostname();
|
|
|
|
|
|
|
|
SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, zt2_WBSNo, object_name,
|
|
|
|
|
|
|
|
"产成品传递", substring, project.getUid(), serverHostname, userId });
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
|
|
|
|
// 存在多个产成品时 下面的PBOM是一样的,只需要记录一次日志新的
|
|
|
|
|
|
|
|
boolean flag = true;
|
|
|
|
|
|
|
|
String batchNum = code + "-00001";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String now = format.format(new Date());
|
|
|
|
|
|
|
|
MyProgressBarCompent comp = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String txtName = format2.format(new Date()) + getUserName(session);
|
|
|
|
|
|
|
|
String txtPath = TXTUtil.createTxt(txtName);
|
|
|
|
|
|
|
|
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
|
|
|
|
|
|
|
|
StringBuffer errMessageAll = new StringBuffer("");
|
|
|
|
|
|
|
|
StringBuffer sendMessageAll = new StringBuffer("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
|
|
|
|
|
|
|
|
// project.getProperty("zt2_WBSNo");
|
|
|
|
|
|
|
|
// 产成品BOM组织时除了产成品不同,其他相同 BOM结构是一样的
|
|
|
|
|
|
|
|
// 记录产成品的物料编码
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (PartBean bean : selectedParts) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Document document = DocumentHelper.parseText(getXML());
|
|
|
|
|
|
|
|
Element rootElement = document.getRootElement();
|
|
|
|
|
|
|
|
Element body = rootElement.element("Body");
|
|
|
|
|
|
|
|
Element element = body.element("MT_MATERIAL_BOP_REQ");
|
|
|
|
|
|
|
|
Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TCComponentItemRevision rev2 = getPRevision(bean.part);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer errMessage = new StringBuffer("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BomUtilWh.checkMatnr(errMessage, rev2);
|
|
|
|
// BomUtilWh.checkMatnr(errMessage, rev2);
|
|
|
|
|
|
|
|
|
|
|
|
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindow win = bomWinType.create(null);
|
|
|
|
TCComponentBOMWindow win = bomWinType.create(null);
|
|
|
|
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null);
|
|
|
|
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null);
|
|
|
|
// 优化项:BOM全展开
|
|
|
|
//优化项:BOM全展开
|
|
|
|
System.out.println("BOM全展开");
|
|
|
|
System.out.println("BOM全展开");
|
|
|
|
Map<String, TCComponent> gy_meops = new HashMap<>(32);
|
|
|
|
Map<String, TCComponent> gy_meops = new HashMap<>(32);
|
|
|
|
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
|
|
|
|
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
|
|
|
|
// 三种情况有PBOM传PDBOM,没PBOM传EBOM,没EBOM传图纸BOM
|
|
|
|
//三种情况有PBOM传PDBOM,没PBOM传EBOM,没EBOM传图纸BOM
|
|
|
|
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
|
|
|
|
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
|
|
|
|
List<String> wbsList = new ArrayList<String>();
|
|
|
|
List<String> wbsList = new ArrayList<String>();
|
|
|
|
// 记录物料图纸关系的集合
|
|
|
|
// 记录物料图纸关系的集合
|
|
|
|
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
|
|
|
|
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
|
|
|
|
// 2024 1 24 新加字段 UID 和 BATCHNUMBER
|
|
|
|
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2,
|
|
|
|
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2, groupName, wbsList, session, now,
|
|
|
|
groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs);
|
|
|
|
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum);
|
|
|
|
System.out.println("BOM全document===>"+document.asXML());
|
|
|
|
System.out.println("BOM全document===>" + document.asXML());
|
|
|
|
if(errMessage.length()>0) {
|
|
|
|
if (errMessage.length() > 0) {
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, errMessage.toString());
|
|
|
|
TXTUtil.writeTXT(txtPath, errMessage.toString());
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
|
|
|
|
errMessageAll.append(errMessage);
|
|
|
|
errMessageAll.append(errMessage);
|
|
|
|
|
|
|
|
// new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessage.toString());
|
|
|
|
// new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessage.toString());
|
|
|
|
win.close();
|
|
|
|
win.close();
|
|
|
|
} else {
|
|
|
|
}else {
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
// 记录XML信息到CHINT_BOM_TO_SAP_DETIALS
|
|
|
|
//记录XML信息到CHINT_BOM_TO_SAP_DETIALS
|
|
|
|
if (flag) {
|
|
|
|
|
|
|
|
flag = false;
|
|
|
|
sendMessageAll.append(SendToSap(txtPath,document.asXML()));
|
|
|
|
BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbs, session);
|
|
|
|
win.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sendMessageAll.append(SendToSap(txtPath, document.asXML()));
|
|
|
|
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
|
|
|
|
win.close();
|
|
|
|
System.out.println("日志所挂对象:" + rev2);
|
|
|
|
}
|
|
|
|
KUtil.setByPass(true);
|
|
|
|
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
|
|
|
|
TXTUtil.addTxttoTarget(rev2, dataset);
|
|
|
|
System.out.println("日志所挂对象:" + rev2);
|
|
|
|
KUtil.setByPass(false);
|
|
|
|
KUtil.setByPass(true);
|
|
|
|
}
|
|
|
|
TXTUtil.addTxttoTarget(rev2, dataset);
|
|
|
|
if(comp!=null) {
|
|
|
|
KUtil.setByPass(false);
|
|
|
|
comp.setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (comp != null) {
|
|
|
|
if(errMessageAll.length()>0) {
|
|
|
|
comp.setVisible(false);
|
|
|
|
new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessageAll.toString());
|
|
|
|
}
|
|
|
|
}else if(sendMessageAll.length()>0) {
|
|
|
|
if (errMessageAll.length() > 0) {
|
|
|
|
new SAPMessageUtil("", "BOM推送异常:\n" + sendMessageAll.toString());
|
|
|
|
new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessageAll.toString());
|
|
|
|
}else {
|
|
|
|
} else if (sendMessageAll.length() > 0) {
|
|
|
|
MessageBox.post("BOM数据推送完成..","提示",2);
|
|
|
|
new SAPMessageUtil("", "BOM推送异常:\n" + sendMessageAll.toString());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} catch (Exception e) {
|
|
|
|
MessageBox.post("BOM数据推送完成..", "提示", 2);
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
}
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
public List<PartBean> getSelectedParts() throws Exception {
|
|
|
|
}
|
|
|
|
List<PartBean> selectedParts = new ArrayList<>();
|
|
|
|
|
|
|
|
int rowCnt = dialog.t_part.getRowCount();
|
|
|
|
}
|
|
|
|
for (int i = 0; i < rowCnt; i++) {
|
|
|
|
|
|
|
|
System.out.println(dialog.t_part.getValueAt(i, 0));
|
|
|
|
public List<PartBean> getSelectedParts() throws Exception {
|
|
|
|
if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) {
|
|
|
|
List<PartBean> selectedParts = new ArrayList<>();
|
|
|
|
PartBean bean = (PartBean) dialog.t_part.getValueAt(i, 5);
|
|
|
|
int rowCnt = dialog.t_part.getRowCount();
|
|
|
|
System.out.println("准备传递对象:" + bean);
|
|
|
|
for (int i = 0; i < rowCnt; i++) {
|
|
|
|
if (bean != null) {
|
|
|
|
System.out.println(dialog.t_part.getValueAt(i, 0));
|
|
|
|
/*
|
|
|
|
if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) {
|
|
|
|
* if(bean.factoryNo==null) { throw new Exception("对象<"+bean.part+">没有找到出厂编号");
|
|
|
|
PartBean bean = (PartBean) dialog.t_part.getValueAt(i, 5);
|
|
|
|
* }
|
|
|
|
System.out.println("准备传递对象:" + bean);
|
|
|
|
*/
|
|
|
|
if (bean != null) {
|
|
|
|
selectedParts.add(bean);
|
|
|
|
/*
|
|
|
|
}
|
|
|
|
* if(bean.factoryNo==null) { throw new Exception("对象<"+bean.part+">没有找到出厂编号");
|
|
|
|
}
|
|
|
|
* }
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
return selectedParts;
|
|
|
|
selectedParts.add(bean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public StringBuffer SendToSap(String txtPath,String wsdlString) throws IOException {
|
|
|
|
}
|
|
|
|
|
|
|
|
return selectedParts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StringBuffer SendToSap(String txtPath, String wsdlString) throws IOException {
|
|
|
|
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, wsdlString);
|
|
|
|
TXTUtil.writeTXT(txtPath, wsdlString);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送SAP
|
|
|
|
//推送SAP
|
|
|
|
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB");
|
|
|
|
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl");
|
|
|
|
String sapUrl = "";
|
|
|
|
String sapUrl = "";
|
|
|
|
String momUrl = "";
|
|
|
|
String momUrl = "";
|
|
|
|
for (String stringValue : stringValues) {
|
|
|
|
for(String stringValue:stringValues) {
|
|
|
|
if (stringValue.startsWith("SAP:1=")) {
|
|
|
|
if(stringValue.startsWith("SAP:1=")) {
|
|
|
|
sapUrl = stringValue.replaceAll("SAP:1=", "");
|
|
|
|
sapUrl = stringValue.replaceAll("SAP:1=", "");
|
|
|
|
} else if (stringValue.startsWith("MOM:1=")) {
|
|
|
|
}else if(stringValue.startsWith("MOM:1=")) {
|
|
|
|
momUrl = stringValue.replaceAll("MOM:1=", "");
|
|
|
|
momUrl = stringValue.replaceAll("MOM:1=", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StringBuffer sendSap = sendSap(sapUrl, wsdlString, txtPath);
|
|
|
|
StringBuffer sendSap = sendSap(sapUrl,wsdlString,txtPath);
|
|
|
|
StringBuffer sendMom = sendMom(momUrl, wsdlString, txtPath);
|
|
|
|
StringBuffer sendMom = sendMom(momUrl,wsdlString,txtPath);
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
if (sendSap.length() > 0) {
|
|
|
|
if(sendSap.length()>0) {
|
|
|
|
errBuffer.append("推送SAP异常:").append("\n");
|
|
|
|
errBuffer.append("推送SAP异常:").append("\n");
|
|
|
|
errBuffer.append(sendSap);
|
|
|
|
errBuffer.append(sendSap);
|
|
|
|
// new SAPMessageUtil("", "s:\n" + errBuffer.toString());
|
|
|
|
//new SAPMessageUtil("", "s:\n" + errBuffer.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sendMom.length() > 0) {
|
|
|
|
if(sendMom.length()>0) {
|
|
|
|
errBuffer.append("推送MOM异常:").append("\n");
|
|
|
|
errBuffer.append("推送MOM异常:").append("\n");
|
|
|
|
errBuffer.append(sendMom);
|
|
|
|
errBuffer.append(sendMom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if(errBuffer.length()>0) {
|
|
|
|
// if(errBuffer.length()>0) {
|
|
|
|
// new SAPMessageUtil("", "推送结果异常:\n" + errBuffer.toString());
|
|
|
|
// new SAPMessageUtil("", "推送结果异常:\n" + errBuffer.toString());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public StringBuffer sendSap(String url,String wsdlString,String txtPath) throws IOException {
|
|
|
|
public StringBuffer sendSap(String url, String wsdlString, String txtPath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
if(!url.contains("http")) {
|
|
|
|
if (!url.contains("http")) {
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
|
client.setConnectTimeout(100, TimeUnit.SECONDS);
|
|
|
|
client.setConnectTimeout(100, TimeUnit.SECONDS);
|
|
|
|
client.setReadTimeout(100, TimeUnit.SECONDS);
|
|
|
|
client.setReadTimeout(100, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
// Authenticator authenticator = client.setAuthenticator(new Au);
|
|
|
|
// Authenticator authenticator = client.setAuthenticator(new Au);
|
|
|
|
String credential = "";// Credentials.basic("shpodev", "sap@2019");
|
|
|
|
String credential = "";//Credentials.basic("shpodev", "sap@2019");
|
|
|
|
if (url.contains("192.168.0.184") || url.contains("gfpot01")) {
|
|
|
|
if(url.contains("192.168.0.184")) {
|
|
|
|
credential = Credentials.basic("po_rfc", "1qaz!QAZ");
|
|
|
|
credential = Credentials.basic("shpodev", "sap@2019");
|
|
|
|
} else {
|
|
|
|
}else {
|
|
|
|
credential = Credentials.basic("shplm", "sap@2019");
|
|
|
|
credential = Credentials.basic("shplm", "sap@2019");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MediaType mediaType = MediaType.parse("application/xml");
|
|
|
|
MediaType mediaType = MediaType.parse("application/xml");
|
|
|
|
RequestBody body = RequestBody.create(mediaType, wsdlString);
|
|
|
|
RequestBody body = RequestBody.create(mediaType,wsdlString);
|
|
|
|
// http://192.168.0.184:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_CHINT_ELECTRIC&receiverParty=&receiverService=&interface=SIO_MATERIAL_BOP_PLM_SYN&interfaceNamespace=urn:chintelectric.com:xi:plm
|
|
|
|
//http://192.168.0.184:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_CHINT_ELECTRIC&receiverParty=&receiverService=&interface=SIO_MATERIAL_BOP_PLM_SYN&interfaceNamespace=urn:chintelectric.com:xi:plm
|
|
|
|
Request request = new Request.Builder().url(url).method("POST", body).header("Authorization", credential)
|
|
|
|
Request request = new Request.Builder()
|
|
|
|
.addHeader("Content-Type", "application/xml").build();
|
|
|
|
.url(url)
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
|
.method("POST", body)
|
|
|
|
Document document = null;
|
|
|
|
.header("Authorization", credential)
|
|
|
|
|
|
|
|
.addHeader("Content-Type", "application/xml")
|
|
|
|
try {
|
|
|
|
.build();
|
|
|
|
String string = response.body().string();
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
|
|
|
|
|
Document document = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String string = response.body().string();
|
|
|
|
// System.out.println("response.body().string()==>"+string);
|
|
|
|
// System.out.println("response.body().string()==>"+string);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, string);
|
|
|
|
TXTUtil.writeTXT(txtPath, string);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
|
|
|
|
// document = DocumentHelper.parseText(string);
|
|
|
|
document = DocumentHelper.parseText(string);
|
|
|
|
// Element rootElement = document.getRootElement();
|
|
|
|
Element rootElement = document.getRootElement();
|
|
|
|
// Element bodys = rootElement.element("Body");
|
|
|
|
Element bodys = rootElement.element("Body");
|
|
|
|
// Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
|
|
|
|
Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
|
|
|
|
//// String attributeValue = elements.get(0).attributeValue("CODE");
|
|
|
|
// String attributeValue = elements.get(0).attributeValue("CODE");
|
|
|
|
// List<Element> ztable = elements.elements("ZTABLE_RETURN");
|
|
|
|
List<Element> ztable = elements.elements("ZTABLE_RETURN");
|
|
|
|
// for (Element zret : ztable) {
|
|
|
|
for(Element zret:ztable) {
|
|
|
|
// String status = zret.elementText("TYPE");
|
|
|
|
String status = zret.elementText("TYPE");
|
|
|
|
// if (status.equals("E")) {
|
|
|
|
if(status.equals("E")) {
|
|
|
|
// String attributeValue = zret.elementText("MESSAGE");
|
|
|
|
String attributeValue = zret.elementText("MESSAGE");
|
|
|
|
// String MATNR = zret.elementText("MATNR");
|
|
|
|
String MATNR = zret.elementText("MATNR");
|
|
|
|
// if (MATNR != null) {
|
|
|
|
if(MATNR!=null) {
|
|
|
|
// attributeValue = attributeValue + ",在" + MATNR + "BOM中";
|
|
|
|
attributeValue = attributeValue+",在"+MATNR+"BOM中";
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
|
|
|
|
// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
|
|
|
|
// System.out.println(attributeValue);
|
|
|
|
System.out.println(attributeValue);
|
|
|
|
// errBuffer.append(attributeValue).append("\n");
|
|
|
|
errBuffer.append(attributeValue).append("\n");
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (DocumentException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
// if(errBuffer.length()>0) {
|
|
|
|
// if(errBuffer.length()>0) {
|
|
|
|
// new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString());
|
|
|
|
// new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String sendJsonHttpPost(String url, String xmlContent,String txtPath) {
|
|
|
|
public String sendJsonHttpPost(String url, String xmlContent, String txtPath) {
|
|
|
|
|
|
|
|
|
|
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
|
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
|
|
|
String responseInfo = null;
|
|
|
|
String responseInfo = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
|
// 设置请求头部
|
|
|
|
// 设置请求头部
|
|
|
|
httpPost.setHeader("Content-Type", "application/xml");
|
|
|
|
httpPost.setHeader("Content-Type", "application/xml");
|
|
|
|
|
|
|
|
|
|
|
|
// 设置请求体
|
|
|
|
// 设置请求体
|
|
|
|
StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8);
|
|
|
|
StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
|
|
|
|
if(url.contains("10.128.11.12")) {
|
|
|
|
if (url.contains("10.128.11.12")) {
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg=");
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg=");
|
|
|
|
|
|
|
|
// http://10.128.11.12:7788/gateway/chint/bop-sync
|
|
|
|
// http://10.128.11.12:7788/gateway/chint/bop-sync
|
|
|
|
} else {
|
|
|
|
}else {
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg=");
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg=");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
httpPost.setEntity(entityReq);
|
|
|
|
httpPost.setEntity(entityReq);
|
|
|
|
|
|
|
|
|
|
|
|
CloseableHttpResponse response = httpclient.execute(httpPost);
|
|
|
|
CloseableHttpResponse response = httpclient.execute(httpPost);
|
|
|
|
HttpEntity entity = response.getEntity();
|
|
|
|
HttpEntity entity = response.getEntity();
|
|
|
|
int status = response.getStatusLine().getStatusCode();
|
|
|
|
int status = response.getStatusLine().getStatusCode();
|
|
|
|
String string = EntityUtils.toString(entity);
|
|
|
|
String string = EntityUtils.toString(entity);
|
|
|
|
System.out.println("MOM status:" + status + "responseInfo:" + string);
|
|
|
|
System.out.println("MOM status:" + status + "responseInfo:" + string);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递MOM结果--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递MOM结果--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "MOM status:" + status);
|
|
|
|
TXTUtil.writeTXT(txtPath, "MOM status:" + status);
|
|
|
|
TXTUtil.writeTXT(txtPath, "responseInfo:" + string);
|
|
|
|
TXTUtil.writeTXT(txtPath, "responseInfo:" + string);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递MOM结果-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递MOM结果-----------");
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
httpclient.close();
|
|
|
|
httpclient.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return responseInfo;
|
|
|
|
return responseInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public StringBuffer sendMom(String url,String wsdlString,String txtPath) throws IOException {
|
|
|
|
public StringBuffer sendMom(String url, String wsdlString, String txtPath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
if (!url.contains("http")) {
|
|
|
|
if(!url.contains("http")) {
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String string = sendJsonHttpPost(url, wsdlString, txtPath); // "http://10.128.11.12:7788/gateway/chint/bop-sync"
|
|
|
|
String string = sendJsonHttpPost(url,wsdlString,txtPath); //"http://10.128.11.12:7788/gateway/chint/bop-sync"
|
|
|
|
|
|
|
|
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|