互感器成本BOM导出

pull/1/head
陈翼晖 1 year ago
parent c2a0fade4b
commit 68609b09fa

@ -300,11 +300,11 @@
<command name="创建生产信息传递通知单" id="com.connor.chint.sap2.zykg.command.CreateProductionChangeCommand#ztdz"/> <command name="创建生产信息传递通知单" id="com.connor.chint.sap2.zykg.command.CreateProductionChangeCommand#ztdz"/>
<command name="项目计划管理" id="com.connor.chint.sap2.commands.OpenPiCommand"/> <command name="项目计划管理" id="com.connor.chint.sap2.commands.OpenPiCommand"/>
<command name="互感器成本BOM导出" id="com.chint.plm.costbomreport.BomCostReportCmd"/>
</extension> </extension>
<extension point="org.eclipse.ui.handlers"> <extension point="org.eclipse.ui.handlers">
<handler commandId="com.connor.chint.sap2.commands.OpenPiCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.OpenPiCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.chint.plm.costbomreport.BomCostReportCmd" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.AutoCreateBomComd" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.AutoCreateBomComd" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.ImpSAPBomCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.ImpSAPBomCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.zykg.command.CreateProductionChangeCommand#ztdz" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.zykg.command.CreateProductionChangeCommand#ztdz" class="com.connor.chint.sap2.KHandler"/>
@ -1989,6 +1989,7 @@
<!--正泰定制--> <!--正泰定制-->
<menuContribution locationURI="menu:com.connor.chint.sap2.menu.ztdz?after=additions"> <menuContribution locationURI="menu:com.connor.chint.sap2.menu.ztdz?after=additions">
<command commandId = "com.connor.chint.sap2.commands.ArefreshThCommand" id = "com.connor.chint.sap2.commands.ArefreshThCommand"> <command commandId = "com.connor.chint.sap2.commands.ArefreshThCommand" id = "com.connor.chint.sap2.commands.ArefreshThCommand">
<visibleWhen> <visibleWhen>
<and> <and>
@ -2779,6 +2780,27 @@
</command> </command>
</menu> </menu>
<command commandId = "com.chint.plm.costbomreport.BomCostReportCmd" id = "com.chint.plm.costbomreport.BomCostReportCmd">
<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.chint.plm.costbomreport.BomCostReportCmd">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution> </menuContribution>
<!--中压设备--> <!--中压设备-->
@ -4037,7 +4059,7 @@
<!-- <!--
<command commandId = "com.connor.chint.sap2.commands.BOMexport" id = "com.connor.chint.sap2.menu.wlgl.bomexport"/> <command commandId = "com.connor.chint.sap2.commands.BOMexport" id = "com.connor.chint.sap2.menu.wlgl.bomexport"/>
<command commandId = "com.connor.chint.sap2.commands.TestCommands" id = "com.connor.chint.sap2.menu.wlgl.flquery"/> <command commandId = "com.connor.chint.sap2.commands.TestCommands" id = "com.connor.chint.sap2.menu.wlgl.flquery"/>
-->
<command commandId = "com.chint.plm.SearchSapResult.SearchSapResultComd" id = "com.chint.plm.SearchSapResult.SearchSapResultComd"> <command commandId = "com.chint.plm.SearchSapResult.SearchSapResultComd" id = "com.chint.plm.SearchSapResult.SearchSapResultComd">
<visibleWhen> <visibleWhen>
<and> <and>
@ -4058,7 +4080,7 @@
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command>--> </command>
<command commandId = "com.connor.chint.sap2.commands.DownloadFilesCommand" id = "com.connor.chint.sap2.menu.wlgl.pdfdownload"> <command commandId = "com.connor.chint.sap2.commands.DownloadFilesCommand" id = "com.connor.chint.sap2.menu.wlgl.pdfdownload">
<visibleWhen> <visibleWhen>
<and> <and>

@ -0,0 +1,117 @@
/**
* Copyright 2023 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.costbomreport
* @author: cyh
* @date: 20231226 11:21:45
*/
package com.chint.plm.costbomreport;
import java.math.BigDecimal;
import java.util.Objects;
/**
* @author cyh
*
*/
public class BomCostBean {
private String bomMaterial;// BOM物料编码zt2_BOMMaterial
private String objectDesc;// BOM属性bl_rev_object_desc
private String unit;// BOM属性bl_item_zt2_unit
private String blQuantity;// BOM属性bl_quantity
// private Boolean isDesign;// BOM物料编码
private String utilization;
private String itemId;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getUtilization() {
return utilization;
}
public void setUtilization(String utilization) {
this.utilization = utilization;
}
public void addQuantity(String addQty) {
blQuantity = new BigDecimal(addQty).add(new BigDecimal(blQuantity)).setScale(2, BigDecimal.ROUND_HALF_UP)
.toString();
}
public BomCostBean(String bomMaterial, String objectDesc, String unit, String blQuantity) {
super();
this.bomMaterial = bomMaterial;
this.objectDesc = objectDesc;
this.unit = unit;
this.blQuantity = blQuantity;
// this.isDesign = isDesign;
}
public BomCostBean(String bomMaterial) {
super();
this.bomMaterial = bomMaterial;
}
public String getBomMaterial() {
return bomMaterial;
}
public void setBomMaterial(String bomMaterial) {
this.bomMaterial = bomMaterial;
}
public String getObjectDesc() {
return objectDesc;
}
public void setObjectDesc(String objectDesc) {
this.objectDesc = objectDesc;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getBlQuantity() {
return blQuantity;
}
public void setBlQuantity(String blQuantity) {
this.blQuantity = blQuantity;
}
@Override
public int hashCode() {
return Objects.hash(bomMaterial);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BomCostBean other = (BomCostBean) obj;
return Objects.equals(bomMaterial, other.bomMaterial);
}
// public Boolean getIsDesign() {
// return isDesign;
// }
//
// public void setIsDesign(Boolean isDesign) {
// this.isDesign = isDesign;
// }
}

@ -0,0 +1,59 @@
/**
* Copyright 2023 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.costbomreport
* @author: cyh
* @date: 20231226 11:14:48
*/
package com.chint.plm.costbomreport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.chint.plm.getGCTH.AutoKTBean;
import com.chint.plm.getGCTH.AutoKTOp;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
/**
* @author cyh
*
*/
public class BomCostReportCmd extends KCommand {
public BomCostReportCmd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
// String groupID = "";
try {
// groupID = SAPUtil.getGroupID(session);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
String type = targetComponent.getType();
if (!type.equals("ZT2_Design3DRevision")) {
MessageBox.post("请选择图纸版本对象", "", MessageBox.ERROR);
return;
}
new BomCostReportOp(app, actionInfo, (TCComponent) targetComponent).executeOperation();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}

@ -0,0 +1,349 @@
/**
* Copyright 2023 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.costbomreport
* @author: cyh
* @date: 20231226 11:33:52
*/
package com.chint.plm.costbomreport;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.swing.filechooser.FileSystemView;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.chint.plm.getGCTH.AutoKTBean;
import com.connor.chint.sap2.sap.SAPXBController;
import com.connor.chint.sap2.sap.YCLMaterialBean;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
/**
* BOM
* @author cyh
*
*/
public class BomCostReportOp extends AbstractAIFOperation {
private AbstractAIFApplication app;
private TCSession session;
private TCComponent target;
public BomCostReportOp(AbstractAIFApplication app, String actionInfo, TCComponent target) {
this.app = app;
this.session = (TCSession) app.getSession();
this.target = target;
}
@Override
public void executeOperation() throws Exception {
// 自制件有子件削层,外购自己 、 自制件无子件原材料展开 、 物料:标准件
MyProgressBarCompent my = new MyProgressBarCompent("", "BOM报表导出中......");
try {
List<BomCostBean> designList = new ArrayList<>();
List<BomCostBean> rawmList = new ArrayList<>();
List<BomCostBean> standList = new ArrayList<>();
// 外购不展开,自制削层、原材料展开
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentItemRevision rev = (TCComponentItemRevision) target;
win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine bomline = win.getTopBOMLine();
Map<String, ExpandPSData[]> allBomMap = BomToSapUtil.getBomLineTreeNodeSOA(bomline);
// 数据集模板 CHINT_M046_CB excel
StringBuffer errMessage = new StringBuffer("");
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc> ", "", MessageBox.INFORMATION);
}
getAllBomCost(allBomMap, bomline, 1, designList, rawmList, standList, errMessage);
System.out.println("standList====>" + standList.size());
File tempFile = BomToSapUtil.getFile(session, "CHINT_M046_CB", "MSExcelX");
String excelName = rev.getProperty("item_id") + "_" + rev.getProperty("object_name") + "_"
+ rev.getProperty("item_revision_id") + "_" + "报价BOM.xlsx";
Collections.sort(designList, new Comparator<BomCostBean>() {
@Override
public int compare(BomCostBean o1, BomCostBean o2) {
return o1.getItemId().compareTo(o2.getItemId());
}
});
String path = outputExcel(excelName, tempFile, designList, rawmList, standList);
my.setVisible(false);
MessageBox.post("BOM报表导出完成,路径:" + path, "", MessageBox.INFORMATION);
Runtime.getRuntime().exec("cmd /c start " + path);
} catch (Exception e) {
e.printStackTrace();
} finally {
SqlUtil.freeAll();
my.setVisible(false);
}
}
/**
* @param excelName
* @param tempFile
* @param standList
* @param rawmList
* @param designList
* @throws Exception
* @function
*/
private String outputExcel(String excelName, File tempFile, List<BomCostBean> designList,
List<BomCostBean> rawmList, List<BomCostBean> standList) throws Exception {
// TODO Auto-generated method stub
FileInputStream in = new FileInputStream(tempFile);
XSSFWorkbook wb = new XSSFWorkbook(in);
in.close();
XSSFSheet sheetAt = wb.getSheetAt(0);
int i = 1;
for (BomCostBean detailsBean : designList) {
// 导出excel设置值
XSSFRow row1 = BomToSapUtil.getRow(sheetAt, i + 1);
BomToSapUtil.setCellValue(row1.getCell(0), 0, row1, i + "");// 序号
BomToSapUtil.setCellValue(row1.getCell(1), 1, row1, detailsBean.getBomMaterial());// 批次号
BomToSapUtil.setCellValue(row1.getCell(2), 2, row1, detailsBean.getObjectDesc());// 父物料编码
BomToSapUtil.setCellValue(row1.getCell(3), 3, row1, detailsBean.getUnit());// WBS
BomToSapUtil.setCellValue(row1.getCell(4), 4, row1, detailsBean.getBlQuantity());// SAP状态
BomToSapUtil.setCellValue(row1.getCell(8), 8, row1, detailsBean.getUtilization());// 具体信息
i = i + 1;
}
for (BomCostBean detailsBean : rawmList) {
// 导出excel设置值
XSSFRow row1 = BomToSapUtil.getRow(sheetAt, i + 1);
BomToSapUtil.setCellValue(row1.getCell(0), 0, row1, i + "");// 序号
BomToSapUtil.setCellValue(row1.getCell(1), 1, row1, detailsBean.getBomMaterial());// 批次号
BomToSapUtil.setCellValue(row1.getCell(2), 2, row1, detailsBean.getObjectDesc());// 父物料编码
BomToSapUtil.setCellValue(row1.getCell(3), 3, row1, detailsBean.getUnit());// WBS
BomToSapUtil.setCellValue(row1.getCell(4), 4, row1, detailsBean.getBlQuantity());// SAP状态
BomToSapUtil.setCellValue(row1.getCell(8), 8, row1, detailsBean.getUtilization());// 具体信息
i = i + 1;
}
for (BomCostBean detailsBean : standList) {
// 导出excel设置值
XSSFRow row1 = BomToSapUtil.getRow(sheetAt, i + 1);
BomToSapUtil.setCellValue(row1.getCell(0), 0, row1, i + "");// 序号
BomToSapUtil.setCellValue(row1.getCell(1), 1, row1, detailsBean.getBomMaterial());// 批次号
BomToSapUtil.setCellValue(row1.getCell(2), 2, row1, detailsBean.getObjectDesc());// 父物料编码
BomToSapUtil.setCellValue(row1.getCell(3), 3, row1, detailsBean.getUnit());// WBS
BomToSapUtil.setCellValue(row1.getCell(4), 4, row1, detailsBean.getBlQuantity());// SAP状态
BomToSapUtil.setCellValue(row1.getCell(8), 8, row1, detailsBean.getUtilization());// 具体信息
i = i + 1;
}
// 桌面
File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory();
String desktopPath = desktopDir.getAbsolutePath();
// 文件保存到桌面,名称:结果导出时间戳
File file2 = new File(desktopPath + File.separator + excelName);
FileOutputStream os = new FileOutputStream(file2);
wb.write(os);
os.flush();
os.close();
return desktopPath + File.separator + excelName;
}
/**
* @param allBomMap
* @param bomline
* @param standList
* @param rawmList
* @param designList
* @throws TCException
* @function BOMCOST
*/
private void getAllBomCost(Map<String, ExpandPSData[]> allBomMap, TCComponentBOMLine bomline, double len,
List<BomCostBean> designList, List<BomCostBean> rawmList, List<BomCostBean> standList,
StringBuffer errMessage) throws Exception {
// TODO Auto-generated method stub
ExpandPSData[] expandPSDatas = allBomMap.get(bomline.getUid());
for (ExpandPSData expandPSData : expandPSDatas) {
TCComponentBOMLine childLine = expandPSData.bomLine;
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
String qty = childLine.getProperty("bl_quantity");
String type = itemRevOfBOMLine.getType();
if (type.equals("ZT2_Design3DRevision")) {
String ztSource = itemRevOfBOMLine.getProperty("zt2_Source");
ExpandPSData[] childPSDatas = allBomMap.get(childLine.getUid());
// 自制且没有子件 原材料展开
if (ztSource.equals("自制")) {
// 自制有子件 削层 展开 rev.getProperty("zt2_MaterialMark").trim();
if (childPSDatas == null || childPSDatas.length == 0) {
String materialMark = itemRevOfBOMLine.getProperty("zt2_MaterialMark").trim();
if (materialMark != null && !materialMark.isEmpty()) {
// 展开
expandRawMatnr(materialMark, childLine, rawmList, len, errMessage);
} else {
// 获取物料representation_for
TCComponent material = itemRevOfBOMLine.getRelatedComponent("representation_for");
if (material != null) {
String materialNo = material.getProperty("zt2_MaterialNo");
addToBeans(designList, materialNo, childLine, qty, len, null, material);
}
}
} else {
getAllBomCost(allBomMap, childLine, len * Double.parseDouble(qty), designList, rawmList,
standList, errMessage);
}
} else if (ztSource.equals("外购")) {
// 外购不展开
TCComponent material = itemRevOfBOMLine.getRelatedComponent("representation_for");
if (material != null) {
String materialNo = material.getProperty("zt2_MaterialNo");
addToBeans(designList, materialNo, childLine, qty, len, null, material);
}
}
} else {
// 标准件
String materialNo = itemRevOfBOMLine.getProperty("zt2_MaterialNo");
addToBeans(standList, materialNo, childLine, qty, len, null, null);
}
}
}
/**
*
* @param materialMark
* @param len
* @param qty
* @param rawmList
* @param childLine
* @param errMessage
* @throws SQLException
* @throws TCException
* @function
*/
private void expandRawMatnr(String materialMark, TCComponentBOMLine childLine, List<BomCostBean> rawmList,
double len, StringBuffer errMessage) throws Exception {
// TODO Auto-generated method stub
ResultSet rs = SqlUtil.read(new Object[] { materialMark },
SAPXBController.SQL_MATERIAL_QUERY.replaceAll("CHINT_M007_MATERIAL", "CHINT_M043_MATERIAL"));
TCComponentItemRevision comp = null;
String materialno = ""; // 物料编码
String materialutilization = "";// 利用率
String materialunit = "";// 单位
if (rs.next()) {
materialno = rs.getString(1);
materialutilization = rs.getString(2);
materialunit = rs.getString(3);
TCComponentItemType itemType = (TCComponentItemType) session.getTypeService().getTypeComponent("Item");
TCComponentItem item = itemType.find(materialno);
if (item != null) {
comp = item.getLatestItemRevision();
} else {
errMessage.append("tc中查询不到[ID]为[" + materialno + "]的原材料;");
}
} else {
errMessage.append("查询不到[材料标记]为[" + materialMark + "]的原材料;");
return;
}
SqlUtil.free();
String qty = getZYSAPMENGE2(materialutilization, childLine.getItemRevision(), childLine, errMessage);
addToBeans(rawmList, materialno, childLine, qty, len, materialutilization, comp);
}
/**
* @param designList
* @param materialNo
* @param childLine
* @param qty
* @param len
* @param materialutilization
* @param comp
* @throws TCException
* @function
*/
private void addToBeans(List<BomCostBean> designList, String materialNo, TCComponentBOMLine childLine, String qty,
double len, String materialutilization, TCComponent comp) throws TCException {
// TODO Auto-generated method stub
int indexOf = designList.indexOf(new BomCostBean(materialNo));
if (len != 1) {
qty = String.valueOf(Double.valueOf(qty) * len);
}
if (indexOf > -1) {
BomCostBean bomCostBean = designList.get(indexOf);
bomCostBean.addQuantity(qty);
} else {
String objectDesc = childLine.getProperty("bl_rev_object_desc");// bl_item_zt2_unit bl_quantity
if (comp != null) {
objectDesc = comp.getProperty("object_desc");
}
String itemId = childLine.getItemRevision().getProperty("item_id");
String unit = childLine.getProperty("bl_item_zt2_unit");
BomCostBean bomCostBean = new BomCostBean(materialNo, objectDesc, unit, qty);
bomCostBean.setItemId(itemId);
designList.add(bomCostBean);
if (materialutilization != null) {
bomCostBean.setUtilization(materialutilization);
}
}
}
public String getZYSAPMENGE2(String lylStr, TCComponentItemRevision design, TCComponentBOMLine line,
StringBuffer errMessage) throws Exception {
double lyl = -1;
if (!KUtil.isEmpty(lylStr)) {
try {
lyl = Double.parseDouble(lylStr);
} catch (Exception e) {
e.printStackTrace();
}
} else {
lyl = 0.85;
}
String zt2_TYJNo = line.getProperty("ZT2_TYSpecifications");
if (!KUtil.isEmpty(zt2_TYJNo)) {
String weight = line.getProperty("ZT2_TYWeight");
if (KUtil.isEmpty(weight)) {
errMessage.append("未填写通用件重量;");
return "0";
}
Double dw = Double.parseDouble(weight);
return String.format("%.3f", dw / lyl);
} else {
double dw = design.getDoubleProperty("zt2_DesignWeight");
return String.format("%.3f", dw / lyl);
}
}
}

@ -0,0 +1,27 @@
/**
* Copyright 2023 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.costbomreport
* @author: cyh
* @date: 2023Äê12ÔÂ26ÈÕ ÏÂÎç1:41:26
*/
package com.chint.plm.costbomreport;
import java.util.ArrayList;
import java.util.List;
/**
* @author cyh
*
*/
public class Test {
public static void main(String[] args) {
BomCostBean bean = new BomCostBean("123", "222", "33", "22");
List<BomCostBean> list = new ArrayList<>();
list.add(bean);
System.out.println(list.indexOf(new BomCostBean("123")));
}
}

@ -166,6 +166,15 @@ public class AutoKTOp extends AbstractAIFOperation{
return null; return null;
} }
/**
* BOM
* @param childWlbm
* @param childQty
* @param ZT2_ClassificationNo
* @param applyPart
* @throws Exception
* @function
*/
public void createBom(List<String> childWlbm,List<String> childQty public void createBom(List<String> childWlbm,List<String> childQty
,String ZT2_ClassificationNo,TCComponentItemRevision applyPart) throws Exception { ,String ZT2_ClassificationNo,TCComponentItemRevision applyPart) throws Exception {
List<RelativeStructureChildInfo> childInfos = new ArrayList<>(); List<RelativeStructureChildInfo> childInfos = new ArrayList<>();
@ -248,6 +257,15 @@ public class AutoKTOp extends AbstractAIFOperation{
// //
return rev; return rev;
} }
/**
*
* @param code
* @param wbsNo
* @param session
* @return
* @throws Exception
* @function
*/
public boolean checkTargets(String code,String wbsNo,TCSession session) throws Exception { public boolean checkTargets(String code,String wbsNo,TCSession session) throws Exception {
Map<String, String> field = new HashMap<String, String>(); Map<String, String> field = new HashMap<String, String>();

@ -22,7 +22,11 @@ import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService; import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
/**
*
* @author cyh
*
*/
public class AutoFeedingCommand extends KCommand { public class AutoFeedingCommand extends KCommand {
private TCComponentItemType type; private TCComponentItemType type;

@ -79,7 +79,7 @@ public class BatchAddController {
BatchReviewBean bean; BatchReviewBean bean;
for (int i = 0; i < rowCunt; i++) { for (int i = 0; i < rowCunt; i++) {
if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) { if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) {
bean = (BatchReviewBean) dialog.t_part.getValueAt(i, 3); bean = (BatchReviewBean) dialog.t_part.getValueAt(i, 4);
list.add((TCComponentItemRevision) bean.getComp()); list.add((TCComponentItemRevision) bean.getComp());
} }
} }
@ -429,7 +429,7 @@ public class BatchAddController {
rev = ((TCComponentItem) comp).getLatestItemRevision(); rev = ((TCComponentItem) comp).getLatestItemRevision();
rev = ((TCComponentItem) comp).getLatestItemRevision(); rev = ((TCComponentItem) comp).getLatestItemRevision();
bean.setRev(rev); bean.setRev(rev);
System.out.println("rev"+rev);
if (dialog.click_type == 0) { if (dialog.click_type == 0) {
dialog.setRev_before(rev); dialog.setRev_before(rev);
dialog.jtf_replace_before.setText(bean.getZt2_MaterialNo()); dialog.jtf_replace_before.setText(bean.getZt2_MaterialNo());

@ -76,7 +76,7 @@ public class BatchAddDialog extends AbstractAIFDialog {
protected JTable t_part; protected JTable t_part;
private CheckBoxTableHeaderRenderer tableHeaderRenderer; private CheckBoxTableHeaderRenderer tableHeaderRenderer;
public final String[] HEADER = new String[] { "", "序号", "方案编码", "方案名称", "发布状态", "所有者" }; public final String[] HEADER = new String[] { "", "序号","出厂编号", "方案编码", "方案名称", "发布状态", "所有者" };
public final int[] HEADERWIDTH = new int[] { 50, 70, 200, 200, 150, 100 }; public final int[] HEADERWIDTH = new int[] { 50, 70, 200, 200, 150, 100 };
// 限制范围 // 限制范围
@ -413,6 +413,13 @@ public class BatchAddDialog extends AbstractAIFDialog {
isTCM = "已发布"; isTCM = "已发布";
} }
bean = new BatchReviewBean(true, object_name, isTCM, drawNo, rev); bean = new BatchReviewBean(true, object_name, isTCM, drawNo, rev);
//获取出厂编号 2023/12/27新增
TCComponent factory = rev.getRelatedComponent("ZT2_FactoryNumber");
if (factory != null) {
String itemId = factory.getProperty("item_id");
bean.setFactoryNo(itemId);
}
bean.setOwning_user(owning_user); bean.setOwning_user(owning_user);
programms.add(bean); programms.add(bean);
} }

@ -79,7 +79,7 @@ public class BatchRemoveController {
BatchReviewBean bean; BatchReviewBean bean;
for (int i = 0; i < rowCunt; i++) { for (int i = 0; i < rowCunt; i++) {
if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) { if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) {
bean = (BatchReviewBean) dialog.t_part.getValueAt(i, 3); bean = (BatchReviewBean) dialog.t_part.getValueAt(i, 4);
list.add((TCComponentItemRevision) bean.getComp()); list.add((TCComponentItemRevision) bean.getComp());
} }
} }

@ -75,7 +75,7 @@ public class BatchRemoveDialog extends AbstractAIFDialog {
protected JTable t_part; protected JTable t_part;
private CheckBoxTableHeaderRenderer tableHeaderRenderer; private CheckBoxTableHeaderRenderer tableHeaderRenderer;
public final String[] HEADER = new String[] { "", "序号", "方案编码", "方案名称", "发布状态", "所有者" }; public final String[] HEADER = new String[] { "", "序号","出厂编号", "方案编码", "方案名称", "发布状态", "所有者" };
public final int[] HEADERWIDTH = new int[] { 50, 70, 200, 200, 150, 100 }; public final int[] HEADERWIDTH = new int[] { 50, 70, 200, 200, 150, 100 };
// ÏÞÖÆ·¶Î§ // ÏÞÖÆ·¶Î§
@ -385,6 +385,11 @@ public class BatchRemoveDialog extends AbstractAIFDialog {
} }
bean = new BatchReviewBean(true, object_name, isTCM, drawNo, rev); bean = new BatchReviewBean(true, object_name, isTCM, drawNo, rev);
bean.setOwning_user(owning_user); bean.setOwning_user(owning_user);
TCComponent factory = rev.getRelatedComponent("ZT2_FactoryNumber");
if (factory != null) {
String itemId = factory.getProperty("item_id");
bean.setFactoryNo(itemId);
}
programms.add(bean); programms.add(bean);
} }
} }

@ -79,7 +79,7 @@ public class BatchReplaceController {
BatchReviewBean bean; BatchReviewBean bean;
for (int i = 0; i < rowCunt; i++) { for (int i = 0; i < rowCunt; i++) {
if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) { if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) {
bean = (BatchReviewBean) dialog.t_part.getValueAt(i, 3); bean = (BatchReviewBean) dialog.t_part.getValueAt(i, 4);
list.add((TCComponentItemRevision) bean.getComp()); list.add((TCComponentItemRevision) bean.getComp());
} }
} }

@ -385,6 +385,12 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
isTCM = "已发布"; isTCM = "已发布";
} }
bean = new BatchReviewBean(true, object_name, isTCM, drawNo, rev); bean = new BatchReviewBean(true, object_name, isTCM, drawNo, rev);
//获取出厂编号 2023/12/27新增
TCComponent factory = rev.getRelatedComponent("ZT2_FactoryNumber");
if (factory != null) {
String itemId = factory.getProperty("item_id");
bean.setFactoryNo(itemId);
}
bean.setOwning_user(owning_user); bean.setOwning_user(owning_user);
programms.add(bean); programms.add(bean);
} }

@ -12,8 +12,17 @@ public class BatchReviewBean {
public static int model_isTCM_INDEX = 3; public static int model_isTCM_INDEX = 3;
private int index = 0; private int index = 0;
private TCComponent comp; private TCComponent comp;
private String factoryNo;
public BatchReviewBean(boolean isSelected, String object_name, String isTCM, String drawNo, TCComponent comp) { public String getFactoryNo() {
return factoryNo;
}
public void setFactoryNo(String factoryNo) {
this.factoryNo = factoryNo;
}
public BatchReviewBean(boolean isSelected, String object_name, String isTCM, String drawNo, TCComponent comp) {
super(); super();
this.isSelected = isSelected; this.isSelected = isSelected;
this.object_name = object_name; this.object_name = object_name;
@ -93,7 +102,7 @@ public class BatchReviewBean {
} }
public Object[] getBatchReplaceRowData() { public Object[] getBatchReplaceRowData() {
return new Object[] { isSelected, index, drawNo, this, isTCM, owning_user }; return new Object[] { isSelected, index,factoryNo, drawNo, this, isTCM, owning_user };
} }
} }

@ -17,7 +17,11 @@ import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService; import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
/**
*
* @author cyh
*
*/
public class ArefreshThCommand extends KCommand { public class ArefreshThCommand extends KCommand {
private TCComponentItemType type; private TCComponentItemType type;

@ -50,18 +50,18 @@ public class AutoCreateBomComd extends KCommand {
List<String> childWlbm = new ArrayList<String>(); List<String> childWlbm = new ArrayList<String>();
List<String> childQty = new ArrayList<String>(); List<String> childQty = new ArrayList<String>();
AutoKTBean bean = new AutoKTBean(); AutoKTBean bean = new AutoKTBean();
bean.setCcpName(split[0]); bean.setCcpName(split[0]);//产成品名称
bean.setFabmCode(split[1]); bean.setFabmCode(split[1]);//方案编码类别
bean.setFolderName(split[2]); bean.setFolderName(split[2]);//存放文件夹名称
bean.setGxbm(split[4]); bean.setGxbm(split[4]);//投料的工序编码
String[] childMsgs = split[3].split(";"); String[] childMsgs = split[3].split(";");
for(String childMsg : childMsgs) { for(String childMsg : childMsgs) {
String[] split2 = childMsg.split(":"); String[] split2 = childMsg.split(":");
childWlbm.add(split2[0]); childWlbm.add(split2[0]);
childQty.add(split2[1]); childQty.add(split2[1]);
} }
bean.setChildQty(childQty); bean.setChildQty(childQty); //子件数量
bean.setChildWlbm(childWlbm); bean.setChildWlbm(childWlbm);//子件物料编码
beans.put(split[0],bean); beans.put(split[0],bean);
} }
} }

@ -92,6 +92,7 @@ public class SendProjectLcCommand extends KCommand {
AIFComponentContext[] xmzxCh = xmzx.getChildren(); AIFComponentContext[] xmzxCh = xmzx.getChildren();
TCComponentFolder tpsj = null; TCComponentFolder tpsj = null;
List<TCComponentItemRevision> tpsjList = new ArrayList<TCComponentItemRevision>(); List<TCComponentItemRevision> tpsjList = new ArrayList<TCComponentItemRevision>();
//在项目计划中查询铜牌设计任务
for (int i = 0; i < xmzxCh.length; i++) { for (int i = 0; i < xmzxCh.length; i++) {
InterfaceAIFComponent c = xmzxCh[i].getComponent(); InterfaceAIFComponent c = xmzxCh[i].getComponent();
String fName = c.getProperty("object_name"); String fName = c.getProperty("object_name");
@ -147,11 +148,13 @@ public class SendProjectLcCommand extends KCommand {
MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2); MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2);
return; return;
} }
//获取资源指派
TCComponent user = tpsjTask.getRelatedComponent("ResourceAssignment"); TCComponent user = tpsjTask.getRelatedComponent("ResourceAssignment");
String userId = user == null ? "" : user.getProperty("user_id"); String userId = user == null ? "" : user.getProperty("user_id");
String userName = user == null ? "" : user.getProperty("user_name"); String userName = user == null ? "" : user.getProperty("user_name");
Map<String,String> lcApplyMap = new HashMap<>(); Map<String,String> lcApplyMap = new HashMap<>();
//获取编码申请的规则
String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session); String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session);
for(String preference:preferences) { for(String preference:preferences) {
String[] split = preference.split(":"); String[] split = preference.split(":");
@ -186,13 +189,7 @@ public class SendProjectLcCommand extends KCommand {
Date date = new Date(); Date date = new Date();
String format = sdf.format(date); String format = sdf.format(date);
esbMap.put("deliverytime",format); esbMap.put("deliverytime",format);
// TCComponent relatedComponent = tpsjTask.getRelatedComponent("ResourceAssignment");
// String userName = "";
// String userId = "";
// if(relatedComponent!=null) {
// userName = relatedComponent.getStringProperty("user_name");
// userId = relatedComponent.getStringProperty("user_id");
// }
esbMap.put("username",userName); esbMap.put("username",userName);
esbMap.put("userid",userId); esbMap.put("userid",userId);
@ -223,6 +220,7 @@ public class SendProjectLcCommand extends KCommand {
for(AIFComponentContext child : children) { for(AIFComponentContext child : children) {
Map facCpMap = new HashMap<>(); Map facCpMap = new HashMap<>();
TCComponent ccbhTarget = (TCComponent) child.getComponent(); TCComponent ccbhTarget = (TCComponent) child.getComponent();
//查询出厂编号的引用,判断是否有铜排单元
AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation( AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation(
new String[] { "Part Revision" }, new String[] { "ZT2_FactoryNumber" }); new String[] { "Part Revision" }, new String[] { "ZT2_FactoryNumber" });
String ccbhId = ccbhTarget.getStringProperty("item_id"); String ccbhId = ccbhTarget.getStringProperty("item_id");
@ -240,7 +238,7 @@ public class SendProjectLcCommand extends KCommand {
if(!hasFabm) { if(!hasFabm) {
Boolean flag = false; Boolean flag = false;
System.out.println("lcApplyMap===>"+lcApplyMap.toString()+"ccbhId==>"+ccbhId); System.out.println("lcApplyMap===>"+lcApplyMap.toString()+"ccbhId==>"+ccbhId);
//编码申请铜排单元
for(String fac : lcApplyMap.keySet()) { for(String fac : lcApplyMap.keySet()) {
if(ccbhId.contains(fac)) { if(ccbhId.contains(fac)) {
flag = true; flag = true;
@ -316,6 +314,7 @@ public class SendProjectLcCommand extends KCommand {
sql1[13] = sdf2.format(finish_date); sql1[13] = sdf2.format(finish_date);
esbMap.put("factorynos",factoryNos); esbMap.put("factorynos",factoryNos);
try { try {
//写入利池数据库
Connection mySqlConnection = SqlUtil.getMySqlConnection(); Connection mySqlConnection = SqlUtil.getMySqlConnection();
if(mySqlConnection==null) { if(mySqlConnection==null) {
MessageBox.post("利驰数据库链接异常,请检查。","提示",2); MessageBox.post("利驰数据库链接异常,请检查。","提示",2);

@ -643,15 +643,6 @@ public class CreateProcBYQController {
meopRev = (TCComponentItemRevision)meproces; meopRev = (TCComponentItemRevision)meproces;
list_standard.add(meopRev); list_standard.add(meopRev);
} }
// 通过制造目标关系反查关联的工艺对象
// AIFComponentContext[] comps = rev_standard.whereReferencedByTypeRelation(
// new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" });
// TCComponent meproces = SAPUtil.getMeproces(rev_standard.getUid(), session);
// TCComponentItemRevision meopRev;
// for (int i = 0, len = comps.length; i < len; i++) {
// meopRev = (TCComponentItemRevision) comps[i].getComponent();
// list_standard.add(meopRev);
// }
} }
} }

@ -47,8 +47,9 @@ public class GYApplyCodeControllerzt {
private TCComponentFolder folder; private TCComponentFolder folder;
// private static String QUERY_NAMES[] = { "%一次规范书%", "%二次规范书%", "%结构方案%" }; // private static String QUERY_NAMES[] = { "%一次规范书%", "%二次规范书%", "%结构方案%" };
private static String SQL_QUERY_ALL = "select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where "; // private static String SQL_QUERY_ALL = "select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where ";
private static String SQL_QUERY_ALL = "select t.\"CompanyCodeStr\",t.\"GoodsCode\",t.\"GoodsName\",t.\"GoodsBpNo\","
+ "t.\"GoodsFullInfo\",t.\"GoodsTeRe\",t.\"GoodsUnitCode\",t.\"GoodsPmpcCode\" from CHINT_XBFAH t where ";
// private static String SQL_QUERY_ALL="select // private static String SQL_QUERY_ALL="select
// t.CgdCompanyCode,t.CgdGoodsCode,t.CgdName,t.CgdBpNo,t.CgdGoodsFullInfo,t.CgdTeRe,t.CgdUnitCode,t.CgdPmpcCode // t.CgdCompanyCode,t.CgdGoodsCode,t.CgdName,t.CgdBpNo,t.CgdGoodsFullInfo,t.CgdTeRe,t.CgdUnitCode,t.CgdPmpcCode
// from ccemvw_cgd t where t.CgdPmpcCode='400101012' "; // from ccemvw_cgd t where t.CgdPmpcCode='400101012' ";
@ -119,8 +120,11 @@ public class GYApplyCodeControllerzt {
// String[] prefs = // String[] prefs =
// session.getPreferenceService().getStringValues("database_tc"); // session.getPreferenceService().getStringValues("database_tc");
// Connection conn = SqlUtil.getTCDataConnection(prefs); // Connection conn = SqlUtil.getTCDataConnection(prefs);
String[] stringValues = session.getPreferenceService().getStringValues("database_tc");
return SqlUtil.getConnection() == null ? false : true; //// Connection conn = SqlUtil.getTCDataConnection(prefs);
//
return SqlUtil.getTCDataConnection(stringValues) == null ? false : true;
// return SqlUtil.getConnection() == null ? false : true;
} }
public boolean checkProject() throws TCException { public boolean checkProject() throws TCException {
@ -218,13 +222,15 @@ public class GYApplyCodeControllerzt {
public void getApplyCode(String query_name, String code) throws Exception { public void getApplyCode(String query_name, String code) throws Exception {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.append(SQL_QUERY_ALL); sql.append(SQL_QUERY_ALL);
sql.append(" t.GoodsCode like ").append(code).append("'%'"); // sql.append(" t.GoodsCode like ").append(code).append("'%'");
sql.append(" t.\"GoodsCode\" like '").append(code).append("%'");
Object obj[] = new Object[2]; Object obj[] = new Object[2];
// obj[0] = "%"+code+"%"; // obj[0] = "%"+code+"%";
obj[0] = query_name; obj[0] = query_name;
String groupID = SAPUtil.getGroupID(session); String groupID = SAPUtil.getGroupID(session);
sql.append(" and t.CompanyCodeStr like ?"); sql.append(" and t.\"CompanyCodeStr\" like ?");
// sql.append(" and t.CompanyCodeStr like ?");
// Object obj[] = new Object[1]; // Object obj[] = new Object[1];
// obj[0] = query_name; // obj[0] = query_name;

@ -55,8 +55,9 @@ public class CcpApplyCodeController {
protected TCComponentFolder folder; protected TCComponentFolder folder;
private static String QUERY_NAMES[] = { "%一次规范书%", "%二次规范书%", "%结构方案%" }; private static String QUERY_NAMES[] = { "%一次规范书%", "%二次规范书%", "%结构方案%" };
private static String SQL_QUERY_ALL = "select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where "; // private static String SQL_QUERY_ALL = "select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where ";
private static String SQL_QUERY_ALL = "select t.\"CompanyCodeStr\",t.\"GoodsCode\",t.\"GoodsName\",t.\"GoodsBpNo\","
+ "t.\"GoodsFullInfo\",t.\"GoodsTeRe\",t.\"GoodsUnitCode\",t.\"GoodsPmpcCode\" from CHINT_XBFAH t where ";
// private static String SQL_QUERY_ALL="select // private static String SQL_QUERY_ALL="select
// t.CgdCompanyCode,t.CgdGoodsCode,t.CgdName,t.CgdBpNo,t.CgdGoodsFullInfo,t.CgdTeRe,t.CgdUnitCode,t.CgdPmpcCode // t.CgdCompanyCode,t.CgdGoodsCode,t.CgdName,t.CgdBpNo,t.CgdGoodsFullInfo,t.CgdTeRe,t.CgdUnitCode,t.CgdPmpcCode
// from ccemvw_cgd t where t.CgdPmpcCode='400101012' "; // from ccemvw_cgd t where t.CgdPmpcCode='400101012' ";
@ -116,11 +117,11 @@ public class CcpApplyCodeController {
} }
public boolean checkConn() { public boolean checkConn() {
// String[] prefs =
// session.getPreferenceService().getStringValues("database_tc"); String[] prefs = session.getPreferenceService().getStringValues("database_tc");
// Connection conn = SqlUtil.getTCDataConnection(prefs); // Connection conn = SqlUtil.getTCDataConnection(prefs);
return SqlUtil.getTCDataConnection(prefs) == null ? false : true;
return SqlUtil.getConnection() == null ? false : true; // return SqlUtil.getConnection() == null ? false : true;
} }
public String type = ""; public String type = "";
// 检查是否选中对应的方案文件夹 // 检查是否选中对应的方案文件夹
@ -223,14 +224,15 @@ public class CcpApplyCodeController {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.append(SQL_QUERY_ALL); sql.append(SQL_QUERY_ALL);
System.out.println("isAPPLYS==>"+isAPPLYS); System.out.println("isAPPLYS==>"+isAPPLYS);
sql.append(" t.GoodsCode like '").append(code).append("%'"); // sql.append(" t.GoodsCode like '").append(code).append("%'");
sql.append(" t.\"GoodsCode\" like '").append(code).append("%'");
Object obj[] = new Object[1]; Object obj[] = new Object[1];
// obj[0] = "%"+code+"%"; // obj[0] = "%"+code+"%";
// obj[0] = query_name; // obj[0] = query_name;
String groupID = SAPUtil.getGroupID(session); String groupID = SAPUtil.getGroupID(session);
sql.append(" and t.CompanyCodeStr like ?"); // sql.append(" and t.CompanyCodeStr like ?");
sql.append(" and t.\"CompanyCodeStr\" like ?");
obj[0] = "%"+groupID+"%"; obj[0] = "%"+groupID+"%";
System.out.println("查询语句:" + sql.toString()); System.out.println("查询语句:" + sql.toString());

@ -475,6 +475,9 @@ public class CcpApplyCodeDialog extends AbstractAIFDialog {
if (map_Applicables.get(bean).size() == 1) { if (map_Applicables.get(bean).size() == 1) {
// model3.removeElement(cloneBean); // model3.removeElement(cloneBean);
// model4.addElement(bean); // model4.addElement(bean);
System.out.println("bean===>"+map_Applicables.toString());
map_Applicables.remove(bean);
value_keys.remove(cloneBean);
list_jl3.remove(cloneBean); list_jl3.remove(cloneBean);
list_jl4.add(bean); list_jl4.add(bean);

@ -196,11 +196,19 @@ public class PartBean extends SAPPushBOMBean {
String type = facts[i].getType(); String type = facts[i].getType();
System.out.println(">> 找到子对象:" + facts[i] + "|" + type); System.out.println(">> 找到子对象:" + facts[i] + "|" + type);
factoryNos = facts; factoryNos = facts;
if (SAPZYDialogControllerzt.TYPE_FACTNO.equals(type)) { // if (SAPZYDialogControllerzt.TYPE_FACTNO.equals(type)) {
factNo = facts[i].getStringProperty("item_id"); // String newFactNo = facts[i].getStringProperty("item_id");
this.factoryNo = (TCComponentItem) facts[i]; // //2023/12/27新增逻辑, 出厂编号展示最小的那个
break; // if (factNo.equals("") || factNo.compareTo(newFactNo) > 0) {
} // factNo = newFactNo;
// this.factoryNo = (TCComponentItem) facts[i];
// }
// }
if (SAPZYDialogControllerzt.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_site = part.getStringProperty("zt2_Site");
String zt2_tankNo = part.getStringProperty("zt2_TankNo"); String zt2_tankNo = part.getStringProperty("zt2_TankNo");

@ -1941,113 +1941,188 @@ public class SAPZYDialogControllerzt {
return sBuilder.toString(); return sBuilder.toString();
} }
// 获取物料表中最大的序列
public int getCode() throws SQLException { // 获取传递BOM中最大的序列
String sql = "select Tab_SendBom_Sequence.nextval as sid from dual"; public int getCode() throws SQLException {
ResultSet rs = SqlUtil.read(sql); String sql = "select Tab_SendBom_Sequence.nextval as sid from dual";
Object objs[] = new Object[1]; ResultSet rs = SqlUtil.read(sql);
int code = 0; Object objs[] = new Object[1];
if (rs.next()) { int code = 0;
code = rs.getInt(1); if (rs.next()) {
System.out.println("code:" + code); code = rs.getInt(1);
} System.out.println("code:" + code);
SqlUtil.free(); }
return code; SqlUtil.free();
} return code;
}
// 第二次优化异步传递
public void sendToSapYHAsyn(String ban, boolean isCheckProduct) throws Exception {
List<PartBean> selectedParts = getSelectedParts();
MyProgressBarCompent my = new MyProgressBarCompent("", "智能电气BOM传递SAP......");
try {
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
String groupID2 = SAPUtil.getGroupID();
String userId = session.getUser().getUserId();
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");
int code = getCode();
JSONArray array = new JSONArray();
StringBuilder uids = new StringBuilder("");
for (int i = 0; i < selectedParts.size(); i++) {
String uid = selectedParts.get(i).getPart().getUid();
array.add(uid);
uids.append(uid).append(":");
}
// obj.put("uid", array);
// OkHttpClient client = new OkHttpClient();
String substring = uids.substring(0, uids.length() - 1);
// 新增字段 项目UID执行人改成定时执行不调用接口
String serverHostname = session.getServerHostname();
System.out.println("serverHostname===>" + serverHostname);
String sql = "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')" + ",?,?,'等待组织','未处理',?,?,'未返回',?,?,?)"; // to_date(?,'yyyy-mm-ddhh24:mi:ss')
SqlUtil.write(sql, new String[] { code + "", groupID2, userName, dataTime, zt2_WBSNo, object_name,
ban.replaceAll("方案传递", ""), substring, project.getUid(), serverHostname, userId });
// MediaType mediaType = MediaType.parse("application/json");
// RequestBody body = RequestBody.create(mediaType, obj.toString());
//// String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
// Request request = new Request.Builder().url("http://10.128.10.203:8081/plm/sendBomXB") // http://10.128.10.203:8081/plm/sendBomXB
// .method("POST", body)
// // .addHeader("Cookie", "")
//// .addHeader("Authorization", "Bearer "+token)
// // .addHeader("Connection", "keep-alive")
// .addHeader("Content-Type", "application/json").build();
// Response response = client.newCall(request).execute();
// // response.body().byteStream()
// // System.out.println(response.body().string());
// String string = response.body().string();
// System.out.println("string==>" + string);
// JSONObject parseObject = JSON.parseObject(string);
//
// my.setVisible(false);
// System.out.println("parseObject==>" + parseObject);
MessageBox.post(dialog, "传递请求已记录,请等待飞书通知.", "", MessageBox.INFORMATION);
} catch (Exception e) {
MessageBox.post(dialog, "发生错误:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace();
my.setVisible(false);
} finally {
SqlUtil.freeAll();
my.setVisible(false);
}
}
//第一次优化同步传递
// private String getNum = "select max(code) from CHINT_BOM_TO_SAP_SUM"; // private String getNum = "select max(code) from CHINT_BOM_TO_SAP_SUM";
public void sendToSapYH(String ban, boolean isCheckProduct) throws Exception { public void sendToSapYH(String ban, boolean isCheckProduct) throws Exception {
List<PartBean> selectedParts = getSelectedParts(); List<PartBean> selectedParts = getSelectedParts();
MyProgressBarCompent my = new MyProgressBarCompent("", "智能电气BOM传递SAP......"); MyProgressBarCompent my = new MyProgressBarCompent("", "智能电气BOM传递SAP......");
// try {
// String strs[] = session.getPreferenceService().getStringValues("database_tc");
// if (SqlUtil.getTCDataConnection(strs) == null) {
// MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
// return;
// }
//// ResultSet read = SqlUtil.read(getNum);
//// int code = 1;
//// if(read.next()) {
//// int int1 = read.getInt(1);
//// code = int1 + 1;
//// }
// String groupID2 = SAPUtil.getGroupID();
// String userId = session.getUser().getUserId();
// 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");
// int code = getCode();
//// JSONObject obj = new JSONObject();
//// obj.put("code", code + "");
//// obj.put("groupId", groupID2);
//// obj.put("userId", userId);
//// obj.put("zt2_WBSNo", zt2_WBSNo);
//// obj.put("object_name", object_name);
//// obj.put("projectUid", project.getUid());
// JSONArray array = new JSONArray();
// StringBuilder uids = new StringBuilder("");
// for (int i = 0; i < selectedParts.size(); i++) {
// String uid = selectedParts.get(i).getPart().getUid();
// array.add(uid);
// uids.append(uid).append(":");
// }
//// obj.put("uid", array);
//// OkHttpClient client = new OkHttpClient();
// String substring = uids.substring(0, uids.length() - 1);
// // 新增字段 项目UID执行人改成定时执行不调用接口
// String serverHostname = session.getServerHostname();
// System.out.println("serverHostname===>" + serverHostname);
// String sql = "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')" + ",?,?,'等待组织','未处理',?,?,'未返回',?,?,?)"; // to_date(?,'yyyy-mm-ddhh24:mi:ss')
// SqlUtil.write(sql, new String[] { code + "", groupID2, userName, dataTime, zt2_WBSNo, object_name,
// ban.replaceAll("方案传递", ""), substring, project.getUid(), serverHostname, userId });
//// MediaType mediaType = MediaType.parse("application/json");
//// RequestBody body = RequestBody.create(mediaType, obj.toString());
////// String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
//// Request request = new Request.Builder().url("http://10.128.10.203:8081/plm/sendBomXB") // http://10.128.10.203:8081/plm/sendBomXB
//// .method("POST", body)
//// // .addHeader("Cookie", "")
////// .addHeader("Authorization", "Bearer "+token)
//// // .addHeader("Connection", "keep-alive")
//// .addHeader("Content-Type", "application/json").build();
//// Response response = client.newCall(request).execute();
//// // response.body().byteStream()
//// // System.out.println(response.body().string());
//// String string = response.body().string();
//// System.out.println("string==>" + string);
//// JSONObject parseObject = JSON.parseObject(string);
////
//// my.setVisible(false);
//// System.out.println("parseObject==>" + parseObject);
// MessageBox.post(dialog, "传递请求已记录,请等待飞书通知.", "", MessageBox.INFORMATION);
// } catch (Exception e) {
// MessageBox.post(dialog, "发生错误:" + e.getMessage(), "", MessageBox.ERROR);
// e.printStackTrace();
// my.setVisible(false);
// } finally {
// SqlUtil.freeAll();
// my.setVisible(false);
// }
// 用户点击提交时先将序号、工厂、发起人、发起时间、项目wbs号、项目名称写入中间数据表数据库名称为CHINT_BOM_TO_SAP_SUM
// SqlUtil.getTCDataConnection(BOM_NAMES);
try { try {
String strs[] = session.getPreferenceService().getStringValues("database_tc"); if(selectedParts.size()>0) {
if (SqlUtil.getTCDataConnection(strs) == null) { String[] propValues = new String[selectedParts.size()];
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2); for(int i = 0; i < selectedParts.size(); i++) {
propValues[i] = selectedParts.get(i).getPart().getUid();
}
Object[] params = { project.getUid(), propValues };
TCUserService userService = (TCUserService) session.getUserService();
Object call = userService.call("readBomMsg", params);
String string = call.toString();
//comp.setVisible(false);
System.out.println(string);
new SAPMessageUtil(dialog, "", string);
return; return;
} }
// ResultSet read = SqlUtil.read(getNum);
// int code = 1;
// if(read.next()) {
// int int1 = read.getInt(1);
// code = int1 + 1;
// }
String groupID2 = SAPUtil.getGroupID();
String userId = session.getUser().getUserId();
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");
int code = getCode();
JSONObject obj = new JSONObject();
obj.put("code", code+"");
obj.put("groupId", groupID2);
obj.put("userId", userId);
obj.put("zt2_WBSNo", zt2_WBSNo);
obj.put("object_name", object_name);
obj.put("projectUid", project.getUid());
JSONArray array = new JSONArray();
StringBuilder uids = new StringBuilder("");
for(int i = 0; i < selectedParts.size(); i++) {
String uid = selectedParts.get(i).getPart().getUid();
array.add(uid);
uids.append(uid).append(":");
}
obj.put("uid", array);
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType,obj.toString());
// String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
Request request = new Request.Builder().url("http://10.128.155.206:8082/plm/sendBomXB")
.method("POST", body)
// .addHeader("Cookie", "")
// .addHeader("Authorization", "Bearer "+token)
// .addHeader("Connection", "keep-alive")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
// response.body().byteStream()
// System.out.println(response.body().string());
JSONObject parseObject = JSON.parseObject(response.body().string());
String substring = uids.substring(0, uids.length()-1);
String sql = "insert into CHINT_BOM_TO_SAP_SUM (code,factory,\"USER\",starttime,wbsno,projectno,taskstauts,plmstarttime,plmresult,transfer,keymsg,sapresult) values (?,?,?,to_date(?,'yyyy-mm-ddhh24:mi:ss'),?,?,'组织中',SYSDATE,'未处理','电气设计',?,'未返回')"; //to_date(?,'yyyy-mm-ddhh24:mi:ss')
SqlUtil.write(sql, new String[] {code+"",groupID2,userName,dataTime,zt2_WBSNo,object_name,substring});
my.setVisible(false);
System.out.println("parseObject==>"+parseObject);
MessageBox.post(dialog, "传递请求已记录,请等待飞书通知.", "", MessageBox.ERROR);
} catch (Exception e) { } catch (Exception e) {
MessageBox.post(dialog, "发生错误:" + e.getMessage(), "", MessageBox.ERROR); MessageBox.post(dialog, "发生错误:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace(); e.printStackTrace();
my.setVisible(false); my.setVisible(false);
} finally { } finally {
SqlUtil.freeAll();
my.setVisible(false); my.setVisible(false);
} }
//用户点击提交时先将序号、工厂、发起人、发起时间、项目wbs号、项目名称写入中间数据表数据库名称为CHINT_BOM_TO_SAP_SUM
// SqlUtil.getTCDataConnection(BOM_NAMES);
// try {
// if(selectedParts.size()>0) {
// String[] propValues = new String[selectedParts.size()];
// for(int i = 0; i < selectedParts.size(); i++) {
// propValues[i] = selectedParts.get(i).getPart().getUid();
// }
// Object[] params = { project.getUid(), propValues };
// TCUserService userService = (TCUserService) session.getUserService();
// Object call = userService.call("readBomMsg", params);
// String string = call.toString();
// //comp.setVisible(false);
// System.out.println(string);
// new SAPMessageUtil(dialog, "", string);
// return;
// }
// } catch (Exception e) {
// MessageBox.post(dialog, "发生错误:" + e.getMessage(), "", MessageBox.ERROR);
// e.printStackTrace();
// my.setVisible(false);
// } finally {
// my.setVisible(false);
// }
// MyProgressBarCompent my = new MyProgressBarCompent("", "中压BOM传递SAP......"); // MyProgressBarCompent my = new MyProgressBarCompent("", "中压BOM传递SAP......");
// try { // try {
// sendSapYH(ban, my, isCheckProduct); // sendSapYH(ban, my, isCheckProduct);
@ -2058,7 +2133,7 @@ public class SAPZYDialogControllerzt {
// } finally { // } finally {
// my.setVisible(false); // my.setVisible(false);
// } // }
} }
private void sendSapYH(String ban, MyProgressBarCompent my, boolean isCheckProduct) throws Exception { private void sendSapYH(String ban, MyProgressBarCompent my, boolean isCheckProduct) throws Exception {
process_boms.clear(); process_boms.clear();
// process_jg.clear(); // process_jg.clear();
@ -2704,7 +2779,7 @@ public class SAPZYDialogControllerzt {
// } // }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
String[] properties2 = line2.getProperties(new String[] {"bl_sequence_no","bl_quantity","ZT2_ClassificationNo","ZT2_Remark"}); String[] properties2 = line2.getProperties(new String[] {"bl_sequence_no","bl_quantity","ZT2_ClassificationNo","ZT2_Remark","zt2_State"});
item.setPOSNR(properties2[0]); //line2.getProperty("bl_sequence_no") item.setPOSNR(properties2[0]); //line2.getProperty("bl_sequence_no")
String sss = properties2[1];//line2.getProperty("bl_quantity"); String sss = properties2[1];//line2.getProperty("bl_quantity");
if (KUtil.isEmpty(sss)) { if (KUtil.isEmpty(sss)) {
@ -2721,6 +2796,10 @@ public class SAPZYDialogControllerzt {
item.setSORTF(sortno); item.setSORTF(sortno);
if (KUtil.isEmpty(sortno)) if (KUtil.isEmpty(sortno))
buff.append("BOM行未找到投料信息;"); buff.append("BOM行未找到投料信息;");
String zt2_State = properties2[4];
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
item.setPOTX1(properties2[3]);//line2.getProperty("ZT2_Remark") item.setPOTX1(properties2[3]);//line2.getProperty("ZT2_Remark")
items[i] = item; items[i] = item;

@ -50,354 +50,373 @@ import plm.xi.com.chintelectric.SI_PUSH_BOM_PLM_OUT_SYNServiceLocator;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class SAPZYDialogzt extends AbstractAIFDialog { public class SAPZYDialogzt extends AbstractAIFDialog {
private SAPZYDialogControllerzt controller; private SAPZYDialogControllerzt controller;
private JButton b_cel; private JButton b_cel;
private JButton b_qr; private JButton b_qr;
private JButton b_qr2; private JButton b_qr2;
protected DefaultTableModel tm_part; private JButton b_qr3;// 异步传递;
protected JTable t_part; protected DefaultTableModel tm_part;
public static final String[] HEADER = new String[] { "", "序号", "站点", "柜号", "物料名称", "物料编码", "出厂编号", "BOM确认状态", "确认人", protected JTable t_part;
"确认时间" }; public static final String[] HEADER = new String[] { "", "序号", "站点", "柜号", "物料名称", "物料编码", "出厂编号", "BOM确认状态", "确认人",
public static final int[] HEADERWIDTH = new int[] { 50, 60, 60, 60, 120, 180, 180, 100, 100, 100 }; "确认时间" };
public static final int[] HEADERWIDTH = new int[] { 50, 60, 60, 180, 180, 180, 180, 100, 60, 60 };
// public static final String[] HEADER = new String[] { "", "序号", "站点","柜号",
// "物料名称","物料编码", "出厂编号" }; // public static final String[] HEADER = new String[] { "", "序号", "站点","柜号",
// public static final int[] HEADERWIDTH = new int[] { 50, 60, 60,60,120, 180, // "物料名称","物料编码", "出厂编号" };
// 180 }; // public static final int[] HEADERWIDTH = new int[] { 50, 60, 60,60,120, 180,
// 180 };
private CheckBoxTableHeaderRenderer tableHeaderRenderer;
private CheckBoxTableHeaderRenderer tableHeaderRenderer;
// protected JButton o_btn; // 一次规范书 // protected JButton o_btn; // 一次规范书
// protected JButton t_btn; // 二次规范书 // protected JButton t_btn; // 二次规范书
// protected JButton kt_btn; // 壳体方案传递 // protected JButton kt_btn; // 壳体方案传递
// protected JButton s_btn; // 结构方案传递 // protected JButton s_btn; // 结构方案传递
protected JButton pushBOM_btn; // BOM确认 protected JButton pushBOM_btn; // BOM确认
private AbstractAIFDialog dialog; private AbstractAIFDialog dialog;
private TCSession session; private TCSession session;
private AbstractAIFApplication app; private AbstractAIFApplication app;
// 是否检查产成品母号工艺路线 // 是否检查产成品母号工艺路线
private boolean isCheckProduct = false; private boolean isCheckProduct = false;
String fa; String fa;
public SAPZYDialogzt(AbstractAIFApplication app,String fa) {
super(false); public SAPZYDialogzt(AbstractAIFApplication app, String fa) {
this.controller = new SAPZYDialogControllerzt(this, app); super(false);
this.app = app; this.controller = new SAPZYDialogControllerzt(this, app);
this.session = (TCSession) app.getSession(); this.app = app;
this.fa= fa; this.session = (TCSession) app.getSession();
} this.fa = fa;
}
@Override
public void run() { @Override
try { public void run() {
dialog = this; try {
controller.groupName = SAPUtil.getGroupID(session); dialog = this;
// 充气柜传递时需要检查产成品母号是否有且只有一条工艺路线 controller.groupName = SAPUtil.getGroupID(session);
if ("M035".endsWith(controller.groupName)) { // 充气柜传递时需要检查产成品母号是否有且只有一条工艺路线
isCheckProduct = true; if ("M035".endsWith(controller.groupName)) {
} isCheckProduct = true;
System.out.println("当前组:" + controller.groupName); }
if (KUtil.isEmpty(controller.groupName) || controller.groupName.equalsIgnoreCase("dba")) { System.out.println("当前组:" + controller.groupName);
MessageBox.post(this, "当前登录组不可使用该功能", "", MessageBox.INFORMATION); if (KUtil.isEmpty(controller.groupName) || controller.groupName.equalsIgnoreCase("dba")) {
KUtil.setByPass(false); MessageBox.post(this, "当前登录组不可使用该功能", "", MessageBox.INFORMATION);
return; KUtil.setByPass(false);
} return;
CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification", }
controller.groupName); CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification",
if (bean == null) { controller.groupName);
System.out.println("groupID:" + controller.groupName); if (bean == null) {
MessageBox.post("未找到[" + controller.groupName + "]配置,请检查首选项<CHINT_ORG_TechnologyClassification>", "", System.out.println("groupID:" + controller.groupName);
2); MessageBox.post("未找到[" + controller.groupName + "]配置,请检查首选项<CHINT_ORG_TechnologyClassification>", "",
return; 2);
} else { //if(bean.getType() !=null && !bean.getType().equals("DB")) return;
System.out.println("原材来库:" + bean.getCodeReark()); } else { // if(bean.getType() !=null && !bean.getType().equals("DB"))
controller.codeMark = bean.getCodeReark(); System.out.println("原材来库:" + bean.getCodeReark());
controller.icsId = SAPUtil.getIcsId(controller.codeMark, "材料标记", session); controller.codeMark = bean.getCodeReark();
} controller.icsId = SAPUtil.getIcsId(controller.codeMark, "材料标记", session);
if (!controller.checkTargets()) { }
MessageBox.post(this, "没有找到产成品信息", "", MessageBox.INFORMATION); if (!controller.checkTargets()) {
return; MessageBox.post(this, "没有找到产成品信息", "", MessageBox.INFORMATION);
} return;
controller.getSapState(); }
} catch (Exception e) { controller.getSapState();
KUtil.setByPass(false); } catch (Exception e) {
MessageBox.post(this, "检查选择对象时发生错误:" + e.getMessage(), "", MessageBox.ERROR); KUtil.setByPass(false);
e.printStackTrace(); MessageBox.post(this, "检查选择对象时发生错误:" + e.getMessage(), "", MessageBox.ERROR);
return; e.printStackTrace();
} return;
initUI(); }
try { initUI();
controller.readPartInfo();// 将需要的数据显示在弹窗中 try {
} catch (Exception e) { controller.readPartInfo();// 将需要的数据显示在弹窗中
MessageBox.post(this, "读取产成品信息时发生错误:" + e.getMessage(), "", MessageBox.ERROR); } catch (Exception e) {
e.printStackTrace(); MessageBox.post(this, "读取产成品信息时发生错误:" + e.getMessage(), "", MessageBox.ERROR);
return; e.printStackTrace();
} return;
showDialog(); }
showDialog();
}
}
private void initUI() {
this.setTitle("产成品信息"); private void initUI() {
this.setPreferredSize(new Dimension(800, 400)); this.setTitle("产成品信息");
this.setMinimumSize(new Dimension(750, 400)); this.setPreferredSize(new Dimension(1000, 400));
this.setLayout(new BorderLayout()); this.setMinimumSize(new Dimension(750, 400));
this.add(BorderLayout.CENTER, getTablePanel()); this.setLayout(new BorderLayout());
this.add(BorderLayout.SOUTH, getBtnPanel()); this.add(BorderLayout.CENTER, getTablePanel());
addListeners(); this.add(BorderLayout.SOUTH, getBtnPanel());
} addListeners();
}
private void setCompEnabled(boolean b) {
b_cel.setEnabled(b); private void setCompEnabled(boolean b) {
t_part.setEnabled(b); b_cel.setEnabled(b);
t_part.setEnabled(b);
// o_btn.setEnabled(b); // o_btn.setEnabled(b);
// t_btn.setEnabled(b); // t_btn.setEnabled(b);
// s_btn.setEnabled(b); // s_btn.setEnabled(b);
// kt_btn.setEnabled(b); // kt_btn.setEnabled(b);
pushBOM_btn.setEnabled(b); pushBOM_btn.setEnabled(b);
} }
private void addListeners() { private void addListeners() {
pushBOM_btn.addActionListener(new ActionListener() { pushBOM_btn.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
MyProgressBarCompent my = null; MyProgressBarCompent my = null;
try { try {
int start_index = 7; int start_index = 7;
List<PartBean> beans = controller.getSelectedParts(); List<PartBean> beans = controller.getSelectedParts();
int len = beans.size(); int len = beans.size();
if (len == 0) { if (len == 0) {
MessageBox.post("请选择需要确认的产成品", "", 2); MessageBox.post("请选择需要确认的产成品", "", 2);
return; return;
} }
PartBean bean; PartBean bean;
JSONArray datas;// = new JSONArray(); JSONArray datas;// = new JSONArray();
JSONObject data; JSONObject data;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss");
Date time = new Date(); Date time = new Date();
String now = sdf.format(time); String now = sdf.format(time);
String user = session.getUser().getUserId(); String user = session.getUser().getUserId();
String userName = session.getUserName(); String userName = session.getUserName();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
bean = beans.get(i); bean = beans.get(i);
if ("已确认".equals(bean.getZt2_SapBomState())) { if ("已确认".equals(bean.getZt2_SapBomState())) {
MessageBox.post(SAPZYDialogzt.this, "BOM已确认,不能重复确认", "", 2); MessageBox.post(SAPZYDialogzt.this, "BOM已确认,不能重复确认", "", 2);
return; return;
} }
} }
if (new ConfirmDialogUtil(SAPZYDialogzt.this, "BOM确认", "此操作在BOM完整下发后确认一次,是否确认BOM", if (new ConfirmDialogUtil(SAPZYDialogzt.this, "BOM确认", "此操作在BOM完整下发后确认一次,是否确认BOM",
new Dimension(500, 200)).getResult()) { new Dimension(500, 200)).getResult()) {
String REQ_TRACE_ID = "123456"; String REQ_TRACE_ID = "123456";
SI_PUSH_BOM_PLM_OUT_SYNService service = new SI_PUSH_BOM_PLM_OUT_SYNServiceLocator(); SI_PUSH_BOM_PLM_OUT_SYNService service = new SI_PUSH_BOM_PLM_OUT_SYNServiceLocator();
SI_PUSH_BOM_PLM_OUT_SYN stub = service.getHTTP_Port(); SI_PUSH_BOM_PLM_OUT_SYN stub = service.getHTTP_Port();
DT_JSON_REQBASEINFO BASEINFO = new DT_JSON_REQBASEINFO(REQ_TRACE_ID); DT_JSON_REQBASEINFO BASEINFO = new DT_JSON_REQBASEINFO(REQ_TRACE_ID);
DT_JSON_REQJSONINFO JSONINFO; DT_JSON_REQJSONINFO JSONINFO;
StringBuilder build = new StringBuilder(); StringBuilder build = new StringBuilder();
StringBuilder success_build = new StringBuilder(); StringBuilder success_build = new StringBuilder();
DT_JSON_REQ req; DT_JSON_REQ req;
DT_JSON_RSP resp; DT_JSON_RSP resp;
int index; int index;
TCComponentItemRevision rev; TCComponentItemRevision rev;
my = new MyProgressBarCompent("", "设计确认......"); my = new MyProgressBarCompent("", "设计确认......");
KUtil.setByPass(true); KUtil.setByPass(true);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
bean = beans.get(i); bean = beans.get(i);
rev = bean.getPart(); rev = bean.getPart();
datas = new JSONArray(); datas = new JSONArray();
data = new JSONObject(); data = new JSONObject();
data.element("POSID", bean.getPOSID()); data.element("POSID", bean.getPOSID());
data.element("WERKS", bean.getWERKS()); data.element("WERKS", bean.getWERKS());
data.element("MATNR", bean.getMATNR()); data.element("MATNR", bean.getMATNR());
data.element("PSPID", bean.getPSPID()); data.element("PSPID", bean.getPSPID());
data.element("ZFLAG", bean.getZFLAG()); data.element("ZFLAG", bean.getZFLAG());
data.element("ZNAME", user); data.element("ZNAME", user);
data.element("ZDATE", now); data.element("ZDATE", now);
datas.add(data); datas.add(data);
System.out.println("jsons:" + datas.toString()); System.out.println("jsons:" + datas.toString());
JSONINFO = new DT_JSON_REQJSONINFO(datas.toString()); JSONINFO = new DT_JSON_REQJSONINFO(datas.toString());
req = new DT_JSON_REQ(BASEINFO, JSONINFO); req = new DT_JSON_REQ(BASEINFO, JSONINFO);
resp = stub.SI_PUSH_UPDATE_PLM_OUT_SYN(req); resp = stub.SI_PUSH_UPDATE_PLM_OUT_SYN(req);
try { try {
SAPUtil.printResp(resp); SAPUtil.printResp(resp);
bean.setZt2_SapBomDate(time); bean.setZt2_SapBomDate(time);
bean.setZNAME(user); bean.setZNAME(user);
bean.setUserName(userName); bean.setUserName(userName);
bean.setZt2_SapBomState("已确认"); bean.setZt2_SapBomState("已确认");
index = bean.getIndex() - 1; index = bean.getIndex() - 1;
t_part.setValueAt("已确认", index, start_index); t_part.setValueAt("已确认", index, start_index);
t_part.setValueAt(userName, index, start_index + 1); t_part.setValueAt(userName, index, start_index + 1);
t_part.setValueAt(now, index, start_index + 2); t_part.setValueAt(now, index, start_index + 2);
rev.setDateProperty("zt2_SapBomDate", time); rev.setDateProperty("zt2_SapBomDate", time);
rev.setProperty("zt2_SapBomState", "已确认"); rev.setProperty("zt2_SapBomState", "已确认");
rev.setProperty("zt2_SapBomUser", user); rev.setProperty("zt2_SapBomUser", user);
success_build.append("\n").append(rev); success_build.append("\n").append(rev);
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace(); e2.printStackTrace();
build.append("\n").append(rev).append(":").append(e2.getMessage()); build.append("\n").append(rev).append(":").append(e2.getMessage());
} }
} }
KUtil.setByPass(false); KUtil.setByPass(false);
KUtil.closeMyProgressBar(my); KUtil.closeMyProgressBar(my);
if (build.toString().length() > 0) { if (build.toString().length() > 0) {
MessageBox.post("以下产品确认失败:" + build.toString(), "", 2); MessageBox.post("以下产品确认失败:" + build.toString(), "", 2);
} else { } else {
MessageBox.post("以下产品确认成功:" + success_build.toString(), "", 2); MessageBox.post("以下产品确认成功:" + success_build.toString(), "", 2);
} }
} }
} catch (Exception e) { } catch (Exception e) {
KUtil.setByPass(false); KUtil.setByPass(false);
KUtil.closeMyProgressBar(my); KUtil.closeMyProgressBar(my);
e.printStackTrace(); e.printStackTrace();
MessageBox.post(SAPZYDialogzt.this, "BOM确认异常:" + e.getMessage(), "", 2); MessageBox.post(SAPZYDialogzt.this, "BOM确认异常:" + e.getMessage(), "", 2);
} }
} }
}).start(); }).start();
} }
}); });
b_cel.addActionListener(new ActionListener() { b_cel.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
disposeDialog(); disposeDialog();
} }
}); });
b_qr2.addActionListener(new ActionListener() { b_qr2.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String selectedItem = (String) comb.getSelectedItem(); String selectedItem = (String) comb.getSelectedItem();
try { try {
controller.sendToSapYH(selectedItem.replaceAll("方案传递", ""), isCheckProduct); controller.sendToSapYH(selectedItem.replaceAll("方案传递", ""), isCheckProduct);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
}).start(); }).start();
} }
}); });
b_qr3.addActionListener(new ActionListener() {
b_qr.addActionListener(new ActionListener() { @Override
@Override public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e) { new Thread(new Runnable() {
new Thread(new Runnable() { @Override
@Override public void run() {
public void run() {
String selectedItem = (String) comb.getSelectedItem();
String selectedItem = (String) comb.getSelectedItem(); try {
controller.sendToSapYHAsyn(selectedItem.replaceAll("方案传递", ""), isCheckProduct);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
}
});
b_qr.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
String selectedItem = (String) comb.getSelectedItem();
// 一次方案传递"); // 一次方案传递");
// t_btn = new JButton("二次方案传递"); // t_btn = new JButton("二次方案传递");
// s_btn = new JButton("结构方案传递"); // s_btn = new JButton("结构方案传递");
// kt_btn = new JButton("壳体方案传递"); // kt_btn = new JButton("壳体方案传递");
if(fa.equals("C")) { if (fa.equals("C")) {
controller.getDists(); controller.getDists();
try { try {
controller.sendToSapBy("C"); controller.sendToSapBy("C");
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}else if(selectedItem.equals("一次方案传递")) { } else if (selectedItem.equals("一次方案传递")) {
setCompEnabled(false); setCompEnabled(false);
try { try {
KUtil.setByPass(true); KUtil.setByPass(true);
controller.sendToSap("一次", isCheckProduct,"B"); controller.sendToSap("一次", isCheckProduct, "B");
} catch (Exception e1) { } catch (Exception e1) {
MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);
// pb.disposeDialog(); // pb.disposeDialog();
} }
setCompEnabled(true); setCompEnabled(true);
}else if(selectedItem.equals("二次方案传递")) { } else if (selectedItem.equals("二次方案传递")) {
setCompEnabled(false); setCompEnabled(false);
try { try {
KUtil.setByPass(true); KUtil.setByPass(true);
controller.sendToSap("二次", isCheckProduct,"B"); controller.sendToSap("二次", isCheckProduct, "B");
} catch (Exception e1) { } catch (Exception e1) {
MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);
// pb.disposeDialog(); // pb.disposeDialog();
} }
setCompEnabled(true); setCompEnabled(true);
}else if(selectedItem.equals("壳体方案传递")) { } else if (selectedItem.equals("壳体方案传递")) {
setCompEnabled(false); setCompEnabled(false);
try { try {
KUtil.setByPass(true); KUtil.setByPass(true);
controller.sendToSapKT(isCheckProduct); controller.sendToSapKT(isCheckProduct);
} catch (Exception e1) { } catch (Exception e1) {
MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);
} }
setCompEnabled(true); setCompEnabled(true);
}else if(selectedItem.equals("结构方案传递")) { } else if (selectedItem.equals("结构方案传递")) {
setCompEnabled(false); setCompEnabled(false);
try { try {
KUtil.setByPass(true); KUtil.setByPass(true);
controller.sendToSap("结构", isCheckProduct,"B"); controller.sendToSap("结构", isCheckProduct, "B");
} catch (Exception e1) { } catch (Exception e1) {
MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);
// pb.disposeDialog(); // pb.disposeDialog();
} }
setCompEnabled(true); setCompEnabled(true);
}else if(selectedItem.equals("产成品BOM传递") && fa.equals("D")) { } else if (selectedItem.equals("产成品BOM传递") && fa.equals("D")) {
//20231030 物料不查询图纸 // 20231030 物料不查询图纸
try { try {
List<PartBean> selectedParts = controller.getSelectedParts(); List<PartBean> selectedParts = controller.getSelectedParts();
new SAPZYGG2Operation(app,selectedParts,controller.project).executeOperation(); new SAPZYGG2Operation(app, selectedParts, controller.project).executeOperation();
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}else if(selectedItem.equals("产成品BOM传递") && fa.equals("E")) { } else if (selectedItem.equals("产成品BOM传递") && fa.equals("E")) {
//电容器 找出厂编号没有 走 变压器 // 电容器 找出厂编号没有 走 变压器
// controller.getSelectedParts().get(0); // controller.getSelectedParts().get(0);
try { try {
List<PartBean> selectedParts = controller.getSelectedParts(); List<PartBean> selectedParts = controller.getSelectedParts();
new SAPPartZYOp2(app, selectedParts,true).executeOperation(); //zy new SAPPartZYOp2(app, selectedParts, true).executeOperation(); // zy
String sendToSapBy = controller.sendToSapBy("E"); //by String sendToSapBy = controller.sendToSapBy("E"); // by
if (sendToSapBy.toString().length() > 0) { if (sendToSapBy.toString().length() > 0) {
new SAPMessageUtil(dialog, "", "传递异常:" + sendToSapBy.toString()); new SAPMessageUtil(dialog, "", "传递异常:" + sendToSapBy.toString());
}else { } else {
MessageBox.post("传递结束", "", MessageBox.INFORMATION); MessageBox.post("传递结束", "", MessageBox.INFORMATION);
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}else if( fa.equals("B")) { } else if (fa.equals("B")) {
try { try {
if(selectedItem.equals("产成品BOM传递")) { if (selectedItem.equals("产成品BOM传递")) {
List<PartBean> selectedParts = controller.getSelectedParts(); List<PartBean> selectedParts = controller.getSelectedParts();
new SAPZYGG2Operation(app,selectedParts,controller.project).executeOperation(); new SAPZYGG2Operation(app, selectedParts, controller.project).executeOperation();
} }
// else if(selectedItem.contains("电气") && controller.groupName.equals("M040")){ // else if(selectedItem.contains("电气") && controller.groupName.equals("M040")){
// try { // try {
// controller.sendToSapYH(selectedItem.replaceAll("方案传递", ""), isCheckProduct); // controller.sendToSapYH(selectedItem.replaceAll("方案传递", ""), isCheckProduct);
@ -406,43 +425,42 @@ public class SAPZYDialogzt extends AbstractAIFDialog {
// e.printStackTrace(); // e.printStackTrace();
// } // }
// } // }
else { else {
controller.sendToSap(selectedItem.replaceAll("方案传递", ""), isCheckProduct,"B"); controller.sendToSap(selectedItem.replaceAll("方案传递", ""), isCheckProduct, "B");
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}else if(fa.equals("F")) { } else if (fa.equals("F")) {
//物料BOM // 物料BOM
try { try {
controller.sendToSapYH(selectedItem.replaceAll("方案传递", ""), isCheckProduct); controller.sendToSapYH(selectedItem.replaceAll("方案传递", ""), isCheckProduct);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} } else {
else { setCompEnabled(false);
setCompEnabled(false); try {
try { KUtil.setByPass(true);
KUtil.setByPass(true); controller.sendToSap(selectedItem.replaceAll("方案传递", ""), isCheckProduct, "D");
controller.sendToSap(selectedItem.replaceAll("方案传递", ""), isCheckProduct,"D"); } catch (Exception e1) {
} catch (Exception e1) { MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR);
MessageBox.post(SAPZYDialogzt.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); e1.printStackTrace();
e1.printStackTrace(); } finally {
} finally { KUtil.setByPass(false);
KUtil.setByPass(false); // pb.disposeDialog();
// pb.disposeDialog(); }
} setCompEnabled(true);
setCompEnabled(true); }
} // ProgressBar pb = new ProgressBar(SAPZYDialog.this,new Dimension(350, 50));
// ProgressBar pb = new ProgressBar(SAPZYDialog.this,new Dimension(350, 50));
}
} }).start();
}).start(); }
} });
}); // 一次规范书传递
// 一次规范书传递
// o_btn.addActionListener(new ActionListener() { // o_btn.addActionListener(new ActionListener() {
// @Override // @Override
// public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
@ -466,7 +484,7 @@ public class SAPZYDialogzt extends AbstractAIFDialog {
// }).start(); // }).start();
// } // }
// }); // });
// 二次规范书传递 // 二次规范书传递
// t_btn.addActionListener(new ActionListener() { // t_btn.addActionListener(new ActionListener() {
// @Override // @Override
// public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
@ -516,7 +534,7 @@ public class SAPZYDialogzt extends AbstractAIFDialog {
// } // }
// }); // });
// 结构方案传递 // 结构方案传递
// s_btn.addActionListener(new ActionListener() { // s_btn.addActionListener(new ActionListener() {
// @Override // @Override
// public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
@ -539,93 +557,95 @@ public class SAPZYDialogzt extends AbstractAIFDialog {
// }).start(); // }).start();
// } // }
// }); // });
} }
private JComboBox<String> comb;
private JPanel getBtnPanel() { private JComboBox<String> comb;
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 30, 5));
private JPanel getBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 30, 5));
// o_btn = new JButton("一次方案传递"); // o_btn = new JButton("一次方案传递");
// t_btn = new JButton("二次方案传递"); // t_btn = new JButton("二次方案传递");
// s_btn = new JButton("结构方案传递"); // s_btn = new JButton("结构方案传递");
// kt_btn = new JButton("壳体方案传递"); // kt_btn = new JButton("壳体方案传递");
b_cel = new JButton("取消"); b_cel = new JButton("取消");
// panel.add(o_btn); // panel.add(o_btn);
// panel.add(t_btn); // panel.add(t_btn);
// panel.add(kt_btn); // panel.add(kt_btn);
// panel.add(s_btn); // panel.add(s_btn);
pushBOM_btn = new JButton("BOM确认"); pushBOM_btn = new JButton("BOM确认");
panel.add(pushBOM_btn); panel.add(pushBOM_btn);
panel.add(b_cel); panel.add(b_cel);
comb = new JComboBox<String>(); comb = new JComboBox<String>();
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_BOMBTN", session); String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_BOMBTN", session);
if (prefs != null && prefs.length > 0) { if (prefs != null && prefs.length > 0) {
for (String pref : prefs) {
for(String pref:prefs) { String[] split = pref.split(":");
String[] split = pref.split(":"); if (controller.groupName.equals(split[0])) {
if(controller.groupName.equals(split[0])) {
if (split[1].endsWith("/")) {
if(split[1].endsWith("/")) { split[1] = split[1].substring(0, split[1].length() - 1);
split[1] = split[1].substring(0,split[1].length()-1); comb.addItem("产成品BOM传递");
comb.addItem("产成品BOM传递"); }
} String[] split2 = split[1].split(";");
String[] split2 = split[1].split(";"); for (String name : split2) {
for(String name:split2) { comb.addItem(name);
comb.addItem(name); }
} }
} }
} }
} if (comb.getItemCount() == 0) {
if(comb.getItemCount()==0) { comb.addItem("产成品BOM传递");
comb.addItem("产成品BOM传递"); }
} b_qr = new JButton("确认");
b_qr = new JButton("确认");
b_qr2 = new JButton("测试低压优化");
b_qr2 = new JButton("测试低压优化"); b_qr3 = new JButton("中低压异步传递");
panel.add(comb);
panel.add(comb); panel.add(b_qr);
panel.add(b_qr); panel.add(b_qr2);
panel.add(b_qr2); panel.add(b_qr3);
return panel; return panel;
} }
private JPanel getTablePanel() { private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel(); tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) { t_part = new JTable(tm_part) {
@Override @Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑 public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if (column == 0) if (column == 0)
return true; return true;
return false; return false;
} }
@Override @Override
public Class<?> getColumnClass(int column) { // 设置选择列(第三列)类型 public Class<?> getColumnClass(int column) { // 设置选择列(第三列)类型
if (column == 0) { if (column == 0) {
return Boolean.class; return Boolean.class;
} }
return super.getColumnClass(column); return super.getColumnClass(column);
} }
}; };
tm_part.setDataVector(null, HEADER); tm_part.setDataVector(null, HEADER);
t_part.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列) t_part.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_part.setRowHeight(23); this.t_part.setRowHeight(23);
// this.t_part.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // this.t_part.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel colModel = this.t_part.getColumnModel(); TableColumnModel colModel = this.t_part.getColumnModel();
int colCnt = HEADERWIDTH.length; int colCnt = HEADERWIDTH.length;
colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]); colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]);
for (int i = 0; i < colCnt; i++) { for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
} }
this.t_part.getTableHeader() this.t_part.getTableHeader()
.setDefaultRenderer(this.tableHeaderRenderer = new CheckBoxTableHeaderRenderer(t_part, 0, false)); .setDefaultRenderer(this.tableHeaderRenderer = new CheckBoxTableHeaderRenderer(t_part, 0, false));
this.t_part.getTableHeader().setBackground(Color.blue); this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part); JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll); panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder()); panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel; return panel;
} }
} }

@ -54,9 +54,9 @@ public class ZYApplyCodeControllerzt {
protected TCComponentFolder folder; protected TCComponentFolder folder;
private static String QUERY_NAMES[] = { "%一次规范书%", "%二次规范书%", "%结构方案%" }; private static String QUERY_NAMES[] = { "%一次规范书%", "%二次规范书%", "%结构方案%" };
// private static String SQL_QUERY_ALL = "select t.\"CompanyCodeStr\",t.\"GoodsCode\",t.\"GoodsName\",t.\"GoodsBpNo\"," private static String SQL_QUERY_ALL = "select t.\"CompanyCodeStr\",t.\"GoodsCode\",t.\"GoodsName\",t.\"GoodsBpNo\","
// + "t.\"GoodsFullInfo\",t.\"GoodsTeRe\",t.\"GoodsUnitCode\",t.\"GoodsPmpcCode\" from CHINT_XBFAH t where "; + "t.\"GoodsFullInfo\",t.\"GoodsTeRe\",t.\"GoodsUnitCode\",t.\"GoodsPmpcCode\" from CHINT_XBFAH t where ";
private static String SQL_QUERY_ALL = "select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where "; // private static String SQL_QUERY_ALL = "select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where ";
// private static String SQL_QUERY_ALL="select // private static String SQL_QUERY_ALL="select
// t.CgdCompanyCode,t.CgdGoodsCode,t.CgdName,t.CgdBpNo,t.CgdGoodsFullInfo,t.CgdTeRe,t.CgdUnitCode,t.CgdPmpcCode // t.CgdCompanyCode,t.CgdGoodsCode,t.CgdName,t.CgdBpNo,t.CgdGoodsFullInfo,t.CgdTeRe,t.CgdUnitCode,t.CgdPmpcCode
// from ccemvw_cgd t where t.CgdPmpcCode='400101012' "; // from ccemvw_cgd t where t.CgdPmpcCode='400101012' ";
@ -117,12 +117,12 @@ public class ZYApplyCodeControllerzt {
public boolean checkConn() { public boolean checkConn() {
// String[] prefs = // String[] prefs =
// String[] stringValues = session.getPreferenceService().getStringValues("database_tc"); String[] stringValues = session.getPreferenceService().getStringValues("database_tc");
//// Connection conn = SqlUtil.getTCDataConnection(prefs); //// Connection conn = SqlUtil.getTCDataConnection(prefs);
// //
// return SqlUtil.getTCDataConnection(stringValues) == null ? false : true; return SqlUtil.getTCDataConnection(stringValues) == null ? false : true;
return SqlUtil.getConnection() == null ? false : true; // return SqlUtil.getConnection() == null ? false : true;
} }
public String type = ""; public String type = "";
// 检查是否选中对应的方案文件夹 // 检查是否选中对应的方案文件夹
@ -226,15 +226,15 @@ public class ZYApplyCodeControllerzt {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.append(SQL_QUERY_ALL); sql.append(SQL_QUERY_ALL);
System.out.println("isAPPLYS==>"+isAPPLYS); System.out.println("isAPPLYS==>"+isAPPLYS);
sql.append(" t.GoodsCode like '").append(code).append("%'"); // sql.append(" t.GoodsCode like '").append(code).append("%'");
// sql.append(" t.\"GoodsCode\" like '").append(code).append("%'"); sql.append(" t.\"GoodsCode\" like '").append(code).append("%'");
Object obj[] = new Object[1]; Object obj[] = new Object[1];
// obj[0] = "%"+code+"%"; // obj[0] = "%"+code+"%";
// obj[0] = query_name; // obj[0] = query_name;
String groupID = SAPUtil.getGroupID(session); String groupID = SAPUtil.getGroupID(session);
sql.append(" and t.CompanyCodeStr like ?"); // sql.append(" and t.CompanyCodeStr like ?");
// sql.append(" and t.\"CompanyCodeStr\" like ?"); sql.append(" and t.\"CompanyCodeStr\" like ?");
obj[0] = "%"+groupID+"%"; obj[0] = "%"+groupID+"%";

@ -443,10 +443,13 @@ public class ZYApplyCodeDialogzt extends AbstractAIFDialog {
flag = true; flag = true;
// tm_part.addRow(applyCodeBean.getRowData()); // tm_part.addRow(applyCodeBean.getRowData());
} }
if (map_Applicables.get(bean).size() == 1) { if (map_Applicables.get(bean).size() == 1) {
// model3.removeElement(cloneBean); // model3.removeElement(cloneBean);
// model4.addElement(bean); // model4.addElement(bean);
System.out.println("bean===>"+map_Applicables.toString());
map_Applicables.remove(bean);
value_keys.remove(cloneBean);
list_jl3.remove(cloneBean); list_jl3.remove(cloneBean);
list_jl4.add(bean); list_jl4.add(bean);
} else if (map_Applicables.get(bean).size() > 1) { } else if (map_Applicables.get(bean).size() > 1) {

@ -1,20 +1,91 @@
package com.connor.chint.sap2.util; package com.connor.chint.sap2.util;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.ui.common.RACUIUtil; import com.teamcenter.rac.ui.common.RACUIUtil;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
public class BomToSapUtil { public class BomToSapUtil {
/**
* @param cell2
* @param index
* @param row0
* @param cellValue
* @function
*/
public static void setCellValue(XSSFCell cell2, int index, XSSFRow row0, String cellValue) {
// TODO Auto-generated method stub
if (cell2 == null) {
cell2 = row0.createCell(index);
}
cell2.setCellValue(cellValue);
}
/**
* @param sheetAt
* @param rowNum
* @return excel
* @function
*/
public static XSSFRow getRow(XSSFSheet sheetAt, int rowNum) {
// TODO Auto-generated method stub
XSSFRow row = sheetAt.getRow(rowNum);
if (row == null) {
row = sheetAt.createRow(rowNum);
}
return row;
}
/**
*
* @param session
* @param PreServiceName:
* @param Filetype:excelMSExcelX
* @return
*/
public static File getFile(TCSession session, String PreServiceName, String Filetype) {
TCPreferenceService service = session.getPreferenceService();
String puid = service.getStringValue(PreServiceName);
if (puid == null) {
System.out.println("未找到首选项");
return null;
}
TCComponentDataset dat;
try {
dat = (TCComponentDataset) session.stringToComponent(puid);
TCComponentTcFile[] tcFile = dat.getTcFiles();
if (tcFile != null && tcFile.length == 0) {
System.out.println("未找到配置文件");
} else {
return tcFile[0].getFmsFile();
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static Map<String, ExpandPSData[]> getBomLineTreeNodeSOA(TCComponentBOMLine bomLine) { public static Map<String, ExpandPSData[]> getBomLineTreeNodeSOA(TCComponentBOMLine bomLine) {
// List<String> bomLineNodes = list; // List<String> bomLineNodes = list;

@ -384,6 +384,10 @@ public class SAPUtil {
zt2_materialNo = part2.getLatestItemRevision().getProperty("zt2_MaterialNo"); zt2_materialNo = part2.getLatestItemRevision().getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_materialNo); item.setIDNRK(zt2_materialNo);
item.setMEINS(part2.getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(part2.getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = part2.getLatestItemRevision().getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
@ -394,7 +398,7 @@ public class SAPUtil {
if (KUtil.isEmpty(sortno)) if (KUtil.isEmpty(sortno))
buff.append("BOMÐÐδÕÒµ½Í¶ÁÏÐÅÏ¢;"); buff.append("BOMÐÐδÕÒµ½Í¶ÁÏÐÅÏ¢;");
item.setPOTX1(line2.getProperty("ZT2_Remark")); item.setPOTX1(line2.getProperty("ZT2_Remark"));
items[i] = item; items[i] = item;
String[] properties2 = rev2.getProperties(new String[] {"item_id","object_name","zt2_SapState"}); String[] properties2 = rev2.getProperties(new String[] {"item_id","object_name","zt2_SapState"});
String item_id2 = properties2[0];//rev2.getProperty("item_id"); String item_id2 = properties2[0];//rev2.getProperty("item_id");
@ -911,7 +915,6 @@ public class SAPUtil {
} }
} }
} }
} }
@ -2306,6 +2309,10 @@ public class SAPUtil {
zt2_materialNo = part2.getLatestItemRevision().getProperty("zt2_MaterialNo"); zt2_materialNo = part2.getLatestItemRevision().getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_materialNo); item.setIDNRK(zt2_materialNo);
item.setMEINS(part2.getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(part2.getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = partRev2.getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
@ -2547,6 +2554,10 @@ public class SAPUtil {
zt2_materialNo = part2.getLatestItemRevision().getProperty("zt2_MaterialNo"); zt2_materialNo = part2.getLatestItemRevision().getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_materialNo); item.setIDNRK(zt2_materialNo);
item.setMEINS(part2.getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(part2.getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = partRev2.getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
@ -4255,6 +4266,10 @@ public class SAPUtil {
zt2_materialNo = partRev2.getProperty("zt2_MaterialNo"); zt2_materialNo = partRev2.getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_materialNo); item.setIDNRK(zt2_materialNo);
item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = partRev2.getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
@ -4570,6 +4585,10 @@ public class SAPUtil {
zt2_MaterialNo = partRev2.getProperty("zt2_MaterialNo"); zt2_MaterialNo = partRev2.getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_MaterialNo); item.setIDNRK(zt2_MaterialNo);
item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = partRev2.getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_MaterialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
@ -4824,6 +4843,10 @@ public class SAPUtil {
zt2_materialNo = part2Rev.getProperty("zt2_MaterialNo"); zt2_materialNo = part2Rev.getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_materialNo); item.setIDNRK(zt2_materialNo);
item.setMEINS(part2Rev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(part2Rev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = part2Rev.getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");
@ -5079,6 +5102,10 @@ public class SAPUtil {
zt2_materialNo = part2Rev.getProperty("zt2_MaterialNo"); zt2_materialNo = part2Rev.getProperty("zt2_MaterialNo");
item.setIDNRK(zt2_materialNo); item.setIDNRK(zt2_materialNo);
item.setMEINS(part2Rev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); item.setMEINS(part2Rev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
String zt2_State = part2Rev.getProperty("zt2_State");
if(zt2_State.equals("封存")||zt2_State.equals("D1")) {
buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP");
}
} }
item.setDATUV(now); item.setDATUV(now);
item.setPOSTP("L"); item.setPOSTP("L");

@ -23,8 +23,8 @@ public class WkpcsInfoWebServiceServiceLocator extends org.apache.axis.client.Se
// Use to get a proxy class for WkpcsInfoWebServicePort // Use to get a proxy class for WkpcsInfoWebServicePort
//private java.lang.String WkpcsInfoWebServicePort_address = "http://10.128.155.13:8080/mes-intfe/services/wkpcsInfo"; //private java.lang.String WkpcsInfoWebServicePort_address = "http://10.128.155.13:8080/mes-intfe/services/wkpcsInfo";
//20200511 //20200511<EFBFBD> 2024/1/7更换IP地址 旧10.128.20.250 新mes.chintelec.com
private java.lang.String WkpcsInfoWebServicePort_address = "http://10.128.20.250:8090/mes-intfe/services/wkpcsInfo"; private java.lang.String WkpcsInfoWebServicePort_address = "https://mes.chintelec.com/mes-intfe/services/wkpcsInfo";
//2020 //2020
//private java.lang.String WkpcsInfoWebServicePort_address = "http://10.128.20.250:8090/mes-intfe/mes/map/mapChange"; //private java.lang.String WkpcsInfoWebServicePort_address = "http://10.128.20.250:8090/mes-intfe/mes/map/mapChange";

Loading…
Cancel
Save