diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/Message_zh_CN.properties b/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/Message_zh_CN.properties index e1b09a2..b97fb23 100644 --- a/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/Message_zh_CN.properties +++ b/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/Message_zh_CN.properties @@ -1,7 +1,3 @@ ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61 -<<<<<<< HEAD ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01 -SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210 -======= -ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01 ->>>>>>> 65c5903c8f3927b85b3c68d928802214a146ec48 +SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210 \ No newline at end of file diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$1.class b/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$1.class index 3d1eed2..d06ae72 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$1.class and b/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$2.class b/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$2.class index 77c14af..ce2c986 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$2.class and b/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh$2.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh.class b/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh.class index 4adb4a2..94f7f41 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh.class and b/com.connor.chint.wuhan/bin/com/connor/chint/sap2/util/BomUtilWh.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSapWhBjOp.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSapWhBjOp.class index 02769b3..1087a64 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSapWhBjOp.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSapWhBjOp.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapController.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapController.class index 82fc347..ffa7a80 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapController.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapController.class differ diff --git a/com.connor.chint.wuhan/plugin.xml b/com.connor.chint.wuhan/plugin.xml index aa402a2..21f830c 100644 --- a/com.connor.chint.wuhan/plugin.xml +++ b/com.connor.chint.wuhan/plugin.xml @@ -3,8 +3,8 @@ - - + + @@ -18,19 +18,19 @@ - - - - - - - - - - - + + + + + + + + + + + - + @@ -44,33 +44,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - - - + @@ -133,310 +133,310 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + @@ -521,30 +521,30 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - + diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java index 1a4a7f9..96aa7ff 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java @@ -74,11 +74,7 @@ public class ExtractDiffComd extends KCommand { return; } readChangeDesign(oldComponents, newComponents, tar); -<<<<<<< HEAD MessageBox.post(resource.getString("SUCC_CHANGE"), "", 2); -======= - ->>>>>>> 65c5903c8f3927b85b3c68d928802214a146ec48 } catch (TCException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -154,16 +150,10 @@ public class ExtractDiffComd extends KCommand { ChangeDesignBean changeDesignBean = itemChangeMap.get(keyItem); TCComponentItemRevision oldDesgin = changeDesignBean.getOldDesgin(); Map materialOld = getMaterialByDesign(oldDesgin); -<<<<<<< HEAD System.out.println("materialOld===>" + materialOld.toString()); TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin(); Map materialNew = getMaterialByDesign(newDesgin); -======= - TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin(); - Map materialNew = getMaterialByDesign(newDesgin); - System.out.println("materialOld===>" + materialOld.toString()); ->>>>>>> 65c5903c8f3927b85b3c68d928802214a146ec48 System.out.println("materialNew===>" + materialNew.toString()); // ȽϱǰBOM for (String materialNo : materialOld.keySet()) { @@ -327,11 +317,8 @@ public class ExtractDiffComd extends KCommand { if (pbomMap.containsKey(materialNo)) { PBomBean pBomBean = pbomMap.get(materialNo); // ǷPBOM -<<<<<<< HEAD System.out.println("matnrProps[1]===>" + matnrProps[1]); System.out.println("matnrProps[2]===>" + matnrProps[2] + "pBomBean.getpRevision()"+pBomBean.getpRevision()); -======= ->>>>>>> 65c5903c8f3927b85b3c68d928802214a146ec48 if (matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.getpRevision()) > 0) { pBomBean.setpMaterial(represent); pBomBean.setpRevision(matnrProps[2]); diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/Message_zh_CN.properties b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/Message_zh_CN.properties index e1b09a2..b97fb23 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/Message_zh_CN.properties +++ b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/Message_zh_CN.properties @@ -1,7 +1,3 @@ ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61 -<<<<<<< HEAD ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01 -SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210 -======= -ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01 ->>>>>>> 65c5903c8f3927b85b3c68d928802214a146ec48 +SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210 \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/connor/chint/sap2/util/BomUtilWh.java b/com.connor.chint.wuhan/src/com/connor/chint/sap2/util/BomUtilWh.java index aa13846..753939e 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/sap2/util/BomUtilWh.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/sap2/util/BomUtilWh.java @@ -1,5 +1,7 @@ package com.connor.chint.sap2.util; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -40,8 +42,26 @@ public class BomUtilWh { public static final String WH_FACOTRY = "M060"; public static final String PARENTTCID = "PARENTTCID"; public static final String PARENTWLBM = "PARENTWLBM"; + public static final String ZT2_WBSNO = "zt2_WBSNo"; + public static final String ZT2_MATERIALNO = "zt2_MaterialNo"; public static final String SPLIT_MSG = "/"; public static final String UID = "UID"; + public static final String detailsSql = "insert into CHINT_BOM_TO_SAP_SUM (code,factory,\"USER\",starttime,wbsno,projectno,taskstauts" + + ",plmresult,transfer,keymsg,sapresult,PROJECTUID,SERVERHOST,USERID) values " + + "(?,?,?,to_date(?,'yyyy-mm-ddhh24:mi:ss')" + ",?,?,'֯','δ',?,?,'δ',?,?,?)"; + // ȡBOM + public static Integer getCode() throws SQLException { + String sql = "select Tab_SendBom_Sequence.nextval as sid from dual"; + ResultSet rs = SqlUtil.read(sql); + Object objs[] = new Object[1]; + int code = 0; + if (rs.next()) { + code = rs.getInt(1); + System.out.println("code:" + code); + } + SqlUtil.free(); + return code; + } /** * дBOMͷϢDETAILS @@ -51,21 +71,21 @@ public class BomUtilWh { * @param productNos Ʒϱ * @function */ - public static void logXmlMsg(Document interGrationList, String code, String productNos, String batchNo, + public static void logXmlMsg(Element interGrationList, String code, String productNos, String batchNo, String wbsNo, TCSession session) { String strs[] = session.getPreferenceService().getStringValues(DATABASE_TC); SqlUtil.getTCDataConnection(strs); try { - Element rootElement = interGrationList.getRootElement(); // Ϣ - Element element = rootElement.element(WLLIST); + Element element = interGrationList.element(WLLIST); List elements = element.elements(WLCONTENTS); for (Element content : elements) { // ¼TCid UID ϱ - String tcId = content.elementText(PARENTTCID); + Element bomContents = content.element("BOMCONTENTS"); + String tcId = bomContents.elementText(PARENTTCID); String[] split = tcId.split(SPLIT_MSG); - String parentMantrNo = content.elementText(PARENTWLBM); - String uid = content.elementText(UID); + String parentMantrNo = bomContents.elementText(PARENTWLBM); + String uid = bomContents.elementText(UID); SqlUtil.write(logSql, new String[] { code, batchNo, WH_FACOTRY, productNos, split[0], uid, parentMantrNo, wbsNo }); } @@ -1176,7 +1196,7 @@ public class BomUtilWh { TCComponentItemRevision pRev, String groupName, List wbsList, TCSession session, String now, List needTCM_meops, Map gy_meops, Element INTERGRATIONLIST, StringBuffer errMessage, List cppRevision, String txtPath, - Map material_revs) { + Map material_revs, String batchNum) { try { String uid = pBomLine.getUid(); @@ -1274,6 +1294,8 @@ public class BomUtilWh { BOMCONTENTS.addElement("QUANTITY").setText(properties[3]); BOMCONTENTS.addElement("QUIT") .setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); + BOMCONTENTS.addElement("UID").setText(pRev.getUid()); + BOMCONTENTS.addElement("BATCHNUMBER").setText(batchNum); Element SONLIST = BOMCONTENTS.addElement("SONLIST"); // ȡϢ BOPLIST BOPCONTENTS µĸϷŵӼ String maxSeq = "10"; @@ -1310,11 +1332,7 @@ public class BomUtilWh { material_revs.put(properties2[2], rev2); } expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops, - INTERGRATIONLIST, errMessage, txtPath, material_revs); - -// if (!KUtil.isEmpty(zt2_materialNo)) { -// material_revs.put(zt2_materialNo, part2Rev); -// } + INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum); } AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" }); @@ -1530,7 +1548,7 @@ public class BomUtilWh { TCComponentItemRevision pRev, String groupName, List wbsList, TCSession session, String now, List needTCM_meops, Map gy_meops, Element INTERGRATIONLIST, StringBuffer errMessage, String txtPath, - Map material_revs) { + Map material_revs, String batchNum) { try { String uid = pBomLine.getUid(); @@ -1621,6 +1639,10 @@ public class BomUtilWh { BOMCONTENTS.addElement("QUANTITY").setText(properties[3]); BOMCONTENTS.addElement("QUIT") .setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); + //ֶUIDκ + BOMCONTENTS.addElement("UID").setText(pRev.getUid()); + BOMCONTENTS.addElement("BATCHNUMBER").setText(batchNum); + Element SONLIST = BOMCONTENTS.addElement("SONLIST"); // ȡϢ BOPLIST BOPCONTENTS µĸϷŵӼ String maxSeq = "10"; @@ -1665,7 +1687,7 @@ public class BomUtilWh { material_revs.put(properties2[2], rev2); } expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops, - INTERGRATIONLIST, errMessage, txtPath, material_revs); + INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum); } AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java index 1f27f13..7f0c948 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java @@ -18,6 +18,7 @@ import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.SAPMessageUtil; import com.connor.chint.sap2.util.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPUtil; +import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.TXTUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFOperation; @@ -40,202 +41,246 @@ import com.teamcenter.rac.util.MessageBox; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; public class BomSapWhBjOp extends AbstractAIFOperation { - private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); - private AbstractAIFApplication app; - private TCSession session; - private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); - private String now; - private String groupName = ""; - private TCComponentItemType ccomponentitemtype; - public BomSapWhBjOp(AbstractAIFApplication app) { - // TODO Auto-generated constructor stub - this.app = app; - this.session = (TCSession) app.getSession(); - now = format.format(new Date()); - try { - ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D"); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public List getCPPPRevision(TCComponentItemRevision rev2) throws TCException { - - List itemList = new ArrayList<>(); - List itemPList = new ArrayList<>(); - String id = "1ZDB300000P-"; - if(rev2.getType().equals("Part Revision")) { - String desc = rev2.getStringProperty("object_desc"); - String[] split = desc.split(" "); - if(split.length>=2) { - String[] split2 = split[1].split("-"); - if(split2.length==2) { - id = id + split2[1]; - }else if(split2.length==3) { - id = id + split2[2]; - } - } - }else if(rev2.getType().equals("ZT2_Design3DRevision")) { - String desc = rev2.getStringProperty("item_id"); - String[] split2 = desc.split("-"); - if(split2.length==2) { - id = id + split2[1]; - }else if(split2.length==3) { - id = id + split2[2]; - } - } - System.out.print("id===>"+id); - TCComponentItem find = ccomponentitemtype.find(id); - TCComponentItemRevision zztRev = find.getLatestItemRevision(); - TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for"); - for(TCComponent matnr:matnrs) { - String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom"}); - TCComponentItemRevision revItem = (TCComponentItemRevision)matnr; - TCComponentItem item = revItem.getItem(); - if(properties[0].equals("P") && !itemPList.contains(item)) { - itemPList.add(item); - }else if(!itemList.contains(item)){ - itemList.add(item); - } - } - if(itemPList.size()>0) { - return itemPList; - } - return itemList; - - } - public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { - - String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); - if(rev2.getType().equals("Part Revision")) { - String zt2_ifpbom = rev2.getProperty("zt2_ifpbom"); - if(zt2_ifpbom.equals("P")) { - return rev2; - }else { - TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By"); - if(designRev!=null) { - TCComponent[] matnrs = designRev.getRelatedComponents("representation_for"); - for(TCComponent matnr:matnrs) { - String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"}); - if(properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) { - return (TCComponentItemRevision)matnr; - } - } - } - } - }else if(rev2.getType().equals("ZT2_Design3DRevision")) { - TCComponent[] matnrs = rev2.getRelatedComponents("representation_for"); - for(TCComponent matnr:matnrs) { - String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"}); - if(properties[0].equals("P")) { - return (TCComponentItemRevision)matnr; - } - } - return (TCComponentItemRevision)matnrs[0]; - } - return rev2; - - } - public static String getXML(){ + private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); + private AbstractAIFApplication app; + private TCSession session; + private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + private String now; + private String groupName = ""; + private TCComponentItemType ccomponentitemtype; + + public BomSapWhBjOp(AbstractAIFApplication app) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = (TCSession) app.getSession(); + now = format.format(new Date()); + try { + ccomponentitemtype = (TCComponentItemType) session.getTypeComponent("ZT2_Design3D"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public List getCPPPRevision(TCComponentItemRevision rev2) throws TCException { + + List itemList = new ArrayList<>(); + List itemPList = new ArrayList<>(); + String id = "1ZDB300000P-"; + if (rev2.getType().equals("Part Revision")) { + String desc = rev2.getStringProperty("object_desc"); + String[] split = desc.split(" "); + if (split.length >= 2) { + String[] split2 = split[1].split("-"); + if (split2.length == 2) { + id = id + split2[1]; + } else if (split2.length == 3) { + id = id + split2[2]; + } + } + } else if (rev2.getType().equals("ZT2_Design3DRevision")) { + String desc = rev2.getStringProperty("item_id"); + String[] split2 = desc.split("-"); + if (split2.length == 2) { + id = id + split2[1]; + } else if (split2.length == 3) { + id = id + split2[2]; + } + } + System.out.print("id===>" + id); + TCComponentItem find = ccomponentitemtype.find(id); + TCComponentItemRevision zztRev = find.getLatestItemRevision(); + TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for"); + for (TCComponent matnr : matnrs) { + String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom" }); + TCComponentItemRevision revItem = (TCComponentItemRevision) matnr; + TCComponentItem item = revItem.getItem(); + if (properties[0].equals("P") && !itemPList.contains(item)) { + itemPList.add(item); + } else if (!itemList.contains(item)) { + itemList.add(item); + } + } + if (itemPList.size() > 0) { + return itemPList; + } + return itemList; + + } + + public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { + + String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); + if (rev2.getType().equals("Part Revision")) { + String zt2_ifpbom = rev2.getProperty("zt2_ifpbom"); + if (zt2_ifpbom.equals("P")) { + return rev2; + } else { + TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By"); + if (designRev != null) { + TCComponent[] matnrs = designRev.getRelatedComponents("representation_for"); + for (TCComponent matnr : matnrs) { + String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" }); + if (properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) { + return (TCComponentItemRevision) matnr; + } + } + } + } + } else if (rev2.getType().equals("ZT2_Design3DRevision")) { + TCComponent[] matnrs = rev2.getRelatedComponents("representation_for"); + for (TCComponent matnr : matnrs) { + String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" }); + if (properties[0].equals("P")) { + return (TCComponentItemRevision) matnr; + } + } + return (TCComponentItemRevision) matnrs[0]; + } + return rev2; + + } + + public static String getXML() { String soapXML = "\r\n" - + " \r\n" - + " \r\n" - + " \r\n" - + " \r\n" - + " \r\n" - + ""; + + " \r\n" + " \r\n" + " \r\n" + + " \r\n" + " \r\n" + ""; return soapXML; } - @Override - public void executeOperation() throws Exception { - // TODO Auto-generated method stub - MyProgressBarCompent comp = null; - try { - groupName = SAPUtil.getGroupID(session); - if (KUtil.isEmpty(groupName) || groupName.equalsIgnoreCase("dba")) { - MessageBox.post("ǰ¼[" + groupName + "]ʹøù", "", MessageBox.INFORMATION); - return; - } - - InterfaceAIFComponent target = app.getTargetComponent(); - if (target == null) { - MessageBox.post("ѡͼֽ汾", "", MessageBox.INFORMATION); - return; - } - TCComponentItemRevision degignRev = null; - // String bmeng = "1"; - if (target.getType().equals("ZT2_Design3DRevision")) { - degignRev = (TCComponentItemRevision) target; - - } else if (target.getType().equals("Part Revision")) { - degignRev = (TCComponentItemRevision) target; - // bmeng = SAPUtil.getSAPBMENG(degignRev); - } else { - MessageBox.post("ѡͼֽ/ϰ汾", "", MessageBox.INFORMATION); - return; - } - - comp = new MyProgressBarCompent("", "ڽвBOMSAP...."); - TCComponentItemRevision pRevision = getPRevision(degignRev); //ȡPBOM - List cppRevision = getCPPPRevision(degignRev); - //ȡƷ - System.out.println("cppRevision===>"+cppRevision.toString()); - List wbsList = new ArrayList(); - - StringBuffer errMessage = new StringBuffer(""); - - BomUtilWh.checkMatnr(errMessage, pRevision); - - TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); - TCComponentBOMWindow win = bomWinType.create(null); - TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(pRevision.getItem(), pRevision, null, null); - //ŻBOMȫչ - System.out.println("BOMȫչ"); - Map gy_meops = new HashMap<>(32); - - String txtName = format2.format(new Date()) + getUserName(session); - String txtPath = TXTUtil.createTxt(txtName); - - 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"); - Map bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine); - List needTCM_meops = new ArrayList(); - Map material_revs = new HashMap<>(); - BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision, - groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,cppRevision,txtPath,material_revs); - System.out.println("BOMȫdocument===>"+document.asXML()); - if(errMessage.length()>0) { - TXTUtil.writeTXT(txtPath, "----------------BOM쳣--------------"); - TXTUtil.writeTXT(txtPath, errMessage.toString()); - TXTUtil.writeTXT(txtPath, "----------BOMϢ-----------"); - new SAPMessageUtilFram("", "BOMSAP쳣:\n" + errMessage.toString()).show(); - win.close(); - }else { - new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation(); - win.close(); - } - if (comp != null) { - comp.setVisible(false); - } - TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); - System.out.println("־Ҷ:" + pRevision); - KUtil.setByPass(true); - TXTUtil.addTxttoTarget(pRevision, dataset); - MessageBox.post("BOM..","ʾ",2); - } catch (Exception e) { - e.printStackTrace(); - } finally { - KUtil.setByPass(false); - } - } - public String getUserName(TCSession session) throws TCException { - TCComponentUser user = session.getUser(); - session.getUserName(); - return user.getTCProperty("user_name").getDisplayValue(); - } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + MyProgressBarCompent comp = null; + try { + + String strs[] = session.getPreferenceService().getStringValues("database_tc"); + if (SqlUtil.getTCDataConnection(strs) == null) { + MessageBox.post("ݿʧ,ѡ", "", 2); + return; + } + String code = BomUtilWh.getCode().toString(); + + + String batchNum = code + "-00001"; + + groupName = SAPUtil.getGroupID(session); + if (KUtil.isEmpty(groupName) || groupName.equalsIgnoreCase("dba")) { + MessageBox.post("ǰ¼[" + groupName + "]ʹøù", "", MessageBox.INFORMATION); + return; + } + + InterfaceAIFComponent target = app.getTargetComponent(); + if (target == null) { + MessageBox.post("ѡͼֽ汾", "", MessageBox.INFORMATION); + return; + } + TCComponentItemRevision degignRev = null; + // String bmeng = "1"; + if (target.getType().equals("ZT2_Design3DRevision")) { + degignRev = (TCComponentItemRevision) target; + + } else if (target.getType().equals("Part Revision")) { + degignRev = (TCComponentItemRevision) target; + // bmeng = SAPUtil.getSAPBMENG(degignRev); + } else { + MessageBox.post("ѡͼֽ/ϰ汾", "", MessageBox.INFORMATION); + return; + } + + comp = new MyProgressBarCompent("", "ڽвBOMSAP...."); + TCComponentItemRevision pRevision = getPRevision(degignRev); // ȡPBOM + List cppRevision = getCPPPRevision(degignRev); + // ȡƷ + System.out.println("cppRevision===>" + cppRevision.toString()); + + //¼SUMϢ + String userName = session.getUser().getProperty("user_name"); + String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); +// String zt2_WBSNo = project.getStringProperty("zt2_WBSNo"); +// String object_name = project.getStringProperty("object_name"); + String userId = session.getUser().getUserId(); +// String code = BomUtilWh.getCode().toString(); + StringBuilder productNosBuild = new StringBuilder(""); + StringBuilder productUidsBuild = new StringBuilder(""); + for(TCComponentItem cppItem:cppRevision) { + TCComponentItemRevision latestItemRevision = cppItem.getLatestItemRevision(); + String property = latestItemRevision.getProperty(BomUtilWh.ZT2_MATERIALNO); + productNosBuild.append(property).append(";"); + productUidsBuild.append(latestItemRevision.getUid()).append(";"); + } + String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1); + String serverHostname = session.getServerHostname(); + String wbsNo = cppRevision.get(0).getLatestItemRevision().getProperty(BomUtilWh.ZT2_WBSNO); + SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, wbsNo, + "", "", substring, "", serverHostname, userId }); + + SqlUtil.freeAll(); + List wbsList = new ArrayList(); + + StringBuffer errMessage = new StringBuffer(""); + + BomUtilWh.checkMatnr(errMessage, pRevision); + + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow win = bomWinType.create(null); + TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(pRevision.getItem(), pRevision, null, null); + // ŻBOMȫչ + System.out.println("BOMȫչ"); + Map gy_meops = new HashMap<>(32); + + String txtName = format2.format(new Date()) + getUserName(session); + String txtPath = TXTUtil.createTxt(txtName); + + 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"); + Map bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine); + List needTCM_meops = new ArrayList(); + Map material_revs = new HashMap<>(); + BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision, groupName, wbsList, session, now, + needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, cppRevision, txtPath, material_revs, batchNum); + System.out.println("BOMȫdocument===>" + document.asXML()); + if (errMessage.length() > 0) { + TXTUtil.writeTXT(txtPath, "----------------BOM쳣--------------"); + TXTUtil.writeTXT(txtPath, errMessage.toString()); + TXTUtil.writeTXT(txtPath, "----------BOMϢ-----------"); +// BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, pRevision.getProperty(BomUtilWh.ZT2_WBSNO), session); + new SAPMessageUtilFram("", "BOMSAP쳣:\n" + errMessage.toString()).show(); + win.close(); + } else { + //¼Ʒϱ +// StringBuilder productNosBuild = new StringBuilder(""); +// for(TCComponentItem cppItem:cppRevision) { +// String property = cppItem.getLatestItemRevision().getProperty(BomUtilWh.ZT2_MATERIALNO); +// productNosBuild.append(property).append(";"); +// } + BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbsNo, session); + new BomSendSapOp(session, document.asXML(), txtPath, gy_meops).executeOperation(); + win.close(); + } + if (comp != null) { + comp.setVisible(false); + } + TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); + System.out.println("־Ҷ:" + pRevision); + KUtil.setByPass(true); + TXTUtil.addTxttoTarget(pRevision, dataset); + MessageBox.post("BOM..", "ʾ", 2); + } catch (Exception e) { + e.printStackTrace(); + } finally { + KUtil.setByPass(false); + SqlUtil.freeAll(); + } + } + + public String getUserName(TCSession session) throws TCException { + TCComponentUser user = session.getUser(); + session.getUserName(); + return user.getTCProperty("user_name").getDisplayValue(); + } } diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapController.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapController.java index 07669a5..53c0d1a 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapController.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapController.java @@ -32,6 +32,7 @@ import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.SAPMessageUtil; import com.connor.chint.sap2.util.SAPUtil; +import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.TXTUtil; import com.squareup.okhttp.Credentials; import com.squareup.okhttp.MediaType; @@ -62,375 +63,411 @@ import com.teamcenter.rac.util.MessageBox; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; public class BomSendSapController { - - public static final String TYPE_REV_PART = "Part Revision"; - public TCComponent project; //ĿϢ - public String groupName; - public String zt2_ProjectNo; - public String wbs; - public AbstractAIFApplication app; - private TCSession session; - public List partList = new ArrayList<>(); - public BomSendSapWhFram dialog; - private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); - public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) { - this.app = app; - this.session = (TCSession) app.getSession(); - } - - // ѡĿǷڲƷ - public boolean checkTargets() throws Exception { - InterfaceAIFComponent target = app.getTargetComponent(); - if (target == null || !(target instanceof TCComponent)) { - return false; - } - project = (TCComponent) target; - - zt2_ProjectNo = project.getProperty("zt2_ProjectNo"); - wbs = project.getProperty("zt2_WBSNo"); - System.out.println("" + target); - List partRevList = KUtil.getCCPFromProject(project); - - for(TCComponentItemRevision rev:partRevList) { - String cType = rev.getType(); + + public static final String TYPE_REV_PART = "Part Revision"; + public TCComponent project; // ĿϢ + public String groupName; + public String zt2_ProjectNo; + public String wbs; + public AbstractAIFApplication app; + private TCSession session; + public List partList = new ArrayList<>(); + public BomSendSapWhFram dialog; + private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); + + public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) { + this.app = app; + this.session = (TCSession) app.getSession(); + } + + // ѡĿǷڲƷ + public boolean checkTargets() throws Exception { + InterfaceAIFComponent target = app.getTargetComponent(); + if (target == null || !(target instanceof TCComponent)) { + return false; + } + project = (TCComponent) target; + + zt2_ProjectNo = project.getProperty("zt2_ProjectNo"); + wbs = project.getProperty("zt2_WBSNo"); + System.out.println("" + target); + List partRevList = KUtil.getCCPFromProject(project); + + for (TCComponentItemRevision rev : partRevList) { + String cType = rev.getType(); // System.out.println(">> ҵӶ" + cName + "|" + cType); - if (TYPE_REV_PART.equals(cType)) { - PartBean bean = new PartBean(rev, partList.size() + 1,""); - SAPPushBOMBean.readUser(bean, rev, groupName, session); - bean.setPSPID(project.getProperty("zt2_ProjectNo")); - partList.add(bean); - } - } - if (partList.size() == 0) { - return false; - } - return true; - } - - public String sapState = ""; - private TCComponent released_Red; - private TCComponent released_Yellow; - private TCComponent released_Green; - - public void getSapState() throws TCException { - TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState"); - if (unitLov != null) { - ListOfValuesInfo listOfValues = unitLov.getListOfValues(); - String[] realval = listOfValues.getStringListOfValues(); - for (int i = 0; i < realval.length; i++) { - String disval = listOfValues.getDisplayableValue(realval[i]); - System.out.println("ʾֵ:" + disval + ";ʵֵ:" + realval[i]); - if (disval.equals("Ѵ")) { - sapState = realval[i]; - } - - } - - } - - TCComponentReleaseStatusType releaseType = (TCComponentReleaseStatusType) session - .getTypeComponent("ReleaseStatus"); - - released_Green = releaseType.create("ZT2_Green"); - released_Green.save(); - released_Green.unlock(); - released_Red = releaseType.create("ZT2_Red"); - released_Red.save(); - released_Red.unlock(); - released_Yellow = releaseType.create("ZT2_Yellow"); - released_Yellow.save(); - released_Yellow.unlock(); - } - private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); - - public static String getXML(){ + if (TYPE_REV_PART.equals(cType)) { + PartBean bean = new PartBean(rev, partList.size() + 1, ""); + SAPPushBOMBean.readUser(bean, rev, groupName, session); + bean.setPSPID(project.getProperty("zt2_ProjectNo")); + partList.add(bean); + } + } + if (partList.size() == 0) { + return false; + } + return true; + } + + public String sapState = ""; + private TCComponent released_Red; + private TCComponent released_Yellow; + private TCComponent released_Green; + + public void getSapState() throws TCException { + TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState"); + if (unitLov != null) { + ListOfValuesInfo listOfValues = unitLov.getListOfValues(); + String[] realval = listOfValues.getStringListOfValues(); + for (int i = 0; i < realval.length; i++) { + String disval = listOfValues.getDisplayableValue(realval[i]); + System.out.println("ʾֵ:" + disval + ";ʵֵ:" + realval[i]); + if (disval.equals("Ѵ")) { + sapState = realval[i]; + } + + } + + } + + TCComponentReleaseStatusType releaseType = (TCComponentReleaseStatusType) session + .getTypeComponent("ReleaseStatus"); + + released_Green = releaseType.create("ZT2_Green"); + released_Green.save(); + released_Green.unlock(); + released_Red = releaseType.create("ZT2_Red"); + released_Red.save(); + released_Red.unlock(); + released_Yellow = releaseType.create("ZT2_Yellow"); + released_Yellow.save(); + released_Yellow.unlock(); + } + + private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + + public static String getXML() { String soapXML = "\r\n" - + " \r\n" - + " \r\n" - + " \r\n" - + " \r\n" - + " \r\n" - + ""; + + " \r\n" + " \r\n" + " \r\n" + + " \r\n" + " \r\n" + ""; return soapXML; } - public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { - - String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); - if(rev2.getType().equals("Part Revision")) { - String zt2_ifpbom = rev2.getProperty("zt2_ifpbom"); - if(zt2_ifpbom.equals("P")) { - return rev2; - }else { - TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By"); - if(designRev!=null) { - TCComponent[] matnrs = designRev.getRelatedComponents("representation_for"); - for(TCComponent matnr:matnrs) { - String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"}); - if(properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) { - return (TCComponentItemRevision)matnr; - } - } - } - } - } - return rev2; - - } - public String getUserName(TCSession session) throws TCException { - TCComponentUser user = session.getUser(); - session.getUserName(); - return user.getTCProperty("user_name").getDisplayValue(); - } - public void sendSap() { - try { - List selectedParts = getSelectedParts(); - String now = format.format(new Date()); - MyProgressBarCompent comp = null; -// try { - 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(""); - + + public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { + + String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); + if (rev2.getType().equals("Part Revision")) { + String zt2_ifpbom = rev2.getProperty("zt2_ifpbom"); + if (zt2_ifpbom.equals("P")) { + return rev2; + } else { + TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By"); + if (designRev != null) { + TCComponent[] matnrs = designRev.getRelatedComponents("representation_for"); + for (TCComponent matnr : matnrs) { + String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" }); + if (properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) { + return (TCComponentItemRevision) matnr; + } + } + } + } + } + return rev2; + + } + + public String getUserName(TCSession session) throws TCException { + TCComponentUser user = session.getUser(); + session.getUserName(); + return user.getTCProperty("user_name").getDisplayValue(); + } + + public void sendSap() { + try { + + String strs[] = session.getPreferenceService().getStringValues("database_tc"); + if (SqlUtil.getTCDataConnection(strs) == null) { + MessageBox.post("ݿʧ,ѡ", "", 2); + return; + } + List selectedParts = getSelectedParts(); + // ¼SUMϢ + String userName = session.getUser().getProperty("user_name"); + String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + String zt2_WBSNo = project.getStringProperty("zt2_WBSNo"); + String object_name = project.getStringProperty("object_name"); + String userId = session.getUser().getUserId(); + String code = BomUtilWh.getCode().toString(); + StringBuilder productNosBuild = new StringBuilder(""); + StringBuilder productUidsBuild = new StringBuilder(""); + for (PartBean cppItem : selectedParts) { + String property = cppItem.part.getProperty(BomUtilWh.ZT2_MATERIALNO); + productNosBuild.append(property).append(";"); + productUidsBuild.append(cppItem.part.getUid()).append(";"); + } + 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); - - TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); - TCComponentBOMWindow win = bomWinType.create(null); - TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null); - //ŻBOMȫչ - System.out.println("BOMȫչ"); - Map gy_meops = new HashMap<>(32); - List needTCM_meops = new ArrayList(); - //PBOMPDBOMûPBOMEBOMûEBOMͼֽBOM - Map bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine); - List wbsList = new ArrayList(); - // ¼ͼֽϵļ - Map material_revs = new HashMap<>(); - BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2, - groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs); - System.out.println("BOMȫdocument===>"+document.asXML()); - if(errMessage.length()>0) { - TXTUtil.writeTXT(txtPath, "----------------BOM쳣--------------"); - TXTUtil.writeTXT(txtPath, errMessage.toString()); - TXTUtil.writeTXT(txtPath, "----------BOMϢ-----------"); - errMessageAll.append(errMessage); + + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow win = bomWinType.create(null); + TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null); + // ŻBOMȫչ + System.out.println("BOMȫչ"); + Map gy_meops = new HashMap<>(32); + List needTCM_meops = new ArrayList(); + // PBOMPDBOMûPBOMEBOMûEBOMͼֽBOM + Map bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine); + List wbsList = new ArrayList(); + // ¼ͼֽϵļ + Map material_revs = new HashMap<>(); + // 2024 1 24 ¼ֶ UID BATCHNUMBER + BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2, groupName, wbsList, session, now, + needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum); + System.out.println("BOMȫdocument===>" + document.asXML()); + if (errMessage.length() > 0) { + TXTUtil.writeTXT(txtPath, "----------------BOM쳣--------------"); + TXTUtil.writeTXT(txtPath, errMessage.toString()); + TXTUtil.writeTXT(txtPath, "----------BOMϢ-----------"); + errMessageAll.append(errMessage); // new SAPMessageUtil("", "BOMSAP쳣:\n" + errMessage.toString()); - win.close(); - }else { + win.close(); + } else { // new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation(); - //¼XMLϢCHINT_BOM_TO_SAP_DETIALS - - sendMessageAll.append(SendToSap(txtPath,document.asXML())); - win.close(); - } - TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); - System.out.println("־Ҷ:" + rev2); - KUtil.setByPass(true); - TXTUtil.addTxttoTarget(rev2, dataset); - KUtil.setByPass(false); - } - if(comp!=null) { - comp.setVisible(false); - } - if(errMessageAll.length()>0) { - new SAPMessageUtil("", "BOMSAP쳣:\n" + errMessageAll.toString()); - }else if(sendMessageAll.length()>0) { - new SAPMessageUtil("", "BOM쳣:\n" + sendMessageAll.toString()); - }else { - MessageBox.post("BOM..","ʾ",2); - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public List getSelectedParts() throws Exception { - List 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)); - if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) { - PartBean bean = (PartBean) dialog.t_part.getValueAt(i, 5); - System.out.println("׼ݶ" + bean); - if (bean != null) { - /* - * if(bean.factoryNo==null) { throw new Exception("<"+bean.part+">ûҵ"); - * } - */ - selectedParts.add(bean); - } - } - } - return selectedParts; - } - - public StringBuffer SendToSap(String txtPath,String wsdlString) throws IOException { + // ¼XMLϢCHINT_BOM_TO_SAP_DETIALS + if (flag) { + flag = false; + BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbs, session); + } + sendMessageAll.append(SendToSap(txtPath, document.asXML())); + win.close(); + } + TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); + System.out.println("־Ҷ:" + rev2); + KUtil.setByPass(true); + TXTUtil.addTxttoTarget(rev2, dataset); + KUtil.setByPass(false); + } + if (comp != null) { + comp.setVisible(false); + } + if (errMessageAll.length() > 0) { + new SAPMessageUtil("", "BOMSAP쳣:\n" + errMessageAll.toString()); + } else if (sendMessageAll.length() > 0) { + new SAPMessageUtil("", "BOM쳣:\n" + sendMessageAll.toString()); + } else { + MessageBox.post("BOM..", "ʾ", 2); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SqlUtil.freeAll(); + } + + } + + public List getSelectedParts() throws Exception { + List 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)); + if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) { + PartBean bean = (PartBean) dialog.t_part.getValueAt(i, 5); + System.out.println("׼ݶ" + bean); + if (bean != null) { + /* + * if(bean.factoryNo==null) { throw new Exception("<"+bean.part+">ûҵ"); + * } + */ + selectedParts.add(bean); + } + } + } + return selectedParts; + } + + public StringBuffer SendToSap(String txtPath, String wsdlString) throws IOException { // new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation(); - TXTUtil.writeTXT(txtPath, "----------------BOM--------------"); - TXTUtil.writeTXT(txtPath, wsdlString); - TXTUtil.writeTXT(txtPath, "----------BOM-----------"); - - //SAP - String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl"); - String sapUrl = ""; - String momUrl = ""; - for(String stringValue:stringValues) { - if(stringValue.startsWith("SAP:1=")) { - sapUrl = stringValue.replaceAll("SAP:1=", ""); - }else if(stringValue.startsWith("MOM:1=")) { - momUrl = stringValue.replaceAll("MOM:1=", ""); - } - } - StringBuffer sendSap = sendSap(sapUrl,wsdlString,txtPath); - StringBuffer sendMom = sendMom(momUrl,wsdlString,txtPath); - StringBuffer errBuffer = new StringBuffer(""); - if(sendSap.length()>0) { - errBuffer.append("SAP쳣:").append("\n"); - errBuffer.append(sendSap); - //new SAPMessageUtil("", "s:\n" + errBuffer.toString()); - } - if(sendMom.length()>0) { - errBuffer.append("MOM쳣:").append("\n"); - errBuffer.append(sendMom); - } + TXTUtil.writeTXT(txtPath, "----------------BOM--------------"); + TXTUtil.writeTXT(txtPath, wsdlString); + TXTUtil.writeTXT(txtPath, "----------BOM-----------"); + + // SAP + String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB"); + String sapUrl = ""; + String momUrl = ""; + for (String stringValue : stringValues) { + if (stringValue.startsWith("SAP:1=")) { + sapUrl = stringValue.replaceAll("SAP:1=", ""); + } else if (stringValue.startsWith("MOM:1=")) { + momUrl = stringValue.replaceAll("MOM:1=", ""); + } + } + StringBuffer sendSap = sendSap(sapUrl, wsdlString, txtPath); + StringBuffer sendMom = sendMom(momUrl, wsdlString, txtPath); + StringBuffer errBuffer = new StringBuffer(""); + if (sendSap.length() > 0) { + errBuffer.append("SAP쳣:").append("\n"); + errBuffer.append(sendSap); + // new SAPMessageUtil("", "s:\n" + errBuffer.toString()); + } + if (sendMom.length() > 0) { + errBuffer.append("MOM쳣:").append("\n"); + errBuffer.append(sendMom); + } // if(errBuffer.length()>0) { // new SAPMessageUtil("", "ͽ쳣:\n" + errBuffer.toString()); // } - return errBuffer; - } - public StringBuffer sendSap(String url,String wsdlString,String txtPath) throws IOException { - - StringBuffer errBuffer = new StringBuffer(""); - if(!url.contains("http")) { - return errBuffer; - } - OkHttpClient client = new OkHttpClient(); - client.setConnectTimeout(100, TimeUnit.SECONDS); - client.setReadTimeout(100, TimeUnit.SECONDS); + return errBuffer; + } + + public StringBuffer sendSap(String url, String wsdlString, String txtPath) throws IOException { + + StringBuffer errBuffer = new StringBuffer(""); + if (!url.contains("http")) { + return errBuffer; + } + OkHttpClient client = new OkHttpClient(); + client.setConnectTimeout(100, TimeUnit.SECONDS); + client.setReadTimeout(100, TimeUnit.SECONDS); // Authenticator authenticator = client.setAuthenticator(new Au); - String credential = "";//Credentials.basic("shpodev", "sap@2019"); - if(url.contains("192.168.0.184")) { - credential = Credentials.basic("shpodev", "sap@2019"); - }else { - credential = Credentials.basic("shplm", "sap@2019"); - } - MediaType mediaType = MediaType.parse("application/xml"); - 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 - Request request = new Request.Builder() - .url(url) - .method("POST", body) - .header("Authorization", credential) - .addHeader("Content-Type", "application/xml") - .build(); - Response response = client.newCall(request).execute(); - Document document = null; - - try { - String string = response.body().string(); + String credential = "";// Credentials.basic("shpodev", "sap@2019"); + if (url.contains("192.168.0.184") || url.contains("gfpot01")) { + credential = Credentials.basic("po_rfc", "1qaz!QAZ"); + } else { + credential = Credentials.basic("shplm", "sap@2019"); + } + MediaType mediaType = MediaType.parse("application/xml"); + 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 + Request request = new Request.Builder().url(url).method("POST", body).header("Authorization", credential) + .addHeader("Content-Type", "application/xml").build(); + Response response = client.newCall(request).execute(); + Document document = null; + + try { + String string = response.body().string(); // System.out.println("response.body().string()==>"+string); - TXTUtil.writeTXT(txtPath, "----------------BOMSAP--------------"); - TXTUtil.writeTXT(txtPath, string); - TXTUtil.writeTXT(txtPath, "----------BOMSAP-----------"); - document = DocumentHelper.parseText(string); - Element rootElement = document.getRootElement(); - Element bodys = rootElement.element("Body"); - Element elements = bodys.element("MT_MATERIAL_BOP_RSP"); -// String attributeValue = elements.get(0).attributeValue("CODE"); - List ztable = elements.elements("ZTABLE_RETURN"); - for(Element zret:ztable) { - String status = zret.elementText("TYPE"); - if(status.equals("E")) { - String attributeValue = zret.elementText("MESSAGE"); - String MATNR = zret.elementText("MATNR"); - if(MATNR!=null) { - attributeValue = attributeValue+","+MATNR+"BOM"; - } -// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8"); - System.out.println(attributeValue); - errBuffer.append(attributeValue).append("\n"); - } - } - } catch (DocumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return errBuffer; + TXTUtil.writeTXT(txtPath, "----------------BOMSAP--------------"); + TXTUtil.writeTXT(txtPath, string); + TXTUtil.writeTXT(txtPath, "----------BOMSAP-----------"); +// document = DocumentHelper.parseText(string); +// Element rootElement = document.getRootElement(); +// Element bodys = rootElement.element("Body"); +// Element elements = bodys.element("MT_MATERIAL_BOP_RSP"); +//// String attributeValue = elements.get(0).attributeValue("CODE"); +// List ztable = elements.elements("ZTABLE_RETURN"); +// for (Element zret : ztable) { +// String status = zret.elementText("TYPE"); +// if (status.equals("E")) { +// String attributeValue = zret.elementText("MESSAGE"); +// String MATNR = zret.elementText("MATNR"); +// if (MATNR != null) { +// attributeValue = attributeValue + "," + MATNR + "BOM"; +// } +//// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8"); +// System.out.println(attributeValue); +// errBuffer.append(attributeValue).append("\n"); +// } +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return errBuffer; // if(errBuffer.length()>0) { // new SAPMessageUtil("", "BOM쳣:\n" + errBuffer.toString()); // } - } - public String sendJsonHttpPost(String url, String xmlContent,String txtPath) { - - CloseableHttpClient httpclient = HttpClients.createDefault(); - String responseInfo = null; - try { - HttpPost httpPost = new HttpPost(url); - // ͷ - httpPost.setHeader("Content-Type", "application/xml"); - - // - StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8); - - if(url.contains("10.128.11.12")) { - httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg="); + } + + public String sendJsonHttpPost(String url, String xmlContent, String txtPath) { + + CloseableHttpClient httpclient = HttpClients.createDefault(); + String responseInfo = null; + try { + HttpPost httpPost = new HttpPost(url); + // ͷ + httpPost.setHeader("Content-Type", "application/xml"); + + // + StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8); + + if (url.contains("10.128.11.12")) { + httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg="); // http://10.128.11.12:7788/gateway/chint/bop-sync - }else { - httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg="); - } + } else { + httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg="); + } // - httpPost.setEntity(entityReq); - - CloseableHttpResponse response = httpclient.execute(httpPost); - HttpEntity entity = response.getEntity(); - int status = response.getStatusLine().getStatusCode(); - String string = EntityUtils.toString(entity); - System.out.println("MOM status:" + status + "responseInfo:" + string); - TXTUtil.writeTXT(txtPath, "----------------BOMMOM--------------"); - TXTUtil.writeTXT(txtPath, "MOM status:" + status); - TXTUtil.writeTXT(txtPath, "responseInfo:" + string); - TXTUtil.writeTXT(txtPath, "----------BOMMOM-----------"); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - httpclient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return responseInfo; - } - public StringBuffer sendMom(String url,String wsdlString,String txtPath) throws IOException { - - - StringBuffer errBuffer = new StringBuffer(""); - if(!url.contains("http")) { - return errBuffer; - } - String string = sendJsonHttpPost(url,wsdlString,txtPath); //"http://10.128.11.12:7788/gateway/chint/bop-sync" - - return errBuffer; - - } - + httpPost.setEntity(entityReq); + + CloseableHttpResponse response = httpclient.execute(httpPost); + HttpEntity entity = response.getEntity(); + int status = response.getStatusLine().getStatusCode(); + String string = EntityUtils.toString(entity); + System.out.println("MOM status:" + status + "responseInfo:" + string); + TXTUtil.writeTXT(txtPath, "----------------BOMMOM--------------"); + TXTUtil.writeTXT(txtPath, "MOM status:" + status); + TXTUtil.writeTXT(txtPath, "responseInfo:" + string); + TXTUtil.writeTXT(txtPath, "----------BOMMOM-----------"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return responseInfo; + } + + public StringBuffer sendMom(String url, String wsdlString, String txtPath) throws IOException { + + StringBuffer errBuffer = new StringBuffer(""); + if (!url.contains("http")) { + return errBuffer; + } + String string = sendJsonHttpPost(url, wsdlString, txtPath); // "http://10.128.11.12:7788/gateway/chint/bop-sync" + + return errBuffer; + + } + } diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java index 6ccff5d..7f0873a 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java @@ -77,8 +77,8 @@ public class BomSendSapOp extends AbstractAIFOperation { client.setReadTimeout(100, TimeUnit.SECONDS); // Authenticator authenticator = client.setAuthenticator(new Au); String credential = "";//Credentials.basic("shpodev", "sap@2019"); - if(url.contains("192.168.0.184")) { - credential = Credentials.basic("shpodev", "sap@2019"); + if(url.contains("192.168.0.184") || url.contains("gfpot01")) { + credential = Credentials.basic("po_rfc", "1qaz!QAZ"); }else { credential = Credentials.basic("shplm", "sap@2019"); } @@ -100,25 +100,25 @@ public class BomSendSapOp extends AbstractAIFOperation { TXTUtil.writeTXT(txtPath, "----------------BOMSAP--------------"); TXTUtil.writeTXT(txtPath, string); TXTUtil.writeTXT(txtPath, "----------BOMSAP-----------"); - document = DocumentHelper.parseText(string); - Element rootElement = document.getRootElement(); - Element bodys = rootElement.element("Body"); - Element elements = bodys.element("MT_MATERIAL_BOP_RSP"); -// String attributeValue = elements.get(0).attributeValue("CODE"); - List ztable = elements.elements("ZTABLE_RETURN"); - for(Element zret:ztable) { - String status = zret.elementText("TYPE"); - if(status.equals("E")) { - String attributeValue = zret.elementText("MESSAGE"); - String MATNR = zret.elementText("MATNR"); - if(MATNR!=null) { - attributeValue = attributeValue+","+MATNR+"BOM"; - } - System.out.println(attributeValue); - errBuffer.append(attributeValue).append("\n"); - } - } - } catch (DocumentException e) { +// document = DocumentHelper.parseText(string); +// Element rootElement = document.getRootElement(); +// Element bodys = rootElement.element("Body"); +// Element elements = bodys.element("MT_MATERIAL_BOP_RSP"); +//// String attributeValue = elements.get(0).attributeValue("CODE"); +// List ztable = elements.elements("ZTABLE_RETURN"); +// for(Element zret:ztable) { +// String status = zret.elementText("TYPE"); +// if(status.equals("E")) { +// String attributeValue = zret.elementText("MESSAGE"); +// String MATNR = zret.elementText("MATNR"); +// if(MATNR!=null) { +// attributeValue = attributeValue+","+MATNR+"BOM"; +// } +// System.out.println(attributeValue); +// errBuffer.append(attributeValue).append("\n"); +// } +// } + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -191,7 +191,7 @@ public class BomSendSapOp extends AbstractAIFOperation { TXTUtil.writeTXT(txtPath, "----------BOM-----------"); //SAP - String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl"); + String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB"); String sapUrl = ""; String momUrl = ""; for(String stringValue:stringValues) {