Merge pull request 'ljh' (#8) from ljh into main

Reviewed-on: http://yunpi.tpddns.cn:3000/ZT_CODE/chint_wuhan/pulls/8
pull/10/head
李建辉 1 year ago
commit 3ae5fa9272

@ -12,6 +12,7 @@
<command name="创建框架BOM" id="com.chint.plm.createKjBom.CreateKjBomCommand"/> <command name="创建框架BOM" id="com.chint.plm.createKjBom.CreateKjBomCommand"/>
<command name="框架BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapKjSendCommand"/> <command name="框架BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapKjSendCommand"/>
<command name="项目BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapWhCommand"/> <command name="项目BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapWhCommand"/>
<command name="拆卸一览表下发" id="com.connor.chint.yunpi.command.ZxjcCommand"/>
<command name="部件BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapWhBjCommand"/> <command name="部件BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapWhBjCommand"/>
<command name="物料编码批量申请-全部图纸" id="com.chint.plm.applyMatnr.ApplyMatnrCommand#all"/> <command name="物料编码批量申请-全部图纸" id="com.chint.plm.applyMatnr.ApplyMatnrCommand#all"/>
<!--正泰定制下 中压开关--> <!--正泰定制下 中压开关-->
@ -57,6 +58,7 @@
<handler commandId="com.chint.plm.applyMatnr.ApplyMatnrCommand#user" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.chint.plm.applyMatnr.ApplyMatnrCommand#user" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.EbomToPCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.EbomToPCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.BomSapWhCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.BomSapWhCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.ZxjcCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.BomSapWhBjCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.BomSapWhBjCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.chint.plm.createKjBom.CreateKjBomCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.chint.plm.createKjBom.CreateKjBomCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.DbomToECommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.DbomToECommand" class="com.connor.chint.yunpi.KHandler"/>
@ -461,6 +463,29 @@
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.ZxjcCommand" id = "com.connor.chint.yunpi.command.ZxjcCommand">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.yunpi.command.ZxjcCommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.yunpi.command.BomDcSapCommand" id = "com.connor.chint.yunpi.command.BomDcSapCommand"> <command commandId = "com.connor.chint.yunpi.command.BomDcSapCommand" id = "com.connor.chint.yunpi.command.BomDcSapCommand">
<visibleWhen> <visibleWhen>
<and> <and>

@ -348,7 +348,13 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
my = new MyProgressBarCompent("自制件编码申请", "正在读取BOM......"); my = new MyProgressBarCompent("自制件编码申请", "正在读取BOM......");
System.out.println("===============开始获取可申请物料 自制件和普通图纸==============="); System.out.println("===============开始获取可申请物料 自制件和普通图纸===============");
long time33 = System.nanoTime(); long time33 = System.nanoTime();
long time1 = System.nanoTime();
Map<String, ExpandPSData[]> listBOM = BomToSapUtil.getBomLineTreeNodeSOA(bomline); Map<String, ExpandPSData[]> listBOM = BomToSapUtil.getBomLineTreeNodeSOA(bomline);
System.out.println("listBOM.size=================="+listBOM.size());
long time2 = System.nanoTime();
System.out.println("===============soa获取bomline用时(ms) " + ((time2 - time1) / 1000000L)+"===============");
gbBuff.setLength(0); gbBuff.setLength(0);
xqErrBuff.setLength(0); xqErrBuff.setLength(0);
readBom(listBOM, bomline, error); readBom(listBOM, bomline, error);
@ -1082,7 +1088,10 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
System.out.println(rev); System.out.println(rev);
if (isNeedApply(rev)) { if (isNeedApply(rev)) {
// boolean flag = true; // boolean flag = true;
String item_id = rev.getProperty("item_id"); //String item_id = rev.getProperty("item_id");
//一次性获取三个属性
String[] revProperties = rev.getProperties(new String[] {"item_id","zt2_Specifications","zt2_DrawingNo"});
String item_id = revProperties[0];
if (item_id.length() >= 3) { if (item_id.length() >= 3) {
String stuf = item_id.substring(0, 3); String stuf = item_id.substring(0, 3);
if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD") || stuf.equalsIgnoreCase("1ZD")) { if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD") || stuf.equalsIgnoreCase("1ZD")) {
@ -1093,7 +1102,8 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
// 无通用件规格 // 无通用件规格
TCComponent[] comps = rev.getReferenceListProperty("representation_for"); TCComponent[] comps = rev.getReferenceListProperty("representation_for");
System.out.println(comps.length); System.out.println(comps.length);
String spec = rev.getProperty("zt2_Specifications"); // ·Ç±ØÌî //String spec = rev.getProperty("zt2_Specifications"); // 非必填
String spec = revProperties[1];
if (comps.length == 0) { if (comps.length == 0) {
if (general_maps.containsKey(rev)) { if (general_maps.containsKey(rev)) {
if (!general_maps.get(rev).contains(spec)) { if (!general_maps.get(rev).contains(spec)) {
@ -1105,26 +1115,38 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
general_maps.put(rev, specs); general_maps.put(rev, specs);
} }
}else if(stuf.equalsIgnoreCase("2ZD")){ }else if(stuf.equalsIgnoreCase("2ZD")){
partRevs.add(comps[0]); //20240426 增加查询的代码
boolean needApply = true; Map<String, String> field = new HashMap<String, String>();
for(TCComponent comp:comps) { String value = "* " + spec;
String specs = comp.getProperty("zt2_Specifications"); // ·Ç±ØÌî System.out.println("查询值:" + value+"item_id==>"+item_id);
if(specs.equals(spec)) { field.put("描述", value);
needApply = false; field.put("关联的图号", item_id);
break; TCComponentContextList contxt = KUtil.query(session, "chint_query_material_test", field);
//"*"+item_id+"*"+zt2_TYJSpec+"*"
if(contxt == null || contxt.getListCount() == 0) {
partRevs.add(comps[0]);
boolean needApply = true;
for(TCComponent comp:comps) {
String specs = comp.getProperty("zt2_Specifications"); // 非必填
if(specs.equals(spec)) {
needApply = false;
break;
}
} }
} if(needApply) {
if(needApply) { if (general_maps.containsKey(rev)) {
if (general_maps.containsKey(rev)) { if (!general_maps.get(rev).contains(spec)) {
if (!general_maps.get(rev).contains(spec)) { general_maps.get(rev).add(spec);
general_maps.get(rev).add(spec); }
} else {
List<String> specs = new ArrayList<String>();
specs.add(spec);
general_maps.put(rev, specs);
} }
} else {
List<String> specs = new ArrayList<String>();
specs.add(spec);
general_maps.put(rev, specs);
} }
} }
} }
} else { } else {
// 有通用件规格 // 有通用件规格
@ -1146,7 +1168,8 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
System.out.println("contxt:" + contxt.getListCount()); System.out.println("contxt:" + contxt.getListCount());
if (contxt == null || contxt.getListCount() == 0) { if (contxt == null || contxt.getListCount() == 0) {
String bpNo = item_id; String bpNo = item_id;
String zt2_DrawingNo = rev.getProperty("zt2_DrawingNo"); //String zt2_DrawingNo = rev.getProperty("zt2_DrawingNo");
String zt2_DrawingNo = revProperties[2];
if (!KUtil.isEmpty(zt2_DrawingNo) && !stuf.equalsIgnoreCase("1ZD")) { if (!KUtil.isEmpty(zt2_DrawingNo) && !stuf.equalsIgnoreCase("1ZD")) {
if (!item_id.equals(zt2_DrawingNo)) if (!item_id.equals(zt2_DrawingNo))
bpNo = zt2_DrawingNo; bpNo = zt2_DrawingNo;
@ -1174,7 +1197,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
boolean flag2 = true; boolean flag2 = true;
for (int i = 0, len = contxt.getListCount(); i < len; i++) { for (int i = 0, len = contxt.getListCount(); i < len; i++) {
TCComponent component = (TCComponent) contxt.get(i).getComponent(); TCComponent component = (TCComponent) contxt.get(i).getComponent();
String property = component.getProperty("object_desc"); //一次性获取两个属性
String[] tcProperties = component.getProperties(new String[] {"object_desc","zt2_MaterialNo"});
String property = tcProperties[0];
//String property = component.getProperty("object_desc");
String[] split = property.split(" "); String[] split = property.split(" ");
if(!zt2_TYJSpec.equals(split[split.length-1])) { if(!zt2_TYJSpec.equals(split[split.length-1])) {
if(split.length-2>=0) { if(split.length-2>=0) {
@ -1187,14 +1214,15 @@ public class ApplyMatnrOp extends AbstractAIFOperation {
} }
ResultSet rs; ResultSet rs;
String zt2_MaterialNo; String zt2_MaterialNo = "";
Object[] objs = new Object[1]; Object[] objs = new Object[1];
String featureList; String featureList;
String temp; String temp;
String[] vals; String[] vals;
if (!flag2) if (!flag2)
break; break;
zt2_MaterialNo = component.getProperty("zt2_MaterialNo"); //zt2_MaterialNo = component.getProperty("zt2_MaterialNo");
zt2_MaterialNo = tcProperties[1];
if(zt2_MaterialNo.equals("")||zt2_MaterialNo.isEmpty()) { if(zt2_MaterialNo.equals("")||zt2_MaterialNo.isEmpty()) {
flag2 = false; flag2 = false;
continue; continue;

@ -549,6 +549,7 @@ public class ApplyMatnrOp2 extends AbstractAIFOperation {
List<TCComponent> partRevs = new ArrayList<>(); List<TCComponent> partRevs = new ArrayList<>();
String zt2_Source = ""; String zt2_Source = "";
String type = itemRevision.getType(); String type = itemRevision.getType();
if(!type.equals("ZT2_XNZJB")) { if(!type.equals("ZT2_XNZJB")) {
getRevs(bomline, error,partRevs); getRevs(bomline, error,partRevs);
zt2_Source = itemRevision.getProperty("zt2_Source"); zt2_Source = itemRevision.getProperty("zt2_Source");
@ -1083,7 +1084,9 @@ public class ApplyMatnrOp2 extends AbstractAIFOperation {
System.out.println(rev); System.out.println(rev);
if (isNeedApply(rev)) { if (isNeedApply(rev)) {
boolean flag = true; boolean flag = true;
String item_id = rev.getProperty("item_id"); //String item_id = rev.getProperty("item_id");
String[] revProperties = rev.getProperties(new String[] {"item_id","zt2_Specifications","zt2_DrawingNo"});
String item_id = revProperties[0];
if (item_id.length() >= 3) { if (item_id.length() >= 3) {
String stuf = item_id.substring(0, 3); String stuf = item_id.substring(0, 3);
if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD") || stuf.equalsIgnoreCase("1ZD")) { if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD") || stuf.equalsIgnoreCase("1ZD")) {
@ -1102,7 +1105,8 @@ public class ApplyMatnrOp2 extends AbstractAIFOperation {
// ÎÞͨÓüþ¹æ¸ñ // ÎÞͨÓüþ¹æ¸ñ
TCComponent[] comps = rev.getReferenceListProperty("representation_for"); TCComponent[] comps = rev.getReferenceListProperty("representation_for");
System.out.println(comps.length); System.out.println(comps.length);
String spec = rev.getProperty("zt2_Specifications"); // ·Ç±ØÌî //String spec = rev.getProperty("zt2_Specifications"); // ·Ç±ØÌî
String spec = revProperties[1];
if (comps.length == 0) { if (comps.length == 0) {
if (general_maps.containsKey(rev)) { if (general_maps.containsKey(rev)) {
if (!general_maps.get(rev).contains(spec)) { if (!general_maps.get(rev).contains(spec)) {
@ -1156,7 +1160,8 @@ public class ApplyMatnrOp2 extends AbstractAIFOperation {
if (contxt == null || contxt.getListCount() == 0) { if (contxt == null || contxt.getListCount() == 0) {
Map<String, String> field2 = new HashMap<String, String>(); Map<String, String> field2 = new HashMap<String, String>();
String bpNo = item_id; String bpNo = item_id;
String zt2_DrawingNo = rev.getProperty("zt2_DrawingNo"); //String zt2_DrawingNo = rev.getProperty("zt2_DrawingNo");
String zt2_DrawingNo = revProperties[2];
if (!KUtil.isEmpty(zt2_DrawingNo) && !stuf.equalsIgnoreCase("1ZD")) { if (!KUtil.isEmpty(zt2_DrawingNo) && !stuf.equalsIgnoreCase("1ZD")) {
if (!item_id.equals(zt2_DrawingNo)) if (!item_id.equals(zt2_DrawingNo))
bpNo = zt2_DrawingNo; bpNo = zt2_DrawingNo;
@ -1187,7 +1192,9 @@ public class ApplyMatnrOp2 extends AbstractAIFOperation {
boolean flag2 = true; boolean flag2 = true;
for (int i = 0, len = contxt.getListCount(); i < len; i++) { for (int i = 0, len = contxt.getListCount(); i < len; i++) {
TCComponent component = (TCComponent) contxt.get(i).getComponent(); TCComponent component = (TCComponent) contxt.get(i).getComponent();
String property = component.getProperty("object_desc"); //String property = component.getProperty("object_desc");
String[] tcProperties = component.getProperties(new String[] {"object_desc","zt2_MaterialNo"});
String property = tcProperties[0];
String[] split = property.split(" "); String[] split = property.split(" ");
if(!zt2_TYJSpec.equals(split[split.length-1])) { if(!zt2_TYJSpec.equals(split[split.length-1])) {
if(split.length-2>=0) { if(split.length-2>=0) {
@ -1207,7 +1214,8 @@ public class ApplyMatnrOp2 extends AbstractAIFOperation {
String[] vals; String[] vals;
if (!flag2) if (!flag2)
break; break;
zt2_MaterialNo = contxt.get(i).getComponent().getProperty("zt2_MaterialNo"); //zt2_MaterialNo = component.getProperty("zt2_MaterialNo");
zt2_MaterialNo = tcProperties[1];
if(zt2_MaterialNo.equals("")||zt2_MaterialNo.isEmpty()) { if(zt2_MaterialNo.equals("")||zt2_MaterialNo.isEmpty()) {
flag2 = false; flag2 = false;
continue; continue;

@ -4,6 +4,7 @@ import java.util.Map;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
public class RemarkUtil { public class RemarkUtil {
@ -40,7 +41,12 @@ public class RemarkUtil {
try { try {
String[] idss = new String[] {"A","B","C","D","E"}; String[] idss = new String[] {"A","B","C","D","E"};
String remark = bomline.getProperty("ZT2_Remark"); //String remark = bomline.getProperty("ZT2_Remark");
//一次性获取两个属性
String[] tcProperties = bomline.getProperties(new String[] {"ZT2_Remark","bl_quantity"});
String remark = tcProperties[0];
String bl_quantity = tcProperties[1];
String markMsg = ""; String markMsg = "";
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (remark.contains(idss[i])) { if (remark.contains(idss[i])) {
@ -49,7 +55,7 @@ public class RemarkUtil {
} }
String c_pId = bomline.getItemRevision().getProperty("item_id"); String c_pId = bomline.getItemRevision().getProperty("item_id");
int xqlen = markMsg.length(); int xqlen = markMsg.length();
String bl_quantity = bomline.getProperty("bl_quantity"); //String bl_quantity = bomline.getProperty("bl_quantity");
if(bl_quantity.isEmpty()) { if(bl_quantity.isEmpty()) {
xqErrBuff.append("图纸:").append(pId).append("下子件").append(c_pId) xqErrBuff.append("图纸:").append(pId).append("下子件").append(c_pId)
.append("无法整除,请检查.").append("\n"); .append("无法整除,请检查.").append("\n");

@ -29,99 +29,105 @@ public class AssignProcess extends KCommand {
// private boolean top = true; // private boolean top = true;
private TCComponentItemRevision rev; private TCComponentItemRevision rev;
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws Exception { public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws Exception {
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;
} }
} }
} }
} }
}else if(rev2.getType().equals("ZT2_Design3DRevision")) { } else if (rev2.getType().equals("ZT2_Design3DRevision")) {
TCComponent[] matnrs = rev2.getRelatedComponents("representation_for"); TCComponent[] matnrs = rev2.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[0].equals("P")) { if (properties[0].equals("P")) {
return (TCComponentItemRevision)matnr; return (TCComponentItemRevision) matnr;
} }
} }
return (TCComponentItemRevision)matnrs[0]; return (TCComponentItemRevision) matnrs[0];
} }
return rev2; return rev2;
} }
private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) { private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) {
// Auto-generated method stub // Auto-generated method stub
// item = null; // item = null;
try { try {
TCComponent[] whereUsed = rev.whereUsed((short)0); TCComponent[] whereUsed = rev.whereUsed((short) 0);
if(whereUsed.length==0) { if (whereUsed.length == 0) {
// String property = rev.getProperty("item_id"); // String property = rev.getProperty("item_id");
return rev; return rev;
}else { } else {
List<TCComponentItemRevision> revPs = new ArrayList<TCComponentItemRevision>(); List<TCComponentItemRevision> revPs = new ArrayList<TCComponentItemRevision>();
for(int i=0;i<whereUsed.length;i++) { for (int i = 0; i < whereUsed.length; i++) {
TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i]; TCComponentItemRevision revP = (TCComponentItemRevision) whereUsed[i];
if(revP.getType().contains("Part")) { if (revP.getType().contains("Part")) {
revPs.add(revP); revPs.add(revP);
} }
} }
for(TCComponentItemRevision revP:revPs) { for (TCComponentItemRevision revP : revPs) {
if(revPs.size()>1) { if (revPs.size() > 1) {
// TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i]; // TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i];
String property = revP.getProperty("zt2_ifpbom"); String property = revP.getProperty("zt2_ifpbom");
if(property==null||!property.equals("P")) { if (property == null || !property.equals("P")) {
continue; continue;
} }
} }
TCComponentItemRevision item = getTopZzItem(revP); TCComponentItemRevision item = getTopZzItem(revP);
if(item!=null) { if (item != null) {
return item; return item;
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
// Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public AssignProcess(AbstractAIFApplication app, String commandId, String actionInfo) { public AssignProcess(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo); super(app, commandId, actionInfo);
long time20 = System.nanoTime();
InterfaceAIFComponent targetComponent = app.getTargetComponent(); InterfaceAIFComponent targetComponent = app.getTargetComponent();
try { try {
TCSession session = (TCSession)app.getSession(); TCSession session = (TCSession) app.getSession();
String groupID = SAPUtil.getGroupID(session); String groupID = SAPUtil.getGroupID(session);
if(!groupID.equals("M060")) { if (!groupID.equals("M060")) {
MessageBox.post("请登录正确组", "", MessageBox.ERROR); MessageBox.post("请登录正确组", "", MessageBox.ERROR);
return; return;
} }
if(targetComponent instanceof TCComponentBOMLine) { if (targetComponent instanceof TCComponentBOMLine) {
rev = ((TCComponentBOMLine)targetComponent).getItemRevision(); rev = ((TCComponentBOMLine) targetComponent).getItemRevision();
}else if(targetComponent instanceof TCComponentItemRevision) { } else if (targetComponent instanceof TCComponentItemRevision) {
TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent;
this.rev = rev; this.rev = rev;
}else { } else {
MessageBox.post("请选择BOM行或者版本对象", "", MessageBox.ERROR); MessageBox.post("请选择BOM行或者版本对象", "", MessageBox.ERROR);
return; return;
} }
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
if(!rev.getType().equals("Part Revision")) { if (!rev.getType().equals("Part Revision")) {
MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR); MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR);
return; return;
} }
@ -129,94 +135,133 @@ public class AssignProcess extends KCommand {
try { try {
TCPreferenceService service = session.getPreferenceService(); TCPreferenceService service = session.getPreferenceService();
// TCComponentItemRevision pRevision = getPRevision(rev); // TCComponentItemRevision pRevision = getPRevision(rev);
long time5 = System.nanoTime();
TCComponentItemRevision topZzItem = getTopZzItem(rev); TCComponentItemRevision topZzItem = getTopZzItem(rev);
long time6 = System.nanoTime();
System.out.println(
"getTopZzItem========================================= " + (time6 - time5) / 1000000L);
long time7 = System.nanoTime();
String name = rev.getProperty("object_name"); String name = rev.getProperty("object_name");
String property = topZzItem.getProperty("zt2_ifpbom"); String property = topZzItem.getProperty("zt2_ifpbom");
if(!property.equals("P") && topZzItem.getStringProperty("object_desc").contains("1ZDB300000P")) { if (!property.equals("P")
&& topZzItem.getStringProperty("object_desc").contains("1ZDB300000P")) {
MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR); MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR);
return; return;
} }
boolean isback = false; boolean isback = false;
String[] rules = service.getStringValues("CHINT_PROCESS_RULE"); String[] rules = service.getStringValues("CHINT_PROCESS_RULE");
for(String rule : rules) { for (String rule : rules) {
String[] split = rule.split(":"); String[] split = rule.split(":");
if(!split[0].equals(groupID)) if (!split[0].equals(groupID))
continue; continue;
String[] backs = split[1].split(";"); String[] backs = split[1].split(";");
for(String back : backs) { for (String back : backs) {
System.out.println(name + "==" + back + ">>" + name.contains(back)); System.out.println(name + "==" + back + ">>" + name.contains(back));
if(name.contains(back)) { if (name.contains(back)) {
isback = true; isback = true;
break; break;
} }
} }
if(isback) if (isback)
break; break;
} }
TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem.getRelatedComponent("TC_Is_Represented_By"); TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem
System.out.println("topZzItem=="+topZzItem.toString()+">>"+isback); .getRelatedComponent("TC_Is_Represented_By");
if(isback) { System.out.println("topZzItem==" + topZzItem.toString() + ">>" + isback);
if (isback) {
AIFComponentContext[] folders = topZzItem.getItem() AIFComponentContext[] folders = topZzItem.getItem()
.whereReferencedByTypeRelation(new String[] { "ZT2_ProjectFolder" }, null);//new String[] { "contents" } .whereReferencedByTypeRelation(new String[] { "ZT2_ProjectFolder" }, null);// new
if(folders.length == 0) { // String[]
// {
// "contents"
// }
if (folders.length == 0) {
MessageBox.post("未找到产成品文件夹,请检查.", "提示", MessageBox.WARNING); MessageBox.post("未找到产成品文件夹,请检查.", "提示", MessageBox.WARNING);
return; return;
} }
AIFComponentContext[] ccps = folders[0].getComponent().getChildren(); AIFComponentContext[] ccps = folders[0].getComponent().getChildren();
System.out.println(folders[0].getComponent() + "==>" + ccps.length); System.out.println(folders[0].getComponent() + "==>" + ccps.length);
for(AIFComponentContext aifcc : ccps) { for (AIFComponentContext aifcc : ccps) {
TCComponentItem item = (TCComponentItem) aifcc.getComponent(); TCComponentItem item = (TCComponentItem) aifcc.getComponent();
desginRev = (TCComponentItemRevision) item.getLatestItemRevision().getRelatedComponent("TC_Is_Represented_By"); desginRev = (TCComponentItemRevision) item.getLatestItemRevision()
.getRelatedComponent("TC_Is_Represented_By");
System.out.println(item + "==>" + desginRev); System.out.println(item + "==>" + desginRev);
if(desginRev != null) if (desginRev != null)
break; break;
} }
} }
if(desginRev == null) {
long time8 = System.nanoTime();
System.out.println(
"检查逻辑========================================= " + (time8 - time7) / 1000000L);
if (desginRev == null) {
MessageBox.post("存在顶层P物料没有关联图纸,请检查.", "提示", MessageBox.WARNING); MessageBox.post("存在顶层P物料没有关联图纸,请检查.", "提示", MessageBox.WARNING);
return; return;
} }
Map<String, String> classificationAttributes = desginRev.getItem().getClassificationAttributes();
long time3 = System.nanoTime();
Map<String, String> classificationAttributes = desginRev.getItem()
.getClassificationAttributes();
System.out.println(classificationAttributes.toString()); System.out.println(classificationAttributes.toString());
for(String key:classificationAttributes.keySet()) {
if(key.equals("产品型号")) {
for (String key : classificationAttributes.keySet()) {
if (key.equals("产品型号")) {
String cphx = classificationAttributes.get(key); String cphx = classificationAttributes.get(key);
String sql = "SELECT \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"ProductXH\" = '"+cphx+"'"; String sql = "SELECT \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"ProductXH\" = '"
+ cphx + "'";
String[] prefs = service.getStringValues("database_tc"); String[] prefs = service.getStringValues("database_tc");
SqlUtil.getTCDataConnection(prefs); SqlUtil.getTCDataConnection(prefs);
ResultSet read2 = SqlUtil.read(sql); ResultSet read2 = SqlUtil.read(sql);
if(!read2.next()) { if (!read2.next()) {
String searchSql = "SELECT distinct \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"COMPANYCODE\" = 'M060'"; String searchSql = "SELECT distinct \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"COMPANYCODE\" = 'M060'";
ResultSet read = SqlUtil.read(searchSql); ResultSet read = SqlUtil.read(searchSql);
List<String> productZuList = new ArrayList<String>(); List<String> productZuList = new ArrayList<String>();
while(read.next()){ while (read.next()) {
productZuList.add(read.getString(1)); productZuList.add(read.getString(1));
} }
System.out.println(productZuList.toString()); System.out.println(productZuList.toString());
String[] array = productZuList.toArray(new String[] {}); String[] array = productZuList.toArray(new String[] {});
Object showInputDialog = JOptionPane.showInputDialog(null,"当前产品型号未维护,请选择对应产品族.","提示",JOptionPane.QUESTION_MESSAGE,null,array,array[0]); Object showInputDialog = JOptionPane.showInputDialog(null, "当前产品型号未维护,请选择对应产品族.",
if(showInputDialog==null) { "提示", JOptionPane.QUESTION_MESSAGE, null, array, array[0]);
if (showInputDialog == null) {
return; return;
}else { } else {
System.out.println("showInputDialog:" + showInputDialog.toString()); System.out.println("showInputDialog:" + showInputDialog.toString());
String insertSql = "INSERT INTO \"CHINT_WORKHOUR_WhProductXH\" " String insertSql = "INSERT INTO \"CHINT_WORKHOUR_WhProductXH\" "
+ "(\"ProductXH\",\"ProductZu\",\"COMPANYCODE\") " + "(\"ProductXH\",\"ProductZu\",\"COMPANYCODE\") " + "VALUES (?,?,?)";
+ "VALUES (?,?,?)"; SqlUtil.write(insertSql,
SqlUtil.write(insertSql, new Object[] {cphx,showInputDialog.toString(),"M060"}); new Object[] { cphx, showInputDialog.toString(), "M060" });
} }
} }
break; break;
} }
} }
long time4 = System.nanoTime();
System.out.println(
"sql========================================== " + (time4 - time3) / 1000000L);
comp = new MyProgressBarCompent("", "正在进行一键指派工艺路线......"); comp = new MyProgressBarCompent("", "正在进行一键指派工艺路线......");
TCUserService userService = (TCUserService) session.getUserService(); TCUserService userService = (TCUserService) session.getUserService();
Object call = userService.call("CloneTempProcess", new Object[] {rev.getUid()}); long time1 = System.nanoTime();
Object call = userService.call("CloneTempProcess", new Object[] { rev.getUid() });
long time2 = System.nanoTime();
System.out.println(
"调用call========================================== " + (time2 - time1) / 1000000L);
String string = call.toString(); String string = call.toString();
comp.setVisible(false); comp.setVisible(false);
System.out.println(string); System.out.println(string);
if(!string.equals("succ")) { if (!string.equals("succ")) {
// if(string.contains("在数据库表中无对应典型产品族值")) { // if(string.contains("在数据库表中无对应典型产品族值")) {
// String[] split = string.split("当前变压器产品型号:"); // String[] split = string.split("当前变压器产品型号:");
// String[] split2 = split[1].split(",在数据库表中无对应典型产品族值"); // String[] split2 = split[1].split(",在数据库表中无对应典型产品族值");
@ -235,23 +280,28 @@ public class AssignProcess extends KCommand {
// System.out.println(productZuList.toString()); // System.out.println(productZuList.toString());
// } // }
new SAPMessageUtilFram("", "一键指派工艺路线存在异常,请检查:\n" + string); new SAPMessageUtilFram("", "一键指派工艺路线存在异常,请检查:\n" + string);
}else { } else {
MessageBox.post("一键指派工艺路线完成。","提示",MessageBox.INFORMATION); MessageBox.post("一键指派工艺路线完成。", "提示", MessageBox.INFORMATION);
} }
} catch (Exception e1) { } catch (Exception e1) {
// Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
}finally { } finally {
SqlUtil.freeAll(); SqlUtil.freeAll();
} }
if(comp!=null) { if (comp != null) {
comp.setVisible(false); comp.setVisible(false);
} }
} }
}.start(); }.start();
}catch(Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
long time21 = System.nanoTime();
System.out.println(
"总时长========================================== " + (time21 - time20) / 1000000L);
} }
} }

@ -208,6 +208,29 @@ public class PartBean extends SAPPushBOMBean {
getUserName(), getZDATE() }; getUserName(), getZDATE() };
} }
public Object[] getRowDataZxjc() throws Exception {
String name = part.getStringProperty("object_name");
TCComponent[] facts = part.getRelatedComponents(REL_PART_FACTNO);
int len = facts == null ? 0 : facts.length;
System.out.println("获取出厂编号:" + part);
String factNo = "";
for (int i = 0; i < len; i++) {
String type = facts[i].getType();
System.out.println(">> 找到子对象:" + facts[i] + "|" + type);
factoryNos = facts;
if (TYPE_FACTNO.equals(type)) {
factNo = facts[i].getStringProperty("item_id");
this.factoryNo = (TCComponentItem) facts[i];
break;
}
}
String zt2_site = part.getStringProperty("zt2_Site");
String zt2_tankNo = part.getStringProperty("zt2_TankNo");
// return new Object[] {true,index,zt2_site,zt2_tankNo,name,this,factNo};
return new Object[] { true, index, zt2_site, zt2_tankNo, name, this, factNo,"",""};
}
public Object[] getZYKGRowData() throws Exception { public Object[] getZYKGRowData() throws Exception {
String name = part.getStringProperty("object_name"); String name = part.getStringProperty("object_name");
String zt2_site = part.getStringProperty("zt2_Site"); String zt2_site = part.getStringProperty("zt2_Site");

Loading…
Cancel
Save