Compare commits

..

No commits in common. 'master' and 'ljh' have entirely different histories.
master ... ljh

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="poi/neethi-3.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="poi/backport-util-concurrent-3.1.jar"/>
<classpathentry exported="true" kind="lib" path="poi/axiom-dom-1.2.7.jar"/>
<classpathentry exported="true" kind="lib" path="poi/okhttp-2.7.4.jar"/>
<classpathentry exported="true" kind="lib" path="poi/okio-1.13.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-8.0.12.jar"/>
@ -54,10 +51,5 @@
<classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/>
<classpathentry kind="lib" path="lib/hutool-all-5.8.8.jar"/>
<classpathentry kind="lib" path="lib/swingx-1.6.1.jar"/>
<classpathentry kind="lib" path="poi/axiom-api-1.2.7.jar"/>
<classpathentry kind="lib" path="poi/axis2-kernel-1.4.1.jar"/>
<classpathentry kind="lib" path="json_lib/jfxrt.jar"/>
<classpathentry kind="lib" path="poi/XmlSchema-1.4.7.jar"/>
<classpathentry kind="lib" path="poi/axiom-impl-1.2.7.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=1.8

@ -50,8 +50,7 @@ Require-Bundle: org.eclipse.ui,
com.teamcenter.rac.util;bundle-version="11000.2.0",
org.eclipse.osgi.services;bundle-version="3.3.100",
TcSoaCaeRac;bundle-version="11000.2.0",
com.teamcenter.rac.project;bundle-version="11000.2.0",
com.connor.chint.wuhan;bundle-version="1.0.0"
com.teamcenter.rac.project;bundle-version="11000.2.0"
Automatic-Module-Name: com.connor.chint.sap2
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
@ -79,15 +78,7 @@ Bundle-ClassPath: .,
poi/okhttp-2.7.4.jar,
poi/okio-1.13.0.jar,
lib/json-org.jar,
lib/commons-dbcp2-2.8.0.jar,
json_lib/jfxrt.jar,
poi/axiom-dom-1.2.7.jar,
poi/axiom-api-1.2.7.jar,
poi/axis2-kernel-1.4.1.jar,
poi/XmlSchema-1.4.7.jar,
poi/axiom-impl-1.2.7.jar,
poi/backport-util-concurrent-3.1.jar,
poi/neethi-3.0.2.jar
lib/commons-dbcp2-2.8.0.jar
Export-Package: com.connor.chint.sap2,
com.connor.chint.sap2.assignfactoryno,
com.connor.chint.sap2.bombuilder,

@ -31,15 +31,7 @@ bin.includes = plugin.xml,\
lib/mysql-connector-java-8.0.12.jar,\
poi/okhttp-2.7.4.jar,\
poi/okio-1.13.0.jar,\
lib/json-org.jar,\
json_lib/jfxrt.jar,\
poi/axiom-dom-1.2.7.jar,\
poi/axiom-api-1.2.7.jar,\
poi/axis2-kernel-1.4.1.jar,\
poi/XmlSchema-1.4.7.jar,\
poi/axiom-impl-1.2.7.jar,\
poi/backport-util-concurrent-3.1.jar,\
poi/neethi-3.0.2.jar
lib/json-org.jar
src.includes = icons/,\
poi/jacob-1.20-x64.dll,\
poi/jacob-1.20-x86.dll,\

@ -64,7 +64,6 @@
<command name="自动更新型号和工作号" id="com.connor.chint.sap2.commands.SetPropertyCommand"/>
<command name="变压器采购清单" id="com.connor.chint.sap2.commands.PPartsReportCommand"/>
<command name="部件采购单BOM编制" id="com.chint.plm.modules.transformer.bomsetup.BomSetupCommand"/>
<command name="创建框架BOM" id="com.connor.chint.sap2.createKjBom.CreateKjBomCommand"/>
<!--中压设备-->
<command name="创建工程图" id="com.connor.chint.sap2.commands.CreateEDCommand"/>
<command name="申请项目产成品" id="com.connor.chint.sap2.commands.ZYProjectAppendixCommand#M008"/>
@ -112,8 +111,8 @@
<!--物料管理-->
<command name="物料编码申请" id="com.connor.chint.sap2.commands.MaterialNoCommand"/>
<command name="物料请购SAP" id="com.connor.chint.sap2.commands.WLQGSAPCommand"/>
<command name="物料编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand"/><!--自制件编码批量申请
<command name="工程图批量申请物料编码" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT"/>-->
<command name="自制件编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand"/>
<command name="工程图批量申请物料编码" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT"/>
<command name="外购件编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#M007_2"/>
@ -137,10 +136,7 @@
<command name="通用BOM导入" id="com.connor.chint.sap2.commands.BOMGeneralImportCommand"/>
<command name="图纸物料关系导入" id="com.connor.chint.sap2.relationImport.RelationImportCommand"/>
<command name="编码清单查询" id="com.connor.chint.sap2.commands.DesignQueryCommand"/>
<command name="整体BOM传递SAP" id="com.connor.chint.sap2.commands.SAPZYZTCommand"/>
<command name="批量导入工艺路线与工时" id="com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand"/>
<command name="部件BOM传递SAP异步" id="com.connor.chint.sap2.commands.SAPBJYBCommand"/>
<command name="维护来料检验数据" id="com.chint.plm.qms.QMSHandler"/>
<command name="整体BOM传递SAP" id="com.connor.chint.sap2.commands.SAPZYZTCommand"/>
<!--报表导出-->
<command name="项目方案清单导出" id="com.connor.chint.sap2.commands.ExportCommand#Proposal"/>
@ -190,7 +186,6 @@
<command name="分配出厂编号" id=" com.connor.chint.sap2.commands.FactoryNoCommand#M030"/>
<command name="诚创系统" id="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_001"/>
<command name="深化系统" id="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_002"/>
<command name="深化系统V2" id="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_002V2"/>
<!--低压柜方案申请-->
<command name="固定单元" id="com.connor.chint.sap2.commands.ApplyCodeCommand#M030_001"/>
<command name="抽屉单元" id="com.connor.chint.sap2.commands.ApplyCodeCommand#M030_002"/>
@ -216,7 +211,6 @@
<command name="拆分方案分配" id="com.connor.chint.sap2.commands.ProgrammeCommand#M030_008"/>
<command name="诚创系统" id="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_001"/>
<command name="深化系统" id="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_002"/>
<command name="深化系统V2" id="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_002V2"/>
<!--图纸批量上传-->
<command name="零件展开图上传" id="com.connor.chint.sap2.zdd023.MyImportCommand#023"/>
<command name="二次图纸上传" id="com.connor.chint.sap2.zdd023.MyImportCommand#024"/>
@ -265,8 +259,6 @@
<command name="生成更改差异文件" id="com.connor.chint.sap2.commands.CreateBOMDifferenceCommand#M010"/>
<command name="生成更改差异文件" id="com.connor.chint.sap2.commands.CreateBOMDifferenceCommand#M011"/>
<command name="生成更改差异文件" id="com.connor.chint.sap2.commands.CreateBOMDifferenceCommand#M030"/>
<command name="生成更改差异文件" id="com.connor.chint.sap2.commands.CreateBOMDifferenceCommandAll"/>
<command name="关联变更内容" id=" com.connor.chint.sap2.commands.ChangeAttachCommand#M030dz"/>
<command name="关联变更内容" id="com.connor.chint.sap2.commands.ChangeAttachCommand#M030"/>
@ -309,14 +301,12 @@
<command name="项目计划管理" id="com.connor.chint.sap2.commands.OpenPiCommand"/>
<command name="互感器成本BOM导出" id="com.chint.plm.costbomreport.BomCostReportCmd"/>
<command name="创建RDM研发项目" id="com.chint.plm.rdmCreate.RdmCreateHandler"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<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.ImpSAPBomCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand" 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.commands.ArefreshThCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.ZYProjectAppendixCommand#ztdz" class="com.connor.chint.sap2.KHandler"/>
@ -390,7 +380,7 @@
<handler commandId="com.connor.chint.sap2.commands.WLQGSAPCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SAPZZCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.MaterialAssignCommand" class="com.connor.chint.sap2.KHandler"/>
<!--handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" class="com.connor.chint.sap2.KHandler"/-->
<handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand" class="com.connor.chint.sap2.KHandler"/>
@ -422,7 +412,6 @@
<handler commandId="com.connor.chint.sap2.commands.SetPropertyCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.PPartsReportCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.chint.plm.modules.transformer.bomsetup.BomSetupCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.createKjBom.CreateKjBomCommand" class="com.connor.chint.sap2.KHandler"/>
<!--中压-->
<handler commandId="com.connor.chint.sap2.commands.SpecStatementCommand#M008_Part2" class="com.connor.chint.sap2.KHandler"/>
@ -469,8 +458,6 @@
<handler commandId="com.connor.chint.sap2.commands.ExportCommand#EEDrawing" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SAPZYZTCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SAPBJYBCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.chint.plm.qms.QMSHandler" class="com.chint.plm.qms.QMSHandler"/>
<!--高压开关-->
<handler commandId="com.connor.chint.sap2.gk.commands.AProjectNoCommand#ZDK008" class="com.connor.chint.sap2.KHandler"/>
@ -540,11 +527,9 @@
<handler commandId="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_001" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_002" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_002V2" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_001" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_002" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_002V2" class="com.connor.chint.sap2.KHandler"/>
<!--图纸上传-->
<handler commandId="com.connor.chint.sap2.zdd023.MyImportCommand#023" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.zdd023.MyImportCommand#024" class="com.connor.chint.sap2.KHandler"/>
@ -609,8 +594,6 @@
<handler commandId="com.connor.chint.sap2.commands.CreateBOMDifferenceCommand#M010" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.CreateBOMDifferenceCommand#M011" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.CreateBOMDifferenceCommand#M030" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.CreateBOMDifferenceCommandAll" class="com.connor.chint.sap2.KHandler"/>
<!--关联变更内容-->
<handler commandId="com.connor.chint.sap2.commands.ChangeAttachCommand#M030dz" class="com.connor.chint.sap2.KHandler"/>
@ -628,7 +611,6 @@
<!--右键物料描述复制-->
<handler commandId="com.connor.chint.sap2.commands.CopyObjectDescCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.chint.plm.rdmCreate.RdmCreateHandler" class="com.chint.plm.rdmCreate.RdmCreateHandler"/>
</extension>
<extension point="org.eclipse.ui.bindings">
@ -683,27 +665,6 @@
</and>
</visibleWhen>
</command>
<command commandId = "com.chint.plm.rdmCreate.RdmCreateHandler" id = "com.chint.plm.rdmCreate.RdmCreateHandler">
<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.rdmCreate.RdmCreateHandler">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="com.connor.chint.sap2.commands.OpenPiCommand" id="com.connor.chint.sap2.commands.OpenPiCommand">
<visibleWhen>
<and>
@ -873,28 +834,6 @@
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_002V2" id = "com.connor.chint.sap2.menu.dyct.ElectricalTasksCommand_002V2">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.commands.ElectricalTasksCommand#M030_002V2">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menu>
<!--提取电气BOM-->
<menu label="提取电气BOM" id="tqdqBOM">
@ -942,28 +881,6 @@
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_002V2" id = "com.connor.chint.sap2.menu.dyct.CreateElectricalBOMCommand#M030_002V2">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.commands.CreateElectricalBOMCommand#M030_002V2">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menu>
<!--方案编码申请-->
@ -2066,24 +1983,6 @@
</and>
</visibleWhen>
</command>
<!---->
<command commandId = "com.connor.chint.sap2.createKjBom.CreateKjBomCommand" id = "com.connor.chint.sap2.menu.cgdexport">
<visibleWhen>
<and>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.createKjBom.CreateKjBomCommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
@ -4065,7 +3964,7 @@
</and>
</visibleWhen>
</command>
<!--command commandId = "com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" id = "com.connor.chint.sap2.menu.wlgl.zzjbmplsq#GCT">
<command commandId = "com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" id = "com.connor.chint.sap2.menu.wlgl.zzjbmplsq#GCT">
<visibleWhen>
<and>
<or>
@ -4085,7 +3984,7 @@
</with>
</and>
</visibleWhen>
</command-->
</command>
<command commandId = "com.connor.chint.sap2.commands.MaterialQueryCommand" id = "com.connor.chint.sap2.commands.MaterialQueryCommand">
<visibleWhen>
<and>
@ -4134,28 +4033,6 @@
<!--通用功能-->
<menuContribution locationURI="menu:com.connor.chint.sap2.menu.test?after=additions">
<command commandId = "com.chint.plm.qms.QMSHandler" id = "com.chint.plm.qms.QMSHandler">
<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.qms.QMSHandler">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<!--
<command commandId = "com.connor.chint.sap2.commands.StatisticalReportCommand" id = "com.connor.chint.sap2.menu.test.StatisticalReportCommand">
<visibleWhen>
@ -4492,27 +4369,6 @@
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand" id = "com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.commands.DeleteTCMCommand" id = "com.connor.chint.sap2.test.DeleteTCMCommand">
<visibleWhen>
<and>
@ -4711,94 +4567,6 @@
</and>
</visibleWhen>
</command>
<!--><!-->
<command commandId = "com.connor.chint.sap2.commands.SAPBJYBCommand" id = "com.connor.chint.sap2.menu.SAPBJYBCommand">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.commands.SAPBJYBCommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.chint.plm.createEcn.CreateEcnCommond" id = "com.chint.plm.createEcn.CreateEcnCommond">
<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.createEcn.CreateEcnCommond">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.commands.CreateBOMDifferenceCommandAll" id = "com.connor.chint.sap2.commands.CreateBOMDifferenceCommandAll">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.commands.CreateBOMDifferenceCommandAll">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.gykg.commands.CreateEDCGYommand" id = "com.connor.chint.sap2.gykg.menu.createECNGY">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.gykg.commands.CreateEDCGYommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.projectTest.VersionCommand" id = "com.connor.chint.sap2.menu.distributionversion">
<visibleWhen>

@ -12,25 +12,14 @@ public class ApiContext {
}
public static String getApiUrl(TCSession session) {
return getApiUrl(session, "CHINT_API_URL", AppConst.PLM_API_URL);
}
public static String getApiUrl(TCSession session, String paramKey) {
return getApiUrl(session, paramKey, "");
}
public static String getApiUrl(TCSession session, String paramKey, String defaultValue) {
try {
String result = session.getPreferenceService().getStringValue(paramKey);
if (StringUtils.isBlank(result)) {
result = defaultValue;
}
String result = session.getPreferenceService().getStringValue("CHINT_API_URL");
if (StringUtils.isBlank(result)) {
throw new RuntimeException("请通知管理员检查首选项<" + paramKey + ">是否配置,查询为空");
result = AppConst.PLM_API_URL;
}
return result;
return result;
} catch (Exception e) {
throw new RuntimeException("请通知管理员检查首选项<" + paramKey + ">是否配置");
throw new RuntimeException("请通知管理员检查首选项CHINT_API_URL是否配置");
}
}

@ -18,41 +18,24 @@ public class WorkhourService {
* @return
*/
public static EasyResponse<List<String>> getProducttype(String companycode) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProducttype";
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourType/getProducttype";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode);
String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
}
/**
* »ñÈ¡µçѹµÈ¼
* @param companycode
* @param producttype
* @return
*/
public static EasyResponse<List<String>> getVoltagelevel(String companycode, String producttype) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getVoltagelevel";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode);
paramMap.put("producttype", producttype);
String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
}
/**
* »ñÈ¡²úÆ·ÐͺÅ
* @param companycode
* @param producttype
* @param voltagelevel
* @return
*/
public static EasyResponse<List<String>> getProductxh(String companycode, String producttype, String voltagelevel) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProductxh";
public static EasyResponse<List<String>> getProductxh(String companycode, String producttype) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourXh/getProductxh";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode);
paramMap.put("producttype", producttype);
paramMap.put("voltagelevel", voltagelevel);
String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
}
@ -63,7 +46,7 @@ public class WorkhourService {
* @return
*/
public static EasyResponse<List<String>> getJsask(String companycode) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getJsask";
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourAsk/getJsask";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode);
String result = HttpUtils.get(url, paramMap);

@ -2,8 +2,14 @@ package com.chint.plm.getGCTH;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
@ -25,11 +31,19 @@ import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeWillExpandListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.ExpandVetoException;
import javax.swing.tree.TreePath;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.TreeTableNode;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.SoaUtils;
import com.connor.chint.sap2.util.SqlUtil;
@ -49,10 +63,6 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData
public class GCTHDialog extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JComboBox<String> xxdbhComb=new JComboBox<String>();
private List<String> nameList =new ArrayList<String>();
@ -62,20 +72,20 @@ public class GCTHDialog extends JFrame {
private TCSession session;
private SoaUtils soaUtil;
private ProcessBarDialog progress1;
// private Boolean jzFlag = false;
// private Map<String, ExpandPSData[]> bomLineTreeNodeSOA;
private Boolean jzFlag = false;
private Map<String, ExpandPSData[]> bomLineTreeNodeSOA;
JFrame frame;
private List<HF04NodeBean> beanList = new ArrayList<HF04NodeBean>();
public GCTHDialog(AbstractAIFApplication app,DefaultMutableTreeTableNode rootNode,
TCComponentBOMLine line,ProcessBarDialog progress,Map<String, ExpandPSData[]> bomLineTreeNodeSOA,List<HF04NodeBean> beanList) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
this.app = app;
this.rootNode = rootNode;
this.line = line;
this.session = (TCSession) app.getSession();
String ip = session.getLoginInfo().getPreviousSessionLoginIP();
System.out.println("ip==>"+ip);
// this.bomLineTreeNodeSOA = bomLineTreeNodeSOA;
this.bomLineTreeNodeSOA = bomLineTreeNodeSOA;
this.beanList = beanList;
soaUtil = new SoaUtils(line);
this.progress1 = progress;
@ -92,7 +102,7 @@ public class GCTHDialog extends JFrame {
private String[] header = new String[] { "对象ID", "选择派生","" };
// @Override
public void initUI() {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
TCSession session = (TCSession)app.getSession();
String strs[] = session.getPreferenceService().getStringValues("database_tc");
@ -140,80 +150,86 @@ public class GCTHDialog extends JFrame {
private JButton btn;
private String xxd = "";
private JPanel getBtnPanel() {
// Auto-generated method stub
// TODO Auto-generated method stub
JPanel topPanel = new JPanel();
btn = new JButton("开始执行");
topPanel.add(btn);
btn.addActionListener(new ActionListener() {
@Override
@Override
public void actionPerformed(ActionEvent param1ActionEvent) {
new Thread() {
@Override
public void run() {
try {
String text = jText.getText();
System.out.println("text===>"+text);
if(!nameList.contains(text)) {
MessageBox.post("系统中无此信息单,请检查!","提示",2);
return;
}
KUtil.setByPass(true);
ProcessBarDialog progress = new ProcessBarDialog("正在执行申请工程图号...");
progress.open();
// init_pb.show();
// int rowCount = table.getRowCount();
getAllNodes(rootNode);
//BOM复制
soaUtil.cloneOrUpdate(session,line,bomLine,jText.getText().trim());
line.window().close();
try {
//剪切
TCComponentItem tcComponentById = (TCComponentItem) soaUtil.getTCComponentById(session, soaUtil.topItemId);
TCComponentItemRevision latestItemRevision = tcComponentById.getLatestItemRevision();
TCTypeService service = session.getTypeService();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
TCComponentBOMWindow window = winType.create(null);
TCComponentBOMLine newTopline = window.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null);
xxd = jText.getText().trim().replaceAll("YHX", "");
changeAllDs(newTopline);
window.close();
// init_pb.disposeDialog();
progress.close();
KUtil.setByPass(true);
// session.getUser().getNewStuffFolder().cutOperation("contents", new TCComponent[] { tcComponentById});
btn.setEnabled(false);
MessageBox.post(GCTHDialog.this, "申请工程图号完成,新的图号为:"+soaUtil.topItemId +"-"+tcComponentById.getStringProperty("object_name"), "提示", 2);
frame.dispose();
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
MessageBox.post(GCTHDialog.this, "申请工程图号时发生异常:" + e.getMessage(), "提示", 2);
}finally {
progress.close();
}
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}finally {
KUtil.setByPass(false);
}
}
}.start();
new Thread() {
@Override
public void run() {
try {
String text = jText.getText();
System.out.println("text===>"+text);
if(!nameList.contains(text)) {
MessageBox.post("系统中无此信息单,请检查!","提示",2);
return;
}
KUtil.setByPass(true);
ProcessBarDialog progress = new ProcessBarDialog("正在执行申请工程图号...");
progress.open();
// init_pb.show();
// int rowCount = table.getRowCount();
getAllNodes(rootNode);
//BOM复制
soaUtil.cloneOrUpdate(session,line,bomLine,jText.getText().trim());
line.window().close();
try {
//剪切
TCComponentItem tcComponentById = (TCComponentItem) soaUtil.getTCComponentById(session, soaUtil.topItemId);
TCComponentItemRevision latestItemRevision = tcComponentById.getLatestItemRevision();
TCTypeService service = session.getTypeService();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
TCComponentBOMWindow window = winType.create(null);
TCComponentBOMLine newTopline = window.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null);
xxd = jText.getText().trim().replaceAll("YHX", "");
changeAllDs(newTopline);
window.close();
// init_pb.disposeDialog();
progress.close();
KUtil.setByPass(true);
// session.getUser().getNewStuffFolder().cutOperation("contents", new TCComponent[] { tcComponentById});
btn.setEnabled(false);
MessageBox.post(GCTHDialog.this, "申请工程图号完成,新的图号为:"+soaUtil.topItemId +"-"+tcComponentById.getStringProperty("object_name"), "提示", 2);
frame.dispose();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post(GCTHDialog.this, "申请工程图号时发生异常:" + e.getMessage(), "提示", 2);
}finally {
progress.close();
}
}
catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
}
});
});
return topPanel;
}
//改变数据集名称
protected void changeAllDs(TCComponentBOMLine newTopline) throws TCException {
// Auto-generated method stub
// TODO Auto-generated method stub
Map<String, String> idMap = soaUtil.getIdMap();
AIFComponentContext[] children = newTopline.getChildren();
@ -226,10 +242,12 @@ public class GCTHDialog extends JFrame {
for(AIFComponentContext context:children) {
TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent();
changeAllDs(component);
}
}
protected void getAllNodes(DefaultMutableTreeTableNode rootNode2) {
// Auto-generated method stub
// TODO Auto-generated method stub
for (int i = 0; i < rootNode2.getChildCount(); i++) {
DefaultMutableTreeTableNode childAt = (DefaultMutableTreeTableNode) rootNode2.getChildAt(i);
// 获取第二层的对象
@ -242,7 +260,7 @@ public class GCTHDialog extends JFrame {
selected = "0";
}
bomLine.put(subLine, Integer.valueOf(selected));
// boolean bzt = true;
boolean bzt = true;
//工程图、标准图
// if(childBean.getGctSelect().equals("1")) {
// bzt = false;
@ -259,19 +277,23 @@ public class GCTHDialog extends JFrame {
private Map<String,List<Integer>> rowMap = new HashMap<>();
private Integer currentRow = 0;
private JPanel getTopPanel() {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
ResultSet rs = SqlUtil.read(sqlStr);
while (rs.next()) {
String item_id = rs.getString("PITEM_ID");
nameList.add(item_id);
}
} catch (SQLException e1) {
// Auto-generated catch block
// TODO Auto-generated catch block
e1.printStackTrace();
}
JPanel topPanel = new JPanel();
xxdbhComb.setEditable(true);
@ -280,19 +302,19 @@ public class GCTHDialog extends JFrame {
@Override
public void keyTyped(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
addSelect(e,xxdbhComb,jText,nameList);
}
@Override
public void keyPressed(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
});
@ -327,13 +349,13 @@ public class GCTHDialog extends JFrame {
jButton4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// Auto-generated method stub
// TODO Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
table.expandAll();
String text = jTextQry.getText();
if(!text.isEmpty()) {
@ -362,13 +384,13 @@ public class GCTHDialog extends JFrame {
jButton3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// Auto-generated method stub
// TODO Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
table.expandAll();
String text = jTextQry.getText();
if(!text.isEmpty()) {
@ -397,13 +419,13 @@ public class GCTHDialog extends JFrame {
jButton5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// Auto-generated method stub
// TODO Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
table.expandAll();
String text = jTextQry.getText();
if(!text.isEmpty()) {
@ -456,13 +478,13 @@ public class GCTHDialog extends JFrame {
jButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// Auto-generated method stub
// TODO Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
// new Thread() {
// @Override
@ -494,13 +516,13 @@ public class GCTHDialog extends JFrame {
jButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// Auto-generated method stub
// TODO Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
String text = jText.getText();
System.out.println("text===>"+text);
@ -551,7 +573,7 @@ public class GCTHDialog extends JFrame {
}
private JScrollPane getTablePanel() {
// Auto-generated method stub
// TODO Auto-generated method stub
table = getJTreeTable(null, null, header, null);
// table.getModel().addTableModelListener(table);
table.setRowHeight(30);
@ -569,31 +591,31 @@ public class GCTHDialog extends JFrame {
@Override
public void mouseReleased(MouseEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
int selectedRow = table.rowAtPoint(e.getPoint());
System.out.println("selectColumn==>"+selectColumn);
@ -639,7 +661,7 @@ public class GCTHDialog extends JFrame {
int rowCount = myTable.getRowCount();
Enumeration<TableColumn> columns = myTable.getColumnModel().getColumns();
Enumeration columns = myTable.getColumnModel().getColumns();
while (columns.hasMoreElements()) {
TableColumn column = (TableColumn) columns.nextElement();
@ -691,7 +713,7 @@ public class GCTHDialog extends JFrame {
}
protected void addSelect(KeyEvent e, JComboBox<String> combox, JTextField jtext, List<String> cpxList) {
// Auto-generated method stub
// TODO Auto-generated method stub
Object obj = e.getSource();
int keyCode = e.getKeyCode();
if (obj == jtext) {

@ -5,23 +5,21 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.chint.plm.common.util.ArrayUtils;
import com.chint.plm.common.util.CollectionUtils;
import com.chint.plm.common.util.LoggerUtils;
import com.chint.plm.common.util.StringUtils;
import com.connor.chint.sap2.proc.CreateProcessController;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
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.StructureManagementService;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
/**
*
@ -31,32 +29,22 @@ public class MEProcessMngHelper {
public static void onAutoFeeding(TCSession session, String groupId, ProgressBar pb, List<TCComponentItemRevision> itemRevisionList) throws Exception {
LoggerUtils.debug("自动投料开始...");
long start = System.nanoTime();
if (CollectionUtils.isNotEmpty(itemRevisionList)) {
pb.setText("自动投料开始...");
pb.showDialog();
Map<String, Map<String, String>> wlflmMap = getWlflmMap(session, groupId);
LoggerUtils.debug("wlflmMap:" + (System.nanoTime() - start) / 1000000000);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
StructureManagement structureService = StructureManagementService.getService(session);
for (TCComponentItemRevision itemRevision : itemRevisionList) {
if (itemRevision != null) {
long rs = System.nanoTime();
onAutoFeeding(session, groupId, pb, itemRevision, wlflmMap, win, structureService);
LoggerUtils.debug("onAutoFeeding:" + (System.nanoTime() - rs) / 1000000);
if (itemRevision!=null) {
onAutoFeeding(session, groupId, pb, itemRevision, wlflmMap);
}
}
win.close();
}
LoggerUtils.debug(itemRevisionList.size() + "end:" + (System.nanoTime() - start) / 1000000000);
LoggerUtils.debug("自动投料结束。");
pb.disposeDialog();
}
// @SuppressWarnings("deprecation")
private static void onAutoFeeding(TCSession session, String groupId, ProgressBar pb, TCComponentItemRevision itemRevision, Map<String, Map<String, String>> wlflmMap,
TCComponentBOMWindow win, StructureManagement structureService) throws Exception {
@SuppressWarnings("deprecation")
private static void onAutoFeeding(TCSession session, String groupId, ProgressBar pb, TCComponentItemRevision itemRevision, Map<String, Map<String, String>> wlflmMap) throws Exception {
LoggerUtils.debug("正在自动投料:" + itemRevision);
pb.setText("正在自动投料:" + itemRevision);
// 虚拟层级物料编码
@ -79,42 +67,43 @@ public class MEProcessMngHelper {
return;
}
// 投料
TCComponentBOMLine topLine = win.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null);
// TCComponentBOMLine topLine = win.getTopBOMLine();
Map<String, ExpandPSData[]> bomLineMap = BomToSapUtil.getBomLineTreeNodeSOA(structureService, topLine);
onAutoFeedingLine(topLine, innerMap, bomLineMap);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine();
onAutoFeedingLine(topLine, innerMap);
win.save();
// win.refresh();
// win.unlock();
win.refresh();
win.unlock();
LoggerUtils.debug("自动投料完成:" + itemRevision);
}
@SuppressWarnings("deprecation")
private static void onAutoFeedingLine(TCComponentBOMLine line, Map<String, String> wlflmMap, Map<String, ExpandPSData[]> bomLineMap) throws Exception {
ExpandPSData[] expandPSDatas = bomLineMap.get(line.getUid());
for (ExpandPSData child : expandPSDatas) {
TCComponentBOMLine childLine = child.bomLine;
// 真实投料的零件版本
TCComponentItemRevision itemRevision = child.itemRevOfBOMLine;
// 物料分类码
String zt2_ClassificationCode = itemRevision.getProperty("zt2_ClassificationCode");
// 物料名称
String name = itemRevision.getProperty("object_name");
// 层级
String level = childLine.getProperty("bl_level_starting_0");
// 工序码值
String wlflm = "";
wlflm = wlflmMap.get(name);
if (StringUtils.isBlank(wlflm)) {
wlflm = wlflmMap.get("*");
}
if (StringUtils.isNotBlank(wlflm)) {
LoggerUtils.debug("正在自动投料:" + itemRevision + "-" + level + "-" + zt2_ClassificationCode + "-" + wlflm);
CreateProcessController.feeding(childLine, wlflm);
private static void onAutoFeedingLine(TCComponentBOMLine line, Map<String, String> wlflmMap) throws Exception {
if (ArrayUtils.isNotEmpty(line.getChildren())) {
for (AIFComponentContext child : line.getChildren()) {
TCComponentBOMLine childLine = (TCComponentBOMLine) child.getComponent();
// 真实投料的零件版本
TCComponentItemRevision itemRevision = childLine.getItemRevision();
// 物料分类码
String zt2_ClassificationCode = itemRevision.getProperty("zt2_ClassificationCode");
// 物料名称
String name = itemRevision.getProperty("object_name");
// 层级
String level = childLine.getProperty("bl_level_starting_0");
// 工序码值
String wlflm = "";
wlflm = wlflmMap.get(name);
if (StringUtils.isBlank(wlflm)) {
wlflm = wlflmMap.get("*");
}
if (StringUtils.isNotBlank(wlflm)) {
LoggerUtils.debug("正在自动投料:" + itemRevision + "-" + level + "-" + zt2_ClassificationCode + "-" + wlflm);
CreateProcessController.feeding(childLine, wlflm);
}
childLine.save();
onAutoFeedingLine(childLine, wlflmMap);
}
childLine.save();
onAutoFeedingLine(childLine, wlflmMap, bomLineMap);
}
}

@ -1,134 +0,0 @@
package com.chint.plm.qms;
import javafx.beans.property.SimpleStringProperty;
import javafx.event.Event;
import javafx.geometry.Pos;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.util.converter.DefaultStringConverter;
import javafx.util.converter.IntegerStringConverter;
import java.lang.reflect.Field;
import java.util.Objects;
public class EditingCell<T> extends TableCell<T, String> {
private TextField textField;
public EditingCell() {
}
@Override
public void startEdit() {
if (!isEmpty()) {
super.startEdit();
createTextField();
setText(null);
setGraphic(textField);
textField.selectAll();
}
}
@Override
public void cancelEdit() {
super.cancelEdit();
setText(getItem());
setGraphic(null);
}
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
if (isEditing()) {
if (textField != null) {
textField.setText(getString());
}
setText(null);
setGraphic(textField);
} else {
setText(getString());
setGraphic(null);
}
}
}
@Override
public void commitEdit(String newValue) {
if (!isEditing() && !Objects.equals(newValue, getItem())) {
TableView<T> table = getTableView();
if (table != null) {
TableColumn<T, String> col = getTableColumn();
CellEditEvent<T, String> event = new CellEditEvent<>(table, new TablePosition<>(table, getIndex(), col),
TableColumn.editCommitEvent(), newValue);
Event.fireEvent(col, event);
System.out.println("开始利用反射将数据写入对象");
T item = getTableView().getItems().get(getIndex());
String property = col.getId();
Class<?> type = getItemFieldType(item, property);
Object convertedValue = convertValue(newValue, type);
setItemProperty(item, property, convertedValue);
}
}
super.commitEdit(newValue);
updateItem(newValue, false);
}
private void setItemProperty(T item, String property, Object value) {
try {
Field field = item.getClass().getDeclaredField(property);
field.setAccessible(true);
field.set(item, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
private Object convertValue(String value, Class<?> type) {
if (type == SimpleStringProperty.class) {
return new SimpleStringProperty(value);
} else if (type == String.class) {
return value;
} else if (type == Integer.class) {
return new IntegerStringConverter().fromString(value);
} else if (type == Double.class) {
return new DefaultStringConverter().fromString(value);
} else {
return null;
}
}
private Class<?> getItemFieldType(T item, String property) {
try {
Field field = item.getClass().getDeclaredField(property);
return field.getType();
} catch (NoSuchFieldException e) {
e.printStackTrace();
return null;
}
}
private void createTextField() {
textField = new TextField(getString());
System.out.println("可读写模式");
textField.setAlignment(Pos.CENTER);
textField.setMinWidth(getWidth() - getGraphicTextGap() * 2);
textField.focusedProperty().addListener((ob, old, now) -> {
if (!now) {
commitEdit(textField.getText());
}
});
}
private String getString() {
return getItem() == null ? "" : getItem();
}
}

@ -1,320 +0,0 @@
package com.chint.plm.qms;
import java.text.SimpleDateFormat;
import java.util.Date;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
public class QMSBean {
private Integer code;
private SimpleStringProperty xh = new SimpleStringProperty();
private SimpleStringProperty qmsinspectioncode = new SimpleStringProperty();
private SimpleStringProperty qmsinspectionname = new SimpleStringProperty();
private SimpleStringProperty qmssuperiorinspectionname = new SimpleStringProperty();
private SimpleStringProperty qmsinspectionschemename = new SimpleStringProperty();
private SimpleStringProperty qmspushuser = new SimpleStringProperty();
private ComboBox<String> plmvaluetype = new ComboBox<String>();
private SimpleStringProperty plminspectioncode = new SimpleStringProperty();
private TextField plmdesignation = new TextField();
private ComboBox<String> plmsequence = new ComboBox<String>();
private SimpleStringProperty result = new SimpleStringProperty();
private SimpleStringProperty status = new SimpleStringProperty();
private SimpleStringProperty synctime = new SimpleStringProperty();
private SimpleStringProperty plmchangeuser = new SimpleStringProperty();
private boolean isEdit;
private boolean red = false;
private CheckBox checkBox = new CheckBox();
private TableView<QMSBean> table = null;
public QMSBean() {
}
public QMSBean(boolean isEdit,Integer code, String xh, String qmsinspectioncode, String qmsinspectionname,
String qmssuperiorinspectionname, String qmsinspectionschemename, String qmspushuser,
String plmvaluetype, String plminspectioncode, String plmdesignation, String plmsequence,
String result, String status, Date synctime, String plmchangeuser) {
super();
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-dd HH:mm:ss");
this.code = code;
checkBox.setSelected(false);
checkBox.setDisable(!isEdit);
this.xh.set(xh);
this.qmsinspectioncode.set(qmsinspectioncode);
this.qmsinspectionname.set(qmsinspectionname);
this.qmssuperiorinspectionname.set(qmssuperiorinspectionname);
this.qmsinspectionschemename.set(qmsinspectionschemename);
this.qmspushuser.set(qmspushuser);
this.plmvaluetype.getItems().addAll("参数化","型号规格(3d模型)","物料描述规格(2d图纸)");
this.plmvaluetype.setValue(plmvaluetype);
this.plmvaluetype.setEditable(false);
this.plmvaluetype.setDisable(!isEdit);
this.plminspectioncode.set(plminspectioncode);
this.plmdesignation.setText(plmdesignation);
this.plmdesignation.setEditable(isEdit);
this.plmsequence.getItems().addAll("1","2","3","4","5","6","7","8","9");
this.plmsequence.setValue(plmsequence);
this.plmsequence.setEditable(false);
this.plmsequence.setDisable(!isEdit);
this.result.set(result);
this.status.set(status);
this.synctime.set(synctime == null ? "" : sdf2.format(synctime));
this.plmchangeuser.set(plmchangeuser);
}
public CheckBox getCheckBox() {
return checkBox;
}
public void setCheckBox(CheckBox checkBox) {
this.checkBox = checkBox;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getXh() {
return xh.get();
}
public void setXh(SimpleStringProperty xh) {
this.xh = xh;
}
public String getQmsinspectioncode() {
return qmsinspectioncode.get();
}
public void setQmsinspectioncode(SimpleStringProperty qmsinspectioncode) {
this.qmsinspectioncode = qmsinspectioncode;
}
public String getQmsinspectionname() {
return qmsinspectionname.get();
}
public void setQmsinspectionname(SimpleStringProperty qmsinspectionname) {
this.qmsinspectionname = qmsinspectionname;
}
public String getQmssuperiorinspectionname() {
return qmssuperiorinspectionname.get();
}
public void setQmssuperiorinspectionname(SimpleStringProperty qmssuperiorinspectionname) {
this.qmssuperiorinspectionname = qmssuperiorinspectionname;
}
public String getQmsinspectionschemename() {
return qmsinspectionschemename.get();
}
public void setQmsinspectionschemename(SimpleStringProperty qmsinspectionschemename) {
this.qmsinspectionschemename = qmsinspectionschemename;
}
public String getQmspushuser() {
return qmspushuser.get();
}
public void setQmspushuser(SimpleStringProperty qmspushuser) {
this.qmspushuser = qmspushuser;
}
public ComboBox<String> getPlmvaluetype() {
return plmvaluetype;
}
public void setPlmvaluetype(ComboBox<String> plmvaluetype) {
this.plmvaluetype=plmvaluetype;
}
public String getPlminspectioncode() {
return plminspectioncode.get();
}
public void setPlminspectioncode(SimpleStringProperty plminspectioncode) {
this.plminspectioncode = plminspectioncode;
}
public TextField getPlmdesignation() {
return plmdesignation;
}
public void setPlmdesignation(TextField plmdesignation) {
this.plmdesignation = plmdesignation;
}
public ComboBox<String> getPlmsequence() {
return plmsequence;
}
public void setPlmsequence(ComboBox<String> plmsequence) {
this.plmsequence = plmsequence;
}
public String getResult() {
return result.get();
}
public void setResult(SimpleStringProperty result) {
this.result = result;
}
public String getStatus() {
return status.get();
}
public void setStatus(SimpleStringProperty status) {
this.status = status;
}
public String getSynctime() {
return synctime.get();
}
public void setSynctime(SimpleStringProperty synctime) {
this.synctime = synctime;
}
public String getPlmchangeuser() {
return plmchangeuser.get();
}
public void setPlmchangeuser(SimpleStringProperty plmchangeuser) {
this.plmchangeuser = plmchangeuser;
}
public boolean isEdit() {
return isEdit;
}
public void setEdit(boolean isEdit) {
this.isEdit = isEdit;
}
public boolean isRed() {
return red;
}
public void setRed(boolean red) {
this.red = red;
}
@Override
public String toString() {
return "QMSBean [code=" + code + ", xh=" + xh + ", qmsinspectioncode=" + qmsinspectioncode
+ ", qmsinspectionname=" + qmsinspectionname + ", qmssuperiorinspectionname="
+ qmssuperiorinspectionname + ", qmsinspectionschemename=" + qmsinspectionschemename + ", qmspushuser="
+ qmspushuser + ", plmvaluetype=" + plmvaluetype + ", plminspectioncode=" + plminspectioncode
+ ", plmdesignation=" + plmdesignation + ", plmsequence=" + plmsequence + ", result=" + result
+ ", status=" + status + ", synctime=" + synctime + ", plmchangeuser=" + plmchangeuser + ", isEdit="
+ isEdit + ", red=" + red + "]";
}
}

@ -1,863 +0,0 @@
package com.chint.plm.qms;
import java.awt.Component;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.chint.plm.rdmCreate.KFXPanel;
import com.chint.plm.rdmCreate.KFXPanelController;
import com.chint.plm.rdmCreate.RdmCreateBean;
import com.connor.chint.sap2.util.KUtil;
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.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentGroupType;
import com.teamcenter.rac.kernel.TCComponentProject;
import com.teamcenter.rac.kernel.TCComponentProjectType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCComponentUserType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SplitPane;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.util.Callback;
public class QMSController extends KFXPanelController {
private Connection conn;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private String PlanTime;//
private String lineSeparator = System.lineSeparator();// 换行符
private String[] prefs = null;
private double paneWidth;
private double paneHight;
ObservableList<QMSBean> data = null;
//ComboBox<String> plmvaluetype = new ComboBox<String>();
boolean isAdmin = false;
boolean isEdit = false;
String factory = "";
@FXML
private Button bc;
@FXML
private ScrollPane scroll;
@FXML
private TextField f1;
@FXML
private TextField f2;
@FXML
private TextField f3;
@FXML
private CheckBox c1;
@FXML
private CheckBox c2;
@FXML
private CheckBox c3;
@FXML
private Pane pane1;
@FXML
private Button cx;
@FXML
private Button cz;
@FXML
private Pane pane;
@FXML
private TableView<QMSBean> table;
// table的列
// private TableColumn<String, TextField> tc_1 = new TableColumn<String,
// TextField>("序号");
private QMSFrame frame;
protected AbstractAIFApplication app;
private TCSession session;
/**
*
*/
@Override
public void initData(KFXPanel paramKFXPanel) throws Exception {
// TODO Auto-generated method stub
// 连接数据库 根据条件查询
this.app = AIFUtility.getCurrentApplication();
this.session = (TCSession) app.getSession();
this.prefs = session.getPreferenceService().getStringValues("CHINT_SRM_SQL_CONNECT");
f1.setPrefSize(180, 28);
f2.setPrefSize(180, 28);
f3.setPrefSize(180, 28);
System.out.println("===============开始连接tc数据库===============");
frame = (QMSFrame) paramKFXPanel.getParentDialog();
addWindListener(frame);
//填界table监听
table.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
int index = table.getSelectionModel().getSelectedIndex();
System.out.println("Selected row at index: " + index);
QMSBean item = table.getItems().get(index);
System.out.println("===================================================="+item.getQmsinspectioncode());
}
});
factory = SAPUtil.getGroupID(session);
String[] pref = session.getPreferenceService().getStringValues("CHINT_QMS_INSPECIFICATION_CODE_RULE");
String userId = session.getUser().getUserId();
if(userId.equalsIgnoreCase("admin")) {
isAdmin = true;
isEdit = true;
}
// 获取对应组织的流水码
for (int z = 0; z < pref.length; z++) {
String[] split = pref[z].split(":");
if(split[0].equalsIgnoreCase(factory)) {
if(split[1].contains(userId)) {
isEdit = true;
}
}
}
if(!isEdit) {
bc.setVisible(false);
}
table.setEditable(true);
frame.setMaximumSize(frame.getMaximumSize());
System.out.println("frame==>" + frame);
TableColumn checkboxColumn = new TableColumn<>("");
checkboxColumn.setCellValueFactory(new PropertyValueFactory<QMSBean, CheckBox>("checkBox"));
checkboxColumn.prefWidthProperty().bind(table.widthProperty().multiply(0.03));
TableColumn<QMSBean, String> tc1 = new TableColumn<>("序号");
tc1.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("xh"));
tc1.prefWidthProperty().bind(table.widthProperty().multiply(0.03));
TableColumn<QMSBean, String> tc2 = new TableColumn<>("检验项编码");
tc2.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("qmsinspectioncode"));
tc2.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, String> tc3 = new TableColumn<>("检验项名称");
tc3.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("qmsinspectionname"));
tc3.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, String> tc4 = new TableColumn<>("上级检验项");
tc4.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("qmssuperiorinspectionname"));
tc4.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, String> tc5 = new TableColumn<>("检验方案名称");
tc5.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("qmsinspectionschemename"));
tc5.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, String> tc6 = new TableColumn<>("QMS推送人员");
tc6.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("qmspushuser"));
tc6.prefWidthProperty().bind(table.widthProperty().multiply(0.06));
TableColumn<QMSBean, ComboBox<String>> tc7 = new TableColumn<>("取值类型");
tc7.setCellValueFactory(new PropertyValueFactory<QMSBean, ComboBox<String>>("plmvaluetype"));
tc7.prefWidthProperty().bind(table.widthProperty().multiply(0.17));
//tc7.setSortable(false);
// tc7.setCellFactory(TextFieldTableCell.forTableColumn()); //
//
// // 设置单元格工厂以监听修改
// tc7.setCellFactory(new Callback<TableColumn<QMSBean, TextField>, TableCell<QMSBean, TextField>>() {
// @Override
// public TableCell<QMSBean, TextField> call(TableColumn<QMSBean, TextField> param) {
// return new TableCell<QMSBean, TextField>() {
// @Override
// public void updateItem(TextField item, boolean empty) {
// //super.updateItem(item, empty);
// if (item == null) {
// //setText(null);
// } else {
// // 当单元格内容修改时,这里会被调用
// //setText(item.getText());
// // 可以在这里添加你想要的逻辑,比如打印修改后的值
// System.out.println("Cell modified to: " + item.getText());
// }
// }
// };
// }
// });
//
// // 监听单元格编辑
// tc7.setOnEditCommit(event -> {
// // 获取编辑后的值
//
// // 获取行索引
// int rowIndex = table.getSelectionModel().getSelectedIndex();
//
// // 获取同一行的"Copy"列
// data = table.getItems();
// QMSBean item = data.get(rowIndex);
// item.setRed(true);
// System.out.println("bean================"+item.toString());
// System.out.println("red完成");
//
//
//
// // 设置行的样式
// table.setRowFactory(tv -> {
// TableRow<QMSBean> row = new TableRow<>();
// row.itemProperty().addListener((obs, previousItem, newItem) -> {
// QMSBean qmsBean = row.getItem();
// System.out.println("newItem========================="+qmsBean);
// if (qmsBean != null && qmsBean.isRed()) {
// // 当行中有数据时设置样式
// row.setStyle("-fx-background-color: red;");
// } else {
// // 当行为空时恢复默认样式
// row.setStyle("");
// }
// });
// return row ;
// });
// table.refresh();
// });
//
TableColumn<QMSBean, String> tc8 = new TableColumn<>("PLM检验项编码");
tc8.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("plminspectioncode"));
tc8.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, TextField> tc9 = new TableColumn<>("参数代号");
tc9.setCellValueFactory(new PropertyValueFactory<QMSBean, TextField>("plmdesignation"));
tc9.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, ComboBox<String>> tc10 = new TableColumn<>("规格位数(顺序)");
tc10.setCellValueFactory(new PropertyValueFactory<QMSBean, ComboBox<String>>("plmsequence"));
tc10.prefWidthProperty().bind(table.widthProperty().multiply(0.13));
TableColumn<QMSBean, String> tc11 = new TableColumn<>("检验项判定");
tc11.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("result"));
tc11.prefWidthProperty().bind(table.widthProperty().multiply(0.13));
TableColumn<QMSBean, String> tc12 = new TableColumn<>("是否同步QMS");
tc12.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("status"));
tc12.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, String> tc13 = new TableColumn<>("保存时间");
tc13.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("synctime"));
tc13.prefWidthProperty().bind(table.widthProperty().multiply(0.1));
TableColumn<QMSBean, String> tc14 = new TableColumn<>("修改账号");
tc14.setCellValueFactory(new PropertyValueFactory<QMSBean, String>("plmchangeuser"));
tc14.prefWidthProperty().bind(table.widthProperty().multiply(0.06));
//tc7.setCellFactory(TextFieldTableCell.forTableColumn()); // 设置单元格为可编辑
checkboxColumn.setEditable(isEdit);
tc7.setEditable(isEdit);
tc9.setEditable(isEdit);
tc10.setEditable(isEdit);
// 把代码中定义的table列加入tableView
table.getColumns().addAll(checkboxColumn,tc1, tc2, tc3, tc4, tc5, tc6, tc7, tc8, tc9, tc10, tc11, tc12, tc13, tc14);
// 设置文本框的高度
// jTextField1.setPrefHeight(30);
// 表格列绑定bean对象
// tc_1.setSortable(false);
// 列绑定bean对象
// tc_1.setCellValueFactory(new PropertyValueFactory<GzxqBean, TextArea>("xh"));
// 设置table列宽度
// tc_1.prefWidthProperty().bind(table.widthProperty().multiply(0.04));
// //设置是否可编辑
// tc_1.setEditable(false);
// tc_2.setEditable(false);
// tc_3.setEditable(false);
// tc_4.setEditable(false);
// tc_5.setEditable(false);
// tc_6.setEditable(false);
// tc_7.setEditable(false);
// tc_8.setEditable(true);
// tc_9.setEditable(true);
// tc_10.setEditable(false);
// tableView.setMaxHeight(pageNum);
cx();
}
/**
* @param frame
* @function
*/
private void addWindListener(QMSFrame frame) {
// TODO Auto-generated method stub
frame.addComponentListener(new ComponentListener() {
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
/**
* pane
*/
@Override
public void componentResized(ComponentEvent e) {
// TODO Auto-generated method stub
System.out.println("==============");
Component component = e.getComponent();
//System.out.println("component==>" + component);
double width = component.getSize().getWidth();
double hight = component.getSize().getHeight();
paneWidth = pane.getWidth();
paneHight = pane.getHeight();
double widthxs = width/paneWidth;
double hightxs = hight/paneHight;
//System.out.println("Widthxs============"+widthxs);
// // double width = primaryStage.getWidth();
System.out.println("width=============>" + width);
System.out.println("pane==========="+pane.getWidth());
System.out.println("pane1==========="+pane1.getWidth());
System.out.println("scroll==========="+scroll.getWidth());
System.out.println("table==========="+table.getWidth());
pane.setPrefWidth(width * 0.98);
pane.setPrefHeight(hight * 0.98);
pane1.setPrefWidth(width * 0.98);
//pane1.setPrefHeight(hight * 0.98);
scroll.setPrefWidth(width * 0.96);
scroll.setPrefHeight((hight - 110) * 0.96);
table.setPrefWidth(width * 0.95);
table.setPrefHeight((hight - 110) * 0.95);
System.out.println("width2=============>" + width);
System.out.println("pane=2=========="+pane.getWidth());
System.out.println("pane1==2========="+pane1.getWidth());
System.out.println("scroll==2========="+scroll.getWidth());
System.out.println("table==2========="+table.getWidth());
// scroll.setPrefWidth(scroll.getWidth() * widthxs);
// scroll.setPrefHeight(scroll.getHeight() * hightxs);
//
//
// pane1.setPrefWidth(pane1.getWidth() * widthxs);
// pane1.setPrefHeight(pane1.getHeight() * hightxs);
//
//grid.setPrefWidth(width * 0.98);
//gridTop.setPrefWidth(width * 0.98);
// table.setPrefWidth(table.getWidth() * widthxs);
// table.setPrefHeight(table.getHeight() * hightxs);
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
});
}
// 重置
@FXML
void czAction(ActionEvent event) {
c1.setSelected(false);
c2.setSelected(false);
c3.setSelected(false);
f1.setText("");
f2.setText("");
f3.setText("");
}
//查询
@FXML
void cxAction(ActionEvent event) throws TCException {
// SqlUtil.SRMGetTCDataConnection(prefs);
// //判断该用户是否有权限编辑界面
//
// System.out.println("======================清除");
// table.getItems().clear();
// List<QMSBean> quotations = new ArrayList<QMSBean>();
// // 拼接查询语句
// String sql = "select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where 1=1 ";
//
// if (f1.getText() != null && !"".equals(f1.getText().trim())) {
// sql += "and \"qmsinspectioncode\" like '%" + f1.getText() + "%'";
// }
// if (f2.getText() != null && !"".equals(f2.getText().trim())) {
// sql += "and \"qmsinspectionname\" like '%" + f2.getText() + "%'";
// }
// if (f3.getText() != null && !"".equals(f3.getText().trim())) {
// sql += "and \"plmdesignation\" like '%" + f3.getText() + "%'";
// }
//
// if (c1.isSelected()) {
// sql += "and \"synctime\" is null";
// }
//
// if (c2.isSelected()) {
// sql += "and \"plmvaluetype\" = '参数化' ";
// }
//
// if (c2.isSelected()) {
// sql += "and \"plmvaluetype\" != '参数化' ";
// }
//
// sql += "order by \"qmsinspectioncode\" desc";
// System.out.println("sql:" + sql);
//
//
//// this.plmvaluetype.textProperty().addListener((observable, oldValue, newValue) -> {
//// System.out.println("Text changed from '" + oldValue + "' to '" + newValue + "'");
//// this.table.setRowFactory(tv -> {
//// TableRow<QMSBean> row = new TableRow<>();
//// row.itemProperty().addListener((obs, previousItem, newItem) -> {
//// QMSBean qmsBean = row.getItem();
//// System.out.println("newItem========================="+qmsBean);
//// if(qmsBean.getPlmvaluetype().getText().equals(oldValue)) {
//// String xh = qmsBean.getXh();
//// qmsBean.setRed(true);
//// System.out.println("xh==============="+xh);
//// if (qmsBean != null && qmsBean.isRed()) {
//// // 当行中有数据时设置样式
//// row.setStyle("-fx-background-color: red;");
//// } else {
//// // 当行为空时恢复默认样式
//// row.setStyle("");
//// }
//// }
////
//// });
//// return row ;
//// });
////
//// });
//
//
// try {
//
// ResultSet res = SqlUtil.read(sql);
// // 处理查询数据结果集
// int xh = 1;
// while (res.next()) {
//
//
// QMSBean QMSBean = new QMSBean(isEdit, (Integer) res.getInt("code"), xh + "",
// res.getString("qmsinspectioncode") != null ? res.getString("qmsinspectioncode") : "",
// res.getString("qmsinspectionname") != null ? res.getString("qmsinspectionname") : "",
// res.getString("qmssuperiorinspectionname") != null ? res.getString("qmssuperiorinspectionname"): "",
// res.getString("qmsinspectionschemename") != null ? res.getString("qmsinspectionschemename"): "",
// res.getString("qmspushuser") != null ? res.getString("qmspushuser") : "",
// res.getString("plmvaluetype") != null ? res.getString("plmvaluetype") : "" ,
// res.getString("plminspectioncode") != null ? res.getString("plminspectioncode") : "",
// res.getString("plmdesignation") != null ? res.getString("plmdesignation") : "",
// res.getString("plmsequence") != null ? res.getString("plmsequence") : "",
// res.getString("result") != null ? res.getString("result") : "",
// res.getString("status") != null ? res.getString("status") : "",
// res.getDate("plmchangetime"),
// res.getString("plmchangeuser") != null ? res.getString("plmchangeuser") : "");
//
// System.out.println("QMSBean===" + QMSBean);
// quotations.add(QMSBean);
// xh++;
// }
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
//
// if (quotations.size() > 0) {
// // 组织界面数据
// data = FXCollections.observableArrayList(quotations);
//
// table.getItems().clear();
// table.setItems(data);
// } else {
// // 未查到数据
// Alert alert = new Alert(AlertType.INFORMATION);
// alert.setTitle("提示");
// alert.setHeaderText("未查到数据!");
// // alert.setContentText("导入完成");
// alert.showAndWait();
// }
cx();
}
public void cx(){
SqlUtil.SRMGetTCDataConnection(prefs);
//判断该用户是否有权限编辑界面
System.out.println("======================清除");
table.getItems().clear();
List<QMSBean> quotations = new ArrayList<QMSBean>();
// 拼接查询语句
String sql = "";
if(isAdmin) {
sql = "select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where 1=1 ";
}else {
sql = "select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"factory\"='"+factory+"' ";
}
if (f1.getText() != null && !"".equals(f1.getText().trim())) {
sql += " and \"qmsinspectioncode\" like '%" + f1.getText() + "%'";
}
if (f2.getText() != null && !"".equals(f2.getText().trim())) {
sql += " and \"qmsinspectionname\" like '%" + f2.getText() + "%'";
}
if (f3.getText() != null && !"".equals(f3.getText().trim())) {
sql += " and \"plmdesignation\" like '%" + f3.getText() + "%'";
}
if (c1.isSelected()) {
sql += " and \"plminspectioncode\" is null";
}
if (c2.isSelected()) {
sql += " and \"plmvaluetype\" = '参数化' ";
}
if (c3.isSelected()) {
sql += " and \"plmvaluetype\" != '参数化' ";
}
sql += " order by \"qmsinspectioncode\" desc";
System.out.println("sql:" + sql);
// this.plmvaluetype.textProperty().addListener((observable, oldValue, newValue) -> {
// System.out.println("Text changed from '" + oldValue + "' to '" + newValue + "'");
// this.table.setRowFactory(tv -> {
// TableRow<QMSBean> row = new TableRow<>();
// row.itemProperty().addListener((obs, previousItem, newItem) -> {
// QMSBean qmsBean = row.getItem();
// System.out.println("newItem========================="+qmsBean);
// if(qmsBean.getPlmvaluetype().getText().equals(oldValue)) {
// String xh = qmsBean.getXh();
// qmsBean.setRed(true);
// System.out.println("xh==============="+xh);
// if (qmsBean != null && qmsBean.isRed()) {
// // 当行中有数据时设置样式
// row.setStyle("-fx-background-color: red;");
// } else {
// // 当行为空时恢复默认样式
// row.setStyle("");
// }
// }
//
// });
// return row ;
// });
//
// });
try {
ResultSet res = SqlUtil.read(sql);
// 处理查询数据结果集
int xh = 1;
while (res.next()) {
QMSBean QMSBean = new QMSBean(isEdit, (Integer) res.getInt("code"), xh + "",
res.getString("qmsinspectioncode") != null ? res.getString("qmsinspectioncode") : "",
res.getString("qmsinspectionname") != null ? res.getString("qmsinspectionname") : "",
res.getString("qmssuperiorinspectionname") != null ? res.getString("qmssuperiorinspectionname"): "",
res.getString("qmsinspectionschemename") != null ? res.getString("qmsinspectionschemename"): "",
res.getString("qmspushuser") != null ? res.getString("qmspushuser") : "",
res.getString("plmvaluetype") != null ? res.getString("plmvaluetype") : "" ,
res.getString("plminspectioncode") != null ? res.getString("plminspectioncode") : "",
res.getString("plmdesignation") != null ? res.getString("plmdesignation") : "",
res.getString("plmsequence") != null ? res.getString("plmsequence") : "",
res.getString("result") != null ? res.getString("result") : "",
res.getString("status") != null ? res.getString("status") : "",
res.getDate("plmchangetime"),
res.getString("plmchangeuser") != null ? res.getString("plmchangeuser") : "");
System.out.println("QMSBean===" + QMSBean);
quotations.add(QMSBean);
xh++;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
if (quotations.size() > 0) {
// 组织界面数据
data = FXCollections.observableArrayList(quotations);
table.getItems().clear();
table.setItems(data);
} else {
Platform.runLater(new Runnable() {
@Override
public void run() {
// 未查到数据
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("未查到数据!");
// alert.setContentText("导入完成");
alert.showAndWait();
}
});
}
}
//保存
@FXML
void bcAction(ActionEvent event) throws TCException {
ObservableList<QMSBean> items = table.getItems();
SqlUtil.SRMGetTCDataConnection(prefs);
String factory = SAPUtil.getGroupID(session);
int count = 0;
//保存之前循环判断值
for (int i = 0; i < items.size(); i++) {
QMSBean qmsBean = items.get(i);
boolean selected = qmsBean.getCheckBox().isSelected();
if(selected) {
String plmvaluetype = qmsBean.getPlmvaluetype().getValue() == null || qmsBean.getPlmvaluetype().getValue().isEmpty() ?"":qmsBean.getPlmvaluetype().getValue();
String plmdesignation =qmsBean.getPlmdesignation().getText() == null || qmsBean.getPlmdesignation().getText().isEmpty() ? "" : qmsBean.getPlmdesignation().getText();
String plmsequence =qmsBean.getPlmsequence().getValue() == null || qmsBean.getPlmsequence().getValue().isEmpty() ? "" : qmsBean.getPlmsequence().getValue();
if(plmvaluetype.equals("参数化") && plmdesignation.isEmpty()) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("第"+qmsBean.getXh()+"行的参数代号不能为空!");
//alert.setContentText("导入完成");
alert.showAndWait();
return;
}else if(plmvaluetype.contains("规格") && plmsequence.isEmpty()){
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("第"+qmsBean.getXh()+"行的规格位数(顺序)不能为空!");
//alert.setContentText("导入完成");
alert.showAndWait();
return;
}
}
}
for (int i = 0; i < items.size(); i++) {
QMSBean qmsBean = items.get(i);
boolean selected = qmsBean.getCheckBox().isSelected();
if(selected) {
//判断检验项编码是否为空 为空数据库获取流水号
String plminspectioncode = "";
plminspectioncode = qmsBean.getPlminspectioncode();
if(plminspectioncode == null || plminspectioncode.isEmpty()) {
//取数据库获取流水号
SqlUtil.SRMGetTCDataConnection(prefs);
String selectLSH = "select \"code\" from CHINT_QMS_INSPECIFICATION_NUMBER_RULE where \"factory\" = '"+factory+"'";
String lsh = "";
try {
ResultSet res = SqlUtil.read(selectLSH);
// 处理查询数据结果集
while (res.next()) {
lsh = res.getString(1);
}
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
if(lsh == null || lsh.isEmpty()) {
// 获取流水号的首选项
String[] lsmPref = session.getPreferenceService().getStringValues("CHINT_QMS_INSPECIFICATION_NUMBER_RULE");
// 获取对应组织的流水码
for (int z = 0; z < lsmPref.length; z++) {
String[] split = lsmPref[z].split(":");
// 判断当前组织与首选项是否相同
if (split[0].equals(factory)) {
lsh = split[1];
SqlUtil.SRMGetTCDataConnection(prefs);
//数据库中插入
String updateSql = "INSERT INTO CHINT_QMS_INSPECIFICATION_NUMBER_RULE (\"factory\",\"code\",\"flow\") VALUES ('"
+ factory + "','" + lsh + "','" + lsh +"')";
System.out.println("updateSql========"+updateSql);
SqlUtil.update(updateSql);
}
}
plminspectioncode = lsh;
}else {
//流水号+1
// 正则表达式,匹配所有的字母和数字
Pattern pattern = Pattern.compile("(\\D+)(\\d+)");
Matcher matcher = pattern.matcher(lsh);
if (matcher.find()) {
String alphaPart = matcher.group(1); // 字母部分
String numericPartStr = matcher.group(2); // 数字部分字符串
// 将数字部分转换为整数加1再转回字符串
int numericPartInt = Integer.parseInt(numericPartStr);
numericPartInt++; // 加1
String newNumericPart = String.format("%0" + numericPartStr.length() + "d",
numericPartInt); // 保持原数字的长度前面补0
// 重新拼接字符串
lsh = alphaPart + newNumericPart;
System.out.println("新组成的字符串: " + lsh);
} else {
System.out.println("未在字符串中找到符合模式的部分。");
}
// 流水码+1 //设置流水号到数据库
SqlUtil.SRMGetTCDataConnection(prefs);
if (!lsh.isEmpty()) {
String updateSql = "update CHINT_QMS_INSPECIFICATION_NUMBER_RULE set \"code\" = '"+lsh+"' where \"factory\" = '"+factory+"'";
System.out.println("updateSql========"+updateSql);
SqlUtil.update(updateSql);
}
plminspectioncode = lsh;
}
}
count++;
//保存操作
String plmvaluetype = qmsBean.getPlmvaluetype().getValue() == null || qmsBean.getPlmvaluetype().getValue().isEmpty() ?"":qmsBean.getPlmvaluetype().getValue();
String plmdesignation =qmsBean.getPlmdesignation().getText() == null || qmsBean.getPlmdesignation().getText().isEmpty() ? "" : qmsBean.getPlmdesignation().getText();
String plmsequence =qmsBean.getPlmsequence().getValue() == null || qmsBean.getPlmsequence().getValue().isEmpty() ? "" : qmsBean.getPlmsequence().getValue();
String sql = "update CHINT_QMS_INSPECIFICATION_CODE_RULE set \"plmvaluetype\" = '"+plmvaluetype
+"',\"plmdesignation\" = '"+plmdesignation
+"',\"plmsequence\" = '"+plmsequence
+"',\"plminspectioncode\" = '"+ plminspectioncode +"' where \"code\"='"+qmsBean.getCode()+"'";
System.out.println("sql ========================"+sql);
SqlUtil.update(sql);
}
}
if(count == 0) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("请勾选数据!");
//alert.setContentText("导入完成");
alert.showAndWait();
}else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("项目保存完成!");
//alert.setContentText("导入完成");
alert.showAndWait();
}
}
}

@ -1,25 +0,0 @@
package com.chint.plm.qms;
import java.awt.BorderLayout;
import java.awt.Dimension;
import com.chint.plm.rdmCreate.KFrame;
import javafx.embed.swing.JFXPanel;
public class QMSFrame extends KFrame {
public QMSFrame() {
super();
}
@Override
protected void initUI() throws Exception {
this.setTitle("ÖÊÁ¿¼ìÑéÏîά»¤½çÃæ");
this.setLayout(new BorderLayout());
// this.setPreferredSize(new Dimension(1300, 900));
JFXPanel panel = new JFXPanel();
panel.setScene(new QMSPanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
}

@ -1,76 +0,0 @@
package com.chint.plm.qms;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.HashMap;
import org.apache.log4j.chainsaw.Main;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
*
* @author admin
* 2023/11/16
*/
public class QMSHandler extends AbstractHandler{
@Override
public Object execute(ExecutionEvent arg0) {
// TODO Auto-generated method stub
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession)app.getSession();
try {
new Thread() {
@Override
public void run() {
// NewJFrame newJFrame = new NewJFrame(session);
// int width2 = newJFrame.getWidth();
// int height2 = newJFrame.getHeight();
// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
// int screenWidth = screenSize.width; // 获取屏幕宽度
// int screenHeight = screenSize.height; // 获取屏幕高度
// int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标
// int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标
// newJFrame.setTitle("工装需求查询");
// // this.getContentPane().setBackground(Color.red);
// newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255));
// newJFrame.setSize(1240, height2); // 设置Frame的大小
// newJFrame.setLocation(x, y); // 设置Frame的位置
// newJFrame.setResizable(false);
// newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作
// newJFrame.setVisible(true);
// String groupID = "";
// try {
// groupID = SAPUtil.getGroupID(session);
// } catch (TCException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// System.out.println("groupID==="+groupID);
// //Project Administration
// if(!groupID.equals("Project Administration")) {
// MessageBox.post("请切换至项目管理组执行此功能。", "提示", MessageBox.INFORMATION);
// return;
// }
//
new QMSFrame();
}
}.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

@ -1,15 +0,0 @@
package com.chint.plm.qms;
import java.awt.Window;
import com.chint.plm.rdmCreate.KFXPanel;
public class QMSPanel extends KFXPanel {
public QMSPanel(Window dialog) {
super(dialog, "QMS.fxml");
// TODO Auto-generated constructor stub
}
}

@ -1,135 +0,0 @@
package com.chint.plm.rdmCreate;
import com.sun.javafx.util.Logging;
import com.teamcenter.rac.util.MessageBox;
import java.awt.Window;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.stage.Stage;
//import sun.util.logging.PlatformLogger;
public abstract class KFXPanel extends Application {
protected Scene scene;
protected KFXPanelController aifController;
protected Parent root;
protected String cssForm;
protected Window parentDialog;
static {
Platform.setImplicitExit(false);
// Logging.getCSSLogger().setLevel(Platform.class...STYLESHEET_CASPIAN....Level.OFF);
}
public KFXPanel(Window dialog, String fxmlName) {
setParentDialog(dialog);
initUI(fxmlName);
initData();
}
public KFXPanel(Window dialog, Class<?> c, String css) {
setParentDialog(dialog);
this.cssForm = c.getResource(css).toExternalForm();
initUI();
initData();
}
public void setParentDialog(Window dialog) {
this.parentDialog = dialog;
}
public Window getParentDialog() {
return this.parentDialog;
}
public Parent getRoot() {
return this.root;
}
public KFXPanelController getController() {
return this.aifController;
}
public Scene getScene() {
if (this.scene == null) {
this.scene = new Scene(this.root);
this.scene.setFill(null);
}
return this.scene;
}
public void initData() {
try {
this.aifController.initData(this);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
protected void initUI(String fxmlName) {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = fxmlName;// "SearchSapResultPanel.fxml";
fxmlLoader.setLocation(getClass().getResource(resource));
this.root = (Parent) fxmlLoader.load();
this.aifController = (KFXPanelController) fxmlLoader.getController();
if (this.cssForm != null)
this.root.getStylesheets().add(this.cssForm);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
protected void initUI() {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = "SearchSapResultPanel.fxml";
fxmlLoader.setLocation(getClass().getResource(resource));
this.root = (Parent) fxmlLoader.load();
this.aifController = (KFXPanelController) fxmlLoader.getController();
if (this.cssForm != null)
this.root.getStylesheets().add(this.cssForm);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
public static void post(Window dialog, final String msg, final String title, int msgType) {
if (dialog == null) {
Platform.runLater(new Runnable() {
public void run() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle(title);
alert.setHeaderText("");
alert.setContentText(msg);
alert.showAndWait();
}
});
} else {
MessageBox.post(dialog, msg, title, msgType);
}
}
// protected Stage primaryStage;
public void start(Stage primaryStage) throws Exception {
initUI();
initData();
// this.primaryStage = primaryStage;
primaryStage.setScene(getScene());
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

@ -1,27 +0,0 @@
package com.chint.plm.rdmCreate;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
public abstract class KFXPanelController {
@FXML
protected AnchorPane coverPane;
public abstract void initData(KFXPanel paramKFXPanel) throws Exception;
public void setCoverVisible(final boolean visible) {
if (this.coverPane != null) {
Platform.runLater(new Runnable() {
public void run() {
KFXPanelController.this.coverPane.setVisible(visible);
}
});
try {
Thread.sleep(10L);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -1,29 +0,0 @@
package com.chint.plm.rdmCreate;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.UIUtilities;
import javax.swing.JFrame;
public abstract class KFrame extends JFrame {
// protected KDialogController controller;
public KFrame() {
try {
// if (!this.controller.init())
// return;
initUI();
showFrame();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(this, e);
}
}
public void showFrame() {
pack();
UIUtilities.centerToScreen(this);
setVisible(true);
}
protected abstract void initUI() throws Exception;
}

@ -1,101 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<Pane fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="840.0" prefWidth="1270.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chint.plm.rdmCreate.RdmCreateController">
<children>
<TitledPane fx:id="titlePane" animated="false" layoutY="-1.0" prefHeight="105.0" prefWidth="1272.0" text="创建研发项目">
<content>
<AnchorPane fx:id="anchorPane1" minHeight="0.0" minWidth="0.0" prefHeight="67.0" prefWidth="1270.0">
<children>
<GridPane fx:id="gridTop" layoutX="197.0" layoutY="18.0" prefHeight="49.0" prefWidth="839.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button fx:id="cjButton" mnemonicParsing="false" onAction="#cjbutton" prefHeight="41.0" prefWidth="136.0" text="创建" GridPane.halignment="CENTER" />
<Button fx:id="gbxmButton" mnemonicParsing="false" onAction="#gbxmButton" prefHeight="43.0" prefWidth="135.0" text="关闭项目" GridPane.columnIndex="2" GridPane.halignment="CENTER" />
</children>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<Pane fx:id="pane1" layoutY="109.0" prefHeight="726.0" prefWidth="309.0">
<children>
<AnchorPane fx:id="anchorPane2" minHeight="0.0" minWidth="0.0" prefHeight="726.0" prefWidth="309.0">
<children>
<GridPane fx:id="grid" layoutX="20.0" layoutY="41.0" prefHeight="457.0" prefWidth="253.0">
<children>
<Label prefHeight="20.0" prefWidth="82.0" text="内部订单号" />
<Label text="项目定义" GridPane.rowIndex="1" />
<Label text="集团项目号" GridPane.rowIndex="2" />
<Label text="项目名称" GridPane.rowIndex="3" />
<Label text="项目经理" GridPane.rowIndex="4" />
<Label text="工厂" GridPane.rowIndex="5" />
<Label text="推送者" GridPane.rowIndex="6" />
<Label text="推送时间早于" GridPane.rowIndex="7" />
<Label text="推送时间晚于" GridPane.rowIndex="8" />
<Label text="状态" GridPane.rowIndex="9" />
<TextField fx:id="f0" GridPane.columnIndex="1" />
<TextField fx:id="f1" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="f2" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField fx:id="f3" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField fx:id="f4" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<TextField fx:id="f6" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<DatePicker fx:id="f7" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<DatePicker fx:id="f8" GridPane.columnIndex="1" GridPane.rowIndex="8" />
<ComboBox fx:id="f5" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<ComboBox fx:id="f9" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="9" />
<Button fx:id="cxButton" mnemonicParsing="false" onAction="#cxButton" prefHeight="30.0" prefWidth="88.0" text="查询" GridPane.columnIndex="1" GridPane.rowIndex="11" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="122.0" minWidth="10.0" prefWidth="93.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="160.0" minWidth="10.0" prefWidth="160.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</children>
</Pane>
<Pane fx:id="pane2" layoutX="318.0" layoutY="108.0" prefHeight="733.0" prefWidth="949.0">
<children>
<AnchorPane fx:id="anchorPane3" minHeight="0.0" minWidth="0.0" prefHeight="726.0" prefWidth="949.0">
<children>
<ScrollPane fx:id="scrollpane" prefHeight="726.0" prefWidth="941.0">
<content>
<AnchorPane fx:id="anchorPane4" minHeight="0.0" minWidth="0.0" prefHeight="707.0" prefWidth="922.0">
<children>
<TableView fx:id="table" prefHeight="711.0" prefWidth="927.0" />
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
</children>
</Pane>
</children>
</Pane>

@ -1,200 +0,0 @@
package com.chint.plm.rdmCreate;
import java.sql.Date;
import java.text.SimpleDateFormat;
import javafx.beans.property.BooleanProperty;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextArea;
public class RdmCreateBean {
private TextArea ordernumber = new TextArea();
private TextArea projectno = new TextArea();
private TextArea rdmprojectno = new TextArea();
private TextArea projectname = new TextArea();
private TextArea projectleader = new TextArea();
private TextArea factory = new TextArea();
private TextArea pushuser = new TextArea();
private TextArea pushdate = new TextArea();
private TextArea status = new TextArea();
private TextArea createdate = new TextArea();
private TextArea projectleaderid = new TextArea();
private TextArea pushuserid = new TextArea();
private CheckBox checkBox = new CheckBox();
public CheckBox getCheckBox() {
return checkBox;
}
public void setCheckBox(CheckBox checkBox) {
this.checkBox = checkBox;
}
public RdmCreateBean(String ordernumber, String projectno, String rdmprojectno, String projectname,
String projectleader, String factory, String pushuser, Date pushdate, String status, Date createdate,
String projectleaderid, String pushuserid) {
super();
this.checkBox.setSelected(false);
this.ordernumber.setText(ordernumber);
this.ordernumber.setEditable(false);
this.ordernumber.setPrefSize(200, 40);
this.projectno.setText(projectno);
this.projectno.setEditable(false);
this.projectno.setPrefSize(200, 40);
this.rdmprojectno.setText(rdmprojectno);
this.rdmprojectno.setEditable(false);
this.rdmprojectno.setPrefSize(200, 40);
this.projectname.setText(projectname);
this.projectname.setEditable(false);
this.projectname.setPrefSize(200, 40);
this.projectleader.setText(projectleader);
this.projectleader.setEditable(false);
this.projectleader.setPrefSize(200, 40);
this.factory.setText(factory);
this.factory.setEditable(false);
this.factory.setPrefSize(200, 40);
this.pushuser.setText(pushuser);
this.pushuser.setEditable(false);
this.pushuser.setPrefSize(200, 40);
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-dd");
this.pushdate.setText(sdf2.format(pushdate));
this.pushdate.setEditable(false);
this.pushdate.setPrefSize(200, 40);
this.status.setText(status);
this.status.setEditable(false);
this.status.setPrefSize(200, 40);
this.createdate.setText(sdf2.format(createdate));
this.createdate.setEditable(false);
this.createdate.setPrefSize(200, 40);
this.projectleaderid.setText(projectleaderid);
this.projectleaderid.setEditable(false);
this.projectleaderid.setPrefSize(200, 40);
this.pushuserid.setText(pushuserid);
this.pushuserid.setEditable(false);
this.pushuserid.setPrefSize(200, 40);
}
public void setOrdernumber(TextArea ordernumber) {
this.ordernumber = ordernumber;
}
public void setProjectno(TextArea projectno) {
this.projectno = projectno;
}
public void setRdmprojectno(TextArea rdmprojectno) {
this.rdmprojectno = rdmprojectno;
}
public void setProjectname(TextArea projectname) {
this.projectname = projectname;
}
public void setProjectleader(TextArea projectleader) {
this.projectleader = projectleader;
}
public void setFactory(TextArea factory) {
this.factory = factory;
}
public void setPushuser(TextArea pushuser) {
this.pushuser = pushuser;
}
public void setPushdate(TextArea pushdate) {
this.pushdate = pushdate;
}
public void setStatus(TextArea status) {
this.status = status;
}
public void setCreatedate(TextArea createdate) {
this.createdate = createdate;
}
public void setProjectleaderid(TextArea projectleaderid) {
this.projectleaderid = projectleaderid;
}
public void setPushuserid(TextArea pushuserid) {
this.pushuserid = pushuserid;
}
public TextArea getOrdernumber() {
return ordernumber;
}
public TextArea getProjectno() {
return projectno;
}
public TextArea getRdmprojectno() {
return rdmprojectno;
}
public TextArea getProjectname() {
return projectname;
}
public TextArea getProjectleader() {
return projectleader;
}
public TextArea getFactory() {
return factory;
}
public TextArea getPushuser() {
return pushuser;
}
public TextArea getPushdate() {
return pushdate;
}
public TextArea getStatus() {
return status;
}
public TextArea getCreatedate() {
return createdate;
}
public TextArea getProjectleaderid() {
return projectleaderid;
}
public TextArea getPushuserid() {
return pushuserid;
}
}

@ -1,25 +0,0 @@
package com.chint.plm.rdmCreate;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javafx.embed.swing.JFXPanel;
public class RdmCreateFrame extends KFrame {
public RdmCreateFrame() {
super();
}
@Override
protected void initUI() throws Exception {
this.setTitle("´´½¨RDMÑз¢ÏîÄ¿");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1300, 900));
JFXPanel panel = new JFXPanel();
panel.setScene(new RdmCreatePanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
}

@ -1,103 +0,0 @@
package com.chint.plm.rdmCreate;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.HashMap;
import org.apache.log4j.chainsaw.Main;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
/**
*
* @author admin
* 2023/11/16
*/
public class RdmCreateHandler extends AbstractHandler{
@Override
public Object execute(ExecutionEvent arg0) {
// TODO Auto-generated method stub
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession)app.getSession();
try {
new Thread() {
@Override
public void run() {
// NewJFrame newJFrame = new NewJFrame(session);
// int width2 = newJFrame.getWidth();
// int height2 = newJFrame.getHeight();
// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
// int screenWidth = screenSize.width; // 获取屏幕宽度
// int screenHeight = screenSize.height; // 获取屏幕高度
// int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标
// int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标
// newJFrame.setTitle("工装需求查询");
// // this.getContentPane().setBackground(Color.red);
// newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255));
// newJFrame.setSize(1240, height2); // 设置Frame的大小
// newJFrame.setLocation(x, y); // 设置Frame的位置
// newJFrame.setResizable(false);
// newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作
// newJFrame.setVisible(true);
String groupID = "";
try {
groupID = SAPUtil.getGroupID(session);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("groupID==="+groupID);
//Project Administration
if(!groupID.equals("Project Administration")) {
MessageBox.post("请切换至项目管理组执行此功能。", "提示", MessageBox.INFORMATION);
return;
}
InterfaceAIFComponent targetComponent = app.getTargetComponent();
String type = "";
if(targetComponent != null) {
System.out.println("targetComponent=============="+targetComponent.getType());
type = targetComponent.getType();
}
if(type == null || type.isEmpty() || !type.equals("ZT2_ProjectFolder")) {
MessageBox.post("请选择公共文件夹类型!", "提示", MessageBox.INFORMATION);
return;
}else {
new RdmCreateFrame();
}
}
}.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
new RdmCreateFrame();
}
}

@ -1,13 +0,0 @@
package com.chint.plm.rdmCreate;
import java.awt.Window;
public class RdmCreatePanel extends KFXPanel {
public RdmCreatePanel(Window dialog) {
super(dialog, "RdmCreate.fxml");
// TODO Auto-generated constructor stub
}
}

@ -19,12 +19,14 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -45,9 +47,14 @@ import javax.swing.table.TableColumnModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import org.apache.ibatis.session.SqlSession;
import com.chint.plm.common.util.tc.TCItemRevisionUtils;
import com.connor.chint.sap2.mybatis.CcemVW_Cgd;
import com.connor.chint.sap2.mybatis.dao.CcemVW_CgdDao;
import com.connor.chint.sap2.sap_zy.CodeBean;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.DBMybatisUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.POIUtil;
import com.connor.chint.sap2.util.ProgressBar;
@ -309,13 +316,9 @@ public class DYStandardBOMController {
public List<CcemVW_Cgd> queryMaterial(String desc, TCSession session) throws Exception {
List<CcemVW_Cgd> cgd_Beans = new ArrayList<>();
// SqlSession sqlSession = DBMybatisUtil.getSession("MDM");
if (SqlUtil.getConnection() == null) {
KUtil.error(dialog, "数据库连接失败");
return cgd_Beans;
}
SqlSession sqlSession = DBMybatisUtil.getSession("MDM");
try {
// CcemVW_CgdDao dao = sqlSession.getMapper(CcemVW_CgdDao.class);
CcemVW_CgdDao dao = sqlSession.getMapper(CcemVW_CgdDao.class);
String code = desc;
String groupID = SAPUtil.getGroupID(session);
if (groupID.equalsIgnoreCase("dba")) {
@ -324,13 +327,10 @@ public class DYStandardBOMController {
code = code.replaceAll("\\*", "");
code = code.replaceAll("", "");
code = code.replaceAll(";", "");
String sql;
if (KUtil.isEmpty(code)) {
// cgd_Beans = dao.queryMaterialByCode(groupID);
sql = "select CompanyCodeStr,GoodsCode,GoodsName,GoodsBpNo,GoodsFullInfo,GoodsTeRe,GoodsUnitCode,"
+ "GoodsPmpcCode,GoodsUsed from \"CcemVW_Cgd\" where \"CompanyCodeStr\" like '%" + groupID
+ "%' and \"GoodsFullInfo\" not like '%停用%' order by GoodsCode";
cgd_Beans = dao.queryMaterialByCode(groupID);
} else {
if (pattern.matcher(code).matches()) {
code = desc.replaceAll("\\*", "%");
code = desc.replaceAll("", "%");
@ -340,10 +340,7 @@ public class DYStandardBOMController {
code += "%";
if (!code.endsWith("%"))
code = "%" + code;
// cgd_Beans = dao.queryMaterialByCode1(groupID, code);
sql = "select CompanyCodeStr,GoodsCode,GoodsName,GoodsBpNo,GoodsFullInfo,GoodsTeRe,GoodsUnitCode,"
+ "GoodsPmpcCode,GoodsUsed from \"CcemVW_Cgd\" where \"CompanyCodeStr\" like '%" + groupID
+ "%' and \"GoodsCode\" like '" + code + "' and \"GoodsFullInfo\" not like '%停用%' order by GoodsCode";
cgd_Beans = dao.queryMaterialByCode1(groupID, code);
} else {
if (!KUtil.isEmpty(code)) {
code = desc.replaceAll("\\*", "%");
@ -354,29 +351,17 @@ public class DYStandardBOMController {
if (!code.startsWith("%"))
code = "%" + code;
}
// cgd_Beans = dao.queryAllMaterialByDesc(groupID, code);
sql = "select CompanyCodeStr,GoodsCode,GoodsName,GoodsBpNo,GoodsFullInfo,GoodsTeRe,GoodsUnitCode,"
+ "GoodsPmpcCode,GoodsUsed from \"CcemVW_Cgd\" where \"CompanyCodeStr\" like '%" + groupID
+ "%' and \"GoodsFullInfo\" like '" + code + "' and \"GoodsFullInfo\" not like '%停用%' order by GoodsCode";
cgd_Beans = dao.queryAllMaterialByDesc(groupID, code);
// cgd_Beans = dao.queryMaterialByDesc1(groupID, code);
}
}
//TODO 20240911排序方式GoodsCode改为GoodsUsed以优化速度 20240929改回GoodsCode
// 20240913去掉停用以优化速度
System.out.println("sql==>\n" + sql);
ResultSet rs = SqlUtil.read(sql);
while (rs.next()) {
cgd_Beans.add(new CcemVW_Cgd(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4),
rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8)));
}
System.out.println("查询结束");
SqlUtil.free();
} catch (Exception e) {
e.printStackTrace();
} finally {
// if (sqlSession != null) {
// sqlSession.close();
// }
if (sqlSession != null) {
sqlSession.close();
}
}
return cgd_Beans;
}
@ -477,7 +462,6 @@ public class DYStandardBOMController {
public void standardBOMSearch(final String ylh, final String text) throws Exception {
System.out.println("ylh:" + ylh);
new Thread(new Runnable() {
@SuppressWarnings("deprecation")
@Override
public void run() {
ProgressBar pb = new ProgressBar(dialog, new Dimension(300, 50));
@ -613,7 +597,6 @@ public class DYStandardBOMController {
return flag;
}
@SuppressWarnings("deprecation")
public void initUI() throws Exception {
TCSession session = (TCSession) app.getSession();
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -749,7 +732,7 @@ public class DYStandardBOMController {
TCComponentBOMWindow win = this.bomWinType.create(null);
List<TreePath> paths = new ArrayList<>();
List<TreePath> paths = new ArrayList();
try
{
Connection connection2 = SqlUtil.getConnection2();
@ -758,7 +741,7 @@ public class DYStandardBOMController {
sql = sql + folderUid + "'";
System.out.println("sql2====================" + sql);
ResultSet rs = SqlUtil.read(sql.toString());
Map<String, DYStandardBomBean> beanMap = new LinkedHashMap<>();
Map<String, DYStandardBomBean> beanMap = new LinkedHashMap();
String itemId;
while (rs.next())
{
@ -835,7 +818,7 @@ public class DYStandardBOMController {
List<TreePath> paths = new ArrayList<>();
List<TreePath> paths = new ArrayList();
try
{
Connection connection2 = SqlUtil.getConnection2();
@ -953,7 +936,7 @@ public class DYStandardBOMController {
@Override
public int compare(StandardBOMBean o1, StandardBOMBean o2) {
// Auto-generated method stub
// TODO Auto-generated method stub
return POIUtil.getIntValue(o1.getBl_sequence_no()) - POIUtil.getIntValue(o2.getBl_sequence_no());
}
@ -1038,7 +1021,7 @@ public class DYStandardBOMController {
@Override
public int compare(StandardBOMBean o1, StandardBOMBean o2) {
// Auto-generated method stub
// TODO Auto-generated method stub
return POIUtil.getIntValue(o1.getBl_sequence_no()) - POIUtil.getIntValue(o2.getBl_sequence_no());
}
@ -1128,7 +1111,7 @@ public class DYStandardBOMController {
@Override
public int compare(StandardBOMBean o1, StandardBOMBean o2) {
// Auto-generated method stub
// TODO Auto-generated method stub
return POIUtil.getIntValue(o1.getBl_sequence_no()) - POIUtil.getIntValue(o2.getBl_sequence_no());
}
@ -1174,7 +1157,7 @@ public class DYStandardBOMController {
@Override
public int compare(StandardBOMBean o1, StandardBOMBean o2) {
// Auto-generated method stub
// TODO Auto-generated method stub
return POIUtil.getIntValue(o1.getBl_sequence_no()) - POIUtil.getIntValue(o2.getBl_sequence_no());
}
@ -1258,7 +1241,7 @@ public class DYStandardBOMController {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
}
});
@ -1447,7 +1430,6 @@ public class DYStandardBOMController {
}
// BOM競뻣
@SuppressWarnings("deprecation")
public void replaceBOM(TCComponentItemRevision before, TCComponentItemRevision after,
List<TCComponentItemRevision> boms, List<TCComponentItemRevision> rev_TCMs) throws Exception {
System.out.println("역迦競뻣");
@ -1844,7 +1826,6 @@ public class DYStandardBOMController {
}
// 괏닸
@SuppressWarnings("deprecation")
public void save2(ProgressBar pb, DefaultMutableTreeNode topTreeNode, List<StandardBOMBean> beans)
throws Exception {
if (!dialog.isUpdate) {
@ -1976,7 +1957,6 @@ public class DYStandardBOMController {
// List<StandardBOMBean> beans
// <20>
@SuppressWarnings("deprecation")
public void doClickTree(DefaultMutableTreeNode topTreeNode, List<StandardBOMBean> beans) throws Exception {
DYStandardBomBean topBean = (DYStandardBomBean) topTreeNode.getUserObject();
TCComponentItemRevision rev = topBean.getRev();
@ -2007,7 +1987,6 @@ public class DYStandardBOMController {
}
// 璘긋疳崗샌
@SuppressWarnings("deprecation")
public void doClickTree(DefaultMutableTreeNode topTreeNode) throws Exception {
DYStandardBomBean topBean = (DYStandardBomBean) topTreeNode.getUserObject();
TCComponentItemRevision rev = topBean.getRev();
@ -2120,7 +2099,7 @@ public class DYStandardBOMController {
private boolean isMaterial = false;
public DYSearchDialog(final List<StandardBOMBean> beans, boolean isMaterial, String text) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
super(dialog, true);
this.isMaterial = isMaterial;
if (!isMaterial) {
@ -2138,7 +2117,7 @@ public class DYStandardBOMController {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
t_part.requestFocus();
t_part.repaint();
t_part.grabFocus();
@ -2188,12 +2167,12 @@ public class DYStandardBOMController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
String desc = jtf_query.getText();
ProgressBar pb = new ProgressBar(DYSearchDialog.this, new Dimension(300, 50));
@ -2253,7 +2232,7 @@ public class DYStandardBOMController {
}
} catch (Exception e1) {
// Auto-generated catch block
// TODO Auto-generated catch block
pb.disposeDialog();
e1.printStackTrace();
MessageBox.post("꿴璂嫩끽:" + e1.getMessage(), "", 2);
@ -2298,7 +2277,7 @@ public class DYStandardBOMController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int rows[] = t_part.getSelectedRows();
int size = rows.length;
if (size == 0) {
@ -2498,7 +2477,7 @@ public class DYStandardBOMController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(desc);
clip.setContents(tText, null);

@ -809,12 +809,6 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog {
System.out.println(map_fn_size);
Date date = new Date();
String dateString = sdf.format(date);
if(isAdd) {
//TODO lidy20240619
String prefix0 = (String) t_bom.getValueAt(0, 5);
dateString = prefix0.substring(prefix0.length() - 4);
}
System.out.println("dateString:" + dateString);
// String query = "select * from \"CHINT_M008_FactoryNo\" WHERE TIME='" + dateString + "'";
ResultSet rs = null;
String selectQuery = "select * from \"CHINT_M008_FactoryNo\" where TYPE=? and TIME=?";
@ -876,10 +870,8 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog {
factoryID = factoryID + String.format(c, start + j);
}else if(type.equals(ztsvg)) {
factoryID = type + String.format(c, start + j);
}else if(isAdd) {
String prefix0 = (String) t_bom.getValueAt(0, 5);
factoryID = prefix0 + String.format(c, start + j);
}else {
}
else {
factoryID = type + dateString + String.format(c, start + j);
}
list_new_factoryNos.add(factoryID);

@ -54,7 +54,7 @@ public class BatchAddController {
private BatchAddDialog dialog;
private TCSession session;
private AbstractAIFApplication app;
// private DYSearchDialog material_dialog;
private DYSearchDialog material_dialog;
private final static String SQL_QUERY_MATERIAL = "select \"GoodsCode\",\"GoodsFullInfo\",\"GoodsTeRe\",\"GoodsUnitCode\" from \"CcemVW_Cgd\" where 1=1 ";
private Map<String, String> real_display_unit = new HashMap<>(32);
private TCComponentBOMWindowType bomWinType;
@ -87,7 +87,6 @@ public class BatchAddController {
return list;
}
@SuppressWarnings("deprecation")
public void initUI() throws Exception {
TCSession session = (TCSession) app.getSession();
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -220,8 +219,7 @@ public class BatchAddController {
}
}
// material_dialog =
new DYSearchDialog(beans, true, desc);
material_dialog = new DYSearchDialog(beans, true, desc);
}
private class DYSearchDialog extends AbstractAIFDialog {
@ -237,13 +235,13 @@ public class BatchAddController {
public int[] HEADERWIDTH = new int[] { 50, 120, 500, 120, 50 };
protected DefaultTableModel tm_part;
protected JTable t_part;
// private List<TCComponentItemRevision> revs = new ArrayList<>();
private List<TCComponentItemRevision> revs = new ArrayList<>();
private StandardBOMBean bean = null;
private boolean isMaterial = false;
public DYSearchDialog(final List<StandardBOMBean> beans, boolean isMaterial, String text) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
super(dialog, true);
this.isMaterial = isMaterial;
initUI();
@ -253,14 +251,6 @@ public class BatchAddController {
btn_ok.requestFocus();
t_part.setRowSelectionInterval(0, 0);
t_part.changeSelection(0, 0, false, false);
//lidy20241108ÄÚÈÝ¿¿×óÏÔʾ
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(JLabel.LEFT);
for (int i = 0; i < t_part.getColumnCount(); i++) {
t_part.getColumn(t_part.getColumnName(i)).setCellRenderer(renderer);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -273,27 +263,27 @@ public class BatchAddController {
showDialog();
}
// public DYSearchDialog(AbstractAIFDialog parent, List<StandardBOMBean> beans, boolean isMaterial, String text) {
// super(parent, true);
// this.isMaterial = isMaterial;
// initUI();
// jtf_query.setText(text);
// refushTable2(beans);
// btn_ok.requestFocusInWindow();
// btn_ok.requestFocus();
// t_part.setRowSelectionInterval(0, 0);
// t_part.changeSelection(0, 0, false, false);
// SwingUtilities.invokeLater(new Runnable() {
//
// @Override
// public void run() {
// t_part.requestFocus();
// t_part.repaint();
// t_part.grabFocus();
// }
// });
// showDialog();
// }
public DYSearchDialog(AbstractAIFDialog parent, List<StandardBOMBean> beans, boolean isMaterial, String text) {
super(parent, true);
this.isMaterial = isMaterial;
initUI();
jtf_query.setText(text);
refushTable2(beans);
btn_ok.requestFocusInWindow();
btn_ok.requestFocus();
t_part.setRowSelectionInterval(0, 0);
t_part.changeSelection(0, 0, false, false);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
t_part.requestFocus();
t_part.repaint();
t_part.grabFocus();
}
});
showDialog();
}
private void initUI() {
this.setTitle("物料查询结果");
@ -321,12 +311,12 @@ public class BatchAddController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
String desc = jtf_query.getText();
ProgressBar pb = new ProgressBar(DYSearchDialog.this, new Dimension(300, 50));
@ -360,7 +350,7 @@ public class BatchAddController {
t_part.changeSelection(0, 0, false, false);
}
} catch (Exception e1) {
// Auto-generated catch block
// TODO Auto-generated catch block
pb.disposeDialog();
e1.printStackTrace();
MessageBox.post("查询异常:" + e1.getMessage(), "", 2);
@ -402,7 +392,7 @@ public class BatchAddController {
System.out.println("关闭界面");
DYSearchDialog.this.disposeDialog();
} catch (Exception e1) {
// : handle exception
// TODO: handle exception
e1.printStackTrace();
}
}
@ -414,7 +404,7 @@ public class BatchAddController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int rows[] = t_part.getSelectedRows();
int size = rows.length;
if (size == 0) {
@ -460,17 +450,17 @@ public class BatchAddController {
@Override
public void keyTyped(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int code = e.getKeyCode();
int row = t_part.getSelectedRow();
switch (code) {
@ -508,14 +498,14 @@ public class BatchAddController {
}
// 单个物料
// public StandardBOMBean getResult() {
// return bean;
// }
//
// // »ñµÃ±ê×¼BOM
// public List<TCComponentItemRevision> getRevs() {
// return revs;
// }
public StandardBOMBean getResult() {
return bean;
}
// »ñµÃ±ê×¼BOM
public List<TCComponentItemRevision> getRevs() {
return revs;
}
private JPanel getBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
@ -560,7 +550,6 @@ public class BatchAddController {
}
}
@SuppressWarnings("deprecation")
public void replaceBOM(TCComponentItemRevision before, TCComponentItemRevision after,
List<TCComponentItemRevision> boms) throws Exception {
if (bomWinType == null) {

@ -54,7 +54,7 @@ public class BatchRemoveController {
private BatchRemoveDialog dialog;
private TCSession session;
private AbstractAIFApplication app;
// private DYSearchDialog material_dialog;
private DYSearchDialog material_dialog;
private final static String SQL_QUERY_MATERIAL = "select \"GoodsCode\",\"GoodsFullInfo\",\"GoodsTeRe\",\"GoodsUnitCode\" from \"CcemVW_Cgd\" where 1=1 ";
private Map<String, String> real_display_unit = new HashMap<>(32);
private TCComponentBOMWindowType bomWinType;
@ -87,7 +87,6 @@ public class BatchRemoveController {
return list;
}
@SuppressWarnings("deprecation")
public void initUI() throws Exception {
TCSession session = (TCSession) app.getSession();
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -220,8 +219,7 @@ public class BatchRemoveController {
}
}
// material_dialog =
new DYSearchDialog(beans, true, desc);
material_dialog = new DYSearchDialog(beans, true, desc);
}
private class DYSearchDialog extends AbstractAIFDialog {
@ -237,13 +235,13 @@ public class BatchRemoveController {
public int[] HEADERWIDTH = new int[] { 50, 120, 500, 120, 50 };
protected DefaultTableModel tm_part;
protected JTable t_part;
// private List<TCComponentItemRevision> revs = new ArrayList<>();
private List<TCComponentItemRevision> revs = new ArrayList<>();
private StandardBOMBean bean = null;
private boolean isMaterial = false;
public DYSearchDialog(final List<StandardBOMBean> beans, boolean isMaterial, String text) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
super(dialog, true);
this.isMaterial = isMaterial;
initUI();
@ -253,14 +251,6 @@ public class BatchRemoveController {
btn_ok.requestFocus();
t_part.setRowSelectionInterval(0, 0);
t_part.changeSelection(0, 0, false, false);
//lidy20241108ÄÚÈÝ¿¿×óÏÔʾ
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(JLabel.LEFT);
for (int i = 0; i < t_part.getColumnCount(); i++) {
t_part.getColumn(t_part.getColumnName(i)).setCellRenderer(renderer);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -273,27 +263,27 @@ public class BatchRemoveController {
showDialog();
}
// public DYSearchDialog(AbstractAIFDialog parent, List<StandardBOMBean> beans, boolean isMaterial, String text) {
// super(parent, true);
// this.isMaterial = isMaterial;
// initUI();
// jtf_query.setText(text);
// refushTable2(beans);
// btn_ok.requestFocusInWindow();
// btn_ok.requestFocus();
// t_part.setRowSelectionInterval(0, 0);
// t_part.changeSelection(0, 0, false, false);
// SwingUtilities.invokeLater(new Runnable() {
//
// @Override
// public void run() {
// t_part.requestFocus();
// t_part.repaint();
// t_part.grabFocus();
// }
// });
// showDialog();
// }
public DYSearchDialog(AbstractAIFDialog parent, List<StandardBOMBean> beans, boolean isMaterial, String text) {
super(parent, true);
this.isMaterial = isMaterial;
initUI();
jtf_query.setText(text);
refushTable2(beans);
btn_ok.requestFocusInWindow();
btn_ok.requestFocus();
t_part.setRowSelectionInterval(0, 0);
t_part.changeSelection(0, 0, false, false);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
t_part.requestFocus();
t_part.repaint();
t_part.grabFocus();
}
});
showDialog();
}
private void initUI() {
this.setTitle("物料查询结果");
@ -321,12 +311,12 @@ public class BatchRemoveController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
String desc = jtf_query.getText();
ProgressBar pb = new ProgressBar(DYSearchDialog.this, new Dimension(300, 50));
@ -360,7 +350,7 @@ public class BatchRemoveController {
t_part.changeSelection(0, 0, false, false);
}
} catch (Exception e1) {
// Auto-generated catch block
// TODO Auto-generated catch block
pb.disposeDialog();
e1.printStackTrace();
MessageBox.post("查询异常:" + e1.getMessage(), "", 2);
@ -402,7 +392,7 @@ public class BatchRemoveController {
System.out.println("关闭界面");
DYSearchDialog.this.disposeDialog();
} catch (Exception e1) {
// : handle exception
// TODO: handle exception
e1.printStackTrace();
}
}
@ -414,7 +404,7 @@ public class BatchRemoveController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int rows[] = t_part.getSelectedRows();
int size = rows.length;
if (size == 0) {
@ -460,17 +450,17 @@ public class BatchRemoveController {
@Override
public void keyTyped(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int code = e.getKeyCode();
int row = t_part.getSelectedRow();
switch (code) {
@ -508,14 +498,14 @@ public class BatchRemoveController {
}
// 单个物料
// public StandardBOMBean getResult() {
// return bean;
// }
//
// // »ñµÃ±ê×¼BOM
// public List<TCComponentItemRevision> getRevs() {
// return revs;
// }
public StandardBOMBean getResult() {
return bean;
}
// »ñµÃ±ê×¼BOM
public List<TCComponentItemRevision> getRevs() {
return revs;
}
private JPanel getBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
@ -560,7 +550,6 @@ public class BatchRemoveController {
}
}
@SuppressWarnings("deprecation")
public void replaceBOM(TCComponentItemRevision before, TCComponentItemRevision after,
List<TCComponentItemRevision> boms) throws Exception {
if (bomWinType == null) {

@ -54,7 +54,7 @@ public class BatchReplaceController {
private BatchReplaceDialog dialog;
private TCSession session;
private AbstractAIFApplication app;
// private DYSearchDialog material_dialog;
private DYSearchDialog material_dialog;
private final static String SQL_QUERY_MATERIAL = "select \"GoodsCode\",\"GoodsFullInfo\",\"GoodsTeRe\",\"GoodsUnitCode\" from \"CcemVW_Cgd\" where 1=1 ";
private Map<String, String> real_display_unit = new HashMap<>(32);
private TCComponentBOMWindowType bomWinType;
@ -87,7 +87,6 @@ public class BatchReplaceController {
return list;
}
@SuppressWarnings("deprecation")
public void initUI() throws Exception {
TCSession session = (TCSession) app.getSession();
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -220,8 +219,7 @@ public class BatchReplaceController {
}
}
// material_dialog =
new DYSearchDialog(beans, true, desc);
material_dialog = new DYSearchDialog(beans, true, desc);
}
private class DYSearchDialog extends AbstractAIFDialog {
@ -237,13 +235,13 @@ public class BatchReplaceController {
public int[] HEADERWIDTH = new int[] { 50, 120, 500, 120, 50 };
protected DefaultTableModel tm_part;
protected JTable t_part;
// private List<TCComponentItemRevision> revs = new ArrayList<>();
private List<TCComponentItemRevision> revs = new ArrayList<>();
private StandardBOMBean bean = null;
private boolean isMaterial = false;
public DYSearchDialog(final List<StandardBOMBean> beans, boolean isMaterial, String text) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
super(dialog, true);
this.isMaterial = isMaterial;
initUI();
@ -253,15 +251,8 @@ public class BatchReplaceController {
btn_ok.requestFocus();
t_part.setRowSelectionInterval(0, 0);
t_part.changeSelection(0, 0, false, false);
//lidy20241108ÄÚÈÝ¿¿×óÏÔʾ
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(JLabel.LEFT);
for (int i = 0; i < t_part.getColumnCount(); i++) {
t_part.getColumn(t_part.getColumnName(i)).setCellRenderer(renderer);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
t_part.requestFocus();
@ -272,27 +263,27 @@ public class BatchReplaceController {
showDialog();
}
// public DYSearchDialog(AbstractAIFDialog parent, List<StandardBOMBean> beans, boolean isMaterial, String text) {
// super(parent, true);
// this.isMaterial = isMaterial;
// initUI();
// jtf_query.setText(text);
// refushTable2(beans);
// btn_ok.requestFocusInWindow();
// btn_ok.requestFocus();
// t_part.setRowSelectionInterval(0, 0);
// t_part.changeSelection(0, 0, false, false);
// SwingUtilities.invokeLater(new Runnable() {
//
// @Override
// public void run() {
// t_part.requestFocus();
// t_part.repaint();
// t_part.grabFocus();
// }
// });
// showDialog();
// }
public DYSearchDialog(AbstractAIFDialog parent, List<StandardBOMBean> beans, boolean isMaterial, String text) {
super(parent, true);
this.isMaterial = isMaterial;
initUI();
jtf_query.setText(text);
refushTable2(beans);
btn_ok.requestFocusInWindow();
btn_ok.requestFocus();
t_part.setRowSelectionInterval(0, 0);
t_part.changeSelection(0, 0, false, false);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
t_part.requestFocus();
t_part.repaint();
t_part.grabFocus();
}
});
showDialog();
}
private void initUI() {
this.setTitle("物料查询结果");
@ -320,12 +311,12 @@ public class BatchReplaceController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
String desc = jtf_query.getText();
ProgressBar pb = new ProgressBar(DYSearchDialog.this, new Dimension(300, 50));
@ -359,7 +350,7 @@ public class BatchReplaceController {
t_part.changeSelection(0, 0, false, false);
}
} catch (Exception e1) {
// Auto-generated catch block
// TODO Auto-generated catch block
pb.disposeDialog();
e1.printStackTrace();
MessageBox.post("查询异常:" + e1.getMessage(), "", 2);
@ -401,7 +392,7 @@ public class BatchReplaceController {
System.out.println("关闭界面");
DYSearchDialog.this.disposeDialog();
} catch (Exception e1) {
// : handle exception
// TODO: handle exception
e1.printStackTrace();
}
}
@ -413,7 +404,7 @@ public class BatchReplaceController {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int rows[] = t_part.getSelectedRows();
int size = rows.length;
if (size == 0) {
@ -459,17 +450,17 @@ public class BatchReplaceController {
@Override
public void keyTyped(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int code = e.getKeyCode();
int row = t_part.getSelectedRow();
switch (code) {
@ -507,14 +498,14 @@ public class BatchReplaceController {
}
// 单个物料
// public StandardBOMBean getResult() {
// return bean;
// }
//
// // »ñµÃ±ê×¼BOM
// public List<TCComponentItemRevision> getRevs() {
// return revs;
// }
public StandardBOMBean getResult() {
return bean;
}
// »ñµÃ±ê×¼BOM
public List<TCComponentItemRevision> getRevs() {
return revs;
}
private JPanel getBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
@ -559,7 +550,6 @@ public class BatchReplaceController {
}
}
@SuppressWarnings("deprecation")
public void replaceBOM(TCComponentItemRevision before, TCComponentItemRevision after,
List<TCComponentItemRevision> boms) throws Exception {
if (bomWinType == null) {

@ -119,7 +119,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
try {
controller.initUI();
} catch (Exception e) {
// Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
initUI();
@ -150,7 +150,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
@Override
public void showDialog() {
// Auto-generated method stub
// TODO Auto-generated method stub
if (jtf_replace_after != null) {
jtf_replace_after.setText("");
}
@ -163,12 +163,12 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
@Override
protected void processWindowEvent(WindowEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
try {
stopTimerTask();
} catch (Exception e1) {
// Auto-generated catch block
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@ -192,7 +192,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
}
} catch (Exception e) {
// Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -216,7 +216,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
@ -247,7 +247,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override
@ -401,7 +401,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
@Override
public int compare(BatchReviewBean o1, BatchReviewBean o2) {
// Auto-generated method stub
// TODO Auto-generated method stub
return o1.getDrawNo().compareTo(o2.getDrawNo());
}
});
@ -433,7 +433,7 @@ public class BatchReplaceDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
new Thread(new Runnable() {
@Override

@ -30,12 +30,12 @@ import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLIST;
public class CaculateBOM {
// 是否有虚件作为递归的必要条件
// private boolean m_hasVirtual;
private boolean m_hasVirtual;
private boolean m_breakRecursive;
private int m_MaxRecuresive;
// 系统最大递归层次数,避免出现循环递归情况
private int MAXCAL = 1000000;
// private static String[] check_list = { "原物料编码", "物料规格", "技术参数" };
private static String[] check_list = { "原物料编码", "物料规格", "技术参数" };
/**
* Clone
@ -54,7 +54,7 @@ public class CaculateBOM {
WriteTempLog.PrintMemoryTree(m_tree.GetMemoryTreeRoot(), "CaculateBom");
} catch (Exception e) {
// Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -63,10 +63,9 @@ public class CaculateBOM {
public void CaculateProcess() throws IOException {
System.out.println("CaculateProcess()");
/* 初始化条件 */
m_breakRecursive = false;
// m_hasVirtual = false;
m_hasVirtual = false;
m_MaxRecuresive = 0;
try {
while (true) {
@ -79,7 +78,7 @@ public class CaculateBOM {
}
// System.out.println(toString());
} catch (Exception e) {
// : handle exception
// TODO: handle exception
// 加入日志处理
e.printStackTrace();
}
@ -87,10 +86,9 @@ public class CaculateBOM {
public void CaculateProcess(boolean isZT) throws IOException {
System.out.println("CaculateProcess(boolean isZT)");
/* 初始化条件 */
m_breakRecursive = false;
// m_hasVirtual = false;
m_hasVirtual = false;
m_MaxRecuresive = 0;
try {
while (true) {
@ -103,7 +101,7 @@ public class CaculateBOM {
}
// System.out.println(toString());
} catch (Exception e) {
// : handle exception
// TODO: handle exception
// 加入日志处理
e.printStackTrace();
}
@ -113,7 +111,7 @@ public class CaculateBOM {
/* 初始化条件 */
m_breakRecursive = false;
// m_hasVirtual = false;
m_hasVirtual = false;
m_MaxRecuresive = 0;
try {
while (true) {
@ -126,7 +124,7 @@ public class CaculateBOM {
}
// System.out.println(toString());
} catch (Exception e) {
// : handle exception
// TODO: handle exception
// 加入日志处理
e.printStackTrace();
}
@ -146,7 +144,7 @@ public class CaculateBOM {
RuiteLogger.CreateInstance().PrintDebug("遍历已到最大循环次数,可能已经产生死锁!");
return;
}
// String id2 = Root.GetId();
String id2 = Root.GetId();
if (Root.getItem().getType().equals("ZT2_Design3DRevision")
&& Root.getItem().getProperty("zt2_Source").equals("外购")) {
// System.out.println("是图纸且是外购件--->"+Root.GetId());
@ -156,15 +154,15 @@ public class CaculateBOM {
return;
}
if (Root.getItem().getType().equals("Part Revision")) {
// id2 = Root.getItem().getProperty("zt2_MaterialNo");
id2 = Root.getItem().getProperty("zt2_MaterialNo");
}
for (int i = 0; i < Root.getChildren().size(); i++) {
Component c = (Root.getChildren().get(i));
// BOMInfo bominfo = Root.getChildrenBomInfo().get(i);
// String id = c.GetId();
BOMInfo bominfo = Root.getChildrenBomInfo().get(i);
String id = c.GetId();
if (c.getItem().getType().equals("Part Revision")) {
// id = c.getItem().getProperty("zt2_MaterialNo");
id = c.getItem().getProperty("zt2_MaterialNo");
}
if (c.getItem().getType().equals("ZT2_Design3DRevision")
@ -206,7 +204,7 @@ public class CaculateBOM {
RuiteLogger.CreateInstance().PrintDebug("遍历已到最大循环次数,可能已经产生死锁!");
return;
}
// String id2 = Root.GetId();
String id2 = Root.GetId();
if (Root.getItem().getType().equals("ZT2_Design3DRevision")
&& Root.getItem().getProperty("zt2_Source").equals("外购")) {
Root.setVirtualNode(false);
@ -216,7 +214,7 @@ public class CaculateBOM {
}
// 高开框架BOM
if (Root.getItem().getType().equals("Part Revision")) {
// id2 = Root.getItem().getProperty("zt2_MaterialNo");
id2 = Root.getItem().getProperty("zt2_MaterialNo");
}
String zt2_SapState;
@ -225,26 +223,23 @@ public class CaculateBOM {
BOMInfo bominfo = Root.getChildrenBomInfo().get(i);
TCComponentBOMLine childLine = (TCComponentBOMLine) bominfo.getBomProperty().get("BomLine");
TCComponentItemRevision rev = childLine.getItemRevision();
System.out.println(level + "RecursiveBomTree:" + childLine + "==" + bominfo.getLevel() +
"==" + SAPUtil.isFrameBOMGK(rev));
if (bominfo.getLevel() == 0 || bominfo.getLevel() == 1) {
if (bominfo.getLevel() == 1) {
if (SAPUtil.isFrameBOMGK(rev)) {
zt2_SapState = rev.getProperty("zt2_SapState");
System.out.println("zt2_SapState:" + zt2_SapState);
if ("未传".equals(zt2_SapState)) {
Root.getChildrenBomInfo().remove(i);
Root.getChildren().remove(i);
m_MaxRecuresive++;
i--;
continue;
} else if ("已传".equals(zt2_SapState)) {//TODO
} else if ("已传".equals(zt2_SapState)) {
if (!(c instanceof Leaf)) {
((Composite) c).getChildrenBomInfo().clear();
((Composite) c).getChildren().clear();
}
m_MaxRecuresive++;
continue;
} else if ("待传".equals(zt2_SapState)) {// || "已传".equals(zt2_SapState)
} else if ("待传".equals(zt2_SapState)) {
if (!(c instanceof Leaf)) {
ArrayList<BOMInfo> childs = ((Composite) c).getChildrenBomInfo();
String parent_sortno = bominfo.getZT2_ClassificationNo();
@ -294,7 +289,7 @@ public class CaculateBOM {
RuiteLogger.CreateInstance().PrintDebug("遍历已到最大循环次数,可能已经产生死锁!");
return;
}
// String id2 = Root.GetId();
String id2 = Root.GetId();
if (Root.getItem().getType().equals("ZT2_Design3DRevision")
&& Root.getItem().getProperty("zt2_Source").equals("外购")) {
Root.setVirtualNode(false);
@ -304,7 +299,7 @@ public class CaculateBOM {
}
// 高开框架BOM
if (Root.getItem().getType().equals("Part Revision")) {
// id2 = Root.getItem().getProperty("zt2_MaterialNo");
id2 = Root.getItem().getProperty("zt2_MaterialNo");
}
String zt2_SapState;
@ -485,7 +480,7 @@ public class CaculateBOM {
/* 初始化条件 */
m_breakRecursive = false;
// m_hasVirtual = false;
m_hasVirtual = false;
m_MaxRecuresive = 0;
try {
while (true) {
@ -502,7 +497,7 @@ public class CaculateBOM {
}
// System.out.println(toString());
} catch (Exception e) {
// : handle exception
// TODO: handle exception
// 加入日志处理
e.printStackTrace();
}
@ -527,7 +522,7 @@ public class CaculateBOM {
/* 初始化条件 */
m_breakRecursive = false;
// m_hasVirtual = false;
m_hasVirtual = false;
m_MaxRecuresive = 0;
try {
while (true) {
@ -541,7 +536,7 @@ public class CaculateBOM {
}
// System.out.println(toString());
} catch (Exception e) {
// : handle exception
// TODO: handle exception
// 加入日志处理
e.printStackTrace();
}
@ -581,29 +576,20 @@ public class CaculateBOM {
Component c = (Root.getChildren().get(i));
BOMInfo bomInfo = Root.getChildrenBomInfo().get(i);
TCComponentItemRevision rev2 = (TCComponentItemRevision) c.getItem();
String zt2_SapState = rev2.getProperty("zt2_SapState");
System.out.println("RecursiveBomTree" + rev2 + "==" + zt2_SapState);
// if (zt2_SapState.equals("已传") && !isZT)
// continue;
if (!(zt2_SapState.equals("待传") || zt2_SapState.equals("已传"))) {//!KUtil.isTCM(rev2) || //!isZT &&
//TODO lidy20241104通用传递子件状态是待传或已传的才展开传递
if (rev2.getProperty("zt2_SapState").equals("已传") && !isZT)
continue;
}
/* 如果是叶子节点,则继续执行 */
if (c instanceof Leaf) {
System.out.println("instanceof Leaf");
m_MaxRecuresive++;
SAPUtil.recurSAP2((TCComponentBOMLine) bomInfo.getBomProperty().get("BomLine"),
(TCComponentItemRevision) c.getItem(), null, true, session, groupName, now, txtPath, list,
proclist, errMess, gy_meops, needTCM_meops, bomISExist, codeRemark, icsId, by_materials, c,
material_revs, set_meops, isZT,wbsList);
} else {
System.out.println("Leafelse");
m_MaxRecuresive++;
RecursiveBomTree((Composite) c, session, groupName, now, txtPath, list, proclist, errMess, gy_meops,
needTCM_meops, bomISExist, codeRemark, icsId, by_materials,
(TCComponentBOMLine) bomInfo.getBomProperty().get("BomLine"),
material_revs, set_meops, isZT, wbsList);
(TCComponentBOMLine) bomInfo.getBomProperty().get("BomLine"), material_revs, set_meops, isZT,wbsList);
}
}

@ -59,7 +59,7 @@ public class ContreteMediator extends AbstractMediator {
@Override
public void CheckPreMemoryTree() {
// Auto-generated method stub
// TODO Auto-generated method stub
CommandResponseCollection.Singleton().Clear();
BomLineQuery query = new BomLineQuery();
QueryResult result;
@ -72,14 +72,14 @@ public class ContreteMediator extends AbstractMediator {
}
} catch (Exception e) {
// Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void ProcessTree() throws IOException {
// Auto-generated method stub
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
CaculateBOM _calBom = new CaculateBOM(_tree);
_calBom.CaculateProcess();
@ -87,7 +87,7 @@ public class ContreteMediator extends AbstractMediator {
}
public void ProcessTree2(List<BOMTestBean> boms) throws IOException {
// Auto-generated method stub
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
CaculateBOM _calBom = new CaculateBOM(_tree);
_calBom.CaculateProcess2(boms);
@ -95,8 +95,7 @@ public class ContreteMediator extends AbstractMediator {
}
public void ProcessTree3() throws IOException {
// Auto-generated method stub
System.out.println("ProcessTree3()");
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
CaculateBOM _calBom = new CaculateBOM(_tree);
_calBom.CaculateProcess();
@ -104,7 +103,7 @@ public class ContreteMediator extends AbstractMediator {
}
public void ProcessTree3(boolean isZT) throws IOException {
// Auto-generated method stub
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
CaculateBOM _calBom = new CaculateBOM(_tree);
_calBom.CaculateProcess(isZT);
@ -117,8 +116,7 @@ public class ContreteMediator extends AbstractMediator {
List<String> bomISExist, String codeRemark, int icsId, Map<String, TCComponentItemRevision> by_materials,
TCComponentBOMLine line, Map<String, TCComponentItemRevision> material_revs, Set<TCComponent> set_meops,
boolean isZT,Map<String,TCComponentItemRevision> wbsList) throws IOException {
// Auto-generated method stub
System.out.println("ProcessTree");
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
CaculateBOM _calBom = new CaculateBOM(_tree);
_calBom.CaculateProcess(session, groupName, now, txtPath, list, proclist, errMess, gy_meops, needTCM_meops,
@ -135,7 +133,7 @@ public class ContreteMediator extends AbstractMediator {
public void ProcessBOMCheck(TCSession session, String groupName, StringBuffer errMess, String codeRemark, int icsId,
Map<String, TCComponentItemRevision> by_materials, TCComponentBOMLine line, String btnName, String txtPath)
throws IOException {
// Auto-generated method stub
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
CaculateBOM _calBom = new CaculateBOM(_tree);
_calBom.CaculateProcessBOMCheck(session, groupName, errMess, codeRemark, icsId, by_materials, line, btnName,
@ -145,13 +143,13 @@ public class ContreteMediator extends AbstractMediator {
@Override
public void CheckPostMemoryTree() {
// Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public void ProcessSQL() {
// Auto-generated method stub
// TODO Auto-generated method stub
for (MemoryTree _tree : m_vecMemoryTrees) {
Component _com = _tree.GetMemoryTreeRoot();
@ -200,7 +198,7 @@ public class ContreteMediator extends AbstractMediator {
WriteTempLog.WriteSQLTOFile(((OrginalSQLCaches) caches).m_TestTree);
} catch (Exception e) {
// Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -209,7 +207,7 @@ public class ContreteMediator extends AbstractMediator {
@Override
public void UpdateDB() {
// Auto-generated method stub
// TODO Auto-generated method stub
}

@ -1,59 +0,0 @@
package com.connor.chint.sap2.commands;
import com.chint.plm.createbomdifference.CreateBOMDifferenceDialogWh;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.dy.createBOMDifference.CreateBOMDifferenceDialog;
import com.connor.chint.sap2.dy.createBOMDifference.CreateBOMDifferenceDialogzt;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
*
*
* @author xiaol
*
*/
public class CreateBOMDifferenceCommandAll extends KCommand {
public CreateBOMDifferenceCommandAll(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
TCSession session = (TCSession) app.getSession();
String groupID = SAPUtil.getGroupID(session);
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_ECN_COMPARE_RULE", session);
if(prefs == null || prefs.length == 0) {
MessageBox.post("CHINT_ECN_COMPARE_RULE首选项配置不正确", "", MessageBox.ERROR);
return;
}
String fa = "C";
for(String pref:prefs) {
String[] split = pref.split(":");
String type = split[0];
String[] split2 = split[1].split(";");
for(String grpId:split2) {
if(grpId.equals(groupID)) {
fa = type;
break;
}
}
}
System.out.println("group:" + groupID + "==>" + fa);
if(fa.equals("A")) {
//武汉工厂
this.setRunnable(new CreateBOMDifferenceDialogWh(app));
} else if(fa.equals("B")) {
//正泰定制
this.setRunnable(new CreateBOMDifferenceDialogzt(app));
} else {
this.setRunnable(new CreateBOMDifferenceDialog(app));
}
}catch(Exception e) {
MessageBox.post("错误:" + e.getMessage(), "", MessageBox.ERROR);
return;
}
}
}

@ -4,7 +4,6 @@ import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.dy.createElectricalBOM.DYCreateElectricalBOMOperation;
import com.connor.chint.sap2.dy.createElectricalBOM.DYCreateElectricalBOMOperation2;
import com.connor.chint.sap2.dy.createElectricalBOM.DYSHCreateElectricalBOMOperation;
import com.connor.chint.sap2.dy.createElectricalBOM.DYSHCreateElectricalBOMOperationV2;
import com.teamcenter.rac.aif.AbstractAIFApplication;
public class CreateElectricalBOMCommand extends KCommand {
@ -26,9 +25,6 @@ public class CreateElectricalBOMCommand extends KCommand {
case "M030_002":
new DYSHCreateElectricalBOMOperation(app).executeOperation();
break;
case "M030_002V2":
new DYSHCreateElectricalBOMOperationV2(app).executeOperation();
break;
case "M030_001ztdz":
new DYCreateElectricalBOMOperation(app).executeOperation();
break;

@ -4,7 +4,6 @@ import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.electrical_task.DYElectricalTasksOperation2;
import com.connor.chint.sap2.electrical_task.DYElectricalTasksOperationNew2;
import com.connor.chint.sap2.electrical_task.DYSHElectricalTasksOperation;
import com.connor.chint.sap2.electrical_task.DYSHElectricalTasksOperationV2;
import com.teamcenter.rac.aif.AbstractAIFApplication;
public class ElectricalTasksCommand extends KCommand {
@ -26,9 +25,6 @@ public class ElectricalTasksCommand extends KCommand {
case "M030_002":
new DYSHElectricalTasksOperation(app).executeOperation();
break;
case "M030_002V2":
new DYSHElectricalTasksOperationV2(app).executeOperation();
break;
case "M030_001ztdz":
// new DYElectricalTasksOperation(app).executeOperation();
new DYElectricalTasksOperation2(app).executeOperation();

@ -1,31 +1,14 @@
package com.connor.chint.sap2.commands;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.materialno.FactoryChooseDialog;
import com.connor.chint.sap2.materialno.MaterialNoDialog;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class MaterialNoCommand extends KCommand {
public MaterialNoCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
TCSession session = (TCSession) app.getSession();
String groupID = SAPUtil.getGroupID(session);
String[] factorys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_FACTORY_RULE", session);
if(SAPUtil.contains(factorys, groupID)) {
new FactoryChooseDialog(app, session, "no");
}else {
this.setRunnable(new MaterialNoDialog(app, session, groupID));
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("´íÎó£º" + e, "", MessageBox.ERROR);
}
this.setRunnable(new MaterialNoDialog(app));
// KUtil.setByPass(false);
}

@ -1,54 +0,0 @@
package com.connor.chint.sap2.commands;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.sap.SAPBJYBOperation;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* : SAP
* :2024-09-06
* @author
*
*
* 2024-09-06
*/
public class SAPBJYBCommand extends KCommand {
public SAPBJYBCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
}
@Override
public void executeModal() {
try {
TCSession session = (TCSession) app.getSession();
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_TYBOMTOSAP", session);
String groupID = SAPUtil.getGroupID(session);
String fa = "";
for(String pref:prefs) {
String[] split = pref.split(":");
String type = split[0];
String[] split2 = split[1].split(";");
for(String grpId : split2) {
if(grpId.equals(groupID)) {
fa = type;
break;
}
}
}
System.out.println("fa==>" + fa);
if(groupID.equals("M060") || fa.equals("B") || fa.equals("D") || fa.equals("C")) {
new SAPBJYBOperation(app, session, groupID, fa).executeOperation();
}else if(fa.equals("A") || fa.equals("E")) {
MessageBox.post("当前组不可使用该功能", "警告", MessageBox.INFORMATION);
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e);
}
}
}

@ -1,17 +1,9 @@
package com.connor.chint.sap2.commands;
import javax.swing.JOptionPane;
import com.chint.plm.applyMatnr.ApplyMatnrOp;
import com.chint.plm.applyMatnr.ApplyMatnrOp2;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.materialno.FactoryChooseDialog;
import com.connor.chint.sap2.operation.OutMPartNoBatchDialog;
import com.connor.chint.sap2.operation.SelfMPartNoBatchOperation;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class SelfMPartNoBatchCommand extends KCommand {
@ -21,47 +13,22 @@ public class SelfMPartNoBatchCommand extends KCommand {
public SelfMPartNoBatchCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
this.actionInfo = actionInfo;
}
@Override
public void executeModal() {
try {
TCSession session = (TCSession) app.getSession();
String groupID = SAPUtil.getGroupID(session);
if(groupID.equals("M060")) {
new Thread() {
public void run(){
try {
String[] array = new String[] { "全部图纸", "个人图纸" };
Object type = JOptionPane.showInputDialog(null, "请选择申请方式", "INFO",
JOptionPane.QUESTION_MESSAGE, null, array, array[0]);
if(type.equals("全部图纸")) {
new ApplyMatnrOp(app, "all").executeOperation();
}else {
new ApplyMatnrOp2(app, "user").executeOperation();
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("错误:" + e, "", MessageBox.ERROR);
}
}
}.start();
}else {
String[] factorys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_FACTORY_RULE", session);
if(SAPUtil.contains(factorys, groupID)) {
new FactoryChooseDialog(app, session, actionInfo);
}else {
if ("M007_2".equals(actionInfo)) {
System.out.println("配变外购件物料申请");
new Thread(new OutMPartNoBatchDialog(app, groupID)).start();
} else {
new SelfMPartNoBatchOperation(app, actionInfo, groupID).executeOperation();
}
}
if ("M007_2".equals(actionInfo)) {
System.out.println("配变外购件物料申请");
new Thread(new OutMPartNoBatchDialog(app)).start();
} else {
new SelfMPartNoBatchOperation(app, actionInfo).executeOperation();
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e);
e.printStackTrace();
}
}

@ -529,12 +529,11 @@ public class CreateECNDialog extends AbstractAIFDialog implements ActionListener
KUtil.stopTableEditing(t_part);
int rowCount = t_part.getRowCount();
boolean write = true;
/*lidy20241205
if (rowCount < 1) {
MessageBox.post("Çë²¹³äÄÚÈÝ", "", MessageBox.INFORMATION);
return;
}
for (int i = 0; i < rowCount; i++) {
if (((String) t_part.getValueAt(i, 7)) == null
|| ((String) t_part.getValueAt(i, 7)).trim().length() == 0) {
@ -547,7 +546,7 @@ public class CreateECNDialog extends AbstractAIFDialog implements ActionListener
write = false;
break;
}
}*/
}
if (write == true) {
try {
String newId = JTextField7.getText();

@ -1,40 +0,0 @@
package com.connor.chint.sap2.createKjBom;
import java.util.Objects;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
public class BomBean {
String revName;
TCComponentBOMLine bomLine;
public BomBean(String revName, TCComponentBOMLine bomLine) {
super();
this.revName = revName;
this.bomLine = bomLine;
}
@Override
public int hashCode() {
return Objects.hash(revName);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BomBean other = (BomBean) obj;
return other.revName.contains(revName);
}
public BomBean(String revName) {
super();
this.revName = revName;
}
@Override
public String toString() {
return "BomBean [revName=" + revName + ", bomLine=" + bomLine + "]\n";
}
}

@ -1,34 +0,0 @@
package com.connor.chint.sap2.createKjBom;
public class CBean {
String cId;
String folderName;
String piName;
public String getcId() {
return cId;
}
public void setcId(String cId) {
this.cId = cId;
}
public String getFolderName() {
return folderName;
}
public void setFolderName(String folderName) {
this.folderName = folderName;
}
public String getPiName() {
return piName;
}
public void setPiName(String piName) {
this.piName = piName;
}
public CBean(String cId, String folderName, String piName) {
super();
this.cId = cId;
this.folderName = folderName;
this.piName = piName;
}
}

@ -1,42 +0,0 @@
package com.connor.chint.sap2.createKjBom;
/**
* @copyRight
* @author E-mail:hub@connor.net.cn
* @date 2017-7-3 11:47:03
* @version v1.0
* @parameter
* @since
* @return
*/
public class ClassProperty {
private int propertyID;
private String value;
public ClassProperty() {
}
public ClassProperty(int propertyID, String value) {
this.propertyID = propertyID;
this.value = value;
}
public int getPropertyID() {
return propertyID;
}
public void setPropertyID(int propertyID) {
this.propertyID = propertyID;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -1,59 +0,0 @@
package com.connor.chint.sap2.createKjBom;
import java.util.ArrayList;
import java.util.List;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateKjBomCommand extends KCommand {
// private boolean top = true;
// private TCComponentBOMLine line;
public CreateKjBomCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
// InterfaceAIFComponent targetComponent = app.getTargetComponent();
try {
TCSession session = (TCSession)app.getSession();
String groupID = SAPUtil.getGroupID(session);
//变压器原首选项CHINT_kjbomTemp改为CHINT_kjbom_M005
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_kjbom_M005", session);
List<KjBean> kjList = new ArrayList<KjBean>();
for(String pref : prefs) {
// 1ZDB300000P-xxx|1ZDB300000P=2-组件布置图;1ZDB400000T=3-铁心图纸&H铁心
if(!pref.startsWith(groupID))
continue;
String[] split = pref.substring(groupID.length() + 1).split("\\|");
String kjBomId = split[0];
KjBean bean = new KjBean(kjBomId);
String[] split2 = split[1].split(";");
for(String s : split2) {
String[] split3 = s.split("=");
if(split3[1].contains("&")) {
String[] split4 = split3[1].split("&");
CBean cb = new CBean(split3[0],split4[0],split4[1]);
bean.cbeans.add(cb);
}else {
CBean cb = new CBean(split3[0],split3[1],"");
bean.cbeans.add(cb);
}
}
kjList.add(bean);
}
if(kjList.size() == 0) {
MessageBox.post("首选项中未找到配置,请登陆正确组", "", MessageBox.WARNING);
return;
}
this.setRunnable(new KjBomDialog(app, "", kjList));
}catch(Exception e) {
e.printStackTrace();
}
}
}

@ -1,28 +0,0 @@
package com.connor.chint.sap2.createKjBom;
import java.util.ArrayList;
import java.util.List;
public class KjBean {
public String kjBs;
public String kjbomId;
public List<CBean> cbeans = new ArrayList<CBean>();
public String getKjbomId() {
return kjbomId;
}
public void setKjbomId(String kjbomId) {
this.kjbomId = kjbomId;
}
public KjBean(String kjbomId) {
super();
this.kjbomId = kjbomId;
String[] split = kjbomId.split("-");
kjBs = split[1];
}
@Override
public String toString() {
return kjbomId;
}
}

@ -1,172 +0,0 @@
package com.connor.chint.sap2.createKjBom;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.util.MessageBox;
public class KjBomDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private List<KjBean> kjList;
// private AbstractAIFApplication app;
private KjController controller;
public KjBomDialog(AbstractAIFApplication app, String actionInfo,List<KjBean> beanList) {
// Auto-generated constructor stub
super(false);
// KUtil.setByPass(true);
// this.app = app;
this.kjList = beanList;
this.controller = new KjController(app);
}
@Override
public void run() {
// Auto-generated method stub
try {
if (!controller.checkProject()) {
MessageBox.post(this, "请选择项目文件夹对象", "", MessageBox.INFORMATION);
return;
}
initUI();
showDialog();
/*
* if(!controller.isAllHave) { MessageBox.post(this,
* "项目中"+controller.name+"方案未同步WBS,请手动执行", "",MessageBox.INFORMATION); }else {
* b_syn.setVisible(false); }
*/
} catch (Exception e) {
MessageBox.post(this, "申请方案编码时发生错误:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace();
return;
}
}
private JButton okButton;
private JButton celButton;
private JComboBox<KjBean> kjCombox;
public void initUI() {
this.setTitle("创建框架BOM");
this.setPreferredSize(new Dimension(400,150));
JPanel p1 = new JPanel(new BorderLayout());
p1.setBorder(new TitledBorder(new EtchedBorder(), "框架BOM模板"));
kjCombox = new JComboBox<KjBean>();
for(KjBean bean:kjList) {
kjCombox.addItem(bean);
}
p1.add(kjCombox);
JPanel rootPanel = new JPanel(new FlowLayout());
this.okButton = new JButton("确认");
this.celButton = new JButton("取消");
rootPanel.add(okButton);
rootPanel.add(celButton);
this.setLayout(new BorderLayout());
this.add(p1, BorderLayout.NORTH);
this.add(rootPanel, BorderLayout.CENTER);
// dialog.add(tablePanel, BorderLayout.CENTER);
this.add(rootPanel, BorderLayout.SOUTH);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
addListeners();
}
private void addListeners() {
// Auto-generated method stub
celButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
dispose();
}
});
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
//开始创建框架BOM
//1.遍历原有框架BOM获取项目代号 、 检查项目结构文件夹、检查id是否唯一
//2.根据项目找到组件布置图 拆分BOM
//3.根据云派信息转换所有权
new Thread() {
@Override
public void run() {
MyProgressBarCompent comp = null;
KUtil.setByPass(true);
try {
comp = new MyProgressBarCompent("", "正在创建框架BOM......");
int selectedIndex = kjCombox.getSelectedIndex();
KjBean kjBean = kjList.get(selectedIndex);
StringBuilder build = new StringBuilder("");
String tempId = kjBean.getKjbomId();
boolean checkFolder = controller.checkFolder(tempId, kjBean, build);
if(!checkFolder) {
comp.setVisible(false);
dispose();
MessageBox.post(build.toString(), "",2);
return;
}
if(controller.byqCCPFromProject.size()>1) {
Object[] options = {"是","否"};
int response = JOptionPane.showOptionDialog(null, "项目产成品存在多台变压器,请确认是否为同一工程图号", "选择",JOptionPane.YES_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if(response == -1 || response==1)
{
return;
}
}
// List<CBean> cbeans = kjBean.cbeans;
boolean createKjBom = controller.createKjBom(kjBean,comp);
comp.setVisible(false);
if(!createKjBom) {
dispose();
return;
}else {
dispose();
MessageBox.post("框架BOM创建完成。", "提示",2);
}
} catch (Exception e1) {
// Auto-generated catch block
e1.printStackTrace();
}finally {
KUtil.setByPass(false);
}
if(comp!=null) {
comp.setVisible(false);
}
dispose();
}
}.start();
}
});
}
}

@ -1,883 +0,0 @@
package com.connor.chint.sap2.createKjBom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JOptionPane;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPUtil;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCAccessControlService;
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.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentRevisionRule;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.ui.common.RACUIUtil;
import com.teamcenter.rac.util.MessageBox;
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.structuremanagement._2014_10.Structure.CloneStructureInputInfo;
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureResponse;
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureSaveAsIn;
public class KjController {
private AbstractAIFApplication app;
private TCSession session;
private TCComponent project;
private String wbsNo = "";
private String projectDh = "";
private String projectId = "";
//存放已经存在的框架BOM的ID
Map<TCComponentItemRevision,TCComponentItem> oldkjIdMap = new HashMap<TCComponentItemRevision,TCComponentItem>();
//存放框架BOM对应的另存ID
Map<TCComponentItemRevision,String> kjIdMap = new HashMap<TCComponentItemRevision,String>();
private List<TCComponentBOMLine> copyLines = new ArrayList<TCComponentBOMLine>();
private String kjBs;
// public
// private TCComponentItemType ccomponentitemtype;
Map<String, String> idName = new HashMap<String, String>();
//存放 ID-文件夹
private Map<String, TCComponentFolder> fMap = new HashMap<>();
private Map<String, TCComponentUser> nameUser = new HashMap<>();
private TCComponentItem tqqgdItem;
protected List<TCComponentItemRevision> byqCCPFromProject;
public KjController(AbstractAIFApplication app) {
// Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
}
public boolean checkProject() throws Exception {
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null || !(target instanceof TCComponent)) {
return false;
}
String type = target.getType();
if (type.equals("ZT2_ProjectItem")) {
project = (TCComponent) target;
projectId = project.getStringProperty("item_id");
projectDh = project.getProperty("zt2_ProjectCode");
wbsNo = project.getProperty("zt2_WBSNo");
System.out.println("WBS号:" + wbsNo);
return true;
}
return false;
}
protected boolean checkFolder(String kjBomId, KjBean kjBean, StringBuilder errBuff) throws Exception {
boolean flag = true;
try {
//获取首选项里的文件夹名称、判断当前项目是否存在
fMap.clear();
Map<String, TCComponentFolder> fodlers = new HashMap<>();
TCComponentFolder xmzxFolder = KUtil.getXMZXFolderFromProject(project);
byqCCPFromProject = getByqCCPFromProject(project, session);
AIFComponentContext[] childFolders = xmzxFolder.getChildren();
TCComponentFolder bztFolder = null;
// TCComponentFolder dcsjFolder = null;
for(AIFComponentContext context : childFolders) {
InterfaceAIFComponent c = context.getComponent();
if(c instanceof TCComponentFolder) {
String cName = c.getProperty("object_name");
if(cName.equals("2-组件布置图")) {
bztFolder = (TCComponentFolder)c;
// }else if(cName.equals("1-电磁设计")) {
// dcsjFolder = (TCComponentFolder)c;
}
fodlers.put(cName, (TCComponentFolder)c);
}
}
if(bztFolder!=null) {
AIFComponentContext[] children = bztFolder.getChildren();
for(AIFComponentContext cont : children) {
InterfaceAIFComponent component = cont.getComponent();
String type = component.getType();
if(type.equals("ZT2_Requisition")) {
tqqgdItem = (TCComponentItem)component;
}
}
}
//lidy20240909取消检查是否创建提前请购和主材采购
/*
TCComponentItem dcsjItem = null;;
if(dcsjFolder != null) {
AIFComponentContext[] children = dcsjFolder.getChildren();
for(AIFComponentContext cont : children) {
InterfaceAIFComponent component = cont.getComponent();
String type = component.getType();
if(type.equals("ZT2_MainMat")) {
dcsjItem = (TCComponentItem)component;
}
}
}if(dcsjItem == null) {
errBuff.append("当前项目中未创建物主材采购单,不允许创建框架BOM.\n");
flag = false;
}else {
TCComponentItemRevision latestItemRevision = dcsjItem.getLatestItemRevision();
if(!KUtil.isTCM(latestItemRevision)){
errBuff.append("当前项目中主材采购单版本未发布,不允许创建框架BOM.\n");flag = false;
}
if(!KUtil.isTCM(KUtil.getRevBOMView(latestItemRevision))) {
errBuff.append("当前项目中主材采购单BOM视图版本未发布,不允许创建框架BOM.\n");flag = false;
}
}
if(tqqgdItem == null) {
errBuff.append("当前项目中未创建物料提前请购单,不允许创建框架BOM.\n");flag = false;
}else {
TCComponentItemRevision latestItemRevision = tqqgdItem.getLatestItemRevision();
if(!KUtil.isTCM(latestItemRevision)){
errBuff.append("当前项目中物料提前请购单版本未发布,不允许创建框架BOM.\n");flag = false;
}
if(!KUtil.isTCM(KUtil.getRevBOMView(latestItemRevision))) {
errBuff.append("当前项目中物料提前请购单BOM视图版本未发布,不允许创建框架BOM.\n");flag = false;
}
}*/
OkHttpClient client = new OkHttpClient();
String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
Request request = new Request.Builder()
.url(preference + "/api/open/task/getTaskInfo/" + projectId)
.build();
Response response = client.newCall(request).execute();
String string = response.body().string();
System.out.println(string);
JSONObject parseObject = JSON.parseObject(string);
JSONArray datas = parseObject.getJSONArray("data");
idName.clear();
if(datas!=null) {
for(int t=0;t<datas.size();t++) {
JSONObject jsonObject = datas.getJSONObject(t);
String string2 = jsonObject.getString("userid");
if(string2!=null && !string2.equals("")) {
idName.put(jsonObject.getString("taskname"),string2);
}
System.out.println(jsonObject.getString("taskname")+"====="+string2);
}
}
System.out.println(idName.toString());
List<CBean> beanList = kjBean.cbeans;
// ZT2_Requisition
for(CBean bean : beanList) {
String piName = bean.piName;
String folderName = bean.folderName;
if(idName.containsKey(piName)) {
String userId = idName.get(piName);
TCComponent userName = getUserName(userId,session);
if(userName!=null) {
nameUser.put(bean.cId,(TCComponentUser) userName);
}
}
if(!fodlers.containsKey(folderName)) {
// errBuff.append("项目执行下没有找到名称为:"+folderName+"的文件夹");//lidy20240829去掉检查没有跳过
// return false;
}else {
fMap.put(bean.cId, fodlers.get(folderName));
}
}
System.out.println(nameUser.toString());
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
return flag;
}
private static TCComponent getUserName(String userID, TCSession session) throws Exception {
Map<String, String> fields = new HashMap<>();
fields.put("用户 ID", userID);
TCComponentContextList quertList = KUtil.query(session, "__WEB_find_user", fields);
if (quertList.getListCount() > 0) {
// System.out.println("user:"+quertList.get(0).getComponent());
return (TCComponent)quertList.get(0).getComponent();
}
return null;
}
private String objectToJson(List<ClassProperty> props) {
String str = null;
try {
net.sf.json.JSONArray json = net.sf.json.JSONArray.fromObject(props);// 将java对象转换为json对象
str = json.toString();// 将json对象转换为字符串
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("JSON =>" + str);
return str;
}
@SuppressWarnings("deprecation")
protected boolean createKjBom(KjBean bean, MyProgressBarCompent comp) throws Exception {
StringBuilder builder = new StringBuilder("");
TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
TCComponentItem newItem = ccomponentitemtype.findItems(bean.getKjbomId())[0];
TCComponentItemRevision kjBomRev = newItem.getLatestItemRevision();
TCTypeService service = session.getTypeService();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
TCComponentBOMWindow window = winType.create(null);
TCComponentBOMLine kjBomLine = window.setWindowTopLine(newItem, kjBomRev, null, null);
kjBs = bean.kjBs;
kjIdMap.clear();
oldkjIdMap.clear();
Map<String, ExpandPSData[]> bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(kjBomLine);
builder.setLength(0);
// 遍历获取BOM结构 判断ID是否存在
String item_id = kjBomRev.getProperty("item_id");
String replaceAll = item_id.replaceAll(kjBs, projectDh);
kjIdMap.put(kjBomRev, replaceAll);
Map<String, TCComponentItem> findMap = new HashMap<String, TCComponentItem>();
//遍历获取BOM新ID
List<TCComponentBOMLine> useLines = new ArrayList<TCComponentBOMLine>();
createId(kjBomLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
System.out.println("kjIdMap==>" + kjIdMap.toString());
System.out.println("builder==>" + builder.toString());
if(builder.length() > 0) {
// MessageBox.post(builder.toString(), "提示",2);
String[] msgs = builder.toString().split("");
builder.setLength(0);
for(int i = 0; i < msgs.length; i++) {
builder.append(msgs[i]).append("");
if(i % 4 == 3) {
builder.append("\n");
}
}
Object[] options = { "是", "否" };
comp.setVisible(false);
builder.append("是否要继续生成.");
int response = JOptionPane.showOptionDialog(null, builder.toString(), "选择", JOptionPane.YES_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if(response == -1 || response == 1) {
window.close();
return false;
}
} //else
{
comp = new MyProgressBarCompent("", "正在创建框架BOM......");
//开始克隆BOM
cloneOrUpdate(session, kjBomLine, copyLines, useLines);
//添加到文件夹
System.out.println("oldkjIdMap==>" + oldkjIdMap.toString());
for(TCComponentItemRevision rev : oldkjIdMap.keySet()) {
TCComponentItem find = oldkjIdMap.get(rev);
String id = find.getProperty("item_id");
String[] split = id.split("-");
System.out.println("id1==>" + id);
if(fMap.containsKey(split[0])) {
TCComponentFolder tcComponentFolder = fMap.get(split[0]);
try {
tcComponentFolder.add("contents", find);
}catch(Exception e) {
if(!e.getMessage().contains("存在于目标文件夹中"))
e.printStackTrace();
}
}
}
System.out.println("nameUser==>" + nameUser.toString());
System.out.println("fMap==>" + fMap.toString());
for(TCComponentItemRevision rev : kjIdMap.keySet()) {
String id = kjIdMap.get(rev);
TCComponentItem[] finds = ccomponentitemtype.findItems(id);
if(finds == null || finds.length == 0) {
System.out.println(id + "对象未找到");
continue;
}
TCComponentItem find = finds[0];
String[] split = id.split("-");
System.out.println("id2==>" + split[0]);
if(fMap.containsKey(split[0])) {
TCComponentFolder tcComponentFolder = fMap.get(split[0]);
try {
tcComponentFolder.add("contents", find);
}catch(Exception e) {
if(!e.getMessage().contains("存在于目标文件夹中"))
e.printStackTrace();
}
}
if(nameUser.containsKey(split[0])) {
TCComponentUser tcComponentUser = nameUser.get(split[0]);
try {
changeOwners(find,tcComponentUser);
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
}
TCComponentItem find = ccomponentitemtype.findItems(replaceAll)[0];
System.out.println("find==>" + find);
TCComponentBOMLine newTopline = window.setWindowTopLine(find, find.getLatestItemRevision(), null, null);
Map<String, ExpandPSData[]> bomLineTreeNodeSOA2 = BomToSapUtil.getBomLineTreeNodeSOA(newTopline);
// replaceBom(newTopline, bomLineTreeNodeSOA2);
if(findMap.size()>0) {
// window.lock();
System.out.println("findMap===>" + findMap.toString());
updateKjBom(findMap, bomLineTreeNodeSOA2, newTopline.getUid());
newTopline.save();
window.save();
window.refresh();
// window.unlock();
// window.close();
}
String groupId = SAPUtil.getGroupID(session);
// TCComponentBOMLine newTopline = window.setWindowTopLine(find, find.getLatestItemRevision(), null, null);
//如果存在已经有的框架BOM对象遍历BOM然后替换再进行下面操作
System.out.println("byqCCPFromProject==>" + byqCCPFromProject.toString());
if(byqCCPFromProject.size()>0) {
try {
if(groupId.equals("M005")) {
for(TCComponentItemRevision ccp : byqCCPFromProject) {
AIFComponentContext[] factorys = KUtil.getPseudoFolder(ccp, "ZT2_FactoryNumber").getChildren();
if(factorys.length > 0) {
for(AIFComponentContext f : factorys) {
find.getLatestItemRevision().add("ZT2_FactoryNumber", (TCComponent) f.getComponent());
}
}else {
find.getLatestItemRevision().add("representation_for", ccp);
}
}
}else
find.getLatestItemRevision().add("representation_for", byqCCPFromProject);
}catch(Exception e) {
if(!e.getMessage().contains("存在于目标文件夹中"))
e.printStackTrace();
}
}
List<ClassProperty> propList = new ArrayList<ClassProperty>();
//TODO 读取CHINT_kjbomTemp_FL首选项根据组织、图纸母号找到对应的分类库 ICM230101
String prefId = groupId + ":" + bean.kjbomId, classID = "";
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_kjbomTemp_FL", session);
for(String pref : prefs) {
if(!pref.startsWith(prefId))
continue;
classID = pref.substring(pref.indexOf("|") + 1);
}
System.out.println("classID==>" + classID);
if(classID.isEmpty()) {
MessageBox.post(prefId + "未找到对应分类库", "提示", MessageBox.WARNING);
}else
sendToClass(find.getUid(), classID, objectToJson(propList));
List<TCComponentBOMLine> listBoms = listBoms(newTopline);
//存放名称对应的BOM行
List<BomBean> bomBeans = new ArrayList<>();
for(TCComponentBOMLine listBom : listBoms) {
String name = listBom.getItemRevision().getProperty("object_name");
bomBeans.add(new BomBean(name, listBom));
}
System.out.println("bomBeans==>" + bomBeans.toString());
// Map<String,List<TCComponentBOMLine>> remarkMap = new HashMap<String,List<TCComponentBOMLine>>();
//拆分BOM逻辑获取物料提前请购单的BOM
if(tqqgdItem != null) {
TCComponentBOMWindow window2 = winType.create(null);
TCComponentBOMLine qgdBomline = window2.setWindowTopLine(tqqgdItem, tqqgdItem.getLatestItemRevision(), null, null);
AIFComponentContext[] children = qgdBomline.getChildren();
//遍历物料提前请购单 根据备注添加BOM到对应位置
// lidy20240710创建框架BOM中功能中的从提前请购组件BOM中抓取成分搭建进生成的框架BOM
//需要将抓取的物料明细在复制后增加注释信息BOM行属性数据来源bl_occ_zt2_wlsource写入“提前请购单”
for(int i = 0; i < children.length; i++) {
TCComponentBOMLine wlLine = (TCComponentBOMLine) children[i].getComponent();
TCComponentItem item = wlLine.getItem();
if(item.getType().equals("ZT2_MainMat")) {
AIFComponentContext[] children2 = wlLine.getChildren();
for(AIFComponentContext c2 : children2) {
TCComponentBOMLine wlLine2 = (TCComponentBOMLine) c2.getComponent();
String object_name = wlLine2.getProperty("ZT2_Remark");
String objName = wlLine2.getItem().getProperty("object_name");
System.out.println(object_name);
System.out.println(objName + "gg");
if(!object_name.equals("") && bomBeans.contains(new BomBean(object_name))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean(object_name)));
if(checkSource(bomBean.bomLine, wlLine2))
continue;
bomBean.bomLine.add(wlLine2, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}else if(object_name.equals("") && objName.contains("硅钢条料")) {
if(bomBeans.contains(new BomBean("硅钢片"))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean("硅钢片")));
if(checkSource(bomBean.bomLine, wlLine2))
continue;
bomBean.bomLine.add(wlLine2, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}
}else {
if(checkSource(newTopline, wlLine2))
continue;
TCComponentBOMLine add = newTopline.add(wlLine2, false);
add.setProperty("bl_occ_zt2_wlsource", "提前请购单");
System.out.println(add);
newTopline.save();
}
}
}else {
String object_name = wlLine.getProperty("ZT2_Remark");
System.out.println(object_name);
String objName = wlLine.getItem().getProperty("object_name");
if(!object_name.equals("") && bomBeans.contains(new BomBean(object_name))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean(object_name)));
if(checkSource(bomBean.bomLine, wlLine))
continue;
bomBean.bomLine.add(wlLine, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}else if(object_name.equals("") && objName.equals("硅钢条料")) {
if(bomBeans.contains(new BomBean("硅钢片"))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean("硅钢片")));
if(checkSource(bomBean.bomLine, wlLine))
continue;
bomBean.bomLine.add(wlLine, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}
}else {
if(checkSource(newTopline, wlLine))
continue;
TCComponentBOMLine add = newTopline.add(wlLine, false);
add.setProperty("bl_occ_zt2_wlsource", "提前请购单");
System.out.println(add);
newTopline.save();
}
}
}
window2.close();
newTopline.window().save();
}
changePrivilege(session, find);
}
window.close();
comp.setVisible(false);
return true;
}
private static void changePrivilege(TCSession session, TCComponent dataset) throws Exception {
KUtil.setByPass(true);
TCAccessControlService accessControlService = session.getTCAccessControlService();
TCComponentUser user = session.getUser();
accessControlService.grantPrivilege(dataset, user, new String[]{"WRITE","READ"});
// KUtil.setByPass(false);
}
@SuppressWarnings("deprecation")
private void updateKjBom(Map<String, TCComponentItem> findMap, Map<String, ExpandPSData[]> bomLineTreeNodeSOA, String uid) throws Exception {
// Auto-generated method stub
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(uid);
for(ExpandPSData expandPSData : expandPSDatas) {
TCComponentBOMLine bomLine = expandPSData.bomLine;
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
String itemId = itemRevOfBOMLine.getProperty("item_id");
System.out.println("itemId===>" + itemId.toString());
String xid = itemId;
if(itemId.contains("-XXX")) {
xid = itemId.substring(0, itemId.indexOf("-XXX") + 4);
}
System.out.println("itemId===>" + itemId.toString() + "==" + xid);
if(findMap.containsKey(itemId)) {
TCComponentItem tcItem = findMap.get(itemId);
System.out.println("tcItem===>" + tcItem.toString());
TCComponentItemRevision lastRev = tcItem.getLatestItemRevision();
bomLine.replace(tcItem, lastRev, null);
bomLine.save();
// bomLine.unlock();
}else if(findMap.containsKey(xid)) {//TODO lidy20240914 TC中已有对象直接使用且不修改子级
TCComponentItem tcItem = findMap.get(xid);
TCComponentItem item = bomLine.getItem();
TCComponentItemRevision lastRev = tcItem.getLatestItemRevision();
bomLine.replace(tcItem, lastRev, null);
bomLine.save();
// bomLine.unlock();
if(!xid.equals(itemId)) {
System.out.println("delete===>" + item);
item.delete();
}
}else
updateKjBom(findMap, bomLineTreeNodeSOA, bomLine.getUid());//ExpandPSData[] expandPSDatas2 = bomLineTreeNodeSOA.get(bomLine.getUid());
}
}
@SuppressWarnings("deprecation")
private static void changeOwners(TCComponentItem item, TCComponentUser user) throws Exception {
TCComponent[] revs = item.getRelatedComponents("revision_list");
TCComponentItemRevision rev;
TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group");
TCComponent bom = null;
TCComponent[] datasets;
for (int i = 0, len = revs.length; i < len; i++) {
rev = (TCComponentItemRevision) revs[i];
bom = rev.getRelatedComponent("structure_revisions");
datasets = rev.getRelatedComponents("IMAN_specification");
for (int m = 0, len2 = datasets.length; m < len2; m++) {
datasets[m].lock();
datasets[m].changeOwner(user, group);
datasets[m].save();
datasets[m].unlock();
}
if (bom != null) {
bom.lock();
bom.changeOwner(user, group);
bom.save();
bom.unlock();
}
rev.lock();
rev.changeOwner(user, group);
rev.save();
rev.unlock();
}
bom = item.getRelatedComponent("bom_view_tags");
if (bom != null) {
bom.lock();
bom.changeOwner(user, group);
bom.save();
bom.unlock();
}
item.lock();
item.changeOwner(user, group);
item.save();
item.unlock();
}
private void sendToClass(String wsoPUID, String classID, String json) {
// AbstractAIFApplication app;
// app=AIFUtility.getCurrentApplication();
// TCSession session;
// session=(TCSession) app.getSession();
try {
TCPreferenceService preferenceService = session.getPreferenceService();
// String account=preferenceService.getStringValue("Autocode_PriverUser_ID");
String url = preferenceService.getStringValue("Autocode_SendClassServer_URL");
ServiceClient sc = new ServiceClient();
Options opts = new Options();
// url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";
EndpointReference end = new EndpointReference(url);
opts.setTo(end);
opts.setAction("SendToClass");
sc.setOptions(opts);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", "");
OMElement method = fac.createOMElement("SendToClass", omNs);
OMElement value = fac.createOMElement("wsoPuiid", omNs);
value.setText(wsoPUID);
OMElement value1 = fac.createOMElement("classID", omNs);
value1.setText(classID);
OMElement value2 = fac.createOMElement("JsonContainer", omNs);
// "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]"
value2.setText(json);
method.addChild(value);
method.addChild(value1);
method.addChild(value2);
OMElement res = sc.sendReceive(method);
res.getFirstElement().getText();
System.out.println(res.getFirstElement().getText());
} catch (Exception e) {
e.printStackTrace();
}
}
private void createId(TCComponentBOMLine pLine, Map<String, ExpandPSData[]> bomLineTreeNodeSOA,
StringBuilder builder, TCComponentItemType ccomponentitemtype,
Map<String, TCComponentItem> findMap, List<TCComponentBOMLine> useLines, int type) throws Exception {
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(pLine.getUid());
if(type != 0) {
copyLines.add(pLine);
}
for(ExpandPSData expandPSData : expandPSDatas) {
TCComponentBOMLine cLine = expandPSData.bomLine;
TCComponentItemRevision cRev = expandPSData.itemRevOfBOMLine;
if(cRev.getType().contains("ZT2_Design3D")) {
String item_id = cRev.getProperty("item_id");
String replaceAll = item_id.replaceAll(kjBs, projectDh);
/*if(type == 0) {
useLines.add(cLine);
oldkjIdMap.put(cRev, cLine.getItem());
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
}else {
}*/
TCComponentItem[] finds = ccomponentitemtype.findItems(replaceAll);
if(finds != null && finds.length > 0) {
builder.append("当前ID已经存在:").append(replaceAll).append("");
findMap.put(item_id, finds[0]);
// if(type != 0)
// useLines.add(cLine);
oldkjIdMap.put(cRev, finds[0]);
// createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
}else {
kjIdMap.put(cRev, replaceAll);
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
}
}else {
copyLines.add(cLine);
}
}
}
//批量复制
private void cloneOrUpdate(TCSession session, TCComponentBOMLine parentLine,
List<TCComponentBOMLine> bomLines, List<TCComponentBOMLine> useLines) {
com.teamcenter.services.rac.structuremanagement.StructureService service =
com.teamcenter.services.rac.structuremanagement.StructureService.getService(session);
// idMapAdd.clear();
CloneStructureInputInfo[] infos = new CloneStructureInputInfo[1];
infos[0] = new CloneStructureInputInfo();
// infos[0].bomline = puid;
infos[0].cadOptions = new String[] { "PartFamilyMaster" };
try {
infos[0].defaultFolder = session.getUser().getNewStuffFolder();
infos[0].cloneFlags = 2;
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo projectInfo
= new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo();
projectInfo.assign = false;
projectInfo.validate = false;
infos[0].projects = projectInfo;
TCComponentRevisionRule revisionRule = parentLine.window().getRevisionRule();
infos[0].revRule = revisionRule;
TCComponentItemRevision[] revs = new TCComponentItemRevision[] { parentLine.getItemRevision() };
infos[0].topItemRevs = revs;
System.out.println("cloneOrUpdate bomLine -- " + bomLines);
System.out.println("cloneOrUpdate useLines -- " + useLines);
List<CloneStructureSaveAsIn> saveList = new ArrayList<CloneStructureSaveAsIn>();
for(TCComponentBOMLine subLine : bomLines) {
TCComponentItem item = subLine.getItem();
CloneStructureSaveAsIn dataMap = null;
if(item.getType().equals("ZT2_Design3D")) {
// subLine.replace
dataMap = getDataMap(subLine, 0, session);
}else {
dataMap = getDataMap(subLine, 1, session);
}
saveList.add(dataMap);
}
for(TCComponentBOMLine subLine : useLines) {
CloneStructureSaveAsIn dataMap = getDataMap(subLine, 1, session);
saveList.add(dataMap);
}
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureDefaultNaming naming =
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureDefaultNaming();
CloneStructureSaveAsIn[] array = saveList.toArray(new CloneStructureSaveAsIn[saveList.size()]);
infos[0].dataMap = array;
naming.autogen = true;
infos[0].defaultName = naming;
infos[0].topLines = new TCComponentBOMLine[] { parentLine };
// TCComponentBOMLine.get
// puid.getr
} catch (Exception e1) {
// Auto-generated catch block
e1.printStackTrace();
}
CloneStructureResponse cloneStructure = service.cloneStructure(infos);
// infos[0].
// cloneStructureExpandOrUpdate.serviceData;
if (cloneStructure.serviceData.sizeOfPartialErrors() > 0) {
for (int i = 0; i < cloneStructure.serviceData.sizeOfPartialErrors(); i++) {
System.out.println("Save class Partial Error -- " + cloneStructure.serviceData
.getPartialError(i).getMessages()[0]);
}
}
try {
System.out.println("Save class Partial Error -- " + cloneStructure.serviceData.sizeOfUpdatedObjects());
if(cloneStructure.serviceData.sizeOfUpdatedObjects()>0) {
TCComponent updatedObject = cloneStructure.serviceData.getUpdatedObject(0);
System.out.println(session.componentToString(updatedObject) + " >> " + updatedObject);
}
// for(int i = 0; i < cloneStructure.serviceData.sizeOfCreatedObjects(); i++) {
// TCComponent plainObject = cloneStructure.serviceData.getCreatedObject(i);
// System.out.println(session.componentToString(plainObject));
// }
// for(int i = 0; i < cloneStructure.serviceData.sizeOfPlainObjects(); i++) {
// TCComponent plainObject = cloneStructure.serviceData.getPlainObject(i);
// System.out.println(session.componentToString(plainObject));
// }
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
private CloneStructureSaveAsIn getDataMap(TCComponentBOMLine child, int type, TCSession session) throws Exception {
TCComponentItemRevision rev = child.getItemRevision();
CloneStructureSaveAsIn dataMap = new CloneStructureSaveAsIn();
Map<String, String[]> newItemRevinfo = new HashMap<>();
dataMap.cloneOperationType = type;
// dataMap.newItemRevinfo =
dataMap.origItemRevComp = rev;
newItemRevinfo.put("sequence_limit", new String[] { "3" });
newItemRevinfo.put("fnd0CheckoutOnSaveAs", new String[] { "false" });
newItemRevinfo.put("item_revision_id", new String[] { "" });
newItemRevinfo.put("sequence_id", new String[] { "1" });
newItemRevinfo.put("object_name", new String[] { rev.getStringProperty("object_name") });
if(type == 0) {
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData[] copys =
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData[1];
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData copy =
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData();
copy.attachedObject = rev.getItem();
copy.copyAction = "CopyAsObject";
copy.copyRelations = true;
copy.isRequired = true;
copy.isTargetPrimary = true;
copy.operationInputTypeName = "";
copy.propertyName = "items_tag";
copy.propertyType = "Reference";
Map<String, String[]> operationInputs = new HashMap<>();
operationInputs.put("fnd0CheckoutOnSaveAs", new String[] { "false" });
operationInputs.put("is_configuration_item", new String[] { "false" });
String zt2Unit = rev.getItem().getTCProperty("zt2_unit").getStringValue();
// rev.getItem().get("zt2_unit");
operationInputs.put("zt2_unit", new String[] { zt2Unit });
String newId = "";
try {
newId = kjIdMap.get(rev);
// newId
}catch(Exception e) {
e.printStackTrace();
}
operationInputs.put("item_id", new String[] { newId }); // 获取规则
copy.operationInputs = operationInputs;
copys[0] = copy;
dataMap.deepCopyDataOverride = copys;
}
dataMap.newItemRevinfo = newItemRevinfo;
return dataMap;
}
/**
* BOMBOMBOMBOMBOM
*
* @param parent
* @param target
* @return BOMtrue
* @throws Exception
*/
private boolean checkSource(TCComponentBOMLine parent, TCComponentBOMLine target) throws Exception {
String id = target.getProperty("bl_item_item_id");
for(AIFComponentContext c : parent.getChildren()) {
TCComponentBOMLine child = (TCComponentBOMLine) c.getComponent();
if(child.getProperty("bl_item_item_id").equals(id) && child.getProperty("bl_occ_zt2_wlsource").equals("提前请购单"))
return true;
}
return false;
}
private List<TCComponentItemRevision> getByqCCPFromProject(TCComponent targetComp, TCSession session) throws Exception {
List<TCComponentItemRevision> ccpRevList = new ArrayList<TCComponentItemRevision>();
TCComponent[] refs = targetComp.getRelatedComponents("IMAN_reference");
int len = refs == null ? 0 : refs.length;
TCComponentFolder projStart = null;
System.out.println("查找项目启动文件夹:" + targetComp);
for (int i = 0; i < len; i++) {
String cName = refs[i].getProperty("object_name");
System.out.println(">> 找到子对象:" + cName);
if ((refs[i] instanceof TCComponentFolder) && cName.contains("项目启动")) {
projStart = (TCComponentFolder) refs[i];
break;
}
}
if (projStart == null) {
return null;
}
TCComponentFolder ccpFolder = null;
AIFComponentContext[] cFolders = projStart.getChildren();
len = cFolders == null ? 0 : cFolders.length;
for (int i = 0; i < len; i++) {
InterfaceAIFComponent c = cFolders[i].getComponent();
String cName = c.getProperty("object_name");
if ((c instanceof TCComponentFolder) && cName.contains("产成品")) {
ccpFolder = (TCComponentFolder) c;
break;
}
}
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_NO_KJTOPROD_M060", session);
AIFComponentContext[] ccpContexts = ccpFolder.getChildren();
for(AIFComponentContext context:ccpContexts) {
InterfaceAIFComponent component = context.getComponent();
String property = component.getProperty("object_name");
if(property.contains("变压器")) {
boolean flag = false;
for(String preference:preferences) {
if(property.contains(preference)) {
flag = true;
break;
}
}
if(component instanceof TCComponentItem && !flag) {
TCComponentItemRevision latestItemRevision = ((TCComponentItem)component).getLatestItemRevision();
ccpRevList.add(latestItemRevision);
}
}
}
return ccpRevList;
}
private List<TCComponentBOMLine> listBoms(TCComponentBOMLine bomLine) {
// List<String> bomLineNodes = list;
// 预定义BOM父子对map及ItemRev map
List<TCComponentBOMLine> listBoms = new ArrayList<>();
try {
// TCComponentItemRevision object = bomLine.getItemRevision();
// String object_type = object.getType();
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService
.getService(RACUIUtil.getTCSession());
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref();
levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; // 输入顶层BOMLine对象
levelInfo.excludeFilter = "None";
levelPref.expItemRev = false;
levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0];
// 使用以下方法展开完整的BOM行
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService
.expandPSAllLevels(levelInfo, levelPref);
if (levelResp.output.length > 0) {
// 将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) {
TCComponentBOMLine parentBomLine = (TCComponentBOMLine) data.parent.bomLine;
listBoms.add(parentBomLine);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return listBoms;
}
}

@ -3,9 +3,7 @@ package com.connor.chint.sap2.downloadFiles;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
@ -25,7 +23,6 @@ import com.teamcenter.rac.kernel.TCComponentTask;
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;
/**
*
@ -40,15 +37,15 @@ public class DownloadFilesController {
/* 选中的版本对象 */
private List<TCComponentItemRevision> selects = new ArrayList<>();
/* 选中的数据集对象 */
private List<TCComponentDataset> datasets = new ArrayList<>();
private List<TCComponentFolder> folders = new ArrayList<>();
private List<TCComponentDataset> datasets = new ArrayList();
private List<TCComponentFolder> folders = new ArrayList();
/* 生产信息传递通知单/更改通知单 */
private List<TCComponent> changes = new ArrayList<>();
protected StringBuffer errBuff = new StringBuffer();
private DownloadFileDialog dialog;
public DownloadFilesController(AbstractAIFApplication app, DownloadFileDialog dialog) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
this.dialog = dialog;
@ -161,7 +158,7 @@ public class DownloadFilesController {
file.mkdirs();
List<TCComponentItemRevision> isDownloads = new ArrayList<>();
for (int i = 0; i < selects.size(); i++) {
// TCComponentItemRevision rev = selects.get(i);
TCComponentItemRevision rev = selects.get(i);
TCComponentBOMLine bomline = SAPUtil.getNewBOMLine(selects.get(i), session);
downFiles(bomline, 0, pdf_path, jt_path, isDownloads, isDownloadBOM, isDdownloadDiagram);
}
@ -213,7 +210,7 @@ public class DownloadFilesController {
MessageBox.post(buff.toString(), "", MessageBox.INFORMATION);
}
public void download(String path, TCSession session, MyProgressBarCompent my) throws Exception {//TODO download
public void download(String path, TCSession session, MyProgressBarCompent my) throws Exception {
// File file = new File(path);
// TCComponentItemRevision tcComponentItemRevision = selects.get(0);
// String name = tcComponentItemRevision.getStringProperty("object_name");
@ -243,7 +240,7 @@ public class DownloadFilesController {
CAD_path = path;
catia_path = path;
}
List<String> list_paths = new ArrayList<>();
List<String> list_paths = new ArrayList();
list_paths.add(pdf_path);
list_paths.add(jt_path);
list_paths.add(excel_path);
@ -263,7 +260,6 @@ public class DownloadFilesController {
if (!file.exists() && !file.isDirectory())
file.mkdirs();
}
// System.out.println("download:1");
/**
* list_paths 0:PDF 1:JT 2:excel 3:word 4:CAD
* 5:
@ -276,24 +272,19 @@ public class DownloadFilesController {
TCComponentItemRevision rev;
for (int i = 0, len = selects.size(); i < len; i++) {
rev = selects.get(i);
// System.out.println("getFiles:" + rev);
getFiles(rev, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
if (flag_downloadBOM) {
System.out.println("ÕýÔÚÕ¹¿ªBOM...");
win = win == null ? bomWinType.create(null) : win;
// win.lock();
win.setWindowTopLine(rev.getItem(), rev, null, null);
topLine = win.getTopBOMLine();
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine);
System.out.println("downFiles:" + topLine);
downFiles(topLine, bomLineTree, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
downFiles(topLine, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
// win.unlock();
if (i == len - 1) {
win.close();
}
}
}
// System.out.println("download:2");
String object_type;
for (int i = 0; i < datasets.size(); i++) {
@ -314,7 +305,6 @@ public class DownloadFilesController {
break;
}
}
// System.out.println("download:3");
StringBuffer buff = new StringBuffer();
buff.append("下载成功,文件保存路径:\n");
@ -326,7 +316,6 @@ public class DownloadFilesController {
buff.append(" " + folder_path + "\n");
}
}
// System.out.println("download:4");
for (int i = 0; i < changes.size(); i++) {
TCComponent[] comps = changes.get(i).getRelatedComponents("IMAN_reference");
for (TCComponent comp : comps) {
@ -338,13 +327,11 @@ public class DownloadFilesController {
}
}
}
// System.out.println("download:5");
// 删除空文件夹
for (int i = 0, len = list_paths.size(); i < len; i++) {
deleteFolder(list_paths.get(i));
}
// System.out.println("download:6");
String temp_path;
for (int i = 0, len = list_paths.size(); i < len; i++) {
@ -353,9 +340,7 @@ public class DownloadFilesController {
buff.append(" " + temp_path + "\n");
}
}
// System.out.println("download:7");
KUtil.closeMyProgressBar(my);
my.dispose();
MessageBox.post(buff.toString(), "", MessageBox.INFORMATION);
}
@ -380,7 +365,7 @@ public class DownloadFilesController {
String[] types = type.split(",");
for (int l = 0; l < types.length; l++) {
try {
dataset.getFiles(types[l], path);
File[] files = dataset.getFiles(types[l], path);
} catch (Exception e) {
e.printStackTrace();
}
@ -413,27 +398,24 @@ public class DownloadFilesController {
*
* @throws Exception
*/
private void downFiles(TCComponentBOMLine line, Map<String, ExpandPSData[]> bomLineTree, List<TCComponentItemRevision> isDownloads,
private void downFiles(TCComponentBOMLine line, List<TCComponentItemRevision> isDownloads,
boolean flag_downloadDiagram, boolean flag_CAD, boolean flag_CATIA, boolean flag_PDF,
List<String> list_paths,boolean flag_doc) throws Exception {
// AIFComponentContext[] contexts = line.getChildren();
System.out.println("downFiles parent:" + line);
if(!bomLineTree.containsKey(line.getUid()))
return;
for (ExpandPSData data : bomLineTree.get(line.getUid())) {
TCComponentBOMLine child = data.bomLine;
// System.out.println("downFiles child:" + child);
TCComponentItemRevision rev = child.getItemRevision();
AIFComponentContext[] contexts = line.getChildren();
TCComponentBOMLine child;
TCComponentItemRevision rev;
for (int i = 0, len = contexts.length; i < len; i++) {
child = (TCComponentBOMLine) contexts[i].getComponent();
rev = child.getItemRevision();
checkChindren(rev, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
getFiles(rev, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
downFiles(child, bomLineTree, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
downFiles(child, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF, list_paths,flag_doc);
}
}
// 若子项为物料则下载物料关联的最新版图纸对象如果这个图纸对象也包含BOM的话BOM中的图纸也要下载
@SuppressWarnings("deprecation")
public void checkChindren(TCComponentItemRevision rev, List<TCComponentItemRevision> isDownloads, String pdf_Path,
String jt_Path, boolean isDownloadBOM, boolean isDdownloadDiagram) throws Exception {
// TC_Is_Represented_By
@ -451,7 +433,7 @@ public class DownloadFilesController {
downFiles(componentbomline, 0, pdf_Path, jt_Path, isDownloads, isDownloadBOM, isDdownloadDiagram);
win.refresh();
win.close();
} catch (Exception e) {
} catch (TCException e) {
e.printStackTrace();
}
@ -460,7 +442,6 @@ public class DownloadFilesController {
}
// 若子项为物料则下载物料关联的最新版图纸对象如果这个图纸对象也包含BOM的话BOM中的图纸也要下载
@SuppressWarnings("deprecation")
public void checkChindren(TCComponentItemRevision rev, List<TCComponentItemRevision> isDownloads,
boolean flag_downloadDiagram, boolean flag_CAD, boolean flag_CATIA, boolean flag_PDF,
List<String> list_paths, boolean flag_doc) throws Exception {
@ -476,8 +457,7 @@ public class DownloadFilesController {
win.lock();
win.setWindowTopLine(design_rev.getItem(), design_rev, null, null);
TCComponentBOMLine componentbomline = win.getTopBOMLine();
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(componentbomline);
downFiles(componentbomline, bomLineTree, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF,
downFiles(componentbomline, isDownloads, flag_downloadDiagram, flag_CAD, flag_CATIA, flag_PDF,
list_paths,flag_doc);
win.refresh();
win.close();
@ -519,7 +499,6 @@ public class DownloadFilesController {
if (datasets[j] instanceof TCComponentDataset) {
dataset = (TCComponentDataset) datasets[j];
type = dataset.getType();
System.out.println("getFiles:" + rev + ">>" + dataset);
switch (type) {
case "MSExcel":
if (flag_doc) {
@ -619,7 +598,7 @@ public class DownloadFilesController {
TCComponent[] comps1 = rev.getRelatedComponents("IMAN_Rendering");
TCComponent[] comps2 = rev.getRelatedComponents("IMAN_specification");
// String object_name = rev.getProperty("object_name");
String object_name = rev.getProperty("object_name");
String m_path = else_Path;
/*
* File d_file = new File(m_path); if( !d_file.exists() &&
@ -638,8 +617,7 @@ public class DownloadFilesController {
String[] types = type.split(",");
for (int l = 0; l < types.length; l++) {
try {
System.out.println("getFiles2:" + rev + ">>" + dataset);
dataset.getFiles(types[l], m_path);
File[] files = dataset.getFiles(types[l], m_path);
} catch (Exception e) {
e.printStackTrace();
}
@ -649,14 +627,13 @@ public class DownloadFilesController {
for (int i = 0; i < comps1.length; i++) {
if (comps1[i] instanceof TCComponentDataset) {
TCComponentDataset dataset = (TCComponentDataset) comps1[i];
// String d_type = dataset.getType();
String d_type = dataset.getType();
m_path = else_Path;
String type = dataset.getProperty("ref_names");
String[] types = type.split(",");
for (int l = 0; l < types.length; l++) {
try {
System.out.println("getFiles2:" + rev + ">>" + dataset);
dataset.getFiles(types[l], m_path);
File[] files = dataset.getFiles(types[l], m_path);
} catch (Exception e) {
// e.printStackTrace();
}
@ -670,14 +647,12 @@ public class DownloadFilesController {
*
*/
private void dataserDownload(TCComponentDataset dataset, String path) throws Exception {
System.out.println("dataserDownload:" + dataset);
// String d_type = dataset.getType();
String d_type = dataset.getType();
String type = dataset.getProperty("ref_names");
String[] types = type.split(",");
for (int l = 0; l < types.length; l++) {
try {
System.out.println("dataserDownload:" + dataset);
dataset.getFiles(types[l], path);
File[] files = dataset.getFiles(types[l], path);
} catch (Exception e) {
}

@ -3,7 +3,7 @@ package com.connor.chint.sap2.dy.createBOMDifference;
public class BOMCompareBean {
private int index;
private String changeType; // 更改类别
private String zt2_MaterialNo_Parent; // 父件物料编码(削层后)
private String zt2_MaterialNo_Parent; // 父件物料编码
private String object_desc_Parent; // 父件物料描述
private String zt2_MaterialNo_Old; // 旧物料编码
private String object_desc_Old; // 旧物料描述
@ -11,7 +11,6 @@ public class BOMCompareBean {
private String zt2_MaterialNo_new; // 新物料编码
private String object_desc_new; // 新物料描述
private String num_new; // 新物料数量
private String parent; // 父件物料编码
public int getIndex() {
return index;
@ -61,14 +60,6 @@ public class BOMCompareBean {
this.num_Old = num_Old;
}
public void addNum_Old(String num) {
if(!num_Old.isEmpty() && !num.isEmpty())
this.num_Old = String.format("%.3f", Double.parseDouble(num_Old) + Double.parseDouble(num));
else if(num_Old.isEmpty() && !num.isEmpty()) {
this.num_Old = num;
}
}
public String getZt2_MaterialNo_new() {
return zt2_MaterialNo_new;
}
@ -85,22 +76,14 @@ public class BOMCompareBean {
this.object_desc_new = object_desc_new;
}
public String getNum_New() {
public String getNum_new() {
return num_new;
}
public void setNum_New(String num_new) {
public void setNum_new(String num_new) {
this.num_new = num_new;
}
public void addNum_New(String num) {
if(!num_new.isEmpty() && !num.isEmpty())
this.num_new = String.format("%.3f", Double.parseDouble(num_new) + Double.parseDouble(num));
else if(num_new.isEmpty() && !num.isEmpty()) {
this.num_new = num;
}
}
public String getChangeType() {
return changeType;
}
@ -109,14 +92,6 @@ public class BOMCompareBean {
this.changeType = changeType;
}
// public String getParent() {
// return parent;
// }
public void setParent(String parent) {
this.parent = parent;
}
public BOMCompareBean(String changeType, String zt2_MaterialNo_Parent, String object_desc_Parent,
String zt2_MaterialNo_Old, String object_desc_Old, String num_Old, String zt2_MaterialNo_new,
String object_desc_new, String num_new) {
@ -138,7 +113,7 @@ public class BOMCompareBean {
+ zt2_MaterialNo_Parent + ", object_desc_Parent=" + object_desc_Parent + ", zt2_MaterialNo_Old="
+ zt2_MaterialNo_Old + ", object_desc_Old=" + object_desc_Old + ", num_Old=" + num_Old
+ ", zt2_MaterialNo_new=" + zt2_MaterialNo_new + ", object_desc_new=" + object_desc_new + ", num_new="
+ num_new + ", parent=" + parent + "]";
+ num_new + "]";
}
public Object[] getRowData(int index) {
@ -148,21 +123,4 @@ public class BOMCompareBean {
object_desc_Old, num_Old, zt2_MaterialNo_new, object_desc_new, num_new, "", "", "" };
}
public String getMaterial() {
String material = "";
if(zt2_MaterialNo_Old != null && !zt2_MaterialNo_Old.isEmpty())
material = zt2_MaterialNo_Old;
else if(zt2_MaterialNo_new != null && !zt2_MaterialNo_new.isEmpty())
material = zt2_MaterialNo_new;
return material;
}
public String getId() {
return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + getMaterial();
}
public String getParentId() {
return (parent == null ? "" : parent) + "@" + getMaterial();
}
}

@ -133,20 +133,5 @@ public class BOMDifCellEditor extends AbstractCellEditor implements TableCellEdi
return null;
}
/**
*
* @param index
* @param add truefalse
*/
public void changeRow(int index, boolean add) {
if(add) {
JComboBox<String> jcom = new JComboBox<String>();
JTextField jtf = new JTextField();
jcom_subclass.add(index, jcom);
jtf_subclass.add(index, jtf);
}else {
jcom_subclass.remove(index);
jtf_subclass.remove(index);
}
}
}

@ -11,37 +11,37 @@ public class BOMDifferenceBean {
/**
*
*/
private TCComponentItemRevision oldRev;
public TCComponentItemRevision oldRev;
/**
*
*/
private TCComponentItemRevision newRev;
public TCComponentItemRevision newRev;
/**
*
*/
private TCComponentItemRevision oldPartRev;
public TCComponentItemRevision oldPartRev;
/**
*
*/
private TCComponentItemRevision newPartRev;
public TCComponentItemRevision newPartRev;
/**
*
*/
private TCComponentItemRevision parentPartRev;
public TCComponentItemRevision parentPartRev;
/**
*
*/
private String zt2_MaterialNo_Parent;
public String zt2_MaterialNo_Parent;
/**
*
*/
private String object_desc_Parent;
public String object_desc_Parent;
/**
*
*/
private String object_name_Parent;
public String object_name_Parent;
public String getObject_name_Parent() {
return object_name_Parent;
@ -54,25 +54,21 @@ public class BOMDifferenceBean {
/**
*
*/
private TCComponentItem item;
public TCComponentItem item;
/**
* BOMLine
*/
private TCComponentBOMLine oldBOMLine;
TCComponentBOMLine oldBOMLine;
/**
* BOMLine
*/
private TCComponentBOMLine newBOMLine;
TCComponentBOMLine newBOMLine;
/**
*
*/
private String rev_object_type;
private TCComponentItemRevision rev;
/**
* ÊÇ·ñ¿ò¼Ü²ã
*/
private boolean isKj;
public TCComponentItem getItem() {
return item;
@ -280,16 +276,4 @@ public class BOMDifferenceBean {
this.rev = rev;
}
public boolean isKj() {
return isKj;
}
public void setKj(boolean isKj) {
this.isKj = isKj;
}
public String getId() {
return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + (item == null ? "" : item);
}
}

@ -25,8 +25,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
@ -66,15 +64,13 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
private static final long serialVersionUID = 1190944518442503011L;
public static final String[] HEADER = { "序号", "更改类别", "父件物料编码", "父件物料描述", "旧物料编码", "旧物料描述", "旧物料数量", "新物料编码",
"新物料描述", "新物料数量", "原因大类", "原因小类", "处理类型", "差异来源" };
public static final int[] HEADERWIDTH = new int[] { 50, 80, 120, 220, 120, 180, 80, 120, 180, 80, 100, 100, 100, 80 };
"新物料描述", "新物料数量", "原因大类", "原因小类", "处理类型" };
public static final int[] HEADERWIDTH = new int[] { 50, 80, 120, 220, 120, 180, 80, 120, 180, 80, 100, 100, 100 };
private AbstractAIFApplication app;
private TCSession session;
private JButton btn_add = new JButton("增加行");
private JButton btn_del = new JButton("删除行");
private JButton btn_ok = new JButton("确定");
private JButton btn_cel = new JButton("取消");
private final JButton btn_ok = new JButton("确定");
private final JButton btn_cel = new JButton("取消");
private JTable t_part;
private DefaultTableModel tm_part;
@ -92,9 +88,8 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
private Map<String, String> map_class = new HashMap<>(8); // 大类
private Map<String, String> map_subclass = new HashMap<>(64); // 小类
private BOMDifCellEditor cellEditor;
// 多选编辑
private JPanel selectPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JPanel selectPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
private JComboBox<String> box_class = new JComboBox<String>();
private JComboBox<String> box_subClass = new JComboBox<String>();
private JComboBox<String> box_processType = new JComboBox<String>();
@ -109,11 +104,11 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
this.session = (TCSession) app.getSession();
}
private void initUI() throws Exception {
private void initUI() {
this.setTitle("BOM差异表");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1400, 600));
this.setMinimumSize(new Dimension(1300, 500));
this.setPreferredSize(new Dimension(1400, 400));
this.setMinimumSize(new Dimension(1300, 300));
this.add(BorderLayout.NORTH, getSelectPanel());
this.add(BorderLayout.CENTER, getTablePanel());
this.add(BorderLayout.SOUTH, getButtonPanel());
@ -271,6 +266,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
ccps = getAssembly(newRev);
CreateBOMDifferenceController.bomCompare(oldline, newLine, 1, 1, childRevs, codeRemark,
icsId, errBuff, compares, ccps, session);
}
}
@ -289,7 +285,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
return;
}
cellEditor = new BOMDifCellEditor(class_subclass, map_class, size);
BOMDifCellEditor cellEditor = new BOMDifCellEditor(class_subclass, map_class, size);
t_part.getColumnModel().getColumn(11).setCellEditor(cellEditor);
new Thread(new Runnable() {
@ -304,8 +300,6 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
for (int i = 0, len = compares.size(); i < len; i++) {
System.out.println(i + "--" + compares.get(i));
tm_part.addRow(compares.get(i).getRowData(i + 1));
//TODO
t_part.setValueAt("自动生成", i, 13);
}
pb.disposeDialog();
} catch (Exception e) {
@ -323,8 +317,8 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
if (pb != null) {
pb.disposeDialog();
}
e.printStackTrace();
MessageBox.post("界面初始化失败:" + e.getMessage(), "", 2);
e.printStackTrace();
disposeDialog();
} finally {
KUtil.setByPass(false);
@ -671,7 +665,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
}
}
private JPanel getTablePanel() throws Exception {
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
@ -683,11 +677,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
@Override
public boolean isCellEditable(int row, int column) {
// Auto-generated method stub
if (column == 13) {
return false;
} else if (column > 9) {
return true;
} else if(column != 0 && getValueAt(row, 13).equals("手工增加")) {
if (column > 9) {
return true;
}
return false;
@ -713,15 +703,17 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
// Auto-generated method stub
return o1.getValue().compareTo(o2.getValue());
}
});
for (int i = 0, len = list.size(); i < len; i++) {
jcm_reason.addItem(list.get(i).getKey());
box_class.addItem(list.get(i).getKey());
}
colModel.getColumn(10).setCellEditor(new DefaultCellEditor(jcm_reason));
t_part.getColumnModel().getColumn(10).setCellEditor(new DefaultCellEditor(jcm_reason));
t_part.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
int col = e.getColumn();
@ -735,13 +727,6 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
}
}
});
//TODO 更改类别列为下拉框
Object[] values = map_indexs.keySet().toArray();
JComboBox<String> changeType = new JComboBox<String>();
changeType.addItem("");
for(Object s : values)
changeType.addItem(s.toString());
colModel.getColumn(1).setCellEditor(new DefaultCellEditor(changeType));
System.out.println("processType:" + processType);
if (processType.size() > 0) {
@ -761,66 +746,6 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
box_processType.addItem(processType);
}
}
for(int i = 0; i < t_part.getColumnCount(); i++) {
if(i == 2 || i == 4 || i == 7) {
//输入父件物料编码、旧物料编码、新物料编码后,物料描述通过查询自动填写
TableCellEditor descEditor = new DefaultCellEditor(new JTextField());
descEditor.addCellEditorListener(new CellEditorListener() {
public void editingStopped(ChangeEvent e) {
// 编辑完成后的操作
try {
int row = t_part.getSelectedRow(), col = t_part.getSelectedColumn();
String val = "" + ((TableCellEditor)e.getSource()).getCellEditorValue();
System.out.println("编辑完成: " + row + "," + col + "==" + val);
HashMap<String, String> fields = new HashMap<>();
fields.put("materialno", val);
AIFComponentContext[] parts = KUtil.query(session, "chint_query_material", fields).toArray();
if(parts.length == 0)
return;
TCComponentItemRevision part = (TCComponentItemRevision) parts[0].getComponent();
t_part.setValueAt(part.getProperty("object_desc"), row, col + 1);
}catch(Exception e1) {
e1.printStackTrace();
MessageBox.post(CreateBOMDifferenceDialog.this, "错误:" + e1, "警告", MessageBox.ERROR);
}
}
public void editingCanceled(ChangeEvent e) {
// 编辑取消后的操作
System.out.println("编辑取消: " + t_part.getSelectedRow() + "," + t_part.getSelectedColumn() + "==" + ((TableCellEditor)e.getSource()).getCellEditorValue());
}
});
colModel.getColumn(i).setCellEditor(descEditor);
}else if(i == 6 || i == 9) {
TableCellEditor descEditor = new DefaultCellEditor(new JTextField());
descEditor.addCellEditorListener(new CellEditorListener() {
public void editingStopped(ChangeEvent e) {
// 编辑完成后的操作
int row = t_part.getSelectedRow(), col = t_part.getSelectedColumn();
DefaultCellEditor editor = (DefaultCellEditor)e.getSource();
try {
String val = "" + editor.getCellEditorValue();
System.out.println("编辑完成: " + row + "," + col + "==" + val);
Double.parseDouble("" + val);
if(val.contains("d") || val.contains("D")) {
MessageBox.post(CreateBOMDifferenceDialog.this, "物料数量填写不符合要求", "错误", MessageBox.ERROR);
// t_part.setValueAt(e.toString(), row, col);
}
} catch (NumberFormatException e1) {
MessageBox.post(CreateBOMDifferenceDialog.this, "物料数量填写不符合要求", "错误", MessageBox.ERROR);
// t_part.setValueAt(e.toString(), row, col);
// ((JTextField)editor.getComponent()).requestFocus();
}
}
public void editingCanceled(ChangeEvent e) {
// 编辑取消后的操作
System.out.println("编辑取消: " + t_part.getSelectedRow() + "," + t_part.getSelectedColumn() + "==" + ((TableCellEditor)e.getSource()).getCellEditorValue());
}
});
colModel.getColumn(i).setCellEditor(descEditor);
}else if(i != 1 && i != 10 && i != 11 && i != 12) {
colModel.getColumn(i).setCellEditor(new DefaultCellEditor(new JTextField()));
}
}
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);
@ -828,58 +753,18 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
}
private JPanel getButtonPanel() {
JPanel south = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new FlowLayout());
panel.add(btn_add);
panel.add(btn_del);
panel.add(btn_ok);
// for (int i = 0; i < 4; i++) {
// panel.add(new JLabel(" "));
// }
for (int i = 0; i < 4; i++) {
panel.add(new JLabel(" "));
}
panel.add(btn_cel);
south.add(BorderLayout.WEST, new JLabel("<html>物料数量变更:只能是当前物料数量由**减少到**<br>物料新增:当前物料数量由**增加了**个 <br>物料删除物料从BOM中全部移除</html>"));
south.add(BorderLayout.CENTER, panel);
return south;
return panel;
}
private void addListener() {
//TODO
btn_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] rows = t_part.getSelectedRows();
if(rows.length == 0) {
tm_part.addRow(new Object[] { 0, "", "", "", "", "", "", "", "", "", "", "", "", "手工增加" });
cellEditor.changeRow(t_part.getRowCount() - 1, true);
}else {
int row = rows[rows.length - 1] + 1;
tm_part.insertRow(row, new Object[] { 0, "", "", "", "", "", "", "", "", "", "", "", "", "手工增加" });
cellEditor.changeRow(row, true);
}
KUtil.refrashNo(t_part);
}
});
btn_del.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] rows = t_part.getSelectedRows();
if(rows.length == 0) {
MessageBox.post("请选择要删除的行", "", MessageBox.WARNING);
return;
}
for(int i = rows.length - 1; i >= 0; i--) {
if(!t_part.getValueAt(rows[i], 13).equals("手工增加"))
continue;
tm_part.removeRow(rows[i]);
cellEditor.changeRow(rows[i], false);
}
KUtil.refrashNo(t_part);
}
});
// t_part.getCellEditor()
btn_cel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
@ -888,6 +773,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
});
// 点击OK 则将界面显示数据写入zt2_BOMEC,并挂载到更改通知单对象下
btn_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@ -897,32 +783,6 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
KUtil.stopTableEditing(t_part);
// 组织数据
try {
//删除空行
int last = HEADER.length - 1;
for(int i = t_part.getRowCount() - 1; i >= 0; i--) {
if(t_part.getValueAt(i, last).equals("自动生成"))
continue;
try {
if(!KUtil.isEmpty(t_part.getValueAt(i, 4)))
Double.parseDouble("" + t_part.getValueAt(i, 6));
if(!KUtil.isEmpty(t_part.getValueAt(i, 7)))
Double.parseDouble("" + t_part.getValueAt(i, 9));
} catch (NumberFormatException e) {
throw new Exception("物料数量填写不符合要求");
}
boolean del = true;
for(int j = 1; j < last; j++) {
if(!KUtil.isEmpty(t_part.getValueAt(i, j))) {
del = false;
break;
}
}
if(del) {
tm_part.removeRow(i);
}
}
KUtil.refrashNo(t_part);
createBOMEC(t_part.getRowCount());
btn_ok.setEnabled(false);
MessageBox.post("BOM差异表生成成功", "", 2);
@ -931,11 +791,13 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
e.printStackTrace();
MessageBox.post("BOM差异表生成失败:" + e.getMessage(), "", 2);
}
}
}).start();
}
});
t_part.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (t_part.getSelectedRowCount() >= 2) {
@ -946,8 +808,10 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
}
});
box_class.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
TableCellEditor tableCellEditor = t_part.getCellEditor();
if (tableCellEditor != null) {
@ -965,6 +829,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
private void setSubClassBoxValue() {
if (selectClassItemString != "") {
field_subClass.setVisible(false);
box_subClass.setVisible(true);
box_subClass.removeAllItems();
@ -973,6 +838,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
for (String item : subClassMap.keySet()) {
box_subClass.addItem(item);
}
} else {
field_subClass.setVisible(true);
box_subClass.setVisible(false);
@ -991,6 +857,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
});
box_subClass.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
@ -1006,6 +873,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
setTableSubClassCellValue();
selectSubClassItemString = null;
}
}
private void setTableSubClassCellValue() {
@ -1016,8 +884,8 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
}
});
box_processType.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
@ -1033,6 +901,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
setTableSubClassCellValue();
selectProcessTypeItemString = null;
}
}
private void setTableSubClassCellValue() {
@ -1040,6 +909,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
for (int index : selectRowsIndex) {
t_part.setValueAt(selectProcessTypeItemString, index, 12);
}
}
});
@ -1061,7 +931,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
}
System.out.println("form uid:" + form.getUid());
List<String> list = new ArrayList<>(rowCout);
for (int i = 0; i < 14; i++) {
for (int i = 0; i < 13; i++) {
String[] values = KUtil.getColumnValues(rowCout, i, list, t_part).toArray(new String[rowCout]);
System.out.println("设置值:" + "zt2_property" + (i + 1) + ";" + Arrays.toString(values));
switch (i) {
@ -1098,6 +968,7 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
KUtil.setProperty(form, "zt2_property" + (i + 1), values);
// form.unlock();
}
// tar.unlock();
return form;
}
@ -1139,4 +1010,5 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
return revs;
}
}

@ -25,8 +25,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
@ -37,8 +35,10 @@ import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.create_proc.CreateProcBean;
import com.connor.chint.sap2.create_proc.CreateProcController;
import com.connor.chint.sap2.sap.YCLMaterialBean;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.POIUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
@ -56,6 +56,7 @@ import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
@ -67,26 +68,23 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
private static final long serialVersionUID = 1190944518442503011L;
public static final String[] HEADER = { "序号", "更改类别", "父件物料编码", "父件物料描述", "旧物料编码", "旧物料描述", "旧物料数量", "新物料编码",
"新物料描述", "新物料数量", "原因大类", "原因小类", "处理类型", "差异来源" };
public static final int[] HEADERWIDTH = new int[] { 50, 80, 120, 220, 120, 180, 80, 120, 180, 80, 100, 100, 100, 80 };
"新物料描述", "新物料数量", "原因大类", "原因小类", "处理类型" };
public static final int[] HEADERWIDTH = new int[] { 50, 80, 120, 220, 120, 180, 80, 120, 180, 80, 100, 100, 100 };
private AbstractAIFApplication app;
private TCSession session;
private JButton btn_add = new JButton("增加行");
private JButton btn_del = new JButton("删除行");
private final JButton btn_ok = new JButton("确定");
private final JButton btn_cel = new JButton("取消");
private JTable t_part;
private DefaultTableModel tm_part;
// private JComboBox<String> jcom_Subclass = null; //小类
private BOMDifCellEditor cellEditor;
private TCComponent tar = null;
// 差异集合
private List<BOMCompareBean> compares = new ArrayList<>();
private ProgressBar pb = null;
// private Map<String, String> map_material = new HashMap<>(6); // 原材料库
// private Map<String, TCComponentItemRevision> map_Materials = new HashMap<>();; // 原材料
private Map<String, TCComponentItemRevision> map_Materials = new HashMap<>();; // 原材料
private Map<String, String> processType = new HashMap<>(32); // 更改类别
private Map<String, String> map_indexs = new HashMap<>(8); // 序号
@ -95,7 +93,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
private Map<String, String> map_subclass = new HashMap<>(64); // 小类
// 多选编辑
private JPanel selectPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JPanel selectPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
private JComboBox<String> box_class = new JComboBox<String>();
private JComboBox<String> box_subClass = new JComboBox<String>();
private JComboBox<String> box_processType = new JComboBox<String>();
@ -113,8 +111,8 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
private void initUI() {
this.setTitle("BOM差异表");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1400, 600));
this.setMinimumSize(new Dimension(1300, 500));
this.setPreferredSize(new Dimension(1400, 400));
this.setMinimumSize(new Dimension(1300, 300));
this.add(BorderLayout.NORTH, getSelectPanel());
this.add(BorderLayout.CENTER, getTablePanel());
this.add(BorderLayout.SOUTH, getButtonPanel());
@ -182,7 +180,6 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
}
@SuppressWarnings("deprecation")
@Override
public void run() {
try {
@ -266,8 +263,8 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
// String groupID = "";
try {
groupID = SAPUtil.getGroupID(session);
} catch (Exception e1) {
// Auto-generated catch block
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String fa = "";
@ -330,7 +327,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
return;
}
cellEditor = new BOMDifCellEditor(class_subclass, map_class, size);
BOMDifCellEditor cellEditor = new BOMDifCellEditor(class_subclass, map_class, size);
t_part.getColumnModel().getColumn(11).setCellEditor(cellEditor);
new Thread(new Runnable() {
@ -345,8 +342,6 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
for (int i = 0, len = compares.size(); i < len; i++) {
System.out.println(i + "--" + compares.get(i));
tm_part.addRow(compares.get(i).getRowData(i + 1));
//TODO
t_part.setValueAt("自动生成", i, 13);
}
pb.disposeDialog();
} catch (Exception e) {
@ -547,7 +542,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
//
// @Override
// public int compare(BOMCoutBean o1, BOMCoutBean o2) {
// // Auto-generated method stub
// // TODO Auto-generated method stub
// return o1.getIndex_num() - o2.getIndex_num();
// }
// });
@ -723,12 +718,8 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
@Override
public boolean isCellEditable(int row, int column) {
// Auto-generated method stub
if (column == 13) {
return false;
} else if (column > 9) {
return true;
} else if(column != 0 && getValueAt(row, 13).equals("手工增加")) {
// TODO Auto-generated method stub
if (column > 9) {
return true;
}
return false;
@ -751,7 +742,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
Collections.sort(list, new Comparator<Entry<String, String>>() {
@Override
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
// Auto-generated method stub
// TODO Auto-generated method stub
return o1.getValue().compareTo(o2.getValue());
}
@ -761,7 +752,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
jcm_reason.addItem(list.get(i).getKey());
box_class.addItem(list.get(i).getKey());
}
colModel.getColumn(10).setCellEditor(new DefaultCellEditor(jcm_reason));
t_part.getColumnModel().getColumn(10).setCellEditor(new DefaultCellEditor(jcm_reason));
t_part.getModel().addTableModelListener(new TableModelListener() {
@ -778,13 +769,6 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
}
}
});
//TODO 更改类别列为下拉框
Object[] values = map_indexs.keySet().toArray();
JComboBox<String> changeType = new JComboBox<String>();
changeType.addItem("");
for(Object s : values)
changeType.addItem(s.toString());
colModel.getColumn(1).setCellEditor(new DefaultCellEditor(changeType));
System.out.println("processType:" + processType);
if (processType.size() > 0) {
@ -798,71 +782,12 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
}
Collections.sort(list2);
JComboBox<String> jcom_Type = new JComboBox<String>(list2.toArray(new String[size]));
colModel.getColumn(12).setCellEditor(new DefaultCellEditor(jcom_Type));
t_part.getColumnModel().getColumn(12).setCellEditor(new DefaultCellEditor(jcom_Type));
for (String processType : list2) {
box_processType.addItem(processType);
}
}
for(int i = 0; i < t_part.getColumnCount(); i++) {
if(i == 2 || i == 4 || i == 7) {
//输入父件物料编码、旧物料编码、新物料编码后,物料描述通过查询自动填写
TableCellEditor descEditor = new DefaultCellEditor(new JTextField());
descEditor.addCellEditorListener(new CellEditorListener() {
public void editingStopped(ChangeEvent e) {
// 编辑完成后的操作
try {
int row = t_part.getSelectedRow(), col = t_part.getSelectedColumn();
String val = "" + ((TableCellEditor)e.getSource()).getCellEditorValue();
System.out.println("编辑完成: " + row + "," + col + "==" + val);
HashMap<String, String> fields = new HashMap<>();
fields.put("materialno", val);
AIFComponentContext[] parts = KUtil.query(session, "chint_query_material", fields).toArray();
if(parts.length == 0)
return;
TCComponentItemRevision part = (TCComponentItemRevision) parts[0].getComponent();
t_part.setValueAt(part.getProperty("object_desc"), row, col + 1);
}catch(Exception e1) {
e1.printStackTrace();
MessageBox.post(CreateBOMDifferenceDialogzt.this, "错误:" + e1, "警告", MessageBox.ERROR);
}
}
public void editingCanceled(ChangeEvent e) {
// 编辑取消后的操作
System.out.println("编辑取消: " + t_part.getSelectedRow() + "," + t_part.getSelectedColumn() + "==" + ((TableCellEditor)e.getSource()).getCellEditorValue());
}
});
colModel.getColumn(i).setCellEditor(descEditor);
}else if(i == 6 || i == 9) {
TableCellEditor descEditor = new DefaultCellEditor(new JTextField());
descEditor.addCellEditorListener(new CellEditorListener() {
public void editingStopped(ChangeEvent e) {
// 编辑完成后的操作
int row = t_part.getSelectedRow(), col = t_part.getSelectedColumn();
TableCellEditor editor = ((TableCellEditor)e.getSource());
try {
String val = "" + editor.getCellEditorValue();
System.out.println("编辑完成: " + row + "," + col + "==" + val);
Double.parseDouble("" + val);
if(val.contains("d") || val.contains("D")) {
MessageBox.post(CreateBOMDifferenceDialogzt.this, "物料数量填写不符合要求", "错误", MessageBox.ERROR);
// t_part.setValueAt(e.toString(), row, col);
}
} catch (NumberFormatException e1) {
MessageBox.post(CreateBOMDifferenceDialogzt.this, "物料数量填写不符合要求", "错误", MessageBox.ERROR);
// t_part.setValueAt(e.toString(), row, col);
}
}
public void editingCanceled(ChangeEvent e) {
// 编辑取消后的操作
System.out.println("编辑取消: " + t_part.getSelectedRow() + "," + t_part.getSelectedColumn() + "==" + ((TableCellEditor)e.getSource()).getCellEditorValue());
}
});
colModel.getColumn(i).setCellEditor(descEditor);
}else if(i != 1 && i != 10 && i != 11 && i != 12) {
colModel.getColumn(i).setCellEditor(new DefaultCellEditor(new JTextField()));
}
}
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);
@ -870,64 +795,27 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
}
private JPanel getButtonPanel() {
JPanel south = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new FlowLayout());
panel.add(btn_add);
panel.add(btn_del);
panel.add(btn_ok);
// for (int i = 0; i < 4; i++) {
// panel.add(new JLabel(" "));
// }
for (int i = 0; i < 4; i++) {
panel.add(new JLabel(" "));
}
panel.add(btn_cel);
south.add(BorderLayout.WEST, new JLabel("<html>物料数量变更:只能是当前物料数量由**减少到**<br>物料新增:当前物料数量由**增加了**个 <br>物料删除物料从BOM中全部移除</html>"));
south.add(BorderLayout.CENTER, panel);
return south;
return panel;
}
private void addListener() {
//TODO
btn_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] rows = t_part.getSelectedRows();
if(rows.length == 0) {
tm_part.addRow(new Object[] { 0, "", "", "", "", "", "", "", "", "", "", "", "", "手工增加" });
cellEditor.changeRow(t_part.getRowCount() - 1, true);
}else {
int row = rows[rows.length - 1] + 1;
tm_part.insertRow(row, new Object[] { 0, "", "", "", "", "", "", "", "", "", "", "", "", "手工增加" });
cellEditor.changeRow(row, true);
}
KUtil.refrashNo(t_part);
}
});
btn_del.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] rows = t_part.getSelectedRows();
if(rows.length == 0) {
MessageBox.post("请选择要删除的行", "", MessageBox.WARNING);
return;
}
for(int i = rows.length - 1; i >= 0; i--) {
if(!t_part.getValueAt(rows[i], 13).equals("手工增加"))
continue;
tm_part.removeRow(rows[i]);
cellEditor.changeRow(rows[i], false);
}
KUtil.refrashNo(t_part);
}
});
btn_cel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
disposeDialog();
}
});
// 点击OK 则将界面显示数据写入zt2_BOMEC,并挂载到更改通知单对象下
btn_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@ -937,32 +825,6 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
KUtil.stopTableEditing(t_part);
// 组织数据
try {
//删除空行
int last = HEADER.length - 1;
for(int i = t_part.getRowCount() - 1; i >= 0; i--) {
if(t_part.getValueAt(i, last).equals("自动生成"))
continue;
try {
if(!KUtil.isEmpty(t_part.getValueAt(i, 4)))
Double.parseDouble("" + t_part.getValueAt(i, 6));
if(!KUtil.isEmpty(t_part.getValueAt(i, 7)))
Double.parseDouble("" + t_part.getValueAt(i, 9));
} catch (NumberFormatException e) {
throw new Exception("物料数量填写不符合要求");
}
boolean del = true;
for(int j = 1; j < last; j++) {
if(!KUtil.isEmpty(t_part.getValueAt(i, j))) {
del = false;
break;
}
}
if(del) {
tm_part.removeRow(i);
}
}
KUtil.refrashNo(t_part);
createBOMEC(t_part.getRowCount());
btn_ok.setEnabled(false);
MessageBox.post("BOM差异表生成成功", "", 2);
@ -971,11 +833,13 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
e.printStackTrace();
MessageBox.post("BOM差异表生成失败:" + e.getMessage(), "", 2);
}
}
}).start();
}
});
t_part.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (t_part.getSelectedRowCount() >= 2) {
@ -986,8 +850,10 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
}
});
box_class.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
TableCellEditor tableCellEditor = t_part.getCellEditor();
if (tableCellEditor != null) {
@ -1005,6 +871,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
private void setSubClassBoxValue() {
if (selectClassItemString != "") {
field_subClass.setVisible(false);
box_subClass.setVisible(true);
box_subClass.removeAllItems();
@ -1013,6 +880,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
for (String item : subClassMap.keySet()) {
box_subClass.addItem(item);
}
} else {
field_subClass.setVisible(true);
box_subClass.setVisible(false);
@ -1031,6 +899,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
});
box_subClass.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
@ -1046,6 +915,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
setTableSubClassCellValue();
selectSubClassItemString = null;
}
}
private void setTableSubClassCellValue() {
@ -1053,9 +923,11 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
for (int index : selectRowsIndex) {
t_part.setValueAt(selectSubClassItemString, index, 11);
}
}
});
box_processType.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
@ -1071,6 +943,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
setTableSubClassCellValue();
selectProcessTypeItemString = null;
}
}
private void setTableSubClassCellValue() {
@ -1078,11 +951,12 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
for (int index : selectRowsIndex) {
t_part.setValueAt(selectProcessTypeItemString, index, 12);
}
}
});
}
@SuppressWarnings("deprecation")
public TCComponentForm createBOMEC(int rowCout) throws Exception {
TCComponentForm form = null;
TCComponent[] comps = tar.getRelatedComponents("IMAN_reference");
@ -1099,7 +973,7 @@ public class CreateBOMDifferenceDialogzt extends AbstractAIFDialog {
}
System.out.println("form uid:" + form.getUid());
List<String> list = new ArrayList<>(rowCout);
for (int i = 0; i < HEADER.length; i++) {
for (int i = 0; i < 13; i++) {
String[] values = KUtil.getColumnValues(rowCout, i, list, t_part).toArray(new String[rowCout]);
System.out.println("设置值:" + "zt2_property" + (i + 1) + ";" + Arrays.toString(values));
switch (i) {

@ -1,23 +1,25 @@
package com.connor.chint.sap2.dy.createBOMDifference;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
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.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
/**
*
@ -26,271 +28,197 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData
*
*/
public class CreateBOMDifference_GKController {
private static HashMap<String, ArrayList<Object[]>> oldStBomMap;
private static HashMap<String, ArrayList<Object[]>> newStBomMap;
private static HashMap<String, Boolean> shitiMap;
private static HashMap<String, ExpandPSData[]> bomMap;
public static final String SQL_Process = "select nvl(a.rprimary_objectu,'-1') from PIMANRELATION a "
+ "left join PIMANTYPE b on a.rrelation_typeu=b.puid "
+ "left join PWORKSPACEOBJECT c on c.puid =a.rprimary_objectu "
+ "where a.rsecondary_objectu =? and b.ptype_name='IMAN_METarget' and c.pobject_type='MEProcessRevision' ";
@SuppressWarnings("deprecation")
public static void getRevMap(TCSession session, TCComponent[] oldComponents, TCComponent[] newComponents,
List<BOMCompareBean> beans) throws Exception {
List<BOMCompareBean> beans) throws TCException {
oldStBomMap = new HashMap<>();
newStBomMap = new HashMap<>();
shitiMap = new HashMap<>();
bomMap = new HashMap<>();
StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
// HashMap<TCComponentItem, BOMDifferenceBean> map_item_beans = new HashMap<>();
HashMap<String, BOMDifferenceBean> map_item_beans = new HashMap<>();
ArrayList<BOMDifferenceBean> kjBeans = new ArrayList<>();
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
throw new Exception("无法连接数据库,请检查首选项<database_tc>配置。");
}
Map<TCComponentItem, BOMDifferenceBean> map_item_beans = new HashMap<>();
for (TCComponent comp : oldComponents) {
TCComponentItemRevision rev = (TCComponentItemRevision) comp;
TCComponentItem item = rev.getItem();
String id = item.getProperty("item_id");
BOMDifferenceBean bean = map_item_beans.get(id);
BOMDifferenceBean bean = map_item_beans.get(item);
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
bean.setOldRev(rev);
if(rev.getProperty("zt2_DrawingNo").equals("高开框架BOM")) {
bean.setKj(true);
kjBeans.add(bean);
}else if(isShiti(rev)) {
bean.setKj(false);
kjBeans.add(bean);
}
}
map_item_beans.put(id, bean);
map_item_beans.put(item, bean);
}
for (TCComponent comp : newComponents) {
TCComponentItemRevision rev = (TCComponentItemRevision) comp;
TCComponentItem item = rev.getItem();
String id = item.getProperty("item_id");
BOMDifferenceBean bean = map_item_beans.get(id);
BOMDifferenceBean bean = map_item_beans.get(item);
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
bean.setNewRev(rev);
if(rev.getProperty("zt2_DrawingNo").equals("高开框架BOM")) {
bean.setKj(true);
kjBeans.add(bean);
}else if(isShiti(rev)) {
bean.setKj(false);
kjBeans.add(bean);
}
} else {
bean.setNewRev(rev);
}
map_item_beans.put(id, bean);
map_item_beans.put(item, bean);
}
if(kjBeans.size() == 0) {
throw new Exception("关系下未找到框架层对象");
}
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
// win.lock();
TCComponentBOMWindow win2 = bomWinType.create(null);
// win2.lock();
List<BOMCompareBean> compares;
List<TCComponentItem> items = new ArrayList<>();
List<TCComponentItem> item_compares = new ArrayList<>();
HashMap<TCComponentItem, BOMDifferenceBean> map_childs = new HashMap<>();
HashMap<String, List<BOMCompareBean>> map_compares = new HashMap<>();
// for (Entry<String, BOMDifferenceBean> entry : map_item_beans.entrySet()) {
// BOMDifferenceBean bean = entry.getValue();
for(BOMDifferenceBean kjBean : kjBeans) {
TCComponentItemRevision oldKjRev = kjBean.getOldRev(), newKjRev = kjBean.getNewRev();
if(kjBean.isKj() && (oldKjRev == null || newKjRev == null)) {
throw new Exception("更改前后关系下框架层对象不匹配");
try {
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
throw new Exception("无法连接数据库,请检查首选项<database_tc>配置。");
}
TCComponentBOMLine oldKjLine = win.setWindowTopLine(oldKjRev.getItem(), oldKjRev, null, null);
TCComponentBOMLine newKjLine = win2.setWindowTopLine(newKjRev.getItem(), newKjRev, null, null);
getBomLineTreeNodeSOA(oldKjRev, structureService, bomWinType);
getBomLineTreeNodeSOA(newKjRev, structureService, bomWinType);
oldStBomMap.clear();
newStBomMap.clear();
//TODO recycleBom
System.out.println("recycleBom------" + oldKjLine + ">>" + newKjLine);
recycleBom(oldKjRev.toString(), oldKjRev.toString(), true, bomWinType, map_item_beans, 1.0, structureService);
System.out.println("oldBomMap------" + printBomMap(oldStBomMap));
recycleBom(newKjRev.toString(), newKjRev.toString(), false, bomWinType, map_item_beans, 1.0, structureService);
System.out.println("newBomMap------" + printBomMap(newStBomMap));
TCComponentItem item = kjBean.getItem();
System.out.println("框架------" + item + " old:" + kjBean.getOldRev() + "; new:" + kjBean.getNewRev());
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
win.lock();
TCComponentBOMWindow win2 = bomWinType.create(null);
win2.lock();
List<BOMCompareBean> compares;
List<TCComponentItem> items = new ArrayList<>();
List<TCComponentItem> item_compares = new ArrayList<>();
Map<TCComponentItem, BOMDifferenceBean> map_childs = new HashMap<>();
Map<TCComponentItem, List<BOMCompareBean>> map_compares = new HashMap<>();
BOMDifferenceBean parentBean;
if (map_childs.containsKey(item)) {
parentBean = map_childs.get(item);
parentBean.setOldBOMLine(oldKjLine);
parentBean.setNewBOMLine(newKjLine);
parentBean.setOldRev(oldKjRev);
parentBean.setNewRev(newKjRev);
} else {
parentBean = new BOMDifferenceBean();
parentBean.setOldQuantity(1);
parentBean.setNewQuantity(1);
parentBean.setOldBOMLine(oldKjLine);
parentBean.setNewBOMLine(newKjLine);
parentBean.setOldRev(oldKjRev);
parentBean.setNewRev(newKjRev);
String zt2_MaterialNo = "";
String object_desc = "";
String object_name = "";
TCComponentItemRevision parentRev = null;
parentRev = SAPUtil.getSAPPart(parentBean.getNewBOMLine(), session);
if (parentRev != null) {
zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
object_desc = parentRev.getProperty("object_desc");
object_name = parentRev.getProperty("object_name");
for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_item_beans.entrySet()) {
BOMDifferenceBean bean = entry.getValue();
TCComponentItem item = entry.getKey();
System.out.println("遍历------" + item + " old:" + bean.getOldRev() + "; new:" + bean.getNewRev());
if (item_compares.indexOf(item) != -1) {
System.out.println("已读取,跳过");
continue;
}
System.out.println("未读取,遍历BOM---");
if (bean.getOldRev() != null && bean.getNewRev() != null) {
win.setWindowTopLine(entry.getKey(), bean.getOldRev(), null, null);
win2.setWindowTopLine(entry.getKey(), bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
BOMDifferenceBean parentBean;
if (map_childs.containsKey(item)) {
parentBean = map_childs.get(item);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
} else {
parentBean = new BOMDifferenceBean();
parentBean.setOldQuantity(1);
parentBean.setNewQuantity(1);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
String zt2_MaterialNo = "";
String object_desc = "";
String object_name = "";
TCComponentItemRevision parentRev = null;
parentRev = SAPUtil.getSAPPart(parentBean.getNewBOMLine(), session);
if (parentRev != null) {
zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
object_desc = parentRev.getProperty("object_desc");
object_name = parentRev.getProperty("object_name");
}
parentBean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
parentBean.setObject_desc_Parent(object_desc);
parentBean.setObject_name_Parent(object_name);
parentBean.setParentPartRev(parentRev);
}
System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, false, item_compares, map_item_beans, map_childs, 0);
map_compares.put(item, compares);
// map_childs.remove(item);
items.add(item);
}
parentBean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
parentBean.setObject_desc_Parent(object_desc);
parentBean.setObject_name_Parent(object_name);
parentBean.setParentPartRev(parentRev);
System.out.println("比较结束");
}
// System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, false, item_compares, map_item_beans, map_childs, 0);
map_compares.put(kjBean.getId(), compares);
// map_childs.remove(item);
items.add(item);
System.out.println("比较结束");
}
/*
List<TCComponentItem> keys = new ArrayList<>(map_childs.keySet());
BOMDifferenceBean bean2;
for (int i = 0, len = keys.size(); i < len; i++) {
TCComponentItem item = keys.get(i);
BOMDifferenceBean bean = map_childs.get(item);
bean2 = map_item_beans.get(item.getProperty("item_id"));
bean.setOldRev(bean2.getOldRev());
bean.setNewRev(bean2.getNewRev());
System.out.println("子项遍历------" + item + " old:" + bean.getOldRev() + "; new:" + bean.getNewRev());
if (bean.getOldRev() != null && bean.getNewRev() != null) {
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
BOMDifferenceBean parentBean = map_childs.get(item);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
System.out.println("子项--------" + parentBean);
System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, true, item_compares, map_item_beans, map_childs, 0);
map_compares.put(item, compares);
items.add(item);
List<TCComponentItem> keys = new ArrayList<>(map_childs.keySet());
BOMDifferenceBean bean2;
for (int i = 0, len = keys.size(); i < len; i++) {
TCComponentItem item = keys.get(i);
BOMDifferenceBean bean = map_childs.get(item);
bean2 = map_item_beans.get(item);
bean.setOldRev(bean2.getOldRev());
bean.setNewRev(bean2.getNewRev());
System.out.println("子项遍历------" + item + " old:" + bean.getOldRev() + "; new:" + bean.getNewRev());
if (bean.getOldRev() != null && bean.getNewRev() != null) {
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
BOMDifferenceBean parentBean = map_childs.get(item);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
System.out.println("子项--------" + parentBean);
System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, true, item_compares, map_item_beans, map_childs, 0);
map_compares.put(item, compares);
items.add(item);
}
System.out.println("比较结束");
}
System.out.println("比较结束");
}*/
System.out.println("读取变更----开始");
HashMap<String, Integer> idList = new HashMap<>();
ArrayList<String> parentList = new ArrayList<>();
for (String id : map_compares.keySet()) {
// String id = entry.getKey();
System.out.println("变更对象:" + id);
// if(!id.startsWith("@"))
// continue;
compares = map_compares.get(id);
if (compares != null) {
for (int i = 0, len = compares.size(); i < len; i++) {
BOMCompareBean compare = compares.get(i);
System.out.println(i + "-----" + compare);
String cid = compare.getId();
if(idList.containsKey(cid)) {
if(!parentList.contains(compare.getParentId())) {
BOMCompareBean bean = beans.get(idList.get(cid));
bean.addNum_Old(compare.getNum_Old());
bean.addNum_New(compare.getNum_New());
parentList.add(compare.getParentId());
}
continue;
System.out.println("读取变更----开始");
for (Entry<TCComponentItem, List<BOMCompareBean>> entry : map_compares.entrySet()) {
System.out.println("变更对象:" + entry.getKey());
compares = entry.getValue();
if (compares != null) {
for (int i = 0, len = compares.size(); i < len; i++) {
System.out.println(i + "-----" + compares.get(i));
}
parentList.add(compare.getParentId());
idList.put(cid, beans.size());
beans.add(compare);
beans.addAll(compares);
}
}
System.out.println("读取变更----结束");
win.unlock();
win.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
// for(int i = beans.size() - 1; i >= 0; i--) {
// BOMCompareBean bean = beans.get(i);
// if(bean.getNum_Old() != null && bean.getNum_New() != null) {
// if(bean.getNum_Old().equals(bean.getNum_New()))
// beans.remove(i);
// else if(!bean.getNum_Old().isEmpty() && !bean.getNum_New().isEmpty())
// bean.setChangeType("物料数量变更");
// }
// }
System.out.println("读取变更----结束");
win.unlock();
win.close();
// win2.unlock();
// win2.close();
}
/**
*
*
*
* @param revType
* @param rev
* @param con
* @throws SQLException
*/
public static boolean isShiti(TCComponentItemRevision rev) throws Exception {
public static boolean isVirtual(TCComponentItemRevision rev) throws SQLException {
/**
* ,
*/
String uid = rev.getUid();
if(shitiMap.containsKey(uid))
return shitiMap.get(uid);
ResultSet rs = SqlUtil.read(SQL_Process, new Object[] { uid });
// String puid = "";
ResultSet rs = SqlUtil.read(SQL_Process, new Object[] { rev.getUid() });
String puid = "";
if (rs.next()) {
// puid = rs.getString(1);
shitiMap.put(uid, true);
puid = rs.getString(1);
SqlUtil.free();
// System.out.println(puid + "-----实体图纸:" + rev);
System.out.println(puid + "-----实体图纸:" + rev);
return true;
}
// System.out.println(puid + "-----虚拟图纸:" + rev);
shitiMap.put(uid, false);
System.out.println(puid + "-----虚拟图纸:" + rev);
SqlUtil.free();
return false;
}
public static void bomCompare_M006(BOMDifferenceBean parentBean, TCSession session, double parent_quantity_old,
double parent_quantity_new, List<BOMCompareBean> beans, boolean isAddVis, boolean isRepeat,
List<TCComponentItem> item_compares, HashMap<String, BOMDifferenceBean> map_item_beans,
HashMap<TCComponentItem, BOMDifferenceBean> map_childs, int level) throws Exception {
List<TCComponentItem> item_compares, Map<TCComponentItem, BOMDifferenceBean> map_item_beans,
Map<TCComponentItem, BOMDifferenceBean> map_childs, int level) throws TCException, SQLException {
TCComponentItem patentItem = parentBean.getItem();
/*String id = patentItem.getProperty("item_id");
if (level > 0 && map_item_beans.containsKey(id)) {
System.out.println("包含父子项-------:" + id + "||" + parentBean);
if (level > 0 && map_item_beans.containsKey(parentBean.getItem())) {
System.out.println("包含父子项-------:" + parentBean.getItem() + "||" + parentBean);
BOMDifferenceBean bomDifferenceBean = map_item_beans.get(id);
BOMDifferenceBean bomDifferenceBean = map_item_beans.get(parentBean.getItem());
double oldQuantity = bomDifferenceBean.getOldQuantity();
double newQuantity = bomDifferenceBean.getNewQuantity();
System.out.println("已经存在?-------:" + newQuantity + "||" + oldQuantity);
@ -301,75 +229,60 @@ public class CreateBOMDifference_GKController {
bomDifferenceBean.setOldQuantity(parentBean.getOldQuantity()+oldQuantity);
bomDifferenceBean.setNewQuantity(parentBean.getNewQuantity()+newQuantity);
// }
map_item_beans.put(id, bomDifferenceBean);
map_item_beans.put(parentBean.getItem(), bomDifferenceBean);
map_childs.put(parentBean.getItem(), parentBean);
return;
}
*/
// if (item_compares.indexOf(parentBean.getItem()) != -1 && !isRepeat) {
// System.out.println("已添加过" + parentBean.getItem());
// return;
// }
System.out.println("未添加过:" + patentItem);
item_compares.add(patentItem);
// TCComponentBOMLine parentLine_old = parentBean.getOldBOMLine();
// TCComponentBOMLine parentLine_new = parentBean.getNewBOMLine();
TCComponentItemRevision parentLine_old = parentBean.getOldRev();
TCComponentItemRevision parentLine_new = parentBean.getNewRev();
System.out.println("未添加过:" + parentBean.getItem());
item_compares.add(parentBean.getItem());
TCComponentBOMLine parentLine_old = parentBean.getOldBOMLine();
TCComponentBOMLine parentLine_new = parentBean.getNewBOMLine();
System.out.println("比较:" + parentLine_old + "--" + parent_quantity_old + "||" + parentLine_new + "--"
+ parent_quantity_new);
BOMDifferenceBean bean;
HashMap<String, BOMDifferenceBean> map_child_beans = new HashMap<>();
Map<TCComponentItem, BOMDifferenceBean> map_child_beans = new HashMap<>();
TCComponentItemRevision oldPartRev = null;
TCComponentItemRevision newPartRev = null;
// 物料数量
// String bl_quantity;
String bl_quantity;
double quantity;
String rev_object_type;
if (parentLine_new != null) {
TCComponentItem item = null;
TCComponentItemRevision rev = null;
TCComponentBOMLine line;
// AIFComponentContext[] childs_new = parentLine_new.getChildren();
// for (int i = 0, len = childs_new.length; i < len; i++) {
String revS = parentLine_new.toString();
if(newStBomMap.containsKey(revS)) {
for(Object[] c : newStBomMap.get(revS)) {
// line = (TCComponentBOMLine) childs_new[i].getComponent();
line = (TCComponentBOMLine) c[0];
rev = (TCComponentItemRevision) c[1];
// bom = (TCComponentBOMLine) c[2];
item = rev.getItem();
String id = item.getProperty("item_id");
bean = map_child_beans.get(id);
newPartRev = SAPUtil.getSAPPart(line, session);
// System.out.println("newPartRev" + rev + "==" + line + ">>" + newPartRev);
if (newPartRev == null) {
continue;
}
// bl_quantity = line.getProperty("bl_quantity");
// if (bl_quantity == null || bl_quantity.trim().length() == 0) {
// bl_quantity = "1";
// }
// quantity = Double.parseDouble(bl_quantity) * parent_quantity_new;
quantity = (double) c[3];
// System.out.println(revS + "==>" + rev + "*" + quantity);
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
bean.setNewPartRev(newPartRev);
}
bean.setNewRev(rev);
// bean.setNewBOMLine(bom);
bean.addNewQuantity(quantity);
map_child_beans.put(id, bean);
AIFComponentContext[] childs_new = parentLine_new.getChildren();
for (int i = 0, len = childs_new.length; i < len; i++) {
line = (TCComponentBOMLine) childs_new[i].getComponent();
rev = line.getItemRevision();
item = rev.getItem();
bean = map_child_beans.get(item);
newPartRev = SAPUtil.getSAPPart(line, session);
if (newPartRev == null) {
continue;
}
}else {
System.out.println("newBomMap未添加过:" + revS);
bl_quantity = line.getProperty("bl_quantity");
if (bl_quantity == null || bl_quantity.trim().length() == 0) {
bl_quantity = "1";
}
quantity = Double.parseDouble(bl_quantity) * parent_quantity_new;
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
bean.setNewPartRev(newPartRev);
}
bean.setNewRev(rev);
bean.setNewBOMLine(line);
bean.addNewQuantity(quantity);
map_child_beans.put(item, bean);
}
}
@ -377,47 +290,34 @@ public class CreateBOMDifference_GKController {
TCComponentItem item = null;
TCComponentItemRevision rev = null;
TCComponentBOMLine line;
// ExpandPSData[] bom;
// AIFComponentContext[] childs_old = parentLine_old.getChildren();
// for (int i = 0, len = childs_old.length; i < len; i++) {
String revS = parentLine_old.toString();
if(oldStBomMap.containsKey(revS)) {
for(Object[] c : oldStBomMap.get(revS)) {
// line = (TCComponentBOMLine) childs_old[i].getComponent();
// rev = line.getItemRevision();
line = (TCComponentBOMLine) c[0];
rev = (TCComponentItemRevision) c[1];
// bom = (ExpandPSData[]) c[2];
item = rev.getItem();
String id = item.getProperty("item_id");
bean = map_child_beans.get(id);
oldPartRev = SAPUtil.getSAPPart(line, session);
// System.out.println("oldPartRev" + rev + "==" + line + ">>" + newPartRev);
if (oldPartRev == null) {
continue;
}
// bl_quantity = line.getProperty("bl_quantity");
// if (bl_quantity == null || bl_quantity.trim().length() == 0) {
// bl_quantity = "1";
// }
// quantity = Double.parseDouble(bl_quantity) * parent_quantity_old;
quantity = (double) c[3];
// System.out.println(revS + "==>" + rev + "*" + quantity);
AIFComponentContext[] childs_old = parentLine_old.getChildren();
for (int i = 0, len = childs_old.length; i < len; i++) {
line = (TCComponentBOMLine) childs_old[i].getComponent();
rev = line.getItemRevision();
item = rev.getItem();
bean = map_child_beans.get(item);
oldPartRev = SAPUtil.getSAPPart(line, session);
if (oldPartRev == null) {
continue;
}
bl_quantity = line.getProperty("bl_quantity");
if (bl_quantity == null || bl_quantity.trim().length() == 0) {
bl_quantity = "1";
}
quantity = Double.parseDouble(bl_quantity) * parent_quantity_old;
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
}
bean.setOldRev(rev);
// bean.setOldBOMLine(bom);
bean.setOldPartRev(oldPartRev);
bean.addOldQuantity(quantity);
map_child_beans.put(id, bean);
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
}
}else {
System.out.println("oldBomMap未添加过:" + revS);
bean.setOldRev(rev);
bean.setOldBOMLine(line);
bean.setOldPartRev(oldPartRev);
bean.addOldQuantity(quantity);
map_child_beans.put(item, bean);
}
}
@ -444,10 +344,8 @@ public class CreateBOMDifference_GKController {
object_desc_Parent = parentBean.getObject_name_Parent();
}
// for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_child_beans.entrySet()) {
// bean = entry.getValue();
for (String id : map_child_beans.keySet()) {
bean = map_child_beans.get(id);
for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_child_beans.entrySet()) {
bean = entry.getValue();
oldPartRev = bean.getOldPartRev();
newPartRev = bean.getNewPartRev();
System.out.println(bean.getItem() + " BOMDifferenceBean:" + bean);
@ -463,21 +361,19 @@ public class CreateBOMDifference_GKController {
// 物料删除 若变更项不为虚拟项则记录
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getOldRev().getProperty("zt2_Source");
// if (bean.getOldBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
if (bean.getOldBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
// 到此为止,不继续展开
compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_Old, num_Old, "", "", "");
beans.add(compareBean);
} else if ("自制".equals(zt2_Source)) {
// 实体层
if (isShiti(rev)) {
if (isVirtual(rev)) {
compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_Old, num_Old, "", "", "");
beans.add(compareBean);
//TODO 删除的实体件不显示子项删除
// bomCompare_M006(bean, session, 1, 1, beans, false, isRepeat, item_compares, map_item_beans,
// map_childs, level + 1);
bomCompare_M006(bean, session, 1, 1, beans, false, isRepeat, item_compares, map_item_beans,
map_childs, level + 1);
} else {
// 虚拟层
bean.setParentPartRev(oldPartRev);
@ -509,20 +405,18 @@ public class CreateBOMDifference_GKController {
System.out.println("**物料新增**:" + rev);
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getNewRev().getProperty("zt2_Source");
// if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "", "",
zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean);
System.out.println(bean.getItem() + "--新增--" + compareBean);
} else if ("自制".equals(zt2_Source)) {
if (isShiti(rev)) {
if (isVirtual(rev)) {
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "",
"", zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean);
//TODO 新增的实体件不显示子项新增
// bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
// map_item_beans, map_childs, level + 1);
bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
map_item_beans, map_childs, level + 1);
} else {
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Parent);
bean.setObject_desc_Parent(object_desc_Parent);
@ -573,24 +467,22 @@ public class CreateBOMDifference_GKController {
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getNewRev().getProperty("zt2_Source");
// if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (compareBean != null) {
System.out.println(bean.getItem() + "--数量变化新增(实)--" + compareBean);
beans.add(compareBean);
}
} else if ("自制".equals(zt2_Source)) {
// 实体层
if (isShiti(rev)) {
if (isVirtual(rev)) {
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New);
bean.setObject_desc_Parent(object_desc_New);
if (compareBean != null) {
System.out.println(bean.getItem() + "--数量变化新增(实)--" + compareBean);
beans.add(compareBean);
}
//TODO 实体件不显示子项数量变化
// bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
// map_item_beans, map_childs, level + 1);
bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
map_item_beans, map_childs, level + 1);
} else {
if (compareBean != null && isAddVis) {
@ -631,19 +523,18 @@ public class CreateBOMDifference_GKController {
System.out.println("物料变更");
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getNewRev().getProperty("zt2_Source");
// if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (compareBean != null) {
System.out.println(bean.getItem() + "--物料变更(实)--" + compareBean);
beans.add(compareBean);
}
} else if ("自制".equals(zt2_Source)) {
// 实体层
if (isShiti(rev)) {
if (isVirtual(rev)) {
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New);
bean.setObject_desc_Parent(object_desc_New);
// bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
// map_item_beans, map_childs, level + 1);
bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
map_item_beans, map_childs, level + 1);
} else {
// 虚拟层
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Parent);
@ -662,127 +553,5 @@ public class CreateBOMDifference_GKController {
}
}
}
/**
* BOMBOMMap
* @param parent BOM
* @param uid object_string//UID
* @param isOld or
* @param bomWinType BOM
* @param map_item_beans
* @param count
*/
private static void recycleBom(String parent, String uid, boolean isOld, TCComponentBOMWindowType bomWinType,
HashMap<String, BOMDifferenceBean> map_item_beans, Double count, StructureManagement structureService) throws Exception {
// if(isOld && oldBomMap.containsKey(uid) || !isOld && newBomMap.containsKey(uid))
// return;
// System.out.println("recycleBom:" + parent + "==" + parent.getChildren().length);
// for(AIFComponentContext c : parent.getChildren()) {
for(ExpandPSData data : bomMap.get(parent)) {
TCComponentBOMLine line = data.bomLine;//(TCComponentBOMLine) c.getComponent(), bom;
System.out.println("recycleBom:" + uid + "==" + parent + ">>" + line);
ExpandPSData[] bom = new ExpandPSData[0];
TCComponentItemRevision rev;
String id = data.itemRevOfBOMLine.getProperty("item_id");
if(map_item_beans.containsKey(id)) {
//由于BOM可能为非精确因此变更前后关系下的对象版本代替现有版本
if(isOld)
rev = map_item_beans.get(id).getOldRev();
else
rev = map_item_beans.get(id).getNewRev();
getBomLineTreeNodeSOA(rev, structureService, bomWinType);
bom = bomMap.get(rev.toString());
}else {
rev = data.itemRevOfBOMLine;
if(bomMap.containsKey(rev.toString()))
bom = bomMap.get(rev.toString());
}
boolean part = !rev.getType().equals("ZT2_Design3DRevision");
String bl_quantity = line.getProperty("bl_quantity");
Double qty = (bl_quantity.isEmpty() ? 1 : Double.parseDouble(bl_quantity)) * count;
if((part && bom.length == 0) || rev.getProperty("zt2_Source").equals("外购")) {
// System.out.println("bom:" + uid + "==" + bom);
//外购就是实体不用看工艺BOM也不需要展开处理
if(isOld) {
if(!oldStBomMap.containsKey(uid))
oldStBomMap.put(uid, new ArrayList<>());
oldStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
}else {
if(!newStBomMap.containsKey(uid))
newStBomMap.put(uid, new ArrayList<>());
newStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
}
}else if(!part && isShiti(rev)) {
if(isOld) {
if(!oldStBomMap.containsKey(uid))
oldStBomMap.put(uid, new ArrayList<>());
oldStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
// System.out.println("oldBomMap:" + uid + "==" + bom);
//如果图纸或物料的实体件只有变更后一个版本,则当前数据不需要作为变更差异父件,即不体现。
if(!map_item_beans.containsKey(id) || map_item_beans.get(id).getNewRev() != null)
recycleBom(rev.toString(), rev.toString(), isOld, bomWinType, map_item_beans, 1.0, structureService);
}else {
if(!newStBomMap.containsKey(uid))
newStBomMap.put(uid, new ArrayList<>());
newStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
// System.out.println("newBomMap:" + uid + "==" + bom);
//如果图纸或物料的实体件只有变更后一个版本,则当前数据不需要作为变更差异父件,即不体现。
if(!map_item_beans.containsKey(id) || map_item_beans.get(id).getOldRev() != null)
recycleBom(rev.toString(), rev.toString(), isOld, bomWinType, map_item_beans, 1.0, structureService);
}
}else {
// System.out.println("bom:" + uid + "==" + bom);
//虚拟BOM进行消层
recycleBom(rev.toString(), uid, isOld, bomWinType, map_item_beans, qty, structureService);
}
}
}
/**
* BomMap
* @param map BomMap
* @return BomMap
*/
private static String printBomMap(HashMap<String, ArrayList<Object[]>> map) {
StringBuilder str = new StringBuilder("");
for(String s : map.keySet()) {
str.append(s).append("=[");
for(Object[] bojs : map.get(s)) {
str.append(bojs[1]).append("*").append(bojs[3]).append(";");
}
str.append("]\n");
}
return str.toString();
}
/**
* SOABOMbomMapStructureManagement
* @param bomLine BOM
* @param structureService StructureManagement
*/
private static void getBomLineTreeNodeSOA(TCComponentItemRevision rev, StructureManagement structureService, TCComponentBOMWindowType bomWinType) throws Exception {
if(bomMap.containsKey(rev.toString()))
return;
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine bomLine = win.setWindowTopLine(rev.getItem(), rev, null, null);
// 调用SOA方法批量展开BOM
// com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(RACUIUtil.getTCSession());
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref();
levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; //输入顶层BOMLine对象
levelInfo.excludeFilter = "None";//zt2_BOMMaterial
levelPref.expItemRev = false;
levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0];
// levelPref.info[0].relationName = "";
//使用以下方法展开完整的BOM行
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService.expandPSAllLevels(levelInfo, levelPref);
if (levelResp.output.length > 0) {
//将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) {
ExpandPSData[] children = data.children;
TCComponentItemRevision parentBomLine = data.parent.itemRevOfBOMLine;
bomMap.put(parentBomLine.toString(), children);
}
}else {
bomMap.put(rev.toString(), new ExpandPSData[0]);
}
win.close();
}
}

@ -11,6 +11,9 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
@ -30,6 +33,7 @@ import com.connor.chint.sap2.util.POIUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.SqlUtil2;
import com.connor.chint.sap2.util.TXTUtil;
import com.connor.chint.sap2.util.ZYFactoryUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
@ -43,12 +47,16 @@ import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad.StructureManagementService;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.AttributesInfo;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureInfo;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructurePref;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureResponse;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelOccInfo;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelativeStructureChildInfo;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2006_03.DataManagement.CreateRelationsResponse;
import com.teamcenter.services.rac.core._2006_03.DataManagement.Relationship;
@ -286,10 +294,10 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
System.out.println("耗时 : " + (endTime - startTime) / 1000 + "s");
my.setVisible(false);
// errorMeg.append("DJ121110383-出场编号创建失败!");
MessageBox.post("µçÆøBOM´î½¨Íê³É\n" + errorMeg.toString(), "", 2);
savaLogAtClient(xxjk_folder);
//savaLogAtClient(xxjk_folder);
MessageBox.post("电气BOM搭建完成\n" + errorMeg.toString(), "", 2);
} catch (Exception e) {
KUtil.closeMyProgressBar(my);
MessageBox.post("异常:" + e.getMessage(), "", 2);
@ -337,7 +345,7 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
if (fpx_factorys.size() == 0) {
return factory;
}
// Set<Entry<String, List<String>>> entry = fpx_factorys.entrySet();
Set<Entry<String, List<String>>> entry = fpx_factorys.entrySet();
System.out.println("整理过后的出厂编号:" + fpx_factorys.toString());
for (Map.Entry<String, List<String>> en : fpx_factorys.entrySet()) {
@ -408,8 +416,7 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
}
return "";
}
@SuppressWarnings("deprecation")
private void savaLogAtClient(TCComponentFolder xxjk_folder) throws Exception {
private void savaLogAtClient(TCComponentFolder xxjk_folder) throws TCException {
// TXTUtil.writeTXT(cc_log, "物料编码出厂编号创建成功");
if (cc_log != null) {
TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session
@ -421,18 +428,17 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
tccomponentDataset.save();
tccomponentDataset.unlock();
xxjk_folder.add("contents", tccomponentDataset);
// TCComponentDataset newDataset = new TCComponentDataset();
TCComponentDataset newDataset = new TCComponentDataset();
// newDatas
System.out.println(cc_log);
}
}
@SuppressWarnings("deprecation")
public void getBOM5(List<CcemFactoryBean> lists, TCComponent folder, MyProgressBarCompent my,String taskid) throws Exception {
Map<String, TCComponentItemRevision> map_revs = new HashMap<>();
// long startTime0 = new Date().getTime();
long startTime0 = new Date().getTime();
long startTime1 = System.currentTimeMillis();
// List<String> list_FnCnCodes;// 规范书号
List<String> list_FnCnCodes;// ¹æ·¶ÊéºÅ
Object[] obj = new Object[3];
Object[] obj2 = new Object[2];
// String sql = SQL_QUERY_CcemEb;
@ -525,7 +531,7 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
}
map_revs.put("9900000135", null);
if (parent.getChilds().size() > 0) {
// int num = getTypeNumber(session, parentCode);
int num = getTypeNumber(session, parentCode);
// type_indexs.put(parentCode, new Integer(num));
parent.setZt2_MaterialNo(parentCode);
parent.setEbGoodsCode("9900000135");
@ -612,7 +618,7 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
// 测试
List<CcemEb> list_parents;
// Vector<TCComponentItem> vec_items = new Vector<>();
Vector<TCComponentItem> vec_items = new Vector<>();
int num = 1;
// List<TCComponent> items = new ArrayList<>();
@ -629,9 +635,9 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
pool.prestartCoreThread();
CountDownLatch sign = new CountDownLatch(count);
// TCComponentItem item;
List<CreateIn> cIList = new ArrayList<>();
List<CreateIn> cIList = new ArrayList();
// String zt2_MaterialNo;
Map<String,CcemEb> idParentMap = new HashMap<>();
Map<String,CcemEb> idParentMap = new HashMap();
String newID;
// CcemEb parent2;
// TCComponent factoryNo;
@ -962,8 +968,8 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
return beans;
}
private Map<String,Integer> countMap = new HashMap<>();
private Map<String,Integer> numMap = new HashMap<>();
private Map<String,Integer> countMap = new HashMap();
private Map<String,Integer> numMap = new HashMap();
public int getTypeNumber(TCSession session, String type) throws Exception {
System.out.println("WBS号"+zt2_WBSNo);
@ -1004,8 +1010,7 @@ public class DYCreateElectricalBOMOperation2 extends AbstractAIFOperation {
ErpWebService service = new ErpWebServiceLocator();
ErpWebServiceSoap stub = service.getErpWebServiceSoap();
String mess = stub.createBom2(json);
System.out.println("createBOM" + json);
System.out.println("createBOM" + mess);
System.out.println(json);
}

@ -1,347 +0,0 @@
package com.connor.chint.sap2.dy.createElectricalBOM;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.chint.plm.common.context.ApiContext;
import com.chint.plm.common.util.ArrayUtils;
import com.chint.plm.common.util.HttpUtils;
import com.chint.plm.common.util.LoggerUtils;
import com.chint.plm.common.util.StringUtils;
import com.connor.chint.sap2.dy.createElectricalBOM.bean.CcemEb;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.POIUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad.StructureManagementService;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.AttributesInfo;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureInfo;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructurePref;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureResponse;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelOccInfo;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelativeStructureChildInfo;
/**
* BOM
*
*/
public class DYSHCreateElectricalBOMOperationV2 extends AbstractAIFOperation {
private AbstractAIFApplication app;
public DYSHCreateElectricalBOMOperationV2(AbstractAIFApplication app) {
this.app = app;
}
@Override
public void executeOperation() throws Exception {
MyProgressBarCompent my = null;
try {
TCComponent project = null;
TCComponent folder = null;
TCSession session = (TCSession) app.getSession();
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null || !(target instanceof TCComponent)) {
return;
}
String type = target.getType();
if (type.equals("ZT2_ProjectItem")) {
project = (TCComponent) target;
String zt2_WBSNo = project.getProperty("zt2_WBSNo");
}
if (project == null) {
MessageBox.post("请选择项目对象", "", 2);
return;
}
TCComponentFolder xxzx_folder = KUtil.getXMZXFolderFromProject(project);
if (xxzx_folder == null) {
MessageBox.post("未找到项目执行文件夹,请检查项目数据 ", "", 2);
return;
}
AIFComponentContext[] childs = xxzx_folder.getChildren();
for (int i = 0, len = childs.length; i < len; i++) {
folder = (TCComponent) childs[i].getComponent();
if (folder.getProperty("object_name").contains("电气设计") && folder instanceof TCComponentFolder) {
break;
}
folder = null;
}
if (folder == null) {
MessageBox.post("未找到电气设计文件夹,请检查项目数据 ", "", 2);
return;
}
my = new MyProgressBarCompent("", "正在提取项目BOM信息......");
String projectId = project.getProperty("item_id");
String zt2_WBSNo = project.getProperty("zt2_WBSNo");
// 发起提取BOM请求
String cadUrl = ApiContext.getApiUrl(session, "CHINT_EX_CADTOOL_URL");
String urlString = cadUrl + "/api/PLM/PullProject";
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("plmId", projectId);
String resp = HttpUtils.get(urlString, paramMap);
try {
JSONObject respObject = JSONObject.parseObject(resp);
if (respObject.containsKey("isOK") && respObject.getBoolean("isOK")) {
JSONObject dataObject = respObject.getJSONObject("data");
JSONArray products = dataObject.getJSONArray("products");
if (products != null && products.size() > 0) {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Part");
for (int i = 0; i < products.size(); i++) {
JSONObject product = products.getJSONObject(i);
String factoryId = product.getString("factoryId");
// String flowNo = product.getString("flowNo");
JSONArray items = product.getJSONArray("items");
if (items != null && items.size() > 0) {
// 在 项目执行/电气设计 下,创建固定单元
String objectName = "固定单元";
int index = getTypeNumber(session, "9900000135", zt2_WBSNo);
// 出厂编号
List<TCComponent> factoryNoComps = new ArrayList<>();
List<String> factoryNos = getFactoryNos(factoryId);
for (String factoryNo : factoryNos) {
Map<String, String> queryCondition = new HashMap<>();
queryCondition.put("fid", factoryNo);
// 查询出厂编号
TCComponentContextList contextList = KUtil.query(session, "chint_query_FactoryNo", queryCondition);
if (contextList.getListCount() > 0) {
TCComponent comp = (TCComponent) contextList.get(0).getComponent();
if (comp instanceof TCComponentItem) {
TCComponentItem item = (TCComponentItem) comp;
factoryNoComps.add(item);
}
}
}
// BOM
CcemEb parent = new CcemEb();
List<CcemEb> bomChilds = new ArrayList<CcemEb>();
Map<String, TCComponentItemRevision> partItemRevMaps = new LinkedHashMap<String, TCComponentItemRevision>();
for (int j = 0; j < items.size(); j++) {
JSONObject item = items.getJSONObject(j);
String code = item.getString("code");
BigDecimal quantity = item.getBigDecimal("quantity").setScale(2, RoundingMode.HALF_UP);
Map<String, String> queryCondition = new HashMap<>();
queryCondition.put("ID", code);
// 查询零件
TCComponentContextList contextList = KUtil.query(session, "chint_query_item", queryCondition);
if (contextList.getListCount() > 0) {
TCComponent comp = (TCComponent) contextList.get(0).getComponent();
if (comp instanceof TCComponentItemRevision) {
TCComponentItemRevision partItemRev = (TCComponentItemRevision) comp;
System.out.print(partItemRev);
partItemRevMaps.put(code, partItemRev);
}
}
CcemEb ccemEb = new CcemEb();
ccemEb.setZt2_MaterialNo(code);
ccemEb.setEbQty(quantity.toString());
ccemEb.setBl_sequence_no("");
ccemEb.setBl_ref_designator("");
bomChilds.add(ccemEb);
}
parent.setChilds(bomChilds);
// 创建固定单元
String zt2_MaterialNo = "9900000135-";
// 物料分类码
String pmpcCode = "990101002";
TCComponentItemRevision partItmeRevision = createPart(session, folder, factoryNoComps, itemType,
objectName, zt2_WBSNo, zt2_MaterialNo + String.format("%05d", index), pmpcCode);
// 创建固定单元下的视图BOM
int p_size = 1;
createBOM(session, parent, partItmeRevision, partItemRevMaps, p_size);
}
}
}
my.setVisible(false);
MessageBox.post("(深化)电气提取BOM成功", "", 2);
} else {
my.setVisible(false);
MessageBox.post("调用接口响应:" + respObject.getString("message"), "", 2);
}
} catch (Exception e) {
e.printStackTrace();
my.setVisible(false);
MessageBox.post("处理异常:" + e.getMessage() + "接口响应:" + resp, "", 2);
return;
}
} catch (Exception e) {
KUtil.closeMyProgressBar(my);
e.printStackTrace();
MessageBox.post("异常:" + e.getMessage(), "", 2);
}
}
public TCComponentItemRevision createPart(TCSession session, TCComponent folder, List<TCComponent> factoryNos, TCComponentItemType itemType,
String object_name, String zt2_WBSNo, String zt2_MaterialNo, String pmpcCode) throws Exception {
// 创建零件
String item_id = itemType.getNewID();
TCComponentItem item = itemType.create(item_id, "A", "Part", object_name, null, null);
item.setProperty("zt2_unit", "TAI");
// 添加内容
folder.add("contents", item);
// 物料编码
item.getLatestItemRevision().setProperty("zt2_MaterialNo", zt2_MaterialNo);
// WBS号
item.getLatestItemRevision().setProperty("zt2_WBSNo", zt2_WBSNo);
// 基本数量
item.getLatestItemRevision().setProperty("zt2_Quantity", "1");
// item.getLatestItemRevision().setProperty("zt2_unit", "TAI");
// 物料分类码
item.getLatestItemRevision().setProperty("zt2_ClassificationCode", pmpcCode);
TCComponentItemRevision rev = item.getLatestItemRevision();
// 添加出厂编码
if (factoryNos.size() > 0) {
rev.add("ZT2_FactoryNumber", factoryNos);
}
return rev;
}
private void createBOM(TCSession session, CcemEb parent, TCComponentItemRevision rev, Map<String, TCComponentItemRevision> partItemRevMaps, int p_size) {
List<CcemEb> childs = parent.getChilds();
if (childs.size() == 0)
return;
// 排序
Collections.sort(childs, new Comparator<CcemEb>() {
@Override
public int compare(CcemEb o1, CcemEb o2) {
return POIUtil.getIntValue(o1.getBl_sequence_no()) - POIUtil.getIntValue(o2.getBl_sequence_no());
}
});
// 创建结构子集
List<RelativeStructureChildInfo> childInfos = new ArrayList<>();
AttributesInfo attr, attr1, attr2;
for (int i = 0, len = childs.size(); i < len; i++) {
// 子集信息
RelativeStructureChildInfo childInfo = new RelativeStructureChildInfo();
RelOccInfo occInfo = new RelOccInfo();
// 数量
attr = new AttributesInfo();
attr.name = "bl_quantity";
attr.value = POIUtil.getIntValue(childs.get(i).getEbQty()) * p_size + "";
// 查找编号
attr1 = new AttributesInfo();
attr1.name = "bl_sequence_no";
attr1.value = (i + 1) * 10 + "";
// 代号
attr2 = new AttributesInfo();
attr2.name = "bl_ref_designator";
attr2.value = childs.get(i).getBl_ref_designator();
occInfo.attrsToSet = new AttributesInfo[] { attr, attr1, attr2 };
childInfo.child = partItemRevMaps.get(childs.get(i).getZt2_MaterialNo());
childInfo.occInfo = occInfo;
childInfos.add(childInfo);
}
// 保存相关的结构
saveRelativeStructure(session, rev, childInfos);
}
@SuppressWarnings("deprecation")
private void saveRelativeStructure(TCSession session, TCComponentItemRevision parent, List<RelativeStructureChildInfo> childInfos) {
StructureManagementService service = StructureManagementService.getService(session);
// 创建或修改相关的结构
CreateOrUpdateRelativeStructurePref structurePref = new CreateOrUpdateRelativeStructurePref();
CreateOrUpdateRelativeStructureInfo structureInfo = new CreateOrUpdateRelativeStructureInfo();
structureInfo.childInfo = childInfos.toArray(new RelativeStructureChildInfo[] {});
structureInfo.parent = parent;
structureInfo.precise = false;
CreateOrUpdateRelativeStructureResponse resp;
try {
resp = service.createOrUpdateRelativeStructure(new CreateOrUpdateRelativeStructureInfo[] { structureInfo }, "view", true, structurePref);
KUtil.throwServiceDataError(resp.serviceData);
} catch (Exception e) {
e.printStackTrace();
LoggerUtils.debug(e.getMessage());
}
}
private static int getTypeNumber(TCSession session, String type, String zt2_WBSNo) throws Exception {
Map<String, String> fields = new HashMap<>();
fields.put("WBS号", zt2_WBSNo);
fields.put("物料编码", type + "-*");
TCComponentContextList querys = KUtil.query(session, "查询物料", fields);
List<InterfaceAIFComponent> list = querys.toComponentVector();
int size = list.size();
Collections.sort(list, new Comparator<InterfaceAIFComponent>() {
@Override
public int compare(InterfaceAIFComponent o1, InterfaceAIFComponent o2) {
try {
return o2.getProperty("zt2_MaterialNo").compareTo(o1.getProperty("zt2_MaterialNo"));
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
});
if (size > 0) {
String zt2_MaterialNo = list.get(0).getProperty("zt2_MaterialNo");
int index = zt2_MaterialNo.indexOf("-");
if (index != -1) {
int value = POIUtil.getIntValue(zt2_MaterialNo.substring(index + 1));
return value == 0 ? 1 : value + 1;
}
}
return 1;
}
private static List<String> getFactoryNos(String factoryId) {
List<String> factoryNos = new ArrayList<>(64);
if (StringUtils.isNotBlank(factoryId)) {
String[] noStrs = factoryId.split(",");
if (ArrayUtils.isNotEmpty(noStrs)) {
for (String str : noStrs) {
String[] nos = str.split("~");
if (ArrayUtils.isNotEmpty(nos)) {
if (nos.length == 1) {
factoryNos.add(nos[0]);
} else if (nos.length == 2) {
String one = nos[0];
String two = nos[1];
String prefix = one.substring(0, one.length() - 8);
String serial = one.substring(one.length() - 8, one.length());
int serialNum = Integer.parseInt(serial);
for (int i = 0; i < 1000; i++) {
String next = prefix + (serialNum + i);
factoryNos.add(next);
if (next.equals(two)) {
break;
}
}
} else {
throw new RuntimeException("出厂编号格式不催:" + factoryId);
}
}
}
}
}
return factoryNos;
}
public static void main(String[] args) {
List<String> nos = getFactoryNos("DX323041400");
System.out.println(nos.size());
nos = getFactoryNos("DX323041400~DX323041432");
System.out.println(nos.size());
nos = getFactoryNos("DX323041400~DX323041432,DX323041388~DX323041399");
System.out.println(nos.size());
}
}

@ -1,171 +0,0 @@
package com.connor.chint.sap2.electrical_task;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.chint.plm.common.context.ApiContext;
import com.chint.plm.common.util.HttpUtils;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.ZYFactoryUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
*
* @since 2024-05-10
*/
public class DYSHElectricalTasksOperationV2 extends AbstractAIFOperation {
private AbstractAIFApplication app;
public DYSHElectricalTasksOperationV2(AbstractAIFApplication app) {
this.app = app;
}
@Override
public void executeOperation() throws Exception {
MyProgressBarCompent my = null;
try {
TCSession session = (TCSession) app.getSession();
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null || !target.getType().equals("ZT2_ProjectItem")) {
MessageBox.post("请选择项目对象", "", 2);
return;
}
my = new MyProgressBarCompent("任务下发", "(深化)电气任务传递中......");
// 项目对象
TCComponent project = (TCComponent) target;
// 产成品文件夹
TCComponentFolder ccpFolder = KUtil.getCCPFolderFromProject(project);
if (ccpFolder == null) {
MessageBox.post("未找到产成品信息,请检查项目数据", "", 2);
return;
}
// 项目基本信息
String itemId = project.getProperty("item_id");
String projectCode = project.getProperty("zt2_ProjectNo");
String projectName = project.getProperty("object_name");
// 同一前缀产成品
Map<String, String> ccp_types = new HashMap<>(16);
// 产成品和出厂编号关系
Map<String, List<String>> ccp_factoryNos = new HashMap<>(16);
// 产成品名称
Map<String, String> ccp_names = new HashMap<>(16);
// 出厂编号:物料编码
Map<String, String> map_factory_ccp = new HashMap<>(32);
// 产成品文件夹子集
AIFComponentContext[] ccpChilds = ccpFolder.getChildren();
for (int i = 0, len = ccpChilds.length; i < len; i++) {
if (ccpChilds[i].getComponent().getType().equals("Part")) {
// 版本对象
TCComponentItemRevision rev = ((TCComponentItem) ccpChilds[i].getComponent()).getLatestItemRevision();
String zt2_MaterialNo = rev.getProperty("zt2_MaterialNo");
int index = zt2_MaterialNo.indexOf("-");
// 主物料编码 直接取子物料编码
String type = zt2_MaterialNo; //index > -1 ? zt2_MaterialNo.substring(0, index) : zt2_MaterialNo;
// 出厂编码
TCComponent[] meops = rev.getRelatedComponents("ZT2_FactoryNumber");
// 产成品名称
String object_name = rev.getProperty("object_name");
ccp_names.put(zt2_MaterialNo, object_name);
if (ccp_types.containsKey(type)) {
String value = ccp_types.get(type);
if (zt2_MaterialNo.compareTo(value) < 0) {
ccp_types.put(type, zt2_MaterialNo);
}
List<String> factoryNos = ccp_factoryNos.get(type);
for (int j = 0; j < meops.length; j++) {
String factoryID = meops[j].getProperty("item_id");
map_factory_ccp.put(factoryID, zt2_MaterialNo);
if (!factoryNos.contains(factoryID)) {
factoryNos.add(factoryID);
}
}
} else {
ccp_types.put(type, zt2_MaterialNo);
List<String> factoryNos = new ArrayList<>();
for (int j = 0; j < meops.length; j++) {
String factoryID = meops[j].getProperty("item_id");
factoryNos.add(factoryID);
map_factory_ccp.put(factoryID, zt2_MaterialNo);
}
ccp_factoryNos.put(type, factoryNos);
}
}
}
// 按物料排序
List<String> keys = new java.util.ArrayList<>(ccp_types.keySet());
Collections.sort(keys);
if (ccp_types.size() > 0) {
// 组织请求参数
JSONObject param = new JSONObject();
JSONArray products = new JSONArray();
param.put("PLMId", itemId);
param.put("Code", projectCode);
param.put("Name", projectName);
for (String key : keys) {
String materialCode = key;
String materialCodePart = ccp_types.get(key);
List<String> factoryNos = ccp_factoryNos.get(materialCode);
String factoryId = "";
if (factoryNos.size() > 0) {
Collections.sort(factoryNos);
if (factoryNos.size() == 1) {
factoryId = factoryNos.get(0);
} else {
factoryId = ZYFactoryUtil.getFactory2(factoryNos, 4, "~");
}
}
JSONObject product = new JSONObject();
product.put("PartId", materialCode);
product.put("PartName", ccp_names.get(materialCodePart));
product.put("FactoryId", factoryId);
product.put("Status", "0");
product.put("FlowNo", "-00001");
products.add(product);
}
param.put("Products", products);
// 发起任务下发请求
String cadUrl = ApiContext.getApiUrl(session, "CHINT_EX_CADTOOL_URL");
String urlString = cadUrl + "/api/PLM/ReceiveProject";
String resp = HttpUtils.post(urlString, param.toString());
try {
JSONObject respObject = JSONObject.parseObject(resp);
if (respObject.containsKey("isOK") && respObject.getBoolean("isOK")) {
my.setVisible(false);
MessageBox.post("(深化)电气任务下发成功", "", 2);
} else {
my.setVisible(false);
MessageBox.post("调用接口响应:" + respObject.getString("message"), "", 2);
}
} catch (Exception e) {
my.setVisible(false);
MessageBox.post("调用接口响应:" + resp, "", 2);
return;
}
} else {
my.setVisible(false);
MessageBox.post("未找到产成品信息,请检查项目数据", "", 2);
return;
}
} catch (Exception e) {
KUtil.closeMyProgressBar(my);
e.printStackTrace();
MessageBox.post("异常:" + e.getMessage(), "", 2);
}
}
}

@ -7,7 +7,6 @@ import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -29,13 +28,14 @@ import com.connor.chint.sap2.modelAudit.ModelAudiTableModel;
import com.connor.chint.sap2.util.CheckBoxTableHeaderRenderer;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.workflow.commands.newprocess.NewProcessDialog;
@ -51,10 +51,10 @@ public class BatchReviewDialog extends AbstractAIFDialog {
*
*/
private static final long serialVersionUID = 1L;
// private List<TCComponent> targets;
private List<TCComponent> targets;
private List<BatchReviewBean> beans;
private AbstractAIFApplication app;
private TCSession session;
// private TCSession session;
protected ModelAudiTableModel tm_part;
protected JTable t_part;
// private CheckBoxTableHeaderRenderer tableHeaderRenderer;
@ -74,18 +74,17 @@ public class BatchReviewDialog extends AbstractAIFDialog {
// Auto-generated constructor stub
super(false);
this.app = app;
this.session = (TCSession) app.getSession();
// this.session = (TCSession) app.getSession();
}
@Override
public void run() {
long start = System.nanoTime();
initUI();
showDialog();
System.out.println("time1:" + (System.nanoTime() - start)/1000000000);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
@ -94,9 +93,9 @@ public class BatchReviewDialog extends AbstractAIFDialog {
try {
pb.setText("加载数据...");
pb.startProgress();
pb.setText("¼ÓÔØÊý¾Ý...");
pb.showDialog();
System.out.println("time2:" + (System.nanoTime() - start)/1000000000);
if (!getTargetSql()) {
if (!getTarget()) {
pb.disposeDialog();
MessageBox.post("当前文件夹无审核对象。", "", 2);
disposeDialog();
@ -108,7 +107,6 @@ public class BatchReviewDialog extends AbstractAIFDialog {
disposeDialog();
return;
}
System.out.println("time3:" + (System.nanoTime() - start)/1000000000);
refreshTable(beans);
timer = new Timer();
check();
@ -123,7 +121,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
// 刷新表格
private void refreshTable(List<BatchReviewBean> beans) {
public void refreshTable(List<BatchReviewBean> beans) {
t_part.clearSelection();
tm_part.getDataVector().clear();
int rowCount = t_part.getRowCount();
@ -131,6 +129,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
tm_part.removeRow(i);
}
Collections.sort(beans, new Comparator<BatchReviewBean>() {
@Override
public int compare(BatchReviewBean o1, BatchReviewBean o2) {
// Auto-generated method stub
@ -146,52 +145,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
// 获取未发布及未在流程中的对象
//TODO lidy20240514改用数据库查询
private boolean getTargetSql() throws Exception {
long start = System.nanoTime();
boolean flag = false;
beans = new ArrayList<>();
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return flag;
}
StringBuilder uids = new StringBuilder("");
InterfaceAIFComponent[] folders = app.getTargetComponents();
for(InterfaceAIFComponent folder : folders) {
uids.append("','").append(folder.getUid());
}
StringBuilder sql = new StringBuilder("select distinct a1.POBJECT_NAME,");
sql.append("decode(a1.pobject_type,'ZT2_Design3DRevision',decode(b2.pzt2_materialno,'',a.pitem_id,b2.pzt2_materialno),'Part Revision',b1.pzt2_materialno,a.pitem_id) as DRAWNO,")
.append("a.COMP from (select t1.puid,decode(t1.pobject_type,'ZT2_Change',t2.puid,'ZT2_SCXXCDTZD',t2.puid,t3.puid) as COMP,t2.pitem_id from pworkspaceobject t1,pitem t2,CHINT_LATESTREV t3 ")
.append("where t1.puid=t2.puid and t2.puid=t3.item and t1.puid in (select PVALU_0 from pcontents where puid in ('").append(uids.substring(3)).append("')) ")
.append("union select t.puid,t.puid as comp,t0.pitem_id from PITEMREVISION t,pitem t0 where t.RITEMS_TAGU=t0.puid ")
.append("and t.puid in (select PVALU_0 from pcontents where puid in ('").append(uids.substring(3)).append("'))) a,pworkspaceobject a1 ")
.append("left join ppart_0_revision_alt b1 on b1.puid=a1.puid left join pzt2_design3drevision b2 on b2.puid=a1.puid where a.comp=a1.puid ")
.append("and not exists (select pvalu_0 from prelease_status_list where puid=a.puid) ")
.append("and not exists (select r.puid from pepmtask r,pimanrelation r0 where r.puid=r0.rprimary_objectu and r.pstate_value=4 and r0.rsecondary_objectu=a.comp)");
System.out.println("sql==>" + sql);
ResultSet rs = SqlUtil.read(sql.toString());
System.out.println("rs==>" + rs.getRow());
while(rs.next()) {
String object_name = rs.getString(1);
String drawNo = rs.getString(2);
TCComponent comp = session.stringToComponent(rs.getString(3));
// System.out.println("POBJECT_NAME==>" + object_name);
// System.out.println("DRAWNO==>" + drawNo);
// System.out.println("COMP==>" + rs.getString(3) + "@@" + comp);
beans.add(new BatchReviewBean(true, object_name, "", drawNo, comp));
flag = true;
}
SqlUtil.free();
System.out.println("t2:" + (System.nanoTime() - start)/1000000);
return flag;
}
// 获取未发布及未在流程中的对象
/*private boolean getTarget() throws Exception {
long start = System.nanoTime();
public boolean getTarget() throws Exception {
// TCComponentFolder folder = (TCComponentFolder) app.getTargetComponent();
// AIFComponentContext[] childs = folder.getChildren();
InterfaceAIFComponent[] folders = app.getTargetComponents();
@ -201,12 +155,10 @@ public class BatchReviewDialog extends AbstractAIFDialog {
childs.add(c);
}
}
System.out.println("childs:" + childs.size());
System.out.println("t1:" + (System.nanoTime() - start)/1000000);
TCComponentItem item = null;
TCComponentItemRevision rev = null;
targets = new ArrayList<>();
beans = new ArrayList<>();
targets = new ArrayList<>(64);
beans = new ArrayList<>(64);
boolean flag = false;
String object_name = "";
String drawNo = "";
@ -215,7 +167,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
for (AIFComponentContext c : childs) {
InterfaceAIFComponent child = c.getComponent();
type = child.getType();
if (type.equals("ZT2_ProjectItem")) {
if (child.getType().equals("ZT2_ProjectItem")) {
continue;
}
flag = true;
@ -239,7 +191,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
// System.out.println("comp2:"+comp);
// System.out.println("flag1:"+!KUtil.isTCM(comp)+";flag2:"+!KUtil.isInProcess(comp)+";flag3:"+targets.contains(comp));
// System.out.println("ccc");
if (!targets.contains(comp) && !KUtil.isTCM(comp) && !KUtil.isInProcess(comp)) {
if (!KUtil.isTCM(comp) && !KUtil.isInProcess(comp) && !targets.contains(comp)) {
targets.add(comp);
object_name = comp.getProperty("object_name");
drawNo = "";
@ -254,10 +206,9 @@ public class BatchReviewDialog extends AbstractAIFDialog {
beans.add(new BatchReviewBean(true, object_name, isTCM, drawNo, comp));
}
}
System.out.println("t2:" + (System.nanoTime() - start)/1000000);
return flag;
}*/
}
@Override
protected void processWindowEvent(WindowEvent e) {
@ -274,7 +225,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
// 开始检查
private void check() {
public void check() {
thread = new TimerTask() {
@Override
public void run() {
@ -303,6 +254,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
}
}
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
@ -310,10 +262,11 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
};
timer.schedule(thread, 1000, 2000);
}
// 停止检查
private void stopTimerTask() {
public void stopTimerTask() {
System.out.println("停止定时检查");
if (thread != null) {
@ -325,10 +278,8 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
// 发起审核流程
private void modelAudit() throws Exception {
long start = System.nanoTime();
public void modelAudit() throws Exception {
List<BatchReviewBean> list = getSelectedParts();
System.out.println("modelAudit1:" + (System.nanoTime() - start)/1000000);
int len = list.size();
System.out.println("选中个数:" + len);
@ -343,11 +294,9 @@ public class BatchReviewDialog extends AbstractAIFDialog {
System.out.println("模块:" + com);
command.selectTargets.add(com.getComp());
}
System.out.println("modelAudit2:" + (System.nanoTime() - start)/1000000);
// AIFDesktop
command.targetArray = command.selectTargets.toArray(new InterfaceAIFComponent[command.selectTargets.size()]);
new NewProcessDialog(command);
System.out.println("modelAudit3:" + (System.nanoTime() - start)/1000000);
// new Thread().sleep(30000);
for (BatchReviewBean com : list) {
System.out.println("模块:" + com);
@ -366,7 +315,6 @@ public class BatchReviewDialog extends AbstractAIFDialog {
tm_part.setValueAt("流程中", com.getIndex(), com.model_isTCM_INDEX);
}
}
System.out.println("modelAudit4:" + (System.nanoTime() - start)/1000000);
}
// 获取选中的对象
@ -385,6 +333,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
private void addListeners() {
// Auto-generated method stub
btn_cel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
@ -393,10 +342,12 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
});
btn_audit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Auto-generated method stub
@ -409,6 +360,7 @@ public class BatchReviewDialog extends AbstractAIFDialog {
}
}
});
}
});
}

@ -19,7 +19,6 @@ import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
@ -28,11 +27,6 @@ import com.teamcenter.rac.util.MessageBox;
public class AProjectNoDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private AProjectNoController controller;
private JButton assign;
private JButton b_ok;
@ -41,21 +35,21 @@ public class AProjectNoDialog extends AbstractAIFDialog {
public static final String[] HEADER = new String[] { "产品代号", "产品特征号", "年代号", "顺序号" };
public static final int[] HEADERWIDTH = new int[] { 180, 180, 180, 180 };
// private AbstractAIFApplication app;
private AbstractAIFApplication app;
private TCSession session;
public AProjectNoDialog(AbstractAIFApplication app) {
super(false);
// this.app = app;
this.app = app;
this.session = (TCSession) app.getSession();
this.controller = new AProjectNoController(app, this);
}
public AProjectNoDialog(Frame paramFrame, AbstractAIFApplication app) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
super(paramFrame, false);
// this.app = app;
this.app = app;
this.session = (TCSession) app.getSession();
this.controller = new AProjectNoController(app, this);
}
@ -113,7 +107,7 @@ public class AProjectNoDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
String cpdh = (String) tm_part.getValueAt(0, 0);
String cptzz = (String) tm_part.getValueAt(0, 1);
@ -146,7 +140,7 @@ public class AProjectNoDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
String flowNo = (String) tm_part.getValueAt(0, 3);
String cpdh = (String) tm_part.getValueAt(0, 0);
@ -180,7 +174,7 @@ public class AProjectNoDialog extends AbstractAIFDialog {
@Override
public void tableChanged(TableModelEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
int col = e.getColumn();
int row = e.getFirstRow();
if (col < 2) {
@ -232,33 +226,25 @@ public class AProjectNoDialog extends AbstractAIFDialog {
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_M006_PROJNO", session);
JComboBox<String> com = new JComboBox<String>();
com.addItem("");
for(String s : prefs[0].split(";")) {
com.addItem(s);
}
// com.addItem("H");
// com.addItem("CB");
// com.addItem("GW");
com.addItem("H");
com.addItem("CB");
com.addItem("GW");
t_part.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(com));
JComboBox<String> com2 = new JComboBox<String>();
com2.addItem("");
for(String s : prefs[1].split(";")) {
com2.addItem(s);
}
// com2.addItem("G");
// com2.addItem("F");
// com2.addItem("E");
// com2.addItem("D");
// String cpdhs[] = new String[] { "", "H", "CB", "GW" };
// String cptzhs[] = new String[] { "", "G", "F", "E", "D" };
com2.addItem("G");
com2.addItem("F");
com2.addItem("E");
com2.addItem("D");
String cpdhs[] = new String[] { "", "H", "CB", "GW" };
String cptzhs[] = new String[] { "", "G", "F", "E", "D" };
t_part.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(com2));
tm_part.addRow(new Vector<String>());
JScrollPane scroll = new JScrollPane(t_part);
scroll.setPreferredSize(new Dimension(452, 120));//48
@SuppressWarnings("deprecation")
scroll.setPreferredSize(new Dimension(452, 48));
int year = new Date().getYear();
year = year % 100;
tm_part.setValueAt("" + year, 0, 2);
@ -267,9 +253,9 @@ public class AProjectNoDialog extends AbstractAIFDialog {
return panel;
}
// private void setCompEnabled(boolean b) {
// assign.setEnabled(b);
// b_ok.setEnabled(b);
// }
private void setCompEnabled(boolean b) {
assign.setEnabled(b);
b_ok.setEnabled(b);
}
}

@ -10,6 +10,7 @@ import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
@ -47,6 +48,7 @@ import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
@ -61,18 +63,14 @@ import com.teamcenter.rac.util.Registry;
*/
public class BOMImportDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private JButton button; // 文件路径
private JButton button2; // 保存
private JButton button3; // 取消
private JTextField jf; // 文件选择器
// private int export_type = -1; // 导出模板类型
// private TCComponentItemRevision bom_rev;
// private String path;
private int export_type = -1; // 导出模板类型
private TCComponentItemRevision bom_rev;
private String path;
private AbstractAIFApplication app;
private TCSession session;
private ProgressReporter report;
@ -85,7 +83,7 @@ public class BOMImportDialog extends AbstractAIFDialog {
Registry registry;
public BOMImportDialog(AbstractAIFApplication app) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
super(false);
this.app = app;
this.session = (TCSession) app.getSession();
@ -180,8 +178,8 @@ public class BOMImportDialog extends AbstractAIFDialog {
@Override
public void run() {
// Auto-generated method stub
Registry.setString("BOM.PATH", file.getParent());
// TODO Auto-generated method stub
registry.setString("BOM.PATH", file.getParent());
try {
lists.clear();
report.setRequestCanceling(false);
@ -191,7 +189,7 @@ public class BOMImportDialog extends AbstractAIFDialog {
} catch (Exception e1) {
MessageBox.post("Error:" + e1.getMessage(), "", MessageBox.INFORMATION);
report.requestCanceling();
// Auto-generated catch block
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@ -223,14 +221,14 @@ public class BOMImportDialog extends AbstractAIFDialog {
@Override
public void run() {
// Auto-generated method stub
// TODO Auto-generated method stub
jfc.showOpenDialog(BOMImportDialog.this);
File f = jfc.getSelectedFile();
if (f != null) {
System.out.println("->" + f.getAbsolutePath());
jf.setText(f.getAbsolutePath());
Registry.setString("BOM.PATH", f.getParent());
registry.setString("BOM.PATH", f.getParent());
try {
lists.clear();
report.setRequestCanceling(false);
@ -240,7 +238,7 @@ public class BOMImportDialog extends AbstractAIFDialog {
} catch (Exception e1) {
MessageBox.post("Error:" + e1.getMessage(), "", MessageBox.INFORMATION);
report.requestCanceling();
// Auto-generated catch block
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@ -253,10 +251,9 @@ public class BOMImportDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@SuppressWarnings("deprecation")
@Override
public void run() {
// path = jf.getText();
path = jf.getText();
TCComponentBOMWindow win2 = null;
try {
TCComponent[] revList = productRev.getReferenceListProperty("revision_list");
@ -305,11 +302,11 @@ public class BOMImportDialog extends AbstractAIFDialog {
if (win2 != null) {
try {
win2.save();
// win2.unlock();
// win2.refresh();
win2.unlock();
win2.refresh();
win2.close();
} catch (TCException e) {
// Auto-generated catch block
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -330,7 +327,6 @@ public class BOMImportDialog extends AbstractAIFDialog {
}
// 创建框架BOM
@SuppressWarnings("deprecation")
public void createProductBom(TCComponentBOMLine topLine, List<BOMImportBean> lists,
Map<String, TCComponentItemRevision> id_revs, TCSession session, ProgressReporter reporter)
throws Exception {
@ -338,9 +334,9 @@ public class BOMImportDialog extends AbstractAIFDialog {
// topLine.save();
// topLine.unlock();
// topLine.refresh();;
// TCComponentItemType partType = (TCComponentItemType) session.getTypeComponent("Part");
TCComponentItemType partType = (TCComponentItemType) session.getTypeComponent("Part");
// List<TCComponentItemRevision> isAdd = new ArrayList<>();
List<TCComponentItemRevision> isAdd = new ArrayList<>();
int bl_sequence_no = 10;
new Thread(reporter).start();
reporter.setTaskRange(0, lists.size());
@ -357,13 +353,13 @@ public class BOMImportDialog extends AbstractAIFDialog {
System.out.println("item_id:" + bean.getItem_id() + ";bl_sequence_no:" + bl_sequence_no);
cout++;
childLine.save();
// childLine.unlock();//TODO
// childLine.refresh();
childLine.unlock();
childLine.refresh();
bl_sequence_no += 10;
}
topLine.save();
// topLine.unlock();
// topLine.refresh();
topLine.unlock();
topLine.refresh();
}
/*
@ -388,11 +384,11 @@ public class BOMImportDialog extends AbstractAIFDialog {
XSSFSheet sheet;
XSSFWorkbook workBook;
InputStream fis;
// OutputStream fos;
OutputStream fos;
fis = new FileInputStream(path);
// if (fis == null) {
// throw new Exception("读取到模板文件");
// }
if (fis == null) {
throw new Exception("读取到模板文件");
}
/*
* if(report==null) { report = new ProgressReporter(); }
*/

@ -21,9 +21,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCComponent;
@ -40,10 +38,6 @@ import com.teamcenter.rac.util.PropertyLayout;
public class CreateEDCGYDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private JButton btn_ok; // 确定
private JButton btn_cel; // 取消
@ -51,11 +45,9 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
private AbstractAIFApplication app;
private TCSession session;
private String len;//流水位数
public CreateEDCGYDialog(AbstractAIFApplication app) {
// Auto-generated constructor stub
// TODO Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
}
@ -63,25 +55,11 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
@Override
public void run() {
try {
len = "";
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_ApplyDrawNumber", session);
String groupID = SAPUtil.getGroupID(session);
for(String pref : prefs) {
String[] split = pref.split(":");
if(groupID.equals(split[0])) {
len = split[1];
break;
}
}
if(len.isEmpty()) {
MessageBox.post("当前登录组不在配置范围内,无法使用该功能", "", MessageBox.WARNING);
return;
}
initUI();
addListener();
showDialog();
} catch (Exception e) {
// : handle exception
// TODO: handle exception
MessageBox.post("界面初始化失败,error:" + e.getMessage(), "", MessageBox.INFORMATION);
e.printStackTrace();
}
@ -101,11 +79,11 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
createDesign();
} catch (Exception e1) {
// : handle exception
// TODO: handle exception
MessageBox.post("通用件工程图创建失败,error:" + e1.getMessage(), "", MessageBox.INFORMATION);
e1.printStackTrace();
}
@ -115,11 +93,11 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
// TODO Auto-generated method stub
try {
disposeDialog();
} catch (Exception e1) {
// : handle exception
// TODO: handle exception
e1.printStackTrace();
}
@ -192,7 +170,6 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
layout.setConstraints(comp, s);
}
@SuppressWarnings("deprecation")
private void createDesign() {
try {
@ -235,7 +212,7 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
* strs[1].charAt(i)<='9') { MessageBox.post(
* "请选择通用件标准图图纸版本","警告",MessageBox.WARNING); return; } } }
*/
// String object_name = rev.getProperty("object_name");
String object_name = rev.getProperty("object_name");
Map<String, String> fields = new HashMap<String, String>();
String value = item_id + "*";
@ -264,13 +241,13 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
KUtil.setByPass(false);
return;
}
// TCComponentItem item = rev.getItem();
TCComponentItem item = rev.getItem();
// item.
String rev_id = rev.getProperty("item_revision_id");
TCComponentItem saveAsItem = rev.saveAsItem(newID, rev_id);
TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder();// 获得NewStuff文件夹
TCComponentItemRevision newRev = saveAsItem.getLatestItemRevision();
// String object_name2 = newRev.getProperty("object_name");
String object_name2 = newRev.getProperty("object_name");
newRev.lock();
newRev.setProperty("zt2_DrawingNo", "");
newRev.setProperty("zt2_Specifications", spec);
@ -324,7 +301,7 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
}
}
private String getMaxValue(TCComponentContextList lists, String itemID) throws Exception {
private String getMaxValue(TCComponentContextList lists, String itemID) throws TCException {
int index = 0;
String id = itemID;
for (int i = 0; i < lists.getListCount(); i++) {
@ -342,8 +319,7 @@ public class CreateEDCGYDialog extends AbstractAIFDialog {
}
}
index = index + 1;
//TODO lidy20240920通过首选项流水码根据工厂配置流水位数
return id + "-" + String.format("%0" + len + "d", index);
return id + "-" + String.format("%05d", index);
}
public static void changeRef(TCComponentDataset dataset, String dataName, String item_id, String old_item_id) {

@ -1,82 +0,0 @@
package com.connor.chint.sap2.gylxgs;
public class GylxGsBatchImportBean {
// 序号
private int no;
// 图样代号
private String tydh;
// 工艺号
private String gyh;
// 工序号
private String gxh;
// 人工时间
private Double rgTime;
// 机器时间
private Double jqTime;
// 准备时间
private Double zbTime;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getTydh() {
return tydh;
}
public void setTydh(String tydh) {
this.tydh = tydh;
}
public String getGyh() {
return gyh;
}
public void setGyh(String gyh) {
this.gyh = gyh;
}
public String getGxh() {
return gxh;
}
public void setGxh(String gxh) {
this.gxh = gxh;
}
public Double getRgTime() {
return rgTime;
}
public void setRgTime(Double rgTime) {
this.rgTime = rgTime;
}
public Double getJqTime() {
return jqTime;
}
public void setJqTime(Double jqTime) {
this.jqTime = jqTime;
}
public Double getZbTime() {
return zbTime;
}
public void setZbTime(Double zbTime) {
this.zbTime = zbTime;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save