正泰客户端代码

pull/1/head
陈翼晖 2 years ago
commit 32488d1cd4

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<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"/>
<classpathentry kind="lib" path="lib/ojdbc7.jar"/>
<classpathentry kind="lib" path="json_lib/commons-beanutils-1.7.0.jar"/>
<classpathentry kind="lib" path="json_lib/commons-collections-3.2.jar"/>
<classpathentry kind="lib" path="json_lib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="json_lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="json_lib/ezmorph-1.0.4.jar"/>
<classpathentry kind="lib" path="json_lib/jdom.jar"/>
<classpathentry kind="lib" path="json_lib/json-lib-2.2.2-jdk15.jar"/>
<classpathentry kind="lib" path="json_lib/json-lib-2.2.3-jdk13.jar"/>
<classpathentry kind="lib" path="lib/sqljdbc4-2.0.jar"/>
<classpathentry kind="lib" path="lib/axis.jar"/>
<classpathentry kind="lib" path="lib/commons-discovery-0.2.jar"/>
<classpathentry kind="lib" path="lib/classes12.jar"/>
<classpathentry kind="lib" path="lib/javax.wsdl_1.6.2.v201012040545.jar"/>
<classpathentry kind="lib" path="lib/jaxrpc.jar"/>
<classpathentry kind="lib" path="lib/org.apache.commons.logging_1.1.1.v201101211721.jar"/>
<classpathentry kind="lib" path="lib/saaj.jar"/>
<classpathentry kind="lib" path="json_lib/jackson-databind-2.1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.5.2.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.11.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.5.2.jar"/>
<classpathentry kind="lib" path="soalib/S8SoaCustServerStrong_11000.2.0.jar"/>
<classpathentry kind="lib" path="soalib/S8SoaBypassStrong_11000.2.0.jar"/>
<classpathentry kind="lib" path="soalib/S8SoaBypassLoose_11000.2.0.jar"/>
<classpathentry kind="lib" path="soalib/S8SoaBypassTypes_11000.2.0.jar"/>
<classpathentry kind="lib" path="soalib/S8SoaCustServerLoose_11000.2.0.jar"/>
<classpathentry kind="lib" path="soalib/S8SoaCustServerTypes_11000.2.0.jar"/>
<classpathentry kind="lib" path="lib/json-org.jar" sourcepath="C:/Users/86183/AppData/Local/Temp/.org.sf.feeling.decompiler1655087337931/source/json-20160212-sources.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaCoreStrong_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaCoreTypes_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaClient_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaStrongModel_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaStructureManagementStrong_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaStructureManagementTypes_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaBomStrong_10000.1.0.jar"/>
<classpathentry kind="lib" path="soalib/TcSoaBomTypes_10000.1.0.jar"/>
<classpathentry kind="lib" path="poi/spire.pdf-3.4.2.jar"/>
<classpathentry kind="lib" path="mybatis/mybatis-3.5.6.jar"/>
<classpathentry kind="lib" path="poi/jacob.jar"/>
<classpathentry kind="lib" path="lib/jna-5.5.0.jar"/>
<classpathentry kind="lib" path="lib/commons-dbcp2-2.8.0.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/org.apache.commons.logging_1.2.0.v20180409-1502.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/fastjson2-2.0.15.jar"/>
<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="output" path="bin"/>
</classpath>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.connor.chint.sap2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

@ -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

@ -0,0 +1,107 @@
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0" targetNamespace="http://msg.chintwebservices.itf.nc/ISendMsgServices" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:ns0="http://msg.chintwebservices.itf.nc/ISendMsgServices" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" jaxb:version="2.0" targetNamespace="http://msg.chintwebservices.itf.nc/ISendMsgServices" xmlns:ns="http://msg.chintwebservices.itf.nc/ISendMsgServices">
<xsd:annotation>
<xsd:appinfo>
<jaxb:schemaBindings>
<jaxb:package name="nc.itf.chintwebservices.msg" />
</jaxb:schemaBindings>
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="chintSendMsgServices">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="string" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string1" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string2" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string3" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="chintSendMsgServicesResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="return" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="chintSendUrlMsgServices">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="string" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string1" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string2" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string3" nillable="true" type="xsd:string" />
<xsd:element minOccurs="0" name="string4" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="chintSendUrlMsgServicesResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="return" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="chintSendUrlMsgServicesRequest">
<wsdl:part element="ns0:chintSendUrlMsgServices" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="chintSendMsgServicesRequest">
<wsdl:part element="ns0:chintSendMsgServices" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="chintSendUrlMsgServicesResponse">
<wsdl:part element="ns0:chintSendUrlMsgServicesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="chintSendMsgServicesResponse">
<wsdl:part element="ns0:chintSendMsgServicesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ISendMsgServicesPortType">
<wsdl:operation name="chintSendMsgServices">
<wsdl:input message="ns0:chintSendMsgServicesRequest" wsaw:Action="urn:chintSendMsgServices">
</wsdl:input>
<wsdl:output message="ns0:chintSendMsgServicesResponse" wsaw:Action="urn:chintSendMsgServicesResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="chintSendUrlMsgServices">
<wsdl:input message="ns0:chintSendUrlMsgServicesRequest" wsaw:Action="urn:chintSendUrlMsgServices">
</wsdl:input>
<wsdl:output message="ns0:chintSendUrlMsgServicesResponse" wsaw:Action="urn:chintSendUrlMsgServicesResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ISendMsgServicesSOAP11Binding" type="ns0:ISendMsgServicesPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="chintSendMsgServices">
<soap:operation soapAction="urn:chintSendMsgServices" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="chintSendUrlMsgServices">
<soap:operation soapAction="urn:chintSendUrlMsgServices" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ISendMsgServices">
<wsdl:port binding="ns0:ISendMsgServicesSOAP11Binding" name="ISendMsgServicesSOAP11port_http">
<soap:address location="http://10.128.10.10/uapws/service/ChintSendMessage" />
</wsdl:port>
</wsdl:service>
<jaxws:bindings>
<jaxws:package name="nc.itf.chintwebservices.msg" />
</jaxws:bindings>
</wsdl:definitions>

@ -0,0 +1,131 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Sap2
Bundle-SymbolicName: com.connor.chint.sap2;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.connor.chint.sap2.Activator
Bundle-Vendor: CONNOR
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp;bundle-version="11000.2.0",
com.teamcenter.rac.common,
com.teamcenter.rac.kernel;bundle-version="11000.2.0",
com.teamcenter.rac.tcapps;bundle-version="11000.2.0",
com.teamcenter.rac.ui;bundle-version="11000.2.0",
com.teamcenter.rac.ui.commands;bundle-version="11000.2.0",
com.teamcenter.rac.external;bundle-version="11000.2.0",
org.apache.commons.discovery;bundle-version="0.2.0",
org.apache.commons.logging;bundle-version="1.0.4",
javax.wsdl;bundle-version="1.6.2",
javax.xml.rpc;bundle-version="1.1.0",
TcSoaCoreRac;bundle-version="11000.2.0",
TcSoaCoreTypes;bundle-version="11000.2.0",
TcSoaCommon;bundle-version="11000.2.0",
TcSoaStructureManagementRac;bundle-version="11000.2.0",
TcSoaStructureManagementTypes;bundle-version="11000.2.0",
com.teamcenter.rac.workflow;bundle-version="11000.2.0",
com.teamcenter.rac.workflow.processdesigner;bundle-version="11000.2.0",
com.teamcenter.rac.workflow.processviewer;bundle-version="11000.2.0",
com.teamcenter.rac.classification.icadmin;bundle-version="11000.2.0",
com.teamcenter.rac.classification.icm;bundle-version="11000.2.0",
com.teamcenter.rac.commonclient;bundle-version="11000.2.0",
TcSoaWorkflowRac;bundle-version="11000.2.0",
cn.net.connor.socket;bundle-version="1.0.0",
org.apache.poi.39;bundle-version="3.9.0",
TcSoaProjectManagementLoose;bundle-version="11000.2.0",
TcSoaProjectManagementRac;bundle-version="11000.2.0",
TcSoaProjectManagementTypes;bundle-version="11000.2.0",
org.apache.commons.httpclient;bundle-version="3.1.0",
TcSoaAdministrationLoose;bundle-version="11000.2.0",
TcSoaAdministrationRac;bundle-version="11000.2.0",
TcSoaAdministrationTypes;bundle-version="11000.2.0",
TcSoaCoreLoose;bundle-version="11000.2.0",
com.teamcenter.rac.schedule;bundle-version="11000.2.0",
org.eclipse.ui.navigator;bundle-version="3.5.200",
TcSoaCadRac;bundle-version="11000.2.0",
TcSoaCadTypes;bundle-version="11000.2.0",
com.teamcenter.rac.bom;bundle-version="11000.2.0",
TcSoaBomRac;bundle-version="11000.2.0",
TcSoaBomTypes;bundle-version="11000.2.0",
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"
Automatic-Module-Name: com.connor.chint.sap2
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
lib/sqljdbc4-2.0.jar,
json_lib/commons-beanutils-1.7.0.jar,
json_lib/commons-collections-3.2.jar,
json_lib/commons-lang-2.4.jar,
json_lib/commons-logging-1.1.jar,
json_lib/ezmorph-1.0.4.jar,
json_lib/jdom.jar,
json_lib/json-lib-2.2.2-jdk15.jar,
json_lib/json-lib-2.2.3-jdk13.jar,
lib/ojdbc7.jar,
lib/httpclient-4.5.2.jar,
lib/httpcore-4.4.11.jar,
lib/httpmime-4.5.2.jar,
mybatis/mybatis-3.5.6.jar,
poi/itextpdf-5.5.11.jar,
poi/jacob.jar,
lib/fastjson2-2.0.15.jar,
lib/guava-31.1-jre.jar,
lib/hutool-all-5.8.8.jar,
lib/swingx-1.6.1.jar,
lib/mysql-connector-java-8.0.12.jar,
poi/okhttp-2.7.4.jar,
poi/okio-1.13.0.jar
Export-Package: com.connor.chint.sap2,
com.connor.chint.sap2.assignfactoryno,
com.connor.chint.sap2.bombuilder,
com.connor.chint.sap2.checkDesign,
com.connor.chint.sap2.commands,
com.connor.chint.sap2.createECN,
com.connor.chint.sap2.dialogs,
com.connor.chint.sap2.downloadFiles,
com.connor.chint.sap2.general,
com.connor.chint.sap2.gykg.commands,
com.connor.chint.sap2.material_m,
com.connor.chint.sap2.material_query,
com.connor.chint.sap2.material_spec,
com.connor.chint.sap2.materialno,
com.connor.chint.sap2.materialno.bean,
com.connor.chint.sap2.mes_meop,
com.connor.chint.sap2.mybatis,
com.connor.chint.sap2.mybatis.dao,
com.connor.chint.sap2.operation,
com.connor.chint.sap2.partDownload,
com.connor.chint.sap2.proc,
com.connor.chint.sap2.proc_by,
com.connor.chint.sap2.proc_dycc,
com.connor.chint.sap2.proc_gy,
com.connor.chint.sap2.proc_jyz,
com.connor.chint.sap2.proc_zy,
com.connor.chint.sap2.proc_zykg,
com.connor.chint.sap2.projcreate_formal,
com.connor.chint.sap2.projcreate_temp,
com.connor.chint.sap2.projectTest,
com.connor.chint.sap2.project_product,
com.connor.chint.sap2.replace,
com.connor.chint.sap2.report,
com.connor.chint.sap2.sap_by,
com.connor.chint.sap2.sap_dy,
com.connor.chint.sap2.sap_gy,
com.connor.chint.sap2.sap_jyz,
com.connor.chint.sap2.sap_zy,
com.connor.chint.sap2.sap_zykg,
com.connor.chint.sap2.setProperty,
com.connor.chint.sap2.stylesheet,
com.connor.chint.sap2.task_by,
com.connor.chint.sap2.util,
com.connor.chint.sap2.zykg.CreateProductionChange,
com.connor.chint.sap2.zykg.command,
com.microsoft.sqlserver.jdbc,
com.xinhua.mes.intf.core.webservice,
nc.itf.chintwebservices.msg.ISendMsgServices,
plm.xi.com.chintelectric
Import-Package: org.apache.commons.httpclient
Bundle-RequiredExecutionEnvironment: JavaSE-1.8,
JavaSE-1.7

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" id="WebApp_ID">
<display-name>com.connor.chint.sap2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace=""></mapper>
<!--
<mapper namespace="CHINTMaterial">
<select id="selectUsers" resultType="CHINTMaterial">
SELECT * FROM CHINT_ECN_FLOW
</select>
</mapper>
-->

@ -0,0 +1,485 @@
package com.connor.chint.sap2.assignfactoryno;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.Map.Entry;
import javax.swing.JTextField;
import org.apache.commons.collections.map.HashedMap;
import com.connor.chint.sap2.bean.FactoryNoBean;
import com.connor.chint.sap2.bean.FlowNoBean;
import com.connor.chint.sap2.bombuilder.BomBuildDialogController;
import com.connor.chint.sap2.sap_zy.FlowBean;
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.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.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.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_REQ;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_REQBASEINFO;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_REQITEMSITEM;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_RSP;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_RSPRSP_BASEINFO;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_RSPZTABLE_RETURN;
import plm.xi.com.chintelectric.SI_FACTORY_NUMBER_PLM_OUT_SYN;
import plm.xi.com.chintelectric.SI_FACTORY_NUMBER_PLM_OUT_SYNService;
import plm.xi.com.chintelectric.SI_FACTORY_NUMBER_PLM_OUT_SYNServiceLocator;
public class FactoryCCController {
private FactoryCCDialog dialog;
private AbstractAIFApplication app;
private List<String> factoryNos = new ArrayList<>();
public FactoryCCController(AbstractAIFApplication app,FactoryCCDialog dialog) {
// TODO Auto-generated constructor stub
this.dialog = dialog;
this.app = app;
}
//获取产成品型号对应的前缀集合
public Map<String, String> getFactoryTypes(String preference,TCSession session)
{
Map<String, String> map = new HashedMap(16);
String[] prefs = ChintPreferenceUtil.getPreferences(preference, session);
String[] values = null;
String[] types = null;
String value = "";
for(int i=0,len = prefs.length;i<len;i++)
{
values = prefs[i].split(":");
if(values.length!=2)
continue;
value = values[0];
types = values[1].split(";");
for(int j=0,len2 = types.length;j<len2;j++)
{
map.put(types[j], value);
}
}
//System.out.println("map:"+map);
return map;
}
public List<FactoryNoBean> getCCPList(TCComponent ccp_Folder,Map<String, String> map,
Map<String, FlowNoBean> map_FlowNos) throws Exception
{
List<FactoryNoBean> list = new ArrayList<>(32);
AIFComponentContext[] childs = ccp_Folder.getChildren();
TCComponent[] contexts = null;
FactoryNoBean bean = null;
int index = 1;
String zt2_Site = "";
String zt2_MaterialNo ="";
String object_name = "";
String prefix = "";
String zt2_TankNo ="";
List<TCComponent> factoryNos = null; //出厂编号对象集合
List<String> factoryIDs = null; //出厂编号ID集合
TCComponentItemRevision rev = null;
List<String> types = new ArrayList<>(map.keySet());
String type = "";
String factoryID = "";
String flowNo ="";
FlowNoBean flowBean = null;
String time = new Date().getYear()%100 + String.format("%02d",new Date().getMonth()+1);
String temp = "";
for(int i=0,len = childs.length;i<len;i++)
{
flowNo = "";
temp ="";
if(childs[i].getComponent().getType().equals("Part"))
{
rev = ((TCComponentItem)childs[i].getComponent()).getLatestItemRevision();
zt2_Site = rev.getProperty("zt2_Site");
zt2_MaterialNo = rev.getProperty("zt2_MaterialNo");
object_name = rev.getProperty("object_name");
zt2_TankNo = rev.getProperty("zt2_TankNo");
type = KUtil.inArray2(object_name, types);
if(!KUtil.isEmpty(type))
{
prefix = map.get(type);
System.out.println("prefix:"+prefix);
if(map_FlowNos.containsKey(prefix))
{
flowBean = map_FlowNos.get(prefix);
flowBean.addSize();;
}else
{
flowBean = new FlowNoBean(prefix);
map_FlowNos.put(prefix, flowBean);
}
contexts = rev.getRelatedComponents("ZT2_FactoryNumber");
if(contexts.length>0)
{
factoryID = contexts[0].getProperty("item_id");
temp = factoryID;
flowNo = factoryID.substring(factoryID.length()-4, factoryID.length());
temp = temp.substring(factoryID.length()-8, factoryID.length()-4);
prefix = factoryID.replaceAll(temp, "").replaceAll(flowNo, "");
flowBean.addIDs(factoryID);
}else
{
if(prefix.endsWith("DX"))
dialog.isHave = true;
temp = time;
}
if(contexts.length>0 && contexts[0].getProperty("item_id").contains(prefix))
{
factoryID = contexts[0].getProperty("item_id");
temp = factoryID.replaceAll(prefix, "");
temp = temp.substring(temp.length()-8, temp.length()-4);
flowNo = factoryID.substring(factoryID.length()-4, factoryID.length());
flowBean.addIDs(factoryID);
}else
{
temp = time;
}
}else
{
throw new Exception("产成品["+rev+"]未能匹配出厂编号规则。");
}
}
System.out.println("rev:"+rev+";flowNo:"+flowNo);
factoryNos = new ArrayList<>(8);
factoryIDs = new ArrayList<>(8);
bean = new FactoryNoBean(rev, factoryNos, factoryIDs,
zt2_MaterialNo, object_name, zt2_Site, zt2_TankNo,
"", i+1, prefix, flowNo);
bean.time = temp;
list.add(bean);
}
System.out.println("map_FlowNos:"+map_FlowNos);
return list;
}
private Map<String, TCComponentItemRevision> factoryNo_Products = new HashedMap();
public List<FactoryNoBean> getCCPList2(TCComponent ccp_Folder,Map<String, String> map,
Map<String, FlowNoBean> map_FlowNos) throws Exception
{
List<FactoryNoBean> list = new ArrayList<>(32);
AIFComponentContext[] childs = ccp_Folder.getChildren();
TCComponent[] contexts = null;
FactoryNoBean bean = null;
int index = 1;
String zt2_Site = "";
String zt2_MaterialNo ="";
String object_name = "";
String prefix = "";
String zt2_TankNo ="";
List<TCComponent> factoryNos = null; //出厂编号对象集合
List<String> factoryIDs = null; //出厂编号ID集合
TCComponentItemRevision rev = null;
List<String> types = new ArrayList<>(map.keySet());
String type = "";
String factoryID = "";
String flowNo ="";
FlowNoBean flowBean = null;
String time = new Date().getYear()%100 + String.format("%02d",new Date().getMonth()+1);
String temp = "";
String zt2_Quantity = "";
TCComponent[] factorys;
int[] indexs;
for(int i=0,len = childs.length;i<len;i++)
{
flowNo = "";
temp ="";
if(childs[i].getComponent().getType().equals("Part"))
{
rev = ((TCComponentItem)childs[i].getComponent()).getLatestItemRevision();
zt2_Site = rev.getProperty("zt2_Site");
zt2_MaterialNo = rev.getProperty("zt2_MaterialNo");
object_name = rev.getProperty("object_name");
zt2_TankNo = rev.getProperty("zt2_TankNo");
type = KUtil.inArray2(object_name, types);
zt2_Quantity = rev.getStringProperty("zt2_Quantity");
if (KUtil.isEmpty(zt2_Quantity)) {
zt2_Quantity = "1";
indexs = new int[] { 1 };
} else {
int size = POIUtil.getIntValue(zt2_Quantity)==0?1:POIUtil.getIntValue(zt2_Quantity);
indexs = new int[size];
}
factorys = rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO);
factoryNos = new ArrayList<>();
factoryIDs = new ArrayList<String>();
//ZT2_FactoryNumber
if (factorys != null && factorys.length > 0) {
for (int j = 0; j < factorys.length; j++) {
factoryID = factorys[j].getProperty("item_id");
factoryNos.add(factorys[j]);
factoryIDs.add(factoryID);
factoryNo_Products.put(factoryID, rev);
}
//isHaveFactoryNo = true;
}else
{
if(!KUtil.isEmpty(type))
{
prefix = map.get(type);
}else
{
throw new Exception("产成品"+rev+"未能匹配出厂编号分配规则");
}
}
}
}
if (list.size() > 0) {
Collections.sort(list, new Comparator<FactoryNoBean>() {
@Override
public int compare(FactoryNoBean o1, FactoryNoBean o2) {
// TODO Auto-generated method stub
return o1.getZt2_MaterialNo().compareTo(o2.getZt2_MaterialNo());
}
});
}
return list;
}
/**
* 根据前缀获得流水码
* DX类型特殊处理
* @param beans
* @param session
* @throws Exception
*/
public void getFlowNo(Map<String, FlowNoBean> beans,TCSession session) throws Exception
{
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if(SqlUtil.getTCDataConnection(prefs)==null)
{
throw new Exception("无法连接数据库,请检查首选项<database_tc>配置。");
}
String time = new Date().getYear()%100 + String.format("%02d",new Date().getMonth()+1);
FlowNoBean bean = null;
FlowNoBean clone = null;
if(beans.containsKey("DX"))
{
System.out.println("包含");
bean = beans.get("DX");
clone = (FlowNoBean) bean.clone();
clone.setPrefix("DX1");
beans.put("DX1", clone);
clone = (FlowNoBean) bean.clone();
clone.setPrefix("DX3");
beans.put("DX3", clone);
beans.remove("DX");
}
List<String> types = new ArrayList<>(beans.keySet());
StringBuffer buff = new StringBuffer(64);
buff.append("(");
int len = types.size();
for(int i=0;i<len-1;i++)
{
buff.append("?").append(",");
}
buff.append("?").append(")");
types.add(time);
String sql = "select type,time,flow from \"CHINT_M008_FactoryNo\" where 1=1 ";
sql+=" and type in "+buff.toString() +" and time = ?";
System.out.println("sql:"+sql);
ResultSet rs = SqlUtil.read(sql,types.toArray(new Object[types.size()]));
String type = "";
String flow = "";
while(rs.next())
{
type = rs.getString(1);
flow = rs.getString(3);
bean = beans.get(type);
bean.isInsert = false;
bean.setStart(POIUtil.getIntValue(flow));
}
SqlUtil.free();
System.out.println("beans:"+beans);
}
public void autoAssign(Map<String, FlowNoBean> beans)
{
factoryNos.clear();
int rowCount = dialog.t_bom.getRowCount();
FactoryNoBean bean = null;
FlowNoBean flowBean = null;
String type = "";
int flow = 0;
System.out.println("beans:"+beans);
String item_id = "";
for(int i=0;i<rowCount;i++)
{
bean = (FactoryNoBean) dialog.t_bom.getValueAt(i, 3);
String val = (String) dialog.t_bom.getValueAt(i, 6);
if(KUtil.isEmpty(val))
{
type = bean.getPrefix();
System.out.println("type:"+type);
flowBean = beans.get(type);
flow = flowBean.getStart();
flowBean.setStart(flow+1);
dialog.t_bom.setValueAt(bean.getPrefix()+bean.time, i, 5);
dialog.t_bom.setValueAt(String.format("%04d", flow), i, 6);
item_id = bean.getPrefix()+bean.time+String.format("%04d", flow);
flowBean.addIDs(item_id);
}else
{
item_id = bean.getPrefix()+bean.time+val;
}
factoryNos.add(item_id);
}
}
public void assign(Map<String, FlowNoBean> beans,TCSession session,TCComponent ccbh_Folder) throws Exception
{
int rowCount = dialog.t_bom.getRowCount();
FactoryNoBean bean = null;
FlowNoBean flowBean = null;
Map<String, TCComponent> maps = new HashedMap(16);
StringBuffer buff = new StringBuffer();
String item_id = "";
String prefix = "";
for(int i=0;i<rowCount;i++)
{
bean = (FactoryNoBean) dialog.t_bom.getValueAt(i, 3);
String val = (String) dialog.t_bom.getValueAt(i, 6);
if(KUtil.isEmpty(val))
{
buff.append("第"+(i+1)+"行未分配出厂编号");
continue;
}
item_id = bean.getPrefix()+bean.time+val;
if(maps.containsKey(item_id))
{
buff.append("第"+(i+1)+"行重复分配出厂编号");
continue;
}
maps.put(item_id, null);
if(!factoryNos.contains(item_id))
{
prefix = bean.getPrefix();
flowBean = beans.get(prefix);
if(!flowBean.getIds().contains(item_id))
{
buff.append("第"+(i+1)+"行出厂编号不在可分配范围");
continue;
}
}
}
if(buff.toString().length()>0)
{
throw new Exception(buff.toString());
}
for(String id:maps.keySet())
{
TCComponent[] items = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id });
if (items == null || items.length == 0) {
TCComponentItem item = KUtil.newItem(session, BomBuildDialogController.TYPE_FACTORYNO, id, "出厂编号");
ccbh_Folder.add("contents", item);
maps.put(id, item);
}else
{
maps.put(id, items[0]);
}
}
String type="";
String flowNo = "";
String sql_update = "update \"CHINT_M008_FactoryNo\" set flow =? where type =? and time = ?";
String sql_insert = "insert into \"CHINT_M008_FactoryNo\"(flow,type,time) values(?,?,?) ";
Object[] obj = new Object[3];
String time = new Date().getYear()%100 + String.format("%02d",new Date().getMonth()+1);
TCComponentItemRevision rev = null;
for(int i=0;i<rowCount;i++)
{
bean = (FactoryNoBean) dialog.t_bom.getValueAt(i, 3);
String val = (String) dialog.t_bom.getValueAt(i, 6);
item_id = bean.getPrefix()+bean.time+val;
rev = bean.getRev();
TCComponent[] comps = rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO);
rev.cutOperation(BomBuildDialogController.REL_FACTORYNO, comps);
rev.add(BomBuildDialogController.REL_FACTORYNO, maps.get(item_id));
}
for(String key:beans.keySet())
{
flowBean = beans.get(key);
type = key;
flowNo = flowBean.getStart()+"";
obj[0] = flowNo;
obj[1] = type;
obj[2] = time;
if(flowBean.isInsert)
{
SqlUtil.write(obj, sql_insert);
}else
{
SqlUtil.write(obj, sql_update);
}
SqlUtil.free();
}
MessageBox.post("出厂编号分配完成","",2);
}
}

@ -0,0 +1,342 @@
package com.connor.chint.sap2.assignfactoryno;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import org.apache.commons.collections.map.HashedMap;
import com.connor.chint.sap2.bean.FactoryNoBean;
import com.connor.chint.sap2.bean.FlowNoBean;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.ProgressBar;
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.PreferenceObject;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCPreferenceService.TCPreferenceLocation;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_REQITEMSITEM;
public class FactoryCCDialog extends AbstractAIFDialog{
private TCSession session;
private FactoryCCController controller;
private AbstractAIFApplication app;
protected DefaultTableModel tm_bom;
protected JTable t_bom;
private JButton b_assign;
protected JButton b_autoAssign;
public static final String[] HEADER = new String[] { "序号","站点","柜号","物料编码", "物料名称", "出厂编码前缀", "出厂编号流水码" };
public static final int[] HEADERWIDTH = new int[] { 50, 150, 150, 150 ,150, 150, 150};
private String preference = "CHINT_M030_Factory";
private Map<String, String> map_types = null;
//项目零组件
private TCComponent project ;
//出厂编号
private TCComponent ccbh_Folder;
//产成品文件夹
private TCComponent ccp_Folder ;
private List<FactoryNoBean> list_ccps ;
private Map<String, FlowNoBean> map_FlowNos ;
protected boolean isHave = false; //针对DX
public FactoryCCDialog(AbstractAIFApplication app, String actionInfo) {
super(false);
this.app = app;
this.session = (TCSession) app.getSession();
this.controller = new FactoryCCController(app,this);
}
@Override
public void run() {
InterfaceAIFComponent target = app.getTargetComponent();
if(target==null || !target.getType().equals("ZT2_ProjectItem"))
{
MessageBox.post("请选择项目零组件","",2);
return ;
}
project = (TCComponent) target;
initUI();
showDialog();
new Thread(new Runnable() {
@Override
public void run() {
map_types = controller.getFactoryTypes(preference, session);
map_FlowNos = new HashedMap(8);
try {
ccp_Folder = KUtil.getCCPFolderFromProject(project);
ccbh_Folder = KUtil.getCCBHFolderFromProject(project);
if(ccp_Folder==null)
{
MessageBox.post("未找到产成品文件夹,请检查项目数据","",2);
disposeDialog();
return ;
}
if(ccp_Folder==null)
{
MessageBox.post("未找到出厂编号文件夹,请检查项目数据","",2);
disposeDialog();
return ;
}
list_ccps = controller.getCCPList(ccp_Folder, map_types,map_FlowNos);
if(list_ccps.size()==0)
{
MessageBox.post("未找到产成品对象,请检查项目数据","",2);
disposeDialog();
return ;
}
for(int i=0,len = list_ccps.size();i<len;i++)
{
tm_bom.addRow(list_ccps.get(i).getCCRowData());
}
controller.getFlowNo(map_FlowNos, session);
}catch (Exception e) {
e.printStackTrace();
MessageBox.post("异常:"+e.getMessage(),"",2);
disposeDialog();
}
}
}).start();
addListeners();
}
private void addListeners() {
//分配出厂编号流水码
b_autoAssign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
KUtil.stopTableEditing(t_bom);
if(isHave)
{
String result = new DXDialog(FactoryCCDialog.this).result;
if(KUtil.isEmpty(result))
return;
FactoryNoBean bean = null;
for(int i=0,len = list_ccps.size();i<len;i++)
{
bean = list_ccps.get(i);
if(bean.getPrefix().equals("DX") && bean.getFactoryIDs().size()==0)
{
bean.setPrefix(result);
}
}
}
controller.autoAssign(map_FlowNos);
b_assign.setEnabled(true);
b_autoAssign.setEnabled(false);
}
});
b_assign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
KUtil.stopTableEditing(t_bom);
try {
controller.assign(map_FlowNos, session, ccbh_Folder);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
b_assign.setEnabled(false);
}
}).start();
}
});
}
private void initUI() {
this.setTitle("分配出厂编号");
this.setPreferredSize(new Dimension(1180,480));
this.setMinimumSize(new Dimension(400,300));
this.setLayout(new BorderLayout());
this.add(BorderLayout.NORTH,getBtnPanel());
this.add(BorderLayout.CENTER,getTablePanel());
}
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
tm_bom = new DefaultTableModel();
t_bom = new JTable(tm_bom) {
@Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if(column==6)
{
return true;
}
return false;
}
};
tm_bom.setDataVector(null, HEADER);
t_bom.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_bom.setRowHeight(23);
TableColumnModel colModel = this.t_bom.getColumnModel();
int colCnt = HEADERWIDTH.length;
colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]);
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
JScrollPane scroll = new JScrollPane(t_bom);
panel.add(BorderLayout.CENTER, scroll);
return panel;
}
private JPanel getBtnPanel() {
JPanel panel = new JPanel(new BorderLayout());
JPanel panel3 = new JPanel();
b_autoAssign = new JButton("自动分配出厂编号");
panel3.add(b_autoAssign);
b_assign = new JButton("保存出厂编号");
panel3.add(b_assign);
panel.add(BorderLayout.EAST,panel3);
return panel;
}
//如果包含DX则弹框
private class DXDialog extends AbstractAIFDialog
{
public String result = "";
private JComboBox<String> jcom;
private JButton b_ok;
private JButton b_ch;
public DXDialog(AbstractAIFDialog parent) {
// TODO Auto-generated constructor stub
super(parent,true);
initUI(null);
addListener();
showDialog();
}
private void initUI(Dimension dim)
{
this.setTitle("");
if(dim==null)
{
this.setPreferredSize(new Dimension(250,200));
}else
{
this.setPreferredSize(dim);
}
//this.setMinimumSize(new Dimension(370,280));
JPanel panel = new JPanel(new FlowLayout());
JLabel label = new JLabel("DX类型选择");
jcom = new JComboBox<>(new String[] {"DX1","DX3"});
panel.add(label);
panel.add(jcom);
this.setLayout(new FlowLayout(FlowLayout.CENTER,15,20));
JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER,15,20));
b_ok = new JButton("是");
b_ch = new JButton("否");
panel2.add(b_ok);
panel2.add(b_ch);
this.add(BorderLayout.CENTER,panel);
this.add(BorderLayout.SOUTH,panel2);
}
private void addListener()
{
b_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(jcom.getSelectedItem().equals("DX1"))
{
result = "DX1";
}else
{
result = "DX3";
}
disposeDialog();
}
});
b_ch.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
disposeDialog();
}
});
}
}
}

@ -0,0 +1,661 @@
package com.connor.chint.sap2.assignfactoryno;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.PreferenceObject;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCPreferenceService.TCPreferenceLocation;
import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("serial")
public class FactoryNoZYDialog extends AbstractAIFDialog{
private FactoryNoZYDialogController controller;
private TCSession session;
private TCPreferenceService prefService=null ;
private AbstractAIFApplication app;
protected DefaultTableModel tm_bom;
protected JTable t_bom;
protected int createCode = 0;//用来标记新分配的还是旧的之间调整属性0新建1调整
private JButton b_assign;
private JButton n_assign;
protected JTextField jtf_zcy ;//
protected JPanel panel ;//
protected JPanel panel2 ;//
protected JPanel panel3 ;//
protected JTextField jtf_zcg ;
protected JTextField jtf_bj ;
protected JTextField jtf_mxq ;
public static final String[] HEADER = new String[] { "序号","站点","柜号","物料编码", "物料名称", "出厂编码前缀", "出厂编号流水码" };
public static final int[] HEADERWIDTH = new int[] { 50, 150, 150, 150 ,150, 150, 150};
public TCComponentFolder factorNoFolder;
// String zt2_ZY = "zt2_ZY";
public boolean fNum_flag = false;
protected TCComponentForm lsmForm=null;
private String actionInfo;
protected String qz="";
protected int lsmMax=0;
protected int lsmMin = 0;
public FactoryNoZYDialog(AbstractAIFApplication app, String actionInfo) {
super(false);
this.controller = new FactoryNoZYDialogController(app,this,actionInfo);
this.app = app;
this.session = (TCSession) app.getSession();
prefService=session.getPreferenceService();
KUtil.setByPass(true);
System.out.println("actionInfo>>"+actionInfo);
// lsmForm = getForm(actionInfo);//把ZCY类型的月份和前缀放在一张指定的form表中
// getFNumber(lsmForm,"ZCY");//每月重置,但是现在新加入三种类型,这种方式不适用,要么用中间表的形式,要么用首选项的形式
resetFlowNumner();
KUtil.setByPass(false);
}
public void disconnect(Connection conn,Statement stmt, ResultSet rs_get) {
try {
if (rs_get != null) {
rs_get.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public Connection connect(Connection conn) {
String[] database=session.getPreferenceService().getStringValues("database_tc");
String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@10.128.18.139:1521:testdb";//测试系统
strUrl="jdbc:oracle:thin:@"+database[0]+":"+database[1]+":"+database[2];
String strUserName = "infodba";
strUserName=database[3];
String strPassword = "infodba";
strPassword=database[4];
try {
Class.forName(JdbcDriverClass);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
try {
conn = DriverManager.getConnection(strUrl, strUserName, strPassword);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
private void resetFlowNumner() {
try {
Connection conn=null;
conn=connect(conn);
String query="select * from CHINT_FLOW";
Statement stmt = conn.createStatement();
ResultSet rs_get = null;
rs_get = stmt.executeQuery(query);
List<String> sqlList=new ArrayList<>();
while (rs_get.next()) {
String type=rs_get.getString("TYPE");
String time=rs_get.getString("TIME");
// String flow=rs_get.getString("FLOW");
String code=type+time+"001";
TCComponent[] comps= session.search("零组件...", new String[] {"零组件 ID"}, new String[] {code});
if(comps.length==0) {
System.out.println("重置当月流水码");
sqlList.add("update CHINT_FLOW set FLOW='001' where TYPE='"+type+"' and TIME='"+time+"'");
}else if(comps.length==1) {
System.out.println("已重置当月流水码");
}
}
//
if (rs_get != null) {
rs_get.close();
}
for (int i = 0; i < sqlList.size(); i++) {
String sql=sqlList.get(0);
rs_get = stmt.executeQuery(sql);
if(rs_get.next()) {
System.out.println("update =====");
}
if (rs_get != null) {
rs_get.close();
}
}
disconnect( conn, stmt, rs_get);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
private TCComponentForm getForm(String prefix)
{
if (prefix == null) {
prefix = "";
}
prefix = "TEST";
String prefName = "ZT2_FactoryNo_" + prefix;
TCPreferenceService prefService = session.getPreferenceService();
try {
prefService.refresh();
TCPreferenceLocation loc = TCPreferenceLocation.OVERLAY_LOCATION;
PreferenceObject pref = prefService.getPreferenceObjectAtLocation(prefName, loc);
String uid = prefService.getStringValue(prefName);
System.out.println("首选项的值:"+uid);
TCComponent comp = session.stringToComponent(uid);
System.out.println("选中的表单:"+comp);
if(comp!=null && comp instanceof TCComponentForm)
{
return (TCComponentForm) comp;
}
} catch (TCException e) {
e.printStackTrace();
}
return null;
}
@Override
public void run() {
initUI();
addListeners();
new Thread(new Runnable() {
@Override
public void run() {
KUtil.setByPass(true);
ProgressBar pb = new ProgressBar(FactoryNoZYDialog.this, new Dimension(250, 50));
setCompEnabled(false);
try {
/*if(lsmForm==null)
{
throw new Exception("获取流水码信息异常,请检查首选项");
}*/
controller.readData(pb);
pb.disposeDialog();
KUtil.setByPass(false);
} catch (Exception e) {
KUtil.setByPass(false);
pb.disposeDialog();
MessageBox.post(FactoryNoZYDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace();
}
setCompEnabled(true);
//重设流水码范围:增加判断,如果出厂编号对象已经存在,那么流水码显示范围就是原来的范围
reFlow();
}
}).start();
showDialog();
}
protected void reFlow() {
int row=t_bom.getRowCount();
Map<String, List<String>> FlowMap=new HashMap<>();
// System.out.println("row===="+row);
FlowMap.put("ZCY", new ArrayList<String>());
FlowMap.put("ZCG", new ArrayList<String>());
FlowMap.put("BJ", new ArrayList<String>());
FlowMap.put("MXQ", new ArrayList<String>());
for (int i = 0; i < row; i++) {
String mapKey=(String) t_bom.getValueAt(i, 5);
String mapValue=(String) t_bom.getValueAt(i, 6);
if(mapKey==null||mapValue==null) {
continue;
}
// System.out.println(mapKey+mapValue);
if(mapValue.length()>0) {
createCode=1;
}
for(Map.Entry<String, List<String>> me:FlowMap.entrySet()) {
if(mapKey.startsWith(me.getKey())) {
me.getValue().add(mapValue);
}
}
}
if(createCode==1) {
for(Map.Entry<String, List<String>> me:FlowMap.entrySet()) {
List<String> list=me.getValue();
if(list.size()==0) {
continue;
}
String[] strings=new String[list.size()];
for (int i = 0; i < strings.length; i++) {
strings[i]=list.get(i);
}
Arrays.sort(strings);
String ss=me.getKey()+":"+strings[0]+"-"+strings[strings.length-1];
// System.out.println(ss);
// System.out.println(me.getKey()+":");
if(jtf_zcy.getText().startsWith(me.getKey()+":")) {
jtf_zcy.setText(ss);
}
if(jtf_zcg.getText().startsWith(me.getKey()+":")) {
jtf_zcg.setText(ss);
}
if(jtf_bj.getText().startsWith(me.getKey()+":")) {
jtf_bj.setText(ss);
}
if(jtf_mxq.getText().startsWith(me.getKey()+":")) {
jtf_mxq.setText(ss);
}
}
n_assign.setEnabled(false);
}
}
protected void setCompEnabled(boolean b) {
b_assign.setEnabled(b);
t_bom.setEnabled(b);
}
public int flowStart(String start){
int startNUm=0;
if(start.length()==0) {
return startNUm;
}else {
startNUm=Integer.valueOf(start.split(":")[1].split("-")[0]);
return startNUm;
}
}
private void addListeners() {
//分配出厂编号流水码
n_assign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if(!controller.checkXMFJ())
{
MessageBox.post("未检测到项目附件,不能分配出厂编号", "", MessageBox.INFORMATION);
return;
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int index2=t_bom.getRowCount();
SimpleDateFormat sdf=new SimpleDateFormat("yyMM");
Date date=new Date();
String dateString=sdf.format(date);
int zcy=flowStart(jtf_zcy.getText());
int zcg=flowStart(jtf_zcg.getText());
int bj=flowStart(jtf_bj.getText());
int mxq=flowStart(jtf_mxq.getText());
String[] types=prefService.getStringValues("zt2_byq_type");
Map<String, String> typeMap=new HashMap<>();
for (int i = 0; i < types.length; i++) {
typeMap.put(types[i].split(":")[0], types[i].split(":")[1]);
}
for (int i = 0; i < index2; i++) {
String prefix0= (String) t_bom.getValueAt(i, 4);
String prefix="";
for(Map.Entry<String, String> me:typeMap.entrySet()) {
String[] names=me.getValue().split(";");
for (int j = 0; j < names.length; j++) {
if(prefix0.contains(names[j])) {
prefix=me.getKey();
break;
}
}
}
t_bom.setValueAt(prefix+dateString, i, 5);
switch(prefix) {
case "ZCY":
t_bom.setValueAt(String.format("%03d", zcy), i,6);
zcy++;
break;
case "ZCG":
t_bom.setValueAt(String.format("%03d", zcg), i,6);
zcg++;
break;
case "BJ":
t_bom.setValueAt(String.format("%03d", bj), i,6);
bj++;
break;
case "MXQ":
t_bom.setValueAt(String.format("%03d", mxq), i,6);
mxq++;
break;
default:
break;
}
}
}
});
b_assign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
ProgressBar pb = new ProgressBar(FactoryNoZYDialog.this, new Dimension(250, 50));
KUtil.setByPass(true);
setCompEnabled(false);
try {
// controller.assign(pb);
controller.assign(pb,0,createCode);//检验,新建等
//将项目启动->出厂编号下面的文件重新排序
if(createCode==0) {
sorting();
}
pb.disposeDialog();
} catch (Exception e1) {
KUtil.setByPass(false);
pb.disposeDialog();
MessageBox.post(FactoryNoZYDialog.this, "分配出厂编号发生异常:" + e1.getMessage(), "", MessageBox.ERROR);
controller.recovery();
setCompEnabled(true);
e1.printStackTrace();
}
KUtil.setByPass(false);
setCompEnabled(true);
}
}).start();
}
});
}
private void sorting() {
try {
TCComponent project=(TCComponent) app.getTargetComponent();
TCComponent[] folders=project.getRelatedComponents("IMAN_reference");
for (int j = 0; j < folders.length; j++) {
if(folders[j].getProperty("object_name").equals("项目启动")) {
TCComponent[] folders2=folders[j].getRelatedComponents("contents");
for (int k = 0; k < folders2.length; k++) {
if(folders2[k].getProperty("object_name").equals("出厂编号")) {
TCComponent[] items=folders2[k].getRelatedComponents("contents");
List<TCComponent> zcyList=new ArrayList<>();
List<TCComponent> zcgList=new ArrayList<>();
List<TCComponent> mxqList=new ArrayList<>();
List<TCComponent> bjList=new ArrayList<>();
List<TCComponent> otherList=new ArrayList<>();
for (int i = 0; i < items.length; i++) {
String id=items[i].getProperty("item_id");
if(id.startsWith("ZCY")) {
zcyList.add(items[i]);
}else if(id.startsWith("ZCG")) {
zcgList.add(items[i]);
}else if(id.startsWith("MXQ")) {
mxqList.add(items[i]);
}else if(id.startsWith("BJ")) {
bjList.add(items[i]);
}else {
otherList.add(items[i]);
}
}
zcyList=sortList(zcyList);
zcgList=sortList(zcgList);
mxqList=sortList(mxqList);
bjList=sortList(bjList);
otherList=sortList(otherList);
//开旁路,清空文件夹,再插入
KUtil.setByPass(true);
for (int i = 0; i < items.length; i++) {
folders2[k].remove("contents", items[i]);
}
addItem(folders2[k],zcyList);
addItem(folders2[k],zcgList);
addItem(folders2[k],mxqList);
addItem(folders2[k],bjList);
addItem(folders2[k],otherList);
KUtil.setByPass(false);
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
}
private void addItem(TCComponent tcComponent, List<TCComponent> zcyList) {
for (int i = 0; i < zcyList.size(); i++) {
try {
tcComponent.add("contents", zcyList.get(i));
} catch (TCException e) {
e.printStackTrace();
}
}
}
private List<TCComponent> sortList(List<TCComponent> list) {
Map<String, TCComponent> map=new HashMap<>();
String[] idString=new String[list.size()];
List<TCComponent> idList=new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
try {
idString[i]=list.get(i).getProperty("item_id");
// idList.add(list.get(i).getProperty("item_id"));
map.put(list.get(i).getProperty("item_id"), list.get(i));
} catch (TCException e) {
e.printStackTrace();
}
}
Arrays.sort(idString);
for (int i = 0; i < idString.length; i++) {
System.out.println(idString[i]);
idList.add(map.get(idString[i]));
}
return idList;
}
private void initUI() {
this.setTitle("分配出厂编号");
this.setPreferredSize(new Dimension(980,480));
this.setMinimumSize(new Dimension(400,300));
this.setLayout(new BorderLayout());
this.add(BorderLayout.NORTH,getBtnPanel());
this.add(BorderLayout.CENTER,getTablePanel());
}
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
tm_bom = new DefaultTableModel();
t_bom = new JTable(tm_bom) {
@Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if(column==6)
{
return true;
}
return false;
}
};
tm_bom.setDataVector(null, HEADER);
t_bom.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_bom.setRowHeight(23);
TableColumnModel colModel = this.t_bom.getColumnModel();
int colCnt = HEADERWIDTH.length;
colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]);
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
JScrollPane scroll = new JScrollPane(t_bom);
panel.add(BorderLayout.CENTER, scroll);
return panel;
}
private JPanel getBtnPanel() {
panel = new JPanel(new BorderLayout());
panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT,10,5));
panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT,10,5));
//JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT,15,5));
JLabel label = new JLabel("出厂编号流水码范围:");
/*JLabel label_zcy = new JLabel("ZCY出厂编号流水码范围:");
JLabel label_zcg = new JLabel("ZCG出厂编号流水码范围:");
JLabel label_bj = new JLabel("BJ出厂编号流水码范围:");
JLabel label_mxq = new JLabel("MXQ出厂编号流水码范围:");*/
panel2.add(label);
jtf_zcy = new JTextField(10);
jtf_zcy.setText("ZCY ");
jtf_zcy.setEditable(false);
panel2.add(jtf_zcy);
jtf_zcg = new JTextField(10);
jtf_zcg.setText("ZCG");
jtf_zcg.setEditable(false);
// panel2.add(label_zcg);
panel2.add(jtf_zcg);
jtf_bj = new JTextField(10);
jtf_bj.setText("BJ");
jtf_bj.setEditable(false);
// panel2.add(label_bj);
panel2.add(jtf_bj);
jtf_mxq = new JTextField(10);
jtf_mxq.setText("MXQ");
jtf_mxq.setEditable(false);
// panel2.add(label_mxq);
panel2.add(jtf_mxq);
//panel.add(panel2);
n_assign = new JButton("自动分配出厂编号");
panel3.add(n_assign);
b_assign = new JButton("保存出厂编号");
panel3.add(b_assign);
//panel3.add(b_assign);
//panel.add(panel3);
panel.add(BorderLayout.WEST,panel2);
panel.add(BorderLayout.EAST,panel3);
return panel;
}
private String getFNumber(TCComponentForm flowForm, String prefix) {
if (prefix == null) {
prefix = "";
}
String nameProp = "user_data_1";//记录年月
String numProp = "user_data_2";//记录流水码
String flowNoStr="";
String str="";
SimpleDateFormat nsw = new SimpleDateFormat("yyMM");
try {
String date = nsw.format(new Date());
flowForm.lock();
//flowForm.refresh();
flowNoStr = flowForm.getStringProperty(numProp);
if (!date.equals(flowNoStr)) {
System.out.println("刷新表单流水:" + flowNoStr + " -> " + date);
flowForm.setStringProperty(nameProp, date);
}
str = flowForm.getStringProperty(nameProp);
if(!fNum_flag)
{
Map<String, String> field = new HashMap<String, String>();
field.put("零组件 ID",prefix+str+"001");
TCComponentContextList contextList = KUtil.query(session, "零组件...", field);
if(contextList!=null && contextList.getListCount()==1)
{
System.out.println("已重置当月流水码");
}else
{
System.out.println("重置当月流水码");
flowForm.setStringProperty(numProp, "1");
fNum_flag = true;
}
}
flowForm.save();
flowForm.unlock();
flowForm.refresh();
} catch (Exception e1) {
e1.printStackTrace();
}
this.qz = prefix+str;
Integer flowNo = 1;
if(!KUtil.isEmpty(flowNoStr)) {
try {
flowNo = Integer.parseInt(flowNoStr);
} catch (Exception e) {
e.printStackTrace();
}
if (flowNo == null) {
flowNo = 1;
}
}
System.out.println("flowNo:"+flowNo);
lsmMax = flowNo+2;
lsmMin = flowNo;
return String.format("%03d", flowNo)+"-"+String.format("%03d", flowNo+2);
}
}

@ -0,0 +1,681 @@
package com.connor.chint.sap2.assignfactoryno;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.PreferenceObject;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCPreferenceService.TCPreferenceLocation;
import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("serial")
public class FactoryNoZYDialog extends AbstractAIFDialog{
private FactoryNoZYDialogController controller;
private TCSession session;
private TCPreferenceService prefService=null ;
private AbstractAIFApplication app;
protected DefaultTableModel tm_bom;
protected JTable t_bom;
protected int createCode = 0;//用来标记新分配的还是旧的之间调整属性0新建1调整
private JButton b_assign;
private JButton n_assign;
protected JTextField jtf_zcy ;//
protected JPanel panel ;//
protected JPanel panel2 ;//
protected JPanel panel3 ;//
protected JTextField jtf_zcg ;
protected JTextField jtf_bj ;
protected JTextField jtf_mxq ;
protected JTextField jtf_zcq ;
public static final String[] HEADER = new String[] { "序号","站点","柜号","物料编码", "物料名称", "出厂编码前缀", "出厂编号流水码" };
public static final int[] HEADERWIDTH = new int[] { 50, 150, 150, 150 ,150, 150, 150};
public TCComponentFolder factorNoFolder;
// String zt2_ZY = "zt2_ZY";
public boolean fNum_flag = false;
protected TCComponentForm lsmForm=null;
private String actionInfo;
protected String qz="";
protected int lsmMax=0;
protected int lsmMin = 0;
public FactoryNoZYDialog(AbstractAIFApplication app, String actionInfo) {
super(false);
this.controller = new FactoryNoZYDialogController(app,this,actionInfo);
this.app = app;
this.session = (TCSession) app.getSession();
prefService=session.getPreferenceService();
KUtil.setByPass(true);
System.out.println("actionInfo>>"+actionInfo);
// lsmForm = getForm(actionInfo);//把ZCY类型的月份和前缀放在一张指定的form表中
// getFNumber(lsmForm,"ZCY");//每月重置,但是现在新加入三种类型,这种方式不适用,要么用中间表的形式,要么用首选项的形式
resetFlowNumner();
KUtil.setByPass(false);
}
public void disconnect(Connection conn,Statement stmt, ResultSet rs_get) {
try {
if (rs_get != null) {
rs_get.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public Connection connect(Connection conn) {
String[] database=session.getPreferenceService().getStringValues("database_tc");
String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@10.128.18.139:1521:testdb";//测试系统
strUrl="jdbc:oracle:thin:@"+database[0]+":"+database[1]+":"+database[2];
String strUserName = "infodba";
strUserName=database[3];
String strPassword = "infodba";
strPassword=database[4];
try {
Class.forName(JdbcDriverClass);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
try {
conn = DriverManager.getConnection(strUrl, strUserName, strPassword);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
private void resetFlowNumner() {
try {
Connection conn=null;
conn=connect(conn);
String query="select * from CHINT_FLOW";
Statement stmt = conn.createStatement();
ResultSet rs_get = null;
rs_get = stmt.executeQuery(query);
List<String> sqlList=new ArrayList<>();
while (rs_get.next()) {
String type=rs_get.getString("TYPE");
String time=rs_get.getString("TIME");
// String flow=rs_get.getString("FLOW");
String code=type+time+"001";
TCComponent[] comps= session.search("零组件...", new String[] {"零组件 ID"}, new String[] {code});
if(comps.length==0) {
System.out.println("重置当月流水码");
sqlList.add("update CHINT_FLOW set FLOW='001' where TYPE='"+type+"' and TIME='"+time+"'");
}else if(comps.length==1) {
System.out.println("已重置当月流水码");
}
}
//
if (rs_get != null) {
rs_get.close();
}
for (int i = 0; i < sqlList.size(); i++) {
String sql=sqlList.get(0);
rs_get = stmt.executeQuery(sql);
if(rs_get.next()) {
System.out.println("update =====");
}
if (rs_get != null) {
rs_get.close();
}
}
disconnect( conn, stmt, rs_get);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
private TCComponentForm getForm(String prefix)
{
if (prefix == null) {
prefix = "";
}
prefix = "TEST";
String prefName = "ZT2_FactoryNo_" + prefix;
TCPreferenceService prefService = session.getPreferenceService();
try {
prefService.refresh();
TCPreferenceLocation loc = TCPreferenceLocation.OVERLAY_LOCATION;
PreferenceObject pref = prefService.getPreferenceObjectAtLocation(prefName, loc);
String uid = prefService.getStringValue(prefName);
System.out.println("首选项的值:"+uid);
TCComponent comp = session.stringToComponent(uid);
System.out.println("选中的表单:"+comp);
if(comp!=null && comp instanceof TCComponentForm)
{
return (TCComponentForm) comp;
}
} catch (TCException e) {
e.printStackTrace();
}
return null;
}
@Override
public void run() {
initUI();
addListeners();
new Thread(new Runnable() {
@Override
public void run() {
KUtil.setByPass(true);
ProgressBar pb = new ProgressBar(FactoryNoZYDialog.this, new Dimension(250, 50));
setCompEnabled(false);
try {
/*if(lsmForm==null)
{
throw new Exception("获取流水码信息异常,请检查首选项");
}*/
controller.readData(pb);
pb.disposeDialog();
KUtil.setByPass(false);
} catch (Exception e) {
KUtil.setByPass(false);
pb.disposeDialog();
MessageBox.post(FactoryNoZYDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace();
}
setCompEnabled(true);
//重设流水码范围:增加判断,如果出厂编号对象已经存在,那么流水码显示范围就是原来的范围
reFlow();
}
}).start();
showDialog();
}
protected void reFlow() {
int row=t_bom.getRowCount();
Map<String, List<String>> FlowMap=new HashMap<>();
// System.out.println("row===="+row);
FlowMap.put("ZCY", new ArrayList<String>());
FlowMap.put("ZCG", new ArrayList<String>());
FlowMap.put("BJ", new ArrayList<String>());
FlowMap.put("MXQ", new ArrayList<String>());
FlowMap.put("ZCQ", new ArrayList<String>());
for (int i = 0; i < row; i++) {
String mapKey=(String) t_bom.getValueAt(i, 5);
String mapValue=(String) t_bom.getValueAt(i, 6);
if(mapKey==null||mapValue==null) {
continue;
}
// System.out.println(mapKey+mapValue);
if(mapValue.length()>0) {
createCode=1;
}
for(Map.Entry<String, List<String>> me:FlowMap.entrySet()) {
if(mapKey.startsWith(me.getKey())) {
me.getValue().add(mapValue);
}
}
}
if(createCode==1) {
for(Map.Entry<String, List<String>> me:FlowMap.entrySet()) {
List<String> list=me.getValue();
if(list.size()==0) {
continue;
}
String[] strings=new String[list.size()];
for (int i = 0; i < strings.length; i++) {
strings[i]=list.get(i);
}
Arrays.sort(strings);
String ss=me.getKey()+":"+strings[0]+"-"+strings[strings.length-1];
// System.out.println(ss);
// System.out.println(me.getKey()+":");
if(jtf_zcy.getText().startsWith(me.getKey()+":")) {
jtf_zcy.setText(ss);
}
if(jtf_zcg.getText().startsWith(me.getKey()+":")) {
jtf_zcg.setText(ss);
}
if(jtf_bj.getText().startsWith(me.getKey()+":")) {
jtf_bj.setText(ss);
}
if(jtf_mxq.getText().startsWith(me.getKey()+":")) {
jtf_mxq.setText(ss);
}
if(jtf_zcq.getText().startsWith(me.getKey()+":")) {
jtf_zcq.setText(ss);
}
}
n_assign.setEnabled(false);
}
}
protected void setCompEnabled(boolean b) {
b_assign.setEnabled(b);
t_bom.setEnabled(b);
}
public int flowStart(String start){
int startNUm=0;
if(start.length()==0) {
return startNUm;
}else {
startNUm=Integer.valueOf(start.split(":")[1].split("-")[0]);
return startNUm;
}
}
private void addListeners() {
//分配出厂编号流水码
n_assign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if(!controller.checkXMFJ())
{
MessageBox.post("未检测到项目附件,不能分配出厂编号", "", MessageBox.INFORMATION);
return;
}
} catch (TCException e1) {
e1.printStackTrace();
}
int index2=t_bom.getRowCount();
SimpleDateFormat sdf=new SimpleDateFormat("yyMM");
Date date=new Date();
String dateString=sdf.format(date);
int zcy=flowStart(jtf_zcy.getText());
int zcg=flowStart(jtf_zcg.getText());
int bj=flowStart(jtf_bj.getText());
int mxq=flowStart(jtf_mxq.getText());
int zcq=flowStart(jtf_zcq.getText());
String[] types=prefService.getStringValues("zt2_byq_type");
Map<String, String> typeMap=new HashMap<>();
for (int i = 0; i < types.length; i++) {
typeMap.put(types[i].split(":")[0], types[i].split(":")[1]);
}
for (int i = 0; i < index2; i++) {
String prefix0= (String) t_bom.getValueAt(i, 4);
String prefix="";
for(Map.Entry<String, String> me:typeMap.entrySet()) {
String[] names=me.getValue().split(";");
for (int j = 0; j < names.length; j++) {
if(prefix0.contains(names[j])) {
prefix=me.getKey();
break;
}
}
}
t_bom.setValueAt(prefix+dateString, i, 5);
switch(prefix) {
case "ZCY":
t_bom.setValueAt(String.format("%03d", zcy), i,6);
zcy++;
break;
case "ZCG":
t_bom.setValueAt(String.format("%03d", zcg), i,6);
zcg++;
break;
case "BJ":
t_bom.setValueAt(String.format("%03d", bj), i,6);
bj++;
break;
case "MXQ":
t_bom.setValueAt(String.format("%03d", mxq), i,6);
mxq++;
break;
case "ZCQ":
t_bom.setValueAt(String.format("%03d", zcq), i,6);
zcq++;
break;
default:
break;
}
}
}
});
b_assign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
ProgressBar pb = new ProgressBar(FactoryNoZYDialog.this, new Dimension(250, 50));
KUtil.setByPass(true);
setCompEnabled(false);
try {
// controller.assign(pb);
controller.assign(pb,0,createCode);//检验,新建等
//将项目启动->出厂编号下面的文件重新排序
if(createCode==0) {
sorting();
}
pb.disposeDialog();
} catch (Exception e1) {
KUtil.setByPass(false);
pb.disposeDialog();
MessageBox.post(FactoryNoZYDialog.this, "分配出厂编号发生异常:" + e1.getMessage(), "", MessageBox.ERROR);
controller.recovery();
setCompEnabled(true);
e1.printStackTrace();
}
KUtil.setByPass(false);
setCompEnabled(true);
}
}).start();
}
});
}
private void sorting() {
try {
TCComponent project=(TCComponent) app.getTargetComponent();
TCComponent[] folders=project.getRelatedComponents("IMAN_reference");
for (int j = 0; j < folders.length; j++) {
if(folders[j].getProperty("object_name").equals("项目启动")) {
TCComponent[] folders2=folders[j].getRelatedComponents("contents");
for (int k = 0; k < folders2.length; k++) {
if(folders2[k].getProperty("object_name").equals("出厂编号")) {
TCComponent[] items=folders2[k].getRelatedComponents("contents");
List<TCComponent> zcyList=new ArrayList<>();
List<TCComponent> zcgList=new ArrayList<>();
List<TCComponent> mxqList=new ArrayList<>();
List<TCComponent> bjList=new ArrayList<>();
List<TCComponent> zcqList=new ArrayList<>();
List<TCComponent> otherList=new ArrayList<>();
for (int i = 0; i < items.length; i++) {
String id=items[i].getProperty("item_id");
if(id.startsWith("ZCY")) {
zcyList.add(items[i]);
}else if(id.startsWith("ZCG")) {
zcgList.add(items[i]);
}else if(id.startsWith("MXQ")) {
mxqList.add(items[i]);
}else if(id.startsWith("BJ")) {
bjList.add(items[i]);
}else if(id.startsWith("ZCQ")) {
zcqList.add(items[i]);
}else {
otherList.add(items[i]);
}
}
zcyList=sortList(zcyList);
zcgList=sortList(zcgList);
mxqList=sortList(mxqList);
bjList=sortList(bjList);
zcqList=sortList(zcqList);
otherList=sortList(otherList);
//开旁路,清空文件夹,再插入
KUtil.setByPass(true);
for (int i = 0; i < items.length; i++) {
folders2[k].remove("contents", items[i]);
}
addItem(folders2[k],zcyList);
addItem(folders2[k],zcgList);
addItem(folders2[k],zcqList);
addItem(folders2[k],mxqList);
addItem(folders2[k],bjList);
addItem(folders2[k],otherList);
KUtil.setByPass(false);
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
}
private void addItem(TCComponent tcComponent, List<TCComponent> zcyList) {
for (int i = 0; i < zcyList.size(); i++) {
try {
tcComponent.add("contents", zcyList.get(i));
} catch (TCException e) {
e.printStackTrace();
}
}
}
private List<TCComponent> sortList(List<TCComponent> list) {
Map<String, TCComponent> map=new HashMap<>();
String[] idString=new String[list.size()];
List<TCComponent> idList=new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
try {
idString[i]=list.get(i).getProperty("item_id");
// idList.add(list.get(i).getProperty("item_id"));
map.put(list.get(i).getProperty("item_id"), list.get(i));
} catch (TCException e) {
e.printStackTrace();
}
}
Arrays.sort(idString);
for (int i = 0; i < idString.length; i++) {
System.out.println(idString[i]);
idList.add(map.get(idString[i]));
}
return idList;
}
private void initUI() {
this.setTitle("分配出厂编号");
this.setPreferredSize(new Dimension(1180,480));
this.setMinimumSize(new Dimension(400,300));
this.setLayout(new BorderLayout());
this.add(BorderLayout.NORTH,getBtnPanel());
this.add(BorderLayout.CENTER,getTablePanel());
}
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
tm_bom = new DefaultTableModel();
t_bom = new JTable(tm_bom) {
@Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if(column==6)
{
return true;
}
return false;
}
};
tm_bom.setDataVector(null, HEADER);
t_bom.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_bom.setRowHeight(23);
TableColumnModel colModel = this.t_bom.getColumnModel();
int colCnt = HEADERWIDTH.length;
colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]);
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
JScrollPane scroll = new JScrollPane(t_bom);
panel.add(BorderLayout.CENTER, scroll);
return panel;
}
private JPanel getBtnPanel() {
panel = new JPanel(new BorderLayout());
panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT,10,5));
panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT,10,5));
//JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT,15,5));
JLabel label = new JLabel("出厂编号流水码范围:");
/*JLabel label_zcy = new JLabel("ZCY出厂编号流水码范围:");
JLabel label_zcg = new JLabel("ZCG出厂编号流水码范围:");
JLabel label_bj = new JLabel("BJ出厂编号流水码范围:");
JLabel label_mxq = new JLabel("MXQ出厂编号流水码范围:");*/
panel2.add(label);
jtf_zcy = new JTextField(10);
jtf_zcy.setText("ZCY ");
jtf_zcy.setEditable(false);
panel2.add(jtf_zcy);
jtf_zcg = new JTextField(10);
jtf_zcg.setText("ZCG");
jtf_zcg.setEditable(false);
// panel2.add(label_zcg);
panel2.add(jtf_zcg);
jtf_zcq = new JTextField(10);
jtf_zcq.setText("ZCQ");
jtf_zcq.setEditable(false);
// panel2.add(label_mxq);
panel2.add(jtf_zcq);
jtf_bj = new JTextField(10);
jtf_bj.setText("BJ");
jtf_bj.setEditable(false);
// panel2.add(label_bj);
panel2.add(jtf_bj);
jtf_mxq = new JTextField(10);
jtf_mxq.setText("MXQ");
jtf_mxq.setEditable(false);
// panel2.add(label_mxq);
panel2.add(jtf_mxq);
//panel.add(panel2);
n_assign = new JButton("自动分配出厂编号");
panel3.add(n_assign);
b_assign = new JButton("保存出厂编号");
panel3.add(b_assign);
//panel3.add(b_assign);
//panel.add(panel3);
panel.add(BorderLayout.WEST,panel2);
panel.add(BorderLayout.EAST,panel3);
return panel;
}
private String getFNumber(TCComponentForm flowForm, String prefix) {
if (prefix == null) {
prefix = "";
}
String nameProp = "user_data_1";//记录年月
String numProp = "user_data_2";//记录流水码
String flowNoStr="";
String str="";
SimpleDateFormat nsw = new SimpleDateFormat("yyMM");
try {
String date = nsw.format(new Date());
flowForm.lock();
//flowForm.refresh();
flowNoStr = flowForm.getStringProperty(numProp);
if (!date.equals(flowNoStr)) {
System.out.println("刷新表单流水:" + flowNoStr + " -> " + date);
flowForm.setStringProperty(nameProp, date);
}
str = flowForm.getStringProperty(nameProp);
if(!fNum_flag)
{
Map<String, String> field = new HashMap<String, String>();
field.put("零组件 ID",prefix+str+"001");
TCComponentContextList contextList = KUtil.query(session, "零组件...", field);
if(contextList!=null && contextList.getListCount()==1)
{
System.out.println("已重置当月流水码");
}else
{
System.out.println("重置当月流水码");
flowForm.setStringProperty(numProp, "1");
fNum_flag = true;
}
}
flowForm.save();
flowForm.unlock();
flowForm.refresh();
} catch (Exception e1) {
e1.printStackTrace();
}
this.qz = prefix+str;
Integer flowNo = 1;
if(!KUtil.isEmpty(flowNoStr)) {
try {
flowNo = Integer.parseInt(flowNoStr);
} catch (Exception e) {
e.printStackTrace();
}
if (flowNo == null) {
flowNo = 1;
}
}
System.out.println("flowNo:"+flowNo);
lsmMax = flowNo+2;
lsmMin = flowNo;
return String.format("%03d", flowNo)+"-"+String.format("%03d", flowNo+2);
}
}

@ -0,0 +1,770 @@
package com.connor.chint.sap2.assignfactoryno;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
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.Vector;
import com.connor.chint.sap2.bombuilder.BomBuildDialogController;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
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.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_REQITEMSITEM;
public class FactoryNoZYDialogController {
private AbstractAIFApplication app;
private FactoryNoZYDialog dialog;
protected List<FactoryNoZYBean> beanList = new ArrayList<>();
private String prefix;
private TCSession session;
protected Vector<String> lsms = new Vector<String>();
protected List<DT_FACTORY_NUMBER_REQITEMSITEM> fNoLists = new ArrayList<DT_FACTORY_NUMBER_REQITEMSITEM>();
protected TCComponent projCon = null;
private static String TYPE_PROJECTCON = "ZT2_ProjectCon";
private int min = 0;
private int max = 0;
public FactoryNoZYDialogController(AbstractAIFApplication app, FactoryNoZYDialog factoryNoDialog, String actionInfo) {
this.app = app;
this.dialog = factoryNoDialog;
this.prefix = actionInfo;
this.session = (TCSession) app.getSession();
}
public boolean checkXMFJ() throws TCException
{
boolean flag = false;
for(FactoryNoZYBean bean:beanList)
{
String name = bean.getCcpRev().getProperty("object_name");
System.out.println("name:"+name);
if(name.equals("项目附件"))
{
flag = true;
}
if(name.contains("备件包"))
{
flag = true;
break;
}
}
System.out.println("flag:"+flag);
return flag;
}
public boolean readData(ProgressBar pb) throws Exception{
//TODO 如果出厂编号文件夹下有产成品那么前缀取前七位如果没有前缀就以固定的为准改成通过名称判断首选项zt2_byq_type多值
//ZCY:KYN61-40.5;KYN28A-24;KYN28A-12;NKM6-12
//ZCG:XGN15-12;HXGN15-12;XGN2-12;XGN77-40.5;XGN66-12;NHM6-12
//BJ:备件包
//MXQ:母线桥
TCPreferenceService pre=session.getPreferenceService();
String[] types=pre.getStringValues("zt2_byq_type");
Map<String, String> typeMap=new HashMap<>();
for (int i = 0; i < types.length; i++) {
typeMap.put(types[i].split(":")[0], types[i].split(":")[1]);
}
InterfaceAIFComponent target = app.getTargetComponent();
if(target == null || !(target instanceof TCComponentItem)) {
return false;
}
TCComponentItem proj = (TCComponentItem) target;
TCComponentFolder ccpFolder = KUtil.getCCPFolderFromProject(proj);//获得项目启动->产成品文件夹
dialog.factorNoFolder = KUtil.getCCBHFolderFromProject(proj);//获得项目启动->出厂编号文件
AIFComponentContext[] contexts22 = ((TCComponent) target).whereReferencedByTypeRelation(null,null);
for(int i=0;i<contexts22.length;i++)
{
String type = contexts22[i].getComponent().getType();
if(TYPE_PROJECTCON.equals(type))
{
System.out.println("有找到ZT2_ProjectCon类型的对象:"+contexts22[i].getComponent());
projCon = (TCComponent) contexts22[i].getComponent();
break;
}
}
if (ccpFolder == null) {
KUtil.info(dialog, "未找到文件夹:" + KUtil.NAME_FOLDER_CCP);
return false;
}
AIFComponentContext[] ccpItems = ccpFolder.getChildren();
int len = ccpItems == null ? 0 : ccpItems.length;
if (len == 0) {
KUtil.info(dialog, "文件夹为空:" + KUtil.NAME_FOLDER_CCP);
return false;
}
//pb.showDialog();
//TODO 如果名称上不匹配也要提示
int zcy=-1,zcg=-1,bj=-1,mxq=-1;
int h_num = 0;
for (int i = 0; i < len; i++) {
InterfaceAIFComponent c = ccpItems[i].getComponent();
pb.setText("加载对象:" + c + "( " + (i + 1) + " / " + len + " )");
if (c instanceof TCComponentItem) {
String cctype="";
boolean hasType=false;
for(Map.Entry<String, String> me:typeMap.entrySet()) {
String name=c.getProperty("object_name");
String key=me.getKey();
String[] value=me.getValue().split(";");
for (int j = 0; j < value.length; j++) {
if(name.contains(value[j] )) {
cctype=key;
hasType=true;
break;
}
}
if(hasType==true) {
break;
}
}
switch(cctype) {
case "ZCY":
zcy++;
break;
case "ZCG":
zcg++;
break;
case "BJ":
bj++;
break;
case "MXQ":
mxq++;
break;
default:
break;
}
TCComponentItemRevision rev = ((TCComponentItem) c).getLatestItemRevision();
System.out.println("找到对象:" + c + ", 最新版本:" + rev);
String type = rev.getType();
if (rev != null && type.equals("Part Revision")) {
FactoryNoZYBean bean = new FactoryNoZYBean(beanList.size()+1, rev);
beanList.add(bean);
dialog.tm_bom.addRow(bean.getRowData(dialog.qz,typeMap));//TODO 前缀需要修改
String code = bean.getP_code();
if(!code.equals(""))
{
h_num++;
lsms.add(code);
}
}
}
}
String[] prefixString=new String[typeMap.size()];
SimpleDateFormat sdf=new SimpleDateFormat("yyMM");
Date date=new Date();
String dateString=sdf.format(date);
int i1=0;
for(Map.Entry<String, String> me:typeMap.entrySet()) {
String key=me.getKey();
prefixString[i1]=key+dateString;
i1++;
}
//换成数据库,因为普通用户就算开旁路也部门修改首选项
Connection conn=null;
conn=dialog.connect(conn);
String[] typeString=new String[] {"ZCY","ZCG","BJ","MXQ"};
String query="select * from CHINT_FLOW WHERE TIME='"+dateString+"'";
Statement stmt = conn.createStatement();
ResultSet rs_get = null;
for (int i = 0; i < typeString.length; i++) {
String selectQuery="select * from CHINT_FLOW where TYPE='"+typeString[i]+"' and TIME='"+dateString+"'";
String insertQuery="insert into CHINT_FLOW (TYPE,TIME,FLOW) values ('"+typeString[i]+"','"+dateString+"','001')";
rs_get = stmt.executeQuery(selectQuery);
if(rs_get.next()) {
if (rs_get != null) {
rs_get.close();
}
}else {
rs_get = stmt.executeQuery(insertQuery);
if (rs_get != null) {
rs_get.close();
}
}
}
rs_get = stmt.executeQuery(query);
String[] values=new String[4];
int count=0;
while (rs_get.next()) {
String type=rs_get.getString("TYPE");
String time=rs_get.getString("TIME");
String flow=rs_get.getString("FLOW");
values[count]=type+";"+time+";"+flow;
count++;
}
dialog.disconnect(conn, stmt, rs_get);
//如果没有某种类型的就不要显示范围
for (int i = 0; i < values.length; i++) {
String id=values[i].split(";")[0]+values[i].split(";")[1]+values[i].split(";")[2];
TCComponent[] comps=session.search("零组件 ID", new String[] {"零组件 ID"}, new String [] {id});
if(comps!=null) {
String lsm="";
switch(values[i].split(";")[0]) {
case "ZCY":
if(zcy<0) {
lsm= "";
dialog.jtf_zcy.setVisible(false);
// dialog.panel2.remove(dialog.jtf_zcy);
}else {
//增加判断是否是当前月份
lsm= values[i].split(";")[0]+":"+values[i].split(";")[2]+"-"+String.format("%03d", zcy+Integer.valueOf(values[i].split(";")[2]));
// dialog.jtf_zcy.setVisible(true);
}
dialog.jtf_zcy.setText(lsm);
break;
case "ZCG":
if(zcg<0) {
lsm= "";
dialog.jtf_zcg.setVisible(false);
// dialog.panel2.remove(dialog.jtf_zcg);
}else {
dialog.jtf_zcg.setVisible(true);
lsm =values[i].split(";")[0]+":" +values[i].split(";")[2]+"-"+String.format("%03d", zcg+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_zcg.setText(lsm);
break;
case "BJ":
if(bj<0) {
lsm= "";
dialog.jtf_bj.setVisible(false);
// dialog.panel2.remove(dialog.jtf_bj);
}else {
dialog.jtf_bj.setVisible(true);
lsm =values[i].split(";")[0]+":" + values[i].split(";")[2]+"-"+String.format("%03d", bj+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_bj.setText(lsm);
break;
case "MXQ":
if(mxq<0) {
lsm= "";
dialog.jtf_mxq.setVisible(false);
dialog.panel2.remove(dialog.jtf_mxq);
}else {
dialog.jtf_mxq.setVisible(true);
lsm =values[i].split(";")[0]+":" + values[i].split(";")[2]+"-"+String.format("%03d", mxq+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_mxq.setText(lsm);
break;
default:
break;
}
}
}
return true;
}
public static void main(String[] args) {
Vector<String> vecs2 = new Vector<String>();
int code = Integer.parseInt("042");
System.out.println("code:["+code+"]");
vecs2.add(String.valueOf(code));
for(int i=40;i<45;i++)
{
System.out.println("i:"+i);
int index = vecs2.indexOf(String.valueOf(Integer.parseInt(""+i)));
if(index!=-1)
{
System.out.println("index:"+index);
System.out.println("存在相同值");
vecs2.remove(""+i);
//vecs2.removeElementAt(index);
continue;
}
vecs2.add(""+i);
}
for(int i=0;i<vecs2.size();i++)
{
System.out.println("vec:"+vecs2.get(i));
}
}
public String lsm(String lsm) {
if(lsm.length()==0) {
return lsm;
}else {
lsm=lsm.split(":")[1].split("-")[1];
int lsmInt=Integer.valueOf(lsm)+1;
lsm=String.format("%03d", lsmInt);
return lsm;
}
}
public Map<String,String> addMap(Map<String, String> rangeMap,String text){
String[] type=text.split(":");
if(type.length>1) {
rangeMap.put(type[0], type[1]);
}
return rangeMap;
}
/*createCode=1表示不用新建createCode=0表示需要新建*/
public void assign(ProgressBar pb,int index2,int createCode) throws Exception{
//获得所有的表格数据
Map<String, String> rangeMap=new HashMap<>();
rangeMap=addMap(rangeMap, dialog.jtf_zcy.getText());
rangeMap=addMap(rangeMap, dialog.jtf_zcg.getText());
rangeMap=addMap(rangeMap, dialog.jtf_bj.getText());
rangeMap=addMap(rangeMap, dialog.jtf_mxq.getText());
index2=dialog.t_bom.getRowCount();
Map<String, List<String>> map=new HashMap<>();
Map<String, String> repeatMap=new HashMap<>();
StringBuilder sb=new StringBuilder("");
for (int i = 0; i < index2; i++) {
String prefix=(String) dialog.t_bom.getValueAt(i, 5);//流水码前缀
String flowNo=(String) dialog.t_bom.getValueAt(i, 6);//流水码
if(flowNo.trim().length()>0) {
if(repeatMap.containsValue(prefix+flowNo)) {
for(Map.Entry<String, String> me:repeatMap.entrySet()) {
if(me.getValue().equals(prefix+flowNo)) {
sb.append("第"+me.getKey()+"行流水码与第"+(i+1)+"行重复\n");
break;
}
}
}else {
repeatMap.put(i+1+"", prefix+flowNo);
}
}else {
sb.append("第"+(i+1)+"行流水码未填写\n");
continue;
}
List<String> value=map.get(prefix);
if(value!=null) {
if(value.contains(flowNo)) {
// sb.append("第"+(i+1)+"行流水码重复,请检查\n");
continue;
// throw new Exception("第"+(i+1)+"列流水码重复,请检查");
}else {
for(Map.Entry<String, String> me:rangeMap.entrySet()) {
if(prefix.startsWith(me.getKey())) {
String[] range=me.getValue().split("-");
int r1=Integer.valueOf(range[0]);
int r2=Integer.valueOf(range[1]);
int r=Integer.valueOf(flowNo);
if(r>r2||r<r1) {
sb.append("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码\n");
break;
}else {
value.add(flowNo);
map.put(prefix, value);
}
}
}
}
}else {
for(Map.Entry<String, String> me:rangeMap.entrySet()) {
if(prefix.startsWith(me.getKey())) {
String[] range=me.getValue().split("-");
int r1=Integer.valueOf(range[0]);
int r2=Integer.valueOf(range[1]);
int r=Integer.valueOf(flowNo);
if(r>r2||r<r1) {
sb.append("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码\n");
break;
}else {
value=new ArrayList<>();
value.add(flowNo);
map.put(prefix, value);
}
}
}
}
}
if(sb.length()>0) {
throw new Exception("存在以下问题,请检查:\n"+sb.toString());
}
//新建并且把对象粘贴到指定位置
int len = beanList.size();
// System.out.println("len==========="+len);
// System.out.println("createCode==========="+createCode);
if(len==0) {
return;
}
Map<String, TCComponentItemRevision> facMap=new HashMap<>();
StringBuilder sb2=new StringBuilder("");
if(createCode==0) {
for (int i = 0; i < len; i++) {
TCComponentItemRevision ccpRev=beanList.get(i).getCcpRev();
String item_id=(String)dialog.t_bom.getValueAt(i, 5)+(String)dialog.t_bom.getValueAt(i, 6);
//查询是否存在,不存在再创建
TCComponent[] item=session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {item_id});
if(item==null||item.length==0) {
facMap.put(item_id, ccpRev);
}else {
sb2.append("存在出厂编号对象:"+item_id+"\n");
}
}
}else {
for (int i = 0; i < len; i++) {
TCComponentItemRevision ccpRev=beanList.get(i).getCcpRev();
String item_id=(String)dialog.t_bom.getValueAt(i, 5)+(String)dialog.t_bom.getValueAt(i, 6);
//查询是否存在,不存在再创建
facMap.put(item_id, ccpRev);
}
}
if(sb2.length()>0) {
throw new Exception("保存失败:\n"+sb2.toString());
}else {
if(createCode==0) {
for(Map.Entry<String, TCComponentItemRevision> me:facMap.entrySet()) {
String item_id=me.getKey();
TCComponentItemRevision rev=me.getValue();
TCComponentItem item = KUtil.newItem(session,BomBuildDialogController.TYPE_FACTORYNO,item_id,item_id);
TCComponent[] comps= rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO);
rev.cutOperation(BomBuildDialogController.REL_FACTORYNO, comps);
rev.add(BomBuildDialogController.REL_FACTORYNO, item);
TCComponentFolder folder = dialog.factorNoFolder;
if(folder!=null)
{
folder.cutOperation("contents", comps);
folder.add("contents", item);
}
}
}else {
// System.out.println("开始保存");
for(Map.Entry<String, TCComponentItemRevision> me:facMap.entrySet()) {
String item_id=me.getKey();
System.out.println(item_id);
TCComponentItemRevision rev=me.getValue();
System.out.println(rev.getProperty("item_id"));
TCComponent[] item = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {item_id});
TCComponent[] comps= rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO);
rev.cutOperation(BomBuildDialogController.REL_FACTORYNO, comps);
// System.out.println("1111111");
rev.add(BomBuildDialogController.REL_FACTORYNO, item[0]);
}
}
}
if(createCode==0) {
//修改首选项zt2_ZY的流水码
Map<String,String> lsmMap=new HashMap<>();
String lsm="";
lsm=lsm(dialog.jtf_zcy.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_zcy.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_zcg.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_zcg.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_bj.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_bj.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_mxq.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_mxq.getText().split(":")[0], lsm);
}
SimpleDateFormat sdf=new SimpleDateFormat("yyMM");
String dateString=sdf.format(new Date());
List<String> sqlList=new ArrayList<>();
for (Map.Entry<String, String> me:lsmMap.entrySet()) {
sqlList.add("update CHINT_FLOW set TIME='"+dateString+"', FLOW='"+me.getValue()+"' where TYPE='"+me.getKey()+"' and TIME='"+dateString+"'");
}
Connection conn=null;
conn=dialog.connect(conn);
Statement stmt = conn.createStatement();
ResultSet rs_get = null;
for (int i = 0; i < sqlList.size(); i++) {
rs_get = stmt.executeQuery(sqlList.get(i));
if ((rs_get.next())) {
System.out.println(" update2==========");
}
if (rs_get != null) {
rs_get.close();
}
}
dialog.disconnect(conn, stmt, rs_get);
}
pb.disposeDialog();
KUtil.info(dialog, "保存出厂编号结束");
if(true) {
return;
}
if(lsms.size()==beanList.size())
{
throw new Exception("该项目无需分配出厂编号");
}
Vector<String> vecs = new Vector<String>();
Vector<String> vecs2 = new Vector<String>();
for(int i=min;i<=max;i++)
{
vecs2.add(String.valueOf(i));
}
int index=0;
for(int i=0;i<len;i++)
{
Object obj = dialog.t_bom.getValueAt(i, 6);
if(obj.equals(""))
{
throw new Exception("第"+(i+1)+"列流水码未填写,请检查");
}
if(obj!=null && !obj.equals(""))
{
String code = String.valueOf(obj);
if(vecs2.indexOf(String.valueOf(Integer.parseInt(code)))==-1 && beanList.get(i).getFactNoItem()==null)
{
throw new Exception("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码");
}
if(vecs.indexOf(code)!=-1)
{
throw new Exception("第"+(i+1)+"行与第"+(vecs.indexOf(code)+1)+"列流水码重复不允许为多个物料分配相同ID的出厂编码");
}
if(beanList.get(i).getFactNoItem()!=null)
{
index++;
}
vecs.add(code);
}
}
if(vecs.size()<len)
{
throw new Exception("请为每一列分配出厂编号");
}
DT_FACTORY_NUMBER_REQITEMSITEM items[] = new DT_FACTORY_NUMBER_REQITEMSITEM[len];
pb.showDialog();
for (int i = 0; i < len; i++) {
pb.setText("分配出厂编号...( " + (i + 1) + " / " + len + " )");
Object obj = dialog.t_bom.getValueAt(i, 6);
String newId = "";
FactoryNoZYBean bean = beanList.get(i);
//DT_FACTORY_NUMBER_REQITEMSITEM item = new DT_FACTORY_NUMBER_REQITEMSITEM();
String con_id = projCon==null?"":projCon.getProperty("item_id");
String wbs = projCon==null?"":projCon.getProperty("zt2_WBSNo");
/*
item.setPSPID(con_id);
item.setZPSPID(wbs);
item.setMATNR(bean.getMaterialNo());
item.setZZD(bean.getSite());
item.setZGH(bean.getTankNo());
item.setSERNR(bean.getFactNoItemID());
item.setWERKS("M008"); //中压默认MOO8
*/
if(index!=0) {
int code=0;
if(obj!=null && !obj.equals("")) {
code = Integer.parseInt((String) obj);
int cind = vecs.indexOf(obj);
System.out.println("cind:"+cind);
System.out.println("code"+code);
//vecs.remove(""+code);
vecs.remove(cind);
}else
{
String str = vecs.get(0);
code = Integer.parseInt(str);
vecs.remove(0);
}
newId= beanList.get(i).assign(session,prefix,dialog,code);
}
else {
newId= beanList.get(i).assign(session,prefix,dialog,-1);
}
if(newId!=null) {
dialog.t_bom.setValueAt(newId.substring(0, 7), i, 5);
dialog.t_bom.setValueAt(newId.substring(7,newId.length()), i,6);
}
//items[i] = item;
}
//sendFactoryNo(items);
pb.disposeDialog();
KUtil.info(dialog, "分配出厂编号结束");
}
public void assign(ProgressBar pb) throws Exception{
int len = beanList.size();
if(len==0) {
return;
}
if(lsms.size()==beanList.size())
{
throw new Exception("该项目无需分配出厂编号");
}
Vector<String> vecs = new Vector<String>();
Vector<String> vecs2 = new Vector<String>();
for(int i=min;i<=max;i++)
{
vecs2.add(String.valueOf(i));
}
int index=0;
for(int i=0;i<len;i++)
{
Object obj = dialog.t_bom.getValueAt(i, 6);
if(obj.equals(""))
{
throw new Exception("第"+(i+1)+"列流水码未填写,请检查");
}
if(obj!=null && !obj.equals(""))
{
String code = String.valueOf(obj);
if(vecs2.indexOf(String.valueOf(Integer.parseInt(code)))==-1 && beanList.get(i).getFactNoItem()==null)
{
throw new Exception("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码");
}
if(vecs.indexOf(code)!=-1)
{
throw new Exception("第"+(i+1)+"行与第"+(vecs.indexOf(code)+1)+"列流水码重复不允许为多个物料分配相同ID的出厂编码");
}
if(beanList.get(i).getFactNoItem()!=null)
{
index++;
}
vecs.add(code);
}
}
if(vecs.size()<len)
{
throw new Exception("请为每一列分配出厂编号");
}
DT_FACTORY_NUMBER_REQITEMSITEM items[] = new DT_FACTORY_NUMBER_REQITEMSITEM[len];
pb.showDialog();
for (int i = 0; i < len; i++) {
pb.setText("分配出厂编号...( " + (i + 1) + " / " + len + " )");
Object obj = dialog.t_bom.getValueAt(i, 6);
String newId = "";
FactoryNoZYBean bean = beanList.get(i);
//DT_FACTORY_NUMBER_REQITEMSITEM item = new DT_FACTORY_NUMBER_REQITEMSITEM();
String con_id = projCon==null?"":projCon.getProperty("item_id");
String wbs = projCon==null?"":projCon.getProperty("zt2_WBSNo");
/*
item.setPSPID(con_id);
item.setZPSPID(wbs);
item.setMATNR(bean.getMaterialNo());
item.setZZD(bean.getSite());
item.setZGH(bean.getTankNo());
item.setSERNR(bean.getFactNoItemID());
item.setWERKS("M008"); //中压默认MOO8
*/
if(index!=0) {
int code=0;
if(obj!=null && !obj.equals("")) {
code = Integer.parseInt((String) obj);
int cind = vecs.indexOf(obj);
System.out.println("cind:"+cind);
System.out.println("code"+code);
//vecs.remove(""+code);
vecs.remove(cind);
}else
{
String str = vecs.get(0);
code = Integer.parseInt(str);
vecs.remove(0);
}
newId= beanList.get(i).assign(session,prefix,dialog,code);
}
else {
newId= beanList.get(i).assign(session,prefix,dialog,-1);
}
if(newId!=null) {
dialog.t_bom.setValueAt(newId.substring(0, 7), i, 5);
dialog.t_bom.setValueAt(newId.substring(7,newId.length()), i,6);
}
//items[i] = item;
}
//sendFactoryNo(items);
pb.disposeDialog();
KUtil.info(dialog, "分配出厂编号结束");
}
public void recovery()
{
int len = beanList.size();
for (int i = 0; i < len; i++) {
dialog.t_bom.setValueAt(beanList.get(i).getP_code(), i,6);
}
}
}

@ -0,0 +1,791 @@
package com.connor.chint.sap2.assignfactoryno;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
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.Vector;
import com.connor.chint.sap2.bombuilder.BomBuildDialogController;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
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.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import plm.xi.com.chintelectric.DT_FACTORY_NUMBER_REQITEMSITEM;
public class FactoryNoZYDialogController {
private AbstractAIFApplication app;
private FactoryNoZYDialog dialog;
protected List<FactoryNoZYBean> beanList = new ArrayList<>();
private String prefix;
private TCSession session;
protected Vector<String> lsms = new Vector<String>();
protected List<DT_FACTORY_NUMBER_REQITEMSITEM> fNoLists = new ArrayList<DT_FACTORY_NUMBER_REQITEMSITEM>();
protected TCComponent projCon = null;
private static String TYPE_PROJECTCON = "ZT2_ProjectCon";
private int min = 0;
private int max = 0;
public FactoryNoZYDialogController(AbstractAIFApplication app, FactoryNoZYDialog factoryNoDialog, String actionInfo) {
this.app = app;
this.dialog = factoryNoDialog;
this.prefix = actionInfo;
this.session = (TCSession) app.getSession();
}
public boolean checkXMFJ() throws TCException
{
boolean flag = false;
for(FactoryNoZYBean bean:beanList)
{
String name = bean.getCcpRev().getProperty("object_name");
System.out.println("name:"+name);
if(name.equals("项目附件"))
{
flag = true;
}
if(name.contains("备件包"))
{
flag = true;
break;
}
}
System.out.println("flag:"+flag);
return flag;
}
public boolean readData(ProgressBar pb) throws Exception{
//TODO 如果出厂编号文件夹下有产成品那么前缀取前七位如果没有前缀就以固定的为准改成通过名称判断首选项zt2_byq_type多值
//ZCY:KYN61-40.5;KYN28A-24;KYN28A-12;NKM6-12
//ZCG:XGN15-12;HXGN15-12;XGN2-12;XGN77-40.5;XGN66-12;NHM6-12
//BJ:备件包
//MXQ:母线桥
TCPreferenceService pre=session.getPreferenceService();
String[] types=pre.getStringValues("zt2_byq_type");
Map<String, String> typeMap=new HashMap<>();
for (int i = 0; i < types.length; i++) {
typeMap.put(types[i].split(":")[0], types[i].split(":")[1]);
}
InterfaceAIFComponent target = app.getTargetComponent();
if(target == null || !(target instanceof TCComponentItem)) {
return false;
}
TCComponentItem proj = (TCComponentItem) target;
TCComponentFolder ccpFolder = KUtil.getCCPFolderFromProject(proj);//获得项目启动->产成品文件夹
dialog.factorNoFolder = KUtil.getCCBHFolderFromProject(proj);//获得项目启动->出厂编号文件
AIFComponentContext[] contexts22 = ((TCComponent) target).whereReferencedByTypeRelation(null,null);
for(int i=0;i<contexts22.length;i++)
{
String type = contexts22[i].getComponent().getType();
if(TYPE_PROJECTCON.equals(type))
{
System.out.println("有找到ZT2_ProjectCon类型的对象:"+contexts22[i].getComponent());
projCon = (TCComponent) contexts22[i].getComponent();
break;
}
}
if (ccpFolder == null) {
KUtil.info(dialog, "未找到文件夹:" + KUtil.NAME_FOLDER_CCP);
return false;
}
AIFComponentContext[] ccpItems = ccpFolder.getChildren();
int len = ccpItems == null ? 0 : ccpItems.length;
if (len == 0) {
KUtil.info(dialog, "文件夹为空:" + KUtil.NAME_FOLDER_CCP);
return false;
}
//pb.showDialog();
//TODO 如果名称上不匹配也要提示
int zcy=-1,zcg=-1,bj=-1,mxq=-1,zcq=-1;
int h_num = 0;
for (int i = 0; i < len; i++) {
InterfaceAIFComponent c = ccpItems[i].getComponent();
pb.setText("加载对象:" + c + "( " + (i + 1) + " / " + len + " )");
if (c instanceof TCComponentItem) {
String cctype="";
boolean hasType=false;
for(Map.Entry<String, String> me:typeMap.entrySet()) {
String name=c.getProperty("object_name");
String key=me.getKey();
String[] value=me.getValue().split(";");
for (int j = 0; j < value.length; j++) {
if(name.contains(value[j] )) {
cctype=key;
hasType=true;
break;
}
}
if(hasType==true) {
break;
}
}
switch(cctype) {
case "ZCY":
zcy++;
break;
case "ZCG":
zcg++;
break;
case "BJ":
bj++;
break;
case "MXQ":
mxq++;
break;
case "ZCQ":
zcq++;
break;
default:
break;
}
TCComponentItemRevision rev = ((TCComponentItem) c).getLatestItemRevision();
System.out.println("找到对象:" + c + ", 最新版本:" + rev);
String type = rev.getType();
if (rev != null && type.equals("Part Revision")) {
FactoryNoZYBean bean = new FactoryNoZYBean(beanList.size()+1, rev);
beanList.add(bean);
dialog.tm_bom.addRow(bean.getRowData(dialog.qz,typeMap));//TODO 前缀需要修改
String code = bean.getP_code();
if(!code.equals(""))
{
h_num++;
lsms.add(code);
}
}
}
}
String[] prefixString=new String[typeMap.size()];
SimpleDateFormat sdf=new SimpleDateFormat("yyMM");
Date date=new Date();
String dateString=sdf.format(date);
int i1=0;
for(Map.Entry<String, String> me:typeMap.entrySet()) {
String key=me.getKey();
prefixString[i1]=key+dateString;
i1++;
}
//换成数据库,因为普通用户就算开旁路也部门修改首选项
Connection conn=null;
conn=dialog.connect(conn);
String[] typeString=new String[] {"ZCY","ZCG","BJ","MXQ","ZCQ"};
String query="select * from CHINT_FLOW WHERE TIME='"+dateString+"'";
Statement stmt = conn.createStatement();
ResultSet rs_get = null;
for (int i = 0; i < typeString.length; i++) {
String selectQuery="select * from CHINT_FLOW where TYPE='"+typeString[i]+"' and TIME='"+dateString+"'";
String insertQuery="insert into CHINT_FLOW (TYPE,TIME,FLOW) values ('"+typeString[i]+"','"+dateString+"','001')";
rs_get = stmt.executeQuery(selectQuery);
if(rs_get.next()) {
if (rs_get != null) {
rs_get.close();
}
}else {
rs_get = stmt.executeQuery(insertQuery);
if (rs_get != null) {
rs_get.close();
}
}
}
rs_get = stmt.executeQuery(query);
String[] values=new String[5];
int count=0;
while (rs_get.next()) {
String type=rs_get.getString("TYPE");
String time=rs_get.getString("TIME");
String flow=rs_get.getString("FLOW");
values[count]=type+";"+time+";"+flow;
count++;
}
dialog.disconnect(conn, stmt, rs_get);
//如果没有某种类型的就不要显示范围
for (int i = 0; i < values.length; i++) {
String id=values[i].split(";")[0]+values[i].split(";")[1]+values[i].split(";")[2];
TCComponent[] comps=session.search("零组件 ID", new String[] {"零组件 ID"}, new String [] {id});
if(comps!=null) {
String lsm="";
switch(values[i].split(";")[0]) {
case "ZCY":
if(zcy<0) {
lsm= "";
dialog.jtf_zcy.setVisible(false);
// dialog.panel2.remove(dialog.jtf_zcy);
}else {
//增加判断是否是当前月份
lsm= values[i].split(";")[0]+":"+values[i].split(";")[2]+"-"+String.format("%03d", zcy+Integer.valueOf(values[i].split(";")[2]));
// dialog.jtf_zcy.setVisible(true);
}
dialog.jtf_zcy.setText(lsm);
break;
case "ZCG":
if(zcg<0) {
lsm= "";
dialog.jtf_zcg.setVisible(false);
// dialog.panel2.remove(dialog.jtf_zcg);
}else {
dialog.jtf_zcg.setVisible(true);
lsm =values[i].split(";")[0]+":" +values[i].split(";")[2]+"-"+String.format("%03d", zcg+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_zcg.setText(lsm);
break;
case "BJ":
if(bj<0) {
lsm= "";
dialog.jtf_bj.setVisible(false);
// dialog.panel2.remove(dialog.jtf_bj);
}else {
dialog.jtf_bj.setVisible(true);
lsm =values[i].split(";")[0]+":" + values[i].split(";")[2]+"-"+String.format("%03d", bj+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_bj.setText(lsm);
break;
case "MXQ":
if(mxq<0) {
lsm= "";
dialog.jtf_mxq.setVisible(false);
dialog.panel2.remove(dialog.jtf_mxq);
}else {
dialog.jtf_mxq.setVisible(true);
lsm =values[i].split(";")[0]+":" + values[i].split(";")[2]+"-"+String.format("%03d", mxq+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_mxq.setText(lsm);
break;
case "ZCQ":
if(zcq<0) {
lsm= "";
dialog.jtf_zcq.setVisible(false);
dialog.panel2.remove(dialog.jtf_zcq);
}else {
dialog.jtf_zcq.setVisible(true);
lsm =values[i].split(";")[0]+":" + values[i].split(";")[2]+"-"+String.format("%03d", zcq+Integer.valueOf(values[i].split(";")[2]));
}
dialog.jtf_zcq.setText(lsm);
break;
default:
break;
}
}
}
return true;
}
public static void main(String[] args) {
Vector<String> vecs2 = new Vector<String>();
int code = Integer.parseInt("042");
System.out.println("code:["+code+"]");
vecs2.add(String.valueOf(code));
for(int i=40;i<45;i++)
{
System.out.println("i:"+i);
int index = vecs2.indexOf(String.valueOf(Integer.parseInt(""+i)));
if(index!=-1)
{
System.out.println("index:"+index);
System.out.println("存在相同值");
vecs2.remove(""+i);
//vecs2.removeElementAt(index);
continue;
}
vecs2.add(""+i);
}
for(int i=0;i<vecs2.size();i++)
{
System.out.println("vec:"+vecs2.get(i));
}
}
public String lsm(String lsm) {
if(lsm.length()==0) {
return lsm;
}else {
lsm=lsm.split(":")[1].split("-")[1];
int lsmInt=Integer.valueOf(lsm)+1;
lsm=String.format("%03d", lsmInt);
return lsm;
}
}
public Map<String,String> addMap(Map<String, String> rangeMap,String text){
String[] type=text.split(":");
if(type.length>1) {
rangeMap.put(type[0], type[1]);
}
return rangeMap;
}
/*createCode=1表示不用新建createCode=0表示需要新建*/
public void assign(ProgressBar pb,int index2,int createCode) throws Exception{
//获得所有的表格数据
Map<String, String> rangeMap=new HashMap<>();
rangeMap=addMap(rangeMap, dialog.jtf_zcy.getText());
rangeMap=addMap(rangeMap, dialog.jtf_zcg.getText());
rangeMap=addMap(rangeMap, dialog.jtf_bj.getText());
rangeMap=addMap(rangeMap, dialog.jtf_mxq.getText());
rangeMap=addMap(rangeMap, dialog.jtf_zcq.getText());
index2=dialog.t_bom.getRowCount();
Map<String, List<String>> map=new HashMap<>();
Map<String, String> repeatMap=new HashMap<>();
StringBuilder sb=new StringBuilder("");
for (int i = 0; i < index2; i++) {
String prefix=(String) dialog.t_bom.getValueAt(i, 5);//流水码前缀
String flowNo=(String) dialog.t_bom.getValueAt(i, 6);//流水码
if(flowNo.trim().length()>0) {
if(repeatMap.containsValue(prefix+flowNo)) {
for(Map.Entry<String, String> me:repeatMap.entrySet()) {
if(me.getValue().equals(prefix+flowNo)) {
sb.append("第"+me.getKey()+"行流水码与第"+(i+1)+"行重复\n");
break;
}
}
}else {
repeatMap.put(i+1+"", prefix+flowNo);
}
}else {
sb.append("第"+(i+1)+"行流水码未填写\n");
continue;
}
List<String> value=map.get(prefix);
if(value!=null) {
if(value.contains(flowNo)) {
// sb.append("第"+(i+1)+"行流水码重复,请检查\n");
continue;
// throw new Exception("第"+(i+1)+"列流水码重复,请检查");
}else {
for(Map.Entry<String, String> me:rangeMap.entrySet()) {
if(prefix.startsWith(me.getKey())) {
String[] range=me.getValue().split("-");
int r1=Integer.valueOf(range[0]);
int r2=Integer.valueOf(range[1]);
int r=Integer.valueOf(flowNo);
if(r>r2||r<r1) {
sb.append("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码\n");
break;
}else {
value.add(flowNo);
map.put(prefix, value);
}
}
}
}
}else {
for(Map.Entry<String, String> me:rangeMap.entrySet()) {
if(prefix.startsWith(me.getKey())) {
String[] range=me.getValue().split("-");
int r1=Integer.valueOf(range[0]);
int r2=Integer.valueOf(range[1]);
int r=Integer.valueOf(flowNo);
if(r>r2||r<r1) {
sb.append("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码\n");
break;
}else {
value=new ArrayList<>();
value.add(flowNo);
map.put(prefix, value);
}
}
}
}
}
if(sb.length()>0) {
throw new Exception("存在以下问题,请检查:\n"+sb.toString());
}
//新建并且把对象粘贴到指定位置
int len = beanList.size();
// System.out.println("len==========="+len);
// System.out.println("createCode==========="+createCode);
if(len==0) {
return;
}
Map<String, TCComponentItemRevision> facMap=new HashMap<>();
StringBuilder sb2=new StringBuilder("");
if(createCode==0) {
for (int i = 0; i < len; i++) {
TCComponentItemRevision ccpRev=beanList.get(i).getCcpRev();
String item_id=(String)dialog.t_bom.getValueAt(i, 5)+(String)dialog.t_bom.getValueAt(i, 6);
//查询是否存在,不存在再创建
TCComponent[] item=session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {item_id});
if(item==null||item.length==0) {
facMap.put(item_id, ccpRev);
}else {
sb2.append("存在出厂编号对象:"+item_id+"\n");
}
}
}else {
for (int i = 0; i < len; i++) {
TCComponentItemRevision ccpRev=beanList.get(i).getCcpRev();
String item_id=(String)dialog.t_bom.getValueAt(i, 5)+(String)dialog.t_bom.getValueAt(i, 6);
//查询是否存在,不存在再创建
facMap.put(item_id, ccpRev);
}
}
if(sb2.length()>0) {
throw new Exception("保存失败:\n"+sb2.toString());
}else {
if(createCode==0) {
for(Map.Entry<String, TCComponentItemRevision> me:facMap.entrySet()) {
String item_id=me.getKey();
TCComponentItemRevision rev=me.getValue();
//20200425出厂编号对象名称改成"出厂编号"
TCComponentItem item = KUtil.newItem(session,BomBuildDialogController.TYPE_FACTORYNO,item_id,"出厂编号");
TCComponent[] comps= rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO);
rev.cutOperation(BomBuildDialogController.REL_FACTORYNO, comps);
rev.add(BomBuildDialogController.REL_FACTORYNO, item);
TCComponentFolder folder = dialog.factorNoFolder;
if(folder!=null)
{
folder.cutOperation("contents", comps);
folder.add("contents", item);
}
}
}else {
// System.out.println("开始保存");
for(Map.Entry<String, TCComponentItemRevision> me:facMap.entrySet()) {
String item_id=me.getKey();
System.out.println(item_id);
TCComponentItemRevision rev=me.getValue();
System.out.println(rev.getProperty("item_id"));
TCComponent[] item = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {item_id});
TCComponent[] comps= rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO);
rev.cutOperation(BomBuildDialogController.REL_FACTORYNO, comps);
// System.out.println("1111111");
rev.add(BomBuildDialogController.REL_FACTORYNO, item[0]);
}
}
}
if(createCode==0) {
//修改首选项zt2_ZY的流水码
Map<String,String> lsmMap=new HashMap<>();
String lsm="";
lsm=lsm(dialog.jtf_zcy.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_zcy.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_zcg.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_zcg.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_bj.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_bj.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_mxq.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_mxq.getText().split(":")[0], lsm);
}
lsm=lsm(dialog.jtf_zcq.getText());
if(lsm.length()>0) {
lsmMap.put(dialog.jtf_zcq.getText().split(":")[0], lsm);
}
SimpleDateFormat sdf=new SimpleDateFormat("yyMM");
String dateString=sdf.format(new Date());
List<String> sqlList=new ArrayList<>();
for (Map.Entry<String, String> me:lsmMap.entrySet()) {
sqlList.add("update CHINT_FLOW set TIME='"+dateString+"', FLOW='"+me.getValue()+"' where TYPE='"+me.getKey()+"' and TIME='"+dateString+"'");
}
Connection conn=null;
conn=dialog.connect(conn);
Statement stmt = conn.createStatement();
ResultSet rs_get = null;
for (int i = 0; i < sqlList.size(); i++) {
rs_get = stmt.executeQuery(sqlList.get(i));
if ((rs_get.next())) {
System.out.println(" update2==========");
}
if (rs_get != null) {
rs_get.close();
}
}
dialog.disconnect(conn, stmt, rs_get);
}
pb.disposeDialog();
KUtil.info(dialog, "保存出厂编号结束");
if(true) {
return;
}
if(lsms.size()==beanList.size())
{
throw new Exception("该项目无需分配出厂编号");
}
Vector<String> vecs = new Vector<String>();
Vector<String> vecs2 = new Vector<String>();
for(int i=min;i<=max;i++)
{
vecs2.add(String.valueOf(i));
}
int index=0;
for(int i=0;i<len;i++)
{
Object obj = dialog.t_bom.getValueAt(i, 6);
if(obj.equals(""))
{
throw new Exception("第"+(i+1)+"列流水码未填写,请检查");
}
if(obj!=null && !obj.equals(""))
{
String code = String.valueOf(obj);
if(vecs2.indexOf(String.valueOf(Integer.parseInt(code)))==-1 && beanList.get(i).getFactNoItem()==null)
{
throw new Exception("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码");
}
if(vecs.indexOf(code)!=-1)
{
throw new Exception("第"+(i+1)+"行与第"+(vecs.indexOf(code)+1)+"列流水码重复不允许为多个物料分配相同ID的出厂编码");
}
if(beanList.get(i).getFactNoItem()!=null)
{
index++;
}
vecs.add(code);
}
}
if(vecs.size()<len)
{
throw new Exception("请为每一列分配出厂编号");
}
DT_FACTORY_NUMBER_REQITEMSITEM items[] = new DT_FACTORY_NUMBER_REQITEMSITEM[len];
pb.showDialog();
for (int i = 0; i < len; i++) {
pb.setText("分配出厂编号...( " + (i + 1) + " / " + len + " )");
Object obj = dialog.t_bom.getValueAt(i, 6);
String newId = "";
FactoryNoZYBean bean = beanList.get(i);
//DT_FACTORY_NUMBER_REQITEMSITEM item = new DT_FACTORY_NUMBER_REQITEMSITEM();
String con_id = projCon==null?"":projCon.getProperty("item_id");
String wbs = projCon==null?"":projCon.getProperty("zt2_WBSNo");
/*
item.setPSPID(con_id);
item.setZPSPID(wbs);
item.setMATNR(bean.getMaterialNo());
item.setZZD(bean.getSite());
item.setZGH(bean.getTankNo());
item.setSERNR(bean.getFactNoItemID());
item.setWERKS("M008"); //中压默认MOO8
*/
if(index!=0) {
int code=0;
if(obj!=null && !obj.equals("")) {
code = Integer.parseInt((String) obj);
int cind = vecs.indexOf(obj);
System.out.println("cind:"+cind);
System.out.println("code"+code);
//vecs.remove(""+code);
vecs.remove(cind);
}else
{
String str = vecs.get(0);
code = Integer.parseInt(str);
vecs.remove(0);
}
newId= beanList.get(i).assign(session,prefix,dialog,code);
}
else {
newId= beanList.get(i).assign(session,prefix,dialog,-1);
}
if(newId!=null) {
dialog.t_bom.setValueAt(newId.substring(0, 7), i, 5);
dialog.t_bom.setValueAt(newId.substring(7,newId.length()), i,6);
}
//items[i] = item;
}
//sendFactoryNo(items);
pb.disposeDialog();
KUtil.info(dialog, "分配出厂编号结束");
}
public void assign(ProgressBar pb) throws Exception{
int len = beanList.size();
if(len==0) {
return;
}
if(lsms.size()==beanList.size())
{
throw new Exception("该项目无需分配出厂编号");
}
Vector<String> vecs = new Vector<String>();
Vector<String> vecs2 = new Vector<String>();
for(int i=min;i<=max;i++)
{
vecs2.add(String.valueOf(i));
}
int index=0;
for(int i=0;i<len;i++)
{
Object obj = dialog.t_bom.getValueAt(i, 6);
if(obj.equals(""))
{
throw new Exception("第"+(i+1)+"列流水码未填写,请检查");
}
if(obj!=null && !obj.equals(""))
{
String code = String.valueOf(obj);
if(vecs2.indexOf(String.valueOf(Integer.parseInt(code)))==-1 && beanList.get(i).getFactNoItem()==null)
{
throw new Exception("第"+(i+1)+"行流水码填写错误,请填写指定范围内的流水码");
}
if(vecs.indexOf(code)!=-1)
{
throw new Exception("第"+(i+1)+"行与第"+(vecs.indexOf(code)+1)+"列流水码重复不允许为多个物料分配相同ID的出厂编码");
}
if(beanList.get(i).getFactNoItem()!=null)
{
index++;
}
vecs.add(code);
}
}
if(vecs.size()<len)
{
throw new Exception("请为每一列分配出厂编号");
}
DT_FACTORY_NUMBER_REQITEMSITEM items[] = new DT_FACTORY_NUMBER_REQITEMSITEM[len];
pb.showDialog();
for (int i = 0; i < len; i++) {
pb.setText("分配出厂编号...( " + (i + 1) + " / " + len + " )");
Object obj = dialog.t_bom.getValueAt(i, 6);
String newId = "";
FactoryNoZYBean bean = beanList.get(i);
//DT_FACTORY_NUMBER_REQITEMSITEM item = new DT_FACTORY_NUMBER_REQITEMSITEM();
String con_id = projCon==null?"":projCon.getProperty("item_id");
String wbs = projCon==null?"":projCon.getProperty("zt2_WBSNo");
/*
item.setPSPID(con_id);
item.setZPSPID(wbs);
item.setMATNR(bean.getMaterialNo());
item.setZZD(bean.getSite());
item.setZGH(bean.getTankNo());
item.setSERNR(bean.getFactNoItemID());
item.setWERKS("M008"); //中压默认MOO8
*/
if(index!=0) {
int code=0;
if(obj!=null && !obj.equals("")) {
code = Integer.parseInt((String) obj);
int cind = vecs.indexOf(obj);
System.out.println("cind:"+cind);
System.out.println("code"+code);
//vecs.remove(""+code);
vecs.remove(cind);
}else
{
String str = vecs.get(0);
code = Integer.parseInt(str);
vecs.remove(0);
}
newId= beanList.get(i).assign(session,prefix,dialog,code);
}
else {
newId= beanList.get(i).assign(session,prefix,dialog,-1);
}
if(newId!=null) {
dialog.t_bom.setValueAt(newId.substring(0, 7), i, 5);
dialog.t_bom.setValueAt(newId.substring(7,newId.length()), i,6);
}
//items[i] = item;
}
//sendFactoryNo(items);
pb.disposeDialog();
KUtil.info(dialog, "分配出厂编号结束");
}
public void recovery()
{
int len = beanList.size();
for (int i = 0; i < len; i++) {
dialog.t_bom.setValueAt(beanList.get(i).getP_code(), i,6);
}
}
}

@ -0,0 +1,8 @@
Class1=CommandTest.CommandTest1@Excute
Class2=CommandTest.CommandTest2@Excute
Class3=CommandTest.CommandTest3@Suspend
Class4=CommandTest.CommandTest4@Skip
Class5=CommandTest.CommandTest5@Excute
Class6=CommandTest.CommandTest6@Excute
Class7=CommandTest.CommandTest7@Excute
BOMSQL=INSERT INTO Z888M_BOM_D (PITMID_NEW,PITMID_OLD,BOMVER,PQTY,ITMID_NEW,ITMID_OLD,QTY,EMPID) VALUES([\u7236\u7269\u6599\u7F16\u7801],[\u539F\u7236\u7269\u6599\u7F16\u7801],[\u7248\u672C],[\u6BCD\u4EF6\u57FA\u6570],[\u5B50\u7269\u6599\u7F16\u7801],[\u539F\u5B50\u7269\u6599\u7F16\u7801],[\u6570\u91CF],[\u7528\u6237\u7F16\u7801])

@ -0,0 +1,8 @@
Class1=com.connor.chint.sap2.bom.CommandTest.CommandTest1@Excute
Class2=com.connor.chint.sap2.bom.CommandTest.CommandTest2@Excute
Class3=com.connor.chint.sap2.bom.CommandTest.CommandTest3@Suspend
Class4=com.connor.chint.sap2.bom.CommandTest.CommandTest4@Skip
Class5=com.connor.chint.sap2.bom.CommandTest.CommandTest5@Excute
Class6=com.connor.chint.sap2.bom.CommandTest.CommandTest6@Excute
Class7=com.connor.chint.sap2.bom.CommandTest.CommandTest7@Excute
BOMSQL=INSERT INTO Z888M_BOM_D (PITMID_NEW,PITMID_OLD,BOMVER,PQTY,ITMID_NEW,ITMID_OLD,QTY,EMPID) VALUES([\u7236\u7269\u6599\u7F16\u7801],[\u539F\u7236\u7269\u6599\u7F16\u7801],[\u7248\u672C],[\u6BCD\u4EF6\u57FA\u6570],[\u5B50\u7269\u6599\u7F16\u7801],[\u539F\u5B50\u7269\u6599\u7F16\u7801],[\u6570\u91CF],[\u7528\u6237\u7F16\u7801])

@ -0,0 +1,6 @@
DBDriver=oracle.jdbc.driver.OracleDriver
Connection=jdbc:oracle:thin:@192.168.1.221:1521:TC10
User=admin
Password=admin
TableName=BOMCHECKINFO
TableName1=BOMCOMPLETEINFO

@ -0,0 +1,8 @@
log4j.rootLogger=DEBUG,A1,R
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.MaxFileSize=200KB log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

@ -0,0 +1,8 @@
DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver
Connection=jdbc:sqlserver://192.168.1.252:1433; DatabaseName=AErp_RTDQ
User=sa
Password=pushi
switchImportFlagMaterial=10
switchImportFlagBOMs=10
PartTableName=Z888M_ITMINFO_D
BomTableName=Z888M_BOM_D

@ -0,0 +1,4 @@
CHINT_ECRTemplete=CHINT_ECRTemplete
ID_QUERY=select flow,time from chint_ecn_flow WHERE TYPE='KGS'
ID_UPDATE=UPDATE CHINT_ECN_FLOW SET FLOW=? WHERE TYPE='KGS'
ID_INSERT=insert into chint_ecn_flow(type,flow,time) values(?,?,?)

@ -0,0 +1,120 @@
package com.connor.chint.sap2.general;
public class GenPartBean {
private int index;
private String companyCode;
private String goodsCode;
private String name;
private String bpNo;
private String goodsFullInfo;
private String teRe;
private String unitCode;
private String pmpcCode;
private String spec;
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getGoodsCode() {
return goodsCode;
}
public void setGoodsCode(String goodsCode) {
this.goodsCode = goodsCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBpNo() {
return bpNo;
}
public void setBpNo(String bpNo) {
this.bpNo = bpNo;
}
public String getGoodsFullInfo() {
return goodsFullInfo;
}
public void setGoodsFullInfo(String goodsFullInfo) {
this.goodsFullInfo = goodsFullInfo;
}
public String getTeRe() {
return teRe;
}
public void setTeRe(String teRe) {
this.teRe = teRe;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
public String getPmpcCode() {
return pmpcCode;
}
public void setPmpcCode(String pmpcCode) {
this.pmpcCode = pmpcCode;
}
public GenPartBean(int index, String companyCode, String goodsCode, String name, String bpNo,
String goodsFullInfo, String teRe, String unitCode, String pmpcCode) {
super();
this.index = index;
this.companyCode = companyCode;
this.goodsCode = goodsCode;
this.name = name;
this.bpNo = bpNo;
this.goodsFullInfo = goodsFullInfo;
this.teRe = teRe;
this.unitCode = unitCode;
this.pmpcCode = pmpcCode;
spec="";
String strs[] = goodsFullInfo.split(" ");
if(strs.length==3)
{
spec=strs[2];
}
}
@Override
public String toString() {
// TODO Auto-generated method stub
return ""+this.index;
}
public Object[] readData()
{
return new Object[] {this,name,bpNo,spec};
}
public Object[] datas()
{
return new Object[] {companyCode,goodsCode,name,pmpcCode};
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
}

@ -0,0 +1,223 @@
package com.connor.chint.sap2.general;
import java.awt.Rectangle;
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 javax.swing.JComboBox;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.util.MessageBox;
public class GeneralManagementController {
private GeneralManagementDialog dialog;
//private List<String> names =new ArrayList<String>();
//private List<String> bpNos =new ArrayList<String>();
protected Map<String, List<String>> name_BpNos = new HashMap<String, List<String>>();
// t.cgdpmpccode like '990101%'
private static String SQL_QUERY_ALL="select t.GoodsName,t.GoodsBpNo from ccemvw_cgd t where 1=1 and t.Goodspmpccode like '220103001'";
private static String SQL_QUERY="select t.CompanyCodeStr,t.GoodsCode,t.GoodsName,t.GoodsBpNo,t.GoodsFullInfo,t.GoodsTeRe,t.GoodsUnitCode,t.GoodsPmpcCode from ccemvw_cgd t where 1=1 and t.Goodspmpccode like '220103001'";
public GeneralManagementController(GeneralManagementDialog dialog) {
// TODO Auto-generated constructor stub
this.dialog = dialog;
}
public boolean checkConn()
{
return SqlUtil.getConnection()==null?false:true;
}
public static void main(String[] args) {
String sss = "7ZDB002-TJSJ001";
int index =-1;
for(int i=sss.length()-1;i>=0;i--)
{
if(sss.charAt(i)>'9'||sss.charAt(i)<'0')
{
index = i;
break;
}
}
System.out.println("ss1:"+sss.substring(0,index+1));
System.out.println("流水码:"+sss.substring(index+1));
}
public void queryAll() throws SQLException
{
ResultSet rs = SqlUtil.read(SQL_QUERY_ALL);
List<String> names = new ArrayList<String>();
while(rs.next())
{
String name= rs.getString(1);
String bpNo= rs.getString(2);
if(!names.contains(name))
{
names.add(name);
List<String> lists = new ArrayList<String>();
lists.add(bpNo);
name_BpNos.put(name, lists);
lists = null;
}else
{
if(!name_BpNos.get(name).contains(bpNo))
{
name_BpNos.get(name).add(bpNo);
}
}
//GenPartBean bean =new GenPartBean(dialog.gp_lists.size()+1, companyCode, goodsCode, name, bpNo, goodsFullInfo, teRe, unitCode, pmpcCode);
//dialog.gp_lists.add(bean);
}
if(!name_BpNos.isEmpty())
{
String name_s[] = new String[names.size()];
names.toArray(name_s);
dialog.j_Name = new JComboBox<String>(name_s);
dialog.j_Name.setBounds(new Rectangle(119, 43, 95, 22));
dialog.j_Name.setEditable(true);
System.out.println("锁定值:"+dialog.j_Name.getSelectedItem());
System.out.println("name_s[0]:"+name_s[0]);
List<String> bpNos = name_BpNos.get(name_s[0]);
String bpNo_s[] = new String[bpNos.size()];
bpNos.toArray(bpNo_s);
dialog.j_BpNo = new JComboBox<String>(bpNo_s);
dialog.j_BpNo.setBounds(new Rectangle(119, 43, 95, 22));
dialog.j_BpNo.setEditable(true);
System.out.println("存在通用件");
}else
{
dialog.j_Name = new JComboBox<String>();
dialog.j_Name.setBounds(new Rectangle(119, 43, 95, 22));
dialog.j_Name.setEditable(true);
dialog.j_BpNo = new JComboBox<String>();
dialog.j_BpNo.setBounds(new Rectangle(119, 43, 95, 22));
dialog.j_BpNo.setEditable(true);
}
}
//刷新表格
public void refreshData(List<GenPartBean> beans) {
dialog.tm_part.getDataVector().clear();
dialog.t_part.clearSelection();
dialog.t_part.revalidate();
dialog.t_part.repaint();
//beans.clear();
for (GenPartBean b : beans) {
dialog.tm_part.addRow(b.readData());
}
dialog.t_part.revalidate();
}
public void addRow(GenPartBean bean)
{
String bpNo = bean.getBpNo();
if(bpNo.trim().length()==0)
{
return;
}
int index = -1;
for(int i=bpNo.length()-1;i>=0;i--)
{
if(bpNo.charAt(i)>'9'||bpNo.charAt(i)<'0')
{
index = i;
break;
}
}
if(index ==-1)
{
MessageBox.post("","",MessageBox.WARNING);
return ;
}
String qz = bpNo.substring(0,index+1);
String num = bpNo.substring(index+1);
}
public void doQuery() throws SQLException
{
String bpno = (String) dialog.j_BpNo.getSelectedItem();
String name = (String) dialog.j_Name.getSelectedItem();
String spec = dialog.j_spec.getText();
StringBuilder sql = new StringBuilder(SQL_QUERY);
List<String> objs = new ArrayList<String>();
if(bpno!=null && !bpno.equals(""))
{
sql.append(" and t.GoodsBpNo = ? ");
objs.add(bpno);
}
if(name!=null && !name.equals(""))
{
sql.append(" and t.GoodsName = ? ");
objs.add(name);
}
if(spec!=null && !spec.equals("") && !spec.equals("*"))
{
sql.append(" and t.GoodsFullInfo like ? ");
objs.add(getRep(spec,true));
}
System.out.println("query_SQL:"+sql.toString());
System.out.println(objs);
ResultSet rs = SqlUtil.read(objs.toArray(), sql.toString());
dialog.gp_lists.clear();
while(rs.next())
{
String companyCode = rs.getString(1);
String goodsCode= rs.getString(2);
String name2= rs.getString(3);
String bpNo= rs.getString(4);
String goodsFullInfo= rs.getString(5);
String teRe= rs.getString(6);
String unitCode= rs.getString(7);
String pmpcCode= rs.getString(8);
GenPartBean bean =new GenPartBean(dialog.gp_lists.size()+1, companyCode, goodsCode, name2, bpNo, goodsFullInfo, teRe, unitCode, pmpcCode);
System.out.println("查到一个结果");
dialog.gp_lists.add(bean);
}
refreshData(dialog.gp_lists);
objs=null;
}
public String getRep(String str,boolean flag)
{
StringBuilder stb = new StringBuilder();
if(!flag)
{
return str.replace("*", "%");
}
if(!str.startsWith("*"))
{
stb.append("%");
}
stb.append(str.trim());
if(!str.endsWith("*"))
{
stb.append("%");
}
str = (stb.toString()).replace("*", "%");
return str;
}
}

@ -0,0 +1,340 @@
package com.connor.chint.sap2.general;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class GeneralManagementDialog extends AbstractAIFDialog {
private AbstractAIFApplication app;
private TCSession session;
private GeneralManagementController controller;
protected DefaultTableModel tm_part;
protected JTable t_part;
public static final String[] HEADER = new String[] { "序号", "图样代号","图样名称","规格","申请人" ,"申请时间"};
public static final int[] HEADERWIDTH = new int[] { 50, 60, 100,100,100,60,60};
protected JComboBox<String> j_Name;
protected JComboBox<String> j_BpNo;
protected JTextField j_spec;
private JButton b_add;
private JButton b_remove;
private JButton b_apply;
private JButton b_copy;
private JButton b_query;
protected List<GenPartBean> gp_lists =new ArrayList<GenPartBean>();
public GeneralManagementDialog(AbstractAIFApplication app) {
super(false);
this.app = app;
this.session = (TCSession) app.getSession();
this.controller = new GeneralManagementController(this);
}
@Override
public void run() {
try {
if(!controller.checkConn())
{
KUtil.error(this, "连接数据库失败:\n");
return;
}
controller.queryAll();
initUI();
//controller.refreshData(gp_lists);
addListener();
showDialog();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void initUI()
{
//setBounds(100, 100, 450, 300);
this.setPreferredSize(new Dimension(800, 600));
this.setMinimumSize(new Dimension(750, 480));
this.setTitle("通用件管理");
this.getContentPane().setLayout(new BorderLayout());
this.add(BorderLayout.EAST,getSRightPanel());
this.add(BorderLayout.CENTER,getCenterPanel());
}
private JPanel getNorthPanel()
{
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
JLabel kl =new JLabel(" ");
JLabel l_Name = new JLabel("通用件名称: ");
j_Name.setPreferredSize(new Dimension(120,25));
JLabel l_BpNo = new JLabel("图样代号: ");
j_BpNo.setPreferredSize(new Dimension(120,25));
j_spec = new JTextField();
j_spec.setPreferredSize(new Dimension(120,25));
panel.add(l_Name);
panel.add(j_Name);
panel.add(new JLabel(" "));
panel.add(l_BpNo);
panel.add(j_BpNo);
panel.add(new JLabel(" "));
panel.add(new JLabel("规格:"));
panel.add(new JLabel(" "));
panel.add(j_spec);
panel.add(new JLabel(" "));
panel.add(new JLabel(" "));
panel.add(new JLabel(" "));
panel.add(new JLabel(" "));
panel.add(new JLabel(" "));
panel.add(new JLabel(" "));
return panel;
}
private JPanel getCenterPanel()
{
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER,getTablePanel());
panel.add(BorderLayout.NORTH,getNorthPanel());
return panel;
}
private void addListener()
{
b_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
int rowConut = t_part.getRowCount();
if(rowConut!=1)
return;
GenPartBean bean = (GenPartBean) tm_part.getValueAt(0, 0);
String bpno = bean.getBpNo();
tm_part.addRow(new Vector<String>());
//System.out.println("新增行");
}
});
b_remove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setCompEnabled(false);
int rows[]=t_part.getSelectedRows();
System.out.println("删除行'");
if(rows.length==0)
{
setCompEnabled(true);
MessageBox.post(GeneralManagementDialog.this, "请选择要删除的行" , "", MessageBox.WARNING);
return;
}
ProgressBar pb = new ProgressBar(GeneralManagementDialog.this, new Dimension(250, 50));
pb.setText("数据删除...");
pb.showDialog();
for(int i=rows.length-1;i>=0;i--)
{
pb.setText("正在删除第"+rows[i]+"行数据");
System.out.println("删除记录");
tm_part.removeRow(rows[i]);
}
pb.disposeDialog();
setCompEnabled(true);
MessageBox.post(GeneralManagementDialog.this, "数据删除成功" , "", MessageBox.INFORMATION);
}
});
b_query.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
ProgressBar pb = new ProgressBar(GeneralManagementDialog.this, new Dimension(250, 50));
setCompEnabled(false);
try {
pb.setText("通用件查询...");
pb.showDialog();
controller.doQuery();
pb.disposeDialog();
setCompEnabled(true);
MessageBox.post(GeneralManagementDialog.this, "查询结束" , "", MessageBox.INFORMATION);
} catch (SQLException e1) {
// TODO Auto-generated catch block
pb.disposeDialog();
setCompEnabled(true);
MessageBox.post(GeneralManagementDialog.this, "查询时时发生异常:" , "", MessageBox.ERROR);
e1.printStackTrace();
}
}
});
j_spec.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if(e.getKeyChar()==KeyEvent.VK_ENTER ) //按回车键执行相应操作;
{
ProgressBar pb = new ProgressBar(GeneralManagementDialog.this, new Dimension(250, 50));
setCompEnabled(false);
try {
pb.setText("通用件查询...");
pb.showDialog();
controller.doQuery();
pb.disposeDialog();
setCompEnabled(true);
MessageBox.post(GeneralManagementDialog.this, "查询结束" , "", MessageBox.INFORMATION);
} catch (SQLException e1) {
// TODO Auto-generated catch block
pb.disposeDialog();
setCompEnabled(true);
MessageBox.post(GeneralManagementDialog.this, "查询时时发生异常:" , "", MessageBox.ERROR);
e1.printStackTrace();
}
}
}
});
j_Name.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
if(e.getStateChange() == ItemEvent.SELECTED)
{
String name = (String) j_Name.getSelectedItem();
List<String> bpNos = controller.name_BpNos.get(name);
String bpNo_s[] = new String[bpNos.size()];
bpNos.toArray(bpNo_s);
//j_BpNo.removeAll();
j_BpNo.removeAllItems();
for(int i=0;i<bpNo_s.length;i++)
{
j_BpNo.addItem(bpNo_s[i]);
}
//j_BpNo.setModel(aModel);
}
}
});
}
private void setCompEnabled(boolean b) {
this.b_add.setEnabled(b);
this.b_apply.setEnabled(b);
this.b_copy.setEnabled(b);
this.b_query.setEnabled(b);
this.b_remove.setEnabled(b);
}
private JPanel getSRightPanel()
{
JPanel panel = new JPanel();
//panel.setLayout(new GridLayout(2, 1, 10, 30));
panel.setPreferredSize(new Dimension(100, 470));
BoxLayout layout=new BoxLayout(panel, BoxLayout.Y_AXIS);
panel.setLayout(layout);
//panel.setLayout(null);
b_add = new JButton("新增");
b_remove = new JButton("删除");
b_apply = new JButton("申请");
b_copy= new JButton("复制");
b_query = new JButton("查询");
panel.add(Box.createRigidArea(new Dimension(15, 5)));
panel.add(b_query);
panel.add(Box.createRigidArea(new Dimension(15, 65)));
panel.add(b_add);
panel.add(Box.createRigidArea(new Dimension(15, 20)));
panel.add(b_remove);
panel.add(Box.createRigidArea(new Dimension(15, 20))); //单纯的空白区域隔开
panel.add(b_apply);
panel.add(Box.createRigidArea(new Dimension(15, 20)));
panel.add(b_copy);
return panel;
}
private JPanel getTablePanel()
{
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
@Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if (column == 3)
return true;
return false;
}
};
tm_part.setDataVector(null, HEADER);
t_part.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_part.setRowHeight(23);
TableColumnModel colModel = this.t_part.getColumnModel();
int colCnt = HEADERWIDTH.length;
colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]);
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
//this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

@ -0,0 +1,422 @@
package com.connor.chint.sap2.modelAudit;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.RowFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import org.apache.commons.collections.map.HashedMap;
import com.connor.chint.sap2.bean.ModelAuditBean;
import com.connor.chint.sap2.proc_zy.CreateProcZYDialog;
import com.connor.chint.sap2.util.ConfirmDialogUtil;
import com.connor.chint.sap2.util.KUtil;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCException;
public class ModelSelectDialog extends JDialog {
private List<JCheckBox> checks= new ArrayList<JCheckBox>();
private JCheckBox jcom_all;
private JButton ok_btn;
private JButton cel_btn;
private int colnum=-1;
private JTable t_part;
private DefaultTableModel tm_part;
private String colName;
private Map<String, ModelSelectDialog> selectedDialogs=null;
private TableRowSorter<DefaultTableModel> sorter;
private JScrollPane checkPanel;
private JPanel panel2;
public JPanel getPanel2() {
return panel2;
}
public void setPanel2(JPanel panel2) {
this.panel2 = panel2;
}
public String getColName() {
return colName;
}
public void setColName(String colName) {
this.colName = colName;
}
public JScrollPane getCheckPanel() {
return checkPanel;
}
public void setCheckPanel(JScrollPane checkPanel) {
this.checkPanel = checkPanel;
}
//是否第一个按下的
private boolean isFirst = false;
public boolean isFirst() {
return isFirst;
}
public void setFirst(boolean isFirst) {
this.isFirst = isFirst;
}
public TableRowSorter<DefaultTableModel> getSorter() {
return sorter;
}
public void setSorter(TableRowSorter<DefaultTableModel> sorter) {
this.sorter = sorter;
}
public Map<String, ModelSelectDialog> getSelectedDialogs() {
return selectedDialogs;
}
public void setSelectedDialogs(Map<String, ModelSelectDialog> selectedDialogs) {
this.selectedDialogs = selectedDialogs;
}
public int getColnum() {
return colnum;
}
public void setColnum(int colnum) {
this.colnum = colnum;
}
public JButton getOk_btn() {
return ok_btn;
}
public void setOk_btn(JButton ok_btn) {
this.ok_btn = ok_btn;
}
public List<JCheckBox> getChecks() {
return checks;
}
public void setChecks(List<JCheckBox> checks) {
this.checks = checks;
}
public JCheckBox getJcom_all() {
return jcom_all;
}
public void setJcom_all(JCheckBox jcom_all) {
this.jcom_all = jcom_all;
}
public void repaintChecks()
{
if(isFirst)
return ;
this.setSize(400,400);
if(!jcom_all.isSelected())
jcom_all.doClick();
}
@Override
protected void processWindowEvent(WindowEvent e) {
// TODO Auto-generated method stub
if(e.getID()==WindowEvent.WINDOW_CLOSING )
{
repaintChecks();
}
super.processWindowEvent(e);
}
public ModelSelectDialog(String colName,DefaultTableModel table_model,List<String> values,
JTable table,TableRowSorter<DefaultTableModel> sort)
{
this.colName = colName;
this.t_part = table;
this.tm_part = table_model;
this.sorter = sort;
this.setTitle(colName);
Collections.sort(values);
checks.clear();
jcom_all = new JCheckBox("全部");
GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 5, 4, 5), 0, 0);
jcom_all.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
boolean flag = jcom_all.isSelected();
if(flag)
{
ok_btn.setEnabled(true);
}else
{
ok_btn.setEnabled(false);
}
for(JCheckBox j:checks)
{
j.setSelected(flag);
}
}
});
panel2 = new JPanel(new GridBagLayout());
panel2.setBorder(BorderFactory.createEmptyBorder(11, 5, 12, 5));
KUtil.newRow(panel2, new JLabel(""), s, 1);
KUtil.newRow(panel2, new JLabel(""), s, 1);
ok_btn = new JButton("确定");
cel_btn = new JButton("取消");
KUtil.addCol(panel2, ok_btn, s,1, 1);
KUtil.addCol(panel2, cel_btn, s,1, 1);
KUtil.addCol(panel2, new JLabel(""), s,0, 1);
cel_btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
repaintChecks();
dispose();
}
});
ok_btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean select_all = false;
select_all = isFirst;
if(isFirst)
{
if(jcom_all.isSelected())
{
isFirst = false;
}
}else
{
boolean flag = true;
if(selectedDialogs!=null)
{
for(String key:selectedDialogs.keySet())
{
if(selectedDialogs.get(key).isFirst())
{
flag = false;
break;
}
//selectedDialogs.get(key)
}
}
if(flag)
isFirst = true;
}
if(selectedDialogs!=null)
{
List<RowFilter<Object,Object>> filters = new ArrayList<RowFilter<Object,Object>>(2);
for(String key:selectedDialogs.keySet())
{
ModelSelectDialog dialog = selectedDialogs.get(key);
int index = dialog.getColnum();
if(index==colnum)
{
//System.out.println("列【"+index+"】全选");
//filters.add(RowFilter.regexFilter(null, index));
List<JCheckBox> chs = dialog.getChecks();
List<RowFilter<Object,Object>> filters2 = new ArrayList<RowFilter<Object,Object>>(2);
for(JCheckBox ch:chs)
{
if(ch.isSelected() )
{
filters2.add(RowFilter.regexFilter(ch.getText(), index));
}
}
if(filters2.size()>0)
{
filters.add(RowFilter.orFilter(filters2));
}
}else
{
if(!dialog.getJcom_all().isSelected())
{
List<JCheckBox> chs = dialog.getChecks();
List<RowFilter<Object,Object>> filters2 = new ArrayList<RowFilter<Object,Object>>(2);
for(JCheckBox ch:chs)
{
if(ch.isSelected() )
{
filters2.add(RowFilter.regexFilter(ch.getText(), index));
}
}
if(filters2.size()>0)
{
filters.add(RowFilter.orFilter(filters2));
}
}
}
}
if(filters.size()>0)
{
RowFilter rf =RowFilter.andFilter(filters);
//TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel>(tm_part);
t_part.setRowSorter(sorter);
sorter.setRowFilter(rf);
repaintCheckPanel(t_part, tm_part, selectedDialogs,sorter);
}
}
dispose();
}
});
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createEmptyBorder(11, 5, 12, 5));
this.setSize(400,400);
//GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 5, 4, 5), 0, 0);
jcom_all.setSelected(true);
System.out.println(jcom_all.getText()+"---");
KUtil.newRow(panel, new JLabel(""), s, 1);
KUtil.addCol(panel, jcom_all, s,0, 1);
for(int i=0;i<values.size();i++)
{
KUtil.newRow(panel, new JLabel(""), s, 1);
JCheckBox jcom = new JCheckBox(values.get(i));
jcom.setSelected(true);
KUtil.addCol(panel, jcom, s,0, 1);
checks.add(jcom);
}
for (JCheckBox jcom : checks) {
jcom.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//jcom_all.setSelected(true);
int index = 0;
for (JCheckBox j : checks) {
if (!j.isSelected()) {
index++;
}
}
//System.out.println("index:"+index+";checks:"+checks.size());
if(index==0)
{
ok_btn.setEnabled(true);
jcom_all.setSelected(true);
}else if(index == checks.size())
{
ok_btn.setEnabled(false);
jcom_all.setSelected(false);
}else
{
ok_btn.setEnabled(true);
jcom_all.setSelected(false);
}
}
});
}
JScrollPane scrol = new JScrollPane(panel);
scrol.getVerticalScrollBar().setUnitIncrement(20);
this.add(BorderLayout.CENTER,scrol);
this.add(BorderLayout.SOUTH,panel2);
}
//筛选后重置界面
public void repaintCheckPanel(JTable table,DefaultTableModel tm_part,Map<String, ModelSelectDialog> dialogs,TableRowSorter<DefaultTableModel> sorter)
{
int rowCout = table.getRowCount();
Map<String, List<String>> newChecksValues = new HashedMap();
for(int i=1;i<table.getColumnCount();i++)
{
List<String> values = new ArrayList<>();
newChecksValues.put(table.getColumnName(i), values);
}
System.out.println("newChecksValues:"+newChecksValues);
if(rowCout>0)
{
for(int i=0;i<rowCout;i++)
{
ModelAuditBean bean = (ModelAuditBean) table.getValueAt(i, 2);
Object[] objs = bean.RowData();
for(int j=1;j<objs.length;j++)
{
List<String> list = newChecksValues.get(GYModelAuditDialog.HEADER[j]);
if(!list.contains(objs[j]))
{
list.add((String) objs[j]);
}
}
}
}
for(String key:dialogs.keySet())
{
ModelSelectDialog dialog = dialogs.get(key);
//System.out.println("dialog colName:"+dialog.getColName()+";是否第一个:"+dialog.isFirst());
if(dialog.isFirst())
{
dialogs.put(key, dialog);
continue;
}
List<String> values = new ArrayList<>();
if(newChecksValues.containsKey(key))
values= newChecksValues.get(key);
//System.out.println("dialog colName:"+dialog.getColName()+";重置:"+values);
ModelSelectDialog dialog_new = new ModelSelectDialog(key, tm_part, values, table,sorter);
int index = tm_part.findColumn(key);
if(index!=-1)
dialog.setColnum(index);
//dialog.setSorter(sorter);
dialogs.put(key, dialog_new);
}
}
public void setLocal(int x,int y,JTable table,JDialog dialog)
{
Point invokerOrigin;
invokerOrigin = table.getLocationOnScreen();
long lx, ly;
lx = ((long) invokerOrigin.x) + ((long) x);
ly = ((long) invokerOrigin.y) + ((long) y);
if (lx > Integer.MAX_VALUE)
lx = Integer.MAX_VALUE;
if (lx < Integer.MIN_VALUE)
lx = Integer.MIN_VALUE;
if (ly > Integer.MAX_VALUE)
ly = Integer.MAX_VALUE;
if (ly < Integer.MIN_VALUE)
ly = Integer.MIN_VALUE;
dialog.setLocation((int) lx, (int) ly);
dialog.setVisible(true);
}
}

@ -0,0 +1,20 @@
#\u8BB0\u5F55\u5DE5\u827A\u3001\u5DE5\u5E8F\u4FE1\u606F
#\u53D8\u538B\u5668 M005
M005.GX=ICM060201
M005.GY=ICM060202
#\u4E2D\u538B\u8BBE\u5907 M008
M008.GX=ICM060101
M008.GY=ICM060102
#\u4E2D\u538B\u5F00\u5173 MO10
M010.GX=ICM090101
M010.GY=ICM090102
#\u9AD8\u538B\u5F00\u5173 M006
M006.GX=ICM060301
M006.GY=ICM060302
#\u7EDD\u7F18\u5B50\u4E0E\u907F\u96F7\u5668 M011
M011.GX=ICM100101
M011.GY=ICM100102
#\u4F4E\u538B\u8BDA\u521B M030
M030.GX=ICM110101
M030.GY=ICM110102

@ -0,0 +1,42 @@
package com.connor.chint.sap2.proc_zy;
public class CHINT_ClassificationCode {
private String productModel; //²úÆ·ÐͺÅ
private String classificationCode; //ÎïÁÏ·ÖÀàÂë
private String ZT2_ClassificationCode; //ͶÁϹ¤Ðò
private String classificationName; //ͶÁϹ¤ÐòÃû³Æ
public String getProductModel() {
return productModel;
}
public void setProductModel(String productModel) {
this.productModel = productModel;
}
public String getClassificationCode() {
return classificationCode;
}
public void setClassificationCode(String classificationCode) {
this.classificationCode = classificationCode;
}
public String getZT2_ClassificationCode() {
return ZT2_ClassificationCode;
}
public void setZT2_ClassificationCode(String zT2_ClassificationCode) {
ZT2_ClassificationCode = zT2_ClassificationCode;
}
public String getClassificationName() {
return classificationName;
}
public void setClassificationName(String classificationName) {
this.classificationName = classificationName;
}
public CHINT_ClassificationCode(String classificationCode, String zT2_ClassificationCode,
String classificationName) {
super();
this.classificationCode = classificationCode;
ZT2_ClassificationCode = zT2_ClassificationCode;
this.classificationName = classificationName;
}
public CHINT_ClassificationCode() {
// TODO Auto-generated constructor stub
}
}

@ -0,0 +1,66 @@
# @<COPYRIGHT>@
# ==================================================
# Copyright 2007.
# Siemens Product Lifecycle Management Software Inc.
# All Rights Reserved.
# ==================================================
# @<COPYRIGHT>@
#*==================================================================================================
# File description: Properties for the substitute command / operation
#===================================================================================================
# Date Name Description of Change
#14-May-1999 Nigel Morse Brought into existance
#08-Jun-1999 nigelm remove properties to item panel
#09-Jun-1999 nigelm created
#15-Jun-1999 nigelm add properties for notes dialog
#01-Jul-1999 nigelm add revision effectivity
#04-Aug-1999 nigelm add findinbill
#05-Aug-1999 nigelm make read only pse
#08-Sep-1999 nigelm merge back from readonly fixes
#08-Oct-1999 israeli bomCompare entries
#08-Oct-1999 nigelm add values
#28-Oct-1999 israeli Merging from israeli_v60_bom
#02-Nov-1999 nigelm merge out ziv's stuff from sdldev_cs
#12-Nov-1999 pracilio Merge from claudio_cs to tc_v60_cs
#25-Jan-2000 Mark Fawcett asSubstitute for add
#24-Feb-2000 mccollr Split out the localization keys.
#23-Feb-2000 Nigel Morse add as substitute
#29-Feb-2000 Nigel Morse merge out from int_v6.2
#24-Feb-2000 Nigel Morse add remove entries
#01-Mar-2000 Nigel Morse merge out.
#09-Mar-2000 James Beard Merge from int_v6.2
#03-Apr-2000 Nigel Morse hard-coded fix
#21-Jun-2001 xuesimon add CS mapper
#27-Nov-2001 xuesimon Remove CSMapper properties
#27-Nov-2001 xuesimon promote to pv_look_v8
#27-Jan-2005 Zhixin Huang Change the icon from gif to png file.
#28-Mar-2005 basava PR#4307699-PSE->Substitute only takes one entry from a big clipboard
#06-Feb-2006 Venkatesh Chitnis de-imanization
#25-Feb-2010 William Zhou Fix PR#6310037 - CondValAgent and CondValData are available in Insert Level operation
#$HISTORY$
#=================================================================================================*/
import=com.teamcenter.rac.pse.pse,com.teamcenter.rac.common.common,com.teamcenter.rac.aif.aif
# AbstractAIFDialog looks for this key.
# The RemoveDialog overrides the title, but this key avoids
# the error comming up.
# DO NOT move to _locale.properties
# DO ignore it.
command.TITLE=NULL
insertLevelOperation=com.teamcenter.rac.pse.operations.InsertLevelOperation
saveAsItemRevDialogPanel=com.teamcenter.rac.commands.saveas.SaveAsItemRevPanel
pasteOperation=com.teamcenter.rac.pse.operations.BOMPasteOperation
# Specify the types to be loaded
com.teamcenter.rac.commands.newitem.ItemTypePanel.TYPES_LOADER=com.teamcenter.rac.commands.newitem.NewItemTypesLoader
com.teamcenter.rac.commands.newitem.NewItemTypesLoader.CLASSES=Item,Drawing
com.teamcenter.rac.commands.newitem.NewItemTypesLoader.Item.EXCLUDETYPES=EngChange,Part,Design,PSSignal,PSConnection,Schedule,ScheduleTask,Architecture,AllocationMap,CAEItem,CAEBCItem,CAEConnItem,CAELoadItem,MEOP,MEProcess,MEWorkarea,MEContext,MEGenericBOP,MEProductBOP,Vendor,BidPackage,SwDesignComp,PhysicalPart,ParmDef,ParmDefBCD,ParmDefBitDef,ParmDefBool,ParmDefDate,ParmDefDbl,ParmDefHex,ParmDefInt,ParmDefSED,ParmDefStr,ParmGrpVal,CalParm,ParmGrpDef,SSP0Frequency,ValidationAgent,ValData,ValidationReq,DesignReq,IssueReport
com.teamcenter.rac.commands.newitem.NewItemTypesLoader.vi.CLASSES=Item,MEProcess,MEOP,MEWorkarea,Drawing
com.teamcenter.rac.commands.newitem.NewItemTypesLoader.vi.Item.EXCLUDETYPES=EngChange,Part,Design,PSSignal,PSConnection,Schedule,ScheduleTask,Architecture,AllocationMap,CAEItem,CAEBCItem,CAEConnItem,CAELoadItem,MEOP,MEProcess,MEWorkarea,MEContext,MEGenericBOP,MEProductBOP,Vendor,BidPackage,SwDesignComp,PhysicalPart,ParmDef,ParmDefBCD,ParmDefBitDef,ParmDefBool,ParmDefDate,ParmDefDbl,ParmDefHex,ParmDefInt,ParmDefSED,ParmDefStr,ParmGrpVal,CalParm,ParmGrpDef,SSP0Frequency,ValidationAgent,ValData,ValidationReq,DesignReq,IssueReport
# Coordinate System Mapper input
sub.ICON=images/replace_16.png

@ -0,0 +1,9 @@
EXCEL.TZ_DH=1ZDB106004D;1ZDB106005D;1ZDB106006D;1ZDB106007D;1ZDB106008D;1ZDB106009D;1ZDB106010D;1ZDB106011D;1ZDB106012D
EXCEL.TZ_ID=1ZDB400000T;1ZDB5*0000X;1ZDB600000J;1ZDB70*000Q;1ZDB800000Y;1ZDB330000Y;1ZDB350000P;1ZDB360000P;1ZDB300000P
EXCEL.TZ_NAME=\u94C1\u5FC3\u91C7\u8D2D\u6E05\u5355;\u7EBF\u5708\u91C7\u8D2D\u6E05\u5355;\u5668\u8EAB\u91C7\u8D2D\u6E05\u5355;\u5F15\u7EBF\u91C7\u8D2D\u6E05\u5355;\u6CB9\u7BB1\u91C7\u8D2D\u6E05\u5355;\u8054\u7BA1\u91C7\u8D2D\u6E05\u5355;\u56DE\u6CB9\u7BA1\u91C7\u8D2D\u6E05\u5355;\u6BCD\u7EBF\u76D2\u91C7\u8D2D\u6E05\u5355;\u603B\u88C5\u91C7\u8D2D\u6E05\u5355
EXCEL.CGD_DH=1ZDB106001D
EXCEL.CGD_NAME=\u7EC4\u4EF6\u91C7\u8D2D\u6E05\u5355

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -0,0 +1,45 @@
#*==================================================================================================
#
# Copyright (c) 2000 Unigraphics Solutions Inc., An EDS Company
# Unpublished - All rights reserved
#
#===================================================================================================
# File description: This properties file contains all locale specific keys for the changeownership package.
# It is the intent that this file is to be localized based upon the Java
# localization resource bundle naming conventions. For further information
# please refer to the Java doc on this subject.
#
# Filename: changeownership.properties
# Module : com.teamcenter.rac.commands.changeownership
#
#===================================================================================================
# Date Name Description of Change
#14-Feb-2000 x_subrat initial create
#05-Mar-2000 chenm Merge from int_v6.2 to chenm_v62
#26-Apr-2002 Rob McColl Rebranding change from tc to Teamcenter.
#06-Feb-2006 Venkatesh Chitnis de-imanization
#$HISTORY$
#=================================================================================================*/
command.TITLE = \u66F4\u6539\u6240\u6709\u6743
selectUser.TIP = \u9009\u62E9\u65B0\u7684\u6240\u6709\u6743\u7528\u6237
confirmationText = \u786E\u5B9A\u8981\u66F4\u6539\u6240\u6709\u6743\u5417\uFF1F
changeOwnershipObjects = \u66F4\u6539\u5BF9\u8C61\u7684\u6240\u6709\u6743...
noSelection = \u672A\u9009\u5B9A\u8981\u66F4\u6539\u6240\u6709\u6743\u7684\u5BF9\u8C61
error.TITLE = \u66F4\u6539\u6240\u6709\u6743...
selectionError.MSG = \u9009\u5B9A\u5BF9\u8C61\u4E0D\u662F\u7528\u6237
newOwnerLabel = \u65B0\u6240\u6709\u6743\u7528\u6237
sameUser.TITLE = \u9009\u5B9A\u7684\u6240\u6709\u6743\u7528\u6237
sameUser.MSG = \u9009\u5B9A\u7528\u6237\u5DF2\u7ECF\u662F\u4EE5\u4E0B\u5BF9\u8C61\u7684\u6240\u6709\u8005\uFF1A
noOwningUserComponents.MSG=\u4EE5\u4E0B\u9009\u5B9A\u5143\u7D20\u6CA1\u6709\u5173\u8054\u6240\u6709\u6743\u7528\u6237\u3002\u5C06\u4EC5\u4F20\u9012\u5177\u6709\u6240\u6709\u6743\u7684\u5143\u7D20\u3002\n\n{0}
#A list of items (items whose owner is already the user to be changed to) will be displayed preceding the following message.
sameUserMoreToDisplay.MSG = \u548C {0} \u66F4\u591A\u5143\u7D20\u3002

@ -0,0 +1,195 @@
<job id="SubsMacros-MSWord">
<reference guid="{00020905-0000-0000-C000-000000000046}"/>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim digitDict
digitDict = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim fs, WshShell
Set fs = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim docFileName, txtFileName ,outdoc_file,pageMax
If WScript.Arguments.Count < 3 Then
MsgBox "Usage: SubsMacros-MSWord <doc file> <data file>"
WScript.Quit
End If
docFileName = WScript.Arguments(0)
txtFileName = WScript.Arguments(1)
'outdoc_file = WScript.Arguments(2)
pageMax = CInt(WScript.Arguments(2))
Dim wordApp
Dim docFilePath, pathLen
For pathLen = Len(docFileName) To 1 Step -1
If Mid(docFileName, pathLen, 1) = "\" Then
docFilePath = Left(docFileName, pathLen)
Exit For
End If
Next
Dim txtFile, line, data
If fs.FileExists(docFileName) = False Then
WScript.Quit
End If
If fs.FileExists(txtFileName) = False Then
WScript.Quit
End If
Set txtFile = fs.OpenTextFile(txtFileName)
line = txtFile.ReadLine()
txtFile.Close
Set data = ReadObject(line)
Dim doc
Dim docVar, varIndex
'Dim word, name, value, startPos, endPos,preword
Set wordApp = CreateObject("Word.Application")
Set doc = wordApp.Documents.Open( docFileName )
'wordApp.Visible = True
Dim docSelection
Set docSelection= wordApp.Selection
Dim tables,table,tableCout,num,rRange
Set tableCout = docSelection.Information(wdNumberOfPagesInDocument)
'WScript.Echo "表格:" & docSelection.Information(wdNumberOfPagesInDocument)
'WScript.Echo "新页数:" & pageMax
'WScript.Echo "新页数:" & doc.tables.Count
'新增页
If docSelection.Information(wdNumberOfPagesInDocument) <pageMax Then
doc.tables(1).Range.Copy
'For Each table in doc.Tables
' table.Range.Copy
'Next
For num = docSelection.Information(wdNumberOfPagesInDocument)+1 to pageMax
'WScript.Echo "新增第" & num & "页"
wordApp.Selection.EndKey(6)
wordApp.Selection.InsertBreak(2)
'wordApp.Selection.TypeBackspace
wordApp.Selection.Range.PasteAndFormat (wdOriginalFormat)
Next
end if
'删除页
If docSelection.Information(wdNumberOfPagesInDocument) >pageMax Then
'WScript.Echo "删除页"
Dim ra,CurrentPageStart,CurrentPageEnd,Range
For num = docSelection.Information(wdNumberOfPagesInDocument) to pageMax+1 Step -1
'If num= docSelection.Information(wdNumberOfPagesInDocument)
' WScript.Echo "删除最后一页"
'Else
'End If
'WScript.Echo "删除第" & num & "页"
wordApp.Selection.EndKey(6)
'wordApp.Selection.Delete
doc.tables(num).Delete
wordApp.Selection.Delete
Next
end if
Dim intProp, cusProp
For intProp = 1 To doc.CustomDocumentProperties.Count
'WScript.Echo doc.CustomDocumentProperties(intProp).Name
If doc.CustomDocumentProperties(intProp).Value = "" Then
doc.CustomDocumentProperties(intProp).Value = " "
End If
Next
Dim t, dataName, dataVal ,pic,strs,str,pim
Dim ObjSelection,wordRange
On Error Resume Next
For Each t In data
On Error Resume Next
dataName = t
'WScript.Echo "内容:" & dataName
For cusProp = 1 To doc.CustomDocumentProperties.Count
If doc.CustomDocumentProperties(cusProp).Name = dataName Then
doc.CustomDocumentProperties(cusProp).Value = data(dataName)
End If
Next
err.Clear
Next
'域更新
Dim aStory, aField
For Each aStory In doc.StoryRanges
For Each aField In aStory.Fields
aField.Update
Next
Next
doc.Save
doc.Close
wordApp.Quit
Function ReadObject(dataline)
Dim data, nvpair, nv
Set ReadObject = CreateObject("Scripting.Dictionary")
data = Split(dataline, "|")
For Each nvpair In data
nv = Split(nvpair, "=")
If UBound(nv) >= 1 Then
If Not ReadObject.Exists(nv(0)) Then
'ReadObject.Add nv(0), SubstEscSeq(nv(1))
ReadObject.Add nv(0), nv(1)
End If
End If
Next
End Function
Function digitValue(hexStr)
digitValue = InStr(digitDict, hexStr) - 1
'WScript.Echo "Decode hex char " & hexStr & " to " & digitValue
End Function
Function CompareDates(s)
Dim lastDate,last,time_str,strs
last = "2000-01-01"
lastDate = CDate(last)
'MsgBox s
Dim ll
strs = Split(s,",")
ll = UBound(strs)
'WScript.Echo "长度="&" "&ll
If UBound(strs) = -1 Then
CompareDates = " "
ElseIf UBound(strs) = 0 Then
CompareDates = s
Else
For Each t In strs
time_str = CDate(t)
'MsgBox time_str
If DateDiff("d", time_str, lastDate) < 0 Then
lastDate = time_str
End if
Next
CompareDates = lastDate
End If
End Function
Function SubstEscSeq(str)
Dim startPos, tokenPos, strLen
SubstEscSeq = ""
strLen = Len(str)
startPos = 1
Do While startPos < strLen
tokenPos = InStr(startPos, str, "%")
If tokenPos < 1 Then
Exit Do
End If
SubstEscSeq = SubstEscSeq + Mid(str, startPos, tokenPos - startPos)
'WScript.Echo "Hex token " & Mid(str, tokenPos, 3) & " decoded to asc value: " & digitValue(Mid(str, tokenPos+1, 1)) * 16 + digitValue(Mid(str, tokenPos+2, 1))
SubstEscSeq = SubstEscSeq + Chr(digitValue(Mid(str, tokenPos+1, 1)) * 16 + digitValue(Mid(str, tokenPos+2, 1)))
startPos = tokenPos + 3
Loop
SubstEscSeq = SubstEscSeq + Mid(str, startPos, strLen - startPos + 1)
'WScript.Echo "Decoded string from " & str & " to " & SubstEscSeq
End Function
</script>
</job>

@ -0,0 +1,75 @@
<job id = "TopFile-MSWord">
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim digitDict
digitDict = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim fs, WshShell
Set fs = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim docFileName, txtFileName
If WScript.Arguments.Count < 2 Then
'MsgBox "Usage: SubsMacros-MSWord <doc file> <data file>"
WScript.Quit
End If
docFileName = WScript.Arguments(0)
txtFileName = WScript.Arguments(1)
Dim docFilePath, pathLen
For pathLen = Len(docFileName) To 1 Step -1
If Mid(docFileName, pathLen, 1) = "\" Then
docFilePath = Left(docFileName, pathLen)
Exit For
End If
Next
Dim wordApp
Dim txtFile, line, data
If fs.FileExists(docFileName) = False Then
'WScript.Echo "File " & docFileName & " doesn't exist!"
WScript.Quit
End If
If Not Right(docFileName, 4) = ".doc" Then
If Not Right(docFileName, 5) = ".docm" Then
'MsgBox "数据集引用文件 " & docFileName & " 扩展名不是.docm或doc, 可能出现不正确结果. 建议将扩展名改为.doc.docm"
End If
End If
If fs.FileExists(txtFileName) = False Then
'WScript.Echo "File " & txtFileName & " doesn't exist!"
WScript.Quit
End If
Dim doc
Dim docVar, varIndex
'Dim word, name, value, startPos, endPos,preword
Set wordApp = CreateObject("Word.Application")
'wordApp.Visible = false
Set doc = wordApp.Documents.Open( docFileName )
Set txtFile = fs.OpenTextFile(txtFileName)
line = txtFile.ReadAll()
'msgbox "插入内容--" & line
txtFile.Close
dim vals,vals2,i
vals = Split(line,"$")
for i=0 to ubound(vals)
'msgbox "显示1:"&vals(i)
vals2 = Split(vals(i),"=")
If doc.Bookmarks.Exists(vals2(0))= True Then
'msgbox "显示2:" & vals2(0) & "=" & vals2(1)
doc.Bookmarks(vals2(0)).Select
doc.Bookmarks(vals2(0)).Range.Text=vals2(1)
End If
next
'magbox "修改结束"
doc.Save
'msgbox "保存"
doc.Close
'msgbox "关闭"
wordApp.Quit
'msgbox "退出"
</script>
</job>

@ -0,0 +1,19 @@
#\u6570\u636E\u5E93\u9A71\u52A8
driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
#\u6570\u636E\u5E93\u8FDE\u63A5\u5730\u5740
url=jdbc:sqlserver://10.128.10.135:1433;DatabaseName=CHINT_DB
#\u7528\u6237\u540D
username=PLMUser
#\u5BC6\u7801
password=PLMUser
#\u8FDE\u63A5\u6C60\u7684\u6700\u5927\u6570\u636E\u5E93\u8FDE\u63A5\u6570\u3002\u8BBE\u4E3A0\u8868\u793A\u65E0\u9650\u5236
maxActive=30
#\u6700\u5927\u7A7A\u95F2\u6570\uFF0C\u6570\u636E\u5E93\u8FDE\u63A5\u7684\u6700\u5927\u7A7A\u95F2\u65F6\u95F4\u3002\u8D85\u8FC7\u7A7A\u95F2\u65F6\u95F4\uFF0C\u6570\u636E\u5E93\u8FDE
#\u63A5\u5C06\u88AB\u6807\u8BB0\u4E3A\u4E0D\u53EF\u7528\uFF0C\u7136\u540E\u88AB\u91CA\u653E\u3002\u8BBE\u4E3A0\u8868\u793A\u65E0\u9650\u5236
maxIdle=10
#\u6700\u5927\u5EFA\u7ACB\u8FDE\u63A5\u7B49\u5F85\u65F6\u95F4\u3002\u5982\u679C\u8D85\u8FC7\u6B64\u65F6\u95F4\u5C06\u63A5\u5230\u5F02\u5E38\u3002\u8BBE\u4E3A-1\u8868\u793A\u65E0\u9650\u5236
maxWait=1000
#\u8D85\u8FC7removeAbandonedTimeout\u65F6\u95F4\u540E\uFF0C\u662F\u5426\u8FDB \u884C\u6CA1\u7528\u8FDE\u63A5\uFF08\u5E9F\u5F03\uFF09\u7684\u56DE\u6536\uFF08\u9ED8\u8BA4\u4E3Afalse\uFF0C\u8C03\u6574\u4E3Atrue)
removeAbandoned=true
#\u8D85\u8FC7\u65F6\u95F4\u9650\u5236\uFF0C\u56DE\u6536\u6CA1\u6709\u7528(\u5E9F\u5F03)\u7684\u8FDE\u63A5\uFF08\u9ED8\u8BA4\u4E3A 300\u79D2\uFF0C\u8C03\u6574\u4E3A180\uFF09
removeAbandonedTimeout=180

@ -0,0 +1,41 @@
SQL.URL=jdbc:sqlserver://10.128.20.35:1433;DatabaseName=BDP2020
SQL.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver
SQL.USER=PLMUser
SQL.PASSWORD=PLMUser
#\u4F4E\u538B\u8BDA\u521B
SQL.CC.URL=jdbc:sqlserver://10.128.10.135:1433;DatabaseName=CHINT_DB
SQL.CC.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver
SQL.CC.USER=PLMUser
SQL.CC.PASSWORD=PLMUser
# Test
#SQL.SH.URL=jdbc:sqlserver://10.128.155.236:1433;DatabaseName=ISP.CADAssistant
#SQL.SH.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver
#SQL.SH.USER=sa
#SQL.SH.PASSWORD=2wsx#EDC
#
SQL.SH.URL=jdbc:sqlserver://10.128.155.140:1433;DatabaseName=ISP.CADAssistant
SQL.SH.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver
SQL.SH.USER=sa
SQL.SH.PASSWORD=2wsx#EDC
SQL.TC.URL=jdbc:oracle:thin:@10.128.10.207:1521:tcprod
SQL.TC.DRIVER=oracle.jdbc.driver.OracleDriver
SQL.TC.USER=infodba
SQL.TC.PASSWORD=infodba
#SQL.TCDATA.URL=jdbc:oracle:thin:@192.168.0.103:1521:TC
SQL.TCDATA.URL=jdbc:oracle:thin:@10.128.18.139:1521:testdb
SQL.TCDATA.DRIVER=oracle.jdbc.driver.OracleDriver
SQL.TCDATA.USER=infodba
SQL.TCDATA.PASSWORD=infodba
SQL.TEMPLATE_TREE=select t.PmpcCode, t.PmpcCompanyCode, t.PmpcName, t.PmpcUpperCode, t.PmpcItem, t.PmpcPrhCode, t.PmpcEnd,t.PmpcCanzz,t.PmpcPType,t.PmpcMType from CcemVW_Pmpc t;
SQL.TEMPLATE=select t.PrhName,t.PrdLine,t.PrdNo,t.PrdFeatureCode,t.FeatureName,t.PrdCanInput,t.PrdSign from CcemVW_Prd t where t.prhcode = ? order by t.PrdNo
SQL.LOV=select t.PrddNo,t.PrddFeatureCode,t.PrddValue from CcemVW_Prdd t where t.PrddCode = ? and PrddLine = ? order by t.PrddNo
SQL.FEATURE=select t.FeatureCode,t.FeatureName from CcemVW_Feature t
SQL.GROUP=select t.ProductGroupCode,t.ProductGroupName from CcemVW_ProductGroup t

@ -0,0 +1 @@
ZT2_BOMEC.FORMJAVARENDERING=com.connor.chint.sap2.stylesheet.BOMDifStyle

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="CHINTMaterial" type="com.connor.chint.sap2.test.CHINTMaterial"></typeAlias>
<typeAlias alias="CcemVW_Cgd" type="com.connor.chint.sap2.mybatis.CcemVW_Cgd"></typeAlias>
<typeAlias alias="CHINT_M007_MATERIAL" type="com.connor.chint.sap2.bean.CHINT_M007_MATERIAL"></typeAlias>
<typeAlias alias="CHINT_M008_MATERIAL" type="com.connor.chint.sap2.bean.CHINT_M008_MATERIAL"></typeAlias>
<typeAlias alias="PBox" type="com.connor.chint.sap2.dy.createElectricalBOM.bean.PBox"></typeAlias>
</typeAliases>
<environments default="development">
<!--TC正式数据库-->
<environment id="tcprod">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@10.128.10.207:1521:tcprod" />
<property name="username" value="infodba" />
<property name="password" value="infodba" />
</dataSource>
</environment>
<!--低压诚创-->
<environment id="DYCC">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://10.128.10.135:1433;DatabaseName=CHINT_DB" />
<property name="username" value="PLMUser" />
<property name="password" value="PLMUser" />
</dataSource>
</environment>
<!--低压深化-->
<environment id="DYSH">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://10.128.155.140:1433;DatabaseName=ISP.CADAssistant" />
<property name="username" value="sa" />
<property name="password" value="2wsx#EDC" />
</dataSource>
</environment>
<!--基础数据平台-->
<environment id="MDM">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://10.128.20.35:1433;DatabaseName=BDP2020" />
<property name="username" value="PLMUser" />
<property name="password" value="PLMUser" />
</dataSource>
</environment>
</environments>
<mappers>
<!-- TC数据库 正式 -->
<!-- <mapper resource="DBMybatis.xml"/> -->
<mapper resource="CcemVW_CgdDao.xml"/>
<mapper resource="CcemVW_Cgd.xml"/>
</mappers>
</configuration>

@ -0,0 +1,19 @@
#\u6570\u636E\u5E93\u9A71\u52A8
driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
#\u6570\u636E\u5E93\u8FDE\u63A5\u5730\u5740
url=jdbc:sqlserver://10.128.10.135:1433;DatabaseName=CHINT_DB
#\u7528\u6237\u540D
username=PLMUser
#\u5BC6\u7801
password=PLMUser
#\u8FDE\u63A5\u6C60\u7684\u6700\u5927\u6570\u636E\u5E93\u8FDE\u63A5\u6570\u3002\u8BBE\u4E3A0\u8868\u793A\u65E0\u9650\u5236
maxActive=30
#\u6700\u5927\u7A7A\u95F2\u6570\uFF0C\u6570\u636E\u5E93\u8FDE\u63A5\u7684\u6700\u5927\u7A7A\u95F2\u65F6\u95F4\u3002\u8D85\u8FC7\u7A7A\u95F2\u65F6\u95F4\uFF0C\u6570\u636E\u5E93\u8FDE
#\u63A5\u5C06\u88AB\u6807\u8BB0\u4E3A\u4E0D\u53EF\u7528\uFF0C\u7136\u540E\u88AB\u91CA\u653E\u3002\u8BBE\u4E3A0\u8868\u793A\u65E0\u9650\u5236
maxIdle=10
#\u6700\u5927\u5EFA\u7ACB\u8FDE\u63A5\u7B49\u5F85\u65F6\u95F4\u3002\u5982\u679C\u8D85\u8FC7\u6B64\u65F6\u95F4\u5C06\u63A5\u5230\u5F02\u5E38\u3002\u8BBE\u4E3A-1\u8868\u793A\u65E0\u9650\u5236
maxWait=1000
#\u8D85\u8FC7removeAbandonedTimeout\u65F6\u95F4\u540E\uFF0C\u662F\u5426\u8FDB \u884C\u6CA1\u7528\u8FDE\u63A5\uFF08\u5E9F\u5F03\uFF09\u7684\u56DE\u6536\uFF08\u9ED8\u8BA4\u4E3Afalse\uFF0C\u8C03\u6574\u4E3Atrue)
removeAbandoned=true
#\u8D85\u8FC7\u65F6\u95F4\u9650\u5236\uFF0C\u56DE\u6536\u6CA1\u6709\u7528(\u5E9F\u5F03)\u7684\u8FDE\u63A5\uFF08\u9ED8\u8BA4\u4E3A 300\u79D2\uFF0C\u8C03\u6574\u4E3A180\uFF09
removeAbandonedTimeout=180

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

Loading…
Cancel
Save