变更管理-如果更改后放的物料版本为A版,生成差异项需按物料新增逻辑进行处理

武汉BOM传递检查逻辑优化
pull/4/head
李冬阳 1 year ago
parent 3fe78f9945
commit 4300500e97

@ -2,7 +2,6 @@ package com.chint.plm.applyMatnr;
import java.awt.Dimension;
import java.io.IOException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
@ -13,8 +12,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.Map.Entry;
import com.connor.chint.sap2.materialno.bean.PMPC;
import com.connor.chint.sap2.materialno.bean.PRD;
//import com.connor.chint.sap2.operation.SelfMPartBean;
@ -32,7 +29,6 @@ import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
@ -43,8 +39,6 @@ import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentUnitOfMeasureType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
@ -86,7 +80,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
public List<PRD> prds3 = new ArrayList<PRD>();
private static String S_CODE = "220103001";
private List<TCComponentItemRevision> applyRevs = new ArrayList<TCComponentItemRevision>();
// private List<TCComponentItemRevision> applyRevs = new ArrayList<TCComponentItemRevision>();
// private List<TCComponentItemRevision> generalRevs = new ArrayList<TCComponentItemRevision>();
// private List<String> s_Revs = new ArrayList<String>();
@ -101,7 +95,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
private Map<TCComponentItemRevision, List<String>> general_maps = new HashMap<TCComponentItemRevision, List<String>>();
private Map<TCComponentItemRevision, List<String>> apply_maps = new HashMap<TCComponentItemRevision, List<String>>();
private List<String> mess = new ArrayList<String>();
private Map<TCComponentItemRevision, Object[]> rev_objs = new HashMap<TCComponentItemRevision, Object[]>();
// private Map<TCComponentItemRevision, Object[]> rev_objs = new HashMap<TCComponentItemRevision, Object[]>();
// private String INSERT_SQL = "insert into infodba.CHINT_MATERIAL
// values(?,?,?,?,?,?,?,?,?,?,?,?,to_date(?,'yyyyMMdd HH24:mi:ss'),?,?)";
public static String INSERT_SQL = "insert into chint_material(\"Code\",\"PUID\",\"PmpcCode\",\"GoodsCode\",\"GoodsName\",\"UnitCode\",\"CompanyCode\",\"BpNo\",\"Spec\",\"TeRe\",\"State\",\"User\",\"Time\",\"Condition\",\"Info\")"
@ -119,7 +113,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
protected String sql_query = "select FeatureList from CcemVW_GoodsFeature where GoodsCode =? ";
Map<String,SelfMPartBean> idBeanMap = new HashMap<String,SelfMPartBean>();
private String actionInfo;
// private String actionInfo;
private TCComponentItemType itemType;
public ApplyMatnrOp(AbstractAIFApplication app, String actionInfo) {
this.app = app;
@ -130,11 +124,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
try {
itemType = (TCComponentItemType) this.session.getTypeComponent("Part");
groupID = SAPUtil.getGroupID(session);
} catch (TCException e) {
// TODO Auto-generated catch block
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
this.actionInfo = actionInfo;
// this.actionInfo = actionInfo;
}
@Override
@ -142,7 +136,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
// List<String> nameList = new ArrayList<String>();
InterfaceAIFComponent[] comps = app.getTargetComponents();
TCComponent target = null;
List<TCComponentBOMLine> lines = new ArrayList<TCComponentBOMLine>();
// List<TCComponentBOMLine> lines = new ArrayList<TCComponentBOMLine>();
if (comps == null || comps.length == 0) {
MessageBox.post("请选中版本对象", "", MessageBox.WARNING);
@ -154,6 +148,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
MessageBox.post("请选中版本对象", "", MessageBox.WARNING);
return;
}
System.out.println("target:" + target);
List<String> nameList = new ArrayList<String>();
List<String> nameList2 = new ArrayList<String>();
dcproxy = KUtil.getUser("dcproxy", session);
@ -292,7 +287,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
pmpc2 = new PMPC(S_CODE, pmpcPrhCode, pmpcPType, pmpcMType);
Object obj3[] = new Object[] { pmpcPrhCode };
ResultSet rs3 = SqlUtil.read(Sql2, obj3);
long time17 = System.nanoTime();
// long time17 = System.nanoTime();
while (rs3.next()) {
String prdFeatureCode = rs3.getString(4);
String featureName = rs3.getString(5);
@ -341,6 +336,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentItemRevision rev = (TCComponentItemRevision) target;
xqxs = RemarkUtil.getXqxs(rev.getProperty("item_id"), session);
if(xqxs == 0) {
MessageBox.post("总装图纸没有填写线圈相数,请检查.", "提示", MessageBox.INFORMATION);
return;
}
win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine bomline = win.getTopBOMLine();
StringBuilder error = new StringBuilder();
@ -351,14 +351,9 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
Map<String, ExpandPSData[]> listBOM = BomToSapUtil.getBomLineTreeNodeSOA(bomline);
gbBuff.setLength(0);
xqErrBuff.setLength(0);
xqxs = RemarkUtil.getXqxs(rev.getProperty("item_id"),session);
if(xqxs ==0 ) {
MessageBox.post("总装图纸没有填写线圈相数,请检查.", "提示", MessageBox.INFORMATION);
return;
}
readBom(listBOM,bomline,error);
if(gbBuff.length()>0) {
MessageBox.post("以下图纸没有物料请检查:\n"+gbBuff.toString(), "提示", MessageBox.INFORMATION);
readBom(listBOM, bomline, error);
if(gbBuff.length() > 0) {
MessageBox.post("以下图纸没有物料请检查:\n" + gbBuff.toString(), "提示", MessageBox.INFORMATION);
return;
}
// for(TCComponentBOMLine line:listBOM) {
@ -434,13 +429,13 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
System.out.println("===============开始创建物料===============");
System.out.println("共需要创建"+self_lists.size()+"个物料!");
long time45 = System.nanoTime();
// long time45 = System.nanoTime();
List<TCComponent> itemList = new ArrayList<TCComponent>();
// tzList.clear();
//批量创建和批量搭关系
TCComponentFolder newStuFolder = user.getNewStuffFolder();
if(self_lists.size()>0) {
List<CreateIn> cIList = new ArrayList();
List<CreateIn> cIList = new ArrayList<>();
for (int i = 0; i < self_lists.size(); i++) {
int t = i+1;
System.out.println("正在创建第"+t+"个物料!");
@ -474,7 +469,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
StringBuffer req_mess = new StringBuffer();
System.out.println("===============开始发送请求===============");
System.out.println("一共需要发送的请求数量:"+drequests.size());
long time37 = System.nanoTime();
// long time37 = System.nanoTime();
for (int i = 0; i < drequests.size(); i++) {
System.out.println("[" + i + "]请求内容:" + drequests.get(i));
String req = HttpUtil.sendJsonHttpPost(url, drequests.get(i));
@ -499,7 +494,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
System.out.println("删除记录");
KUtil.setByPass(true);
SelfMPartBean selfMPartBean = deleteMap.get(bean.getCode());
TCComponentItemRevision pRev = selfMPartBean.getRev();
// TCComponentItemRevision pRev = selfMPartBean.getRev();
TCComponentItemRevision cRev = selfMPartBean.getMatnrRev();
// pRev.remove("representation_for", cRev);
TCComponentItem item = cRev.getItem();
@ -592,7 +587,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
}
@ -606,9 +601,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM");
// TXTUtil.writeTXT(logPath, "返回信息:" + mess2);
System.out.println("返回信息:" + mess2);
} catch (javax.xml.rpc.ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
} catch (Exception e) {
e.printStackTrace();
}
// TXTUtil.writeTXT(logPath, "AM消息推送结束");
@ -616,7 +609,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
// List<TCComponentItemRevision> tzList = new ArrayList<TCComponentItemRevision>();
public CreateIn createMaterialYH(SelfMPartBean bean, String companyCode,
String zt2_Specifications, String code) throws TCException, ServiceException {
Object[] result = new Object[2];
// Object[] result = new Object[2];
// TCComponentItem item = null;
// 自动按照编码规则获取ID
@ -753,6 +746,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
}
@SuppressWarnings("deprecation")
public TCComponentBOMLine getNewBOMLine(TCComponentItemRevision itemR) {
TCComponentBOMWindowType bomWinType;
try {
@ -844,8 +838,8 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
String zt2_ProductModel = properties[4];//rev.getProperty("zt2_ProductModel");
String teRe = "";
String state = ""; // 申请时为空
String wbs = "";
String product = "";
// String wbs = "";
// String product = "";
String user = userID;
String time = now;
String condition = "审核中";// 默认审核中
@ -998,8 +992,8 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
String zt2_ProductModel = properties[4];//rev.getProperty("zt2_ProductModel");
String teRe = "";
String state = ""; // 申请时为空
String wbs = "";
String product = "";
// String wbs = "";
// String product = "";
String user = userID;
String time = now;
String condition = "审核中";// 默认审核中
@ -1087,12 +1081,12 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
TCComponentItemRevision rev = line.getItemRevision();
System.out.println(rev);
if (isNeedApply(rev)) {
boolean flag = true;
// boolean flag = true;
String item_id = rev.getProperty("item_id");
if (item_id.length() >= 3) {
String stuf = item_id.substring(0, 3);
if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD") || stuf.equalsIgnoreCase("1ZD")) {
flag = false;
// flag = false;
// 开始根据通用件规格属性来判断是否需要申请物料
String zt2_TYJSpec = line.getProperty("ZT2_TYSpecifications");
if (zt2_TYJSpec == null || zt2_TYJSpec.length() == 0) {
@ -1312,6 +1306,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
// }
// return flag;
// }
/*
private String getValue(TCProperty property) throws TCException {
TCComponentListOfValues lov = property.getLOV();
if (lov != null) {// 判断是否lov
@ -1329,7 +1324,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
}
return "外购";
}
}*/
// public Object[] createMaterial(TCComponentItemRevision tzRev, String companyCode,
// String zt2_Specifications, String code) throws TCException, ServiceException {
@ -1455,7 +1450,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
String item_id = "8zdk.177.999";
System.out.println(item_id.substring(0, 8));
}
/*
private List<TCComponentBOMLine> listBOM(TCComponentBOMLine bomlineObj) {
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();
@ -1469,11 +1464,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
if (levelResp.output.length <= 0) {
return null;
}
/*
* levelRespOutputBOMLine
* StructureManagement.ExpandPSData[] children List of ExpandPSData children found for this parent.
StructureManagement.ExpandPSParentData parent ExpandPSParentData member
*/
// levelResp中的Output有所有的BOMLine
// StructureManagement.ExpandPSData[] children List of ExpandPSData children found for this parent.
// StructureManagement.ExpandPSParentData parent ExpandPSParentData member
List<TCComponentBOMLine> bomlineList = new ArrayList<TCComponentBOMLine>(levelResp.output.length);
List<TCComponentItemRevision> itemRevList = new ArrayList<TCComponentItemRevision>(levelResp.output.length);
@ -1493,5 +1488,5 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
}
}
return bomlineList;
}
}*/
}

@ -3,9 +3,7 @@ import java.util.Map;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
public class RemarkUtil {
@ -16,21 +14,24 @@ public class RemarkUtil {
try {
String[] split = itemId.split("-");
String topId = "1ZDB300000P-"+split[1];
System.out.println("topId:" + topId);
TCComponentItemType partType = (TCComponentItemType) session.getTypeComponent("ZT2_Design3D");
TCComponentItem find = partType.find(topId);
TCComponentItem find = partType.findItems(topId)[0];
Map<String, String> classificationAttributes = find.getClassificationAttributes();
// System.out.println(classificationAttributes.toString());
for(String key:classificationAttributes.keySet()) {
for(String key : classificationAttributes.keySet()) {
System.out.println("key:" + key);
if(key.equals("ÏàÊý")) {
String cphx = classificationAttributes.get(key);
len = Integer.valueOf(cphx);
System.out.println("len:" + len);
break;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
}
return len;
@ -65,7 +66,7 @@ public class RemarkUtil {
}
// TCComponentItemRevision itemRevision = bomline.getItemRevision();
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
}
}

@ -279,20 +279,24 @@ public class CreateBOMDifference_DYController {
bean = entry.getValue();
oldRev = bean.getOldRev();
newRev = bean.getNewRev();
if (oldRev != null && newRev != null && oldRev != newRev) {
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
bean.setNewBOMLine(win2.getTopBOMLine());
bean.setOldBOMLine(win.getTopBOMLine());
if (oldRev != newRev) {//lidy 20240411 oldRev != null && newRev != null &&
zt2_MaterialNo = "";
object_desc = "";
parentRev = null;
parentRev = SAPUtil.getSAPPart(bean.getNewBOMLine(), session);
if (parentRev != null) {
zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
object_desc = parentRev.getProperty("object_desc");
if(oldRev != null) {
win.setWindowTopLine(item, oldRev, null, null);
win.refresh();
bean.setOldBOMLine(win.getTopBOMLine());
}
if(newRev != null) {
win2.setWindowTopLine(item, newRev, null, null);
win2.refresh();
bean.setNewBOMLine(win2.getTopBOMLine());
parentRev = SAPUtil.getSAPPart(bean.getNewBOMLine(), session);
if (parentRev != null) {
zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
object_desc = parentRev.getProperty("object_desc");
}
}
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
bean.setObject_desc_Parent(object_desc);

@ -152,17 +152,6 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
// Auto-generated method stub
MyProgressBarCompent comp = null;
try {
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 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);
@ -203,6 +192,16 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
}
}
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
String code = BomUtilWh.getCode().toString();
String batchNum = code + "-00001";
comp = new MyProgressBarCompent("", "正在进行部件BOM传递SAP....");
TCComponentItemRevision pRevision = getPRevision(degignRev); // 获取PBOM
List<TCComponentItem> cppRevision = getCPPPRevision(degignRev);

Loading…
Cancel
Save