diff --git a/lib/jinweiLib/OpenAPIUtil-1.0.1.jar b/lib/jinweiLib/OpenAPIUtil-1.0.1.jar new file mode 100644 index 0000000..3431268 Binary files /dev/null and b/lib/jinweiLib/OpenAPIUtil-1.0.1.jar differ diff --git a/lib/jinweiLib/aliyun-sdk-oss-3.10.2.jar b/lib/jinweiLib/aliyun-sdk-oss-3.10.2.jar new file mode 100644 index 0000000..4889f96 Binary files /dev/null and b/lib/jinweiLib/aliyun-sdk-oss-3.10.2.jar differ diff --git a/lib/jinweiLib/dlt-app-1.5.0.jar b/lib/jinweiLib/dlt-app-1.5.0.jar new file mode 100644 index 0000000..8273402 Binary files /dev/null and b/lib/jinweiLib/dlt-app-1.5.0.jar differ diff --git a/lib/jinweiLib/dlt-commons-1.5.0.jar b/lib/jinweiLib/dlt-commons-1.5.0.jar new file mode 100644 index 0000000..5c18725 Binary files /dev/null and b/lib/jinweiLib/dlt-commons-1.5.0.jar differ diff --git a/lib/jinweiLib/dlt-data-1.5.0.jar b/lib/jinweiLib/dlt-data-1.5.0.jar new file mode 100644 index 0000000..beb9279 Binary files /dev/null and b/lib/jinweiLib/dlt-data-1.5.0.jar differ diff --git a/lib/jinweiLib/dlt-pc-1.5.0.jar b/lib/jinweiLib/dlt-pc-1.5.0.jar new file mode 100644 index 0000000..c815f70 Binary files /dev/null and b/lib/jinweiLib/dlt-pc-1.5.0.jar differ diff --git a/lib/jinweiLib/joss-0.9.14.jar b/lib/jinweiLib/joss-0.9.14.jar new file mode 100644 index 0000000..8200868 Binary files /dev/null and b/lib/jinweiLib/joss-0.9.14.jar differ diff --git a/lib/jinweiLib/model16.jar b/lib/jinweiLib/model16.jar new file mode 100644 index 0000000..fca79c4 Binary files /dev/null and b/lib/jinweiLib/model16.jar differ diff --git a/lib/jinweiLib/signpost-commonshttp4-1.2.jar b/lib/jinweiLib/signpost-commonshttp4-1.2.jar new file mode 100644 index 0000000..0b8c0ed Binary files /dev/null and b/lib/jinweiLib/signpost-commonshttp4-1.2.jar differ diff --git a/lib/jinweiLib/signpost-core-2.1.1.jar b/lib/jinweiLib/signpost-core-2.1.1.jar new file mode 100644 index 0000000..094b60f Binary files /dev/null and b/lib/jinweiLib/signpost-core-2.1.1.jar differ diff --git a/lib/jinweiLib/spire.doc.free-5.2.0.jar b/lib/jinweiLib/spire.doc.free-5.2.0.jar new file mode 100644 index 0000000..a0c4d89 Binary files /dev/null and b/lib/jinweiLib/spire.doc.free-5.2.0.jar differ diff --git a/lib/jinweiLib/util16.jar b/lib/jinweiLib/util16.jar new file mode 100644 index 0000000..2c2b01f Binary files /dev/null and b/lib/jinweiLib/util16.jar differ diff --git a/lib/jinweiLib/weaver-file-sync.jar b/lib/jinweiLib/weaver-file-sync.jar new file mode 100644 index 0000000..e317db2 Binary files /dev/null and b/lib/jinweiLib/weaver-file-sync.jar differ diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/boge/api/CreateBomApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/boge/api/CreateBomApi.java new file mode 100644 index 0000000..ac8d506 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/boge/api/CreateBomApi.java @@ -0,0 +1,101 @@ +package com.api.taojw.boge.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.boge.webservice.ERPIServiceLocator; +import com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.ModelDataToJsonUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 勃格建模查询勾选记录 调用webservice接口 + */ +@Path("/bogetjw") +public class CreateBomApi { + + Logger logger = MyLogger.getLogger(); + + //接口调用成功后,将建模的是否成功推送字段改为是 + private String updateModeStatusSql = "update uf_js03 set sfcgts = 0,spph = ? where id = ?"; + + @POST + @Path("/createBom") + @Produces(MediaType.APPLICATION_JSON) + public String createBom(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + RecordSet rs = new RecordSet(); + result.put("success","1"); + + String errMsg = ""; + List errIds = new ArrayList<>(); + //勾选的记录id + String selectedIds = request.getParameter("selectedIds"); + String configId = CommonSqlUtil.getSystemParamValue("modedatatojson_bom",rs); + String url = CommonSqlUtil.getSystemParamValue("bomurl",rs); + + String getStatusSql = "select id from uf_js03 where sfcgts = 0 and id in (" + selectedIds + ")"; + List> data = DaoUtil.getData(rs, getStatusSql); + if(data.size() > 0){ + for(Map m : data){ + String id = m.get("id"); + errIds.add(id); + } + result.put("success","0"); + errMsg = "数据id为:" + errIds + "的记录已成功调用过接口,请取消勾选后再提交!"; + result.put("errMsg",errMsg); + logger.info("CreateBomApi.createBom end;result:" + result.toJSONString()); + return result.toJSONString(); + } + + URL wbUrl = new URL(url); + //根据配置将建模转json + String[] selectedIdArr = selectedIds.split(","); + for(String id : selectedIdArr){ + JSONObject o = ModelDataToJsonUtil.getJsonByModelData(id,configId); + ERPIServiceLocator locator = new ERPIServiceLocator(); + ERPIServiceSoap11BindingStub stub = new ERPIServiceSoap11BindingStub(wbUrl,locator); + String product4OA = stub.createProduct4OA(o.toJSONString()); + JSONObject msg = JSONObject.parseObject(product4OA); + String code = msg.getString("code"); + String phData = msg.getString("data"); + JSONObject loggerInfo = new JSONObject(); + if(!"0".equals(code)){ + result.put("success","0"); + errIds.add(id); + loggerInfo.put("cgbz",1); + }else{ + DaoUtil.updateData(rs,updateModeStatusSql,phData,id); + loggerInfo.put("cgbz",0); + } + loggerInfo.put("sjid",id); + loggerInfo.put("qqbw",o.toJSONString()); + loggerInfo.put("xybw",product4OA); + TjwModelUtil.addModelData(rs,"uf_bomjkrz",loggerInfo); + } + errMsg = "数据id为:" + errIds + "的记录接口调用失败!"; + result.put("errMsg",errMsg); + logger.info("CreateBomApi.createBom end;result:" + result.toJSONString()); + return result.toJSONString(); + }catch(Exception e){ + logger.error("CreateBomApi.createBom end;message:" + e.getMessage() + ";e:" + e); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIService.java b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIService.java new file mode 100644 index 0000000..fca6e9e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIService.java @@ -0,0 +1,21 @@ +/** + * ERPIService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.boge.webservice; + +public interface ERPIService extends javax.xml.rpc.Service { + public java.lang.String getERPIServiceHttpSoap12EndpointAddress(); + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public java.lang.String getERPIServiceHttpSoap11EndpointAddress(); + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceLocator.java new file mode 100644 index 0000000..0933475 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceLocator.java @@ -0,0 +1,202 @@ +/** + * ERPIServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.boge.webservice; + +public class ERPIServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.boge.webservice.ERPIService { + + public ERPIServiceLocator() { + } + + + public ERPIServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public ERPIServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for ERPIServiceHttpSoap12Endpoint + private java.lang.String ERPIServiceHttpSoap12Endpoint_address = "http://58.211.172.10:88/axis2/services/ERPIService.ERPIServiceHttpSoap12Endpoint/"; + + public java.lang.String getERPIServiceHttpSoap12EndpointAddress() { + return ERPIServiceHttpSoap12Endpoint_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String ERPIServiceHttpSoap12EndpointWSDDServiceName = "ERPIServiceHttpSoap12Endpoint"; + + public java.lang.String getERPIServiceHttpSoap12EndpointWSDDServiceName() { + return ERPIServiceHttpSoap12EndpointWSDDServiceName; + } + + public void setERPIServiceHttpSoap12EndpointWSDDServiceName(java.lang.String name) { + ERPIServiceHttpSoap12EndpointWSDDServiceName = name; + } + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(ERPIServiceHttpSoap12Endpoint_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getERPIServiceHttpSoap12Endpoint(endpoint); + } + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub(portAddress, this); + _stub.setPortName(getERPIServiceHttpSoap12EndpointWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setERPIServiceHttpSoap12EndpointEndpointAddress(java.lang.String address) { + ERPIServiceHttpSoap12Endpoint_address = address; + } + + + // Use to get a proxy class for ERPIServiceHttpSoap11Endpoint + private java.lang.String ERPIServiceHttpSoap11Endpoint_address = "http://58.211.172.10:88/axis2/services/ERPIService.ERPIServiceHttpSoap11Endpoint/"; + + public java.lang.String getERPIServiceHttpSoap11EndpointAddress() { + return ERPIServiceHttpSoap11Endpoint_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String ERPIServiceHttpSoap11EndpointWSDDServiceName = "ERPIServiceHttpSoap11Endpoint"; + + public java.lang.String getERPIServiceHttpSoap11EndpointWSDDServiceName() { + return ERPIServiceHttpSoap11EndpointWSDDServiceName; + } + + public void setERPIServiceHttpSoap11EndpointWSDDServiceName(java.lang.String name) { + ERPIServiceHttpSoap11EndpointWSDDServiceName = name; + } + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(ERPIServiceHttpSoap11Endpoint_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getERPIServiceHttpSoap11Endpoint(endpoint); + } + + public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub(portAddress, this); + _stub.setPortName(getERPIServiceHttpSoap11EndpointWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setERPIServiceHttpSoap11EndpointEndpointAddress(java.lang.String address) { + ERPIServiceHttpSoap11Endpoint_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + * This service has multiple ports for a given interface; + * the proxy implementation returned may be indeterminate. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (com.api.taojw.boge.webservice.ERPIServicePortType.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub(new java.net.URL(ERPIServiceHttpSoap12Endpoint_address), this); + _stub.setPortName(getERPIServiceHttpSoap12EndpointWSDDServiceName()); + return _stub; + } + if (com.api.taojw.boge.webservice.ERPIServicePortType.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub(new java.net.URL(ERPIServiceHttpSoap11Endpoint_address), this); + _stub.setPortName(getERPIServiceHttpSoap11EndpointWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("ERPIServiceHttpSoap12Endpoint".equals(inputPortName)) { + return getERPIServiceHttpSoap12Endpoint(); + } + else if ("ERPIServiceHttpSoap11Endpoint".equals(inputPortName)) { + return getERPIServiceHttpSoap11Endpoint(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("http://service.dcis", "ERPIService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("http://service.dcis", "ERPIServiceHttpSoap12Endpoint")); + ports.add(new javax.xml.namespace.QName("http://service.dcis", "ERPIServiceHttpSoap11Endpoint")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("ERPIServiceHttpSoap12Endpoint".equals(portName)) { + setERPIServiceHttpSoap12EndpointEndpointAddress(address); + } + else +if ("ERPIServiceHttpSoap11Endpoint".equals(portName)) { + setERPIServiceHttpSoap11EndpointEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServicePortType.java b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServicePortType.java new file mode 100644 index 0000000..db9cffc --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServicePortType.java @@ -0,0 +1,19 @@ +/** + * ERPIServicePortType.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.boge.webservice; + +public interface ERPIServicePortType extends java.rmi.Remote { + public java.lang.String invokeSrv(java.lang.String paramXML) throws java.rmi.RemoteException; + public java.lang.String setT100JobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException; + public java.lang.String createFileData(java.lang.String paramXML) throws java.rmi.RemoteException; + public java.lang.String exportDataToErp(java.lang.String endPoint, java.lang.String xml) throws java.rmi.RemoteException; + public java.lang.String createProduct4OA(java.lang.String requestJson) throws java.rmi.RemoteException; + public java.lang.String setERPJobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException; + public java.lang.String syncProd(java.lang.String paramXML) throws java.rmi.RemoteException; + public java.lang.String callbackSrv(java.lang.String paramXML) throws java.rmi.RemoteException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceSoap11BindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceSoap11BindingStub.java new file mode 100644 index 0000000..ab9e483 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceSoap11BindingStub.java @@ -0,0 +1,459 @@ +/** + * ERPIServiceSoap11BindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.boge.webservice; + +public class ERPIServiceSoap11BindingStub extends org.apache.axis.client.Stub implements com.api.taojw.boge.webservice.ERPIServicePortType { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[8]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("invokeSrv"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("setT100JobStatus"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("createFileData"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("exportDataToErp"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "endPoint"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xml"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[3] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("createProduct4OA"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "requestJson"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[4] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("setERPJobStatus"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[5] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("syncProd"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[6] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("callbackSrv"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[7] = oper; + + } + + public ERPIServiceSoap11BindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public ERPIServiceSoap11BindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public ERPIServiceSoap11BindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public java.lang.String invokeSrv(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:invokeSrv"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "invokeSrv")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String setT100JobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:setT100JobStatus"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setT100JobStatus")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String createFileData(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:createFileData"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createFileData")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String exportDataToErp(java.lang.String endPoint, java.lang.String xml) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:exportDataToErp"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "exportDataToErp")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {endPoint, xml}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String createProduct4OA(java.lang.String requestJson) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[4]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:createProduct4OA"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createProduct4OA")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {requestJson}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String setERPJobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[5]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:setERPJobStatus"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setERPJobStatus")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String syncProd(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[6]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:syncProd"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "syncProd")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String callbackSrv(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[7]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:callbackSrv"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "callbackSrv")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceSoap12BindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceSoap12BindingStub.java new file mode 100644 index 0000000..2169412 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/boge/webservice/ERPIServiceSoap12BindingStub.java @@ -0,0 +1,459 @@ +/** + * ERPIServiceSoap12BindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.boge.webservice; + +public class ERPIServiceSoap12BindingStub extends org.apache.axis.client.Stub implements com.api.taojw.boge.webservice.ERPIServicePortType { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[8]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("invokeSrv"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("setT100JobStatus"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("createFileData"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("exportDataToErp"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "endPoint"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xml"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[3] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("createProduct4OA"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "requestJson"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[4] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("setERPJobStatus"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[5] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("syncProd"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[6] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("callbackSrv"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false); + param.setOmittable(true); + param.setNillable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[7] = oper; + + } + + public ERPIServiceSoap12BindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public ERPIServiceSoap12BindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public ERPIServiceSoap12BindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public java.lang.String invokeSrv(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:invokeSrv"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "invokeSrv")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String setT100JobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:setT100JobStatus"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setT100JobStatus")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String createFileData(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:createFileData"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createFileData")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String exportDataToErp(java.lang.String endPoint, java.lang.String xml) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:exportDataToErp"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "exportDataToErp")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {endPoint, xml}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String createProduct4OA(java.lang.String requestJson) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[4]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:createProduct4OA"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createProduct4OA")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {requestJson}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String setERPJobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[5]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:setERPJobStatus"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setERPJobStatus")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String syncProd(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[6]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:syncProd"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "syncProd")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public java.lang.String callbackSrv(java.lang.String paramXML) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[7]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("urn:callbackSrv"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "callbackSrv")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/bomei/FzcKbApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/bomei/FzcKbApi.java new file mode 100644 index 0000000..ecff863 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/bomei/FzcKbApi.java @@ -0,0 +1,74 @@ +package com.api.taojw.bomei; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * 柏美收付款提醒 + */ +@Path("/bmfzckb") +public class FzcKbApi { + + Logger logger = MyLogger.getLogger(); + + //获取下一条提醒 + @GET + @Path("/getNextSfkTx") + @Produces(MediaType.APPLICATION_JSON) + public String getNextSfkTx(@Context HttpServletRequest request, @Context HttpServletResponse response){ + //响应数据 + JSONObject result = new JSONObject(); + try{ + //当前展示的是第几条数据 + String currentId = request.getParameter("currentId"); + if("".equals(currentId) || currentId == null){ + currentId = "0"; + } + //当前用户 + User user = HrmUserVarify.getUser(request, response); + logger.info("FzcKbApi.getNextSfkTx begin;currentId:" + currentId + ";user:" + user.getUID() + ";name:" + user.getLastname()); + //查询比currentId大的下一条数据进行展示 + RecordSet rs = new RecordSet(); + String getNextTxSql = + "select " + + "top 1 " + + "t1.id,t4.khmc,t5.xmmc,t2.bcsqskje,t2.yskje," + + "case when t2.htzje is null or t2.htzje = 0 then '1.00' else FORMAT(t2.bcsqskje/t2.htzje,'N') end as bl," + + "t1.skrq " + + "from " + + "uf_skqd t1 " + + "inner join uf_skqd_dt1 t2 on t2.mainid = t1.id " + + "left join Modeviewlog_90 t3 on t3.operateuserid = ? and t3.relatedid = t1.id and t3.operatetype = 4 " + + "inner join uf_kh t4 on t4.id = t1.khmc " + + "inner join formtable_main_151 t5 on t5.id = t2.cwxm " + + "where " + + "t3.id is null " + + "and t1.id > ? " + + "order by " + + "t1.id "; + Map txData = DaoUtil.getFirstData(rs, getNextTxSql, user.getUID(), currentId); + for(String key:txData.keySet()){ + result.put(key,txData.get(key)); + } + logger.info("FzcKbApi.getNextSfkTx end;result:" + result.toJSONString()); + return result.toJSONString(); + }catch(Exception e){ + logger.error("FzcKbApi.getNextSfkTx exception;message:" + e.getMessage() + ";e:" + e); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/bomei/cronjob/MakeDataCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/bomei/cronjob/MakeDataCronJob.java new file mode 100644 index 0000000..c3d1530 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/bomei/cronjob/MakeDataCronJob.java @@ -0,0 +1,51 @@ +package com.api.taojw.bomei.cronjob; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.Map; + +public class MakeDataCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info("MakeDataCronJob.execute() begin"); + RecordSet rs = new RecordSet(); + String getCountSql = + "select " + + "sum(case when xmzt in (31,38,39,40,48) then 1 else 0 end) as zjxms," + + "sum(case when xmzt in (41,42,43) then 1 else 0 end) as ysxms," + + "sum(case when mqsjscjd not in (9,10) then 1 else 0 end) as gzxms," + + "format(DATEADD(YEAR,-1,GETDATE()),'yyyy') as nf " + + "from " + + "uf_xm t1 " + + "where " + + "substring(t1.modedatacreatedate,1,4) = format(DATEADD(YEAR,-1,GETDATE()),'yyyy') "; + Map firstData = DaoUtil.getFirstData(rs, getCountSql); + String zjxms = firstData.get("zjxms"); + String ysxms = firstData.get("ysxms"); + String gzxms = firstData.get("gzxms"); + String nf = firstData.get("nf"); + + JSONObject json = new JSONObject(); + json.put("zjxms",zjxms); + json.put("ysxms",ysxms); + json.put("gzxms",gzxms); + json.put("nf",nf); + TjwModelUtil.addModelData(rs,"uf_zjxms",json); + + logger.info("MakeDataCronJob.execute() end"); + }catch(Throwable e){ + logger.error("MakeDataCronJob.execute() exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/bozhongjgj/GetFpImageApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/bozhongjgj/GetFpImageApi.java new file mode 100644 index 0000000..1b56bd4 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/bozhongjgj/GetFpImageApi.java @@ -0,0 +1,206 @@ +package com.api.taojw.bozhongjgj; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.doc.detail.util.DocDownloadCheckUtil; +import org.apache.log4j.Logger; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.rendering.PDFRenderer; +import sun.misc.BASE64Encoder; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +@Path("/fpdy") +public class GetFpImageApi { + + static Logger logger = MyLogger.getLogger(); + + @GET + @Path("/getImageDataById") + @Produces(MediaType.APPLICATION_JSON) + public String getImageDataById(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + RecordSet rs = new RecordSet(); + //发票台账id + String requestId = request.getParameter("requestId"); + String fieldNames = request.getParameter("fieldNames"); + + /*String workFlowIds = request.getParameter("workFlowIds"); + String[] workFlowIdArr = workFlowIds.split(","); + String nodeIds = request.getParameter("nodeIds"); + String[] nodeIdArr = nodeIds.split(","); + String requestIds = request.getParameter("requestIds"); + List requestIdList = new ArrayList<>();*/ + String getBaseInfoSql = + "select workflowid,currentnodeid from workflow_requestbase where requestid = ?"; + /*for(String requestIdInArr : requestIds.split(",")){ + boolean requestIdInWorkflow = false; + boolean requestIdInNode = false; + Map firstData = DaoUtil.getFirstData(rs, getBaseInfoSql, requestIdInArr); + String workflowid = firstData.get("firstData"); + String currentnodeid = firstData.get("currentnodeid"); + if(workflowid != null && !"".equals(workflowid) && currentnodeid != null && !"".equals(currentnodeid)){ + for(String workFlowId : workFlowIdArr){ + if(workFlowId.equals(workflowid)){ + requestIdInWorkflow = true; + break; + } + } + for(String nodeid : nodeIdArr){ + if(nodeid.equals(currentnodeid)){ + requestIdInNode = true; + break; + } + } + } + if(requestIdInWorkflow && requestIdInNode){ + requestIdList.add(requestIdInArr); + } + }*/ + + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + List fpIdList = new ArrayList<>(); + if(!"".equals(requestId) && requestId != null){ + if(!"".equals(fieldNames) && fieldNames != null){ + String[] fieldNameArr = fieldNames.split(","); + for(String fieldName : fieldNameArr){ + String getTableNameSql = "select t1." + fieldName + " from " + tableName + "_dt1 t1 inner join " + tableName + " t2 on t2.id = t1.mainid where t2.requestid = ?"; + List> data = DaoUtil.getData(rs, getTableNameSql, requestId); + for(Map m : data){ + String fpIds = m.get(fieldName.toLowerCase(Locale.ROOT)); + if(fpIds != null && !"".equals(fpIds)){ + String[] fpIdArr = fpIds.split(","); + for(String fpId : fpIdArr){ + fpIdList.add(fpId); + } + } + } + } + } + } + + /*for(String requestIdInArr : requestIdList){ + if(!"".equals(fieldNames) && fieldNames != null){ + String[] fieldNameArr = fieldNames.split(","); + for(String fieldName : fieldNameArr){ + String getTableNameSql = "select t1." + fieldName + " from " + tableName + "_dt1 t1 inner join " + tableName + " t2 on t2.id = t1.mainid where t2.requestid = ?"; + List> data = DaoUtil.getData(rs, getTableNameSql, requestIdInArr); + for(Map m : data){ + String fpIds = m.get(fieldName.toLowerCase(Locale.ROOT)); + if(fpIds != null && !"".equals(fpIds)){ + String[] fpIdArr = fpIds.split(","); + for(String fpId : fpIdArr){ + fpIdList.add(fpId); + } + } + } + } + } + }*/ + + JSONArray res = new JSONArray(); + User user = HrmUserVarify.getUser(request, response); + + for(String id : fpIdList){ + JSONObject o = new JSONObject(); + //获取发票imageFileId + String imageFileId = ""; + String imageFileType = ""; + String fileSize = ""; + String getImageFileIdSql = "select t1.imageid,t2.imagefilename,t2.filesize from fnainvoiceledger t1 inner join imagefile t2 on t2.imageFileId = t1.imageid where t1.id = ?"; + Map firstData = DaoUtil.getFirstData(rs, getImageFileIdSql, id); + if(firstData.size() > 0){ + imageFileId = firstData.get("imageid"); + String imageFileName = firstData.get("imagefilename"); + fileSize = firstData.get("filesize"); + imageFileType = imageFileName.substring(imageFileName.lastIndexOf(".")+1); + } + + String newImageFileId = ""; + try{ + logger.info("DocDownloadCheckUtil.checkPermission begin;imageFileId:" + imageFileId + ";user:" + user.getUID()); + newImageFileId = DocDownloadCheckUtil.checkPermission(imageFileId,user); + }catch (Exception e){ + logger.error("DocDownloadCheckUtil.checkPermission exception;imageFileId:" + imageFileId + ";user:"+user.getUID()+";message:" + e.getMessage() + ";e:" + e); + } + + + o.put("imageFileType",imageFileType); + o.put("imageFileId",imageFileId); + o.put("newImageFileId",newImageFileId); + String imageImageFileId = pdfToImage(imageFileId); + o.put("base64",imageToBase64(imageImageFileId,fileSize)); + res.add(o); + } + result.put("data",res); + }catch(Exception e){ + logger.error("getImageDataById exception;message:" + e.getMessage() + ";e:" + e); + } + return result.toJSONString(); + } + + // 将图片文件转化为字节数组字符串,并对其进行Base64编码处理 + public static String imageToBase64(String imageFileId,String fileSize) { + byte[] data = null; + // 读取图片字节数组 + try { + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + data = new byte[Integer.parseInt(fileSize)*12]; + in.read(data); + in.close(); + } catch (Exception e) { + logger.error("imageToBase64 exception;message:" + e.getMessage() + ";e:" + e); + } + // 对字节数组Base64编码 + BASE64Encoder encoder = new BASE64Encoder(); + return encoder.encode(data);// 返回Base64编码过的字节数组字符串 + } + + public String pdfToImage(String pdfImageFileId){ + try { + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(pdfImageFileId)); + PDDocument doc = PDDocument.load(in); + PDFRenderer renderer = new PDFRenderer(doc); + int pageCount = doc.getNumberOfPages(); + int fileByInputSteam = 0; + for(int i=0;i firstData = DaoUtil.getFirstData(rs, getModeDataSql, id); + Map mainTable = new HashMap<>(); + mainTable.put("xgya",firstData.get("xgyt")); + String requestName = firstData.get("dbmc"); + TjwWorkFlowUtil.createWorkFlow(requestName,user.getUID()+"",workFlowId,"1",mainTable,null); + } + result.put("flag","1"); + return result.toJSONString(); + }catch(Exception e){ + logger.error("MultiSubmitApi.multiSubmitApi exception;message:" + e.getMessage() + ";e:" + e); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/chuanbo/servlet/FileDownloadServlet.java b/src/main/jinwei_tao_old_src/com/api/taojw/chuanbo/servlet/FileDownloadServlet.java new file mode 100644 index 0000000..c1f684c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/chuanbo/servlet/FileDownloadServlet.java @@ -0,0 +1,88 @@ +package com.api.taojw.chuanbo.servlet; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.*; + +public class FileDownloadServlet extends HttpServlet{ + + Logger logger = MyLogger.getLogger(); + + public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + this.doGet(req, res); + } + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { + RecordSet rs = new RecordSet(); + //获取参数 + + String modeId = Util.null2String(req.getParameter("modeId")); + String tableName = CommonSqlUtil.getTableNameByModeId(modeId,rs); + String columns = Util.null2String(req.getParameter("columns")); + String ids = Util.null2String(req.getParameter("ids")); + String fileName = Util.null2String(req.getParameter("ids")); + + logger.info("FileDownloadServlet.param: modeId:" + modeId + ";columns:" + columns + ";ids:" + ids); + if("".equals(ids) || ids == null || columns == null || "".equals(columns)){ + return; + } + String[] idArr = ids.split(","); + String[] columnArr = columns.split(","); + String getDocIdSql = "SELECT " + columns + " from " + tableName + " where id = ?"; + String getImageFileInfoSql = "select imagefilename,imagefileid from docimagefile where docid = ? order by versionid desc"; + List docIdList = new ArrayList<>(); + for(String id : idArr){ + Map firstData = DaoUtil.getFirstData(rs, getDocIdSql, id); + for(String column : columnArr){ + String docId = firstData.get(column.toLowerCase(Locale.ROOT)); + if(docId != null && !"".equals(docId)){ + docIdList.add(firstData.get(column.toLowerCase(Locale.ROOT))); + } + } + } + List> imageFileInfos = new ArrayList<>(); + for(String docId : docIdList){ + Map firstData = DaoUtil.getFirstData(rs, getImageFileInfoSql, docId); + Map m = new HashMap<>(); + m.put("imageFileId",firstData.get("imagefileid")); + m.put("imageFileName",firstData.get("imagefilename")); + imageFileInfos.add(m); + } + //响应文件 + downloadExcel(res,imageFileInfos,fileName); + } + + public void downloadExcel(HttpServletResponse res,List> imageFileInfos,String fileName){ + try { + res.setContentType("application/octet-stream"); + res.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(fileName,"UTF-8")); + //res.setHeader("Content-Length", String.valueOf(fis.getChannel().size())); + ServletOutputStream servletOutputStream = res.getOutputStream(); + try{ + TjwDocumentUtil.toZip(imageFileInfos,servletOutputStream); + //关闭资源 + servletOutputStream.close(); + }catch(Throwable e){ + logger.error("FileDownloadServlet.return file exception;exception:" + e.getMessage() + ";e:" + e); + }finally { + servletOutputStream.close(); + } + } catch (Exception e) { + logger.error("FileDownloadServlet exception;e:" + e.getMessage() + ";e:" + e); + } + logger.info("FileDownloadServlet done"); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/CommonSqlUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/CommonSqlUtil.java new file mode 100644 index 0000000..abd8b09 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/CommonSqlUtil.java @@ -0,0 +1,460 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CommonSqlUtil { + + static Logger logger = MyLogger.getLogger(); + + public static List> getDoneInfo(String userId){ + try { + RecordSet rs = new RecordSet(); + String getDoneInfoSql = + "select " + + "a.requestId as id, a.requestId as requestId, " + + "a.workflowId, a.requestName, a.requestnamenew,a.creater, a.creatertype, a.createDate, a.createTime, " + + "c.workflowname,b.viewtype,b.nodeid,b.isremark,b.agentorbyagentid,b.agenttype,b.isprocessed ,b.viewDate," + + "b.viewTime,a.lastFeedBackDate,a.lastFeedBackTime,b.needwfback,a.lastFeedBackOperator,b.userid," + + "(case WHEN b.operatedate IS NULL THEN b.receivedate ELSE b.operatedate END) operatedatenew,(case WHEN b.operatetime IS NULL THEN b.receivetime ELSE b.operatetime END) operatetimenew " + + "FROM " + + "Workflow_CurrentOperator b " + + "inner join Workflow_RequestBase a on a.requestId = b.requestId " + + "inner join workflow_base c on a.workflowid = c.id " + + "WHERE " + + "b.userId = ? " + + "AND (b.isRemark in ('2', '4') or (b.isremark=0 and b.takisremark =-2)) " + + "AND b.userType = 0 " + + "AND b.isLastTimes = 1 " + + "and (a.deleted<>1 or a.deleted is null or a.deleted='') " + + "AND (b.isComplete = 1 OR b.agenttype<>1)"; + List> data = DaoUtil.getData(rs, getDoneInfoSql, userId); + return data; + }catch(Throwable e){ + logger.error("CommonSqlUtil.getDoneInfo error;message:" + e.getMessage() + ";e:" + e); + return new ArrayList<>(); + } + } + + public static List> getWorkFlowCurrentUser(String requestId){ + RecordSet rs = new RecordSet(); + //数据库类型 + String dbType = rs.getDBType(); + //查询人员待办数量、邮箱地址、人员id + String sql = ""; + if("mysql".equalsIgnoreCase(dbType)){ + sql = + "select " + + "t3.id " + + "from " + + "workflow_requestbase t1 " + + "inner join workflow_currentoperator t2 on t1.requestid = t2.requestid " + + "inner join workflow_nodebase t5 on t5.id = t1.currentnodeid " + + "inner join hrmresource t3 on t3.id = t2.userid " + + "where " + + "((isremark='0' and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " + + "and islasttimes = 1 " + + "and (ifnull(t1.currentstatus,-1) = -1 or (ifnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " + + "and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " + + "and (t2.isprocessing = '' or t2.isprocessing is null) " + + "and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " + + "and t1.requestid = ?"; + } + + if("sqlserver".equalsIgnoreCase(dbType)){ + sql = + "select " + + "t3.id " + + "from " + + "workflow_currentoperator t2 " + + "inner join workflow_requestbase t1 on t1.requestid = t2.requestid " + + "inner join hrmresource t3 on t3.id = t2.userid " + + "where " + + "((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " + + "and islasttimes=1 " + + "and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " + + "and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " + + "and (t2.isprocessing = '' or t2.isprocessing is null) " + + "and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " + + "and t1.requestid = ?"; + } + + if("oracle".equalsIgnoreCase(dbType)){ + sql = + "select " + + "t3.id " + + "from " + + "workflow_currentoperator t2," + + "workflow_requestbase t1," + + "hrmresource t3 " + + "where " + + "t1.requestid = t2.requestid " + + "and t3.id = t2.userid " + + "and ((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " + + "and islasttimes=1 " + + "and (NVL(t1.currentstatus,-1) = -1 or (NVL(t1.currentstatus,-1)=0 and t1.creater in (1))) " + + "and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " + + "and (t2.isprocessing = '' or t2.isprocessing is null) " + + "and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " + + "and t1.requestid = ?"; + } + List> data = DaoUtil.getData(rs, sql, requestId); + return data; + } + + public static List> getTodoInfo(String userId){ + RecordSet rs = new RecordSet(); + //数据库类型 + String dbType = rs.getDBType(); + //查询人员待办数量、邮箱地址、人员id + String sql = ""; + if("mysql".equalsIgnoreCase(dbType)){ + sql = + "select " + + "t1.requestid,t1.workflowid " + + "from " + + "workflow_requestbase t1 " + + "inner join workflow_currentoperator t2 on t1.requestid = t2.requestid " + + "inner join workflow_nodebase t5 on t5.id = t1.currentnodeid " + + "inner join hrmresource t3 on t3.id = t2.userid " + + "where " + + "((isremark='0' and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " + + "and islasttimes = 1 " + + "and (ifnull(t1.currentstatus,-1) = -1 or (ifnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " + + "and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " + + "and (t2.isprocessing = '' or t2.isprocessing is null) " + + "and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " + + "and t3.id = ?"; + } + + if("sqlserver".equalsIgnoreCase(dbType)){ + sql = + "select " + + "t1.requestid,t1.workflowid " + + "from " + + "workflow_currentoperator t2 " + + "inner join workflow_requestbase t1 on t1.requestid = t2.requestid " + + "inner join hrmresource t3 on t3.id = t2.userid " + + "where " + + "((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " + + "and islasttimes=1 " + + "and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " + + "and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " + + "and (t2.isprocessing = '' or t2.isprocessing is null) " + + "and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " + + "and t3.id = ?"; + } + + if("oracle".equalsIgnoreCase(dbType)){ + sql = + "select " + + "t1.requestid,t1.workflowid " + + "from " + + "workflow_currentoperator t2," + + "workflow_requestbase t1," + + "hrmresource t3 " + + "where " + + "t1.requestid = t2.requestid " + + "and t3.id = t2.userid " + + "and ((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " + + "and islasttimes=1 " + + "and (NVL(t1.currentstatus,-1) = -1 or (NVL(t1.currentstatus,-1)=0 and t1.creater in (1))) " + + "and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " + + "and (t2.isprocessing = '' or t2.isprocessing is null) " + + "and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " + + "and t3.id = ?"; + } + List> data = DaoUtil.getData(rs, sql, userId); + return data; + } + + /** + * 查询所有上级部门id + * @param id + * @return + */ + public static void getAllParentDepartment(List result,String id){ + RecordSet rs = new RecordSet(); + String getParentDepartmentSql = "select supdepid from hrmdepartment where id = ?"; + Map firstData = DaoUtil.getFirstData(rs, getParentDepartmentSql, id); + String parentId = Util.null2String(firstData.get("supdepid")); + if("".equals(parentId)){ + return ; + }else{ + result.add(parentId); + getAllParentDepartment(result,parentId); + } + } + + /** + * 查询所有下级部门id + * @param id + * @return + */ + public static void getAllSonDepartment(List result,String id){ + RecordSet rs = new RecordSet(); + String getParentDepartmentSql = "select id from hrmdepartment where supdepid = ?"; + List> data = DaoUtil.getData(rs, getParentDepartmentSql, id); + if(data.size() == 0){ + return ; + }else{ + for(Map m : data){ + result.add(m.get("id")); + getAllSonDepartment(result,m.get("id")); + } + } + } + + + /** + * 获取系统参数设置值 + * @param uuid 参数标识 + * @return 返回配置值 + */ + public static String getSystemParamValue(String uuid,RecordSet rs){ + String result = ""; + try{ + String getDataByUuidSql = + "select paramvalue as result from uf_systemconfig where uuid = ?"; + if(rs.executeQuery(getDataByUuidSql,uuid)){ + if(rs.next()){ + result = Util.null2String(rs.getString("result")); + } + }else{ + logger.error("CommonSqlUtil.getSystemParamValue.getDataByUuidSql execute error;sql:" + getDataByUuidSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getSystemParamValue exception;uuid:" + uuid); + } + return result; + } + + /** + * 根据流程类型ID获取其对应的表单名称 + * @param workFlowId 流程类型ID + * @return 字符串 + */ + public static String getTableNameByWorkflowId(String workFlowId,RecordSet rs){ + String tableName = ""; + try{ + String getTableNameByWorkFlowIdSql = + "select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)"; + if(rs.executeQuery(getTableNameByWorkFlowIdSql,workFlowId)){ + if(rs.next()){ + tableName = Util.null2String(rs.getString("tablename")); + }else{ + logger.error("CommonSqlUtil.getTableNameByWorkflowId.getTableNameByWorkFlowIdSql execute success but found nothing;sql:" + getTableNameByWorkFlowIdSql); + } + }else{ + logger.error("CommonSqlUtil.getTableNameByWorkflowId.getTableNameByWorkFlowIdSql execute error;sql:" + getTableNameByWorkFlowIdSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getTableNameByWorkflowId exception;workFlowId:" + workFlowId); + } + return tableName; + } + + /** + * 根据requestId查询主表表名 + * @param requestId + * @param rs 数据库链接 + * @return + */ + public static String getTableNameByRequetId(String requestId, RecordSet rs){ + String tableName = ""; + try{ + String getTableNameByRequetIdSql = + "select tablename from workflow_bill where id = (Select formid from workflow_base where id = (select workflowid from workflow_requestbase where requestid = ? ))"; + if(rs.executeQuery(getTableNameByRequetIdSql,requestId)){ + if(rs.next()){ + tableName = Util.null2String(rs.getString("tablename")); + }else{ + logger.error("CommonSqlUtil.getTableNameByRequetId.getTableNameByRequetIdSql execute success but found nothing;sql:" + getTableNameByRequetIdSql); + } + }else{ + logger.error("CommonSqlUtil.getTableNameByRequetId.getTableNameByRequetIdSql execute error;sql:" + getTableNameByRequetIdSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getTableNameByRequetId exception;requestId:" + requestId); + } + return tableName; + } + + /** + * 根据modeId查询建模表表名 + * @param modeId 建模表表名 + * @param rs 数据库链接 + * @return + */ + public static String getTableNameByModeId(String modeId, RecordSet rs){ + String tableName = ""; + try{ + String getTableNameSql = + "select t2.tablename from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid where t1.id = ?"; + if(rs.executeQuery(getTableNameSql,modeId)){ + if(rs.next()){ + tableName = Util.null2String(rs.getString("tablename")); + }else{ + logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql execute success but found nothing;sql:" + getTableNameSql + ";modeId:" + modeId); + } + }else{ + logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql execute error;sql:" + getTableNameSql+ ";modeId:" + modeId); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql exception;modeId:" + modeId); + } + return tableName; + } + + /** + * 根据建模表表名查询modeId + * @param tableName 建模表表名 + * @param rs 数据库链接 + * @return + */ + public static int getModeIdByTableName(String tableName, RecordSet rs){ + int modeId = -1; + try{ + String getModeIdSql = + "select t1.id from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid where t2.tablename = '" + tableName + "' and t1.isdelete = 0"; + if(rs.executeQuery(getModeIdSql)){ + if(rs.next()){ + modeId = Util.getIntValue(rs.getString("id"),0); + }else{ + logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql execute success but found nothing;sql:" + getModeIdSql); + } + }else{ + logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql execute error;sql:" + getModeIdSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql exception;tableName:" + tableName); + } + return modeId; + } + + /** + * 根据requestId获取流程审批意见 + * @param requestId + * @return + */ + public static List> getProcessInfoList(String requestId,RecordSet rs){ + List> result = new ArrayList<>(); + try{ + if(rs == null){ + rs = new RecordSet(); + } + String selectSQL = + "Select " + + "t2.departmentid as deptid," + + "t3.departmentname as deptname," + + "t1.operator as createuserid," + + "t2.lastname as createusername," + + "t1.operatedate as operatedate," + + "t1.operatetime as operatetime," + + "t1.logtype as serviceactioncode," + + "t1.remark as suggestion " + + "from " + + "workflow_requestlog t1 " + + "left join Hrmresource t2 on t2.id= t1.operator " + + "left join hrmdepartment t3 on t3.id= t2.departmentid " + + "where " + + "t1.requestid = ? " + + "order by " + + "t1.operatedate asc,t1.operatetime asc"; + if(rs.executeQuery(selectSQL,requestId)){ + while(rs.next()){ + Map processInfo = new HashMap<>(); + processInfo.put("deptid",Util.null2String(rs.getString("deptid"))); + processInfo.put("deptname",Util.null2String(rs.getString("deptname"))); + processInfo.put("createuserid",Util.null2String(rs.getString("createuserid"))); + processInfo.put("createusername",Util.null2String(rs.getString("createusername"))); + processInfo.put("serviceactiontime",Util.null2String(rs.getString("operatedate")) + " " + Util.null2String(rs.getString("operatetime"))); + String serviceactioncode = Util.null2String(rs.getString("serviceactioncode")); + String serviceaction = ""; + switch (serviceactioncode){ + case "0": serviceaction = "批准"; break; + case "1": serviceaction = "保存"; break; + case "2": serviceaction = "提交"; break; + case "3": serviceaction = "退回"; break; + case "4": serviceaction = "重新打开"; break; + case "5": serviceaction = "删除"; break; + case "6": serviceaction = "激活"; break; + case "7": serviceaction = "转发"; break; + case "9": serviceaction = "批注"; break; + case "a": serviceaction = "意见征询"; break; + case "b": serviceaction = "意见征询回复"; break; + case "e": serviceaction = "强制归档"; break; + case "h": serviceaction = "转办"; break; + case "i": serviceaction = "干预"; break; + case "j": serviceaction = "转办反馈"; break; + case "s": serviceaction = "督办"; break; + case "t": serviceaction = "抄送"; break; + default: serviceaction = "其他"; break; + } + processInfo.put("serviceaction",serviceaction); + String suggestion = Util.null2String(rs.getString("suggestion")); + if(!"".equals(suggestion)){ + suggestion = CommonUtil.delHTMLTag(suggestion); + } + processInfo.put("suggestion",suggestion); + result.add(processInfo); + } + }else{ + logger.error("CommonSqlUtil.getProcessInfoList.sql error;sql:" + selectSQL + ";requestId:" + requestId); + } + }catch(Exception e){ + logger.error("CommonSqlUtil.getProcessInfoList exception;requestId:" + requestId + ";message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据requestid,获取流程审批意见 + * @param rs + * @param requestId + * @return + */ + public static String getWorkFlowSuggestion(RecordSetTrans rs, String requestId){ + String result = ""; + String getWorkFlowSuggestionSql = + "Select " + + "t2.departmentid as deptid," + + "t3.departmentname as deptname," + + "t1.operator as createuserid," + + "t2.lastname as createusername," + + "t1.operatedate as operatedate," + + "t1.operatetime as operatetime," + + "t1.logtype as logtype," + + "t1.remark as suggestion " + + "from " + + "workflow_requestlog t1 " + + "left join Hrmresource t2 on t2.id= t1.operator " + + "left join hrmdepartment t3 on t3.id= t2.departmentid " + + "where " + + "requestid = ? " + + "order by " + + "t1.operatedate desc,t1.operatetime desc"; + try{ + if(rs.executeQuery(getWorkFlowSuggestionSql,requestId)){ + if(rs.next()){ + result = Util.null2String(rs.getString("suggestion")); + } + }else{ + logger.error("CommonSqlUtil.getWorkFlowSuggestion execute error;getWorkFlowSuggestionSql:" + getWorkFlowSuggestionSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getFormatTimeByTimeMillis execute error;getWorkFlowSuggestionSql:" + getWorkFlowSuggestionSql + "exception:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/CommonUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/CommonUtil.java new file mode 100644 index 0000000..8ee358d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/CommonUtil.java @@ -0,0 +1,318 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class CommonUtil { + + static Logger logger = MyLogger.getLogger(); + static SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + static DecimalFormat jeFormat = new DecimalFormat("###,##0.00"); + static DecimalFormat twoXsFormat = new DecimalFormat("0.00"); + + /** + * + * @return + */ + public static JSONObject getLastMonthDate(){ + JSONObject result = new JSONObject(); + try{ + SimpleDateFormat df =new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + String berforeFirstDay = df.format(calendar.getTime()); + result.put("lastMonthBegin",berforeFirstDay); + Calendar calendar1 = Calendar.getInstance(); + calendar1.set(Calendar.DAY_OF_MONTH, 1); + calendar1.add(Calendar.DATE, -1); + String berforeLastDay = df.format(calendar1.getTime()); + result.put("berforeLastDay",berforeLastDay); + //logger.error("CommonUtil.getLastMonthDate done;result:" + result.toJSONString()); + }catch(Exception e){ + logger.error("CommonUtil.getLastMonthDate exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 减法 + * @param js + * @param bjs + * @return + */ + public static String minusString(String js,String bjs) { + try{ + Float jsFloat; + try { + jsFloat = Float.parseFloat(js); + } catch (Exception e) { + logger.error("CommonUtil.minusString.parseFloat data error;js:" + js); + return "0.00"; + } + Float bjsFloat; + try { + bjsFloat = Float.parseFloat(bjs); + } catch (Exception e) { + logger.error("CommonUtil.minusString.parseFloat data error;bjs:" + bjs); + return "0.00"; + } + return twoXsFormat.format(bjsFloat - jsFloat); + }catch(Exception e){ + logger.error("CommonUtil.multiplyHundred exception;js:" + js + ";bjs:" + bjs + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 将字符串转为乘100 + * @param data + * @return + */ + public static String multiplyHundred(String data) { + try{ + Float dataFloat; + try { + dataFloat = Float.parseFloat(data); + } catch (Exception e) { + logger.error("CommonUtil.multiplyHundred.parseFloat data error;data:" + data); + return "0.00"; + } + dataFloat = dataFloat * 100; + return twoXsFormat.format(dataFloat); + }catch(Exception e){ + logger.error("CommonUtil.multiplyHundred exception;data:" + data + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 将字符串转为带逗号的金额 + * @param data + * @return + */ + public static String formatMoney(String data) { + try{ + Float dataFloat; + try { + dataFloat = Float.parseFloat(data); + } catch (Exception e) { + logger.error("CommonUtil.formatMoney.parseFloat data error;data:" + data); + return "0.00"; + } + return jeFormat.format(dataFloat); + }catch(Exception e){ + logger.error("CommonUtil.formatMoney exception;data:" + data + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 计算占比,保留两位小数返回字符串 + * 已乘100 + * @param fz 分子 + * @param fm 分母 + * @return + */ + public static String getBl(String fz,String fm,String needMultiplyHundred) { + try { + String result = ""; + Float fzFloat; + Float fmFloat; + try { + fzFloat = Float.parseFloat(fz); + } catch (Exception e) { + logger.error("CommonUtil.getBl.parseFloat fz error;fz:" + fz); + return "0.00"; + } + try { + fmFloat = Float.parseFloat(fm); + } catch (Exception e) { + logger.error("CommonUtil.getBl.parseFloat fm error;fm:" + fm); + return "0.00"; + } + + BigDecimal oldDataBd = new BigDecimal(fm); + if(oldDataBd.compareTo(BigDecimal.ZERO)==0){ + return "0.00"; + } + + if("1".equals(needMultiplyHundred)){ + result = twoXsFormat.format(100 * fzFloat / fmFloat); + }else{ + result = twoXsFormat.format(fzFloat / fmFloat); + } + return result; + } catch (Exception e) { + logger.error("CommonUtil.getBl exception;fz:" + fz + ";fm:"+ fm + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 计算增长率,保留两位小数返回字符串 + * 已乘100 + * @param oldData + * @param newData + * @return + */ + public static String getGrowthRate(String oldData,String newData) { + try { + String result = ""; + Float oldDataFloat; + Float newDataFloat; + try { + oldDataFloat = Float.parseFloat(oldData); + } catch (Exception e) { + logger.error("CommonUtil.getGrowthRate.parseFloat oldData error;oldData:" + oldData); + return "100.00"; + } + try { + newDataFloat = Float.parseFloat(newData); + } catch (Exception e) { + logger.error("CommonUtil.getGrowthRate.parseFloat newData error;newData:" + newData); + return "-100.00"; + } + BigDecimal oldDataBd = new BigDecimal(oldData); + if(oldDataBd.compareTo(BigDecimal.ZERO)==0){ + return "100.00"; + } + result = twoXsFormat.format(100*(newDataFloat - oldDataFloat) / oldDataFloat); + return result; + } catch (Exception e) { + logger.error("CommonUtil.getGrowthRate exception;oldData:" + oldData + ";newData:"+ newData + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 剔除字符串中的html标签 + * @param htmlStr + * @return + */ + public static String delHTMLTag(String htmlStr){ + String regEx_script="]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式 + String regEx_style="]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式 + String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式 + + Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE); + Matcher m_script=p_script.matcher(htmlStr); + htmlStr=m_script.replaceAll(""); //过滤script标签 + + Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); + Matcher m_style=p_style.matcher(htmlStr); + htmlStr=m_style.replaceAll(""); //过滤style标签 + + Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE); + Matcher m_html=p_html.matcher(htmlStr); + htmlStr=m_html.replaceAll(""); //过滤html标签 + + return htmlStr.trim(); //返回文本字符串 + } + + /** + * 获取json指定路径的JSONArray 路径中有数组,则获取数组的第一个明细中的数据 + * @param obj 待查询的JSONObject + * @param path 格式为a/b/c + * @return JSONArray + */ + public static JSONArray getJsonArrayByPath(JSONObject obj, String path){ + try{ + int index = path.indexOf("/"); + if(index > -1){ + JSONObject son; + Object sons = obj.get(path.substring(0,index)); + if(sons instanceof JSONArray){ + son = (JSONObject) ((JSONArray) sons).get(0); + }else{ + son = obj.getJSONObject(path.substring(0,index)); + } + return getJsonArrayByPath(son,path.substring(index+1)); + }else{ + return obj.getJSONArray(path); + } + }catch(Exception e){ + logger.error("CommonUtil.getJsonArrayByPath error;exception:" + e.getMessage() + ";e:" + e); + return new JSONArray(); + } + } + + /** + * 获取json指定路径的值 路径中有数组,则获取数组的第一个明细中的数据 + * @param obj 待查询的JSONObject + * @param path 格式为a/b/c + * @return 值 + */ + public static String getJsonValueByPath(JSONObject obj, String path){ + try{ + int index = path.indexOf("/"); + if(index > -1){ + JSONObject son; + Object sons = obj.get(path.substring(0,index)); + if(sons instanceof JSONArray){ + son = (JSONObject) ((JSONArray) sons).get(0); + }else{ + son = obj.getJSONObject(path.substring(0,index)); + } + return getJsonValueByPath(son,path.substring(index+1)); + }else{ + return obj.get(path).toString(); + } + }catch(Exception e){ + logger.error("CommonUtil.getJsonValueByPath error;path:" + path + ";obj" + obj + "exception:" + e.getMessage() + ";e:" + e); + return ""; + } + } + + /** + * 多行文本转字符串 剔除
、  标签; 全角转半角 + * @param input 待转换的字符串 + * @return 转换后的字符串 + */ + public static String manyLineToString(String input) { + if("".equals(input) || input == null){ + return ""; + } + String result = ""; + input = input.replaceAll("
"," "); + input = input.replaceAll(" "," "); + result = fullToHalfAngle(input); + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + } + } + return result; + } + + /** + * 全角转半角 + * @param input 待转换的字符串 + * @return 转换后的字符串 + */ + public static String fullToHalfAngle(String input) { + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + return returnString; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/Constant.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/Constant.java new file mode 100644 index 0000000..fd18285 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/Constant.java @@ -0,0 +1,118 @@ +package com.api.taojw.common; + + +/** + * 一些静态常量定义 + */ +public class Constant { + + //action接口调用配置表名称 + public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd"; + + //------------------------------------------------------------------------------接口请求日志表名及字段 + //action调用接口日志记录表表名 + public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd"; + //action调用接口日志记录表requestId字段名称 + public static String LOG_REQUESTID_COLUMN = "lcrequestid"; + //action调用接口日志记录表请求正文字段名称 + public static String LOG_REQUEST_COLUMN = "qqbw"; + //action调用接口日志记录表响应文字段名称 + public static String LOG_RESPONSE_COLUMN = "xybw"; + //action调用接口日志记录表响应码字段名称 + public static String LOG_RESPONSECODE_COLUMN = "xym"; + //action调用接口日志记录表请求地址字段名称 + public static String LOG_REQUEST_ADDRESS_COLUMN = "qqdz"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUEST_HEADER_COLUMN = "qqt"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUEST_RESULT_COLUMN = "qqjg"; + + //------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志 + public static final String PARAM_BEGIN = "{"; + public static final String PARAM_END = "}"; + + //------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功 + public static final String CALL_SUCCESS = "1"; + public static final String CALL_FAILED = "0"; + + //------------------------------------------------------------------------------选择框 0-否 1-是 + public static final String SELECT_TYPE_IS = "1"; + public static final String SELECT_TYPE_NOT = "0"; + + //------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次 + public static final String CALL_TYPE_ONLY_ONE = "0"; + public static final String CALL_TYPE_EVERY_DETAIL = "1"; + + //------------------------------------------------------------------------------接口请求类型 0-get 1-post + //GET + public static final String REQUEST_METHOD_GET = "0"; + //POST + public static final String REQUEST_METHOD_POST = "1"; + + //------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对 + //xml + public static final String REQUEST_DATA_TYPE_XML = "0"; + //json + public static final String REQUEST_DATA_TYPE_JSON = "1"; + //键值对 + public static final String REQUEST_DATA_TYPE_PAIR = "2"; + //MultipartFile + public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3"; + + //------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json + //xml + public static final String RESPONSE_DATA_TYPE_XML = "0"; + //json + public static final String RESPONSE_DATA_TYPE_JSON = "1"; + + //------------------------------------------------------------------------------节点类型 + //文本 + public static final String NODE_TYPE_STRING = "0"; + //对象 + public static final String NODE_TYPE_OBJECT = "1"; + //文本数组 + public static final String NODE_TYPE_STRING_ARRAY = "2"; + //数组 + public static final String NODE_TYPE_ARRAY = "3"; + //json对象字符串 + public static final String NODE_TYPE_JSONSTRING = "4"; + //数字 + public static final String NODE_TYPE_NUMBER = "5"; + //布尔 + public static final String NODE_TYPE_BOOLEAN = "6"; + //浮点数 + public static final String NODE_TYPE_FLOAT = "7"; + //辅助核算项 + public static final String NODE_TYPE_FZHSX = "8"; + + + //------------------------------------------------------------------------------转换规则 + //不转换 + public static final String CHANGE_TYPE_NONE = "0"; + //固定值 + public static final String CHANGE_TYPE_FIXED = "1"; + //自定义sql + public static final String CHANGE_TYPE_SQL = "2"; + //字段求和 + public static final String CHANGE_TYPE_SUM = "3"; + //文本数组 + public static final String CHANGE_TYPE_STRING_ARRAY = "4"; + //明细序号 + public static final String CHANGE_TYPE_ROW_NUMBER = "5"; + //流程审批意见 + public static final String CHANGE_TYPE_SUGGESTION = "6"; + //加密处理 + public static final String CHANGE_TYPE_MD5 = "7"; + //requestId + public static final String CHANGE_TYPE_REQUEST_ID = "8"; + //流程标题 + public static final String CHANGE_TYPE_REQUEST_NAME = "9"; + + //------------------------------------------------------------------------------sql转义 + //默认换行符 + public static final String Default_Line_Break = "
"; + //默认空格HTML代码 + public static final String Default_Html_Blank = " "; + //默认空格字符 + public static final String Default_Blank_Char = " "; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/DaoUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/DaoUtil.java new file mode 100644 index 0000000..a47a538 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/DaoUtil.java @@ -0,0 +1,218 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.util.*; + + +/** + * 数据库操作添加try catch 以及日志输出 + */ +public class DaoUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 将结果行转为map + * @param rs + * @return + */ + public static Map setRsToMap(RecordSet rs){ + try{ + Map result = new HashMap<>(); + for(String name:rs.getColumnName()){ + result.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name))); + } + return result; + }catch(Exception e){ + logger.error("DaoUtil.setRsToMap execute error;exception:" + e.getMessage() + ";e:" + e); + return new HashMap<>(); + } + } + + /** + * 判断数据是否存在 + * @param sql + * @param params + * @return + */ + public static boolean isDataExists(String sql,Object...params) { + try{ + RecordSet rs = new RecordSet(); + return isDataExists(rs,sql,params); + }catch(Exception e){ + logger.error("DaoUtil.isDataExists Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 判断数据是否存在 + * @param rs + * @param sql + * @param params + * @return + */ + public static boolean isDataExists(RecordSet rs,String sql,Object...params) { + try{ + int count = 0; + if(rs.executeQuery(sql,params)){ + if(rs.next()){ + count = Util.getIntValue(rs.getString(1),0); + } + }else{ + logger.error("DaoUtil.isDataExists sql error;sql:" + sql + ";params:" + Arrays.toString(params)); + } + if(count > 0){ + return true; + }else{ + return false; + } + }catch(Exception e){ + logger.error("DaoUtil.isDataExists Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 查询第一行数据 + * @param rs + * @param sql + * @param params + * @return + */ + public static Map getFirstData(RecordSet rs, String sql, Object...params){ + Map result = new HashMap<>(); + try{ + if(rs.executeQuery(sql,params)){ + if(rs.next()){ + for(String name:rs.getColumnName()){ + result.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name))); + } + }else{ + logger.error("DaoUtil.getFirstData sql found nothing;sql:" + sql + ";params:" + Arrays.toString(params)); + } + }else{ + logger.error("DaoUtil.getFirstData sql error;sql:" + sql + ";params:" + Arrays.toString(params)); + } + return result; + }catch(Exception e){ + logger.error("DaoUtil.getFirstData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 查询 + * @param sql + * @param params + * @return + */ + public static Map getFirstData(String sql, Object...params){ + Map result = new HashMap<>(); + try{ + RecordSet rs = new RecordSet(); + result = getFirstData(rs,sql,params); + return result; + }catch(Exception e){ + logger.error("DaoUtil.getFirstData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 查询 + * @param rs + * @param sql + * @param params + * @return + */ + public static List> getData(RecordSet rs, String sql, Object...params){ + List> result = new ArrayList<>(); + try{ + if(rs.executeQuery(sql,params)){ + while(rs.next()){ + Map m = new HashMap<>(); + for(String name:rs.getColumnName()){ + if("zdysql".equalsIgnoreCase(name) || Util.null2String(name).toLowerCase(Locale.ROOT).indexOf("zdysql") > -1){ + String zdysql = Util.null2String(rs.getString(name)); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + m.put(name.toLowerCase(Locale.ROOT),zdysql); + }else{ + m.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name))); + } + } + result.add(m); + } + }else{ + logger.error("DaoUtil.getData sql error;sql:" + sql + ";params:" + Arrays.toString(params)); + } + return result; + }catch(Exception e){ + logger.error("DaoUtil.getData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 查询 + * @param sql + * @param params + * @return + */ + public static List> getData(String sql, Object...params){ + List> result = new ArrayList<>(); + try{ + RecordSet rs = new RecordSet(); + result = getData(rs,sql,params); + return result; + }catch(Exception e){ + logger.error("DaoUtil.getData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 更新数据 + * @param rs + * @param sql + * @param params + * @return + */ + public static boolean updateData(RecordSet rs,String sql, Object...params){ + try{ + if(!rs.executeUpdate(sql,params)){ + logger.error("DaoUtil.updateData sql error;sql:" + sql + ";params:" + Arrays.toString(params)); + return false; + }else{ + return true; + } + }catch(Exception e){ + logger.error("DaoUtil.updateData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 更新数据 + * @param sql + * @param params + */ + public static boolean updateData(String sql, Object...params){ + try{ + RecordSet rs = new RecordSet(); + return updateData(rs,sql,params); + }catch(Exception e){ + logger.error("DaoUtil.updateData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/HrmCommonUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/HrmCommonUtil.java new file mode 100644 index 0000000..df32b28 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/HrmCommonUtil.java @@ -0,0 +1,77 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import com.weaver.general.Util; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.finance.SalaryManager; +import weaver.hrm.resource.ResourceComInfo; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +public class HrmCommonUtil { + + static Logger logger = MyLogger.getLogger(); + + public static Map addUser(Map userInfo,RecordSet rsSch){ + Map result = new HashMap<>(); + try{ + if(rsSch == null){ + rsSch = new RecordSet(); + } + + char separator = Util.getSeparator(); + Calendar todaycal = Calendar.getInstance(); + String today = Util.add0(todaycal.get(Calendar.YEAR), 4) + "-" + + Util.add0(todaycal.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(todaycal.get(Calendar.DAY_OF_MONTH), 2); + String userpara = "" + 1 + separator + today; + + rsSch.executeProc("HrmResourceMaxId_Get", ""); + rsSch.next(); + //新增的人员id + String newId = "" + rsSch.getInt(1); + //使用sql新增人员 + String insertSql = + "insert into HrmResource(" + + "id,systemlanguage,workcode,departmentid,subcompanyid1," + + "jobtitle,status,createrid,createdate,lastmodid," + + "lastmoddate,lastname,sex,loginid,password," + + "managerid,seclevel,dsporder) " + + "values(" + + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean addUser = DaoUtil.updateData(insertSql, + newId, userInfo.get("systemlanguage"), userInfo.get("workcode"), userInfo.get("departmentid"), userInfo.get("subcompanyid1"), + userInfo.get("jobtitle"), userInfo.get("status"), userInfo.get("createrid"), userInfo.get("createdate"), userInfo.get("lastmodid"), + userInfo.get("lastmoddate"), userInfo.get("lastname"), userInfo.get("sex"), userInfo.get("loginid"), userInfo.get("password"), + userInfo.get("managerid"), userInfo.get("seclevel"), userInfo.get("dsporder")); + if(addUser){ + rsSch.executeProc("HrmResource_CreateInfo", "" + newId + separator + userpara + separator + userpara); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + resourceComInfo.addResourceInfoCache(newId); + SalaryManager salaryManager = new SalaryManager(); + salaryManager.initResourceSalary(newId); + String para1 = "" + newId + separator + "" + separator + userInfo.get("departmentid") + separator + userInfo.get("subcompanyid1") + separator + "0" + separator + "0"; + rsSch.executeProc("HrmResource_Trigger_Insert", para1); + String sql_1 = ("insert into HrmInfoStatus (itemid,hrmid) values(1," + newId + ")"); + rsSch.execute(sql_1); + String sql_2 = ("insert into HrmInfoStatus (itemid,hrmid) values(2," + newId + ")"); + rsSch.execute(sql_2); + String sql_3 = ("insert into HrmInfoStatus (itemid,hrmid) values(3," + newId + ")"); + rsSch.execute(sql_3); + String sql_10 = ("insert into HrmInfoStatus (itemid,hrmid) values(10," + newId + ")"); + rsSch.execute(sql_10); + resourceComInfo.updateResourceInfoCache(newId); + result.put("newId",newId); + }else{ + logger.error("HrmCommonUtil.addUser.addUserSql error;userInfo:" + userInfo); + } + }catch(Exception e){ + logger.error("HrmCommonUtil.addUser exception;userInfo:" + userInfo + "message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/HttpGetWithEntity.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/HttpGetWithEntity.java new file mode 100644 index 0000000..32a2ef0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/HttpGetWithEntity.java @@ -0,0 +1,29 @@ +package com.api.taojw.common; + +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; + +import java.net.URI; + +public class HttpGetWithEntity extends HttpEntityEnclosingRequestBase { + private final static String METHOD_NAME = "GET"; + + @Override + public String getMethod() { + return METHOD_NAME; + } + + public HttpGetWithEntity() { + super(); + } + + public HttpGetWithEntity(final URI uri) { + super(); + setURI(uri); + } + + HttpGetWithEntity(final String uri) { + super(); + setURI(URI.create(uri)); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/JsonConvertUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/JsonConvertUtil.java new file mode 100644 index 0000000..c0c0dc3 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/JsonConvertUtil.java @@ -0,0 +1,32 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONObject; +import weaver.conn.RecordSet; + +import java.util.List; +import java.util.Map; + +public class JsonConvertUtil { + + public static JSONObject convertJsonByConfig(JSONObject oldJson,String configId){ + RecordSet rs = new RecordSet(); + //获取配置信息 + String getConfigSql = + "select " + + "t2.zhgz,t2.zdysql,t2.xzdmc,t2.yzdmc " + + "from " + + "uf_jsontojson t1 " + + "inner join uf_jsontojson_dt1 t2 on t2.mainid = t1.id " + + "where " + + "t1.id = ?"; + List> configData = DaoUtil.getData(rs, getConfigSql, configId); + JSONObject result = new JSONObject(); + for(Map configMap : configData){ + String oldValue = oldJson.getString(configMap.get("yzdmc")); + String newValue = WorkFlowDataToJsonUtil.convertDataByZhgz(oldValue,configMap); + result.put(configMap.get("xzdmc"),newValue); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/Md5Util.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/Md5Util.java new file mode 100644 index 0000000..d564eff --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/Md5Util.java @@ -0,0 +1,77 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import com.weaverboot.tools.logTools.LogTools; +import org.apache.log4j.Logger; + +import javax.xml.bind.DatatypeConverter; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.security.MessageDigest; + +public class Md5Util { + + static Logger logger = MyLogger.getLogger(); + + public static String MD5Encode(String originalString) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(originalString.getBytes()); + byte[] digest = md.digest(); + String hash = DatatypeConverter.printHexBinary(digest).toUpperCase(); + return hash; + } catch (Exception var5) { + logger.error(""); + return ""; + } + } + + /** + * 对文件全文生成MD5摘要 + * + * @param file + * 要加密的文件 + * @return MD5摘要码 + */ + public static String getMD5OfFile(final File file) throws IOException { + FileInputStream fis = null; + try { + final MessageDigest md = MessageDigest.getInstance("MD5"); + fis = new FileInputStream(file); + final byte[] buffer = new byte[2048]; + int length = -1; + final long s = System.currentTimeMillis(); + while ((length = fis.read(buffer)) != -1) { + md.update(buffer, 0, length); + } + final byte[] b = md.digest(); + return byteToHexStringSingle(b); + } catch (final Exception ex) { + LogTools.error(file.getName()+"生成md5码时发生异常:"+ex.getMessage()); + return null; + } finally { + fis.close(); + } + } + + /** + * 独立把byte[]数组转换成十六进制字符串表示形式 + * + * @param byteArray + * 字节数组 + * @return String + */ + public static String byteToHexStringSingle(final byte[] byteArray) { + final StringBuffer md5StrBuff = new StringBuffer(); + for (int i = 0; i < byteArray.length; i++) { + if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) { + md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i])); + } else { + md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i])); + } + } + return md5StrBuff.toString(); + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/ModelDataToJsonUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/ModelDataToJsonUtil.java new file mode 100644 index 0000000..cd07f2f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/ModelDataToJsonUtil.java @@ -0,0 +1,498 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.text.SimpleDateFormat; +import java.util.*; + +public class ModelDataToJsonUtil { + + static Logger logger = MyLogger.getLogger(); + + public static JSONObject getJsonByModelData(String billId,String configId){ + JSONObject result = new JSONObject(); + try{ + logger.info("ModelDataToJsonUtil.getJsonByModelData begin;billId:" + billId + ";configId:" + configId); + + RecordSet rs = new RecordSet(); + //-----------------------根据配置id获取配置信息 + //根节点配置信息 + List> rootJsonConfigInfo = new ArrayList<>(); + //明细配置信息 + List> requestBodyConfigList = new ArrayList<>(); + getConfigInfo(rs,configId,requestBodyConfigList,rootJsonConfigInfo); + + String modeId = ""; + String getModeIdSql = "select mkid from uf_jmsjzjson where id = ?"; + if(rs.executeQuery(getModeIdSql,configId)){ + if(rs.next()){ + modeId = Util.null2String(rs.getString("mkid")); + } + } + String[] base_array = new String[5]; + base_array[0] = ""; + base_array[1] = ""; + base_array[2] = ""; + base_array[3] = CommonSqlUtil.getTableNameByModeId(modeId,rs); + base_array[4] = billId; + + //-----------------------获取主表数据 用于拼装json + Map mainTableData = new HashMap<>(); + String getMainTableDataSql = "select * from " + base_array[3] + " where id = " + base_array[4]; + if(rs.executeQuery(getMainTableDataSql)) { + if (rs.next()) { + mainTableData = DaoUtil.setRsToMap(rs); + } + } + //-----------------------生成json + logger.info("recursionGenerateJson begin;"); + recursionGenerateJson(null,rs,rs,0,result,rootJsonConfigInfo,base_array,mainTableData,requestBodyConfigList,"",""); + }catch(Throwable e){ + logger.error("WorkFlowDataToJsonUtil.getJsonByWorkFlowData exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据转换规则 获取转换后的数据 + */ + public static String convertDataByZhgz(String oldValue,Map configMap){ + //函数返回值 + String result = ""; + try{ + //转换规则 + String zhgz = configMap.get("zhgz"); + //自定义sql + String zdysql = configMap.get("zdysql"); + String requestId = Util.null2String(configMap.get("requestId")); + //不同转换规则处理 + switch(zhgz){ + //不转换 + case "0": + result = oldValue; + break; + //固定值 + case "1": + result = zdysql; + break; + //自定义sql + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId); + Map firstData = DaoUtil.getFirstData(zdysql); + for(String key : firstData.keySet()){ + result = firstData.get(key); + } + break; + //日期格式化 + case "3": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd").parse(oldValue)); + break; + //日期时间格式化 + case "4": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(oldValue)); + break; + //当前日期 + case "5": + result = new SimpleDateFormat(zdysql).format(new Date()); + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.convertDataByZhgz error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + + /** + * 根据configId获取配置信息 + * @param rs 数据库链接 + * @param configId 配置id + * @param requestBodyConfigList 明细配置 + * @param rootJsonConfigInfo 根节点配置 + */ + public static void getConfigInfo(RecordSet rs,String configId,List> requestBodyConfigList,List> rootJsonConfigInfo){ + //获取明细表 请求体字段详细配置信息 + String selectDetailSQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from uf_jmsjzjson_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetailSQL,configId)){ + while(rs.next()){ + //节点序号 + String xmljdxh = Util.null2String(rs.getString("jdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("jdmc")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("jdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + sjtj = sjtj.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + sjtj = CommonUtil.fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("jdxh",xmljdxh); + dtMap.put("jdmc",xmljdmc); + dtMap.put("jdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("zdgz",zdgz); + dtMap.put("detailtable",detailtable); + dtMap.put("fieldName",fieldName.toLowerCase()); + if("".equals(fjdxh)){ + rootJsonConfigInfo.add(dtMap); + } + requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL sql execute error;sql:" + selectDetailSQL); + } + logger.info("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL done;requestBodyConfigList:" + requestBodyConfigList); + } + + /** + * 递归生成json报文 + */ + public static Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence,JSONObject jsonDoc, + List> rootJsonConfigInfo, + String[] baseArray,Map mainTableData, + List> requestBodyConfigList,String currentTableIndex,String currentDetailDataId){ + String getMainDataByConditionSql = "select count(1) as c from " + baseArray[3] + " t1 where "; + String getDetailDataByConditionSql = "select count(1) as c from " + baseArray[3] + " t1 inner join " + baseArray[3] + "_dt" + currentTableIndex + " t2 where t2.id = ? and "; + + if(configMap == null){ + for(Map configInfo:rootJsonConfigInfo){ + + String sjtj = configInfo.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null && !Constant.NODE_TYPE_ARRAY.equals(configInfo.get("jdlx"))){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,"","")); + } + }else{ + jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,"","")); + } + + } + }else{ + switch(configMap.get("jdlx")){ + case Constant.NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + return getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + case Constant.NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + return "true".equals(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + case Constant.NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case Constant.NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + d = Double.parseDouble(f); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case Constant.NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = m.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + return json; + case Constant.NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + String sjtj = m.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + return jsonObj.toString(); + case Constant.NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + JSONArray stringArray = new JSONArray(); + stringArray.addAll(Arrays.asList(stringArrayValue.split(","))); + return stringArray; + case Constant.NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && Constant.CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = son.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = son.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select t2.id as detailid,* from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " t2 inner join " + baseArray[3] + " t1 on t1.id = t2.mainid where t2.mainid = " + baseArray[4] + " and "; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = son.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid"))); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid"))); + } + } + }else{ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid"))); + } + } + } + array.add(o); + } + } + return array; + default: + break; + } + } + return null; + } + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + */ + public static String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs,String[] baseArray,Map mainTableData){ + //函数返回值 + StringBuilder result = new StringBuilder(); + try{ + Map detailDataMap = DaoUtil.setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //字段所属明细表表名 + String detailtable = configMap.get("detailtable"); + //不同转换规则处理 + switch(zhgz){ + case Constant.CHANGE_TYPE_REQUEST_ID: + result = new StringBuilder(baseArray[0]); + break; + case Constant.CHANGE_TYPE_REQUEST_NAME: + result = new StringBuilder(baseArray[1]); + break; + case Constant.CHANGE_TYPE_MD5: + result = new StringBuilder("Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes())); + break; + case Constant.CHANGE_TYPE_SUGGESTION: + result = new StringBuilder(baseArray[2]); + break; + case Constant.CHANGE_TYPE_ROW_NUMBER: + result = new StringBuilder(configMap.get("detailRowNum")); + break; + case Constant.CHANGE_TYPE_FIXED: + result = new StringBuilder(configMap.get("zdysql")); + break; + case Constant.CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = new StringBuilder(mainTableData.get(fieldName)); + }else{ + result = new StringBuilder(detailDataMap.get(fieldName)); + } + break; + case Constant.CHANGE_TYPE_SQL: + String oldValue; + if(!"".equals(viewType) && !"".equals(fieldName)){ + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + } + zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + } + } + break; + case Constant.CHANGE_TYPE_SUM: + if("0".equals(viewType)){ + logger.error("want sum but config main field"); + break; + } + String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4]; + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString("val"))); + } + } + break; + case Constant.CHANGE_TYPE_STRING_ARRAY: + if("0".equals(viewType)){ + logger.error("want array but config main field"); + break; + } + String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4]; + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + }else{ + result.append(",").append(Util.null2String(rs.getString(1))); + } + i = i + 1; + } + } + break; + default: + result = new StringBuilder(); + break; + } + return result.toString(); + }catch(Exception e){ + result = new StringBuilder(); + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result.toString(); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/OauthOneHttpUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/OauthOneHttpUtil.java new file mode 100644 index 0000000..8fd697a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/OauthOneHttpUtil.java @@ -0,0 +1,51 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import oauth.signpost.OAuthConsumer; +import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; +import oauth.signpost.http.HttpParameters; +import oauth.signpost.signature.AuthorizationHeaderSigningStrategy; +import oauth.signpost.signature.HmacSha1MessageSigner; +import oauth.signpost.signature.HmacSha256MessageSigner; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.log4j.Logger; + +/** + * OAuth1.0接口调用工具类 + * jar包 + * signpost-commonshttp4-1.2.jar + * signpost-core-2.1.1.jar + */ +public class OauthOneHttpUtil { + + Logger logger = MyLogger.getLogger(); + + public String consumerKey = ""; + public String consumerSecret = ""; + public String accessToken = ""; + public String accessTokenSecret = ""; + public String realmID = ""; + public String encryption = ""; + + public void authorize(HttpRequestBase httpRequest){ + try { + OAuthConsumer oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); + if("HMAC-SHA256".equalsIgnoreCase(encryption)){ + oAuthConsumer.setMessageSigner(new HmacSha256MessageSigner()); + }else if("HMAC-SHA1".equalsIgnoreCase(encryption)){ + oAuthConsumer.setMessageSigner(new HmacSha1MessageSigner()); + } + if(realmID != null && !"".equals(realmID)){ + HttpParameters parameters = new HttpParameters(); + parameters.put("realm", realmID); + oAuthConsumer.setAdditionalParameters(parameters); + } + oAuthConsumer.setTokenWithSecret(accessToken, accessTokenSecret); + oAuthConsumer.setSigningStrategy(new AuthorizationHeaderSigningStrategy()); + oAuthConsumer.sign(httpRequest); + }catch(Throwable e) { + logger.info("OauthOneHttpUtil.authorize error;message:" + e.getMessage() + ";e:" + e); + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwAesUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwAesUtil.java new file mode 100644 index 0000000..766f9dc --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwAesUtil.java @@ -0,0 +1,66 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.file.AESCoder; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +public class TjwAesUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String aesEncrypt(String param,String key){ + String result = ""; + try{ + result = AESCoder.encrypt(param,key); + }catch (Exception e){ + logger.error("AesUtil.aesEncrypt error;message" + e.getMessage() + ";e:" + e); + } + logger.info("aesEncrypt result:" + result); + return result; + } + + // 加密 + public static String Encrypt(String sKey, String sSrc) throws Exception { + byte[] raw = sKey.getBytes("utf-8"); + SecretKeySpec sks = new SecretKeySpec(raw, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式" + cipher.init(Cipher.ENCRYPT_MODE, sks); + byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8")); + return bytesToHexString(encrypted); + } + + // 解密 + public static String Decrypt(String sKey, String sSrc) throws Exception { + byte[] raw = sKey.getBytes("utf-8"); + SecretKeySpec sks = new SecretKeySpec(raw, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, sks); + byte[] encrypted1 = hexStringToBytes(sSrc); //new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密 + byte[] original = cipher.doFinal(encrypted1); + String originalString = new String(original,"utf-8"); + return originalString; + } + + //字节数组转16进制字符串 + public static String bytesToHexString(byte[] b){ + StringBuffer result = new StringBuffer(); + for(int i = 0;i < b.length;i++){ + result.append(String.format("%02X",b[i])); + } + return result.toString(); + } + + //16进制字符串转字节数组 + public static byte[] hexStringToBytes(String src){ + int l = src.length()/2; + byte[] ret = new byte[l]; + for(int i = 0;i> srcFiles , OutputStream out) { + ZipOutputStream zos = null; + try{ + zos = new ZipOutputStream(out); + for (Map imageFileInfo : srcFiles) { + String imageFileId = imageFileInfo.get("imageFileId"); + String imageFileName = imageFileInfo.get("imageFileName"); + byte[] buf = new byte[2 * 1024]; + zos.putNextEntry(new ZipEntry(imageFileName)); + int len; + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + while ((len = in.read(buf)) != -1){ + zos.write(buf, 0, len); + } + zos.closeEntry(); + in.close(); + } + }catch (Throwable e){ + logger.error("TjwDocumentUtil.toZip error;message:" + e.getMessage() + ";e:" + e); + }finally{ + if(zos != null){ + try { + zos.close(); + } catch (IOException e) { + logger.error("TjwDocumentUtil.toZip zos close error;message:" + e.getMessage() + ";e:" + e); + } + } + } + } + + public static String getBase64StringByImageFileId(String imageFileId){ + String base64 = ""; + InputStream is = null; + try { + ImageFileManager imageFileManager = new ImageFileManager(); + is = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + String getFileSizeSql = "select filesize from imagefile where imagefileid = ?"; + String filesize = DaoUtil.getFirstData(new RecordSet(), getFileSizeSql, imageFileId).get("filesize"); + byte[] bytes = new byte[Integer.parseInt(filesize)]; + is.read(bytes); + BASE64Encoder encoder = new BASE64Encoder(); + base64 = encoder.encode(bytes); + } catch (Exception e) { + logger.error("TjwDocumentUtil.getBase64StringByImageFileId exception;imageFileId:" + imageFileId + ";message:" + e.getMessage() + ";e:" + e); + } finally { + if (is != null) { + try { + is.close(); + } catch (Exception e) { + logger.error("TjwDocumentUtil.getBase64StringByImageFileId io close exception;imageFileId:" + imageFileId + ";message:" + e.getMessage() + ";e:" + e); + } + } + } + return base64; + } + + /** + * 根据docId复制文档;返回新docId + * @param olddocid 被复制的docId + * @param userid + * @param docsubject 新的文件名称 + * @param seccategory 目录id + * @return + */ + public static int copyDocToNewDoc(int olddocid, int userid,String docsubject,int seccategory){ + int newdocid = -1; + try { + logger.info("TjwDocumentUtil.copyDocToNewDoc begin;olddocid:" + olddocid + ";userid:" + userid + ";docsubject:" + docsubject + ";seccategory:" + seccategory); + //复制文档 + DocComInfo dc = new DocComInfo(); + DocViewer dv = new DocViewer(); + DocManager docManager = new DocManager(); + docManager.setId(olddocid); + docManager.setUserid(userid); + docManager.setUsertype("0"); + docManager.setDocsubject(docsubject); + docManager.setClientAddress("127.0.0.1"); + docManager.setSeccategory(seccategory); + docManager.copyDoc(); + newdocid = docManager.getId(); + // 文档赋权操作 + DocManager docNewManager = new DocManager(); + docNewManager.setIsreply("0"); + docNewManager.setId(newdocid); + docNewManager.setSeccategory(seccategory); + docNewManager.setUserid(userid); + docNewManager.setUsertype("1"); + docManager.AddShareInfo(); + dc.addDocInfoCache("" + newdocid); + dv.setDocShareByDoc("" + newdocid); + //TODO 据我观察 上面虽然传了docsubject,但代码并未更新文件名称,因此在下面更新文件名称 + RecordSet rs = new RecordSet(); + String oldname = ""; + String docfiletype = ""; + String getExtendSql = "select imagefilename,docfiletype from DocImageFile where docid = ?"; + if(rs.executeQuery(getExtendSql,olddocid)){ + if(rs.next()){ + oldname = Util.null2String(rs.getString("imagefilename")); + docfiletype = Util.null2String(rs.getString("docfiletype")); + } + } + logger.info("oldname:" + oldname + ";docfiletype:" + docfiletype); + String extend = ""; + switch (docfiletype){ + case "7": + extend = ".docx"; + break; + case "3": + extend = ".doc"; + break; + case "4": + extend = ".xls"; + break; + case "5": + extend = ".ppt"; + break; + case "6": + extend = ".wps"; + break; + case "8": + extend = ".xlsx"; + break; + case "9": + extend = ".pptx"; + break; + default: + break; + } + String newName = docsubject + extend; + String updateDocImageFileNameSql = "update DocImageFile set imagefilename = ? where docid = ?"; + if(!rs.executeUpdate(updateDocImageFileNameSql,newName,newdocid)){ + logger.error("updateDocImageFileNameSql error"); + } + String updateImagefileName2Sql = "update imagefile set imagefilename = ? where imagefileid in (select imagefileid from DocImageFile where docid = ?)"; + if(!rs.executeUpdate(updateImagefileName2Sql,newName,newdocid)){ + logger.error("updateImagefileName2Sql error"); + } + String updateDocdetailSql = "update docdetail set docsubject = ?,keyword = ? where id = ?"; + if(!rs.executeUpdate(updateDocdetailSql,docsubject,docsubject,newdocid)){ + logger.error("updateDocdetailSql error"); + } + } catch (Exception e) { + logger.error("TjwDocumentUtil.copyDocToNewDoc exception;message:" + e.getMessage() + ";e:" + e); + } + return newdocid; + } + + public static int addDocImageInfo(int docId,String fileName, int imageFileId) { + try{ + DocImageManager imgManger = new DocImageManager(); + imgManger.resetParameter(); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFileId); + imgManger.setImagefilename(fileName); + imgManger.setIsextfile("1"); + String ext = fileName.substring(fileName.lastIndexOf(".") + 1); + if ("doc".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("3"); + } else if ("xls".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("4"); + } else if ("ppt".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("5"); + } else if ("wps".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("6"); + } else if ("docx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("7"); + } else if ("xlsx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("8"); + } else if ("pptx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("9"); + } else { + imgManger.setDocfiletype("2"); + } + imgManger.AddDocImageInfo(); + return docId; + }catch(Exception e){ + logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";imageFileId" + imageFileId + ";docId:" + docId + ";message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + /** + * 根据imageFileId生成docId + * @param fileName 文件名称 + * @param seccategory 文件目录 + * @param imageFileId 物理文件ID + * @param userId 用户ID + * @return docId + */ + public static int createDocByImageFileId(String docSubject, String fileName, int seccategory, int imageFileId, Integer userId) { + try{ + DocInfo docInfo = new DocInfo(); + docInfo.setImagefileId(imageFileId); + docInfo.setSeccategory(seccategory); + docInfo.setDocSubject(docSubject); + docInfo.setDoccontent(""); + DocServiceImpl docService = new DocServiceImpl(); + int docId = docService.createDocByUser(docInfo, new User(userId)); + DocImageManager imgManger = new DocImageManager(); + imgManger.resetParameter(); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFileId); + imgManger.setImagefilename(fileName); + imgManger.setIsextfile("1"); + String ext = fileName.substring(fileName.lastIndexOf(".") + 1); + if ("doc".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("3"); + } else if ("xls".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("4"); + } else if ("ppt".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("5"); + } else if ("wps".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("6"); + } else if ("docx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("7"); + } else if ("xlsx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("8"); + } else if ("pptx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("9"); + } else { + imgManger.setDocfiletype("2"); + } + imgManger.AddDocImageInfo(); + return docId; + }catch(Exception e){ + logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";seccategory:" + seccategory + ";imageFileId" + imageFileId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + /** + * 根据imageFileId生成docId + * @param fileName 文件名称 + * @param seccategory 文件目录 + * @param imageFileId 物理文件ID + * @param userId 用户ID + * @return docId + */ + public static int createDocByImageFileId(String fileName, int seccategory, int imageFileId, Integer userId) { + try{ + DocInfo docInfo = new DocInfo(); + docInfo.setImagefileId(imageFileId); + docInfo.setSeccategory(seccategory); + docInfo.setDocSubject(fileName); + docInfo.setDoccontent(""); + DocServiceImpl docService = new DocServiceImpl(); + int docId = docService.createDocByUser(docInfo, new User(userId)); + DocImageManager imgManger = new DocImageManager(); + imgManger.resetParameter(); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFileId); + imgManger.setImagefilename(fileName); + imgManger.setIsextfile("1"); + String ext = fileName.substring(fileName.lastIndexOf(".") + 1); + if ("doc".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("3"); + } else if ("xls".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("4"); + } else if ("ppt".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("5"); + } else if ("wps".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("6"); + } else if ("docx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("7"); + } else if ("xlsx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("8"); + } else if ("pptx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("9"); + } else { + imgManger.setDocfiletype("2"); + } + imgManger.AddDocImageInfo(); + return docId; + }catch(Exception e){ + logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";seccategory:" + seccategory + ";imageFileId" + imageFileId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + /** + * 创建物理文件 + * + * @param content 文件流 + * @param fileName 文件名 + * @return 文件id + */ + public static int createFileByInputSteam(InputStream content, String fileName) { + try{ + /*byte[] bytes = IOUtils.toBytes(content); + logger.info("bytes.size:" + bytes.length);*/ + ImageFileManager imageFileManager = new ImageFileManager(); + int imgFileId = -1; + try { + ImageFileManager.class.getMethod("saveImageFileByInputStream", InputStream.class, String.class); + imgFileId = imageFileManager.saveImageFileByInputStream(content, fileName); + }catch (NoSuchMethodException e) { + logger.error("createFileByInputSteam.NoSuchMethodException"); + imageFileManager.setImagFileName(fileName); + try { + imageFileManager.setData(IOUtils.toBytes(content)); + } catch (Exception ex) { + logger.error("CommonUtil.createFileByInputSteam toBytes exception;fileName:" + fileName + ";message:" + e.getMessage() + ";e:" + e); + throw new Exception("创建文件失败,文件流转换失败", e); + } + imgFileId = imageFileManager.saveImageFile(); + } + return imgFileId; + }catch (Exception e){ + logger.error("CommonUtil.createFileByInputSteam exception;fileName:" + fileName + ";message:" + e.getMessage() + ";e:" + e); + return -1; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwFpUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwFpUtil.java new file mode 100644 index 0000000..b7e4c91 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwFpUtil.java @@ -0,0 +1,249 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.fna.invoice.utils.InvoiceCloudUtil; +import weaver.general.Util; +import weaver.hrm.User; + +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +public class TjwFpUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String getTimestamp(String date){ + String timestamp = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date d = sdf.parse(date); + timestamp = Util.null2String(d.getTime()/1000); + }catch (Throwable e){ + logger.error("TjwFpUtil.getTimestamp error;message:" + e.getMessage() + ";e:" + e); + } + return timestamp; + } + + /** + * @param cloudIdParam 发票的cloudid + * @param user + * @param sreim 0-取消 1-报销 2-核销 + * @param je 金额 + * @param requestId + * @param requestmark + * @param requestName + */ + public static void updateFpStatusInCloudCommon(User user,String cloudIdParam,String sreim,String je,String requestId,String requestmark,String requestName){ + try{ + RecordSet rs = new RecordSet(); + + String getTimeSql = "select CREATEDATE,CREATETIME from workflow_requestbase where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getTimeSql, requestId); + String CREATEDATE = firstData1.get("createdate"); + String CREATETIME = firstData1.get("createtime"); + + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + String getdjbhSql = "select djbh from " + tableName + " where requestid = ?"; + Map firstData2 = DaoUtil.getFirstData(rs, getdjbhSql, requestId); + requestmark = Util.null2String(firstData2.get("djbh")); + + + String getDataSql = "select * from fnainvoiceledger where cloudid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam); + String userId = firstData.get("userid_new"); + //其中key为userid_new, value为的List + Map> mapCloud = new HashMap<>(); + List cloudIds = new ArrayList<>(); + cloudIds.add(cloudIdParam); + mapCloud.put(userId,cloudIds); + //发票云报销修改发票云数据 + for(Map.Entry> entry : mapCloud.entrySet()){ + String userid_new = entry.getKey(); + int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0); + JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true); + JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud"); + + String cid = Util.null2String(cloudInfo.getString("cid")); + String userName = Util.null2String(cloudInfo.getString("userName")); + String password = Util.null2String(cloudInfo.getString("password")); + String aesKey = Util.null2String(cloudInfo.getString("aesKey")); + String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl")); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("cid",cid); + bodyJson.put("userId",user.getUID()); + //2表示修改状态 3表示校验 + bodyJson.put("flag","2"); + JSONArray fnaInvoiceReimburseInfoJa = new JSONArray(); + + JSONObject fnaInvoiceReimburseInfoJo = new JSONObject(); + fnaInvoiceReimburseInfoJo.put("dataid", requestId); + fnaInvoiceReimburseInfoJo.put("number", requestmark); + DecimalFormat df = new DecimalFormat("#####################0.00"); + fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00))); + fnaInvoiceReimburseInfoJo.put("uid", user.getUID()); + //fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2))); + fnaInvoiceReimburseInfoJo.put("date", getTimestamp(CREATEDATE+" "+CREATETIME)); + fnaInvoiceReimburseInfoJo.put("name", requestName); + fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam); + fnaInvoiceReimburseInfoJo.put("cid", cid); + fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + + //1表示报销中 2表示已报销 + bodyJson.put("sreim",sreim); + + JSONArray reimburseInfoJa = new JSONArray(); + reimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + bodyJson.put("infos", reimburseInfoJa); + JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据"); + logger.info("reimburseJson:" + reimburseJson); + } + }catch (Throwable e){ + logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e); + } + + } + + /** + * @param cloudIdParam 发票的cloudid + * @param user 当前操作用户 + */ + public static void updateFpStatusInCloud3(User user,String cloudIdParam,String flag,String je,String requestId,String requestmark,String requestName){ + try{ + RecordSet rs = new RecordSet(); + String getDataSql = "select * from fnainvoiceledger where cloudid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam); + String userId = firstData.get("userid_new"); + DecimalFormat df = new DecimalFormat("#####################0.00"); + //其中key为userid_new, value为的List + Map> mapCloud = new HashMap<>(); + List cloudIds = new ArrayList<>(); + cloudIds.add(cloudIdParam); + mapCloud.put(userId,cloudIds); + //发票云报销修改发票云数据 + RecordSet rs5= new RecordSet(); + for(Map.Entry> entry : mapCloud.entrySet()){ + String userid_new = entry.getKey(); + int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0); + JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true); + JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud"); + boolean existEffectCloud = cloudInfo.getBoolean("existEffectCloud"); + logger.info("existEffectCloud:" + existEffectCloud); + + String cid = Util.null2String(cloudInfo.getString("cid")); + String userName = Util.null2String(cloudInfo.getString("userName")); + String password = Util.null2String(cloudInfo.getString("password")); + String aesKey = Util.null2String(cloudInfo.getString("aesKey")); + String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl")); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("cid",cid); + bodyJson.put("userId",user.getUID()); + bodyJson.put("flag",flag); + JSONArray fnaInvoiceReimburseInfoJa = new JSONArray(); + + logger.info("requestid:" + requestId); + logger.info("requestmark:" + requestmark); + logger.info("je:" + je); + + JSONObject fnaInvoiceReimburseInfoJo = new JSONObject(); + fnaInvoiceReimburseInfoJo.put("dataid", requestId);//requestid + fnaInvoiceReimburseInfoJo.put("number", requestmark);//requestmark + fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00))); + fnaInvoiceReimburseInfoJo.put("uid", user.getUID()); + fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2))); + fnaInvoiceReimburseInfoJo.put("name", requestName); + fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam); + fnaInvoiceReimburseInfoJo.put("cid", cid); + fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + + bodyJson.put("sreim","2"); + + JSONArray reimburseInfoJa = new JSONArray(); + reimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + bodyJson.put("infos", reimburseInfoJa); + JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据"); + logger.info("reimburseJson:" + reimburseJson); + } + }catch (Throwable e){ + logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e); + } + + } + + /** + * @param cloudIdParam 发票的cloudid + * @param user 当前操作用户 + */ + public static void updateFpStatusInCloud(User user,String cloudIdParam,String flag,String je,String requestId,String requestmark,String requestName){ + try{ + RecordSet rs = new RecordSet(); + String getDataSql = "select * from fnainvoiceledger where cloudid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam); + String userId = firstData.get("userid_new"); + DecimalFormat df = new DecimalFormat("#####################0.00"); + //其中key为userid_new, value为的List + Map> mapCloud = new HashMap<>(); + List cloudIds = new ArrayList<>(); + cloudIds.add(cloudIdParam); + mapCloud.put(userId,cloudIds); + //发票云报销修改发票云数据 + RecordSet rs5= new RecordSet(); + for(Map.Entry> entry : mapCloud.entrySet()){ + String userid_new = entry.getKey(); + int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0); + JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true); + JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud"); + boolean existEffectCloud = cloudInfo.getBoolean("existEffectCloud"); + logger.info("existEffectCloud:" + existEffectCloud); + + String cid = Util.null2String(cloudInfo.getString("cid")); + String userName = Util.null2String(cloudInfo.getString("userName")); + String password = Util.null2String(cloudInfo.getString("password")); + String aesKey = Util.null2String(cloudInfo.getString("aesKey")); + String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl")); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("cid",cid); + bodyJson.put("userId",user.getUID()); + bodyJson.put("flag",flag); + JSONArray fnaInvoiceReimburseInfoJa = new JSONArray(); + + logger.info("requestid:" + requestId); + logger.info("requestmark:" + requestmark); + logger.info("je:" + je); + + JSONObject fnaInvoiceReimburseInfoJo = new JSONObject(); + fnaInvoiceReimburseInfoJo.put("dataid", requestId);//requestid + fnaInvoiceReimburseInfoJo.put("number", requestmark);//requestmark + fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00))); + fnaInvoiceReimburseInfoJo.put("uid", user.getUID()); + fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2))); + fnaInvoiceReimburseInfoJo.put("name", requestName); + fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam); + fnaInvoiceReimburseInfoJo.put("cid", cid); + fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + + bodyJson.put("sreim","1"); + + JSONArray reimburseInfoJa = new JSONArray(); + reimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + bodyJson.put("infos", reimburseInfoJa); + JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据"); + logger.info("reimburseJson:" + reimburseJson); + } + }catch (Throwable e){ + logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e); + } + + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpServletRequest.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpServletRequest.java new file mode 100644 index 0000000..8e84ccb --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpServletRequest.java @@ -0,0 +1,272 @@ +package com.api.taojw.common; + +import javax.servlet.*; +import javax.servlet.http.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Map; + +public class TjwHttpServletRequest implements HttpServletRequest { + + @Override + public String getMethod() { + return null; + } + + @Override + public String getRequestURI() { + return null; + } + + @Override + public StringBuffer getRequestURL() { + return null; + } + + @Override + public String getContextPath() { + return null; + } + + @Override + public String getServletPath() { + return null; + } + + @Override + public String getPathInfo() { + return null; + } + + @Override + public String getPathTranslated() { + return null; + } + + @Override + public String getQueryString() { + return null; + } + + @Override + public String getHeader(String s) { + return null; + } + + @Override + public Enumeration getHeaders(String s) { + return null; + } + + @Override + public Enumeration getHeaderNames() { + return null; + } + + @Override + public int getIntHeader(String s) { + return 0; + } + + @Override + public long getDateHeader(String s) { + return 0; + } + + @Override + public Cookie[] getCookies() { + return new Cookie[0]; + } + + @Override + public HttpSession getSession(boolean b) { + return null; + } + + @Override + public HttpSession getSession() { + return null; + } + + @Override + public String getRequestedSessionId() { + return null; + } + + @Override + public boolean isRequestedSessionIdValid() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromCookie() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromURL() { + return false; + } + + @Override + public String getAuthType() { + return null; + } + + @Override + public String getRemoteUser() { + return null; + } + + @Override + public boolean isUserInRole(String s) { + return false; + } + + @Override + public Principal getUserPrincipal() { + return null; + } + + /** + * @deprecated + */ + @Override + public boolean isRequestedSessionIdFromUrl() { + return false; + } + + @Override + public String getProtocol() { + return null; + } + + @Override + public String getScheme() { + return null; + } + + @Override + public String getServerName() { + return null; + } + + @Override + public int getServerPort() { + return 0; + } + + @Override + public String getRemoteAddr() { + return null; + } + + @Override + public String getRemoteHost() { + return null; + } + + @Override + public void setCharacterEncoding(String s) throws UnsupportedEncodingException { + + } + + @Override + public String getParameter(String s) { + return null; + } + + @Override + public String[] getParameterValues(String s) { + return new String[0]; + } + + @Override + public Enumeration getParameterNames() { + return null; + } + + @Override + public Map getParameterMap() { + return null; + } + + @Override + public ServletInputStream getInputStream() throws IOException { + return null; + } + + @Override + public BufferedReader getReader() throws IOException, IllegalStateException { + return null; + } + + @Override + public String getCharacterEncoding() { + return null; + } + + @Override + public int getContentLength() { + return 0; + } + + @Override + public String getContentType() { + return null; + } + + @Override + public Locale getLocale() { + return null; + } + + @Override + public Enumeration getLocales() { + return null; + } + + @Override + public boolean isSecure() { + return false; + } + + @Override + public Object getAttribute(String s) { + return null; + } + + @Override + public void setAttribute(String s, Object o) { + + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public void removeAttribute(String s) { + + } + + @Override + public RequestDispatcher getRequestDispatcher(String s) { + return null; + } + + /** + * @param s + * @deprecated + */ + @Override + public String getRealPath(String s) { + return null; + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpSession.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpSession.java new file mode 100644 index 0000000..7f79b27 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpSession.java @@ -0,0 +1,119 @@ +package com.api.taojw.common; + +import javax.servlet.*; +import javax.servlet.http.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Map; + +public class TjwHttpSession implements HttpSession { + + @Override + public String getId() { + return null; + } + + @Override + public boolean isNew() { + return false; + } + + @Override + public long getCreationTime() { + return 0; + } + + @Override + public long getLastAccessedTime() { + return 0; + } + + @Override + public void setMaxInactiveInterval(int i) { + + } + + @Override + public int getMaxInactiveInterval() { + return 0; + } + + @Override + public Object getAttribute(String s) { + return null; + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public void setAttribute(String s, Object o) { + + } + + @Override + public void removeAttribute(String s) { + + } + + @Override + public void invalidate() { + + } + + /** + * @deprecated + */ + @Override + public HttpSessionContext getSessionContext() { + return null; + } + + @Override + public ServletContext getServletContext() { + return null; + } + + /** + * @param s + * @deprecated + */ + @Override + public Object getValue(String s) { + return null; + } + + /** + * @deprecated + */ + @Override + public String[] getValueNames() { + return new String[0]; + } + + /** + * @param s + * @param o + * @deprecated + */ + @Override + public void putValue(String s, Object o) { + + } + + /** + * @param s + * @deprecated + */ + @Override + public void removeValue(String s) { + + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpUtil.java new file mode 100644 index 0000000..9da38c8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwHttpUtil.java @@ -0,0 +1,679 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import org.apache.commons.io.IOUtils; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.*; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.BufferedHttpEntity; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.StringBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; + +import javax.net.ssl.*; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.cert.X509Certificate; +import java.util.*; + +public class TjwHttpUtil { + + static Logger logger = MyLogger.getLogger(); + + + /** + * 附件上传 + */ + public static JSONObject uploadFileUtil(String url, String imageFileIds, Map headers,Map textParams,String fileParamName){ + JSONObject result = new JSONObject(); + try{ + logger.info("TjwHttpUtil.uploadFileUtil begin;url:" + url + ";imageFileIds:" + imageFileIds); + //根据docIds获取文件信息 + String[] imageFileIdsArray = imageFileIds.split(","); + if(imageFileIdsArray == null || imageFileIdsArray.length == 0){ + return result; + } + List> fileInfos = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String getFileInfoSql = "select t2.imagefilename,t2.imagefileid from docimagefile t1 inner join imagefile t2 on t2.imagefileid = t1.imagefileid where t2.imagefileid = ?"; + for(String imageFileId:imageFileIdsArray){ + if(rs.executeQuery(getFileInfoSql,imageFileId)){ + while(rs.next()){ + Map file = new HashMap<>(); + file.put("imagefileid", Util.null2String(rs.getString("imagefileid"))); + file.put("imagefilename", Util.null2String(rs.getString("imagefilename"))); + fileInfos.add(file); + } + } + } + CloseableHttpClient httpClient = createSSLClientDefault(url); + HttpPost httpPost = new HttpPost(url); + MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create(); + multipartEntityBuilder.setCharset(StandardCharsets.UTF_8); + multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + ImageFileManager imageFileManager = new ImageFileManager(); + for(Map file:fileInfos){ + String fileName = file.get("imagefilename"); + fileName = fileName.replaceAll("&","&"); + fileName = fileName.replaceAll(">",">"); + fileName = fileName.replaceAll("<","<"); + fileName = fileName.replaceAll("'","'"); + fileName = fileName.replaceAll(""","\""); + InputStream imagefileid = imageFileManager.getInputStreamById(Integer.parseInt(file.get("imagefileid"))); + multipartEntityBuilder.addBinaryBody(fileParamName,imagefileid, ContentType.MULTIPART_FORM_DATA,fileName); + } + + ContentType contentType = ContentType.create("text/plain", StandardCharsets.UTF_8); + for(String key : textParams.keySet()){ + StringBody stringBody = new StringBody(String.valueOf(textParams.get(key)), contentType); + multipartEntityBuilder.addPart(key, stringBody); + } + + HttpEntity httpEntity = multipartEntityBuilder.build(); + httpPost.setEntity(httpEntity); + + //请求头设置 + if(headers != null && headers.size() > 0){ + for(String key:headers.keySet()){ + if(!"Content-Type".equals(key)){ + httpPost.setHeader(key,headers.get(key)); + } + } + } + + logger.info("FilePostUtil.uploadFileUtil.httpClient.execute begin;imageFileIds:" + imageFileIds + ";url:" + url); + + CloseableHttpResponse httpResponse = httpClient.execute(httpPost); + HttpEntity responseEntity = httpResponse.getEntity(); + int statusCode= httpResponse.getStatusLine().getStatusCode(); + BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent())); + StringBuffer buffer = new StringBuffer(); + String str = ""; + while((str = reader.readLine()) != null) { + buffer.append(str); + } + logger.info("FilePostUtil.uploadFileUtil.httpClient.execute done;statusCode:" + statusCode + ";message:" + buffer); + result = JSONObject.parseObject(buffer.toString()); + httpClient.close(); + if(httpResponse!=null){ + httpResponse.close(); + } + }catch(Throwable e){ + logger.error("FilePostUtil.uploadFileUtil exception;url:" + url + ";imageFileIds:" + imageFileIds); + } + return result; + } + + public static void addLogInMode(String url,int code,String requestParam,String responseData){ + try{ + RecordSet rs = new RecordSet(); + JSONObject loggerJson = new JSONObject(); + loggerJson.put("qqdz",url); + loggerJson.put("qqxx",requestParam); + loggerJson.put("xyxx",responseData); + loggerJson.put("xym",code); + TjwModelUtil.addModelData(rs,"uf_tjwhttplog",loggerJson); + }catch (Throwable e){ + logger.error("TjwHttpUtil.addLogInMode error;message:" + e.getMessage() + ";e:" + e); + } + } + + public static void addLogInModeWithCusLog(String url,int code,String requestParam,String responseData,Map cusLogInfo){ + try{ + if(responseData.length() > 1000){ + responseData = "报文长度过长,请在日志文件中查看!"; + } + RecordSet rs = new RecordSet(); + JSONObject loggerJson = new JSONObject(); + loggerJson.put("qqdz",url); + loggerJson.put("qqxx",requestParam); + loggerJson.put("xyxx",responseData); + loggerJson.put("xym",code); + if(cusLogInfo != null && cusLogInfo.size() > 0){ + for(String key : cusLogInfo.keySet()){ + loggerJson.put(key,cusLogInfo.get(cusLogInfo)); + } + } + TjwModelUtil.addModelData(rs,"uf_tjwhttplog",loggerJson); + }catch (Throwable e){ + logger.error("TjwHttpUtil.addLogInMode error;message:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 下载文件 + * @param url + * @param headMap 请求头 + * @param fileName 文件名称 + */ + public static InputStream httpGetDownloadFile(String url,Map headMap,String fileName) { + CloseableHttpClient httpclient = createSSLClientDefault(url); + try { + HttpGet httpGet = new HttpGet(url); + if (headMap != null && headMap.size() > 0) { + Set keySet = headMap.keySet(); + for (String key : keySet) { + httpGet.addHeader(key, headMap.get(key)); + } + } + CloseableHttpResponse response = httpclient.execute(httpGet); + try { + int statusCode = response.getStatusLine().getStatusCode(); + logger.info("url:" + url + ";download file end;code:" + statusCode); + HttpEntity httpEntity = response.getEntity(); + InputStream is = httpEntity.getContent(); + // 根据InputStream 下载文件 + ByteArrayOutputStream output = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int r = 0; + while ((r = is.read(buffer)) > 0) { + output.write(buffer, 0, r); + } + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(output.toByteArray()); + output.flush(); + output.close(); + EntityUtils.consume(httpEntity); + logger.info("url:" + url + ";download file success"); + return byteArrayInputStream; + } finally { + response.close(); + } + } catch (Throwable e) { + logger.error("httpGetDownloadFile exception;message:" + e.getMessage() + ";e:" + e); + } finally { + try { + httpclient.close(); + } catch (Throwable e) { + logger.error("httpGetDownloadFile httpclient close exception;message:" + e.getMessage() + ";e:" + e); + } + } + return null; + } + + public static void oauthOneSignHeader(HttpRequestBase httpRequest,Map oauthConfigMap){ + OauthOneHttpUtil oAuthUtil = new OauthOneHttpUtil(); + oAuthUtil.consumerKey = oauthConfigMap.get("consumerKey"); + oAuthUtil.consumerSecret = oauthConfigMap.get("consumerSecret"); + oAuthUtil.accessToken = oauthConfigMap.get("accessToken"); + oAuthUtil.accessTokenSecret = oauthConfigMap.get("accessTokenSecret"); + oAuthUtil.realmID = oauthConfigMap.get("realmID"); + oAuthUtil.encryption = oauthConfigMap.get("encryption"); + oAuthUtil.authorize(httpRequest); + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpOAuthRequest(String url, String param, String method, ContentType contentType,Map headers,Map oauthConfigMap){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + oauthOneSignHeader(post,oauthConfigMap); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + oauthOneSignHeader(get,oauthConfigMap); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Throwable e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequest(String url, String param, String method, ContentType contentType,Map headers,int imageFileId){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + + if(imageFileId > 0){ + ImageFileManager ifm = new ImageFileManager(); + InputStream is = ifm.getInputStreamById(imageFileId); + ByteArrayEntity byteArrayEntity = new ByteArrayEntity(IOUtils.toByteArray(is)); + post.setEntity(byteArrayEntity); + } + + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + + if(imageFileId > 0){ + ImageFileManager ifm = new ImageFileManager(); + InputStream is = ifm.getInputStreamById(imageFileId); + ByteArrayEntity byteArrayEntity = new ByteArrayEntity(IOUtils.toByteArray(is)); + put.setEntity(byteArrayEntity); + } + + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequestWithCusLog(String url, String param, String method, ContentType contentType,Map headers,Map cusLogInfo){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + JSONObject responseHeaders = new JSONObject(); + Header[] allHeaders = response.getAllHeaders(); + for(Header header:allHeaders){ + responseHeaders.put(header.getName(),header.getValue()); + } + result.put("responseHeaders",responseHeaders.toJSONString()); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("getWithEntity".equalsIgnoreCase(method)){ + HttpGetWithEntity get=new HttpGetWithEntity(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + HttpEntity httpEntity = new StringEntity(param, contentType); + get.setEntity(httpEntity); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + Header[] allHeaders = response.getAllHeaders(); + Header[] clone = allHeaders.clone(); + result.put("responseHeaders",clone); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequest(String url, String param, String method, ContentType contentType,Map headers){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + JSONObject responseHeaders = new JSONObject(); + Header[] allHeaders = response.getAllHeaders(); + for(Header header:allHeaders){ + responseHeaders.put(header.getName(),header.getValue()); + } + result.put("responseHeaders",responseHeaders.toJSONString()); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("getWithEntity".equalsIgnoreCase(method)){ + HttpGetWithEntity get=new HttpGetWithEntity(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + HttpEntity httpEntity = new StringEntity(param, contentType); + get.setEntity(httpEntity); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + Header[] allHeaders = response.getAllHeaders(); + Header[] clone = allHeaders.clone(); + result.put("responseHeaders",clone); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequest(String url, String param, String method, ContentType contentType){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + + /** + * 返回CloseableHttpClient 如果接口为https协议 信任所有证书 + * @return + * @throws MalformedURLException + */ + public static CloseableHttpClient createSSLClientDefault(String urlString){ + URL url = null; + try { + url = new URL(urlString); + } catch (Exception e) { + logger.error("url error;urlString:" + urlString); + } + String protocol = url.getProtocol(); + if("https".equals(protocol)){ + try { + //使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书 + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { + return true; + } + }).build(); + //NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何 + //有效的SSL会话并匹配到目标主机。 + HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return build; + } catch (Exception e) { + logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e); + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + }else{ + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + } + + private static final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + + private static final HostnameVerifier NOT_VERYFY = new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwJsonToWorkflowByConfigUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwJsonToWorkflowByConfigUtil.java new file mode 100644 index 0000000..5580952 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwJsonToWorkflowByConfigUtil.java @@ -0,0 +1,159 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.workflow.webservices.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TjwJsonToWorkflowByConfigUtil { + + static Logger logger = MyLogger.getLogger(); + + + public static String getValueByConfig(Map configMap, JSONObject jsonData, RecordSet rs){ + String result = ""; + try{ + String path = configMap.get("jsonbwzdlj"); + String zhgz = configMap.get("zhgz"); + String zdysql = configMap.get("zdysql"); + String oldValue = CommonUtil.getJsonValueByPath(jsonData,path); + switch(zhgz){ + case "0": + result = oldValue; + break; + case "1": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + }else{ + logger.error("zdysql execute but find nothing;sql:" + zdysql); + } + }else{ + logger.error("zdysql execute error;sql:" + zdysql); + } + break; + case "2": + result = zdysql; + break; + default: + break; + } + }catch(Exception e){ + logger.error("TjwJsonToWorkflowByConfigUtil.getValueByConfig exception;configMap:" + configMap + ";jsonData:" + jsonData + ";message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public static void dealWorkflowRequestInfoByConfigId(String configId, WorkflowRequestInfo info,JSONObject jsonData){ + try{ + logger.info("dealWorkflowRequestInfoByConfigId begin;configId:" + configId + ";jsonData:" + jsonData.toJSONString()); + RecordSet rs = new RecordSet(); + String getConfigDataSql = + "select " + + "t1.lclx," + + "t2.bdzd," + + "t2.zdgz," + + "t2.jsonbwzdlj," + + "t2.zhgz," + + "t2.zdysql," + + "wb.fieldName," + + "wb.viewType," + + "wb.detailtable " + + "from " + + "uf_jsonzlcbdsj t1 " + + "inner join uf_jsonzlcbdsj_dt1 t2 on t2.mainid = t1.id " + + "inner join workflow_billField wb on t2.bdzd = wb.id " + + "where " + + "t1.id = ?"; + List> configData = DaoUtil.getData(rs, getConfigDataSql, configId); + + //主表字段数量 + int mainTableFieldCount = 0; + //主表字段配置信息 + List> mainFieldConfigInfoList = new ArrayList<>(); + //明细表字段配置信息 + Map>> detailFieldConfigInfo = new HashMap<>(); + + for(Map m : configData){ + String zdgz = m.get("zdgz"); + if("".equals(zdgz) || "0".equals(zdgz)){ + mainTableFieldCount = mainTableFieldCount + 1; + mainFieldConfigInfoList.add(m); + }else{ + List> detailFieldConfigInfoList = detailFieldConfigInfo.get(zdgz); + if(detailFieldConfigInfoList == null){ + detailFieldConfigInfoList = new ArrayList<>(); + detailFieldConfigInfoList.add(m); + detailFieldConfigInfo.put(zdgz,detailFieldConfigInfoList); + }else{ + detailFieldConfigInfoList.add(m); + } + } + } + + ////////////处理主表字段 + WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[mainTableFieldCount]; + for(int i = 0; i < mainTableFieldCount; i ++){ + String fieldName = mainFieldConfigInfoList.get(i).get("fieldName"); + String value = getValueByConfig(mainFieldConfigInfoList.get(i),jsonData,rs); + wrti[i]=new WorkflowRequestTableField(); + wrti[i].setFieldName(fieldName); + wrti[i].setFieldValue(value); + wrti[i].setEdit(true);//是否能编辑 + wrti[i].setView(true);//是否可以查看 + wrti[i].setMand(false);//是否必填 + } + + WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据 + tablre[0]=new WorkflowRequestTableRecord(); + tablre[0].setWorkflowRequestTableFields(wrti); + WorkflowMainTableInfo maininfo=new WorkflowMainTableInfo(); + maininfo.setRequestRecords(tablre); + info.setWorkflowMainTableInfo(maininfo); + + /////////////处理明细表字段 + WorkflowDetailTableInfo[] WorkflowDetailTableInfo = new WorkflowDetailTableInfo[detailFieldConfigInfo.size()]; + for(int i = 0;i> detailFieldConfigInfoList = detailFieldConfigInfo.get(i); + //根据path查询有多少行明细 + String path = detailFieldConfigInfoList.get(0).get("jsonbwzdlj"); + path = path.substring(0,path.lastIndexOf("/")); + JSONArray array = CommonUtil.getJsonArrayByPath(jsonData,path); + if(array == null || array.size() == 0){ + continue; + } + WorkflowRequestTableRecord[] tablre1 = new WorkflowRequestTableRecord[array.size()]; + for(int j = 0;j< array.size();j++){ + wrti = new WorkflowRequestTableField[detailFieldConfigInfoList.size()]; + for(int k = 0;j param = new HashMap<>(); + param.put("rebulidFlag","1"); + param.put("righttype","1"); + param.put("modeid",modeId); + param.put("rebulidFlag","1"); + param.put("showProgress","0"); + param.put("operation","resetAllRight"); + param.put("session",new TjwHttpSession()); + modeAppService.saveModeRightList(param,new User(1)); + } + + /** + * 新增建模数据 + * @param rs + * @param tableName + * @param dataInfo + * @return + */ + public static int addModelData(RecordSet rs,String tableName, JSONObject dataInfo){ + try{ + logger.info("dataInfo:" + dataInfo.toJSONString()); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs); + int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime); + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = newDataId; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId); + return newDataId; + }catch(Exception e){ + logger.error("TjwModelUtil addModelData;tableName:" + tableName + ";dataInfo:" + dataInfo.toJSONString() + ";messahe:" + e.getMessage() + ";e:" + e); + return -1; + } + } + + /** + * 新增或更新建模数据 + */ + public static int addOrUpdateModelData(RecordSet rs, String tableName, JSONObject dataInfo, List keyList){ + try{ + //根据dataKey判断数据是否存在,有则更新 无则新增 + String idWhere = " 1 = 1 "; + Object[] keyData = new Object[keyList.size()]; + for(int i = 0;i < keyList.size(); i++){ + keyData[i] = dataInfo.get(keyList.get(i)); + } + for(String key:keyList){ + idWhere = idWhere + " and " + key + " = ?"; + } + + String getDataSql = "select id from " + tableName + " where " + idWhere; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, keyData); + String id = firstData.get("id"); + if("".equals(id) || id == null){ + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs); + int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime); + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = newDataId; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId); + return newDataId; + }else{ + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = id; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + return Integer.parseInt(id); + } + }catch(Exception e){ + logger.error("TjwModelUtil addOrUpdateModelData;tableName:" + tableName + ";dataInfo:" + dataInfo + ";messahe:" + e.getMessage() + ";e:" + e); + return -1; + } + } + + /** + * 新增或更新建模数据 + */ + public static int addOrUpdateModelData(RecordSet rs, String tableName, JSONObject dataInfo,String dataKey){ + try{ + //根据dataKey判断数据是否存在,有则更新 无则新增 + String getDataSql = "select id from " + tableName + " where " + dataKey + " = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, dataInfo.get(dataKey)); + String id = firstData.get("id"); + if("".equals(id) || id == null){ + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs); + int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime); + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = newDataId; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId); + return newDataId; + }else{ + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = id; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + return Integer.parseInt(id); + } + }catch(Exception e){ + logger.error("TjwModelUtil addOrUpdateModelData;tableName:" + tableName + ";dataInfo:" + dataInfo + ";messahe:" + e.getMessage() + ";e:" + e); + return -1; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwRightMoveUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwRightMoveUtil.java new file mode 100644 index 0000000..ef24cfe --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwRightMoveUtil.java @@ -0,0 +1,52 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd; +import org.apache.log4j.Logger; +import weaver.hrm.User; + +import javax.servlet.ServletContext; +import javax.servlet.http.*; +import java.util.*; + +public class TjwRightMoveUtil { + static Logger logger = MyLogger.getLogger(); + + public static JSONObject moveRight(JSONObject param){ + try{ + logger.info("TjwRightMoveUtil.moveRight begin;param:" + param.toJSONString()); + Map params = new HashMap<>(); + for(Object key : param.keySet()){ + params.put(key.toString(),param.get(key)); + } + HttpServletRequest request = new TjwHttpServletRequest(){ + @Override + public String getParameter(String s) { + return param.getString(s); + } + + @Override + public HttpSession getSession(boolean b) { + HttpSession session = new TjwHttpSession(){ + @Override + public Object getAttribute(String s) { + return new User(1); + } + }; + return session; + } + }; + + ProcessDataCmd cmd = new ProcessDataCmd(params,request,new User(1)); + Map execute = cmd.execute(null); + logger.info("moveRight.result:" + execute.toString()); + return null; + }catch (Throwable e){ + logger.error("TjwRightMoveUtil.moveRight error;message:" + e.getMessage() + ";e:" + e); + return null; + } + + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwTimeUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwTimeUtil.java new file mode 100644 index 0000000..a866040 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwTimeUtil.java @@ -0,0 +1,52 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class TjwTimeUtil { + + static Logger logger = MyLogger.getLogger(); + static SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + public static String getLastDay(){ + //获取今天的日期 + Date today = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(today); + c.add(Calendar.DAY_OF_MONTH, -1); + //这是昨天 + Date yesterday = c.getTime(); + String lastDay = new SimpleDateFormat("yyyy-MM-dd").format(yesterday); + return lastDay; + } + + + /** + * 将时间戳转换为固定格式 + * @param format 日期格式 + * @param time 时间戳 毫秒 + * @return + */ + public static String getFormatTimeByTimeMillis(String format, long time){ + try{ + String result = ""; + Date date= new Date(time); + switch (format){ + case "yyyy-MM-dd HH:mm:ss": + result = sdfDateAndTime.format(date); + break; + default: + break; + } + return result; + }catch(Exception e){ + logger.error("CommonUtil.getFormatTimeByTimeMillis execute error;exception:" + e.getMessage() + ";e:" + e); + return ""; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwWorkFlowUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwWorkFlowUtil.java new file mode 100644 index 0000000..6e81256 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TjwWorkFlowUtil.java @@ -0,0 +1,176 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.interfaces.action.WorkflowToMode; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.soa.workflow.request.RequestService; +import weaver.workflow.request.RequestManager; +import weaver.workflow.webservices.*; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +public class TjwWorkFlowUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String createWorkFlow(String requestName, String creator, String workFlowId, String isNextFlow, Map mainTableData, List>> detailTableData){ + try{ + logger.info("TjwWorkFlowUtil.createWorkFlow begin;requestName:" + requestName); + WorkflowService service = new WorkflowServiceImpl(); + WorkflowRequestInfo info = new WorkflowRequestInfo(); + info.setRequestName(requestName); + //创建人 + info.setCreatorId(creator); + //0正常,1重要,2紧急 + info.setRequestLevel("0"); + WorkflowBaseInfo base = new WorkflowBaseInfo(); + //流程id + RecordSet rs = new RecordSet(); + base.setWorkflowId(workFlowId); + info.setWorkflowBaseInfo(base); + //流转到下一个节点 + info.setIsnextflow(isNextFlow); + + WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[mainTableData.size()]; + int i = 0; + for(String key : mainTableData.keySet()){ + wrti[i]=new WorkflowRequestTableField(); + wrti[i].setFieldName(key); + wrti[i].setFieldValue(mainTableData.get(key)); + wrti[i].setEdit(true);//是否能编辑 + wrti[i].setView(true);//是否可以查看 + wrti[i].setMand(true);//是否必填 + i = i + 1; + } + + WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据 + tablre[0]=new WorkflowRequestTableRecord(); + tablre[0].setWorkflowRequestTableFields(wrti); + WorkflowMainTableInfo mainInfo=new WorkflowMainTableInfo(); + mainInfo.setRequestRecords(tablre); + //添加主字段数据 + info.setWorkflowMainTableInfo(mainInfo); + + //添加到明细表中 + if(detailTableData != null && detailTableData.size() > 0){ + WorkflowDetailTableInfo WorkflowDetailTableInfo[] = new WorkflowDetailTableInfo[detailTableData.size()]; + for(int j = 0; j> tableData = detailTableData.get(j); + if(tableData != null && tableData.size() > 0){ + WorkflowRequestTableRecord[] detailTablre = new WorkflowRequestTableRecord[tableData.size()]; + for(int m = 0;m < tableData.size();m ++){ + Map datas = tableData.get(m); + WorkflowRequestTableField[] d = new WorkflowRequestTableField[datas.size()]; + int n = 0; + for(String key : datas.keySet()){ + d[n] = new WorkflowRequestTableField(); + d[n].setFieldName(key); + d[n].setFieldValue(datas.get(key)); + d[n].setView(true);//字段是否可见 + d[n].setEdit(true);//字段是否可编辑 + } + detailTablre[n] = new WorkflowRequestTableRecord(); + detailTablre[n].setWorkflowRequestTableFields(d); + } + WorkflowDetailTableInfo[j] = new WorkflowDetailTableInfo(); + WorkflowDetailTableInfo[j].setWorkflowRequestTableRecords(detailTablre); + } + } + info.setWorkflowDetailTableInfos(WorkflowDetailTableInfo);//添加明细数据 + } + //发起流程 + String returnMsg = service.doCreateWorkflowRequest(info, Integer.parseInt(creator)); + logger.info("TjwWorkFlowUtil.createWorkFlow end;returnMsg:" + returnMsg); + return returnMsg; + }catch (Throwable e){ + logger.error("TjwWorkFlowUtil.createWorkFlow error;requestName:" + requestName); + return ""; + } + + } + + + /** + * 提交流程至下一节点 + * @param requestId + * @param userId + */ + public static boolean submitWorkFlow(int requestId,int userId){ + try{ + WorkflowService service = new WorkflowServiceImpl(); + String message = service.submitWorkflowRequest(null, requestId, userId,"submit",""); + if("success".equals(message)){ + return true; + }else{ + logger.error("TjwWorkFlowUtil.submitWorkFlow false;requestId:" + requestId + ";userId:" + userId + ";message:" + message); + return false; + } + }catch (Exception e){ + logger.error("TjwWorkFlowUtil.submitWorkFlow exception;requestId:" + requestId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 触发流程转数据 + * @param requestId 流程请求id + * @param configId 流程转数据的配置id + * @param rs 数据库连接 + * @return 1-成功; + */ + public static String doWorkFlowToMode(int requestId,int configId,RecordSet rs){ + try{ + if(rs == null){ + rs = new RecordSet(); + } + //获取流程转数据的配置信息 + String getWorkFlowToModeSetInfoSql = "select triggernodeid,actionid from mode_workflowtomodeset where id = ?"; + Map configInfo = DaoUtil.getFirstData(rs,getWorkFlowToModeSetInfoSql,configId); + int nodeId = Integer.parseInt(configInfo.get("triggernodeid")); + int actionId = Integer.parseInt(configInfo.get("actionid")); + //获取流程基本信息 + String getRequestBaseInfoSql = "select t1.workflowid,t2.formid,t1.creater,t1.requestname from workflow_requestbase t1 inner join workflow_base t2 on t2.id = t1.workflowid where t1.requestid = ?"; + Map requestBaseInfo = DaoUtil.getFirstData(rs,getRequestBaseInfoSql,requestId); + int workFlowId = Integer.parseInt(requestBaseInfo.get("workflowid")); + int formId = Integer.parseInt(requestBaseInfo.get("formid")); + int creater = Integer.parseInt(requestBaseInfo.get("creater")); + User user = new User(creater); + String requestName = requestBaseInfo.get("requestname"); + //构造请求参数 + RequestService x = new RequestService(); + RequestInfo requestInfo = x.getRequest(requestId); + //只记录日志 triggerType + requestInfo.setIspreadd("0"); + RequestManager requestManager = new RequestManager(); + requestManager.setNodeid(nodeId); + //只记录日志 + requestManager.setNextNodeid(0); + requestManager.setWorkflowid(workFlowId); + requestManager.setFormid(formId); + requestManager.setRequestid(requestId); + requestManager.setCreater(creater); + //用于区分流程类型 + requestManager.setIsbill(1); + requestManager.setUser(user); + requestManager.setRequestname(requestName); + requestInfo.setRequestManager(requestManager); + WorkflowToMode wtm = new WorkflowToMode(); + Class classType = WorkflowToMode.class; + Field field = classType.getDeclaredField("actionid"); + field.setAccessible(true); + field.set(wtm, actionId); + String result = wtm.execute(requestInfo); + logger.info("doWorkFlowToMode done;requestId:" + requestId + ";configId:" + configId + ";result:" + result); + return result; + }catch(Exception e){ + logger.error("doWorkFlowToMode exception;requestId:" + requestId + ";configId:" + configId + ";messahe:" + e.getMessage() + ";e:" + e); + return "error"; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/ToolUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/ToolUtil.java new file mode 100644 index 0000000..cc00d59 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/ToolUtil.java @@ -0,0 +1,404 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.ConnStatementDataSource; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.GCONST; +import weaver.general.TimeUtil; +import weaver.general.Util; + +import java.io.*; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +/** + * 常用工具方法-公用类 + * @author bleach + * @date 2018-01-18 + * @version 2.0 Modify By Weilin.Zhu 添加日志级别 2018-12-05 + * @version 3.0 Modify By Weilin.Zhu 修改日志输出方式,使用log4j 2020-03-10 + * @version 4.0 Modify By Weilin.Zhu 去除根据建模配置来控制日志输出功能 2021-06-29 + */ +public class ToolUtil extends BaseBean { + + Logger logger = MyLogger.getLogger(); + + + private RecordSet rs = new RecordSet(); + + + /** + * 构造方法 + */ + public ToolUtil() { + //logger = LoggerFactory.getLogger("cus"); + } + + /** + * 根据流程类型ID获取其对应的表单名称 + * @param workflowid 流程类型ID + * @return 字符串 + */ + public String getBillTableNameByWorkflowId(String workflowid){ + String tablename = ""; + + if(!"".equals(workflowid)){ + String select_data = "select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)"; + + if(rs.executeQuery(select_data, workflowid)){ + if(rs.next()){ + tablename = Util.null2String(rs.getString(1)); + } + } + } + + return tablename; + } + + /** + * 查询满足模糊查询的所有标识集合 + * @param likestr 模糊条件 + * @return + */ + public Map getSystemParamValueMap(String likestr){ + return getSystemParamList(likestr); + } + + /** + * 查询系统中所有参数配置 + * @return + */ + public Map getAllSystemParamValue(){ + return getSystemParamList(""); + } + + + /** + * 获取参数集合 + * @param likestr 模糊查询的条件 + * @return 集合 + */ + private Map getSystemParamList(String likestr){ + Map param_map = new HashMap(); + + String select_sql = "select uuid,paramvalue from uf_systemconfig"; + + RecordSet rs = new RecordSet(); + + if(!"".equals(likestr)){ + select_sql += " where uuid like '%" + likestr + "%'"; + } + + if(rs.execute(select_sql)){ + while(rs.next()){ + String uuid = Util.null2String(rs.getString(1)); + String paramvalue = Util.null2String(rs.getString(2)); + param_map.put(uuid, paramvalue); + } + } + + return param_map; + + } + + /** + * 获取系统参数设置值 + * @param uuid 参数标识 + * @return 返回配置值 + */ + public static String getSystemParamValue(String uuid){ + String paramvalue = ""; + + if(!"".equals(uuid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,uuid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @return 配置值 + */ + public String getValueByChangeRule(String userId,String cus_sql,String value){ + + return getValueByChangeRule(userId,cus_sql,value,""); + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @param requestid 流程请求ID + * @return + */ + public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid){ + + return getValueByChangeRule(userId,cus_sql,value,requestid,0); + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @param requestid 流程请求ID + * @param detailKeyvalue 明细表主键值 + * @return + */ + public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid,int detailKeyvalue){ + return getValueByChangeRule(userId,cus_sql,value,requestid,detailKeyvalue,null); + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @param requestid 流程请求ID + * @param detailKeyvalue 明细表主键值 + * @pram datasourceid 外部数据源ID + * @return + */ + public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid,int detailKeyvalue,String datasourceid){ + String endValue = ""; + cus_sql = ToDBC(cus_sql); + + cus_sql = cus_sql.replace(" ", " "); + + cus_sql = cus_sql.replace("{?dt.id}", String.valueOf(detailKeyvalue)); + + cus_sql = cus_sql.replace("{?currentUserId}", String.valueOf(userId)); + + //参数进行替换 + String sqlString = cus_sql.replace("{?requestid}", requestid); + + sqlString = sqlString.replace("?", value); + + try { + if(datasourceid != null && !"".equals(datasourceid)){ + ConnStatementDataSource csds = new ConnStatementDataSource(datasourceid); + + csds.setStatementSql(sqlString); + + csds.executeQuery(); + + if(csds.next()){ + endValue = Util.null2String(csds.getString(1)); + } + + csds.close(); + }else{ + + RecordSet rs = new RecordSet(); + if(rs.executeQuery(sqlString)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return endValue; + } + + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @return + */ + public String getValueByChangeRule_SingleParam(String cus_sql,String value){ + String endValue = ""; + + cus_sql = cus_sql.replace(" ", " "); + + RecordSet rs = new RecordSet(); + + if(rs.executeQuery(cus_sql,value)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + + return endValue; + } + + /** + * 全角转半角 + * @param input + * @return + */ + public static String ToDBC(String input) { + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + return returnString; + } + + /** + * 根据字段ID获取其对应的字段名称 + * @param fieldid + * @return + */ + public String getFieldNameByFieldid(int fieldid){ + if(fieldid > 0){ + return getFieldNameByFieldid(String.valueOf(fieldid)); + }else{ + return ""; + } + } + + /** + * 根据字段ID获取其对应的字段名称 + * @param fieldid + * @return + */ + public String getFieldNameByFieldid(String fieldid){ + String fieldname = ""; + + if(!"".equals(fieldid)){ + + if(fieldid.startsWith(",")){ + fieldid = fieldid.substring(1); + } + + if(fieldid.endsWith(",")){ + fieldid =fieldid.substring(0,fieldid.length() - 1); + } + + String select_sql = "select fieldname from workflow_billfield where id in (" + fieldid + ")"; + + RecordSet rs = new RecordSet(); + + if(rs.execute(select_sql)){ + while(rs.next()){ + + fieldname += "," + Util.null2String(rs.getString(1)); + } + } + } + + if(fieldname.startsWith(",")){ + fieldname = fieldname.substring(1); + } + + return fieldname; + } + + /** + * 输出调试日志 + * @param className 类名称 + * @param logstr 日志信息 + */ + public void writeDebuggerLog(String className,String logstr){ + logger.info(logstr); + } + + /** + * 输出警告日志 + * @param className 类名称 + * @param logstr 日志信息 + */ + public void writeWarningLog(String className,String logstr){ + logger.warn(logstr); + } + + /** + * 输出错误日志 + * @param className 类名称 + * @param logstr 日志信息 + */ + public void writeErrorLog(String className,String logstr){ + logger.error(logstr); + } + + + /** + * 日志输出 + * @param logstr + */ + public void writeDebugLog(Object logstr){ + logger.info(logstr); + } + + /** + * 日志输出 + * @param logstr + */ + public void writeErrorLog(Object logstr){ + logger.error(logstr); + } + + /** + * 日志输出 + * @param logstr + */ + public void writeNewDebuggerLog(Object o,Object logstr){ + logger.info(logstr); + } + + /** + * 写入同步的日志文件 + * @param o + * @param s + * @deprecated 该写入文件的日志输出方式删除 + */ + protected void writeNewLog(String o,String s){ + try { + String filename = "cus_" + TimeUtil.getCurrentDateString() + "_ecology.log"; + + + String folder = GCONST.getRootPath() + "log" + File.separatorChar + "cus"; + + //this.writeDebugLog("folder:[" + folder + "]"); + + File f = new File(folder); + + // 创建文件夹 + if (!f.exists()) { + f.mkdirs(); + } + + f = new File(folder + File.separatorChar + filename); + //文件不存在,则直接创建 + if(!f.exists()){ + f.createNewFile(); + } + + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true))); + + out.write("[" + o + "][" + TimeUtil.getCurrentTimeString() + "]:"+ s + "\r\n"); + + //关闭写入流 + out.close(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + writeDebugLog("创建日志文件存在异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/TwoDimensionalCodeUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/TwoDimensionalCodeUtil.java new file mode 100644 index 0000000..09b3b31 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/TwoDimensionalCodeUtil.java @@ -0,0 +1,67 @@ +package com.api.taojw.common; + +import com.api.taojw.common.logging.MyLogger; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.common.BitMatrix; +import org.apache.log4j.Logger; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class TwoDimensionalCodeUtil { + + private static final int BLACK = 0xFF000000; + private static final int WHITE = 0xFFFFFFFF; + + static Logger logger = MyLogger.getLogger(); + + /** + * 在指定位置生成二维码图片 + * @param content 二维码内容;eg:https://www.baidu.com + * @param path 生成的图片路径;eg:F:/测试 + * @param codeName 生成的图片名称;eg:UUID.randomUUID().toString() + * @param imageType 生成的图片类型;eg:jpg + */ + public static void getImage(String content,String path,String codeName,String imageType) { + try { + MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); + Map hints = new HashMap<>(); + hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); + BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints); + File file = new File(path, codeName + "." + imageType); + writeToFile(bitMatrix, imageType, file); + } catch (Exception e) { + logger.error("TwoDimensionalCodeUtil.getImage exception;content:" + content + "message:" + e.getMessage() + ";e:" + e); + } + } + + public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException { + BufferedImage image = toBufferedImage(matrix); + if (!ImageIO.write(image, format, file)) { + throw new IOException("Could not write an image of format " + format + " to " + file); + } + } + + public static BufferedImage toBufferedImage(BitMatrix matrix) { + int width = matrix.getWidth(); + int height = matrix.getHeight(); + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE); + } + } + return image; + } + + + + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/WorkFlowDataToJsonUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/WorkFlowDataToJsonUtil.java new file mode 100644 index 0000000..d515be6 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/WorkFlowDataToJsonUtil.java @@ -0,0 +1,434 @@ +package com.api.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; + +import java.text.SimpleDateFormat; +import java.util.*; + +public class WorkFlowDataToJsonUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String[] getRequestBaseInfo(String requestId,RecordSetTrans rsts,String requestMark,String billTableName){ + //--------------------------------------基于文件发起签署 + //流程基础数据数组[流程请求ID\流程标题\签字意见\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId); + if(firstData.size() > 0){ + base_array[4] = firstData.get("id"); + } + return base_array; + } catch (Throwable e) { + logger.error("WorkFlowDataToJsonUtil getRequestBaseInfo error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return null; + } + } + + + /** + * 根据转换规则 获取转换后的数据 + */ + public static String convertDataByZhgz(String oldValue,Map configMap){ + //函数返回值 + String result = ""; + try{ + //转换规则 + String zhgz = configMap.get("zhgz"); + //自定义sql + String zdysql = configMap.get("zdysql"); + String requestId = Util.null2String(configMap.get("requestId")); + //不同转换规则处理 + switch(zhgz){ + //不转换 + case "0": + result = oldValue; + break; + //固定值 + case "1": + result = zdysql; + break; + //自定义sql + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId); + Map firstData = DaoUtil.getFirstData(zdysql); + for(String key : firstData.keySet()){ + result = firstData.get(key); + } + break; + //日期格式化 + case "3": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd").parse(oldValue)); + break; + //日期时间格式化 + case "4": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(oldValue)); + break; + //当前日期 + case "5": + result = new SimpleDateFormat(zdysql).format(new Date()); + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.convertDataByZhgz error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public static JSONObject getJsonByWorkFlowData(String requestId,String configId,String[] base_array){ + JSONObject result = new JSONObject(); + try{ + logger.info("WorkFlowDataToJsonUtil.getJsonByWorkFlowData begin;requestId:" + requestId + ";configId:" + configId); + RecordSet rs = new RecordSet(); + //-----------------------根据配置id获取配置信息 + //根节点配置信息 + List> rootJsonConfigInfo = new ArrayList<>(); + //明细配置信息 + List> requestBodyConfigList = new ArrayList<>(); + getConfigInfo(rs,configId,requestBodyConfigList,rootJsonConfigInfo); + //-----------------------获取主表数据 用于拼装json + Map mainTableData = new HashMap<>(); + String getMainTableDataSql = "select * from " + base_array[3] + " where id = " + base_array[4]; + if(rs.executeQuery(getMainTableDataSql)) { + if (rs.next()) { + mainTableData = DaoUtil.setRsToMap(rs); + } + } + //-----------------------生成json + logger.info("recursionGenerateJson begin;"); + recursionGenerateJson(null,rs,rs,0,result,rootJsonConfigInfo,base_array,mainTableData,requestBodyConfigList); + }catch(Throwable e){ + logger.error("WorkFlowDataToJsonUtil.getJsonByWorkFlowData exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据configId获取配置信息 + * @param rs 数据库链接 + * @param configId 配置id + * @param requestBodyConfigList 明细配置 + * @param rootJsonConfigInfo 根节点配置 + */ + public static void getConfigInfo(RecordSet rs,String configId,List> requestBodyConfigList,List> rootJsonConfigInfo){ + //获取明细表 请求体字段详细配置信息 + String selectDetailSQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from uf_lcsjzjson_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetailSQL,configId)){ + while(rs.next()){ + //节点序号 + String xmljdxh = Util.null2String(rs.getString("jdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("jdmc")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("jdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + sjtj = sjtj.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + sjtj = CommonUtil.fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("jdxh",xmljdxh); + dtMap.put("jdmc",xmljdmc); + dtMap.put("jdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("zdgz",zdgz); + dtMap.put("detailtable",detailtable); + dtMap.put("fieldName",fieldName.toLowerCase()); + if("".equals(fjdxh)){ + rootJsonConfigInfo.add(dtMap); + } + requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL sql execute error;sql:" + selectDetailSQL); + } + logger.info("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL done;requestBodyConfigList:" + requestBodyConfigList); + } + + + /** + * 递归生成json报文 + */ + public static Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence,JSONObject jsonDoc, + List> rootJsonConfigInfo, + String[] baseArray,Map mainTableData, + List> requestBodyConfigList){ + if(configMap == null){ + for(Map configInfo:rootJsonConfigInfo){ + jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + }else{ + switch(configMap.get("jdlx")){ + case Constant.NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + return getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + case Constant.NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + return "true".equals(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + case Constant.NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case Constant.NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + d = Double.parseDouble(f); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case Constant.NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return json; + case Constant.NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return jsonObj.toString(); + case Constant.NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + JSONArray stringArray = new JSONArray(); + stringArray.addAll(Arrays.asList(stringArrayValue.split(","))); + return stringArray; + case Constant.NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && Constant.CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + array.add(o); + } + } + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh")) && Constant.NODE_TYPE_OBJECT.equals(son.get("jdlx"))) { + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return array; + default: + break; + } + } + return null; + } + + + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + */ + public static String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs,String[] baseArray,Map mainTableData){ + //函数返回值 + StringBuilder result = new StringBuilder(); + try{ + Map detailDataMap = DaoUtil.setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //数据条件 + String sjtj = configMap.get("sjtj"); + //字段所属明细表表名 + String detailtable = configMap.get("detailtable"); + //不同转换规则处理 + switch(zhgz){ + case Constant.CHANGE_TYPE_REQUEST_ID: + result = new StringBuilder(baseArray[0]); + break; + case Constant.CHANGE_TYPE_REQUEST_NAME: + result = new StringBuilder(baseArray[1]); + break; + case Constant.CHANGE_TYPE_MD5: + result = new StringBuilder("Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes())); + break; + case Constant.CHANGE_TYPE_SUGGESTION: + result = new StringBuilder(baseArray[2]); + break; + case Constant.CHANGE_TYPE_ROW_NUMBER: + result = new StringBuilder(configMap.get("detailRowNum")); + break; + case Constant.CHANGE_TYPE_FIXED: + result = new StringBuilder(configMap.get("zdysql")); + break; + case Constant.CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = new StringBuilder(mainTableData.get(fieldName)); + }else{ + result = new StringBuilder(detailDataMap.get(fieldName)); + } + break; + case Constant.CHANGE_TYPE_SQL: + String oldValue; + if(!"".equals(viewType) && !"".equals(fieldName)){ + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + } + zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + } + } + break; + case Constant.CHANGE_TYPE_SUM: + if("0".equals(viewType)){ + logger.error("want sum but config main field"); + break; + } + String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getSumSql = getSumSql + " " + sjtj; + } + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString("val"))); + } + } + break; + case Constant.CHANGE_TYPE_STRING_ARRAY: + if("0".equals(viewType)){ + logger.error("want array but config main field"); + break; + } + String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getArraySql = getArraySql + " " + sjtj; + } + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + }else{ + result.append(",").append(Util.null2String(rs.getString(1))); + } + i = i + 1; + } + } + break; + default: + result = new StringBuilder(); + break; + } + return result.toString(); + }catch(Exception e){ + result = new StringBuilder(); + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result.toString(); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java new file mode 100644 index 0000000..a9d2b8e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java @@ -0,0 +1,107 @@ +package com.api.taojw.common.action; + +import com.api.taojw.common.action.util.CallApiByWorkFlowDataUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Map; + +/** + * taojingwei @2022-05-26 + * 1、获取建模配置,将流程数据封装成需要的请求报文 + * 2、调用http接口传输报文信息,获取接口返回信息 + */ +public class RequestDataToApiAction implements Action { + + //自定义参数值 + private String cusParam = ""; + + Logger logger = MyLogger.getLogger(); + + /** + * 实现父类方法 + * 具体的业务实现 + * @param requestInfo 流程请求信息 + * @return 流程是否允许提交标识 + */ + @Override + public String execute(RequestInfo requestInfo) { + //流程请求ID + String requestId = ""; + try { + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + //流程请求ID + requestId = requestInfo.getRequestid(); + //流程类型ID + String workflowId = requestInfo.getWorkflowid(); + //流程表单名称 + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = ""; + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + requestMark = Util.null2String(rsts.getString("requestMark")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + logger.info("requestName:[" + requestName + "],requestMark:[" + requestMark + "],workflowId:["+workflowId+"],requestId:[" + requestId + "],billTableName:[" + billTableName + "],cusParam[" + cusParam + "]"); + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + //获取当前流程信息 + String selectData = "select * from " + billTableName + " where requestId = ?"; + RecordSet rs = new RecordSet(); + if(rs.executeQuery(selectData,requestId)){ + rs.next(); + base_array[4] = Util.null2String(rs.getString("id")); + } + + CallApiByWorkFlowDataUtil callApiByWorkFlowDataUtil = new CallApiByWorkFlowDataUtil(); + callApiByWorkFlowDataUtil.setBaseArray(base_array); + callApiByWorkFlowDataUtil.setRsts(rsts); + Map result = callApiByWorkFlowDataUtil.execute(workflowId, cusParam); + if("CALL_FAILED".equals(result.get("code"))){ + requestInfo.getRequestManager().setMessageid("2022052791402"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",接口响应:" + result.get("message")); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + }catch (Throwable e) { + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString()+requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +";" + "请联系管理员TJW!异常信息:" + e.getMessage()); + logger.error("Action Exception;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + + public String getCusParam() { + return cusParam; + } + + public void setCusParam(String cusParam) { + this.cusParam = cusParam; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/constant/Constant.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/constant/Constant.java new file mode 100644 index 0000000..ebe7b1c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/constant/Constant.java @@ -0,0 +1,107 @@ +package com.api.taojw.common.action.constant; + + +/** + * 一些静态常量定义 + */ +public class Constant { + + //action接口调用配置表名称 + public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd"; + //action调用接口日志记录表表名 + public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd"; + //action调用接口日志记录表requestId字段名称 + public static String LOG_REQUESTID_COLUMN = "lcrequestid"; + //action调用接口日志记录表请求正文字段名称 + public static String LOG_REQUEST_COLUMN = "qqbw"; + //action调用接口日志记录表响应文字段名称 + public static String LOG_RESPONSE_COLUMN = "xybw"; + //action调用接口日志记录表响应码字段名称 + public static String LOG_RESPONSECODE_COLUMN = "xym"; + //action调用接口日志记录表请求地址字段名称 + public static String LOG_REQUESTURL_COLUMN = "qqdz"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUESTHEADER_COLUMN = "qqt"; + + //------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志 + public static final String PARAM_BEGIN = "{"; + public static final String PARAM_END = "}"; + + //------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功 + public static final String CALL_SUCCESS = "1"; + public static final String CALL_FAILED = "0"; + + //------------------------------------------------------------------------------选择框 0-否 1-是 + public static final String SELECT_TYPE_IS = "1"; + public static final String SELECT_TYPE_NOT = "0"; + + //------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次 + public static final String CALL_TYPE_ONLY_ONE = "0"; + public static final String CALL_TYPE_EVERY_DETAIL = "1"; + + //------------------------------------------------------------------------------接口请求类型 0-get 1-post + //GET + public static final String REQUEST_METHOD_GET = "0"; + //POST + public static final String REQUEST_METHOD_POST = "1"; + + //------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对 + //xml + public static final String REQUEST_DATA_TYPE_XML = "0"; + //json + public static final String REQUEST_DATA_TYPE_JSON = "1"; + //键值对 + public static final String REQUEST_DATA_TYPE_PAIR = "2"; + //MultipartFile + public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3"; + + //------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json + //xml + public static final String RESPONSE_DATA_TYPE_XML = "0"; + //json + public static final String RESPONSE_DATA_TYPE_JSON = "1"; + + //------------------------------------------------------------------------------节点类型 + //文本 + public static final String NODE_TYPE_STRING = "0"; + //对象 + public static final String NODE_TYPE_OBJECT = "1"; + //文本数组 + public static final String NODE_TYPE_STRING_ARRAY = "2"; + //数组 + public static final String NODE_TYPE_ARRAY = "3"; + //json对象字符串 + public static final String NODE_TYPE_JSONSTRING = "4"; + //数字 + public static final String NODE_TYPE_NUMBER = "5"; + //布尔 + public static final String NODE_TYPE_BOOLEAN = "6"; + //浮点数 + public static final String NODE_TYPE_FLOAT = "7"; + + //------------------------------------------------------------------------------转换规则 + //不转换 + public static final String CHANGE_TYPE_NONE = "0"; + //固定值 + public static final String CHANGE_TYPE_FIXED = "1"; + //自定义sql + public static final String CHANGE_TYPE_SQL = "2"; + //字段求和 + public static final String CHANGE_TYPE_SUM = "3"; + //文本数组 + public static final String CHANGE_TYPE_STRING_ARRAY = "4"; + //明细序号 + public static final String CHANGE_TYPE_ROW_NUMBER = "5"; + //流程审批意见 + public static final String CHANGE_TYPE_SUGGESTION = "6"; + //加密处理 + public static final String CHANGE_TYPE_MD5 = "7"; + + //------------------------------------------------------------------------------sql转义 + //默认换行符 + public static final String Default_Line_Break = "
"; + //默认空格HTML代码 + public static final String Default_Html_Blank = " "; + //默认空格字符 + public static final String Default_Blank_Char = " "; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/entity/ConfigInfoEntity.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/entity/ConfigInfoEntity.java new file mode 100644 index 0000000..f52f91f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/entity/ConfigInfoEntity.java @@ -0,0 +1,54 @@ +package com.api.taojw.common.action.entity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ConfigInfoEntity { + + //接口调用类型 0-仅调用一次 1-每条明细调用一次 + public String callType; + //请求方式 0-get 1-post + public String requestMethod; + //失败是否阻止流程提交 + public String failedAndReturn; + //明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口 + public String detailTableIndex; + //数据条件 + public String sqlCondition; + //接口报文类型 0-xml 1-json 2-键值对 + public String requestDataType; + //响应报文类型 0-xml 1-json + public String responseDataType; + //接口地址 + public String callAddress; + //日志记录表名称 + public String logTableName; + //日志记录表requestid字段名称 + public String logRequestIdFieldName; + //日志记录表接口地址字段名称 + public String logRequestUrlFieldName; + //日志记录表请求头字段名称 + public String logRequestHeaderFieldName; + //日志记录表请求报文字段名称 + public String logRequestBodyFieldName; + //日志记录表响应报文字段名称 + public String logResponseBodyFieldName; + //日志记录表响应码字段名称 + public String logResponseStatusFieldName; + //接口地址参数配置详情 + public List> requestAddressConfigList = new ArrayList<>(); + //请求头参数配置详情 + public List> requestHeaderConfigList = new ArrayList<>(); + //请求体字段详细配置 + public List> requestBodyConfigList = new ArrayList<>(); + //xml节点属性详细配置 + public List> xmlNodeAttrConfigList = new ArrayList<>(); + //响应信息详细配置 + public List> responseConfigList = new ArrayList<>(); + + //json请求报文根节点配置信息 + public List> rootJsonConfigInfo = new ArrayList<>(); + //xml请求报文根节点配置信息 + public Map rootXmlConfigInfo; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/entity/RequestAndResponseInfoEntity.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/entity/RequestAndResponseInfoEntity.java new file mode 100644 index 0000000..4f95cf5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/entity/RequestAndResponseInfoEntity.java @@ -0,0 +1,40 @@ +package com.api.taojw.common.action.entity; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.message.BasicNameValuePair; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RequestAndResponseInfoEntity { + + //请求头参数 + public Map headers = new HashMap<>(); + //生成的xml请求报文对象 + public Document xmlDoc = DocumentHelper.createDocument(); + //生成的json请求报文对象 + public JSONObject jsonDoc = new JSONObject(); + //生成的键值对参数 + public List pairList = new ArrayList<>(); + //文件信息参数 + public List> multiPartFileInfos = new ArrayList<>(); + //接口响应信息 + public CloseableHttpResponse response; + //接口响应体 + public String responseString; + //接口响应码 + public int responseCode; + //JSON类型响应体 + public JSONObject responseJson; + //XML类型响应体 + public Document responseXml; + //响应的成功失败标识值 + public String resultValue = ""; + //接口调用提示信息 + public String responseMessage = ""; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/util/CallApiByWorkFlowDataUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/util/CallApiByWorkFlowDataUtil.java new file mode 100644 index 0000000..3e7ec1a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/util/CallApiByWorkFlowDataUtil.java @@ -0,0 +1,1281 @@ +package com.api.taojw.common.action.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.CommonSqlUtil; +import com.api.taojw.common.CommonUtil; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.action.entity.ConfigInfoEntity; +import com.api.taojw.common.action.entity.RequestAndResponseInfoEntity; +import com.api.taojw.common.logging.MyLogger; +import org.apache.http.HttpEntity; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.file.ImageFileManager; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.workflow.workflow.WorkflowVersion; + +import javax.net.ssl.*; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.text.DecimalFormat; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static weaver.taojw.common.action.constant.Constant.*; + +/** + *

+ * 功能描述: + * 流程数据推送工具类 + * 获取配置信息 生成请求 解析响应 + * 创建日期: + * 2022-05-26 + *

+ * @author taojingwei + * @version 1.0 + */ +public class CallApiByWorkFlowDataUtil { + + //建模工具类 + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + private RecordSetTrans rsts = null; + + //流程类型 + private String workflowId = ""; + //自定义配置值 + private String paramValue = ""; + //配置主表id + private int mainConfigInfoId; + //流程基础数据数组[流程请求ID\流程标题\流程编号\流程主表表名\流程主表主键值] + private String[] baseArray = new String[5]; + + //建模中的配置信息 + private ConfigInfoEntity configInfoEntity = new ConfigInfoEntity(); + //请求和响应内容 + private RequestAndResponseInfoEntity rarInfoEntity = new RequestAndResponseInfoEntity(); + + //流程主表数据 + private Map mainTableData = new HashMap<>(); + //流程明细表数据 + private Map>> detailTableData = new HashMap<>(); + + Logger logger = MyLogger.getLogger(); + + /** + * 获取对应配置信息 + * @param rs 数据库链接 + * @throws Exception + */ + public void getConfigurationByWorkflowId(RecordSet rs) throws Exception{ + //获取该流程类型对应的所有类型ID + String allWfIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId); + String selectMainSQL = "select * from " + CONFIG_TABLE_NAME + " where lclx in (" + allWfIds + ")"; + if(!"".equals(paramValue)){ + selectMainSQL += " and pzid = '" + paramValue + "'"; + } + if(rs.executeQuery(selectMainSQL)){ + if(rs.next()){ + //配置主表id + mainConfigInfoId = Util.getIntValue(rs.getString("id"),0); + //接口调用类型 0-仅调用一次 1-每条明细调用一次 + configInfoEntity.callType = Util.null2String(rs.getString("jkdylx")); + //请求方式 0-get 1-post + configInfoEntity.requestMethod = Util.null2String(rs.getString("qqfs")); + //失败是否阻止流程提交 + configInfoEntity.failedAndReturn = Util.null2String(rs.getString("sbsfzzlctj")); + //明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口 + configInfoEntity.detailTableIndex = Util.null2String(rs.getString("mxbxb")); + //数据条件 用于筛选明细表中需要调用接口的记录 + configInfoEntity.sqlCondition = Util.null2String(rs.getString("sjtj")); + //接口报文类型 0-xml 1-json 2-键值对 + configInfoEntity.requestDataType = Util.null2String(rs.getString("jkbwlx")); + //接口响应报文类型 0-xml 1-json + configInfoEntity.responseDataType = Util.null2String(rs.getString("xybwlx")); + //接口地址 + configInfoEntity.callAddress = Util.null2String(rs.getString("jkdz")); + //日志记录表名称 + configInfoEntity.logTableName = LOG_TABLE_NAME; + //日志记录表requestid字段名称 + configInfoEntity.logRequestIdFieldName = LOG_REQUESTID_COLUMN; + //日志记录表请求报文字段名称 + configInfoEntity.logRequestBodyFieldName = LOG_REQUEST_COLUMN; + //日志记录表响应报文字段名称 + configInfoEntity.logResponseBodyFieldName = LOG_RESPONSE_COLUMN; + //日志记录表响应码文字段名称 + configInfoEntity.logResponseStatusFieldName = LOG_RESPONSECODE_COLUMN; + //日志记录表请求地址字段名称 + configInfoEntity.logRequestUrlFieldName = LOG_REQUESTURL_COLUMN; + //日志记录表请求头字段名称 + configInfoEntity.logRequestHeaderFieldName = LOG_REQUESTHEADER_COLUMN; + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.getMainConfigInfo sql execute success and found nothing;sql:" + selectMainSQL); + throw new Exception("接口调用前未到获取配置信息,请联系管理员!"); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.getMainConfigInfo sql execute error;sql:" + selectMainSQL); + throw new Exception("接口调用前获取配置信息失败,请联系管理员!"); + } + + //获取明细表1 接口地址详细配置 + String selectDetail1SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail1SQL,mainConfigInfoId)){ + while(rs.next()){ + //参数名称 + String csmc = Util.null2String(rs.getString("csmc")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("csmc",csmc); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("fieldName",fieldName); + detailMap.put("zdgz",zdgz); + detailMap.put("zhgz",zhgz); + detailMap.put("zdysql",zdysql); + detailMap.put("viewType",viewType); + configInfoEntity.requestAddressConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail1SQL sql execute error;sql:" + selectDetail1SQL); + throw new Exception("接口调用前获取明细1配置信息失败,请联系管理员!"); + } + + //获取明细表2 请求头参数详细配置 + String selectDetail2SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt2 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail2SQL,mainConfigInfoId)){ + while(rs.next()){ + //参数名称 + String csmc = Util.null2String(rs.getString("csmc")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + logger.info("configInfo:requestHeaderConfigList.zdysql:" + zdysql); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("csmc",csmc); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("fieldName",fieldName); + detailMap.put("zdgz",zdgz); + detailMap.put("zhgz",zhgz); + detailMap.put("zdysql",zdysql); + detailMap.put("viewType",viewType); + logger.info("configInfo:requestHeaderConfigList.zdysql:" + zdysql); + configInfoEntity.requestHeaderConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail2SQL sql execute error;sql:" + selectDetail2SQL); + throw new Exception("接口调用前获取明细2配置信息失败,请联系管理员!"); + } + + //获取明细表3 请求体字段详细配置信息 + String selectDetail3SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt3 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail3SQL,mainConfigInfoId)){ + while(rs.next()){ + //xml节点序号 + String xmljdxh = Util.null2String(rs.getString("xmljdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("xmljdmc")); + //是否科目字段 + String sfkmzd = Util.null2String(rs.getString("sfkmzd")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("xmljdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Default_Line_Break,Default_Blank_Char); + sjtj = sjtj.replace(Default_Html_Blank,Default_Blank_Char); + sjtj = CommonUtil.fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("xmljdxh",xmljdxh); + dtMap.put("xmljdmc",xmljdmc); + dtMap.put("xmljdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("sfkmzd",sfkmzd); + dtMap.put("zdgz",zdgz); + dtMap.put("fieldName",fieldName); + if("".equals(fjdxh)){ + configInfoEntity.rootXmlConfigInfo = dtMap; + configInfoEntity.rootJsonConfigInfo.add(dtMap); + } + configInfoEntity.requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail3SQL sql execute error;sql:" + selectDetail3SQL); + throw new Exception("接口调用前获取明细3配置信息失败,请联系管理员!"); + } + + //获取明细表4 xml节点属性详细配置信息 + String selectDetail4SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt4 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail4SQL,mainConfigInfoId)){ + while(rs.next()){ + //属性名称 + String sxmc = Util.null2String(rs.getString("sxmc")); + //对应字段序号 + String dyzdxh = Util.null2String(rs.getString("dyzdxh")); + //表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //取值方式 + String zhgz = Util.null2String(rs.getString("zhgz")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("sxmc",sxmc); + detailMap.put("dyzdxh",dyzdxh); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("zhgz",zhgz); + detailMap.put("zdgz",zdgz); + detailMap.put("zdysql",zdysql); + detailMap.put("fieldName",fieldName); + detailMap.put("viewType",viewType); + configInfoEntity.xmlNodeAttrConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail4SQL sql execute error;sql:" + selectDetail4SQL); + throw new Exception("接口调用前获取明细4配置信息失败,请联系管理员!"); + } + + //获取明细表5 接口响应信息详细配置 + String selectDetail5SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt5 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail5SQL,mainConfigInfoId)){ + while(rs.next()){ + //响应字段名称 + String xyzdmc = Util.null2String(rs.getString("xyzdmc")); + //响应字段父节点路径 + String xyzdfjdlj = Util.null2String(rs.getString("xyzdfjdlj")); + //回写流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //是否为成功失败标识字段 + String sfwcgsbbszd = Util.null2String(rs.getString("sfwcgsbbszd")); + //是否为提示信息字段 + String sftsxxzd = Util.null2String(rs.getString("sftsxxzd")); + //成功标识 + String cgbs = Util.null2String(rs.getString("cgbs")); + //失败标识 + String sbbs = Util.null2String(rs.getString("sbbs")); + Map detailMap = new HashMap<>(); + detailMap.put("xyzdmc",xyzdmc); + detailMap.put("xyzdfjdlj",xyzdfjdlj); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("sfwcgsbbszd",sfwcgsbbszd); + detailMap.put("cgbs",cgbs); + detailMap.put("sbbs",sbbs); + detailMap.put("fieldName",fieldName); + detailMap.put("viewType",viewType); + detailMap.put("sftsxxzd",sftsxxzd); + configInfoEntity.responseConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail5SQL sql execute error;sql:" + selectDetail5SQL); + throw new Exception("接口调用前获取明细5配置信息失败,请联系管理员!"); + } + + } + + /** + * 根据流程类型、自定义参数找到对应的配置,生成请求-发送请求-处理响应 + * @param workflowId 流程类型 + * @param paramValue 自定义配置 + * @return {code:接口调用成功失败标识,message:接口响应提示信息} + * @throws Exception + */ + public Map execute(String workflowId, String paramValue) throws Exception { + this.workflowId = workflowId; + this.paramValue = paramValue; + //返回值 + Map result = new HashMap<>(); + result.put("code",CALL_SUCCESS); + result.put("message",""); + //数据库链接 + RecordSet rs = new RecordSet(); + //获取配置信息 + getConfigurationByWorkflowId(rs); + //根据配置的接口调用类型 查询数据 然后遍历每一行数据分别调用接口 + String getMainTableDataSql = "select * from " + baseArray[3] + " where id = " + baseArray[4]; + RecordSet detailRs = new RecordSet(); + switch(configInfoEntity.callType){ + case CALL_TYPE_ONLY_ONE: + if(!"".equals(configInfoEntity.sqlCondition)){ + getMainTableDataSql = getMainTableDataSql + configInfoEntity.sqlCondition; + } + if(rs.executeQuery(getMainTableDataSql)){ + if(rs.next()){ + mainTableData = DaoUtil.setRsToMap(rs); + commonExecute(rs,rs); + //如果配置为失败阻止流程提交 且接口响应失败 则返回信息 + if(SELECT_TYPE_IS.equals(configInfoEntity.failedAndReturn)){ + if(CALL_FAILED.equals(rarInfoEntity.resultValue)){ + result.put("code",CALL_FAILED); + result.put("message",rarInfoEntity.responseMessage); + return result; + } + } + } + } + break; + case CALL_TYPE_EVERY_DETAIL: + if("".equals(configInfoEntity.detailTableIndex)){ + throw new Exception("参数配置中未配置明细表下标!"); + } + if(rs.executeQuery(getMainTableDataSql)){ + if(rs.next()){ + mainTableData = DaoUtil.setRsToMap(rs); + } + } + String getDetailSql = "select id from " + baseArray[3] + "_dt" + configInfoEntity.detailTableIndex + " where mainid = " + baseArray[4]; + //如果配置了数据条件,则添加在sql后,用于筛选出需要调用接口的数据 + if(!"".equals(configInfoEntity.sqlCondition)){ + getDetailSql = getDetailSql + configInfoEntity.sqlCondition; + } + //查询需要调用接口的数据 然后遍历每一行数据分别调用接口 + if(detailRs.executeQuery(getDetailSql)){ + while(detailRs.next()){ + //数据id + commonExecute(rs,detailRs); + //如果配置为失败阻止流程提交 且接口响应失败 则返回信息 + if(SELECT_TYPE_IS.equals(configInfoEntity.failedAndReturn)){ + if(!CALL_SUCCESS.equals(rarInfoEntity.resultValue)){ + result.put("code",CALL_FAILED); + result.put("message",rarInfoEntity.responseMessage); + return result; + } + } + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.execute.getDetailSql sql execute error;sql:" + getDetailSql); + throw new Exception("action接口调用失败!"); + } + break; + default: + break; + } + return result; + } + + /** + * 处理请求 - 处理响应 + * @param rs + * @param detailRs + * @throws Exception + */ + public void commonExecute(RecordSet rs,RecordSet detailRs) throws Exception { + //请求地址处理 + dealUrl(rs,detailRs); + //请求头处理 + dealHeaders(rs,detailRs); + //请求报文处理 + dealRequestBody(rs,detailRs); + //发送请求 + sendRequest(); + //日志处理 + dealLog(rs); + //解析响应 + dealResponseInfo(detailRs,rs); + } + + /** + * 处理配置的接口地址,将参数转换为实际值 + * @param rs 数据库链接 + * @param detailRs 明细数据行 + */ + public void dealUrl(RecordSet rs,RecordSet detailRs) throws Exception { + if("".equals(configInfoEntity.callAddress)){ + throw new Exception("接口地址未配置!"); + } + int index = configInfoEntity.callAddress.indexOf(PARAM_BEGIN); + if(configInfoEntity.callAddress.indexOf(PARAM_BEGIN) > -1){ + //截取配置的请求地址中的参数项 + String paramKey = configInfoEntity.callAddress.substring(index + 1,configInfoEntity.callAddress.indexOf(PARAM_END)); + //获取字段对应的配置信息 + Map configMap = new HashMap<>(); + for(Map configInfo:configInfoEntity.requestAddressConfigList){ + if(paramKey.equals(configInfo.get("csmc"))){ + configMap = configInfo; + break; + } + } + //获取实际值 + String value = getFieldValue(configMap,rs,detailRs); + //将配置的地址中的参数替换成实际值 + configInfoEntity.callAddress = configInfoEntity.callAddress.replaceAll("\\{"+paramKey+PARAM_END,value); + dealUrl(rs,detailRs); + } + } + + /** + * 生成请求头参数 + * @param rs + * @param detailRs 数据id 空表示从主表取数据 其余值表示明细表id + */ + public void dealHeaders(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestHeaderConfigList){ + String fieldValue = getFieldValue(m, rs, detailRs); + rarInfoEntity.headers.put(m.get("csmc"),fieldValue); + } + } + + /** + * 生成请求报文 + * @param rs 数据库链接 + * @param detailRs 数据id + */ + public void dealRequestBody(RecordSet rs,RecordSet detailRs){ + //根据配置调用不同的方法生成相应报文 + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + recursionGenerateXML(null,null,rs,detailRs,0); + break; + case REQUEST_DATA_TYPE_JSON: + recursionGenerateJson(null,rs,detailRs,0); + break; + case REQUEST_DATA_TYPE_PAIR: + dealPairRequestData(rs,detailRs); + break; + default: + break; + } + } + + /** + * 以流的形式发送请求 方便控制编码格式 + * @throws Exception + */ + public void sendRequestWithUtf8() throws Exception { + OutputStreamWriter out = null; + BufferedReader in = null; + try{ + //创建URL对象 + URL url = new URL(configInfoEntity.callAddress); + //https信任所有证书设置 + HttpsURLConnection.setDefaultHostnameVerifier(NOT_VERYFY); + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + //请求协议 + String protocol = url.getProtocol(); + //打开链接 + URLConnection conn = url.openConnection(); + //设置请求头 + //设置通用的请求属性 + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("contentType", "UTF-8"); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + conn.setRequestProperty(key,rarInfoEntity.headers.get(key)); + } + } + //发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + //设置请求体信息 + String requestBody = ""; + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + requestBody = rarInfoEntity.xmlDoc.toString(); + break; + case REQUEST_DATA_TYPE_JSON: + requestBody = rarInfoEntity.jsonDoc.toString(); + break; + case REQUEST_DATA_TYPE_PAIR: + if(rarInfoEntity.pairList != null && rarInfoEntity.pairList.size() > 0){ + for(BasicNameValuePair pair:rarInfoEntity.pairList){ + if("".equals(requestBody)){ + requestBody = pair.getName() + "=" + pair.getValue(); + }else{ + requestBody = requestBody + "&" + pair.getName() + "=" + pair.getValue(); + } + } + } + break; + default: + break; + } + //发送请求 + out = null; + out = new OutputStreamWriter(conn.getOutputStream(),"UTF-8"); + out.write(requestBody); + out.flush(); + out.close(); + //获取响应码 + if("http".equals(protocol)){ + rarInfoEntity.responseCode = ((HttpURLConnection) conn).getResponseCode(); + }else{ + rarInfoEntity.responseCode = ((HttpsURLConnection) conn).getResponseCode(); + } + //获取响应体 + in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8")); + String line; + while ((line = in.readLine()) != null) { + rarInfoEntity.responseString += line; + } + switch (configInfoEntity.responseDataType){ + case REQUEST_DATA_TYPE_XML: + rarInfoEntity.responseXml = DocumentHelper.parseText(rarInfoEntity.responseString); + break; + case REQUEST_DATA_TYPE_JSON: + rarInfoEntity.responseJson = JSONObject.parseObject(rarInfoEntity.responseString); + break; + default: + break; + } + }catch(Exception e){ + logger.error("sendRequestWithUtf8 exception;info" + e.getMessage() + ";e:" + e); + rarInfoEntity.responseCode = 9999; + rarInfoEntity.responseString = e.getMessage(); + }finally { + if(in != null){ + in.close(); + } + if(out != null){ + out.close(); + } + } + } + + /** + * 发送请求 获取响应信息 + * @throws Exception + */ + public void sendRequest() throws Exception { + CloseableHttpClient client = createSSLClientDefault(); + try{ + switch(configInfoEntity.requestMethod){ + case REQUEST_METHOD_GET: + HttpGet get = new HttpGet(configInfoEntity.callAddress); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + get.setHeader(key,rarInfoEntity.headers.get(key)); + } + } + get.setHeader("Charset","UTF-8"); + rarInfoEntity.response = client.execute(get); + break; + case REQUEST_METHOD_POST: + HttpPost post = new HttpPost(configInfoEntity.callAddress); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + post.setHeader(key,rarInfoEntity.headers.get(key)); + } + } + post.setHeader("Charset","UTF-8"); + //请求信息设置 + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + StringEntity xmlEntity = new StringEntity(rarInfoEntity.xmlDoc.toString(), "UTF-8"); + post.setEntity(xmlEntity); + break; + case REQUEST_DATA_TYPE_JSON: + StringEntity jsonEntity = new StringEntity(rarInfoEntity.jsonDoc.toString(), "UTF-8"); + post.setEntity(jsonEntity); + break; + case REQUEST_DATA_TYPE_PAIR: + post.setEntity(new UrlEncodedFormEntity(rarInfoEntity.pairList, "UTF-8")); + break; + case REQUEST_DATA_TYPE_MULTIPARTFILE: + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(Charset.forName("utf-8")); + //加上此行代码解决返回中文乱码问题 + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + //文件流处理 + ImageFileManager imageFileManager = new ImageFileManager(); + for(Map map : rarInfoEntity.multiPartFileInfos){ + if(map != null){ + builder.addBinaryBody(map.get("xmljdmc"), imageFileManager.getInputStreamById(Integer.parseInt(map.get("imagefileid"))), ContentType.MULTIPART_FORM_DATA, map.get("imagefilename")); + } + } + HttpEntity entity = builder.build(); + post.setEntity(entity); + break; + default: + break; + } + rarInfoEntity.response = client.execute(post); + break; + default: + break; + } + //响应信息设置 + rarInfoEntity.responseCode = rarInfoEntity.response.getStatusLine().getStatusCode(); + logger.info("response code:" + rarInfoEntity.responseCode); + HttpEntity en = rarInfoEntity.response.getEntity(); + String content = EntityUtils.toString(en, "utf-8"); + logger.info("response entity:" + content); + switch (configInfoEntity.responseDataType){ + case RESPONSE_DATA_TYPE_XML: + rarInfoEntity.responseXml = DocumentHelper.parseText(content); + break; + case RESPONSE_DATA_TYPE_JSON: + rarInfoEntity.responseJson = JSONObject.parseObject(content); + break; + default: + rarInfoEntity.responseString = content; + break; + } + }catch(Exception e){ + logger.error("DealWorkFlowDataToRequestUtil.sendRequest exception;url:"+configInfoEntity.callAddress+";info:"+e.getMessage()+";e"+e); + rarInfoEntity.responseCode = 91919; + rarInfoEntity.resultValue = CALL_FAILED; + }finally { + client.close(); + } + } + + /** + * 记录日志 + * @param rs + */ + public void dealLog(RecordSet rs){ + try{ + if("".equals(configInfoEntity.logTableName) || "".equals(configInfoEntity.logRequestIdFieldName)){ + return; + } + //查询modeid + int modeId = -1; + String getModeIdSql = "select t1.id from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid " + + " where t2.tablename = '" + configInfoEntity.logTableName + "' and t1.isdelete = 0"; + if(rs.executeQuery(getModeIdSql)){ + if(rs.next()){ + modeId = Util.getIntValue(rs.getString("id"),0); + }else{ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.getModeIdSql execute success but found nothing;sql:" + getModeIdSql); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.getModeIdSql execute error;sql:" + getModeIdSql); + } + if(modeId == -1){ + return; + } + //日志表新增记录 + int dataId = -1; + dataId = mdu.getModeDataNewId(configInfoEntity.logTableName, modeId, 1, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString()); + //设置请求数据 + String requestHeaderString = ""; + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + requestHeaderString = requestHeaderString + key + ":" + rarInfoEntity.headers.get(key) + "\n"; + } + } + String requestString = ""; + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + requestString = requestString + rarInfoEntity.xmlDoc.asXML(); + break; + case REQUEST_DATA_TYPE_JSON: + requestString = requestString + rarInfoEntity.jsonDoc.toString(); + break; + case REQUEST_DATA_TYPE_PAIR: + requestString = requestString + rarInfoEntity.pairList.toString(); + break; + default: + break; + } + + //设置响应数据 + String responseString = ""; + switch (configInfoEntity.responseDataType){ + case RESPONSE_DATA_TYPE_XML: + responseString = rarInfoEntity.responseXml.asXML(); + break; + case RESPONSE_DATA_TYPE_JSON: + responseString = rarInfoEntity.responseJson.toString(); + break; + default: + responseString = rarInfoEntity.responseString; + break; + } + if(rarInfoEntity.responseCode == 9999){ + responseString = rarInfoEntity.responseString; + } + //更新日志表记录 + String updateLogTableSql = + "update " + + configInfoEntity.logTableName + + " set " + + configInfoEntity.logRequestIdFieldName + " = " + baseArray[0] + + "," + configInfoEntity.logResponseStatusFieldName + " = ? " + + "," + configInfoEntity.logRequestBodyFieldName + " = ? " + + "," + configInfoEntity.logResponseBodyFieldName + " = ? " + + "," + configInfoEntity.logRequestUrlFieldName + " = ? " + + "," + configInfoEntity.logRequestHeaderFieldName + " = ? " + + " where " + + "id = " + dataId; + if(!rs.executeUpdate(updateLogTableSql,rarInfoEntity.responseCode,requestString,responseString,configInfoEntity.callAddress,requestHeaderString)){ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.updateLogTableSql execute error;sql:" + updateLogTableSql); + } + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,dataId); + }catch(Throwable e){ + logger.error("DealWorkFlowDataToRequestUtil.dealLog execute error;requestId:" + baseArray[0] + "exception:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 解析响应信息 回写表单字段 + * @param detailRs + * @param rs + */ + public void dealResponseInfo(RecordSet detailRs,RecordSet rs){ + for(Map m : configInfoEntity.responseConfigList){ + //获取响应信息字段的值 + String value = ""; + switch (configInfoEntity.responseDataType){ + case REQUEST_DATA_TYPE_XML: + value = rarInfoEntity.responseXml.selectSingleNode(m.get("xyzdfjdlj")).getText(); + break; + case REQUEST_DATA_TYPE_JSON: + value = CommonUtil.getJsonValueByPath(rarInfoEntity.responseJson,m.get("xyzdfjdlj")); + break; + default: + break; + } + //将响应值回写表单字段 + if(!"".equals(m.get("fieldName"))){ + String updateDataSql = ""; + if(configInfoEntity.callType.equals(CALL_TYPE_ONLY_ONE)){ + updateDataSql = "update " + baseArray[3] + " set " + m.get("fieldName") + " = ? where id = " + baseArray[4]; + if(!rs.executeUpdate(updateDataSql,value)){ + logger.error("DealWorkFlowDataToRequestUtil.dealResponseInfo.updateDataSql execute error;sql:" + updateDataSql); + } + }else{ + updateDataSql = "update " + baseArray[3] + "_dt" + configInfoEntity.detailTableIndex + " set " + m.get("fieldName") + " = ? where id = " + Util.null2String(detailRs.getString("id")); + if(!rs.executeUpdate(updateDataSql)){ + logger.error("DealWorkFlowDataToRequestUtil.dealResponseInfo.updateDataSql execute error;sql:" + updateDataSql); + } + } + + } + //设置成功失败标识字段的值 + if(SELECT_TYPE_IS.equals(m.get("sfwcgsbbszd"))){ + if(!"".equals(m.get("cgbs"))){ + if(m.get("cgbs").equals(value)){ + rarInfoEntity.resultValue = CALL_SUCCESS; + }else{ + rarInfoEntity.resultValue = CALL_FAILED; + } + } + if(!"".equals(m.get("sbbs"))){ + if(m.get("cgbs").equals(value)){ + rarInfoEntity.resultValue = CALL_FAILED; + }else{ + rarInfoEntity.resultValue = CALL_SUCCESS; + } + } + } + //设置提示信息 + if(SELECT_TYPE_IS.equals(m.get("sftsxxzd"))){ + rarInfoEntity.responseMessage = value; + } + } + logger.info("dealResponseInfo end;rarInfoEntity.resultValue:" + rarInfoEntity.resultValue + ";rarInfoEntity.resultValue:" + rarInfoEntity.responseMessage); + } + + /** + * 根据配置信息 生成请求的键值对参数 + * @param rs + */ + public void dealPairRequestData(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestBodyConfigList){ + rarInfoEntity.pairList.add(new BasicNameValuePair(m.get("xmljdmc"),getFieldValue(m,rs,detailRs))); + } + } + + /** + * 根据配置信息 生成文件参数 + * @param rs + */ + public void dealMultipartFileRequestData(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestBodyConfigList){ + String docIds = getFieldValue(m,rs,detailRs); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArray = docIds.split(","); + for(String docId:docIdArray){ + if(docId != null && !"".equals(docId)){ + String getFileInfoSql = + "select " + + "t3.imagefileid as imagefileid," + + "t3.imagefilename as imagefilename " + + "from " + + "docdetail t1 " + + "inner join DocImageFile t2 on t2.docid = t1.id " + + "inner join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "where " + + "t1.id = ?"; + if(rs.executeQuery(getFileInfoSql,docId)){ + while(rs.next()){ + Map map = DaoUtil.setRsToMap(rs); + map.put("xmljdmc",m.get("xmljdmc")); + rarInfoEntity.multiPartFileInfos.add(map); + } + }else{ + logger.error("getFileInfoSql error;getFileInfoSql:" + getFileInfoSql + ";docId:" + docId); + } + } + } + } + } + logger.info("dealMultipartFileRequestData done;result:" + rarInfoEntity.multiPartFileInfos); + } + + /** + * 递归生成json报文 + * @param configMap + * @param rs + * @param detailRs + * @param sequence + * @return + */ + public Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence){ + if(configMap == null){ + for(Map configInfo:configInfoEntity.rootJsonConfigInfo){ + rarInfoEntity.jsonDoc.put(configInfo.get("xmljdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence)); + } + }else{ + switch(configMap.get("xmljdlx")){ + case NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + String value = getFieldValue(configMap,rs,detailRs); + return value; + case NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + if("true".equals(getFieldValue(configMap,rs,detailRs))){ + return true; + }else{ + return false; + } + case NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs); + DecimalFormat myformat= new DecimalFormat("#0.00"); + d = Double.parseDouble(myformat.format(f)); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : configInfoEntity.requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("xmljdxh"))) { + json.put(m.get("xmljdmc"),recursionGenerateJson(m,rs,detailRs,sequence)); + } + } + return json; + case NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : configInfoEntity.requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("xmljdxh"))) { + jsonObj.put(m.get("xmljdmc"),recursionGenerateJson(m,rs,detailRs,sequence)); + } + } + return jsonObj.toString(); + case NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs); + JSONArray stringArray = new JSONArray(); + for(String v : stringArrayValue.split(",")){ + stringArray.add(v); + } + return stringArray; + case NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + array.add(recursionGenerateJson(son,rs,detailRs,sequence)); + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + o.put(son.get("xmljdmc"),recursionGenerateJson(son,rs,detailRs,sequence)); + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + o.put(son.get("xmljdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence)); + } + } + array.add(o); + } + } + return array; + default: + break; + } + } + return null; + } + + /** + * 生成父节点的所有下级节点 + * @param parentMap 父节点的配置信息 + * @param parentNode 父节点对象 + * @param rs 数据库链接 + * @param detailRs 明细表数据id + * @param sequence 明细序列号 + */ + public void recursionGenerateXML(Map parentMap,Element parentNode,RecordSet rs, + RecordSet detailRs,int sequence){ + if(parentNode == null){ + Element root = rarInfoEntity.xmlDoc.addElement(configInfoEntity.rootXmlConfigInfo.get("xmljdmc")); + setElementAttribute(detailRs,rs,root, configInfoEntity.rootXmlConfigInfo); + recursionGenerateXML(configInfoEntity.rootXmlConfigInfo,root,rs,detailRs,0); + }else{ + //查找parentNode的所有子节点 + for(Map m : configInfoEntity.requestBodyConfigList){ + if(m.get("fjdxh").equals(parentMap.get("xmljdxh"))){ + switch(m.get("xmljdlx")){ + case NODE_TYPE_STRING: + Element ele = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailRs,rs,ele,m); + m.put("detailRowNum", String.valueOf(sequence)); + String value = getFieldValue(m,rs,detailRs); + ele.setText(value); + break; + case NODE_TYPE_OBJECT: + Element objEle = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailRs,rs,objEle,m); + recursionGenerateXML(m,objEle,rs,detailRs,sequence); + break; + case NODE_TYPE_ARRAY: + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + m.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(m.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + m.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + sequence = sequence + 1; + Element arrayEle = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailDataRs,rs,arrayEle,m); + recursionGenerateXML(m,arrayEle,rs,detailDataRs,sequence); + } + } + break; + default: + break; + } + } + } + } + } + + + /** + * 返回CloseableHttpClient 如果接口为https协议 信任所有证书 + * @return + * @throws MalformedURLException + */ + public CloseableHttpClient createSSLClientDefault() throws MalformedURLException { + URL url = new URL(configInfoEntity.callAddress); + String protocol = url.getProtocol(); + if("https".equals(protocol)){ + try { + //使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书 + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { + return true; + } + }).build(); + //NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何 + //有效的SSL会话并匹配到目标主机。 + HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return build; + } catch (Exception e) { + logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e); + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + }else{ + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + } + + private static final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + + private static final HostnameVerifier NOT_VERYFY = new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; + + /** + * 根据明细表3中的配置获取xml节点的属性 + * @param detailRs 明细表数据id + * @param rs 数据库链接 + * @param element xml节点 + * @param map 字段配置信息 + */ + public void setElementAttribute(RecordSet detailRs,RecordSet rs,Element element,Map map){ + //根据节点序号在明细配置中找到对应的配置项 并生成属性 + for(Map configInfo : configInfoEntity.xmlNodeAttrConfigList){ + if(configInfo.get("dyzdxh").equals(map.get("xmljdxh"))){ + String value = getFieldValue(configInfo,rs,detailRs); + element.addAttribute(configInfo.get("sxmc"),value); + } + } + } + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + * @return + */ + public String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs){ + //函数返回值 + String result = ""; + try{ + Map detailDataMap = DaoUtil.setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //数据条件 + String sjtj = configMap.get("sjtj"); + //不同转换规则处理 + switch(zhgz){ + case CHANGE_TYPE_MD5: + result = "Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes()); + break; + case CHANGE_TYPE_SUGGESTION: + result = CommonSqlUtil.getWorkFlowSuggestion(rsts,baseArray[0]); + break; + case CHANGE_TYPE_ROW_NUMBER: + result = configMap.get("detailRowNum"); + break; + case CHANGE_TYPE_FIXED: + result = configMap.get("zdysql"); + break; + case CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = mainTableData.get(fieldName); + }else{ + result = detailDataMap.get(fieldName); + } + break; + case CHANGE_TYPE_SQL: + String oldValue = ""; + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + } + } + break; + case CHANGE_TYPE_SUM: + String getSumSql = "select sum(" + fieldName + ") as val from " + baseArray[3] + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getSumSql = getSumSql + " " + sjtj; + } + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = Util.null2String(rs.getString("val")); + } + } + break; + case CHANGE_TYPE_STRING_ARRAY: + String getArraySql = "select " + fieldName + " as val from " + baseArray[3] + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getArraySql = getArraySql + " " + sjtj; + } + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = Util.null2String(rs.getString(1)); + }else{ + result = result + "," + Util.null2String(rs.getString(1)); + } + i = i + 1; + } + } + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public RecordSetTrans getRsts() { + return rsts; + } + + public void setRsts(RecordSetTrans rsts) { + this.rsts = rsts; + } + + public String[] getBaseArray() { + return baseArray; + } + + public void setBaseArray(String[] baseArray) { + this.baseArray = baseArray; + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/Log4JLogger.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/Log4JLogger.java new file mode 100644 index 0000000..60c944e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/Log4JLogger.java @@ -0,0 +1,89 @@ +package com.api.taojw.common.logging; + +/** + * 写日志(log4j) + * @date 2020-03-10 + * @version 1.0 + */ +public class Log4JLogger implements Logger { + + private org.apache.log4j.Logger log; + //类名 + private String classname; + + @Override + public String getClassname() { + return classname; + } + + @Override + public void setClassname(String classname) { + this.classname = classname; + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public void debug(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.debug(classname+"."+method+"() - "+message); + } + + @Override + public void debug(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.debug(classname+"."+method+"() - "+message, exception); + } + + @Override + public void info(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.info(classname+"."+method+"() - "+message); + } + + @Override + public void info(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.info(classname+"."+method+"() - "+message, exception); + } + + @Override + public void warn(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.warn(classname+"."+method+"() - "+message); + } + + @Override + public void warn(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.warn(classname+"."+method+"() - "+message, exception); + } + + @Override + public void error(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.error(classname+"."+method+"() - "+message); + } + + @Override + public void error(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.error(classname+"."+method+"() - "+message, exception); + } + + @Override + public void init(String name) { + if("".equals(name)) { + name = "cuslog"; + } + log = org.apache.log4j.Logger.getLogger(name); + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/Logger.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/Logger.java new file mode 100644 index 0000000..45f5f5a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/Logger.java @@ -0,0 +1,78 @@ +package com.api.taojw.common.logging; + +/** + * 日志接口(写) + * + * @author zwl + * @date 2020-03-10 + */ +public interface Logger extends weaver.integration.logging.Logger { + + public boolean isDebugEnabled(); + + /** + * 打印debug日志 + * @param message 消息 + */ + public void debug(Object message); + + /** + * 打印debug日志 + * @param message 消息 + * @param exception 异常 + */ + public void debug(Object message, Throwable exception); + + public boolean isInfoEnabled(); + + /** + * 打印info日志 + * @param message 消息 + */ + public void info(Object message); + + + /** + * 打印info日志 + * @param message 消息 + * @param exception 异常 + */ + public void info(Object message, Throwable exception); + + /** + * 打印warn日志 + * @param message 消息 + */ + public void warn(Object message); + + /** + * 打印warn日志 + * @param message 消息 + * @param exception 异常 + */ + public void warn(Object message, Throwable exception); + + /** + * 打印error日志 + * @param message + */ + public void error(Object message); + + /** + * 打印error日志 + * @param message 消息 + * @param exception 异常 + */ + public void error(Object message, Throwable exception); + + public String getClassname(); + + public void setClassname(String classname); + + /** + * 初始化 + * + * @param name logger名称 + */ + public void init(String name); +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/LoggerFactory.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/LoggerFactory.java new file mode 100644 index 0000000..4d6b4f7 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/LoggerFactory.java @@ -0,0 +1,50 @@ +package com.api.taojw.common.logging; + + +/** + * 日志工厂类 + * + * @author zwl + * @date 2020-03-10 + * @version 1.0 + */ +public class LoggerFactory { + private static final String loggerName = "cus"; + + public static Logger getLogger(String LogName, String clazz) { + if("".equals(LogName)) { + LogName = loggerName; + } + Logger logger = new Log4JLogger(); + logger.setClassname(clazz); + logger.init(LogName); + return logger; + } + + /** + * 获取指定类的logger对象 + * @param clazz + * @return + */ + public static Logger getLogger(Class clazz) { + return getLogger(loggerName,clazz.getCanonicalName()); + } + + /** + * 获取指定类的logger对象 + * @param className + * @return + */ + public static Logger getLogger(String className) { + return getLogger(loggerName,className); + } + /** + * 获取未指定指定类的logger对象 + * @param + * @return + */ + public static Logger getLogger() { + String className = Thread.currentThread().getStackTrace()[2].getClassName(); + return getLogger(loggerName, className); + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/MyLogger.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/MyLogger.java new file mode 100644 index 0000000..2ee8c08 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/logging/MyLogger.java @@ -0,0 +1,38 @@ +package com.api.taojw.common.logging; + +import org.apache.log4j.Logger; +import org.apache.log4j.*; + +import java.io.File; + +public class MyLogger { + + private static volatile Logger log = null; + + /** + * 获取日志对象 + * + * @return 日志对象 + */ + public static Logger getLogger() { + if (log == null) { + synchronized (MyLogger.class) { + if (log == null) { + DailyRollingFileAppender appender = new DailyRollingFileAppender(); + log = Logger.getLogger("tjw_cus"); + appender.setName("tjw_cus"); + appender.setEncoding("UTF-8"); + appender.setDatePattern("'_'yyyyMMdd'.log'"); + appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "tjw_cus" + File.separator + "cus.log"); + appender.setThreshold(Priority.DEBUG); + appender.setLayout(new PatternLayout("[%-5p][%d{yyyy-MM-dd HH:mm:ss,SSS}][Thread:%t][%F.%M:%L] ==> : %m %x %n")); + appender.setAppend(true); + appender.activateOptions(); + log.addAppender(appender); + log.setLevel(Level.INFO); + } + } + } + return log; + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/dianzhuang/cronjob/DealYlfCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/dianzhuang/cronjob/DealYlfCronJob.java new file mode 100644 index 0000000..62332e1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/dianzhuang/cronjob/DealYlfCronJob.java @@ -0,0 +1,85 @@ +package com.api.taojw.dianzhuang.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 电装项目 + * 处理医疗费标准表:uf_ylfjebzb + * 执行时间:每年1月1日凌晨1点自动执行 + * /*1、 该表中所有数据的主表【已使用金额】=0(数据库名:ysyje), + * 2、①当【赴任属性】(数据库名:frzx)为独身赴任(id=0)或単身赴任(id=1), + * ②且【本人赴任移动日】(数据库名:frrq)早于当前系统时间 + * + * 则明细表1,明细id=1的【月数】=12(数据库名:ys),【小计】=1000(数据库名:je); + * 主表【合计】=1000(数据库名:hj) + * 3、①当【赴任属性】(数据库名:frzx)为家族帯同(id=2), + * ②且【本人赴任移动日】(数据库名:frrq)早于当前系统时间 + * ③且【家属赴任移动日】(数据库名:jzfrydr)早于当前系统时间 + * + * 则明细表1,明细id=2的【月数】=12(数据库名:ys),【小计】=4000(数据库名:je); + * 主表【合计】=4000(数据库名:hj) + * */ +public class DealYlfCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info("DealYlfCronJob.execute start;"); + String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + + RecordSet rs = new RecordSet(); + String updateMainDataSql = "update uf_ylfjebzb set ysyje = 0 "; + DaoUtil.updateData(rs,updateMainDataSql); + + String updateMinDetailDataSql = + "update " + + "uf_ylfjebzb_dt1 " + + "set " + + "ys = 12," + + "je = 1000 " + + "where " + + "id in (select min(t1.id) as id from uf_ylfjebzb_dt1 t1 inner join uf_ylfjebzb t2 on t2.id = t1.mainid where (t2.frzx = 0 or t2.frzx = 1) and t2.frrq < ? )"; + DaoUtil.updateData(rs,updateMinDetailDataSql,currentDate); + updateMainDataSql = + "update " + + "uf_ylfjebzb " + + "set " + + "hj = ? " + + "where " + + "(frzx = 0 or frzx = 1) and frrq < ?"; + DaoUtil.updateData(rs,updateMainDataSql,1000,currentDate); + + String updateMaxDetailDataSql = + "update " + + "uf_ylfjebzb_dt1 " + + "set " + + "ys = 12," + + "je = 4000 " + + "where " + + "id in (select max(t1.id) as id from uf_ylfjebzb_dt1 t1 inner join uf_ylfjebzb t2 on t2.id = t1.mainid where t2.frzx = 2 and t2.frrq < ? and t2.jzfrydr < ?)"; + DaoUtil.updateData(rs,updateMaxDetailDataSql,currentDate,currentDate); + updateMainDataSql = + "update " + + "uf_ylfjebzb " + + "set " + + "hj = ? " + + "where " + + "frzx = 2 and frrq < ? and jzfrydr < ?"; + DaoUtil.updateData(rs,updateMainDataSql,4000,currentDate,currentDate); + + logger.info("DealYlfCronJob end."); + }catch(Throwable e){ + logger.error("DealYlfCronJob exception:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/action/CallNcAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/action/CallNcAction.java new file mode 100644 index 0000000..0f9ae16 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/action/CallNcAction.java @@ -0,0 +1,146 @@ +package com.api.taojw.fute.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.fute.util.FuteHttpUtil; +import org.apache.http.Header; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 福特action + * 调用NC接口 + */ +public class CallNcAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String hjndColumnName = ""; + private String pzhColumnName = ""; + + private String type = ""; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + private String configId = ""; + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + public String getHjndColumnName() { + return hjndColumnName; + } + + public void setHjndColumnName(String hjndColumnName) { + this.hjndColumnName = hjndColumnName; + } + + public String getPzhColumnName() { + return pzhColumnName; + } + + public void setPzhColumnName(String pzhColumnName) { + this.pzhColumnName = pzhColumnName; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + //String configId = CommonSqlUtil.getSystemParamValue("sapNcJsonConfigId",rs); + String[] baseInfo = WorkFlowDataToJsonUtil.getRequestBaseInfo(requestId,requestInfo.getRsTrans(),"",requestInfo.getRequestManager().getBillTableName()); + JSONObject param = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,baseInfo); + JSONObject requestParameter = param.getJSONObject("REQUEST_PARAMETER"); + requestParameter.put("TYPE",type); + requestParameter.put("SIMU_POST","2"); + param.put("REQUEST_PARAMETER",requestParameter); + + //调用sap接口 + String token = FuteHttpUtil.getToken(); + String sapNcUrl = CommonSqlUtil.getSystemParamValue("sapTempNcUrl",rs); + Map headers = new HashMap<>(); + headers.put("Authorization","Bearer " + token); + String ncCheckSign = CommonSqlUtil.getSystemParamValue("ncCheckSign",rs); + if("1".equals(ncCheckSign)){ + Map getHeaders = new HashMap<>(); + getHeaders.put("Authorization","Bearer " + token); + String saptokenheader = CommonSqlUtil.getSystemParamValue("saptokenheader",rs); + getHeaders.put("X-CSRF-Token",saptokenheader); + + Map get = TjwHttpUtil.sendHttpRequest(sapNcUrl, param.toJSONString(), "getWithEntity", ContentType.APPLICATION_JSON, getHeaders); + Header[] responseHeaders = (Header[]) get.get("responseHeaders"); + Header[] allHeaders = responseHeaders; + String thing = ""; + for(Header header : allHeaders){ + if("x-csrf-token".equals(header.getName())){ + thing = header.getValue(); + } + } + List cookies = new ArrayList<>(); + for(int i = 0;i < allHeaders.length;i ++){ + Header h = allHeaders[i]; + if("set-cookie".equalsIgnoreCase(h.getName())){ + cookies.add(h.getValue()); + } + } + logger.info("thing:" + thing); + headers.put("X-CSRF-Token",thing); + StringBuffer cookisStr = new StringBuffer(""); + for (String str : cookies) { + cookisStr.append(str.substring(0, str.indexOf(";"))).append(";"); + } + String endCookie = cookisStr.substring(0, cookisStr.length()); + logger.info("endCookie:" + endCookie); + headers.put("Cookie", endCookie); + } + Map post = TjwHttpUtil.sendHttpRequest(sapNcUrl, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String resData = (String) post.get("data"); + JSONObject result = JSONObject.parseObject(resData); + + if("S".equals(result.getString("RETURN_CODE"))){ + String updateSql = "update " + billTableName + " set "+hjndColumnName+" = ?,"+pzhColumnName+" = ? where requestid = ?"; + JSONObject returnResult = result.getJSONObject("RETURN_RESULT"); + String hjnd = returnResult.getString("GJAHR"); + String pzh = returnResult.getString("BELNR"); + DaoUtil.updateData(rs,updateSql,hjnd,pzh,requestId); + return Action.SUCCESS; + }else{ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口响应异常;对方接口响应RETURN_MESSAGE:" + result.getString("RETURN_MESSAGE")); + return Action.FAILURE_AND_CONTINUE; + } + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent(this.getClass() + "Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/action/FkAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/action/FkAction.java new file mode 100644 index 0000000..1316f2d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/action/FkAction.java @@ -0,0 +1,162 @@ +package com.api.taojw.fute.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.fute.util.FuteHttpUtil; +import org.apache.http.Header; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.taojw.common.CommonSqlUtil; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 福特action + * 价格调整审批反馈 + */ +public class FkAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String configId = ""; + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + private String url = ""; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + private String condition = ""; + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getWorkFlowIdSql = "select workflowid from workflow_requestbase where requestid = ?"; + Map data = DaoUtil.getFirstData(rs, getWorkFlowIdSql, requestId); + String workFlowId = data.get("workflowid"); + String getSapChSql = "select sapch from " + requestInfo.getRequestManager().getBillTableName() + " where requestid = ?"; + Map firstData2 = DaoUtil.getFirstData(rs, getSapChSql, requestId); + String sapch = firstData2.get("sapch"); + //sap撤回时不走action + if("1".equals(sapch)){ + return Action.SUCCESS; + } + + if(condition != null && !"".equals(condition)){ + String src = requestInfo.getRequestManager().getSrc(); + if(!src.equals(condition)){ + return Action.SUCCESS; + } + } + String remark = ""; + if("withdraw".equals(condition)){ + String getRemarkSql = "select remark from workflow_requestlog where requestid = ? order by operatedate desc,operatetime desc"; + RecordSetTrans rsTrans = requestInfo.getRsTrans(); + if(rsTrans == null){ + rsTrans = new RecordSetTrans(); + if(rsTrans.executeQuery(getRemarkSql,requestId)){ + if(rsTrans.next()){ + remark = Util.null2String(rsTrans.getString("remark")); + } + } + } + }else{ + remark = requestInfo.getRequestManager().getRemark(); + } + + String token = FuteHttpUtil.getToken(); + + String[] baseInfo = WorkFlowDataToJsonUtil.getRequestBaseInfo(requestId,requestInfo.getRsTrans(),remark,requestInfo.getRequestManager().getBillTableName()); + JSONObject param = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,baseInfo); + Map headers = new HashMap<>(); + + String checkSign = CommonSqlUtil.getSystemParamValue("sfkqtosapsign",rs); + if("1".equals(checkSign)){ + Map getHeaders = new HashMap<>(); + getHeaders.put("Authorization","Bearer " + token); + String saptokenheader = CommonSqlUtil.getSystemParamValue("saptokenheader",rs); + getHeaders.put("X-CSRF-Token",saptokenheader); + + Map get = TjwHttpUtil.sendHttpRequest(url, param.toJSONString(), "getWithEntity", ContentType.APPLICATION_JSON, getHeaders); + Header[] responseHeaders = (Header[]) get.get("responseHeaders"); + Header[] allHeaders = responseHeaders; + String thing = ""; + for(Header header : allHeaders){ + if("x-csrf-token".equals(header.getName())){ + thing = header.getValue(); + } + } + List cookies = new ArrayList<>(); + for(int i = 0;i < allHeaders.length;i ++){ + Header h = allHeaders[i]; + if("set-cookie".equalsIgnoreCase(h.getName())){ + cookies.add(h.getValue()); + } + } + logger.info("thing:" + thing); + headers.put("X-CSRF-Token",thing); + StringBuffer cookisStr = new StringBuffer(""); + for (String str : cookies) { + cookisStr.append(str.substring(0, str.indexOf(";"))).append(";"); + } + String endCookie = cookisStr.substring(0, cookisStr.length()); + logger.info("endCookie:" + endCookie); + headers.put("Cookie", endCookie); + } + + headers.put("Authorization","Bearer " + token); + Map cusLogInfo = new HashMap<>(); + cusLogInfo.put("lclx",workFlowId); + logger.info("workFlowId:" + workFlowId); + Map post = TjwHttpUtil.sendHttpRequestWithCusLog(url, param.toJSONString(), "post", ContentType.APPLICATION_JSON, headers,cusLogInfo); + + JSONObject result = JSONObject.parseObject((String) post.get("data")); + + if("S".equals(result.getString("RETURN_CODE"))){ + return Action.SUCCESS; + }else{ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口响应异常;对方接口响应RETURN_MESSAGE:" + result.getString("RETURN_MESSAGE")); + return Action.FAILURE_AND_CONTINUE; + } + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent(this.getClass() + "Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/api/CusCreateWorkFlowApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/api/CusCreateWorkFlowApi.java new file mode 100644 index 0000000..23705c5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/api/CusCreateWorkFlowApi.java @@ -0,0 +1,220 @@ +package com.api.taojw.fute.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.fute.util.SignUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.workflow.entity.publicApi.PAResponseEntity; +import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity; +import com.engine.workflow.publicApi.WorkflowRequestOperatePA; +import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; + +/** + * 福特 + * 封装创建流程接口 + */ +@Path("/futetjw") +public class CusCreateWorkFlowApi { + + Logger logger = MyLogger.getLogger(); + + public static WorkflowRequestOperatePA WRO = null; + + static { + WRO = getRequestOperatePA(); + } + + private static WorkflowRequestOperatePA getRequestOperatePA() { + return (WorkflowRequestOperatePAImpl) ServiceUtil.getService(WorkflowRequestOperatePAImpl.class); + } + + @POST + @Path("/createWorkFlow") + @Produces(MediaType.APPLICATION_JSON) + public String createWorkFlow(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody String objParam){ + logger.info("CusCreateWorkFlowApi.createWorkFlow begin;objParam:" + objParam); + JSONObject obj = JSONObject.parseObject(objParam); + logger.info("param:" + obj.toJSONString()); + + try{ + RecordSet rs = new RecordSet(); + String workCode = Util.null2String(obj.getString("cusWorkCode")); + String title = Util.null2String(obj.getString("requestName")); + String logId = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + workCode + Util.getRandom(); + logger.info("logId:" + logId); + + String checkSign = CommonSqlUtil.getSystemParamValue("sfkqsign",rs); + if("1".equals(checkSign)){ + String headerString = request.getHeader("SAPSignatureValue"); + //String bodyString = obj.toString(); + boolean b = SignUtil.checkSign(objParam, headerString); + if(!b){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code","ERROR"); + jsonObject.put("cusErrMsg","流程创建失败,验签失败!logId:"+logId); + return jsonObject.toJSONString(); + } + } + + String workFlowId = Util.null2String(obj.getString("workflowId")); + String tableName = CommonSqlUtil.getTableNameByWorkflowId(workFlowId,rs); + JSONArray mainData = obj.getJSONArray("mainData"); + String theirRequestId = ""; + for(int i = 0;i < mainData.size();i++){ + JSONObject o = mainData.getJSONObject(i); + if("SAPrequestid".equalsIgnoreCase(o.getString("fieldName")) || "pvrequestid".equalsIgnoreCase(o.getString("fieldName")) || "qvrequestid".equalsIgnoreCase(o.getString("fieldName"))){ + theirRequestId = o.getString("fieldValue"); + } + } + + String checkSql1 = "select count(1) as c,max(requestid) as requestid from " + tableName + " where SAPrequestid = ? "; + String checkSql2 = "select count(1) as c,max(requestid) as requestid from " + tableName + " where pvrequestid = ? "; + String checkSql3 = "select count(1) as c,max(requestid) as requestid from " + tableName + " where qvrequestid = ? "; + String oldRequestId = ""; + String getIdSql1 = "select requestid from " + tableName + " where SAPrequestid = ? "; + String getIdSql2 = "select requestid from " + tableName + " where pvrequestid = ? "; + String getIdSql3 = "select requestid from " + tableName + " where qvrequestid = ? "; + Map firstData2 = DaoUtil.getFirstData(rs, getIdSql1, theirRequestId); + if(firstData2.get("requestid") != null && !"".equals(firstData2.get("requestid"))){ + oldRequestId = firstData2.get("requestid"); + } + firstData2 = DaoUtil.getFirstData(rs, getIdSql2, theirRequestId); + if(firstData2.get("requestid") != null && !"".equals(firstData2.get("requestid"))){ + oldRequestId = firstData2.get("requestid"); + } + firstData2 = DaoUtil.getFirstData(rs, getIdSql3, theirRequestId); + if(firstData2.get("requestid") != null && !"".equals(firstData2.get("requestid"))){ + oldRequestId = firstData2.get("requestid"); + } + + if(DaoUtil.isDataExists(rs,checkSql1,theirRequestId) || DaoUtil.isDataExists(rs,checkSql2,theirRequestId) || DaoUtil.isDataExists(rs,checkSql3,theirRequestId)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code","C"); + JSONObject o = new JSONObject(); + o.put("requestid",oldRequestId); + jsonObject.put("data",o); + jsonObject.put("cusErrMsg","流程已创建,请勿重复提交!logId:"+logId); + return jsonObject.toJSONString(); + } + + String getUserIdSql = "select id,departmentid from hrmresource where workcode = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getUserIdSql, workCode); + int userId = Integer.parseInt(firstData.get("id")); + String departmentid = firstData.get("departmentid"); + User user = new User(userId); + ReqOperateRequestEntity entity = JSONObject.parseObject(String.valueOf(obj), ReqOperateRequestEntity.class); + entity.setUserId(userId); + PAResponseEntity paResponseEntity = WRO.doCreateRequest(user, entity); + String result = JSONObject.toJSONString(paResponseEntity); + JSONObject jsonObject = JSONObject.parseObject(result); + String code = jsonObject.getString("code"); + if(!"SUCCESS".equals(code)){ + jsonObject.put("cusErrMsg","流程创建失败!logId:"+logId); + }else{ + String requestId = jsonObject.getJSONObject("data").getString("requestid"); + //更新主表 申请人、申请部门、申请时间字段 + //String workFlowId = obj.getString("workflowId"); + String getTableSql = "select tablename from workflow_bill where id = (select formid from workflow_base where id = ?)"; + Map firstData1 = DaoUtil.getFirstData(rs, getTableSql, workFlowId); + String tablename = firstData1.get("tablename"); + String updateDataSql = "update " + tablename + " set Title = ?,Applicant = ?,ApplicationDepartment = ?,ApplicationDate = ?,cusWorkCode = ? where requestid = ?"; + DaoUtil.updateData(rs,updateDataSql,title,userId,departmentid,new SimpleDateFormat("yyyy-MM-dd").format(new Date()),workCode,requestId); + } + logger.info("result:"+jsonObject.toJSONString()); + return jsonObject.toJSONString(); + }catch(Throwable e){ + logger.error("CusCreateWorkFlowApi.createWorkFlow exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + @POST + @Path("/withDrawWorkFlow") + @Produces(MediaType.APPLICATION_JSON) + public String withDrawWorkFlow(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody String objParam){ + logger.info("CusCreateWorkFlowApi.withDrawWorkFlow begin;"); + JSONObject obj = JSONObject.parseObject(objParam); + logger.info("param:" + obj.toJSONString()); + try{ + RecordSet rs = new RecordSet(); + + String workCode = Util.null2String(obj.getString("cusWorkCode")); + String logId = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + workCode + Util.getRandom(); + logger.info("logId:" + logId); + + String checkSign = CommonSqlUtil.getSystemParamValue("sfkqsign",rs); + if("1".equals(checkSign)){ + String headerString = request.getHeader("SAPSignatureValue"); + String bodyString = obj.toString(); + boolean b = SignUtil.checkSign(objParam, headerString); + if(!b){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code","ERROR"); + jsonObject.put("cusErrMsg","流程创建失败,验签失败!logId:"+logId); + return jsonObject.toJSONString(); + } + } + + String requestId = Util.null2String(obj.getString("requestId")); + //若当前是在撤回状态 则返回一个C + String getCurrentNodeTypeSql = + "select currentnodetype from workflow_requestbase where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getCurrentNodeTypeSql, requestId); + String currentnodetype = Util.null2String(firstData1.get("currentnodetype")); + if("0".equals(currentnodetype)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code","C"); + jsonObject.put("cusErrMsg","流程当前已被撤回,请勿重复撤回!"); + logger.info("result:"+jsonObject); + return jsonObject.toJSONString(); + } + + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + String getUserIdSql = "select id from hrmresource where workcode = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getUserIdSql, workCode); + int userId = Integer.parseInt(firstData.get("id")); + User user = new User(userId); + ReqOperateRequestEntity entity = JSONObject.parseObject(String.valueOf(obj), ReqOperateRequestEntity.class); + entity.setUserId(userId); + + String updateSql = "update " + tableName + " set sapch = 1 where requestid = ?"; + DaoUtil.updateData(rs,updateSql,requestId); + + PAResponseEntity paResponseEntity = WRO.withdrawRequest(user, entity); + String result = JSONObject.toJSONString(paResponseEntity); + JSONObject jsonObject = JSONObject.parseObject(result); + String code = jsonObject.getString("code"); + + if(!"SUCCESS".equals(code)){ + jsonObject.put("cusErrMsg","流程撤回失败!logId:"+logId); + } + String updateSql2 = "update " + tableName + " set sapch = 2 where requestid = ?"; + DaoUtil.updateData(rs,updateSql2,requestId); + + logger.info("result:"+result); + return jsonObject.toJSONString(); + }catch(Throwable e){ + logger.error("CusCreateWorkFlowApi.withDrawWorkFlow exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/api/FuteTjwApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/api/FuteTjwApi.java new file mode 100644 index 0000000..7409d22 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/api/FuteTjwApi.java @@ -0,0 +1,118 @@ +package com.api.taojw.fute.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.fute.util.FuteHttpUtil; +import org.apache.http.Header; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 福特 + * + */ +@Path("/futetjwnc") +public class FuteTjwApi { + + Logger logger = MyLogger.getLogger(); + + //流程中点击按钮 调用前置NC接口 + @POST + @Path("/callNccFirst") + @Produces(MediaType.APPLICATION_JSON) + public String callNccFirst(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + JSONObject param = new JSONObject(); + try{ + RecordSet rs = new RecordSet(); + String configId = request.getParameter("configId"); + String requestId = request.getParameter("requestId"); + String type = request.getParameter("type"); + logger.info("FuteTjwApi.callNccFirst begin;requestId:" + requestId + ";configId:" + configId); + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + base_array[0] = requestId; + base_array[1] = ""; + base_array[2] = ""; + base_array[3] = tableName; + + String getIdSql = "select id from " + tableName + " where requestid = ?"; + Map firstData3 = DaoUtil.getFirstData(rs, getIdSql, requestId); + String id = Util.null2String(firstData3.get("id")); + base_array[4] = id; + param = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,base_array); + JSONObject requestParameter = param.getJSONObject("REQUEST_PARAMETER"); + requestParameter.put("TYPE",type); + param.put("REQUEST_PARAMETER",requestParameter); + //param.put("SIMU_POST","1"); + + //调用sap接口 + String token = FuteHttpUtil.getToken(); + String sapNcUrl = CommonSqlUtil.getSystemParamValue("sapTempNcUrl",rs); + Map headers = new HashMap<>(); + headers.put("Authorization","Bearer " + token); + + String ncCheckSign = CommonSqlUtil.getSystemParamValue("ncCheckSign",rs); + if("1".equals(ncCheckSign)){ + Map getHeaders = new HashMap<>(); + getHeaders.put("Authorization","Bearer " + token); + String saptokenheader = CommonSqlUtil.getSystemParamValue("saptokenheader",rs); + getHeaders.put("X-CSRF-Token",saptokenheader); + + Map get = TjwHttpUtil.sendHttpRequest(sapNcUrl, param.toJSONString(), "getWithEntity", ContentType.APPLICATION_JSON, getHeaders); + Header[] responseHeaders = (Header[]) get.get("responseHeaders"); + Header[] allHeaders = responseHeaders; + String thing = ""; + for(Header header : allHeaders){ + if("x-csrf-token".equals(header.getName())){ + thing = header.getValue(); + } + } + List cookies = new ArrayList<>(); + for(int i = 0;i < allHeaders.length;i ++){ + Header h = allHeaders[i]; + if("set-cookie".equalsIgnoreCase(h.getName())){ + cookies.add(h.getValue()); + } + } + logger.info("thing:" + thing); + headers.put("X-CSRF-Token",thing); + StringBuffer cookisStr = new StringBuffer(""); + for (String str : cookies) { + cookisStr.append(str.substring(0, str.indexOf(";"))).append(";"); + } + String endCookie = cookisStr.substring(0, cookisStr.length()); + logger.info("endCookie:" + endCookie); + headers.put("Cookie", endCookie); + } + + Map post = TjwHttpUtil.sendHttpRequest(sapNcUrl, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String resData = (String) post.get("data"); + JSONObject resJson = JSONObject.parseObject(resData); + result.put("result",resJson); + }catch(Throwable e){ + logger.error("FuteTjwApi.callNccFirst exception;message:" + e.getMessage() + ";e:" + e); + } + result.put("param",param.getJSONObject("REQUEST_PARAMETER")); + return result.toJSONString(); + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/cronjob/CallSapGetDataToMode.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/cronjob/CallSapGetDataToMode.java new file mode 100644 index 0000000..01648ca --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/cronjob/CallSapGetDataToMode.java @@ -0,0 +1,390 @@ +package com.api.taojw.fute.cronjob; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.*; +import com.api.taojw.common.logging.MyLogger; +import com.api.taojw.fute.util.FuteHttpUtil; +import org.apache.http.Header; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 福特 + * 定时任务调接口同步数据到建模 + */ +public class CallSapGetDataToMode extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String SYSID = ""; + private String objectId = ""; + private String posid = ""; + private String extendby1 = ""; + private String extendby2 = ""; + private String ktopl = ""; + private String bukrs = ""; + private String lifnr = ""; + private String kokrs = ""; + private String auart = ""; + private String saknr = ""; + private String prctr = ""; + private String kostl = ""; + private String dateStringMode = ""; + private String modeKeyName = ""; + private String modeTableName = ""; + private String jsonConfigId = ""; + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getPosid() { + return posid; + } + + public void setPosid(String posid) { + this.posid = posid; + } + + public String getExtendby1() { + return extendby1; + } + + public void setExtendby1(String extendby1) { + this.extendby1 = extendby1; + } + + public String getExtendby2() { + return extendby2; + } + + public void setExtendby2(String extendby2) { + this.extendby2 = extendby2; + } + + public String getKtopl() { + return ktopl; + } + + public void setKtopl(String ktopl) { + this.ktopl = ktopl; + } + + public String getBukrs() { + return bukrs; + } + + public void setBukrs(String bukrs) { + this.bukrs = bukrs; + } + + public String getLifnr() { + return lifnr; + } + + public void setLifnr(String lifnr) { + this.lifnr = lifnr; + } + + public String getKokrs() { + return kokrs; + } + + public void setKokrs(String kokrs) { + this.kokrs = kokrs; + } + + public String getAuart() { + return auart; + } + + public void setAuart(String auart) { + this.auart = auart; + } + + public String getSaknr() { + return saknr; + } + + public void setSaknr(String saknr) { + this.saknr = saknr; + } + + public String getPrctr() { + return prctr; + } + + public void setPrctr(String prctr) { + this.prctr = prctr; + } + + public String getKostl() { + return kostl; + } + + public void setKostl(String kostl) { + this.kostl = kostl; + } + + public String getDateStringMode() { + return dateStringMode; + } + + public void setDateStringMode(String dateStringMode) { + this.dateStringMode = dateStringMode; + } + + public String getModeTableName() { + return modeTableName; + } + + public void setModeTableName(String modeTableName) { + this.modeTableName = modeTableName; + } + + public String getJsonConfigId() { + return jsonConfigId; + } + + public void setJsonConfigId(String jsonConfigId) { + this.jsonConfigId = jsonConfigId; + } + + public String getModeKeyName() { + return modeKeyName; + } + + public void setModeKeyName(String modeKeyName) { + this.modeKeyName = modeKeyName; + } + + public String getSYSID() { + return SYSID; + } + + public void setSYSID(String SYSID) { + this.SYSID = SYSID; + } + + @Override + public void execute() { + try{ + logger.info(this.getClass() + " begin;" ); + RecordSet rs = new RecordSet(); + String token = FuteHttpUtil.getToken(); + //调用sap接口时是否开启加签 + String sapCronjobCheckSign = CommonSqlUtil.getSystemParamValue("sapCronjobCheckSign",rs); + //sap接口地址 + String sapDataUrl = CommonSqlUtil.getSystemParamValue("sapDataUrl",rs); + //sap接口入参 + JSONObject param = new JSONObject(); + param.put("REQUEST_CODE","IF0280"); + JSONObject requestParameter = new JSONObject(); + + if(objectId != null && !"".equals(objectId)){ + requestParameter.put("OBJECTID",objectId); + } + if(SYSID != null && !"".equals(SYSID)){ + requestParameter.put("SYSID",SYSID); + } + if("01".equals(objectId)){ + if(bukrs != null && !"".equals(bukrs)){ + requestParameter.put("BUKRS",bukrs); + }else{ + requestParameter.put("BUKRS",""); + } + if(lifnr != null && !"".equals(lifnr)){ + requestParameter.put("LIFNR",lifnr); + }else{ + requestParameter.put("LIFNR",""); + } + } + if("02".equals(objectId)){ + if(kokrs != null && !"".equals(kokrs)){ + requestParameter.put("KOKRS",kokrs); + }else{ + requestParameter.put("KOKRS",""); + } + if(auart != null && !"".equals(auart)){ + requestParameter.put("AUART",auart); + }else{ + requestParameter.put("AUART",""); + } + } + if("03".equals(objectId)){ + if(posid != null && !"".equals(posid)){ + requestParameter.put("POSID",posid); + }else{ + requestParameter.put("POSID",""); + } + } + if("04".equals(objectId)){ + if(ktopl != null && !"".equals(ktopl)){ + requestParameter.put("KTOPL",ktopl); + }else{ + requestParameter.put("KTOPL",""); + } + if(saknr != null && !"".equals(saknr)){ + requestParameter.put("SAKNR",saknr); + }else{ + requestParameter.put("SAKNR",""); + } + if(bukrs != null && !"".equals(bukrs)){ + requestParameter.put("BUKRS",bukrs); + }else{ + requestParameter.put("BUKRS",""); + } + } + if("05".equals(objectId)){ + if(kokrs != null && !"".equals(kokrs)){ + requestParameter.put("KOKRS",kokrs); + }else{ + requestParameter.put("KOKRS",""); + } + if(prctr != null && !"".equals(prctr)){ + requestParameter.put("PRCTR",prctr); + }else{ + requestParameter.put("PRCTR",""); + } + } + if("06".equals(objectId)){ + if(kokrs != null && !"".equals(kokrs)){ + requestParameter.put("KOKRS",kokrs); + }else{ + requestParameter.put("KOKRS",""); + } + if(kostl != null && !"".equals(kostl)){ + requestParameter.put("KOSTL",kostl); + }else{ + requestParameter.put("KOSTL",""); + } + } + String _extendby1 = ""; + if("".equals(extendby1) || extendby1 == null){ + //extendby1为空时 传入昨天的日期 + //_extendby1 = new SimpleDateFormat(dateStringMode).format(new SimpleDateFormat("yyyy-MM-dd").parse(TjwTimeUtil.getLastDay())); + //extendby1为空时 传入上次同步的结束日期 + String getLastDateSql = "select max(sjjsrq) as rq from uf_updatelog where lx = ?"; + Map firstData = DaoUtil.getFirstData(rs, getLastDateSql, objectId); + _extendby1 = firstData.get("rq"); + if(_extendby1 == null || "".equals(_extendby1)){ + //定时任务不配参数 之前也没执行过 那就传昨天的日期 + _extendby1 = new SimpleDateFormat(dateStringMode).format(new SimpleDateFormat("yyyy-MM-dd").parse(TjwTimeUtil.getLastDay())); + } + requestParameter.put("extendby1",_extendby1); + }else{ + _extendby1 = extendby1; + requestParameter.put("extendby1",extendby1); + } + String _extendby2 = ""; + if("".equals(extendby2) || extendby2 == null){ + //extendby2为空时 传入今天的日期 + _extendby2 = new SimpleDateFormat(dateStringMode).format(new Date()); + requestParameter.put("extendby2",_extendby2); + }else{ + _extendby2 = extendby2; + requestParameter.put("extendby2",extendby2); + } + param.put("REQUEST_PARAMETER",requestParameter); + //sap请求头参数 + Map headers = new HashMap<>(); + if("1".equals(sapCronjobCheckSign)){ + Map getHeaders = new HashMap<>(); + getHeaders.put("Authorization","Bearer " + token); + String saptokenheader = CommonSqlUtil.getSystemParamValue("saptokenheader",rs); + getHeaders.put("X-CSRF-Token",saptokenheader); + Map get = TjwHttpUtil.sendHttpRequest(sapDataUrl, param.toJSONString(), "getWithEntity", ContentType.APPLICATION_JSON, getHeaders); + Header[] responseHeaders = (Header[]) get.get("responseHeaders"); + Header[] allHeaders = responseHeaders; + String thing = ""; + for(Header header : allHeaders){ + if("x-csrf-token".equals(header.getName())){ + thing = header.getValue(); + } + } + List cookies = new ArrayList<>(); + for(int i = 0;i < allHeaders.length;i ++){ + Header h = allHeaders[i]; + if("set-cookie".equalsIgnoreCase(h.getName())){ + cookies.add(h.getValue()); + } + } + logger.info("thing:" + thing); + headers.put("X-CSRF-Token",thing); + StringBuffer cookisStr = new StringBuffer(""); + for (String str : cookies) { + cookisStr.append(str.substring(0, str.indexOf(";"))).append(";"); + } + String endCookie = cookisStr.substring(0, cookisStr.length()); + logger.info("endCookie:" + endCookie); + headers.put("Cookie", endCookie); + } + headers.put("Authorization","Bearer " + token); + + + String[] keyArr = modeKeyName.split(","); + List keys = new ArrayList<>(); + for(String key : keyArr){ + keys.add(key); + } + + Map cusLogInfo = new HashMap<>(); + Map post = TjwHttpUtil.sendHttpRequestWithCusLog(sapDataUrl, param.toJSONString(), "post", ContentType.APPLICATION_JSON, headers,cusLogInfo); + JSONObject result = JSONObject.parseObject((String) post.get("data")); + JSONArray RETURN_RESULT = new JSONArray(); + try{ + RETURN_RESULT = result.getJSONArray("RETURN_RESULT"); + }catch (Throwable e){ + RETURN_RESULT = new JSONArray(); + } + String returnMessage = result.getString("RETURN_MESSAGE"); + String returnCode = result.getString("RETURN_CODE"); + if(RETURN_RESULT != null && RETURN_RESULT.size() > 0 && "S".equals(returnCode)){ + for(int i = 0;i < RETURN_RESULT.size();i++){ + JSONObject o = (JSONObject) RETURN_RESULT.get(i); + JSONObject jsonObject = JsonConvertUtil.convertJsonByConfig(o, jsonConfigId); + if(jsonObject.containsKey("name1") || jsonObject.containsKey("name2") || jsonObject.containsKey("name3") || jsonObject.containsKey("name4")){ + jsonObject.put("gysms", Util.null2String(jsonObject.getString("name1"))+Util.null2String(jsonObject.getString("name2"))+Util.null2String(jsonObject.getString("name3"))+Util.null2String(jsonObject.getString("name4"))); + jsonObject.remove("name1"); + jsonObject.remove("name2"); + jsonObject.remove("name3"); + jsonObject.remove("name4"); + } + TjwModelUtil.addOrUpdateModelData(rs,modeTableName,jsonObject,keys); + } + } + + //若接口调用成功 则向uf_updatelog中添加记录 + if("S".equals(returnCode) || "No data".equalsIgnoreCase(returnMessage)){ + JSONObject o = new JSONObject(); + o.put("lx",objectId); + o.put("jhrwzxsj", TimeUtil.getCurrentTimeString()); + o.put("sjksrq",_extendby1); + o.put("sjjsrq",_extendby2); + if("No data".equalsIgnoreCase(returnMessage)){ + o.put("bchqjls","0"); + }else{ + o.put("bchqjls",RETURN_RESULT.size()); + } + + TjwModelUtil.addModelData(rs,"uf_updatelog",o); + } + + logger.info(this.getClass() + " end"); + }catch (Throwable e){ + logger.error(this.getClass() + " exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/cronjob/CallSapGetDataToWorkFlow.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/cronjob/CallSapGetDataToWorkFlow.java new file mode 100644 index 0000000..c952181 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/cronjob/CallSapGetDataToWorkFlow.java @@ -0,0 +1,192 @@ +package com.api.taojw.fute.cronjob; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.*; +import com.api.taojw.common.logging.MyLogger; +import com.api.taojw.fute.util.FuteHttpUtil; +import org.apache.http.Header; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import java.util.*; + +/** + * 福特 + * 定时任务调接口同步数据到流程表单 + */ +public class CallSapGetDataToWorkFlow extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String tableName = ""; + private String fkrqColumnName = ""; + private String hjndColumnName = ""; + private String pzhColumnName = ""; + private String gsdmColumnName = ""; + private String fkpzhColumnName = ""; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getFkrqColumnName() { + return fkrqColumnName; + } + + public void setFkrqColumnName(String fkrqColumnName) { + this.fkrqColumnName = fkrqColumnName; + } + + public String getHjndColumnName() { + return hjndColumnName; + } + + public void setHjndColumnName(String hjndColumnName) { + this.hjndColumnName = hjndColumnName; + } + + public String getPzhColumnName() { + return pzhColumnName; + } + + public void setPzhColumnName(String pzhColumnName) { + this.pzhColumnName = pzhColumnName; + } + + public String getGsdmColumnName() { + return gsdmColumnName; + } + + public void setGsdmColumnName(String gsdmColumnName) { + this.gsdmColumnName = gsdmColumnName; + } + + public String getFkpzhColumnName() { + return fkpzhColumnName; + } + + public void setFkpzhColumnName(String fkpzhColumnName) { + this.fkpzhColumnName = fkpzhColumnName; + } + + private String configId = ""; + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + private String sqlWhere = ""; + + public String getSqlWhere() { + return sqlWhere; + } + + public void setSqlWhere(String sqlWhere) { + this.sqlWhere = sqlWhere; + } + + @Override + public void execute() { + try{ + logger.info(this.getClass() + " begin;" ); + RecordSet rs = new RecordSet(); + + //sap接口入参 + JSONObject param = new JSONObject(); + param.put("REQUEST_CODE","IF0282"); + JSONArray REQUEST_PARAMETER = new JSONArray(); + String getDataSql = + "select * from " + tableName + " where ("+fkrqColumnName+" = '' or "+fkrqColumnName+" is null) and "+hjndColumnName+" is not null and "+pzhColumnName+" is not null"; + if(sqlWhere != null && !"".equals(sqlWhere)){ + getDataSql = "select * from " + tableName + " where " + sqlWhere; + } + logger.info("sql :" + getDataSql); + List> data = DaoUtil.getData(rs, getDataSql); + logger.info("size:" + data.size()); + int number = 1; + for(Map m : data){ + JSONObject oldJson = new JSONObject(); + for(String key : m.keySet()){ + oldJson.put(key,m.get(key)); + } + JSONObject newJson = JsonConvertUtil.convertJsonByConfig(oldJson,configId); + newJson.put("NUMBER",number); + number = number + 1; + REQUEST_PARAMETER.add(newJson); + logger.info("REQUEST_PARAMETER add:" +newJson.toJSONString() ); + } + param.put("REQUEST_PARAMETER",REQUEST_PARAMETER); + logger.info("REQUEST_PARAMETER size :" + REQUEST_PARAMETER.size()); + //调用sap接口 + String token = FuteHttpUtil.getToken(); + String sap0282Url = CommonSqlUtil.getSystemParamValue("sap0282Url",rs); + Map headers = new HashMap<>(); + headers.put("Authorization","Bearer " + token); + String ncCheckSign = CommonSqlUtil.getSystemParamValue("sapCronjobCheckSign",rs); + if("1".equals(ncCheckSign)){ + Map getHeaders = new HashMap<>(); + getHeaders.put("Authorization","Bearer " + token); + String saptokenheader = CommonSqlUtil.getSystemParamValue("saptokenheader",rs); + getHeaders.put("X-CSRF-Token",saptokenheader); + + Map get = TjwHttpUtil.sendHttpRequest(sap0282Url, param.toJSONString(), "getWithEntity", ContentType.APPLICATION_JSON, getHeaders); + Header[] responseHeaders = (Header[]) get.get("responseHeaders"); + Header[] allHeaders = responseHeaders; + String thing = ""; + for(Header header : allHeaders){ + if("x-csrf-token".equals(header.getName())){ + thing = header.getValue(); + } + } + List cookies = new ArrayList<>(); + for(int i = 0;i < allHeaders.length;i ++){ + Header h = allHeaders[i]; + if("set-cookie".equalsIgnoreCase(h.getName())){ + cookies.add(h.getValue()); + } + } + logger.info("thing:" + thing); + headers.put("X-CSRF-Token",thing); + StringBuffer cookisStr = new StringBuffer(""); + for (String str : cookies) { + cookisStr.append(str.substring(0, str.indexOf(";"))).append(";"); + } + String endCookie = cookisStr.substring(0, cookisStr.length()); + logger.info("endCookie:" + endCookie); + headers.put("Cookie", endCookie); + } + Map post = TjwHttpUtil.sendHttpRequest(sap0282Url, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String resData = (String) post.get("data"); + JSONObject result = JSONObject.parseObject(resData); + String code = result.getString("RETURN_CODE"); + if("S".equals(code)){ + String updateSql = "update " + tableName + " set "+fkpzhColumnName+"= ?,"+fkrqColumnName+" = ? where "+hjndColumnName+" = ? and "+pzhColumnName+" = ? and "+gsdmColumnName+" = ?"; + + JSONArray RETURN_RESULT = result.getJSONArray("RETURN_RESULT"); + for(int x = 0;x < RETURN_RESULT.size(); x++){ + JSONObject oo = RETURN_RESULT.getJSONObject(x); + String GJAHR = oo.getString("GJAHR"); + String BUKRS = oo.getString("BUKRS"); + String BELNR = oo.getString("BELNR"); + String EXTENDBY1 = oo.getString("EXTENDBY1"); + String EXTENDBY2 = oo.getString("EXTENDBY2"); + DaoUtil.updateData(rs,updateSql,EXTENDBY2,EXTENDBY1,GJAHR,BELNR,BUKRS); + } + } + logger.info(this.getClass() + " end"); + }catch (Throwable e){ + logger.error(this.getClass() + " exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/util/FuteHttpUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/util/FuteHttpUtil.java new file mode 100644 index 0000000..45a729d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/util/FuteHttpUtil.java @@ -0,0 +1,35 @@ +package com.api.taojw.fute.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.HashMap; +import java.util.Map; + +public class FuteHttpUtil { + + static Logger logger = MyLogger.getLogger(); + + //福特获取token + public static String getToken(){ + RecordSet rs = new RecordSet(); + String tokenUrl = CommonSqlUtil.getSystemParamValue("tokenUrl",rs); + String client_id = CommonSqlUtil.getSystemParamValue("client_id",rs); + String grant_type = CommonSqlUtil.getSystemParamValue("grant_type",rs); + String client_secret = CommonSqlUtil.getSystemParamValue("client_secret",rs); + Map headers = new HashMap<>(); + headers.put("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); + Map post = TjwHttpUtil.sendHttpRequest(tokenUrl, "client_id=" + client_id + "&grant_type=" + grant_type + "&client_secret=" + client_secret, "POST", ContentType.APPLICATION_FORM_URLENCODED, headers); + String data = (String) post.get("data"); + JSONObject result = JSONObject.parseObject(data); + String access_token = result.getString("access_token"); + logger.info("token:" + access_token); + return access_token; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/fute/util/SignUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/fute/util/SignUtil.java new file mode 100644 index 0000000..f50da83 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/fute/util/SignUtil.java @@ -0,0 +1,70 @@ +package com.api.taojw.fute.util; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.security.PublicKey; +import java.security.Signature; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.Base64; + +public class SignUtil { + + static Logger logger = MyLogger.getLogger(); + + public static boolean checkSign(String body,String headerString){ + try{ + logger.info("SignUtil.checkSign begin;body:" + body + ";headerString:" + headerString); + RecordSet rs = new RecordSet(); + String publicKeyPath = CommonSqlUtil.getSystemParamValue("sapPublicKeyPath",rs); + //CertificateFactory certificatefactory= CertificateFactory.getInstance("X.509"); + //FileInputStream fis = new FileInputStream(publicKeyPath); + //X509Certificate Cert = (X509Certificate)certificatefactory.generateCertificate(fis); + //PublicKey pk = Cert.getPublicKey(); + PublicKey pk = readPublic(publicKeyPath); + Signature sign = Signature.getInstance("SHA256withRSA"); + sign.initVerify(pk); + sign.update(body.getBytes("UTF-8")); + boolean result = sign.verify(Base64.getDecoder().decode(headerString)); + logger.info("SignUtil.checkSign end;result:" + result); + return result; + }catch (Throwable e){ + logger.error("SignUtil.checkSign exception;body:" + body + ";headerString:" + headerString + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + public static PublicKey readPublic(String publicKeyPath){ + if(publicKeyPath==null){ + return null; + } + PublicKey pk = null; + FileInputStream bais = null; + try { + CertificateFactory certificatefactory = CertificateFactory.getInstance("X.509"); + bais = new FileInputStream(publicKeyPath); + X509Certificate cert = (X509Certificate)certificatefactory.generateCertificate(bais); + pk = cert.getPublicKey(); + } catch (CertificateException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } finally{ + if(bais != null){ + try { + bais.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return pk; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/CusModeExpand.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/CusModeExpand.java new file mode 100644 index 0000000..3e472e4 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/CusModeExpand.java @@ -0,0 +1,67 @@ +package com.api.taojw.huifeng; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + + +/** + * 说明 + * 修改时 + * 类名要与文件名保持一致 + * class文件存放位置与路径保持一致。 + * 请把编译后的class文件,放在对应的目录中才能生效 + * 注意 同一路径下java名不能相同。 + * @author Administrator + * + */ +public class CusModeExpand extends AbstractModeExpandJavaCodeNew { + + Logger logger = MyLogger.getLogger(); + + /** + * 执行模块扩展动作 + * @param param + * param包含(但不限于)以下数据 + * user 当前用户 + * importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加,2覆盖,3更新,获取方式(int)param.get("importtype") + * 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输),比如a=1,可通过param.get("a")获取参数值 + * 页面链接拼接的参数,比如b=2,可以通过param.get("b")来获取参数 + * @return + */ + public Map doModeExpand(Map param) { + Map result = new HashMap(); + try{ + RecordSet rs = new RecordSet(); + String sql = + "update " + + "uf_deposit_pricing a," + + "uf_Daily_VOF b " + + "set " + + "a.lossmakingcontrol = " + + "case when a.customergroupgbcmb='CMB' then " + + "(case when b.allin1-a.pricing<0 then 0 else 1 end) " + + "else " + + "(case when b. allin-a.pricing<0 then 0 else 1 end) end," + + "a.dailynimupdate = " + + "case a.customergroupgbcmb " + + "when 'CMB' then b.allin1-a.pricing " + + "else b.allin-a.pricing end " + + "where " + + "a.depositcurrency = b.depositcurrency " + + "and a.vofdy=b.deposittype " + + "and a.pricingstatus not in (0,3,4) " + + "and a.pricingvaluedate != curdate()"; + DaoUtil.updateData(rs,sql); + }catch(Exception e){ + logger.error("DealDailyVofCronJob exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/MultiSubmitApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/MultiSubmitApi.java new file mode 100644 index 0000000..1c3be23 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/MultiSubmitApi.java @@ -0,0 +1,100 @@ +package com.api.taojw.huifeng; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwWorkFlowUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 汇丰银行批量提交功能 + * 查询列表中点击批量提交按钮 调用此api 批量提交流程 + */ +@Path("/huifengtjw") +public class MultiSubmitApi { + + Logger logger = MyLogger.getLogger(); + + @GET + @Path("/multiSubmitApi") + @Produces(MediaType.APPLICATION_JSON) + public String multiSubmitApi(@Context HttpServletRequest request, @Context HttpServletResponse response){ + //响应数据 + JSONObject result = new JSONObject(); + try{ + logger.info("MultiSubmitApi.multiSubmitApi begin;"); + //建模表名 + String tableName = Util.null2String(request.getParameter("tableName")); + //字段名称 + String requestIdColumnName = Util.null2String(request.getParameter("requestIdColumnName")); + //勾选的id + String selectedIds = Util.null2String(request.getParameter("selectedIds")); + logger.info("MultiSubmitApi.multiSubmitApi begin;tableName:" + tableName + ";requestIdColumnName:" + requestIdColumnName + ";selectedIds:" + selectedIds); + RecordSet rs = new RecordSet(); + String getRequestIdSql = + "select " + + requestIdColumnName + " as requestid " + + "from " + + tableName + " " + + "where " + + "id = ?"; + String[] selectedIdArr = selectedIds.split(","); + if(selectedIdArr == null || selectedIdArr.length == 0){ + result.put("code","0"); + result.put("message","未勾选记录"); + return result.toJSONString(); + } + int successCount = 0; + int failCount = 0; + List failedRequestIdList = new ArrayList<>(); + + User user = HrmUserVarify.getUser(request, response); + + for(String selectedId : selectedIdArr){ + String requestId = ""; + try{ + Map firstData = DaoUtil.getFirstData(rs, getRequestIdSql, selectedId); + requestId = firstData.get("requestid"); + boolean submitSuccess = TjwWorkFlowUtil.submitWorkFlow(Integer.parseInt(requestId), user.getUID()); + if(submitSuccess){ + successCount++; + }else{ + failedRequestIdList.add(requestId); + failCount++; + } + }catch(Exception e){ + failCount++; + logger.error("MultiSubmitApi.multiSubmitApi.submitWorkFlow exception;requestId:" + requestId + "message:" + e.getMessage() + ";e:" + e); + } + } + if(failCount > 0){ + result.put("code","1"); + //result.put("message","批量提交完成;其中"+failCount+"条流程提交失败,requestId分别为:" + failedRequestIdList); + result.put("message","批量提交完成;其中"+failCount+"条流程提交失败,请联系管理员!"); + }else{ + result.put("code","2"); + result.put("message","批量提交完成;共"+successCount+"条流程全部提交成功。"); + } + logger.info("MultiSubmitApi.multiSubmitApi done;result:" + result.toJSONString()); + return result.toJSONString(); + }catch(Exception e){ + logger.error("MultiSubmitApi.multiSubmitApi exception;message:" + e.getMessage() + ";e:" + e); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/WorkFlowCheckApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/WorkFlowCheckApi.java new file mode 100644 index 0000000..00bf434 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/WorkFlowCheckApi.java @@ -0,0 +1,154 @@ +package com.api.taojw.huifeng; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * 汇丰银行表单校验 + */ +@Path("/huifengtjwcheck") +public class WorkFlowCheckApi { + + Logger logger = MyLogger.getLogger(); + + @GET + @Path("/getCountData") + @Produces(MediaType.APPLICATION_JSON) + public String getCountData(@Context HttpServletRequest request, @Context HttpServletResponse response){ + //响应数据 + JSONObject result = new JSONObject(); + try{ + logger.info("WorkFlowCheckApi.getData begin;"); + String customerid = Util.null2String(request.getParameter("customerid")); + String deposittype = Util.null2String(request.getParameter("deposittype")); + String depositcurrency = Util.null2String(request.getParameter("depositcurrency")); + String accounttype = Util.null2String(request.getParameter("accounttype")); + String customertype = Util.null2String(request.getParameter("customertype")); + logger.info("customerid:" + customerid + ";deposittype:" + deposittype + ";depositcurrency:" + depositcurrency + ";accounttype:" + accounttype + ";customertype:" + customertype); + String getDataSql = + "select count(1) as c from uf_deposit_pricing where customerid = ? and deposittype = ? and depositcurrency = ? and accounttype = ? and customertype = ? and status != 0"; + Map firstData = DaoUtil.getFirstData(getDataSql, customerid, deposittype, depositcurrency, accounttype, customertype); + String count = firstData.get("c"); + result.put("count",count); + logger.info("WorkFlowCheckApi.getData done;result:" + result.toJSONString()); + return result.toJSONString(); + }catch(Exception e){ + logger.error("WorkFlowCheckApi.getData exception;message:" + e.getMessage() + ";e:" + e); + return result.toJSONString(); + } + } + + @GET + @Path("/getBaseRate") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseRate(@Context HttpServletRequest request, @Context HttpServletResponse response){ + //响应数据 + JSONObject result = new JSONObject(); + try{ + logger.info("WorkFlowCheckApi.getData begin;"); + String customerid = Util.null2String(request.getParameter("customerid")); + String deposittype = Util.null2String(request.getParameter("deposittype")); + String depositcurrency = Util.null2String(request.getParameter("depositcurrency")); + String period = Util.null2String(request.getParameter("period")); + + logger.info("customerid:" + customerid + ";depositcurrency:" + depositcurrency + ";deposittype:" + deposittype); + if(customerid != null && !"".equals(customerid)){ + customerid = customerid.substring(0,3); //292 + } + String getIdFromBranchMappingSql = + "select branch from uf_branch_mapping where customerid = ?"; + Map idFromBranchMapping = DaoUtil.getFirstData(getIdFromBranchMappingSql, customerid); + String idFromBranch = idFromBranchMapping.get("branch"); //58 + String getPbocfhFromBranchBankSql = + "select pbocfh from uf_branch_bank where id = ?"; + Map pbocfhMapping = DaoUtil.getFirstData(getPbocfhFromBranchBankSql, idFromBranch); + String pbocfh = pbocfhMapping.get("pbocfh"); //1 + String getPbocSql = + "select pboc from uf_pboclistrmb where convert(depositcurrency,char) = ? and convert(deposittype,char) = ? and convert(timedeposit,char) = ?"; + Map pbocMapping = DaoUtil.getFirstData(getPbocSql, depositcurrency,deposittype,period); + String pboc = Util.null2String(pbocMapping.get("pboc")); //2 + String column = ""; + switch (pboc){ + case "0": + column = "casa"; + break; + case "1": + column = "contractsavings"; + break; + case "2": + column = "normal7daycall"; + break; + case "3": + column = "daycallplus"; + break; + case "4": + column = "mtmd3"; + break; + case "5": + column = "mtmd6"; + break; + case "6": + column = "ytmd1"; + break; + case "7": + column = "ytmd2"; + break; + case "8": + column = "ytmd3"; + break; + case "9": + column = "mcd1"; + break; + case "10": + column = "mcd3"; + break; + case "11": + column = "mcd6"; + break; + case "12": + column = "mcd9"; + break; + case "13": + column = "ycd1"; + break; + case "14": + column = "mcd18"; + break; + case "15": + column = "ycd2"; + break; + case "16": + column = "ycd3"; + break; + default: + break; + } + String baseRate = ""; + if(!"".equals(column)){ //normal7daycall + String getBaseRateSql = + "select " + column + " from uf_pboc_base_rate where branch = ?"; + Map firstData = DaoUtil.getFirstData(getBaseRateSql, pbocfh); + baseRate = firstData.get(column); + } + result.put("baseRate",baseRate); + logger.info("WorkFlowCheckApi.getData done;result:" + result.toJSONString()); + return result.toJSONString(); + }catch(Exception e){ + logger.error("WorkFlowCheckApi.getData exception;message:" + e.getMessage() + ";e:" + e); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/action/CreateDocAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/action/CreateDocAction.java new file mode 100644 index 0000000..767a83b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/action/CreateDocAction.java @@ -0,0 +1,235 @@ +package com.api.taojw.huifeng.action; + +import freemarker.template.Configuration; +import freemarker.template.Template; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.email.EmailWorkRunnable; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 汇丰银行 明细表数据生成word 并发送邮件给用户 + */ +public class CreateDocAction implements Action { + public String getIsTest() { + return isTest; + } + + public void setIsTest(String isTest) { + this.isTest = isTest; + } + + private String isTest = ""; + private String condition = ""; + private String pzbss = ""; + private String eamilPersonColumn = ""; + private String mailTitle = ""; + private String mailTitleColumns = ""; + + public String getMailTitleColumns() { + return mailTitleColumns; + } + + public void setMailTitleColumns(String mailTitleColumns) { + this.mailTitleColumns = mailTitleColumns; + } + + private String mailContent = ""; + + public String getPzbss() { + return pzbss; + } + + public void setPzbss(String pzbss) { + this.pzbss = pzbss; + } + + public String getEamilPersonColumn() { + return eamilPersonColumn; + } + + public void setEamilPersonColumn(String eamilPersonColumn) { + this.eamilPersonColumn = eamilPersonColumn; + } + + public String getMailTitle() { + return mailTitle; + } + + public void setMailTitle(String mailTitle) { + this.mailTitle = mailTitle; + } + + public String getMailContent() { + return mailContent; + } + + public void setMailContent(String mailContent) { + this.mailContent = mailContent; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + String tableName = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + try{ + logger.info("CreateDocAction begin;requestId:" + requestId + ";pzbss:" + pzbss); + String getMainTableDataSql = + "select * from " + tableName + " where requestid = ?"; + Map mainTableData = DaoUtil.getFirstData(rs,getMainTableDataSql,requestId); + //获取明细行 + String getDetailDataSql = + "select * from " + tableName + "_dt1 where mainid = (select id from " + tableName + " where requestid = ? )"; + + if(condition != null && !"".equals(condition)){ + getDetailDataSql = getDetailDataSql + condition; + } + + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + //配置id + String[] pzbsArr = pzbss.split(","); + //邮件人员字段 + String[] eamilPersonColumnArr = eamilPersonColumn.split(","); + EmailWorkRunnable emailSender = new EmailWorkRunnable(); + //遍历明细行 每行数据生成两个文件 将生成的文件以附件形式发送邮件给明细行里的用户 + for(Map detailData : data){ + //生成文件 + String imageFileIds = ""; + for(String pzbs : pzbsArr){ + Map docFile = createDocFile(pzbs, mainTableData, detailData); + String imageFileId = docFile.get("imageFileId") + ""; + imageFileIds = imageFileIds + imageFileId + ","; + } + imageFileIds = imageFileIds.substring(0,imageFileIds.length() - 1); + //右键标题处理 + logger.info("mailTitle:" + mailTitle); + String thisMailTitle = new String(mailTitle); + logger.info("thisMailTitle begin:" + thisMailTitle); + if(mailTitleColumns != null && !"".equals(mailTitleColumns)){ + String[] mailTitleColumnsArr = mailTitleColumns.split(","); + for(String col : mailTitleColumnsArr){ + thisMailTitle = thisMailTitle.replaceAll(col,detailData.get(col)); + } + } + logger.info("thisMailTitle end:" + thisMailTitle); + //获取要发送邮件的email + List emails = new ArrayList<>(); + for(String eamilPersonCol : eamilPersonColumnArr){ + String emailPerson = detailData.get(eamilPersonCol); + String getPersonEmailSql = "select email from hrmresource where id = ?"; + String email = DaoUtil.getFirstData(getPersonEmailSql,emailPerson).get("email"); + emails.add(email); + } + //发送邮件 + logger.info("send email begin;email:" + StringUtils.join(emails, ",") + ";imageFileIds:" + imageFileIds); + emailSender.threadModeReminder(StringUtils.join(emails, ","),"","", thisMailTitle, mailContent,imageFileIds); + } + }catch(Exception e){ + logger.error("CreateDocAction exception;message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("send email exception;requestId:"+ requestInfo.getRequestid() +"!"); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + } + + private Map createDocFile(String pzbs,Map mainTableData,Map detailTableData){ + Map result = new HashMap<>(); + try{ + //获取配置信息 + String getConfigDataSql = + "select id,scdwordwjmc,ftlmbwjcflj,ftlmbwjmc,wordwjmccs from uf_hfyhmxsjscwordpz where pzbs = ?"; + Map mainConfigData = DaoUtil.getFirstData(getConfigDataSql, pzbs); + String configId = mainConfigData.get("id"); + String fileName = mainConfigData.get("scdwordwjmc"); + String wordwjmccs = mainConfigData.get("wordwjmccs"); + if(wordwjmccs != null && !"".equals(wordwjmccs)){ + String[] wordwjmccsArr = wordwjmccs.split(","); + for(String col : wordwjmccsArr){ + fileName = fileName.replaceAll(col,detailTableData.get(col)); + } + } + + String getDetailConfigDataSql = + "select mbbqbs,bdzdsjkmc,bdzdgz,zhgz,zdysql from uf_hfyhmxsjscwordpz_dt1 where mainid = ?"; + List> data = DaoUtil.getData(getDetailConfigDataSql, configId); + //根据配置信息将明细表中的数据封装为map 用于生成doc文件 + HashMap paramsMap = new HashMap<>(); + for(Map configData : data){ + String mbbqbs = configData.get("mbbqbs"); + String bdzdgz = configData.get("bdzdgz"); + String bdzdsjkmc = configData.get("bdzdsjkmc"); + configData.put("requestId",mainTableData.get("requestid")); + String oldValue = ""; + if("".equals(bdzdgz) || bdzdgz == null || "0".equals(bdzdgz)){ + oldValue = mainTableData.get(bdzdsjkmc); + }else{ + oldValue = detailTableData.get(bdzdsjkmc); + } + String value = WorkFlowDataToJsonUtil.convertDataByZhgz(oldValue,configData); + paramsMap.put(mbbqbs,value); + } + //生产word + File templateFile = null; + Template template4CN = null; + Configuration cfg = new Configuration(); + File docFile = new File(fileName); + OutputStream ops = new FileOutputStream(docFile); + Writer writer = new OutputStreamWriter(ops, "utf-8"); + cfg.setDefaultEncoding("UTF-8"); + templateFile = new File(mainConfigData.get("ftlmbwjcflj")); + cfg.setDirectoryForTemplateLoading(templateFile); + template4CN = cfg.getTemplate(mainConfigData.get("ftlmbwjmc")); + + template4CN.process(paramsMap, writer); + ops.close(); + writer.close(); + //返回 + FileInputStream fis = new FileInputStream(docFile); + int imageFileId = TjwDocumentUtil.createFileByInputSteam(fis, fileName); + result.put("fileName",fileName); + result.put("imageFileId",imageFileId); + try{ + fis.close(); + }catch(Exception e){ + logger.error("createDocFile close file exception;message:" + e.getMessage() + ";e:" + e); + } + try { + docFile.delete(); + } catch (Exception e) { + logger.error("createDocFile delete file exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + }catch (Exception e){ + logger.error("createDocFile exception;message:" + e.getMessage() + ";e:" + e); + return result; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/action/DealModelDataAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/action/DealModelDataAction.java new file mode 100644 index 0000000..75c4419 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/action/DealModelDataAction.java @@ -0,0 +1,260 @@ +package com.api.taojw.huifeng.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 汇丰银行 处理建模表数据 + * 1、取建模表uf_deposit_pricing中的pricingstatus !=0的数据判断 + * 1.1 建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中, + * 如果只有多条数据,根据pricingvaluedate判断,将除了pricingvaluedate最新的一条之外的所有数据赋值pricingstatus=3, + * 如果只有一条数据,不做赋值 + * 1.2 处理1.1中pricingstatus未赋值的数据,及pricingstatus !=0 or 3的数据 + * 当前日期-pricingvaluedate>365,赋值pricingstatus=2, + * 当前日期-pricingvaluedate<=365,赋值pricingstatus=1 + */ +public class DealModelDataAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + RecordSet rs = new RecordSet(); + try{ + logger.info("DealModelDataAction begin;requestId:" + requestId); + String getMoreThenOneByFiveColumnsSql = + "select customerid,accounttype,customertype,deposittype,depositcurrency,max(pricingvaluedate) as pricingvaluedate from uf_deposit_pricing where ((pricingstatus !=0 and pricingstatus != 3) or pricingstatus is null) group by customerid,accounttype,customertype,deposittype,depositcurrency having count(1) > 1 "; + List> data = DaoUtil.getData(rs, getMoreThenOneByFiveColumnsSql); + logger.info("data.count:" + data.size()); + String updateOnlyOneMaxDateToThreeSql = + "update uf_deposit_pricing set " + + "pricingstatus = ? " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate != ? "; + // + String updateMoreThenOneMaxDateToThreeSql = + "update uf_deposit_pricing set " + + "pricingstatus = ? " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and gxsj != ?"; + + String getMaxDateCountSql = + "select " + + "count(1) as c,MAX(gxsj) AS gxsj " + + "from " + + "uf_deposit_pricing " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate = ? "; + + + //建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中,如果只有多条数据,将除了pricingvaluedate最新的一条之外的所有数据赋值pricingstatus=3 + for(Map m : data){ + Map firstData = DaoUtil.getFirstData(rs, getMaxDateCountSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate")); + String c = firstData.get("c"); + String gxsj = firstData.get("gxsj"); + logger.info("c:" + c + ";gxsj:" + gxsj + + ";customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + + ";pricingvaluedate:" + m.get("pricingvaluedate") + ); + if(Integer.parseInt(c) == 1){ + DaoUtil.updateData(rs,updateOnlyOneMaxDateToThreeSql,"3", + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate") + ); + }else{ + DaoUtil.updateData(rs,updateMoreThenOneMaxDateToThreeSql,"3", + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + gxsj + ); + } + } + //建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中,如果只有多条数据,pricingvaluedate最新的一条的数据 + //当前日期-pricingvaluedate<=365,赋值pricingstatus=1 当前日期-pricingvaluedate>365,赋值pricingstatus=2 + String updateOnlyOneMaxDateMaxSql = + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate = ? "; + String updateMoreThenOneMaxDateMaxSql = + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate = ? " + + "and gxsj = ?"; + for(Map m : data){ + Map firstData = DaoUtil.getFirstData(rs, getMaxDateCountSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate")); + String c = firstData.get("c"); + String gxsj = firstData.get("gxsj"); + if(Integer.parseInt(c) == 1){ + if(!DaoUtil.updateData(rs,updateOnlyOneMaxDateMaxSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate") + )){ + logger.error("updateOnlyOneMaxDateMaxSql error:" + updateOnlyOneMaxDateMaxSql + ";" + + "customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + + ";pricingvaluedate:" + m.get("pricingvaluedate") + ); + } + }else{ + if(!DaoUtil.updateData(rs,updateMoreThenOneMaxDateMaxSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate"), + gxsj + )){ + logger.error("updateMoreThenOneMaxDateMaxSql error:" + updateMoreThenOneMaxDateMaxSql + ";" + + "customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + + ";pricingvaluedate:" + m.get("pricingvaluedate") + ); + } + } + } + //建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中,中只有一条数据, + //当前日期-pricingvaluedate<=365,赋值pricingstatus=1 当前日期-pricingvaluedate>365,赋值pricingstatus=2 + String getUnSetDataSql = + "select customerid,accounttype,customertype,deposittype,depositcurrency from uf_deposit_pricing group by customerid,accounttype,customertype,deposittype,depositcurrency having count(1) = 1 "; + String updateDataSql2 = + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? "; + List> data1 = DaoUtil.getData(rs, getUnSetDataSql); + for(Map m : data1){ + if(!DaoUtil.updateData(rs,updateDataSql2, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency") + )){ + logger.info("updateDataSql2 error:" + updateDataSql2 + ";" + + "customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + ); + } + } + //pricingstatus !=0 or 3的数据 + //当前日期-pricingvaluedate>365,赋值pricingstatus=2, 当前日期-pricingvaluedate<=365,赋值pricingstatus=1 + String updateByStatusSql = + /*"update uf_deposit_pricing set " + + "pricingstatus = case when DATEDIFF(NOW(), pricingvaluedate) <= 365 then 1 else 2 end " + + "where " + + "((pricingstatus !=0 and pricingstatus != 3 and pricingstatus != 4 and pricingstatus != 5) or pricingstatus is null)";*/ + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "((pricingstatus !=0 and pricingstatus != 3 and pricingstatus != 4 and pricingstatus != 5 and pricingstatus != 6) or pricingstatus is null)"; + if(!DaoUtil.updateData(rs,updateByStatusSql)){ + logger.error("updateByStatusSql error:" + updateByStatusSql + ";"); + } + + // + String updateSql1 = "update uf_deposit_pricing set pricingstatus=6 where lossmakingcontrol=0 and pricingstatus=1 and pricingvaluedate != curdate()"; + String updateSql2 = "update uf_deposit_pricing set pricingstatus=1 where lossmakingcontrol=1 and pricingstatus=6 and pricingvaluedate != curdate()"; + DaoUtil.updateData(rs,updateSql1); + DaoUtil.updateData(rs,updateSql2); + + logger.info("updateSql1:" + updateSql1); + logger.info("updateSql2:" + updateSql2); + logger.info("updateOnlyOneMaxDateToThreeSql:" + updateOnlyOneMaxDateToThreeSql); + logger.info("updateMoreThenOneMaxDateToThreeSql:" + updateMoreThenOneMaxDateToThreeSql); + logger.info("getMaxDateCountSql:" + getMaxDateCountSql); + logger.info("updateOnlyOneMaxDateMaxSql:" + updateOnlyOneMaxDateMaxSql); + logger.info("updateMoreThenOneMaxDateMaxSql:" + updateMoreThenOneMaxDateMaxSql); + logger.info("getUnSetDataSql:" + getUnSetDataSql); + logger.info("updateDataSql2:" + updateDataSql2); + logger.info("updateByStatusSql:" + updateByStatusSql); + logger.info("getMoreThenOneByFiveColumnsSql:" + getMoreThenOneByFiveColumnsSql); + + }catch(Exception e){ + logger.error("DealModelDataAction exception;message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("DealModelDataAction exception;requestId:"+ requestId +"!"); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/CreateCsvUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/CreateCsvUtil.java new file mode 100644 index 0000000..f70eee9 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/CreateCsvUtil.java @@ -0,0 +1,80 @@ +package com.api.taojw.huifeng.cronjob; + +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.List; + +public class CreateCsvUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * CSV文件生成方法 + * @param head 文件头 + * @param dataList 数据列表 + * @param outPutPath 文件输出路径 + * @param filename 文件名 + * @return + */ + public static File createCSVFile(List head, List> dataList, String outPutPath, String filename) { + File csvFile = null; + BufferedWriter csvWtriter = null; + try { + csvFile = new File(outPutPath + File.separator + filename + ".csv"); + File parent = csvFile.getParentFile(); + if (parent != null && !parent.exists()) { + parent.mkdirs(); + } + csvFile.createNewFile(); + csvWtriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvFile), "UTF-8"), 1024); + // 写入文件头部 + writeRow(head, csvWtriter); + csvWtriter.newLine(); + // 写入文件内容 + for(int i = 0;i < dataList.size() ;i ++){ + if(i == 0){ + writeRow(dataList.get(i), csvWtriter); + }else{ + csvWtriter.newLine(); + writeRow(dataList.get(i), csvWtriter); + } + } + csvWtriter.flush(); + } catch (Exception e) { + logger.error("CreateCsvUtil.createCSVFile exception;fileName:" + filename + ";message:" + e.getMessage() + ";e:" + e); + } finally { + try { + csvWtriter.close(); + } catch (IOException e) { + logger.error("CreateCsvUtil.createCSVFile.close exception;fileName:" + filename + ";message:" + e.getMessage() + ";e:" + e); + } + } + return csvFile; + } + + /** + * 写一行数据方法 + * @param row + * @param csvWriter + * @throws IOException + */ + public static void writeRow(List row, BufferedWriter csvWriter) throws IOException { + for(int i = 0;i < row.size(); i ++){ + Object data = row.get(i); + if(i == row.size() - 1){ + StringBuffer sb = new StringBuffer(); + /*String rowStr = sb.append("\"").append(data).append("\"|").toString();*/ + String rowStr = sb.append(data).toString(); + csvWriter.write(rowStr); + }else{ + StringBuffer sb = new StringBuffer(); + /*String rowStr = sb.append("\"").append(data).append("\"|").toString();*/ + String rowStr = sb.append(data).append("|").toString(); + csvWriter.write(rowStr); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealDailyVofCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealDailyVofCronJob.java new file mode 100644 index 0000000..583622f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealDailyVofCronJob.java @@ -0,0 +1,44 @@ +package com.api.taojw.huifeng.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +public class DealDailyVofCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + RecordSet rs = new RecordSet(); + String sql = + "update " + + "uf_deposit_pricing a," + + "uf_Daily_VOF b " + + "set " + + "a.lossmakingcontrol = " + + "case when a.customergroupgbcmb='CMB' then " + + "(case when b.allin1-a.pricing<0 then 0 else 1 end) " + + "else " + + "(case when b. allin-a.pricing<0 then 0 else 1 end) end," + + "a.dailynimupdate = " + + "case a.customergroupgbcmb " + + "when 'CMB' then b.allin1-a.pricing " + + "else b.allin-a.pricing end " + + "where " + + "a.depositcurrency = b.depositcurrency " + + "and a.vofdy=b.deposittype " + + "and a.pricingstatus not in (0,3,4) " + + "and a.pricingvaluedate != curdate()"; + DaoUtil.updateData(rs,sql); + }catch(Exception e){ + logger.error("DealDailyVofCronJob exception;message:" + e.getMessage() + ";e:" + e); + } + } + + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealModelDataCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealModelDataCronJob.java new file mode 100644 index 0000000..b47808e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealModelDataCronJob.java @@ -0,0 +1,244 @@ +package com.api.taojw.huifeng.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.*; + +public class DealModelDataCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + RecordSet rs = new RecordSet(); + try{ + logger.info("DealModelDataCronJob begin;"); + String getMoreThenOneByFiveColumnsSql = + "select customerid,accounttype,customertype,deposittype,depositcurrency,max(pricingvaluedate) as pricingvaluedate from uf_deposit_pricing where ((pricingstatus !=0 and pricingstatus != 3) or pricingstatus is null) group by customerid,accounttype,customertype,deposittype,depositcurrency having count(1) > 1 "; + List> data = DaoUtil.getData(rs, getMoreThenOneByFiveColumnsSql); + logger.info("data.count:" + data.size()); + String updateOnlyOneMaxDateToThreeSql = + "update uf_deposit_pricing set " + + "pricingstatus = ? " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate != ? "; + // + String updateMoreThenOneMaxDateToThreeSql = + "update uf_deposit_pricing set " + + "pricingstatus = ? " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and gxsj != ?"; + + String getMaxDateCountSql = + "select " + + "count(1) as c,MAX(gxsj) AS gxsj " + + "from " + + "uf_deposit_pricing " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate = ? "; + + + //建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中,如果只有多条数据,将除了pricingvaluedate最新的一条之外的所有数据赋值pricingstatus=3 + for(Map m : data){ + Map firstData = DaoUtil.getFirstData(rs, getMaxDateCountSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate")); + String c = firstData.get("c"); + String gxsj = firstData.get("gxsj"); + logger.info("c:" + c + ";gxsj:" + gxsj + + ";customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + + ";pricingvaluedate:" + m.get("pricingvaluedate") + ); + if(Integer.parseInt(c) == 1){ + DaoUtil.updateData(rs,updateOnlyOneMaxDateToThreeSql,"3", + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate") + ); + }else{ + DaoUtil.updateData(rs,updateMoreThenOneMaxDateToThreeSql,"3", + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + gxsj + ); + } + } + //建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中,如果只有多条数据,pricingvaluedate最新的一条的数据 + //当前日期-pricingvaluedate<=365,赋值pricingstatus=1 当前日期-pricingvaluedate>365,赋值pricingstatus=2 + String updateOnlyOneMaxDateMaxSql = + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate = ? "; + String updateMoreThenOneMaxDateMaxSql = + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? " + + "and pricingvaluedate = ? " + + "and gxsj = ?"; + for(Map m : data){ + Map firstData = DaoUtil.getFirstData(rs, getMaxDateCountSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate")); + String c = firstData.get("c"); + String gxsj = firstData.get("gxsj"); + if(Integer.parseInt(c) == 1){ + if(!DaoUtil.updateData(rs,updateOnlyOneMaxDateMaxSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate") + )){ + logger.error("updateOnlyOneMaxDateMaxSql error:" + updateOnlyOneMaxDateMaxSql + ";" + + "customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + + ";pricingvaluedate:" + m.get("pricingvaluedate") + ); + } + }else{ + if(!DaoUtil.updateData(rs,updateMoreThenOneMaxDateMaxSql, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency"), + m.get("pricingvaluedate"), + gxsj + )){ + logger.error("updateMoreThenOneMaxDateMaxSql error:" + updateMoreThenOneMaxDateMaxSql + ";" + + "customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + + ";pricingvaluedate:" + m.get("pricingvaluedate") + ); + } + } + } + //建模表中customerid+accounttype+customertype+deposittype+depositcurrency相同的数据中,中只有一条数据, + //当前日期-pricingvaluedate<=365,赋值pricingstatus=1 当前日期-pricingvaluedate>365,赋值pricingstatus=2 + String getUnSetDataSql = + "select customerid,accounttype,customertype,deposittype,depositcurrency from uf_deposit_pricing group by customerid,accounttype,customertype,deposittype,depositcurrency having count(1) = 1 "; + String updateDataSql2 = + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "customerid = ? " + + "and accounttype = ? " + + "and customertype = ? " + + "and deposittype = ? " + + "and depositcurrency = ? "; + List> data1 = DaoUtil.getData(rs, getUnSetDataSql); + for(Map m : data1){ + if(!DaoUtil.updateData(rs,updateDataSql2, + m.get("customerid"), + m.get("accounttype"), + m.get("customertype"), + m.get("deposittype"), + m.get("depositcurrency") + )){ + logger.info("updateDataSql2 error:" + updateDataSql2 + ";" + + "customerid:" + m.get("customerid") + + ";accounttype:" + m.get("accounttype") + + ";customertype:" + m.get("customertype") + + ";deposittype:" + m.get("deposittype") + + ";depositcurrency:" + m.get("depositcurrency") + ); + } + } + //pricingstatus !=0 or 3的数据 + //当前日期-pricingvaluedate>365,赋值pricingstatus=2, 当前日期-pricingvaluedate<=365,赋值pricingstatus=1 + String updateByStatusSql = + /*"update uf_deposit_pricing set " + + "pricingstatus = case when DATEDIFF(NOW(), pricingvaluedate) <= 365 then 1 else 2 end " + + "where " + + "((pricingstatus !=0 and pricingstatus != 3 and pricingstatus != 4 and pricingstatus != 5) or pricingstatus is null)";*/ + "update uf_deposit_pricing set " + + "pricingstatus = case when expirationdate <= curdate() then 2 else 1 end " + + "where " + + "((pricingstatus !=0 and pricingstatus != 3 and pricingstatus != 4 and pricingstatus != 5 and pricingstatus != 6) or pricingstatus is null)"; + if(!DaoUtil.updateData(rs,updateByStatusSql)){ + logger.error("updateByStatusSql error:" + updateByStatusSql + ";"); + } + + // + String updateSql1 = "update uf_deposit_pricing set pricingstatus=6 where lossmakingcontrol=0 and pricingstatus=1 and pricingvaluedate != curdate()"; + String updateSql2 = "update uf_deposit_pricing set pricingstatus=1 where lossmakingcontrol=1 and pricingstatus=6 and pricingvaluedate != curdate()"; + DaoUtil.updateData(rs,updateSql1); + DaoUtil.updateData(rs,updateSql2); + + logger.info("updateSql1:" + updateSql1); + logger.info("updateSql2:" + updateSql2); + logger.info("updateOnlyOneMaxDateToThreeSql:" + updateOnlyOneMaxDateToThreeSql); + logger.info("updateMoreThenOneMaxDateToThreeSql:" + updateMoreThenOneMaxDateToThreeSql); + logger.info("getMaxDateCountSql:" + getMaxDateCountSql); + logger.info("updateOnlyOneMaxDateMaxSql:" + updateOnlyOneMaxDateMaxSql); + logger.info("updateMoreThenOneMaxDateMaxSql:" + updateMoreThenOneMaxDateMaxSql); + logger.info("getUnSetDataSql:" + getUnSetDataSql); + logger.info("updateDataSql2:" + updateDataSql2); + logger.info("updateByStatusSql:" + updateByStatusSql); + logger.info("getMoreThenOneByFiveColumnsSql:" + getMoreThenOneByFiveColumnsSql); + + }catch(Exception e){ + logger.error("DealModelDataCronJob exception;message:" + e.getMessage() + ";e:" + e); + } + } + + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealPositCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealPositCronJob.java new file mode 100644 index 0000000..5ba33c6 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/DealPositCronJob.java @@ -0,0 +1,127 @@ +package com.api.taojw.huifeng.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.List; +import java.util.Map; + +public class DealPositCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + @Override + public void execute() { + try{ + RecordSet rs = new RecordSet(); + int modeId = CommonSqlUtil.getModeIdByTableName("uf_deposit_pricing", rs); + String sql = + "update " + + "uf_deposit_pricing a," + + "(" + + "select " + + "b.id as hrmid," + + "c.id as customerid " + + "from " + + "hrmresource b " + + "left join uf_customer c on c.relationshipmanagerstaffid=b.loginid " + + "where " + + "c.relationshipmanagerstaffid is not null" + + ") hm " + + "set " + + "a.rmname=hm.hrmid " + + "where " + + "a.customerid=hm.customerid"; + sql = + "select " + + "a.id,hm.hrmid " + + "from " + + "uf_deposit_pricing a " + + "(" + + "select " + + "b.id as hrmid," + + "c.id as customerid " + + "from " + + "hrmresource b " + + "left join uf_customer c on c.relationshipmanagerstaffid=b.loginid " + + "where " + + "c.relationshipmanagerstaffid is not null " + + ") hm " + + "where " + + "a.customerid=hm.customerid"; + String updateSql = "update uf_deposit_pricing set rmname = ? where id = ?"; + List> data = DaoUtil.getData(rs, sql); + for(Map m : data){ + String id = m.get("id"); + String hrmid = m.get("hrmid"); + DaoUtil.updateData(rs,updateSql,hrmid,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId, Integer.parseInt(id)); + } + + + + sql = + "update " + + "uf_deposit_pricing a," + + "(select b.id as hrmid,c.id as customerid from hrmresource b left join uf_customer c on c.crosssellmanagername =substring_index(b.jobactivitydesc,'/',1) where c.crosssellmanagername is not null) hm " + + "set " + + "a.csmname=hm.hrmid " + + "where " + + "a.customerid=hm.customerid"; + sql = + "select " + + "a.id,hm.hrmid " + + "from " + + "uf_deposit_pricing a," + + "(select b.id as hrmid,c.id as customerid from hrmresource b left join uf_customer c on c.crosssellmanagername =substring_index(b.jobactivitydesc,'/',1) where c.crosssellmanagername is not null) hm " + + "where " + + "a.customerid=hm.customerid"; + updateSql = "update uf_deposit_pricing set csmname = ? where id = ?"; + List> data1 = DaoUtil.getData(rs, sql); + for(Map m : data1){ + String id = m.get("id"); + String hrmid = m.get("hrmid"); + DaoUtil.updateData(rs,updateSql,hrmid,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId, Integer.parseInt(id)); + } + + sql = + "update " + + "uf_deposit_pricing a, " + + "uf_customer b " + + "set " + + "a.customergroupgbcmb=case b.customertypecode when ' CMB ' then 'CMB' else 'GB' end " + + "where " + + "a.customerid = b.id"; + sql = + "select " + + "a.id ,b.id as ccid " + + "from" + + "uf_deposit_pricing a, " + + "uf_customer b " + + "where " + + "a.customerid = b.id"; + updateSql = "update uf_deposit_pricing set customerid = ? where id = ?"; + List> data2 = DaoUtil.getData(rs, sql); + for(Map m : data2){ + String id = m.get("id"); + String ccid = m.get("ccid"); + DaoUtil.updateData(rs,updateSql,ccid,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId, Integer.parseInt(id)); + } + + + }catch(Exception e){ + logger.error("DealPositCronJob exception;message:" + e.getMessage() + ";e:" + e); + } + } + + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/UploadCsvCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/UploadCsvCronJob.java new file mode 100644 index 0000000..0a86ba3 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/UploadCsvCronJob.java @@ -0,0 +1,219 @@ +package com.api.taojw.huifeng.cronjob; + +import com.api.taojw.huifeng.cronjob.util.FileSyncImpl; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 汇丰银行 + * 生成CSV文件 上传到OSS服务器 + * jar包 + * aliyun-sdk-oss-2.8.3.jar + * aliyun-sdk-oss-3.10.2.jar + * joss-0.9.14.jar + */ +public class UploadCsvCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String tableName = ""; + private String configTableName = ""; + private String pzbs = ""; + private String requestIdColumnName = ""; + private String fileName = ""; + private String okFileName = ""; + private String ossFilePath = ""; + private String filePath = ""; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getConfigTableName() { + return configTableName; + } + + public void setConfigTableName(String configTableName) { + this.configTableName = configTableName; + } + + public String getPzbs() { + return pzbs; + } + + public void setPzbs(String pzbs) { + this.pzbs = pzbs; + } + + public String getRequestIdColumnName() { + return requestIdColumnName; + } + + public void setRequestIdColumnName(String requestIdColumnName) { + this.requestIdColumnName = requestIdColumnName; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getOkFileName() { + return okFileName; + } + + public void setOkFileName(String okFileName) { + this.okFileName = okFileName; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getOssFilePath() { + return ossFilePath; + } + + public void setOssFilePath(String ossFilePath) { + this.ossFilePath = ossFilePath; + } + + @Override + public void execute() { + try{ + logger.info("UploadCsvCronJob.execute start,fileName:" + fileName + ";okFileName:" + okFileName + "date:" + new Date() + ";formatDate:" + new SimpleDateFormat("yyyyMMdd").format(new Date())); + String _fileName = fileName; + _fileName = _fileName.replaceAll("yyyy",new SimpleDateFormat("yyyy").format(new Date())); + _fileName = _fileName.replaceAll("MM",new SimpleDateFormat("MM").format(new Date())); + _fileName = _fileName.replaceAll("dd",new SimpleDateFormat("dd").format(new Date())); + logger.info("_fileName:" + _fileName); + String _okFileName = okFileName; + _okFileName = _okFileName.replaceAll("yyyy",new SimpleDateFormat("yyyy").format(new Date())); + _okFileName = _okFileName.replaceAll("MM",new SimpleDateFormat("MM").format(new Date())); + _okFileName = _okFileName.replaceAll("dd",new SimpleDateFormat("dd").format(new Date())); + logger.info("_okFileName:" + _okFileName); + RecordSet rs = new RecordSet(); + //读取配置 + String getConfigDataSql = + "select " + + "t2.lm,t2.lczd,t2.zhgz,t2.zdysql " + + "from " + + configTableName + " t1 " + + "inner join " + configTableName + "_dt1 t2 on t2.mainid = t1.id " + + "where " + + "t1.pzbs = ? " + + "order by " + + "t2.zdpx asc "; + List> configData = DaoUtil.getData(rs, getConfigDataSql, pzbs); + Map> lmConfigMap = new HashMap<>(); + for(Map m : configData){ + lmConfigMap.put(m.get("lm"),m); + } + //查询建模中需要生成csv的数据 即在特定节点的流程 + String getDataSql = + "select " + + "t1.* " + + "from " + + tableName + " t1 " + + "inner join workflow_requestbase t2 on t2.requestid = t1." + requestIdColumnName + " " + + "inner join workflow_nodebase t3 on t3.id = t2.currentnodeid " + + "where " + + "t2.currentnodetype = ?"; + List> data = DaoUtil.getData(rs, getDataSql, 3); + //根据配置获取列名 + List columns = new ArrayList<>(); + Map lmColumnMap = new HashMap<>(); + for(Map m : configData){ + columns.add(m.get("lm")); + lmColumnMap.put(m.get("lm"),m.get("lczd")); + } + //根据配置获取数据 + List> csvDatas = new ArrayList<>(); + for(Map dataMap : data){ + List csvData = new ArrayList<>(); + for(int i = 0;i< columns.size(); i++){ + String oldValue = dataMap.get(lmColumnMap.get(columns.get(i))); + String newValue = dealValue(oldValue,lmConfigMap.get(columns.get(i)),rs); + csvData.add(newValue); + } + csvDatas.add(csvData); + } + //删除 fileName+".csv" okFileName + try{ + File directory = new File(filePath); + for (File f : directory.listFiles()) { + if (f.isFile()) { + f.delete(); + } + } + }catch (Exception e){ + logger.error("delete file exception;message:" + e.getMessage() + ";e:" + e); + } + + File csvFile = CreateCsvUtil.createCSVFile(columns, csvDatas, filePath, _fileName); + logger.info("create csv done;fileName:" + _fileName); + File okFile = new File(filePath + File.separator + _okFileName); + okFile.createNewFile(); + logger.info("create okfile done;fileName:" + _okFileName); + + //上传OSS服务器 + FileSyncImpl impl = new FileSyncImpl(); + impl.uploadFile(csvFile.getAbsolutePath(),ossFilePath,_fileName+".csv"); + impl.uploadFile(okFile.getAbsolutePath(),ossFilePath,_okFileName); + //OSSOperation.uploadFile(FileSyncImpl.getInstance().); + + logger.info("create ok file done"); + logger.info("SendMailCronJob.sendToDoCount end."); + }catch(Exception e){ + logger.error("SendMailCronJob.sendToDoCount exception:" + e.getMessage() + ";e:" + e); + } + } + + private String dealValue(String oldValue,Map configMap,RecordSet rs){ + String result = ""; + try{ + String zhgz = configMap.get("zhgz"); + String zdysql = configMap.get("zdysql"); + switch(zhgz){ + case "0": + result = zdysql; + break; + case "1": + result = oldValue; + break; + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + } + } + break; + default: + break; + } + }catch(Exception e){ + logger.error("dealValue exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/FileSyncImpl.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/FileSyncImpl.java new file mode 100644 index 0000000..fdc90e9 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/FileSyncImpl.java @@ -0,0 +1,123 @@ +package com.api.taojw.huifeng.cronjob.util; + +import com.aliyun.oss.OSS; +import org.apache.log4j.Logger; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.sync.FileSync; +import weaver.taojw.common.logging.MyLogger; + +import java.io.File; + +/** + * @author why + * @classname FileSyncImpl + * @description TODO + * @date 2021/9/22 9:49 + **/ +public class FileSyncImpl implements FileSync { + private static String endpoint; + private static String accessKeyId; + private static String accessKeySecret; + private static String bucketName; + private static String objectName; + private static OSS ossClient; + BaseBean baseBean = null; + + Logger logger = MyLogger.getLogger(); + + public FileSyncImpl() { + this.baseBean = new BaseBean();; + } + + private static class FileSyncImplHolder { + private static final FileSyncImpl FILE_SYNC_IMPL = new FileSyncImpl(); + } + + public static FileSyncImpl getInstance() { + return FileSyncImplHolder.FILE_SYNC_IMPL; + } + + static { + try { + endpoint = Prop.getPropValue("syncFileForOSSnew", "endpointnew"); + accessKeyId = Prop.getPropValue("syncFileForOSSnew", "accessKeyIdnew"); + accessKeySecret = Prop.getPropValue("syncFileForOSSnew", "accessKeySecretnew"); + bucketName = Prop.getPropValue("syncFileForOSSnew", "bucketNamenew"); + objectName = Prop.getPropValue("syncFileForOSSnew", "objectNamenew"); + ossClient = OSSOperation.getOSS(endpoint,accessKeyId,accessKeySecret); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * 上传文件 + * @param file 文件绝对路径 + * @return 成功:fileId 失败:"0" + */ + @Override + public String uploadFile(String file) { + try{ + logger.info("FileSyncImpl.uploadFile begin;file:" + file); + String fileId = getFileId(file); + String path = new File(file).getAbsolutePath(); + //path = objectName + path; + logger.info("FileSyncImpl.uploadFile ossClient:" + ossClient + ";bucketName:" + bucketName + ";fileId:" + fileId + ";path:" + path + ";objectName:" + objectName); + String res = OSSOperation.uploadFile(ossClient, bucketName, path, fileId); + logger.info("FileSyncImpl.uploadFile res:" + res); + if("0".equals(res)){ + return "0"; + } + return fileId; + }catch(Exception e){ + logger.error("FileSyncImpl.uploadFile exception;message:" + e.getMessage() + ";e:" + e); + return "-1"; + } + } + + /** + * 上传文件 + * @param file 文件绝对路径 + * @return 成功:fileId 失败:"0" + */ + public String uploadFile(String file,String ossFilePath,String fileName) { + try{ + logger.info("FileSyncImpl.uploadFile begin;file:" + file); + //String fileId = getFileId(file); + String fileId = objectName + ossFilePath + fileName; + String path = new File(file).getAbsolutePath(); + //path = objectName + path; + logger.info("FileSyncImpl.uploadFile ossClient:" + ossClient + ";bucketName:" + bucketName + ";fileId:" + fileId + ";path:" + path + ";objectName:" + objectName); + String res = OSSOperation.uploadFile(ossClient, bucketName, path, fileId); + logger.info("FileSyncImpl.uploadFile res:" + res); + if("0".equals(res)){ + return "0"; + } + return fileId; + }catch(Exception e){ + logger.error("FileSyncImpl.uploadFile exception;message:" + e.getMessage() + ";e:" + e); + return "-1"; + } + } + + /** + * 下载文件 + * @param file 文件绝对路径 + * @return 成功:1 失败:0 + */ + @Override + public int downFile(String file) { + baseBean.writeLog("【集群文件同步】下载文件方法"); + return OSSOperation.downloadFile(ossClient,bucketName,file,getFileId(file)); + } + + private String getFileId(String file) { + String fileTemp = file; + if (fileTemp.startsWith("/") || fileTemp.startsWith("\\")) { + fileTemp = objectName + fileTemp; + } else { + fileTemp = objectName + "/" + fileTemp; + } + return fileTemp; + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/JossUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/JossUtil.java new file mode 100644 index 0000000..a55e20c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/JossUtil.java @@ -0,0 +1,84 @@ +package com.api.taojw.huifeng.cronjob.util; + +import com.weaver.file.Prop; +import org.javaswift.joss.client.factory.AccountConfig; +import org.javaswift.joss.client.factory.AccountFactory; +import org.javaswift.joss.client.factory.AuthenticationMethod; +import org.javaswift.joss.model.Account; +import org.javaswift.joss.model.Container; +import org.javaswift.joss.model.StoredObject; + +import java.io.File; + +/** + * Hello world! + * + */ +public class JossUtil +{ + private Container container = null; + private JossUtil() { + + } + private void initJossUtil() { + if(container == null) { + String yourUserName = Prop.getPropValue("sanxiajoss.properties", "yourUserName"); + String yourPassword = Prop.getPropValue("sanxiajoss.properties", "yourPassword"); + String yourAuthUrl = Prop.getPropValue("sanxiajoss.properties", "yourAuthUrl"); + String yourContainerName = Prop.getPropValue("sanxiajoss.properties", "yourContainerName"); + AccountConfig config = new AccountConfig(); + //配置你的用户名(一般是租户和用户名的组合) + config.setUsername(yourUserName); + //配置你的密码 + config.setPassword(yourPassword); + //配置你的认证地址 + config.setAuthUrl(yourAuthUrl); + //配置你的认证方式 + config.setAuthenticationMethod(AuthenticationMethod.BASIC); + //通过初始化配置来创建你的帐户 + Account account = new AccountFactory(config).createAccount(); + //通过帐户来获取你的容器 + container = account.getContainer(yourContainerName); + } + } + + private static class JossUtilHolder{ + private static final JossUtil jossUtil = new JossUtil(); + } + + public static JossUtil getInstance(){ + return JossUtilHolder.jossUtil; + } + + //下载文件 + public int downFile(String fileid,String file) { + try { + initJossUtil(); + //下载到本地 + StoredObject object = container.getObject(fileid); + //下载到本地 + object.downloadObject(new File(file)); + return 1; + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return 0; + } + + //上传文件 + public String uploadFile(String file) { + try { + String fileid = System.currentTimeMillis()+""; + //获取你的对象 + StoredObject object = container.getObject(fileid); + //上传本地文件 + object.uploadObject(new File(file)); + return fileid; + }catch (Exception e) { + e.printStackTrace(); + } + return "0"; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/OSFileFilter.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/OSFileFilter.java new file mode 100644 index 0000000..57a7e72 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/OSFileFilter.java @@ -0,0 +1,64 @@ +package com.api.taojw.huifeng.cronjob.util; + +import com.caucho.server.webapp.WebApp; +import com.weaver.general.BaseBean; +import weaver.file.Prop; +import weaver.general.GCONST; +import weaver.sync.ClusterFileSync; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author why + * @classname OsFileFilter + * @description 静态资源对象存储拦截器 + * @date 2022/5/17 15:20 + **/ +public class OSFileFilter extends BaseBean implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + String path = request.getRequestURI(); + if (path.contains(".")) { + String staticFiles = Prop.getPropValue("OSStaticFile", "staticFiles"); + if (staticFiles != null && !"".equals(staticFiles.trim())) { + List staticFileList = new ArrayList(Arrays.asList(staticFiles.split(","))); + for (String staticFile : staticFileList) { + if (staticFile != null && !"".equals(staticFile.trim())) { + if (path.startsWith(staticFile)) { + String suffix = path.substring(path.lastIndexOf(".")); + boolean isStaticFile = false; + //判断是否静态资源 + String type = WebApp.getLocal().getMimeTypeImpl(suffix); + if (type != null) { + isStaticFile = true; + } + if (isStaticFile) { + ClusterFileSync.getInstance().downloadFile(new File(GCONST.getRootPath(),path).getAbsolutePath()); + break; + } + } + } + + } + } + } + filterChain.doFilter(servletRequest, servletResponse); + } + + @Override + public void destroy() { + + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/OSSOperation.java b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/OSSOperation.java new file mode 100644 index 0000000..41f4870 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/huifeng/cronjob/util/OSSOperation.java @@ -0,0 +1,75 @@ +package com.api.taojw.huifeng.cronjob.util; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.GetObjectRequest; +import com.aliyun.oss.model.PutObjectResult; +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +public class OSSOperation { + + static Logger logger = MyLogger.getLogger(); + + public static String deleteBucket(OSS ossClient, String expiredBucketName) { + ossClient.deleteBucket(expiredBucketName); + return null; + } + + private static class OSSOperationHolder { + private static final OSSOperation ossoperation = new OSSOperation(); + } + + public static OSSOperation getInstance() { + return OSSOperationHolder.ossoperation; + } + + public static String uploadFile(OSS ossClient, String bucketName, String fileName, String objectName) { + InputStream inputStream = null; + try { + logger.info("OSSOperation.uploadFile begin;fileName:" + fileName); + inputStream = new FileInputStream(fileName); + // 表示上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。 + PutObjectResult putObjectResult = ossClient.putObject(bucketName, objectName, inputStream); + logger.info("OSSOperation.uploadFile end;tag:" + putObjectResult.getETag() + ";requestId:" + putObjectResult.getRequestId() + ";message:" + putObjectResult.getResponse()); + return fileName; + } catch (Exception e) { + logger.error("OSSOperation.uploadFile exception;message:" + e.getMessage() + ";e:" + e); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + logger.error("OSSOperation.uploadFile close exception;message:" + e.getMessage() + ";e:" + e); + } + } + return "0"; + } + + public static int downloadFile(OSS ossClient, String bucketName, String pathName, String objectName){ + try { + if(!new File(pathName).getParentFile().exists()){ + new File(pathName).getParentFile().mkdirs(); + } + ossClient.getObject(new GetObjectRequest(bucketName, objectName), new File(pathName)); + return 1; + }catch (Exception e){ + e.printStackTrace(); + } + return 0; + } + + public static OSS getOSS(String endpoint, String accessKeyId, String accessKeySecret) { + OSS ossClient = null; + try { + ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + } catch (Exception e) { + System.out.println("BackupRule:OSS密钥验证错误" + e.getMessage()); + } + return ossClient; + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/jkzcdemo/GetDetailDataApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/jkzcdemo/GetDetailDataApi.java new file mode 100644 index 0000000..d611566 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/jkzcdemo/GetDetailDataApi.java @@ -0,0 +1,90 @@ +package com.api.taojw.jkzcdemo; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +@Path("/jkzcdemo") +public class GetDetailDataApi { + + Logger logger = MyLogger.getLogger(); + + private JSONObject mapToJson(Map m){ + JSONObject o = new JSONObject(); + for(String key: m.keySet()){ + o.put(key,m.get(key)); + } + return o; + } + + @GET + @Path("/getDetailData") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailData(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + JSONArray dataArray = new JSONArray(); + + RecordSet rs = new RecordSet(); + String glyIds = request.getParameter("glyIds"); + String ztIds = request.getParameter("ztIds"); + String type = request.getParameter("type"); + + if(type != null && !"".equals(type) && glyIds != null && !"".equals(glyIds)){ + String[] glyIdArr = glyIds.split(","); + String getDetailSql = "select t1.id,t1.zcmc from uf_zcxxjmbd t1 where t1.glry = ? or t1.syry = ? or t1.zczrr = ?"; + for(String glyId : glyIdArr){ + List> data = DaoUtil.getData(rs,getDetailSql, glyId,glyId,glyId); + for(Map m : data){ + JSONObject o = mapToJson(m); + dataArray.add(o); + } + } + result.put("data",dataArray); + } + + if(glyIds != null && !"".equals(glyIds)){ + String[] glyIdArr = glyIds.split(","); + String getDetailSql = "select t1.id,t1.zcmc from uf_zcxxjmbd t1 where t1.glry = ?"; + for(String glyId : glyIdArr){ + List> data = DaoUtil.getData(rs,getDetailSql, glyId); + for(Map m : data){ + JSONObject o = mapToJson(m); + dataArray.add(o); + } + } + result.put("data",dataArray); + } + + if(ztIds != null && !"".equals(ztIds)){ + String[] glyIdArr = ztIds.split(","); + String getDetailSql = "select t1.id,t1.zcmc from uf_zcxxjmbd t1 where t1.zt1 = ?"; + for(String glyId : glyIdArr){ + List> data = DaoUtil.getData(rs,getDetailSql, glyId); + for(Map m : data){ + JSONObject o = mapToJson(m); + dataArray.add(o); + } + } + result.put("data",dataArray); + } + + }catch(Exception e){ + logger.error("getDetailData exception;message:" + e.getMessage() + ";e:" + e); + } + return result.toJSONString(); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/jkzcdemo/ScanZcApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/jkzcdemo/ScanZcApi.java new file mode 100644 index 0000000..480dd45 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/jkzcdemo/ScanZcApi.java @@ -0,0 +1,180 @@ +package com.api.taojw.jkzcdemo; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * 扫描资产 + */ +@Path("/jkzcscan") +public class ScanZcApi { + + Logger logger = MyLogger.getLogger(); + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + + @GET + @Path("/zcPk") + @Produces(MediaType.APPLICATION_JSON) + public String zcPk(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String zxId = request.getParameter("zxId"); + String planId = request.getParameter("planId"); + String planTableName = "uf_PDJHGL"; + logger.info("zcpk begin;zcid:" + zxId); + String updateStatusSql = "update uf_PDZXGL set pdzt = 1,sfpd = 0 where id = ?"; + DaoUtil.updateData(updateStatusSql,zxId); + //更新计划的盘点总数、已盘点数量 + String updateCountSql = "update " + planTableName + " t1 set t1.zcpdzs = (select count(1) from uf_PDZXGL t2 where t2.jhbh = ? ),t1.ypdsl = (select count(1) from uf_PDZXGL t2 where t2.jhbh = ? and t2.sfpd = 0) where t1.lcbh = ?"; + DaoUtil.updateData(updateCountSql,planId,planId,planId); + String updateRateSql = "update " + planTableName + " t1 set t1.pdjd = t1.ypdsl/t1.zcpdzs where t1.lcbh = ?"; + DaoUtil.updateData(updateRateSql,planId); + return ""; + } + + @POST + @Path("/scanzc") + @Produces(MediaType.APPLICATION_JSON) + public String scanZc(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + //更新计划的已盘点数量、进度 + String updatePlanSql = "update uf_PDJHGL set ypdsl = isnull(ypdsl,0) + 1 "; + DaoUtil.updateData(updatePlanSql); + String updateRateSql = "update uf_PDJHGL set pdjd = CAST(ypdsl AS FLOAT)/zcpdzs"; + DaoUtil.updateData(updateRateSql); + result.put("code","1"); + + User user = HrmUserVarify.getUser(request, response); + int userId = user.getUID(); + String zcId = request.getParameter("zcId"); + //更新资产盘点明细 盘点状态 为 相符 是否盘点改为已盘点 地点改为当前人的所在部门的地点 + String updateDetailStatusSql = "update uf_PDZXGL set pdzt = 2,sfpd = 0,cfdd = (select bmdz from hrmdepartmentdefined where deptid = (select departmentid from hrmresource where id = ?)) where and zc = ?"; + if(DaoUtil.updateData(updateDetailStatusSql,userId,zcId)){ + logger.info("ScanZcApi.scanZc.updateDetailStatus execute"); + }else{ + logger.error("ScanZcApi.scanZc.updateDetailStatus error;updateDetailStatus:" + updateDetailStatusSql); + } + + return result.toString(); + +/* + //当前用户 + User user = HrmUserVarify.getUser(request, response); + int userId = user.getUID(); + //获取盘点计划编号参数 + String planId = request.getParameter("planId"); + //获取资产id + String zcId = request.getParameter("zcId"); + //当前用户 + String currentUser = request.getParameter("currentUser"); + //资产盘点计划、明细计划、计划明细表名 + String planTableName = "uf_PDJHGL"; + String detailTableName = "uf_PDZXGL"; + + //-1表示资产不在本次计划中, -2表示这个资产已盘点 其余值表示盘点人 + String pdr = checkZcInPlan(planId,detailTableName,zcId); + *//*if("-2".equals(pdr)){ + result.put("code",pdr); + return result.toString(); + }*//* + //如果不在本次计划内 做盘赢处理 + if("-1".equals(pdr)){ + String getPlanInfoSql = "select * from uf_PDJHGL where lcbh = ?"; + Map planInfo = DaoUtil.getFirstData(getPlanInfoSql, planId); + String getZcInfoSql = "select * from uf_zcxxjmbd where id = ?"; + Map zcInfo = DaoUtil.getFirstData(getZcInfoSql, zcId); + //向执行台账新增记录 + int newDataId = -1; + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + newDataId = mdu.getModeDataNewId("uf_PDZXGL", 1488, 1, 0, currentDate, currentTime); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, 1488,newDataId); + //更新数据 + String updateDateSql = + "update uf_PDZXGL set " + + "jhbh = ?, " + + "pdksrq = ?,pdjsrq = ?,zc = ?,zcbm = ?," + + "zcmc = ?,ggxh= ?,zczt = ?,cfdd = ?,syr = ?," + + "sybm = ?,pdry = ?,pdxbry= ?,sfpd = 0,pdzt = 0,sjpdrq = ? " + + "where " + + "id = ?"; + DaoUtil.updateData(updateDateSql, + planId,planInfo.get("pdksrq"),planInfo.get("pdjsrq"),zcId,zcInfo.get("zcbm"), + zcInfo.get("zcmc"),zcInfo.get("ggxh"),zcInfo.get("zczt"),zcInfo.get("cfdd"),zcInfo.get("syry"), + zcInfo.get("sybm"),userId,userId,new SimpleDateFormat("yyyy-MM-dd").format(new Date()), + newDataId); + //更新计划的盘点总数、已盘点数量 + String updateCountSql = "update " + planTableName + " t1 set t1.zcpdzs = (select count(1) from uf_PDZXGL t2 where t2.jhbh = ? ),t1.ypdsl = (select count(1) from uf_PDZXGL t2 where t2.jhbh = ? and t2.sfpd = 0) where t1.lcbh = ?"; + DaoUtil.updateData(updateCountSql,planId,planId,planId); + String updateRateSql = "update " + planTableName + " t1 set t1.pdjd = t1.ypdsl/t1.zcpdzs where t1.lcbh = ?"; + DaoUtil.updateData(updateRateSql,planId); + } + + if(!currentUser.equals(pdr)){ + result.put("code","4"); + return result.toString(); + } + try{ + //更新资产盘点明细 盘点状态 为 相符 是否盘点改为已盘点 地点改为当前人的所在部门的地点 + String updateDetailStatusSql = "update " + detailTableName + " set pdzt = 2,sfpd = 0,cfdd = (select bmdz from hrmdepartmentdefined where deptid = (select departmentid from hrmresource where id = ?)) where jhbh = ? and zc = ?"; + if(DaoUtil.updateData(updateDetailStatusSql,userId,planId,zcId)){ + logger.info("ScanZcApi.scanZc.updateDetailStatus execute"); + }else{ + logger.error("ScanZcApi.scanZc.updateDetailStatus error;updateDetailStatus:" + updateDetailStatusSql); + } + //更新计划的已盘点数量、进度 + String updatePlanSql = "update " + planTableName + " t1 set t1.ypdsl = (select count(1) from uf_PDZXGL t2 where t2.jhbh = ? and t2.sfpd = 0) where t1.lcbh = ?"; + DaoUtil.updateData(updatePlanSql,planId,planId); + String updateRateSql = "update " + planTableName + " t1 set t1.pdjd = t1.ypdsl/t1.zcpdzs where t1.lcbh = ?"; + DaoUtil.updateData(updateRateSql,planId); + result.put("code","1"); + return result.toString(); + }catch(Exception e){ + logger.error("ScanZcApi.scanZc error,planId:"+planId+";message:"+e.getMessage()+";e:"+e); + result.put("code","0"); + return result.toString(); + }*/ + } + + /** + * @param planId 盘点计划编号 + * @param detailTableName 盘点明细表名称 + * @param zcId 资产id + * @return -1表示资产不在本次计划中, -2表示这个资产已盘点 其余值表示盘点人 + */ + private String checkZcInPlan(String planId,String detailTableName,String zcId){ + String status = "-1"; + RecordSet rs = new RecordSet(); + String checkSql = "select pdry,pdzt from " + detailTableName + " where jhbh = '" + planId + "' and zc = "+zcId; + logger.info("ZcpdSubmitInfo checkZcInPlan sql:"+checkSql); + if(rs.executeQuery(checkSql)){ + if(rs.next()){ + if("2".equals(Util.null2String(rs.getString("pdzt"))) || "0".equals(Util.null2String(rs.getString("pdzt")))){ + status = "-2"; + }else{ + status = Util.null2String(rs.getString("pdry")); + } + } + } + logger.info("ZcpdSubmitInfo checkZcInPlan status:"+status); + return status; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/CreateBhAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/CreateBhAction.java new file mode 100644 index 0000000..760ef46 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/CreateBhAction.java @@ -0,0 +1,81 @@ +package com.api.taojw.leimi.action; + +import com.api.taojw.leimi.action.util.BhUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 雷米action + * 表单中的部门字段简写 按字母排序 用-拼接 + * FY年 + * 按部门和年单独四位流水 + */ +public class CreateBhAction implements Action { + + private String bmColumn = ""; + + public String getBmColumn() { + return bmColumn; + } + + public void setBmColumn(String bmColumn) { + this.bmColumn = bmColumn; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //获取流程表单中的部门缩写 + String getBmSql = "select " + bmColumn + " from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getBmSql, requestId); + String bmId = Util.null2String(firstData.get(bmColumn.toLowerCase(Locale.ROOT))); + String[] bmIdArray = bmId.split(","); + String getBmJcSql = "select bmsx from hrmdepartmentdefined where deptid = ?"; + String bmString = ""; + for(int i=0;i firstData1 = DaoUtil.getFirstData(rs, getBmJcSql, id); + String bmsx = Util.null2String(firstData1.get("bmsx")); + bmIdArray[i] = bmsx; + } + Arrays.sort(bmIdArray); + for(int i=0;i > data = DaoUtil.getData(rs, getDetailSql, requestId); + for(Map m : data){ + String uniquecode = m.get("uniquecode"); + String uniquecodename = m.get("uniquecodename"); + String VendorName = m.get("vendorname"); + String amount = m.get("totalactual"); + DealJeUtil.free(uniquecode,uniquecodename,VendorName,amount); + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("----------------------" + this.getClass() + " action error ----------------------requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/FnaDoneAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/FnaDoneAction.java new file mode 100644 index 0000000..8e2fb2d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/FnaDoneAction.java @@ -0,0 +1,49 @@ +package com.api.taojw.leimi.action; + +import com.api.taojw.leimi.action.util.DealJeUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.List; +import java.util.Map; + +/** + * 雷米action + * + */ +public class FnaDoneAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + String getDetailSql = "select t1.vendor as vendorname,t1.TotalActual,t2.uniquecode,t2.uniquecodename from " + billTableName + "_dt1 t1 inner join " + billTableName + " t2 on t2.id = t1.mainid where t2.requestid = ?"; + List> data = DaoUtil.getData(rs, getDetailSql, requestId); + for(Map m : data){ + String uniquecode = m.get("uniquecode"); + String uniquecodename = m.get("uniquecodename"); + String VendorName = m.get("vendorname"); + String amount = m.get("totalactual"); + DealJeUtil.minus(uniquecode,uniquecodename,VendorName,amount); + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("----------------------" + this.getClass() + " action error ----------------------requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/FnaIceAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/FnaIceAction.java new file mode 100644 index 0000000..8112518 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/FnaIceAction.java @@ -0,0 +1,49 @@ +package com.api.taojw.leimi.action; + +import com.api.taojw.leimi.action.util.DealJeUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.List; +import java.util.Map; + +/** + * 雷米action + * + */ +public class FnaIceAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + String getDetailSql = "select t1.vendor as vendorname,t1.TotalActual,t2.uniquecode,t2.uniquecodename from " + billTableName + "_dt1 t1 inner join " + billTableName + " t2 on t2.id = t1.mainid where t2.requestid = ?"; + List> data = DaoUtil.getData(rs, getDetailSql, requestId); + for(Map m : data){ + String uniquecode = m.get("uniquecode"); + String uniquecodename = m.get("uniquecodename"); + String VendorName = m.get("vendorname"); + String amount = m.get("totalactual"); + DealJeUtil.freeze(uniquecode,uniquecodename,VendorName,amount); + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("----------------------" + this.getClass() + " action error ----------------------requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/util/BhUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/util/BhUtil.java new file mode 100644 index 0000000..6ee6e7b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/util/BhUtil.java @@ -0,0 +1,41 @@ +package com.api.taojw.leimi.action.util; + +import com.alibaba.fastjson.JSONObject; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; + +import java.util.Map; + +public class BhUtil { + + public static synchronized String getBh(String bm,String year){ + String thisYear = year.substring(2,4); + int nextYear = Integer.parseInt(thisYear) + 1; + year = thisYear + "" + nextYear; + String result = bm + "-FY" + year; + //查询建模中是否有 + RecordSet rs = new RecordSet(); + String getDataSql = "select dqls from uf_lmbhtz where bm = ? and nf = ?"; + String updateSql = "update uf_lmbhtz set dqls = dqls + 1 where bm = ? and nf = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, bm, year); + String dqls = Util.null2String(firstData.get("dqls")); + if("".equals(dqls)){ + //建模插入数据 + JSONObject o = new JSONObject(); + o.put("bm",bm); + o.put("nf",year); + o.put("dqls","1"); + TjwModelUtil.addModelData(rs,"uf_lmbhtz",o); + result = result + "-0001"; + }else{ + int currentLs = Integer.parseInt(dqls) + 1; + String replace = String.format("%4s", currentLs + "").replace(" ", "0"); + result = result + "-" + replace; + DaoUtil.updateData(rs,updateSql, bm, year); + } + return result; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/util/DealJeUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/util/DealJeUtil.java new file mode 100644 index 0000000..7e8ac6a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/action/util/DealJeUtil.java @@ -0,0 +1,61 @@ +package com.api.taojw.leimi.action.util; + +import com.alibaba.fastjson.JSONObject; +import weaver.conn.RecordSet; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; + +public class DealJeUtil { + + public static String tableName = "uf_ucvnjy"; + + public static String uniqueCodeColumn = "uniqueCode"; + public static String uniqueCodeNameColumn = "uniqueCodeName"; + public static String vendorNameColumn = "vendorName"; + public static String yxpoje = "yxpoje"; + public static String ztje = "ztje"; + public static String lcljje = "lcljje"; + + + //冻结 + //在途增加 累计增加 + public static synchronized void freeze(String uniqueCode,String uniqueCodeName, String vendorName,String amount){ + RecordSet rs = new RecordSet(); + String checkExistsSql = "select count(1) as c from " + tableName + " where " + uniqueCodeColumn + " = ? and " + vendorNameColumn + " = ?"; + if(!DaoUtil.isDataExists(rs,checkExistsSql,uniqueCode,vendorName)){ + JSONObject o = new JSONObject(); + o.put(uniqueCodeColumn,uniqueCode); + o.put(uniqueCodeNameColumn,uniqueCodeName); + o.put(vendorNameColumn,vendorName); + o.put(ztje,amount); + o.put(lcljje,amount); + TjwModelUtil.addModelData(rs,tableName,o); + return; + } + + String updateSql = + "update " + tableName + " set " + ztje + " = isnull(" + ztje + ",0) + " + amount + "," + lcljje + " = isnull(" + lcljje + ",0) + " + amount + " where "+ + uniqueCodeColumn+" = '" + uniqueCode + "' and " + vendorNameColumn + " = '" + vendorName + "'"; + DaoUtil.updateData(new RecordSet(),updateSql); + } + + //扣减 + //在途减少 已下PO增加 + public static synchronized void minus(String uniqueCode,String uniqueCodeName, String vendorName,String amount){ + String updateSql = + "update " + tableName + " set " + yxpoje + " = isnull(" + yxpoje + ",0) + " + amount + "," + ztje + " = isnull(" + ztje + ",0) - " + amount + " where "+ + uniqueCodeColumn+" = '" + uniqueCode + "' and " + vendorNameColumn + " = '" + vendorName + "'"; + DaoUtil.updateData(new RecordSet(),updateSql); + } + + //释放 + //在途减少 累计减少 + public static synchronized void free(String uniqueCode,String uniqueCodeName, String vendorName,String amount){ + String updateSql = + "update " + tableName + " set " + ztje + " = isnull(" + ztje + ",0) - " + amount + "," + lcljje + " = isnull(" + lcljje + ",0) - " + amount + " where "+ + uniqueCodeColumn+" = '" + uniqueCode + "' and " + vendorNameColumn + " = '" + vendorName + "'"; + DaoUtil.updateData(new RecordSet(),updateSql); + } + +} + diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/api/LmTjwApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/api/LmTjwApi.java new file mode 100644 index 0000000..5826529 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/api/LmTjwApi.java @@ -0,0 +1,92 @@ +package com.api.taojw.leimi.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * 浦银租赁NCC集成 + * action + * 流程数据转json 调用NCC接口 + * 需要jar包 OpenAPIUtil-1.0.1.jar + */ +@Path("/lmtjw") +public class LmTjwApi { + + private String cusparam = ""; + + public String getCusparam() { + return cusparam; + } + + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/getJe") + @Produces(MediaType.APPLICATION_JSON) + public String getJe(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("----------------------" + this.getClass() + " getJe begin"); + RecordSet rs = new RecordSet(); + String requestId = request.getParameter("requestId"); + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + String getDataSql = + "select " + + "t1.uniquecode ,t1.uniquecodename, t2.vendor as vendorname ,t4.VendorNameCN as vendornamename,t5.uniquecode as uniquecodeid " + + "from " + + tableName + " t1 " + + "inner join " + tableName + "_dt1 t2 on t2.mainid = t1.id " + + "inner join uf_Vendor t4 on t4.id = t2.vendor " + + "left join uf_uctz t5 on t5.id = t1.uniquecode " + + "where " + + "t1.requestid = ?"; + String getJeSql = "select lcljje from uf_ucvnjy where uniqueCode = ? and vendorName = ?"; + List> data = DaoUtil.getData(rs, getDataSql, requestId); + JSONArray res = new JSONArray(); + for(Map m : data){ + JSONObject o = new JSONObject(); + String uniquecode = m.get("uniquecode"); + String uniquecodename = m.get("uniquecodename"); + String VendorName = m.get("vendorname"); + String vendornamename = m.get("vendornamename"); + String uniquecodeid = m.get("uniquecodeid"); + Map firstData = DaoUtil.getFirstData(rs, getJeSql, uniquecode, VendorName); + String je = firstData.get("lcljje"); + o.put("VendorName",VendorName); + o.put("uniquecodename",uniquecodename); + o.put("uniquecode",uniquecode); + o.put("vendornamename",vendornamename); + o.put("uniquecodeid",uniquecodeid); + o.put("je",je); + res.add(o); + } + result.put("arr",res); + result.put("flag","success"); + return result.toJSONString(); + }catch(Throwable e){ + logger.error("getJe error;message:" + e.getMessage()); + result.put("flag","fail"); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/cronjob/UpdateModeStatusCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/cronjob/UpdateModeStatusCronjob.java new file mode 100644 index 0000000..7c31c08 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/cronjob/UpdateModeStatusCronjob.java @@ -0,0 +1,31 @@ +package com.api.taojw.leimi.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +/** + * 雷米定时任务 + * FY2223 表示23年3月31日以后就到期了 到期了更新状态为否 + * 根据日期更新台账状态字段 + */ +public class UpdateModeStatusCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info("UpdateModeStatusCronjob begin"); + RecordSet rs = new RecordSet(); + String updateStatusSql = "UPDATE uf_uctz SET sfyx = 1 where '20'+SUBSTRING(UNIQUECODE,LEN(UNIQUECODE) - 6,2)+'-03-31' <= CONVERT(varchar,GETDATE(),23)"; + DaoUtil.updateData(rs,updateStatusSql); + logger.info("UpdateModeStatusCronjob end"); + }catch (Throwable e){ + logger.error("UpdateModeStatusCronjob exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/leimi/modecussearch/LeimiModeCusSearch.java b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/modecussearch/LeimiModeCusSearch.java new file mode 100644 index 0000000..fdeb90f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/leimi/modecussearch/LeimiModeCusSearch.java @@ -0,0 +1,134 @@ +package com.api.taojw.leimi.modecussearch; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractCustomSqlConditionJavaCode; +import weaver.hrm.User; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class LeimiModeCusSearch extends AbstractCustomSqlConditionJavaCode { + + Logger logger = MyLogger.getLogger(); + + /** + * 生成SQL查询限制条件 + * @param param + * param包含(但不限于)以下数据 + * user 当前用户 + * + * @return + * 返回的查询限制条件的格式举例为: t1.a = '1' and t1.b = '3' and t1.c like '%22%' + * 其中t1为表单主表表名的别名 + */ + public String generateSqlCondition(Map param) throws Exception { + logger.info("LeimiModeCusSearch.generateSqlCondition begin;"); + try{ + User user = (User)param.get("user"); + logger.info("user:" + user.getLastname() + ";id:" + user.getUID()); + RecordSet rs = new RecordSet(); + //当前用户所在部门 + int userDepartment = user.getUserDepartment(); + //用户未某个特殊部门下的 他能看到所有数据 + int specialDepartmentId_All = Integer.parseInt(CommonSqlUtil.getSystemParamValue("specialDepartmentId_All",rs)); + if(userDepartment == specialDepartmentId_All){ + logger.info("userDepartment == specialDepartmentId_All"); + return " sfyx = 0 "; + } + + String teId = CommonSqlUtil.getSystemParamValue("teDepartmentId",rs); + String lyDepartmentId = CommonSqlUtil.getSystemParamValue("lyDepartmentId",rs); + //若用户为te及te下级部门的用户 则相关权限部门选择里必须包含te 或 te下级 或路易13 + boolean isTe = false; + if(teId.equals(userDepartment+"")){ + isTe = true; + } + List teAllSonId = new ArrayList<>(); + CommonSqlUtil.getAllSonDepartment(teAllSonId,teId); + for(String i : teAllSonId){ + if(i.equals(userDepartment+"")){ + isTe = true; + } + } + if(isTe){ + String sqlCondition = ""; + String whereSql = "','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + teId + ",%' "; + for(String id : teAllSonId){ + whereSql = whereSql + " or (','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + id + ",%') "; + } + sqlCondition = + "( " + + whereSql + " or (','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + lyDepartmentId + ",%') " + + ") and sfyx = 0 "; + logger.info("sqlCondition:" + sqlCondition); + return sqlCondition; + } + + String sqlCondition = ""; + String specialDepartmentId_first = CommonSqlUtil.getSystemParamValue("specialDepartmentId_first",rs); + String specialDepartmentId_second = CommonSqlUtil.getSystemParamValue("specialDepartmentId_second",rs); + //若用户为特殊部门1下的用户,则选择部门需要包含特殊部门1 + boolean sp1 = false; + if(specialDepartmentId_first.equals(userDepartment+"")){ + sp1 = true; + } + List specila1AllSonId = new ArrayList<>(); + CommonSqlUtil.getAllSonDepartment(specila1AllSonId,specialDepartmentId_first); + for(String i : specila1AllSonId){ + if(i.equals(userDepartment+"")){ + sp1 = true; + } + } + if(sp1){ + sqlCondition = + "','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + specialDepartmentId_first + ",%' and sfyx = 0 "; + logger.info("sqlCondition:" + sqlCondition); + return sqlCondition; + } + //若用户为特殊部门2下的用户,则选择部门需要包含特殊部门1 + boolean sp2= false; + if(specialDepartmentId_second.equals(userDepartment+"")){ + sp2 = true; + } + List specila2AllSonId = new ArrayList<>(); + CommonSqlUtil.getAllSonDepartment(specila2AllSonId, specialDepartmentId_second); + for(String i : specila2AllSonId){ + if(i.equals(userDepartment+"")){ + sp2 = true; + } + } + if(sp2){ + sqlCondition = + "','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + specialDepartmentId_second + ",%' and sfyx = 0 "; + logger.info("sqlCondition:" + sqlCondition); + return sqlCondition; + } + + List allParentId = new ArrayList<>(); + CommonSqlUtil.getAllParentDepartment(allParentId, String.valueOf(userDepartment)); + List allSonId = new ArrayList<>(); + CommonSqlUtil.getAllSonDepartment(allSonId, String.valueOf(userDepartment)); + String whereSql = "','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + userDepartment + ",%' "; + for(String id : allParentId){ + whereSql = whereSql + " or (','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + id + ",%') "; + } + for(String id : allSonId){ + whereSql = whereSql + " or (','+cast(t1.xgqxbmxz as nvarchar(2000))+',' like '%," + id + ",%') "; + } + sqlCondition = + "(" + + whereSql + + ") and sfyx = 0 "; + logger.info("sqlCondition:" + sqlCondition); + return sqlCondition; + }catch(Throwable e){ + logger.error("LeimiModeCusSearch.generateSqlCondition error;message:" + e.getMessage() + ";e:" + e); + return ""; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/GetDetailDataApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/GetDetailDataApi.java new file mode 100644 index 0000000..483ad9a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/GetDetailDataApi.java @@ -0,0 +1,87 @@ +package com.api.taojw.liangxin; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * 获取明细数据 + */ +@Path("/liangxintjw") +public class GetDetailDataApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/getDetailData") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailData(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String userId = request.getParameter("userId"); + //需求说是取上周一的数据,放在前端处理 + String tbksrq = request.getParameter("tbksrq"); + try{ + JSONObject result = new JSONObject(); + RecordSet rs = new RecordSet(); + String getMaxLccjsjSql = "select max(lccjsj) as lccjsj from uf_gstzbd where tbr = ?"; + Map firstData = DaoUtil.getFirstData(rs, getMaxLccjsjSql, userId); + String lccjsj = firstData.get("lccjsj"); + String getDetailDataSql = + "select " + + "t1.xmmc as xmmcid," + + "t2.xmmc as xmmcname," + + "t1.xmfzr as xmfzrid," + + "t3.lastname as xmfzrname," + + "t1.zygs, " + + "t1.zegs, " + + "t1.zsgs, " + + "t1.zsgs1, " + + "t1.zwgs, " + + "t1.zlgs, " + + "t1.ztgs," + + "t1.gznr " + + "from " + + "uf_gstzbd t1 " + + "left join uf_xmzsjtzb t2 on t2.id = t1.xmmc " + + "left join hrmresource t3 on t3.id = t1.xmfzr " + + "where " + + "t1.tbr = ? " + + "and t1.lccjsj = ?"; + List> data = DaoUtil.getData(rs, getDetailDataSql, userId, lccjsj); + JSONArray dataArray = new JSONArray(); + for(Map m : data){ + JSONObject o = new JSONObject(); + o.put("xmmcid",m.get("xmmcid")); + o.put("xmmcname",m.get("xmmcname")); + o.put("xmfzrid",m.get("xmfzrid")); + o.put("xmfzrname",m.get("xmfzrname")); + o.put("zygs",m.get("zygs")); + o.put("zegs",m.get("zegs")); + o.put("zsgs",m.get("zsgs")); + o.put("zsgs1",m.get("zsgs1")); + o.put("zwgs",m.get("zwgs")); + o.put("zlgs",m.get("zlgs")); + o.put("ztgs",m.get("ztgs")); + o.put("gznr",m.get("gznr")); + dataArray.add(o); + } + result.put("data",dataArray); + return result.toJSONString(); + }catch(Exception e){ + logger.error("GetDetailDataApi.getDetailData exception;userId:" + userId + ";tbksrq:" + tbksrq); + } + return ""; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/SyncBaseInfoCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/SyncBaseInfoCronJob.java new file mode 100644 index 0000000..de8a8d5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/SyncBaseInfoCronJob.java @@ -0,0 +1,334 @@ +package com.api.taojw.liangxin.baseinfocronjob; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.ISysSynchroGetOrgWebServiceServiceLocator; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.ISysSynchroGetOrgWebServiceServiceSoapBindingStub; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.SysSynchroGetOrgBaseInfoContextV2; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.SysSynchroOrgResult; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import java.lang.Exception; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class SyncBaseInfoCronJob extends BaseCronJob { + //接口提供方webservice地址 + private String serviceUrl = ""; + //存储人员信息的建模表表名 + private String personInfoTable = ""; + //存储分部信息的建模表表名 + private String orgInfoTable = ""; + //存储部门信息的建模表表名 + private String deptInfoTable = ""; + //存储岗位信息的建模表表名 + private String jobInfoTable = ""; + + public String getServiceUrl() { + return serviceUrl; + } + + public void setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + public String getPersonInfoTable() { + return personInfoTable; + } + + public void setPersonInfoTable(String personInfoTable) { + this.personInfoTable = personInfoTable; + } + + public String getOrgInfoTable() { + return orgInfoTable; + } + + public void setOrgInfoTable(String orgInfoTable) { + this.orgInfoTable = orgInfoTable; + } + + public String getDeptInfoTable() { + return deptInfoTable; + } + + public void setDeptInfoTable(String deptInfoTable) { + this.deptInfoTable = deptInfoTable; + } + + public String getJobInfoTable() { + return jobInfoTable; + } + + public void setJobInfoTable(String jobInfoTable) { + this.jobInfoTable = jobInfoTable; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info("SyncBaseInfoCronJob.execute() begin222"); + RecordSet rs = new RecordSet(); + + String deletePersonSql = "delete from " + personInfoTable + " where bh is null or bh = ''"; + String deleteDeptSql = "delete from " + deptInfoTable + " where bh is null or bh = ''"; + String deleteOrgSql = "delete from " + orgInfoTable + " where subcompanycode is null or subcompanycode = ''"; + String deletePostSql = "delete from " + jobInfoTable + " where gwbm is null or gwbm = ''"; + DaoUtil.updateData(rs,deletePersonSql); + DaoUtil.updateData(rs,deleteDeptSql); + DaoUtil.updateData(rs,deleteOrgSql); + DaoUtil.updateData(rs,deletePostSql); + + URL wbUrl = new URL(serviceUrl); + ISysSynchroGetOrgWebServiceServiceLocator locator = new ISysSynchroGetOrgWebServiceServiceLocator(); + ISysSynchroGetOrgWebServiceServiceSoapBindingStub stub = new ISysSynchroGetOrgWebServiceServiceSoapBindingStub(wbUrl,locator); + SysSynchroGetOrgBaseInfoContextV2 orgContext = new SysSynchroGetOrgBaseInfoContextV2(); + //获取人员信息 + String returnOrgType = "[{\"type\":\"person\"}]"; + orgContext.setReturnOrgType(returnOrgType); + + SysSynchroOrgResult elementsBaseInfoV2 = stub.getElementsBaseInfoV2(orgContext); + logger.info("SyncBaseInfoCronJob.execute().getPersonInfo response;ReturnState:" + elementsBaseInfoV2.getReturnState() + ";Count:" + elementsBaseInfoV2.getCount() + ";TimeStamp:" + elementsBaseInfoV2.getTimeStamp() + ";Message:" + elementsBaseInfoV2.getMessage()); + //处理人员信息 + String personResponseMessage = elementsBaseInfoV2.getMessage(); + JSONArray personJsonArray = JSONArray.parseArray(personResponseMessage); + dealPersonInfo(rs,personJsonArray); + //获取部门信息 + String returnOrgType2 = "[{\"type\":\"dept\"}]"; + orgContext.setReturnOrgType(returnOrgType2); + elementsBaseInfoV2 = stub.getElementsBaseInfoV2(orgContext); + logger.info("SyncBaseInfoCronJob.execute().getDeptInfo response;ReturnState:" + elementsBaseInfoV2.getReturnState() + ";Count:" + elementsBaseInfoV2.getCount() + ";TimeStamp:" + elementsBaseInfoV2.getTimeStamp() + ";Message:" + elementsBaseInfoV2.getMessage()); + //处理部门信息 + String deptResponseMessage = elementsBaseInfoV2.getMessage(); + JSONArray deptJsonArray = JSONArray.parseArray(deptResponseMessage); + dealDeptInfo(rs,deptJsonArray); + //获取岗位信息 + String returnOrgType3 = "[{\"type\":\"post\"}]"; + orgContext.setReturnOrgType(returnOrgType3); + elementsBaseInfoV2 = stub.getElementsBaseInfoV2(orgContext); + logger.info("SyncBaseInfoCronJob.execute().getPostInfo response;ReturnState:" + elementsBaseInfoV2.getReturnState() + ";Count:" + elementsBaseInfoV2.getCount() + ";TimeStamp:" + elementsBaseInfoV2.getTimeStamp() + ";Message:" + elementsBaseInfoV2.getMessage()); + //处理岗位信息 + String postResponseMessage = elementsBaseInfoV2.getMessage(); + JSONArray postJsonArray = JSONArray.parseArray(postResponseMessage); + dealPostInfo(rs,postJsonArray); + //获取分部信息 + String returnOrgType4 = "[{\"type\":\"org\"}]"; + orgContext.setReturnOrgType(returnOrgType4); + elementsBaseInfoV2 = stub.getElementsBaseInfoV2(orgContext); + logger.info("SyncBaseInfoCronJob.execute().getOrgInfo response;ReturnState:" + elementsBaseInfoV2.getReturnState() + ";Count:" + elementsBaseInfoV2.getCount() + ";TimeStamp:" + elementsBaseInfoV2.getTimeStamp() + ";Message:" + elementsBaseInfoV2.getMessage()); + //处理分部信息 + String orgResponseMessage = elementsBaseInfoV2.getMessage(); + JSONArray orgJsonArray = JSONArray.parseArray(orgResponseMessage); + dealOrgInfo(rs,orgJsonArray); + + //处理人员直接上级 + /*String updateManageridSql = + "update " + personInfoTable + " t1 " + + "set t1.managerid = " + + "(select max(workcode) from " + personInfoTable + " t2 where t2.id = " + + "(select max(zzjgbmfzr) from " + deptInfoTable + " t3 where t3.departmentcode = t1.departmentid))"; + DaoUtil.updateData(rs,updateManageridSql);*/ + + }catch(Throwable e){ + logger.error("SyncBaseInfoCronJob.execute() exception;messgae:" + e.getMessage() + ";e:" + e); + } + } + + private void dealOrgInfo(RecordSet rs,JSONArray orgJsonArray){ + for(int i = 0;i< orgJsonArray.size(); i++){ + JSONObject org = (JSONObject) orgJsonArray.get(i); + JSONObject orgData = new JSONObject(); + //分布简称 + orgData.put("subcompanyname",org.get("name")); + //分布编码 + orgData.put("subcompanycode",org.get("no")); + //上级分部编码 + orgData.put("sjfbbm",""); + //分部全称 + orgData.put("subcompanydesc",org.get("name")); + //封存标识 + boolean isAvailable = (boolean) org.get("isAvailable"); + orgData.put("canceled",isAvailable?0:1); + //插入时间 + orgData.put("Createdate",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + //机构负责人 + orgData.put("jgfzr",org.get("thisLeader")); + TjwModelUtil.addOrUpdateModelData(rs,orgInfoTable,orgData,"subcompanycode"); + } + } + + private void dealPostInfo(RecordSet rs,JSONArray postJsonArray){ + for(int i = 0;i< postJsonArray.size(); i++){ + JSONObject post = (JSONObject) postJsonArray.get(i); + JSONObject postData = new JSONObject(); + //封存标识 + try{ + boolean isAvailable = (boolean) post.get("isAvailable"); + postData.put("canceled",isAvailable?0:1); + }catch (Exception e){ + logger.error("post isAvailable exception; message:" + e.getMessage() + ";"); + } + //岗位编码 + postData.put("gwbm",post.get("id")); + //岗位简称 + postData.put("departmentid",post.get("name")); + //岗位全称 + postData.put("gwqc",post.get("name")); + //插入时间 + postData.put("Createdate",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + TjwModelUtil.addOrUpdateModelData(rs,jobInfoTable,postData,"gwbm"); + } + } + + private void dealDeptInfo(RecordSet rs,JSONArray deptJsonArray){ + for(int i = 0;i< deptJsonArray.size(); i++){ + JSONObject dept = (JSONObject) deptJsonArray.get(i); + JSONObject deptData = new JSONObject(); + //部门全称 + deptData.put("departmentname",dept.get("name")); + //部门简称 + deptData.put("departmentmark",dept.get("name")); + //所属分部 + deptData.put("subcompanyid1",dept.get("orgCode")); + //上级部门 + deptData.put("supdepid",dept.get("parent")); + //部门编码 + deptData.put("departmentcode",dept.get("lunid")); + //插入时间 + deptData.put("createdate",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + //部门负责人 + deptData.put("zzjgbmfzr",dept.get("thisLeader")); + //封存标识 + try{ + boolean isAvailable = (boolean) dept.get("isAvailable"); + deptData.put("canceled",isAvailable?0:1); + }catch (Exception e){ + logger.error("dept isAvailable exception; message:" + e.getMessage() + ";" + dept.get("isAvailable")); + } + //编号 + deptData.put("bh",dept.get("no")); + //上级部门编码 + deptData.put("sjbmbm",dept.get("parent")); + //部门层级 + deptData.put("bmcj",dept.get("fdHierarchyLeve")); + //层级id + deptData.put("cjid",dept.get("fdHierarchyId")); + TjwModelUtil.addOrUpdateModelData(rs,deptInfoTable,deptData,"departmentcode"); + } + } + + private void dealPersonInfo(RecordSet rs,JSONArray personJsonArray){ + for(int i = 0;i< personJsonArray.size(); i++){ + JSONObject person = (JSONObject) personJsonArray.get(i); + JSONObject personData = new JSONObject(); + //工号 + personData.put("workcode",person.get("no")); + //姓名 + personData.put("lastname",person.get("name")); + //性别 + personData.put("sex",person.get("sex")); + //所在部门 + personData.put("departmentid",person.get("parent")); + //所在分部 + personData.put("subcompanyid1",person.get("orgCode")); + //直接上级 + personData.put("managerid",""); + //安全级别 + personData.put("seclevl",""); + //人员状态 + try{ + boolean isAvailable = (boolean) person.get("isAvailable"); + if(isAvailable){ + personData.put("status","1"); + }else{ + personData.put("status","5"); + } + }catch (Exception e){ + logger.error("isAvailable exception;isAvailable:" + person.get("isAvailable")); + personData.put("status","1"); + } + //国籍 + personData.put("nationalID",""); + //民族 + personData.put("folk",""); + //身份证号码 + personData.put("certificatenum",person.get("fdIdCard")); + //工作地点 + personData.put("locationid",""); + //电子邮件 + personData.put("email",person.get("email")); + //手机 + personData.put("mobile",person.get("mobileNo")); + //岗位 + personData.put("jobtitle",""); + //岗位级别 + personData.put("joblevel",""); + //入职日期 + String hiredate = (String) person.get("hiredate"); + if(hiredate != null && !"".equals(hiredate)){ + hiredate = hiredate.substring(0,10); + } + personData.put("Com_date",hiredate ); + //离职日期 + String fdLeaveTime = (String) person.get("fdLeaveTime"); + if(fdLeaveTime != null && !"".equals(fdLeaveTime)){ + fdLeaveTime = fdLeaveTime.substring(0,10); + } + personData.put("quitdate",fdLeaveTime); + //插入时间 + personData.put("Createdate",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + //班组 + personData.put("bz",person.get("fdWorkTeam")); + //部门编码 + personData.put("bmbm",person.get("parent")); + //工作性质 + personData.put("gzxz",person.get("fdWorkType")); + //编号 + personData.put("bh",person.get("lunid")); + //层级ID + personData.put("cjid",person.get("fdHierarchyId")); + //员工类型 + try{ + String yglx = ""; + String fdPersonType = (String) person.get("fdPersonType"); + if("1".equals(fdPersonType)){ + yglx = "0"; + }else if("2".equals(fdPersonType)){ + yglx = "1"; + }else if("3".equals(fdPersonType)){ + yglx = "2"; + }else if("4".equals(fdPersonType)){ + yglx = "3"; + } + if("".equals(yglx) || "1".equals(yglx) || "2".equals(yglx) || "3".equals(yglx)){ + continue; + } + personData.put("yglx",yglx); + }catch(Exception e){ + logger.error("yglx exception;message:" + e.getMessage()); + } + //机构编码 + personData.put("jgbm",person.get("orgCode")); + //劳务关系 + personData.put("lwgx",person.get("fdLaborRelation")); + //keyword + personData.put("keyword",person.get("keyword")); + //order + personData.put("order1",person.get("order")); + //数据类型 + personData.put("sjlx",person.get("type")); + //id + personData.put("personid",person.get("id")); + TjwModelUtil.addOrUpdateModelData(rs,personInfoTable,personData,"workcode"); + } + } + +} + diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/Exception.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/Exception.java new file mode 100644 index 0000000..454e350 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/Exception.java @@ -0,0 +1,127 @@ +/** + * Exception.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class Exception extends org.apache.axis.AxisFault implements java.io.Serializable { + private java.lang.String message1; + + public Exception() { + } + + public Exception( + java.lang.String message1) { + this.message1 = message1; + } + + + /** + * Gets the message1 value for this Exception. + * + * @return message1 + */ + public java.lang.String getMessage1() { + return message1; + } + + + /** + * Sets the message1 value for this Exception. + * + * @param message1 + */ + public void setMessage1(java.lang.String message1) { + this.message1 = message1; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof Exception)) return false; + Exception other = (Exception) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.message1==null && other.getMessage1()==null) || + (this.message1!=null && + this.message1.equals(other.getMessage1()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getMessage1() != null) { + _hashCode += getMessage1().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(Exception.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + + + /** + * Writes the exception data to the faultDetails + */ + public void writeDetails(javax.xml.namespace.QName qname, org.apache.axis.encoding.SerializationContext context) throws java.io.IOException { + context.serialize(qname, null, this); + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebService.java new file mode 100644 index 0000000..25ca1c5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebService.java @@ -0,0 +1,24 @@ +/** + * ISysSynchroGetOrgWebService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public interface ISysSynchroGetOrgWebService extends java.rmi.Remote { + public SysSynchroOrgResult getRoleLineInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getOrgStaffingLevelInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getRoleLineDefaultRoleInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getRoleInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getUpdatedElementsV2(SysSynchroGetOrgInfoContextV2 arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getUpdatedElements(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgTokenResult getUpdatedElementsByToken(SysSynchroGetOrgInfoTokenContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getRoleConfMemberInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getOrgGroupCateInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getRoleConfInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getElementsBaseInfo(SysSynchroGetOrgBaseInfoContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getElementsBaseInfoV2(SysSynchroGetOrgBaseInfoContextV2 arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.Exception; + public SysSynchroOrgResult getRoleConfCateInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceService.java new file mode 100644 index 0000000..c6f9406 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceService.java @@ -0,0 +1,16 @@ +/** + * ISysSynchroGetOrgWebServiceService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public interface ISysSynchroGetOrgWebServiceService extends javax.xml.rpc.Service { + public java.lang.String getISysSynchroGetOrgWebServicePortAddress(); + + public com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.ISysSynchroGetOrgWebService getISysSynchroGetOrgWebServicePort() throws javax.xml.rpc.ServiceException; + + public ISysSynchroGetOrgWebService getISysSynchroGetOrgWebServicePort(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceServiceLocator.java new file mode 100644 index 0000000..3d6d2c2 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceServiceLocator.java @@ -0,0 +1,142 @@ +/** + * ISysSynchroGetOrgWebServiceServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class ISysSynchroGetOrgWebServiceServiceLocator extends org.apache.axis.client.Service implements ISysSynchroGetOrgWebServiceService { + + public ISysSynchroGetOrgWebServiceServiceLocator() { + } + + + public ISysSynchroGetOrgWebServiceServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public ISysSynchroGetOrgWebServiceServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for ISysSynchroGetOrgWebServicePort + private java.lang.String ISysSynchroGetOrgWebServicePort_address = "http://oa.sh-liangxin.com/sys/webservice/sysSynchroGetOrgWebService"; + + public java.lang.String getISysSynchroGetOrgWebServicePortAddress() { + return ISysSynchroGetOrgWebServicePort_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String ISysSynchroGetOrgWebServicePortWSDDServiceName = "ISysSynchroGetOrgWebServicePort"; + + public java.lang.String getISysSynchroGetOrgWebServicePortWSDDServiceName() { + return ISysSynchroGetOrgWebServicePortWSDDServiceName; + } + + public void setISysSynchroGetOrgWebServicePortWSDDServiceName(java.lang.String name) { + ISysSynchroGetOrgWebServicePortWSDDServiceName = name; + } + + public ISysSynchroGetOrgWebService getISysSynchroGetOrgWebServicePort() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(ISysSynchroGetOrgWebServicePort_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getISysSynchroGetOrgWebServicePort(endpoint); + } + + public ISysSynchroGetOrgWebService getISysSynchroGetOrgWebServicePort(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + ISysSynchroGetOrgWebServiceServiceSoapBindingStub _stub = new ISysSynchroGetOrgWebServiceServiceSoapBindingStub(portAddress, this); + _stub.setPortName(getISysSynchroGetOrgWebServicePortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setISysSynchroGetOrgWebServicePortEndpointAddress(java.lang.String address) { + ISysSynchroGetOrgWebServicePort_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (ISysSynchroGetOrgWebService.class.isAssignableFrom(serviceEndpointInterface)) { + ISysSynchroGetOrgWebServiceServiceSoapBindingStub _stub = new ISysSynchroGetOrgWebServiceServiceSoapBindingStub(new java.net.URL(ISysSynchroGetOrgWebServicePort_address), this); + _stub.setPortName(getISysSynchroGetOrgWebServicePortWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("ISysSynchroGetOrgWebServicePort".equals(inputPortName)) { + return getISysSynchroGetOrgWebServicePort(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "ISysSynchroGetOrgWebServiceService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "ISysSynchroGetOrgWebServicePort")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("ISysSynchroGetOrgWebServicePort".equals(portName)) { + setISysSynchroGetOrgWebServicePortEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceServiceSoapBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceServiceSoapBindingStub.java new file mode 100644 index 0000000..50f24e1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/ISysSynchroGetOrgWebServiceServiceSoapBindingStub.java @@ -0,0 +1,972 @@ +/** + * ISysSynchroGetOrgWebServiceServiceSoapBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class ISysSynchroGetOrgWebServiceServiceSoapBindingStub extends org.apache.axis.client.Stub implements ISysSynchroGetOrgWebService { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[13]; + _initOperationDesc1(); + _initOperationDesc2(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getOrgStaffingLevelInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getRoleLineInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getRoleLineDefaultRoleInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getRoleInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[3] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getUpdatedElementsV2"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContextV2"), SysSynchroGetOrgInfoContextV2.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[4] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getUpdatedElements"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[5] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getUpdatedElementsByToken"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoTokenContext"), SysSynchroGetOrgInfoTokenContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgTokenResult")); + oper.setReturnClass(SysSynchroOrgTokenResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[6] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getRoleConfMemberInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[7] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getOrgGroupCateInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[8] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getRoleConfInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[9] = oper; + + } + + private static void _initOperationDesc2(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getElementsBaseInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgBaseInfoContext"), SysSynchroGetOrgBaseInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[10] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getElementsBaseInfoV2"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgBaseInfoContextV2"), SysSynchroGetOrgBaseInfoContextV2.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[11] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getRoleConfCateInfo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"), SysSynchroGetOrgInfoContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + oper.setReturnClass(SysSynchroOrgResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + "weaver.taojw.liangxin.cronjob.webservice.Exception", + new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[12] = oper; + + } + + public ISysSynchroGetOrgWebServiceServiceSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public ISysSynchroGetOrgWebServiceServiceSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public ISysSynchroGetOrgWebServiceServiceSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "Exception"); + cachedSerQNames.add(qName); + cls = Exception.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgBaseInfoContext"); + cachedSerQNames.add(qName); + cls = SysSynchroGetOrgBaseInfoContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgBaseInfoContextV2"); + cachedSerQNames.add(qName); + cls = SysSynchroGetOrgBaseInfoContextV2.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgContext"); + cachedSerQNames.add(qName); + cls = SysSynchroGetOrgContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext"); + cachedSerQNames.add(qName); + cls = SysSynchroGetOrgInfoContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContextV2"); + cachedSerQNames.add(qName); + cls = SysSynchroGetOrgInfoContextV2.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoTokenContext"); + cachedSerQNames.add(qName); + cls = SysSynchroGetOrgInfoTokenContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult"); + cachedSerQNames.add(qName); + cls = SysSynchroOrgResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgTokenResult"); + cachedSerQNames.add(qName); + cls = SysSynchroOrgTokenResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public SysSynchroOrgResult getOrgStaffingLevelInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getOrgStaffingLevelInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getRoleLineInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getRoleLineInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getRoleLineDefaultRoleInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getRoleLineDefaultRoleInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getRoleInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getRoleInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getUpdatedElementsV2(SysSynchroGetOrgInfoContextV2 arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[4]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getUpdatedElementsV2")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getUpdatedElements(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[5]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getUpdatedElements")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgTokenResult getUpdatedElementsByToken(SysSynchroGetOrgInfoTokenContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[6]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getUpdatedElementsByToken")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgTokenResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgTokenResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgTokenResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getRoleConfMemberInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[7]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getRoleConfMemberInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getOrgGroupCateInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[8]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getOrgGroupCateInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getRoleConfInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[9]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getRoleConfInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getElementsBaseInfo(SysSynchroGetOrgBaseInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[10]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getElementsBaseInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getElementsBaseInfoV2(SysSynchroGetOrgBaseInfoContextV2 arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[11]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getElementsBaseInfoV2")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public SysSynchroOrgResult getRoleConfCateInfo(SysSynchroGetOrgInfoContext arg0) throws java.rmi.RemoteException, Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[12]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "getRoleConfCateInfo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (SysSynchroOrgResult) _resp; + } catch (java.lang.Exception _exception) { + return (SysSynchroOrgResult) org.apache.axis.utils.JavaUtils.convert(_resp, SysSynchroOrgResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof Exception) { + throw (Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgBaseInfoContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgBaseInfoContext.java new file mode 100644 index 0000000..871f234 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgBaseInfoContext.java @@ -0,0 +1,162 @@ +/** + * SysSynchroGetOrgBaseInfoContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroGetOrgBaseInfoContext extends SysSynchroGetOrgContext implements java.io.Serializable { + private java.lang.String beginTimeStamp; + + private java.lang.String returnType; + + public SysSynchroGetOrgBaseInfoContext() { + } + + public SysSynchroGetOrgBaseInfoContext( + java.lang.String returnOrgType, + java.lang.String specifiedDate, + java.lang.String beginTimeStamp, + java.lang.String returnType) { + super( + returnOrgType, + specifiedDate); + this.beginTimeStamp = beginTimeStamp; + this.returnType = returnType; + } + + + /** + * Gets the beginTimeStamp value for this SysSynchroGetOrgBaseInfoContext. + * + * @return beginTimeStamp + */ + public java.lang.String getBeginTimeStamp() { + return beginTimeStamp; + } + + + /** + * Sets the beginTimeStamp value for this SysSynchroGetOrgBaseInfoContext. + * + * @param beginTimeStamp + */ + public void setBeginTimeStamp(java.lang.String beginTimeStamp) { + this.beginTimeStamp = beginTimeStamp; + } + + + /** + * Gets the returnType value for this SysSynchroGetOrgBaseInfoContext. + * + * @return returnType + */ + public java.lang.String getReturnType() { + return returnType; + } + + + /** + * Sets the returnType value for this SysSynchroGetOrgBaseInfoContext. + * + * @param returnType + */ + public void setReturnType(java.lang.String returnType) { + this.returnType = returnType; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroGetOrgBaseInfoContext)) return false; + SysSynchroGetOrgBaseInfoContext other = (SysSynchroGetOrgBaseInfoContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = super.equals(obj) && + ((this.beginTimeStamp==null && other.getBeginTimeStamp()==null) || + (this.beginTimeStamp!=null && + this.beginTimeStamp.equals(other.getBeginTimeStamp()))) && + ((this.returnType==null && other.getReturnType()==null) || + (this.returnType!=null && + this.returnType.equals(other.getReturnType()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = super.hashCode(); + if (getBeginTimeStamp() != null) { + _hashCode += getBeginTimeStamp().hashCode(); + } + if (getReturnType() != null) { + _hashCode += getReturnType().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroGetOrgBaseInfoContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgBaseInfoContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("beginTimeStamp"); + elemField.setXmlName(new javax.xml.namespace.QName("", "beginTimeStamp")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnType"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnType")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgBaseInfoContextV2.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgBaseInfoContextV2.java new file mode 100644 index 0000000..b44ac46 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgBaseInfoContextV2.java @@ -0,0 +1,166 @@ +/** + * SysSynchroGetOrgBaseInfoContextV2.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroGetOrgBaseInfoContextV2 extends SysSynchroGetOrgBaseInfoContext implements java.io.Serializable { + private java.lang.String extendPara; + + private java.lang.Boolean isBusiness; + + public SysSynchroGetOrgBaseInfoContextV2() { + } + + public SysSynchroGetOrgBaseInfoContextV2( + java.lang.String returnOrgType, + java.lang.String specifiedDate, + java.lang.String beginTimeStamp, + java.lang.String returnType, + java.lang.String extendPara, + java.lang.Boolean isBusiness) { + super( + returnOrgType, + specifiedDate, + beginTimeStamp, + returnType); + this.extendPara = extendPara; + this.isBusiness = isBusiness; + } + + + /** + * Gets the extendPara value for this SysSynchroGetOrgBaseInfoContextV2. + * + * @return extendPara + */ + public java.lang.String getExtendPara() { + return extendPara; + } + + + /** + * Sets the extendPara value for this SysSynchroGetOrgBaseInfoContextV2. + * + * @param extendPara + */ + public void setExtendPara(java.lang.String extendPara) { + this.extendPara = extendPara; + } + + + /** + * Gets the isBusiness value for this SysSynchroGetOrgBaseInfoContextV2. + * + * @return isBusiness + */ + public java.lang.Boolean getIsBusiness() { + return isBusiness; + } + + + /** + * Sets the isBusiness value for this SysSynchroGetOrgBaseInfoContextV2. + * + * @param isBusiness + */ + public void setIsBusiness(java.lang.Boolean isBusiness) { + this.isBusiness = isBusiness; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroGetOrgBaseInfoContextV2)) return false; + SysSynchroGetOrgBaseInfoContextV2 other = (SysSynchroGetOrgBaseInfoContextV2) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = super.equals(obj) && + ((this.extendPara==null && other.getExtendPara()==null) || + (this.extendPara!=null && + this.extendPara.equals(other.getExtendPara()))) && + ((this.isBusiness==null && other.getIsBusiness()==null) || + (this.isBusiness!=null && + this.isBusiness.equals(other.getIsBusiness()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = super.hashCode(); + if (getExtendPara() != null) { + _hashCode += getExtendPara().hashCode(); + } + if (getIsBusiness() != null) { + _hashCode += getIsBusiness().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroGetOrgBaseInfoContextV2.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgBaseInfoContextV2")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("extendPara"); + elemField.setXmlName(new javax.xml.namespace.QName("", "extendPara")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("isBusiness"); + elemField.setXmlName(new javax.xml.namespace.QName("", "isBusiness")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgContext.java new file mode 100644 index 0000000..73fd4d8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgContext.java @@ -0,0 +1,157 @@ +/** + * SysSynchroGetOrgContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroGetOrgContext implements java.io.Serializable { + private java.lang.String returnOrgType; + + private java.lang.String specifiedDate; + + public SysSynchroGetOrgContext() { + } + + public SysSynchroGetOrgContext( + java.lang.String returnOrgType, + java.lang.String specifiedDate) { + this.returnOrgType = returnOrgType; + this.specifiedDate = specifiedDate; + } + + + /** + * Gets the returnOrgType value for this SysSynchroGetOrgContext. + * + * @return returnOrgType + */ + public java.lang.String getReturnOrgType() { + return returnOrgType; + } + + + /** + * Sets the returnOrgType value for this SysSynchroGetOrgContext. + * + * @param returnOrgType + */ + public void setReturnOrgType(java.lang.String returnOrgType) { + this.returnOrgType = returnOrgType; + } + + + /** + * Gets the specifiedDate value for this SysSynchroGetOrgContext. + * + * @return specifiedDate + */ + public java.lang.String getSpecifiedDate() { + return specifiedDate; + } + + + /** + * Sets the specifiedDate value for this SysSynchroGetOrgContext. + * + * @param specifiedDate + */ + public void setSpecifiedDate(java.lang.String specifiedDate) { + this.specifiedDate = specifiedDate; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroGetOrgContext)) return false; + SysSynchroGetOrgContext other = (SysSynchroGetOrgContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.returnOrgType==null && other.getReturnOrgType()==null) || + (this.returnOrgType!=null && + this.returnOrgType.equals(other.getReturnOrgType()))) && + ((this.specifiedDate==null && other.getSpecifiedDate()==null) || + (this.specifiedDate!=null && + this.specifiedDate.equals(other.getSpecifiedDate()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getReturnOrgType() != null) { + _hashCode += getReturnOrgType().hashCode(); + } + if (getSpecifiedDate() != null) { + _hashCode += getSpecifiedDate().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroGetOrgContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnOrgType"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnOrgType")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("specifiedDate"); + elemField.setXmlName(new javax.xml.namespace.QName("", "specifiedDate")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoContext.java new file mode 100644 index 0000000..9045329 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoContext.java @@ -0,0 +1,157 @@ +/** + * SysSynchroGetOrgInfoContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroGetOrgInfoContext extends SysSynchroGetOrgContext implements java.io.Serializable { + private java.lang.String beginTimeStamp; + + private int count; + + public SysSynchroGetOrgInfoContext() { + } + + public SysSynchroGetOrgInfoContext( + java.lang.String returnOrgType, + java.lang.String specifiedDate, + java.lang.String beginTimeStamp, + int count) { + super( + returnOrgType, + specifiedDate); + this.beginTimeStamp = beginTimeStamp; + this.count = count; + } + + + /** + * Gets the beginTimeStamp value for this SysSynchroGetOrgInfoContext. + * + * @return beginTimeStamp + */ + public java.lang.String getBeginTimeStamp() { + return beginTimeStamp; + } + + + /** + * Sets the beginTimeStamp value for this SysSynchroGetOrgInfoContext. + * + * @param beginTimeStamp + */ + public void setBeginTimeStamp(java.lang.String beginTimeStamp) { + this.beginTimeStamp = beginTimeStamp; + } + + + /** + * Gets the count value for this SysSynchroGetOrgInfoContext. + * + * @return count + */ + public int getCount() { + return count; + } + + + /** + * Sets the count value for this SysSynchroGetOrgInfoContext. + * + * @param count + */ + public void setCount(int count) { + this.count = count; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroGetOrgInfoContext)) return false; + SysSynchroGetOrgInfoContext other = (SysSynchroGetOrgInfoContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = super.equals(obj) && + ((this.beginTimeStamp==null && other.getBeginTimeStamp()==null) || + (this.beginTimeStamp!=null && + this.beginTimeStamp.equals(other.getBeginTimeStamp()))) && + this.count == other.getCount(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = super.hashCode(); + if (getBeginTimeStamp() != null) { + _hashCode += getBeginTimeStamp().hashCode(); + } + _hashCode += getCount(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroGetOrgInfoContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("beginTimeStamp"); + elemField.setXmlName(new javax.xml.namespace.QName("", "beginTimeStamp")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("count"); + elemField.setXmlName(new javax.xml.namespace.QName("", "count")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoContextV2.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoContextV2.java new file mode 100644 index 0000000..683ec6a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoContextV2.java @@ -0,0 +1,166 @@ +/** + * SysSynchroGetOrgInfoContextV2.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroGetOrgInfoContextV2 extends SysSynchroGetOrgInfoContext implements java.io.Serializable { + private java.lang.String extendPara; + + private java.lang.Boolean isBusiness; + + public SysSynchroGetOrgInfoContextV2() { + } + + public SysSynchroGetOrgInfoContextV2( + java.lang.String returnOrgType, + java.lang.String specifiedDate, + java.lang.String beginTimeStamp, + int count, + java.lang.String extendPara, + java.lang.Boolean isBusiness) { + super( + returnOrgType, + specifiedDate, + beginTimeStamp, + count); + this.extendPara = extendPara; + this.isBusiness = isBusiness; + } + + + /** + * Gets the extendPara value for this SysSynchroGetOrgInfoContextV2. + * + * @return extendPara + */ + public java.lang.String getExtendPara() { + return extendPara; + } + + + /** + * Sets the extendPara value for this SysSynchroGetOrgInfoContextV2. + * + * @param extendPara + */ + public void setExtendPara(java.lang.String extendPara) { + this.extendPara = extendPara; + } + + + /** + * Gets the isBusiness value for this SysSynchroGetOrgInfoContextV2. + * + * @return isBusiness + */ + public java.lang.Boolean getIsBusiness() { + return isBusiness; + } + + + /** + * Sets the isBusiness value for this SysSynchroGetOrgInfoContextV2. + * + * @param isBusiness + */ + public void setIsBusiness(java.lang.Boolean isBusiness) { + this.isBusiness = isBusiness; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroGetOrgInfoContextV2)) return false; + SysSynchroGetOrgInfoContextV2 other = (SysSynchroGetOrgInfoContextV2) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = super.equals(obj) && + ((this.extendPara==null && other.getExtendPara()==null) || + (this.extendPara!=null && + this.extendPara.equals(other.getExtendPara()))) && + ((this.isBusiness==null && other.getIsBusiness()==null) || + (this.isBusiness!=null && + this.isBusiness.equals(other.getIsBusiness()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = super.hashCode(); + if (getExtendPara() != null) { + _hashCode += getExtendPara().hashCode(); + } + if (getIsBusiness() != null) { + _hashCode += getIsBusiness().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroGetOrgInfoContextV2.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoContextV2")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("extendPara"); + elemField.setXmlName(new javax.xml.namespace.QName("", "extendPara")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("isBusiness"); + elemField.setXmlName(new javax.xml.namespace.QName("", "isBusiness")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoTokenContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoTokenContext.java new file mode 100644 index 0000000..740fd96 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroGetOrgInfoTokenContext.java @@ -0,0 +1,161 @@ +/** + * SysSynchroGetOrgInfoTokenContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroGetOrgInfoTokenContext extends SysSynchroGetOrgInfoContext implements java.io.Serializable { + private int pageNo; + + private java.lang.String token; + + public SysSynchroGetOrgInfoTokenContext() { + } + + public SysSynchroGetOrgInfoTokenContext( + java.lang.String returnOrgType, + java.lang.String specifiedDate, + java.lang.String beginTimeStamp, + int count, + int pageNo, + java.lang.String token) { + super( + returnOrgType, + specifiedDate, + beginTimeStamp, + count); + this.pageNo = pageNo; + this.token = token; + } + + + /** + * Gets the pageNo value for this SysSynchroGetOrgInfoTokenContext. + * + * @return pageNo + */ + public int getPageNo() { + return pageNo; + } + + + /** + * Sets the pageNo value for this SysSynchroGetOrgInfoTokenContext. + * + * @param pageNo + */ + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + + /** + * Gets the token value for this SysSynchroGetOrgInfoTokenContext. + * + * @return token + */ + public java.lang.String getToken() { + return token; + } + + + /** + * Sets the token value for this SysSynchroGetOrgInfoTokenContext. + * + * @param token + */ + public void setToken(java.lang.String token) { + this.token = token; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroGetOrgInfoTokenContext)) return false; + SysSynchroGetOrgInfoTokenContext other = (SysSynchroGetOrgInfoTokenContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = super.equals(obj) && + this.pageNo == other.getPageNo() && + ((this.token==null && other.getToken()==null) || + (this.token!=null && + this.token.equals(other.getToken()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = super.hashCode(); + _hashCode += getPageNo(); + if (getToken() != null) { + _hashCode += getToken().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroGetOrgInfoTokenContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroGetOrgInfoTokenContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("pageNo"); + elemField.setXmlName(new javax.xml.namespace.QName("", "pageNo")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("token"); + elemField.setXmlName(new javax.xml.namespace.QName("", "token")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroOrgResult.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroOrgResult.java new file mode 100644 index 0000000..c360ad1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroOrgResult.java @@ -0,0 +1,221 @@ +/** + * SysSynchroOrgResult.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroOrgResult implements java.io.Serializable { + private int count; + + private java.lang.String message; + + private int returnState; + + private java.lang.String timeStamp; + + public SysSynchroOrgResult() { + } + + public SysSynchroOrgResult( + int count, + java.lang.String message, + int returnState, + java.lang.String timeStamp) { + this.count = count; + this.message = message; + this.returnState = returnState; + this.timeStamp = timeStamp; + } + + + /** + * Gets the count value for this SysSynchroOrgResult. + * + * @return count + */ + public int getCount() { + return count; + } + + + /** + * Sets the count value for this SysSynchroOrgResult. + * + * @param count + */ + public void setCount(int count) { + this.count = count; + } + + + /** + * Gets the message value for this SysSynchroOrgResult. + * + * @return message + */ + public java.lang.String getMessage() { + return message; + } + + + /** + * Sets the message value for this SysSynchroOrgResult. + * + * @param message + */ + public void setMessage(java.lang.String message) { + this.message = message; + } + + + /** + * Gets the returnState value for this SysSynchroOrgResult. + * + * @return returnState + */ + public int getReturnState() { + return returnState; + } + + + /** + * Sets the returnState value for this SysSynchroOrgResult. + * + * @param returnState + */ + public void setReturnState(int returnState) { + this.returnState = returnState; + } + + + /** + * Gets the timeStamp value for this SysSynchroOrgResult. + * + * @return timeStamp + */ + public java.lang.String getTimeStamp() { + return timeStamp; + } + + + /** + * Sets the timeStamp value for this SysSynchroOrgResult. + * + * @param timeStamp + */ + public void setTimeStamp(java.lang.String timeStamp) { + this.timeStamp = timeStamp; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroOrgResult)) return false; + SysSynchroOrgResult other = (SysSynchroOrgResult) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + this.count == other.getCount() && + ((this.message==null && other.getMessage()==null) || + (this.message!=null && + this.message.equals(other.getMessage()))) && + this.returnState == other.getReturnState() && + ((this.timeStamp==null && other.getTimeStamp()==null) || + (this.timeStamp!=null && + this.timeStamp.equals(other.getTimeStamp()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + _hashCode += getCount(); + if (getMessage() != null) { + _hashCode += getMessage().hashCode(); + } + _hashCode += getReturnState(); + if (getTimeStamp() != null) { + _hashCode += getTimeStamp().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroOrgResult.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgResult")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("count"); + elemField.setXmlName(new javax.xml.namespace.QName("", "count")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnState"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnState")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("timeStamp"); + elemField.setXmlName(new javax.xml.namespace.QName("", "timeStamp")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroOrgTokenResult.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroOrgTokenResult.java new file mode 100644 index 0000000..e4cae79 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/baseinfocronjob/syncbaseinfowebservice/SysSynchroOrgTokenResult.java @@ -0,0 +1,221 @@ +/** + * SysSynchroOrgTokenResult.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice; + +public class SysSynchroOrgTokenResult implements java.io.Serializable { + private int count; + + private java.lang.String message; + + private int returnState; + + private java.lang.String token; + + public SysSynchroOrgTokenResult() { + } + + public SysSynchroOrgTokenResult( + int count, + java.lang.String message, + int returnState, + java.lang.String token) { + this.count = count; + this.message = message; + this.returnState = returnState; + this.token = token; + } + + + /** + * Gets the count value for this SysSynchroOrgTokenResult. + * + * @return count + */ + public int getCount() { + return count; + } + + + /** + * Sets the count value for this SysSynchroOrgTokenResult. + * + * @param count + */ + public void setCount(int count) { + this.count = count; + } + + + /** + * Gets the message value for this SysSynchroOrgTokenResult. + * + * @return message + */ + public java.lang.String getMessage() { + return message; + } + + + /** + * Sets the message value for this SysSynchroOrgTokenResult. + * + * @param message + */ + public void setMessage(java.lang.String message) { + this.message = message; + } + + + /** + * Gets the returnState value for this SysSynchroOrgTokenResult. + * + * @return returnState + */ + public int getReturnState() { + return returnState; + } + + + /** + * Sets the returnState value for this SysSynchroOrgTokenResult. + * + * @param returnState + */ + public void setReturnState(int returnState) { + this.returnState = returnState; + } + + + /** + * Gets the token value for this SysSynchroOrgTokenResult. + * + * @return token + */ + public java.lang.String getToken() { + return token; + } + + + /** + * Sets the token value for this SysSynchroOrgTokenResult. + * + * @param token + */ + public void setToken(java.lang.String token) { + this.token = token; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SysSynchroOrgTokenResult)) return false; + SysSynchroOrgTokenResult other = (SysSynchroOrgTokenResult) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + this.count == other.getCount() && + ((this.message==null && other.getMessage()==null) || + (this.message!=null && + this.message.equals(other.getMessage()))) && + this.returnState == other.getReturnState() && + ((this.token==null && other.getToken()==null) || + (this.token!=null && + this.token.equals(other.getToken()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + _hashCode += getCount(); + if (getMessage() != null) { + _hashCode += getMessage().hashCode(); + } + _hashCode += getReturnState(); + if (getToken() != null) { + _hashCode += getToken().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SysSynchroOrgTokenResult.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://out.webservice.organization.sys.kmss.landray.com/", "sysSynchroOrgTokenResult")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("count"); + elemField.setXmlName(new javax.xml.namespace.QName("", "count")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnState"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnState")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("token"); + elemField.setXmlName(new javax.xml.namespace.QName("", "token")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/SapCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/SapCronJob.java new file mode 100644 index 0000000..03024d9 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/SapCronJob.java @@ -0,0 +1,83 @@ +package com.api.taojw.liangxin.sap; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ; +import com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN; +import com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub; +import com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.net.URL; + +public class SapCronJob extends BaseCronJob { + + private String url = ""; + private String modelTableName = ""; + private String userName = ""; + private String password = ""; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getModelTableName() { + return modelTableName; + } + + public void setModelTableName(String modelTableName) { + this.modelTableName = modelTableName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info("SapCronJob.execute begin"); + RecordSet rs = new RecordSet(); + URL wbUrl = new URL(url); + SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator locator = new SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator(); + SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub stub = new SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(wbUrl,locator); + stub.setUsername(userName); + stub.setPassword(password); + DT_OA_GET_INTERNAL_FI_ORDER_REQ req = new DT_OA_GET_INTERNAL_FI_ORDER_REQ(); + DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[] dt_oa_get_internal_fi_order_respet_returns = stub.SI_OA_GET_INTERNAL_FI_ORDER_Out(req); + for(DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN data : dt_oa_get_internal_fi_order_respet_returns){ + JSONObject o = new JSONObject(); + o.put("sapbh",data.getAUFNR()); + o.put("xmbh",data.getAUFEX()); + o.put("msnr",data.getKTEXT()); + o.put("BUKRS",data.getBUKRS()); + TjwModelUtil.addOrUpdateModelData(rs,modelTableName,o,"sapbh"); + } + logger.info("SapCronJob.execute end"); + }catch(Exception e){ + logger.error("SapCronJob.execute exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java new file mode 100644 index 0000000..abf3f9d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java @@ -0,0 +1,120 @@ +/** + * DT_OA_GET_INTERNAL_FI_ORDER_REQ.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.sap.webservice; + +public class DT_OA_GET_INTERNAL_FI_ORDER_REQ implements java.io.Serializable { + private java.lang.String IV_DATUM; + + public DT_OA_GET_INTERNAL_FI_ORDER_REQ() { + } + + public DT_OA_GET_INTERNAL_FI_ORDER_REQ( + java.lang.String IV_DATUM) { + this.IV_DATUM = IV_DATUM; + } + + + /** + * Gets the IV_DATUM value for this DT_OA_GET_INTERNAL_FI_ORDER_REQ. + * + * @return IV_DATUM + */ + public java.lang.String getIV_DATUM() { + return IV_DATUM; + } + + + /** + * Sets the IV_DATUM value for this DT_OA_GET_INTERNAL_FI_ORDER_REQ. + * + * @param IV_DATUM + */ + public void setIV_DATUM(java.lang.String IV_DATUM) { + this.IV_DATUM = IV_DATUM; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof DT_OA_GET_INTERNAL_FI_ORDER_REQ)) return false; + DT_OA_GET_INTERNAL_FI_ORDER_REQ other = (DT_OA_GET_INTERNAL_FI_ORDER_REQ) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.IV_DATUM==null && other.getIV_DATUM()==null) || + (this.IV_DATUM!=null && + this.IV_DATUM.equals(other.getIV_DATUM()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getIV_DATUM() != null) { + _hashCode += getIV_DATUM().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(DT_OA_GET_INTERNAL_FI_ORDER_REQ.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("IV_DATUM"); + elemField.setXmlName(new javax.xml.namespace.QName("", "IV_DATUM")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java new file mode 100644 index 0000000..11c58c1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java @@ -0,0 +1,342 @@ +/** + * DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.sap.webservice; + +public class DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN implements java.io.Serializable { + private java.lang.String AUFNR; + + private java.lang.String AUART; + + private java.lang.String KTEXT; + + private java.lang.String ZORDER_STAT; + + private java.lang.String BUKRS; + + private java.lang.String KOSTV; + + private java.lang.String AUFEX; + + public DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN() { + } + + public DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN( + java.lang.String AUFNR, + java.lang.String AUART, + java.lang.String KTEXT, + java.lang.String ZORDER_STAT, + java.lang.String BUKRS, + java.lang.String KOSTV, + java.lang.String AUFEX) { + this.AUFNR = AUFNR; + this.AUART = AUART; + this.KTEXT = KTEXT; + this.ZORDER_STAT = ZORDER_STAT; + this.BUKRS = BUKRS; + this.KOSTV = KOSTV; + this.AUFEX = AUFEX; + } + + + /** + * Gets the AUFNR value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return AUFNR + */ + public java.lang.String getAUFNR() { + return AUFNR; + } + + + /** + * Sets the AUFNR value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param AUFNR + */ + public void setAUFNR(java.lang.String AUFNR) { + this.AUFNR = AUFNR; + } + + + /** + * Gets the AUART value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return AUART + */ + public java.lang.String getAUART() { + return AUART; + } + + + /** + * Sets the AUART value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param AUART + */ + public void setAUART(java.lang.String AUART) { + this.AUART = AUART; + } + + + /** + * Gets the KTEXT value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return KTEXT + */ + public java.lang.String getKTEXT() { + return KTEXT; + } + + + /** + * Sets the KTEXT value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param KTEXT + */ + public void setKTEXT(java.lang.String KTEXT) { + this.KTEXT = KTEXT; + } + + + /** + * Gets the ZORDER_STAT value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return ZORDER_STAT + */ + public java.lang.String getZORDER_STAT() { + return ZORDER_STAT; + } + + + /** + * Sets the ZORDER_STAT value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param ZORDER_STAT + */ + public void setZORDER_STAT(java.lang.String ZORDER_STAT) { + this.ZORDER_STAT = ZORDER_STAT; + } + + + /** + * Gets the BUKRS value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return BUKRS + */ + public java.lang.String getBUKRS() { + return BUKRS; + } + + + /** + * Sets the BUKRS value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param BUKRS + */ + public void setBUKRS(java.lang.String BUKRS) { + this.BUKRS = BUKRS; + } + + + /** + * Gets the KOSTV value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return KOSTV + */ + public java.lang.String getKOSTV() { + return KOSTV; + } + + + /** + * Sets the KOSTV value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param KOSTV + */ + public void setKOSTV(java.lang.String KOSTV) { + this.KOSTV = KOSTV; + } + + + /** + * Gets the AUFEX value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @return AUFEX + */ + public java.lang.String getAUFEX() { + return AUFEX; + } + + + /** + * Sets the AUFEX value for this DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN. + * + * @param AUFEX + */ + public void setAUFEX(java.lang.String AUFEX) { + this.AUFEX = AUFEX; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN)) return false; + DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN other = (DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.AUFNR==null && other.getAUFNR()==null) || + (this.AUFNR!=null && + this.AUFNR.equals(other.getAUFNR()))) && + ((this.AUART==null && other.getAUART()==null) || + (this.AUART!=null && + this.AUART.equals(other.getAUART()))) && + ((this.KTEXT==null && other.getKTEXT()==null) || + (this.KTEXT!=null && + this.KTEXT.equals(other.getKTEXT()))) && + ((this.ZORDER_STAT==null && other.getZORDER_STAT()==null) || + (this.ZORDER_STAT!=null && + this.ZORDER_STAT.equals(other.getZORDER_STAT()))) && + ((this.BUKRS==null && other.getBUKRS()==null) || + (this.BUKRS!=null && + this.BUKRS.equals(other.getBUKRS()))) && + ((this.KOSTV==null && other.getKOSTV()==null) || + (this.KOSTV!=null && + this.KOSTV.equals(other.getKOSTV()))) && + ((this.AUFEX==null && other.getAUFEX()==null) || + (this.AUFEX!=null && + this.AUFEX.equals(other.getAUFEX()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAUFNR() != null) { + _hashCode += getAUFNR().hashCode(); + } + if (getAUART() != null) { + _hashCode += getAUART().hashCode(); + } + if (getKTEXT() != null) { + _hashCode += getKTEXT().hashCode(); + } + if (getZORDER_STAT() != null) { + _hashCode += getZORDER_STAT().hashCode(); + } + if (getBUKRS() != null) { + _hashCode += getBUKRS().hashCode(); + } + if (getKOSTV() != null) { + _hashCode += getKOSTV().hashCode(); + } + if (getAUFEX() != null) { + _hashCode += getAUFEX().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:nader:com/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("AUFNR"); + elemField.setXmlName(new javax.xml.namespace.QName("", "AUFNR")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("AUART"); + elemField.setXmlName(new javax.xml.namespace.QName("", "AUART")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("KTEXT"); + elemField.setXmlName(new javax.xml.namespace.QName("", "KTEXT")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("ZORDER_STAT"); + elemField.setXmlName(new javax.xml.namespace.QName("", "ZORDER_STAT")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("BUKRS"); + elemField.setXmlName(new javax.xml.namespace.QName("", "BUKRS")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("KOSTV"); + elemField.setXmlName(new javax.xml.namespace.QName("", "KOSTV")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("AUFEX"); + elemField.setXmlName(new javax.xml.namespace.QName("", "AUFEX")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_Out.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_Out.java new file mode 100644 index 0000000..b4c45a0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_Out.java @@ -0,0 +1,12 @@ +/** + * SI_OA_GET_INTERNAL_FI_ORDER_Out.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.sap.webservice; + +public interface SI_OA_GET_INTERNAL_FI_ORDER_Out extends java.rmi.Remote { + public com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[] SI_OA_GET_INTERNAL_FI_ORDER_Out(com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ MT_OA_GET_INTERNAL_FI_ORDER_REQ) throws java.rmi.RemoteException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java new file mode 100644 index 0000000..ea15089 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java @@ -0,0 +1,193 @@ +/** + * SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.sap.webservice; + +public class SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub extends org.apache.axis.client.Stub implements com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[1]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("SI_OA_GET_INTERNAL_FI_ORDER_Out"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("urn:nader:com/ECC", "MT_OA_GET_INTERNAL_FI_ORDER_REQ"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ"), com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_RESP")); + oper.setReturnClass(com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[].class); + oper.setReturnQName(new javax.xml.namespace.QName("urn:nader:com/ECC", "MT_OA_GET_INTERNAL_FI_ORDER_RESP")); + param = oper.getReturnParamDesc(); + param.setItemQName(new javax.xml.namespace.QName("", "ET_RETURN")); + oper.setStyle(org.apache.axis.constants.Style.DOCUMENT); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + } + + public SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("urn:nader:com/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_RESP"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[].class; + cachedSerClasses.add(cls); + qName = new javax.xml.namespace.QName("urn:nader:com/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN"); + qName2 = new javax.xml.namespace.QName("", "ET_RETURN"); + cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2)); + cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory()); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[] SI_OA_GET_INTERNAL_FI_ORDER_Out(com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ MT_OA_GET_INTERNAL_FI_ORDER_REQ) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("", "SI_OA_GET_INTERNAL_FI_ORDER_Out")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {MT_OA_GET_INTERNAL_FI_ORDER_REQ}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[]) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[]) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[].class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutService.java new file mode 100644 index 0000000..cd56f71 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutService.java @@ -0,0 +1,21 @@ +/** + * SI_OA_GET_INTERNAL_FI_ORDER_OutService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.sap.webservice; + +public interface SI_OA_GET_INTERNAL_FI_ORDER_OutService extends javax.xml.rpc.Service { + public java.lang.String getHTTPS_PortAddress(); + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTPS_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public java.lang.String getHTTP_PortAddress(); + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTP_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java new file mode 100644 index 0000000..e4b9a8b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java @@ -0,0 +1,202 @@ +/** + * SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.sap.webservice; + +public class SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutService { + + public SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator() { + } + + + public SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for HTTPS_Port + private java.lang.String HTTPS_Port_address = "https://poqas.sh-liangxin.com:50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_OA&receiverParty=&receiverService=&interface=SI_OA_GET_INTERNAL_FI_ORDER_Out&interfaceNamespace=urn%3Anader%3Acom%2FOA"; + + public java.lang.String getHTTPS_PortAddress() { + return HTTPS_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTPS_PortWSDDServiceName = "HTTPS_Port"; + + public java.lang.String getHTTPS_PortWSDDServiceName() { + return HTTPS_PortWSDDServiceName; + } + + public void setHTTPS_PortWSDDServiceName(java.lang.String name) { + HTTPS_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTPS_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTPS_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTPS_Port(endpoint); + } + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub _stub = new com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(portAddress, this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTPS_PortEndpointAddress(java.lang.String address) { + HTTPS_Port_address = address; + } + + + // Use to get a proxy class for HTTP_Port + private java.lang.String HTTP_Port_address = "http://poqas.sh-liangxin.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_OA&receiverParty=&receiverService=&interface=SI_OA_GET_INTERNAL_FI_ORDER_Out&interfaceNamespace=urn%3Anader%3Acom%2FOA"; + + public java.lang.String getHTTP_PortAddress() { + return HTTP_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTP_PortWSDDServiceName = "HTTP_Port"; + + public java.lang.String getHTTP_PortWSDDServiceName() { + return HTTP_PortWSDDServiceName; + } + + public void setHTTP_PortWSDDServiceName(java.lang.String name) { + HTTP_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTP_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTP_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTP_Port(endpoint); + } + + public com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub _stub = new com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(portAddress, this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTP_PortEndpointAddress(java.lang.String address) { + HTTP_Port_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + * This service has multiple ports for a given interface; + * the proxy implementation returned may be indeterminate. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub _stub = new com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(new java.net.URL(HTTPS_Port_address), this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + if (com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_Out.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub _stub = new com.api.taojw.liangxin.sap.webservice.SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub(new java.net.URL(HTTP_Port_address), this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("HTTPS_Port".equals(inputPortName)) { + return getHTTPS_Port(); + } + else if ("HTTP_Port".equals(inputPortName)) { + return getHTTP_Port(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("urn:nader:com/OA", "SI_OA_GET_INTERNAL_FI_ORDER_OutService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("urn:nader:com/OA", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:com/OA", "HTTP_Port")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("HTTPS_Port".equals(portName)) { + setHTTPS_PortEndpointAddress(address); + } + else +if ("HTTP_Port".equals(portName)) { + setHTTP_PortEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/SyncToDoInfo.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/SyncToDoInfo.java new file mode 100644 index 0000000..3a5215c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/SyncToDoInfo.java @@ -0,0 +1,219 @@ +package com.api.taojw.liangxin.todo; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.ofs.interfaces.SendRequestStatusDataInterfaces; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.request.todo.DataObj; +import weaver.workflow.request.todo.RequestStatusObj; + +import java.util.*; +import java.util.stream.Collectors; + +public class SyncToDoInfo implements SendRequestStatusDataInterfaces { + + Logger logger = MyLogger.getLogger(); + + //------------以下参数为发送请求时的相关参数 + private String wbUrl = ""; + private String appName = ""; + private String modelName = ""; + private String pcLink = ""; + private String mobileLink = ""; + + private String sendTodoUrl = ""; + private String updateTodoUrl = ""; + private String delTodoUrl = ""; + private String userName = ""; + private String password = ""; + + public String getMobileLink() { + return mobileLink; + } + + public void setMobileLink(String mobileLink) { + this.mobileLink = mobileLink; + } + + public String getWbUrl() { + return wbUrl; + } + + public void setWbUrl(String wbUrl) { + this.wbUrl = wbUrl; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getPcLink() { + return pcLink; + } + + public void setPcLink(String pcLink) { + this.pcLink = pcLink; + } + + public String getSendTodoUrl() { + return sendTodoUrl; + } + + public void setSendTodoUrl(String sendTodoUrl) { + this.sendTodoUrl = sendTodoUrl; + } + + public String getUpdateTodoUrl() { + return updateTodoUrl; + } + + public void setUpdateTodoUrl(String updateTodoUrl) { + this.updateTodoUrl = updateTodoUrl; + } + + public String getDelTodoUrl() { + return delTodoUrl; + } + + public void setDelTodoUrl(String delTodoUrl) { + this.delTodoUrl = delTodoUrl; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + /** + * 后台设置id + */ + public String id ; + /** + * 设置的系统编号 + */ + public String syscode ; + /** + * 服务器URL + */ + public String serverurl ; + /** + * 流程白名单 + */ + public ArrayList workflowwhitelist ; + /** + * 人员白名单 + */ + public ArrayList userwhitelist ; + + + public String getId() { + return id; + } + public String getSyscode() { + return syscode; + } + public String getServerurl() { + return serverurl; + } + public ArrayList getWorkflowwhitelist() { + return workflowwhitelist; + } + public ArrayList getUserwhitelist() { + return userwhitelist; + } + + @Override + public void SendRequestStatusData(ArrayList arrayList) { + logger.info("SyncToDoInfo.SendRequestStatusData begin"); + try { + RecordSet rs = new RecordSet(); + Map commonMap = new HashMap<>(); + commonMap.put("appName",appName); + commonMap.put("modelName",modelName); + commonMap.put("pcLink",pcLink); + commonMap.put("mobileLink",mobileLink); + commonMap.put("userName",userName); + commonMap.put("password",password); + Iterator arrayListIterator = arrayList.iterator(); + while(arrayListIterator.hasNext()) { + DataObj dataObj = (DataObj)arrayListIterator.next(); + ArrayList doneDataList = dataObj.getDonedatas(); + doneDataList = doneDataList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RequestStatusObj::getRequestid))), ArrayList::new)); + ArrayList todoDataList = dataObj.getTododatas(); + todoDataList = todoDataList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RequestStatusObj::getRequestid))), ArrayList::new)); + ArrayList delDataList = dataObj.getDeldatas(); + delDataList = delDataList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RequestStatusObj::getRequestid))), ArrayList::new)); + + logList("doneDataList",doneDataList); + logList("todoDataList",todoDataList); + logList("delDataList",delDataList); + + //真正要发送的已办 = 已办信息中剔除待办信息 + ArrayList realDoneDataList = new ArrayList(); + Iterator doneDataListIterator = doneDataList.iterator(); + RequestStatusObj requestStatusObj; + while(doneDataListIterator.hasNext()) { + requestStatusObj = (RequestStatusObj)doneDataListIterator.next(); + //已办信息是否在待办信息中 + boolean isDoneInTodo = false; + Iterator todoDataListIterator = todoDataList.iterator(); + while(todoDataListIterator.hasNext()) { + RequestStatusObj var13 = (RequestStatusObj)todoDataListIterator.next(); + if (requestStatusObj.getRequestid() == var13.getRequestid() && requestStatusObj.getUser().getUID() == var13.getUser().getUID()) { + isDoneInTodo = true; + break; + } + } + //如果已办不在待办中,则发送已办信息 + if (!isDoneInTodo) { + realDoneDataList.add(requestStatusObj); + } + } + logList("realDoneDataList",realDoneDataList); + SyncTodoUtil.deleteTodoInfo(rs,delTodoUrl,delDataList,commonMap); + SyncTodoUtil.updateTodoInfo(rs,updateTodoUrl,realDoneDataList,commonMap); + SyncTodoUtil.sendTodoInfo(rs,sendTodoUrl,todoDataList,commonMap); + } + } catch (Throwable e) { + logger.error("SyncToDoInfo.SendRequestStatusData throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + private void logList(String name,List list){ + logger.info("name:" + name + ";value:"); + for(RequestStatusObj o:list){ + logger.info("requestid:" + o.getRequestid()); + } + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/SyncTodoUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/SyncTodoUtil.java new file mode 100644 index 0000000..14fc3de --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/SyncTodoUtil.java @@ -0,0 +1,335 @@ +package com.api.taojw.liangxin.todo; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.liangxin.todo.podeltodowebservice.*; +import com.api.taojw.liangxin.todo.posendtodowebservice.*; +import com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub; +import com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator; +import com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDone; +import com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.request.todo.RequestStatusObj; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class SyncTodoUtil { + + static Logger logger = MyLogger.getLogger(); + + private static final String OA_URL = getOAAddress(); + + private static SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator sendTodoLocator = null; + private static SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator deleteLocator = null; + private static SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator uploadLocator = null; + + private static SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub sendTodoInfoStub = null; + private static SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub deleteTodoStub = null; + + private static SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub setTodoDoneStub = null; + public static void sendTodoInfo(RecordSet rs,String url, ArrayList todoDataList, Map param){ + try{ + logger.info("sendTodoInfo begin;"); + URL wbUrl = new URL(url); + if(sendTodoLocator == null){ + logger.error("static sendTodoLocator is null;begin init"); + try{ + sendTodoLocator = new SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator(); + }catch(Throwable e){ + logger.error("sendTodoLocator new throwable;message:" + e.getMessage() + ";e:" + e); + } + } + if(sendTodoInfoStub == null){ + logger.error("static sendTodoInfoStub is null;begin init"); + try{ + sendTodoInfoStub = new SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(wbUrl,sendTodoLocator); + }catch(Throwable e){ + logger.error("sendTodoInfoStub new throwable;message:" + e.getMessage() + ";e:" + e); + } + } + logger.info("get sendTodoInfoStub done;sendTodoInfoStub:" + sendTodoInfoStub); + sendTodoInfoStub.setUsername(param.get("userName")); + sendTodoInfoStub.setPassword(param.get("password")); + for(RequestStatusObj requestStatusObj : todoDataList){ + logger.info("sendTodoInfo begin;requestid:" + requestStatusObj.getRequestid()); + SendTodo todoParam = new SendTodo(); + NotifyTodoSendContext todo = new NotifyTodoSendContext(); + int uid = requestStatusObj.getUser().getUID(); + String getWorkCodeSql = "select workcode from hrmresource where id = ?"; + String workCode = DaoUtil.getFirstData(rs,getWorkCodeSql,uid).get("workcode"); + todo.setAppName(param.get("appName")); + todo.setModelName(param.get("modelName")); + todo.setModelId(String.valueOf(requestStatusObj.getRequestid())); + todo.setSubject(requestStatusObj.getRequstname()); + if(!"".equals(param.get("pcLink")) && param.get("pcLink") != null){ + todo.setLink(param.get("pcLink")+requestStatusObj.getRequestid()); + }else{ + todo.setLink(OA_URL + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestStatusObj.getRequestid()); + } + if(!"".equals(param.get("mobileLink")) && param.get("mobileLink") != null){ + todo.setMobileLink(param.get("mobileLink")+requestStatusObj.getRequestid()); + }else{ + todo.setMobileLink(OA_URL + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestStatusObj.getRequestid()); + } + //待办类型 1-审批类 2-通知类 + todo.setType(1); + todo.setTargets("{\"PersonNo\":\""+workCode+"\"}"); + // HH:mm:ss + String createtime = requestStatusObj.getCreatetime(); + if(StringUtils.isNotBlank(createtime)){ + if(createtime.length() < 6){ + createtime += ":00"; + } + }else { + createtime="00:00:00"; + } + todo.setCreateTime(requestStatusObj.getReceivedate() + " " + createtime); + String creatorWorkCode = DaoUtil.getFirstData(rs,getWorkCodeSql,requestStatusObj.getCreator().getUID()).get("workcode"); + todo.setDocCreator("{\"PersonNo\":\""+creatorWorkCode+"\"}"); + logger.info("todo:link:" + todo.getLink() + ";mobileLink:" + todo.getMobileLink() + ";workCode:" + workCode + ";creatorWorkCode:" + creatorWorkCode); + todoParam.setArg0(todo); + SendTodoResponse sendTodoResponse = sendTodoInfoStub.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT(todoParam); + logger.info("requestid:" + requestStatusObj.getRequestid() + ";result:" + sendTodoResponse.get_return().getMessage() + ";code:" + sendTodoResponse.get_return().getReturnState()); + } + }catch(Throwable e){ + logger.error("SyncTodoUtil.sendTodoInfo Throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + public static void deleteTodoInfo(RecordSet rs,String url, ArrayList todoDataList, Map param){ + try{ + logger.info("deleteTodoInfo begin;"); + URL wbUrl = new URL(url); + if(deleteLocator == null){ + logger.error("static deleteLocator is null;begin init"); + try{ + deleteLocator = new SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator(); + }catch(Throwable e){ + logger.error("deleteLocator new throwable;message:" + e.getMessage() + ";e:" + e); + } + } + if(deleteTodoStub == null){ + logger.error("static deleteTodoStub is null;begin init"); + try{ + deleteTodoStub = new SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(wbUrl,deleteLocator); + }catch(Throwable e){ + logger.error("sendTodoInfoStub new throwable;message:" + e.getMessage() + ";e:" + e); + } + } + logger.info("get deleteTodoStub done;deleteTodoStub:" + deleteTodoStub); + //SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub stub = new SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(wbUrl,deleteLocator); + deleteTodoStub.setUsername(param.get("userName")); + deleteTodoStub.setPassword(param.get("password")); + for(RequestStatusObj requestStatusObj : todoDataList){ + logger.info("deleteTodoInfo begin;requestId:" + requestStatusObj.getRequestid()); + DeleteTodo delTodo = new DeleteTodo(); + NotifyTodoRemoveContext todo = new NotifyTodoRemoveContext(); + todo.setAppName(param.get("appName")); + todo.setModelName(param.get("modelName")); + todo.setModelId(String.valueOf(requestStatusObj.getRequestid())); + todo.setOptType(1); + String getWorkCodeSql = "select workcode from hrmresource where id = ?"; + int uid = requestStatusObj.getUser().getUID(); + String workCode = DaoUtil.getFirstData(rs,getWorkCodeSql,uid).get("workcode"); + todo.setTargets("{\"PersonNo\":\""+workCode+"\"}"); + delTodo.setArg0(todo); + logger.info("deleteTodoInfo begin;requestid:" + requestStatusObj.getRequestid() + ";workcode:" + workCode); + DeleteTodoResponse deleteTodoResponse = deleteTodoStub.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT(delTodo); + logger.info("requestid:" + requestStatusObj.getRequestid() + ";result:" + deleteTodoResponse.get_return().getMessage() + ";code:" + deleteTodoResponse.get_return().getReturnState()); + } + }catch(Throwable e){ + logger.error("SyncTodoUtil.deleteTodoInfo Throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + public static void updateTodoInfo(RecordSet rs,String url, ArrayList todoDataList, Map param){ + try{ + logger.info("updateTodoInfo begin;"); + URL wbUrl = new URL(url); + if(uploadLocator == null){ + logger.error("static uploadLocator is null;begin init"); + try{ + uploadLocator = new SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator(); + }catch(Throwable e){ + logger.error("uploadLocator new throwable;message:" + e.getMessage() + ";e:" + e); + } + } + if(setTodoDoneStub == null){ + logger.error("static setTodoDoneStub is null;begin init"); + try{ + setTodoDoneStub = new SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(wbUrl,uploadLocator); + }catch(Throwable e){ + logger.error("setTodoDoneStub new throwable;message:" + e.getMessage() + ";e:" + e); + } + } + logger.info("get setTodoDoneStub done;setTodoDoneStub:" + setTodoDoneStub); + //SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub stub = new SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(wbUrl,uploadLocator); + setTodoDoneStub.setUsername(param.get("userName")); + setTodoDoneStub.setPassword(param.get("password")); + for(RequestStatusObj requestStatusObj : todoDataList){ + logger.info("updateTodoInfo begin;requestid:" + requestStatusObj.getRequestid()); + SetTodoDone todoParam = new SetTodoDone(); + com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext todo = new com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext(); + todo.setAppName(param.get("appName")); + todo.setModelName(param.get("modelName")); + todo.setModelId(String.valueOf(requestStatusObj.getRequestid())); + todo.setType(1); + todo.setOptType(2); + String getWorkCodeSql = "select workcode from hrmresource where id = ?"; + int uid = requestStatusObj.getUser().getUID(); + String workCode = DaoUtil.getFirstData(rs,getWorkCodeSql,uid).get("workcode"); + todo.setTargets("{\"PersonNo\":\""+workCode+"\"}"); + todoParam.setArg0(todo); + logger.info("updateTodoInfo begin;requestid:" + requestStatusObj.getRequestid() + ";workCode:" + workCode); + SetTodoDoneResponse setTodoDoneResponse = setTodoDoneStub.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT(todoParam); + logger.info("requestid:" + requestStatusObj.getRequestid() + ";result:" + setTodoDoneResponse.get_return().getMessage() + ";code:" + setTodoDoneResponse.get_return().getReturnState()); + } + }catch(Throwable e){ + logger.error("SyncTodoUtil.updateTodoInfo Throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + /** + *

获取oa地址

+ * @author xuanran.wang + * @dateTime 2022/12/22 13:51 + * @return OA地址 + **/ + private static String getOAAddress(){ + String sql = "select oaaddress from systemset"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + String url = Util.null2String(recordSet.getString(1)); + if(StringUtils.isBlank(url)){ + url = "https://weaver-pc-dev.sh-liangxin.com"; + }else if(url.endsWith("/")){ + url = url.substring(0, url.length() - 1); + } + logger.info("OA地址: [ " + url + " ]"); + return url; + } + + public static void sendTodoInfobak(RecordSet rs,String url, ArrayList todoDataList, Map param){ + /*try{ + URL wbUrl = new URL(url); + ISysNotifyTodoWebServiceServiceLocator locator = new ISysNotifyTodoWebServiceServiceLocator(); + ISysNotifyTodoWebServiceServiceSoapBindingStub stub = new ISysNotifyTodoWebServiceServiceSoapBindingStub(wbUrl,locator); + for(RequestStatusObj requestStatusObj : todoDataList){ + logger.info("sendTodoInfo begin;requestid:" + requestStatusObj.getRequestid()); + NotifyTodoSendContext todo = new NotifyTodoSendContext(); + int uid = requestStatusObj.getUser().getUID(); + String getWorkCodeSql = "select workcode from hrmresource where id = ?"; + String workCode = DaoUtil.getFirstData(rs,getWorkCodeSql,uid).get("workcode"); + todo.setAppName(param.get("appName")); + todo.setModelName(param.get("modelName")); + todo.setModelId(String.valueOf(requestStatusObj.getRequestid())); + todo.setSubject(requestStatusObj.getRequstname()); + if(!"".equals(param.get("pcLink")) && param.get("pcLink") != null){ + todo.setLink(param.get("pcLink")+requestStatusObj.getRequestid()); + }else{ + todo.setLink(OA_URL + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestStatusObj.getRequestid()); + } + if(!"".equals(param.get("mobileLink")) && param.get("mobileLink") != null){ + todo.setMobileLink(param.get("mobileLink")+requestStatusObj.getRequestid()); + }else{ + todo.setMobileLink(OA_URL + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestStatusObj.getRequestid()); + } + //待办类型 1-审批类 2-通知类 + todo.setType(1); + todo.setTargets("{\"PersonNo\":\""+workCode+"\"}"); + // HH:mm:ss + String createtime = requestStatusObj.getCreatetime(); + if(StringUtils.isNotBlank(createtime)){ + if(createtime.length() < 6){ + createtime += ":00"; + } + }else { + createtime="00:00:00"; + } + todo.setCreateTime(requestStatusObj.getReceivedate() + " " + createtime); + String creatorWorkCode = DaoUtil.getFirstData(rs,getWorkCodeSql,requestStatusObj.getCreator().getUID()).get("workcode"); + todo.setDocCreator("{\"PersonNo\":\""+creatorWorkCode+"\"}"); + //logObj(todo); + logger.info("todo:link:" + todo.getLink() + ";mobileLink:" + todo.getMobileLink() + ";workCode:" + workCode + ";creatorWorkCode:" + creatorWorkCode); + NotifyTodoAppResult notifyTodoAppResult = stub.sendTodo(todo); + logger.info("requestid:" + requestStatusObj.getRequestid() + ";result:" + notifyTodoAppResult.getMessage() + ";code:" + notifyTodoAppResult.getReturnState()); + } + }catch(Exception e){ + logger.error("SyncTodoUtil.sendTodoInfo exception;message:" + e.getMessage() + ";e:" + e); + }*/ + } + + /*public static void updateTodoInfobak(RecordSet rs,String url, ArrayList todoDataList, Map param){ + try{ + URL wbUrl = new URL(url); + ISysNotifyTodoWebServiceServiceLocator locator = new ISysNotifyTodoWebServiceServiceLocator(); + ISysNotifyTodoWebServiceServiceSoapBindingStub stub = new ISysNotifyTodoWebServiceServiceSoapBindingStub(wbUrl,locator); + for(RequestStatusObj requestStatusObj : todoDataList){ + logger.info("updateTodoInfo begin;requestid:" + requestStatusObj.getRequestid()); + NotifyTodoRemoveContext todo = new NotifyTodoRemoveContext(); + todo.setAppName(param.get("appName")); + todo.setModelName(param.get("modelName")); + todo.setModelId(String.valueOf(requestStatusObj.getRequestid())); + todo.setOptType(1); + //logObj(todo); + NotifyTodoAppResult notifyTodoAppResult = stub.setTodoDone(todo); + logger.info("requestid:" + requestStatusObj.getRequestid() + ";result:" + notifyTodoAppResult.getMessage() + ";code:" + notifyTodoAppResult.getReturnState()); + } + }catch(Exception e){ + logger.error("SyncTodoUtil.updateTodoInfo exception;message:" + e.getMessage() + ";e:" + e); + } + }*/ + + public static void deleteTodoInfobak(RecordSet rs,String url, ArrayList todoDataList, Map param){ + /*try{ + URL wbUrl = new URL(url); + ISysNotifyTodoWebServiceServiceLocator locator = new ISysNotifyTodoWebServiceServiceLocator(); + ISysNotifyTodoWebServiceServiceSoapBindingStub stub = new ISysNotifyTodoWebServiceServiceSoapBindingStub(wbUrl,locator); + for(RequestStatusObj requestStatusObj : todoDataList){ + logger.info("deleteTodoInfo begin;requestid:" + requestStatusObj.getRequestid()); + NotifyTodoRemoveContext todo = new NotifyTodoRemoveContext(); + todo.setAppName(param.get("appName")); + todo.setModelName(param.get("modelName")); + todo.setModelId(String.valueOf(requestStatusObj.getRequestid())); + todo.setOptType(1); + //logObj(todo); + NotifyTodoAppResult notifyTodoAppResult = stub.deleteTodo(todo); + logger.info("requestid:" + requestStatusObj.getRequestid() + ";result:" + notifyTodoAppResult.getMessage() + ";code:" + notifyTodoAppResult.getReturnState()); + } + }catch(Exception e){ + logger.error("SyncTodoUtil.deleteTodoInfo exception;message:" + e.getMessage() + ";e:" + e); + }*/ + } + + /** + *

反射打印对象

+ * @author xuanran.wang + * @dateTime 2022/12/22 13:50 + * @param t 输出对象 + **/ + private static void logObj(T t){ + try { + HashMap info = new HashMap<>(); + Class clazz = t.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + String fieldName = field.getName(); + field.setAccessible(true); + Object value = Util.null2String(field.get(clazz)); + info.put(fieldName, value); + } + logger.info("推送对象json : " + JSONObject.toJSONString(info)); + }catch (IllegalAccessException e){ + logger.error("反射输出对象信息失败! 异常信息: " + e.getMessage()); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/TodoAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/TodoAction.java new file mode 100644 index 0000000..e28a65c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/TodoAction.java @@ -0,0 +1,63 @@ +package com.api.taojw.liangxin.todo; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.ToolUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.request.todo.RequestStatusObj; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class TodoAction extends ToolUtil implements Action { + + private String sendTodoUrl = ""; + private String updateTodoUrl = ""; + private String appName = ""; + private String modelName = ""; + private String pcLink = ""; + private String mobileLink = ""; + private String userName = ""; + private String password = ""; + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try { + logger.info("TodoAction begin;requestId:" + requestId); + Map commonMap = new HashMap<>(); + commonMap.put("appName",appName); + commonMap.put("modelName",modelName); + commonMap.put("pcLink",pcLink); + commonMap.put("mobileLink",mobileLink); + commonMap.put("userName",userName); + commonMap.put("password",password); + RecordSet rs = new RecordSet(); + ArrayList todoDataList = new ArrayList<>(); + RequestStatusObj todo = new RequestStatusObj(); + todo.setRequestid(Integer.parseInt(requestInfo.getRequestid())); + User user = new User(Integer.parseInt(requestInfo.getCreatorid())); + todo.setUser(user); + todo.setRequstname(requestInfo.getRequestManager().getRequestname()); + todo.setReceivedate(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); + todo.setCreatetime(new SimpleDateFormat("HH:mm:ss").format(new Date())); + todo.setCreator(user); + SyncTodoUtil.sendTodoInfo(rs,sendTodoUrl,todoDataList,commonMap); + SyncTodoUtil.updateTodoInfo(rs,updateTodoUrl,todoDataList,commonMap); + return Action.SUCCESS; + }catch (Exception e) { + logger.error("TodoAction exception;requestId:" + requestId + ";message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(requestId+new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); + requestInfo.getRequestManager().setMessagecontent("OA add done data error,please contact manager!"); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/DeleteTodo.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/DeleteTodo.java new file mode 100644 index 0000000..2fae9ab --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/DeleteTodo.java @@ -0,0 +1,120 @@ +/** + * DeleteTodo.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public class DeleteTodo implements java.io.Serializable { + private com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoRemoveContext arg0; + + public DeleteTodo() { + } + + public DeleteTodo( + com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoRemoveContext arg0) { + this.arg0 = arg0; + } + + + /** + * Gets the arg0 value for this DeleteTodo. + * + * @return arg0 + */ + public com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoRemoveContext getArg0() { + return arg0; + } + + + /** + * Sets the arg0 value for this DeleteTodo. + * + * @param arg0 + */ + public void setArg0(com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoRemoveContext arg0) { + this.arg0 = arg0; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof DeleteTodo)) return false; + DeleteTodo other = (DeleteTodo) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.arg0==null && other.getArg0()==null) || + (this.arg0!=null && + this.arg0.equals(other.getArg0()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getArg0() != null) { + _hashCode += getArg0().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(DeleteTodo.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodo")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("arg0"); + elemField.setXmlName(new javax.xml.namespace.QName("", "arg0")); + elemField.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/DeleteTodoResponse.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/DeleteTodoResponse.java new file mode 100644 index 0000000..362a52d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/DeleteTodoResponse.java @@ -0,0 +1,120 @@ +/** + * DeleteTodoResponse.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public class DeleteTodoResponse implements java.io.Serializable { + private com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoAppResult _return; + + public DeleteTodoResponse() { + } + + public DeleteTodoResponse( + com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoAppResult _return) { + this._return = _return; + } + + + /** + * Gets the _return value for this DeleteTodoResponse. + * + * @return _return + */ + public com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoAppResult get_return() { + return _return; + } + + + /** + * Sets the _return value for this DeleteTodoResponse. + * + * @param _return + */ + public void set_return(com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoAppResult _return) { + this._return = _return; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof DeleteTodoResponse)) return false; + DeleteTodoResponse other = (DeleteTodoResponse) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this._return==null && other.get_return()==null) || + (this._return!=null && + this._return.equals(other.get_return()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (get_return() != null) { + _hashCode += get_return().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(DeleteTodoResponse.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodoResponse")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("_return"); + elemField.setXmlName(new javax.xml.namespace.QName("", "return")); + elemField.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/NotifyTodoAppResult.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/NotifyTodoAppResult.java new file mode 100644 index 0000000..c47ce45 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/NotifyTodoAppResult.java @@ -0,0 +1,152 @@ +/** + * NotifyTodoAppResult.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public class NotifyTodoAppResult implements java.io.Serializable { + private java.lang.String message; + + private int returnState; + + public NotifyTodoAppResult() { + } + + public NotifyTodoAppResult( + java.lang.String message, + int returnState) { + this.message = message; + this.returnState = returnState; + } + + + /** + * Gets the message value for this NotifyTodoAppResult. + * + * @return message + */ + public java.lang.String getMessage() { + return message; + } + + + /** + * Sets the message value for this NotifyTodoAppResult. + * + * @param message + */ + public void setMessage(java.lang.String message) { + this.message = message; + } + + + /** + * Gets the returnState value for this NotifyTodoAppResult. + * + * @return returnState + */ + public int getReturnState() { + return returnState; + } + + + /** + * Sets the returnState value for this NotifyTodoAppResult. + * + * @param returnState + */ + public void setReturnState(int returnState) { + this.returnState = returnState; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoAppResult)) return false; + NotifyTodoAppResult other = (NotifyTodoAppResult) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.message==null && other.getMessage()==null) || + (this.message!=null && + this.message.equals(other.getMessage()))) && + this.returnState == other.getReturnState(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getMessage() != null) { + _hashCode += getMessage().hashCode(); + } + _hashCode += getReturnState(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoAppResult.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnState"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnState")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/NotifyTodoRemoveContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/NotifyTodoRemoveContext.java new file mode 100644 index 0000000..c3b3d6f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/NotifyTodoRemoveContext.java @@ -0,0 +1,448 @@ +/** + * NotifyTodoRemoveContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public class NotifyTodoRemoveContext implements java.io.Serializable { + private java.lang.String appName; + + private java.lang.String key; + + private java.lang.String modelId; + + private java.lang.String modelName; + + private java.lang.Integer optType; + + private java.lang.String others; + + private java.lang.String param1; + + private java.lang.String param2; + + private java.lang.String targets; + + private int type; + + public NotifyTodoRemoveContext() { + } + + public NotifyTodoRemoveContext( + java.lang.String appName, + java.lang.String key, + java.lang.String modelId, + java.lang.String modelName, + java.lang.Integer optType, + java.lang.String others, + java.lang.String param1, + java.lang.String param2, + java.lang.String targets, + int type) { + this.appName = appName; + this.key = key; + this.modelId = modelId; + this.modelName = modelName; + this.optType = optType; + this.others = others; + this.param1 = param1; + this.param2 = param2; + this.targets = targets; + this.type = type; + } + + + /** + * Gets the appName value for this NotifyTodoRemoveContext. + * + * @return appName + */ + public java.lang.String getAppName() { + return appName; + } + + + /** + * Sets the appName value for this NotifyTodoRemoveContext. + * + * @param appName + */ + public void setAppName(java.lang.String appName) { + this.appName = appName; + } + + + /** + * Gets the key value for this NotifyTodoRemoveContext. + * + * @return key + */ + public java.lang.String getKey() { + return key; + } + + + /** + * Sets the key value for this NotifyTodoRemoveContext. + * + * @param key + */ + public void setKey(java.lang.String key) { + this.key = key; + } + + + /** + * Gets the modelId value for this NotifyTodoRemoveContext. + * + * @return modelId + */ + public java.lang.String getModelId() { + return modelId; + } + + + /** + * Sets the modelId value for this NotifyTodoRemoveContext. + * + * @param modelId + */ + public void setModelId(java.lang.String modelId) { + this.modelId = modelId; + } + + + /** + * Gets the modelName value for this NotifyTodoRemoveContext. + * + * @return modelName + */ + public java.lang.String getModelName() { + return modelName; + } + + + /** + * Sets the modelName value for this NotifyTodoRemoveContext. + * + * @param modelName + */ + public void setModelName(java.lang.String modelName) { + this.modelName = modelName; + } + + + /** + * Gets the optType value for this NotifyTodoRemoveContext. + * + * @return optType + */ + public java.lang.Integer getOptType() { + return optType; + } + + + /** + * Sets the optType value for this NotifyTodoRemoveContext. + * + * @param optType + */ + public void setOptType(java.lang.Integer optType) { + this.optType = optType; + } + + + /** + * Gets the others value for this NotifyTodoRemoveContext. + * + * @return others + */ + public java.lang.String getOthers() { + return others; + } + + + /** + * Sets the others value for this NotifyTodoRemoveContext. + * + * @param others + */ + public void setOthers(java.lang.String others) { + this.others = others; + } + + + /** + * Gets the param1 value for this NotifyTodoRemoveContext. + * + * @return param1 + */ + public java.lang.String getParam1() { + return param1; + } + + + /** + * Sets the param1 value for this NotifyTodoRemoveContext. + * + * @param param1 + */ + public void setParam1(java.lang.String param1) { + this.param1 = param1; + } + + + /** + * Gets the param2 value for this NotifyTodoRemoveContext. + * + * @return param2 + */ + public java.lang.String getParam2() { + return param2; + } + + + /** + * Sets the param2 value for this NotifyTodoRemoveContext. + * + * @param param2 + */ + public void setParam2(java.lang.String param2) { + this.param2 = param2; + } + + + /** + * Gets the targets value for this NotifyTodoRemoveContext. + * + * @return targets + */ + public java.lang.String getTargets() { + return targets; + } + + + /** + * Sets the targets value for this NotifyTodoRemoveContext. + * + * @param targets + */ + public void setTargets(java.lang.String targets) { + this.targets = targets; + } + + + /** + * Gets the type value for this NotifyTodoRemoveContext. + * + * @return type + */ + public int getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoRemoveContext. + * + * @param type + */ + public void setType(int type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoRemoveContext)) return false; + NotifyTodoRemoveContext other = (NotifyTodoRemoveContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.appName==null && other.getAppName()==null) || + (this.appName!=null && + this.appName.equals(other.getAppName()))) && + ((this.key==null && other.getKey()==null) || + (this.key!=null && + this.key.equals(other.getKey()))) && + ((this.modelId==null && other.getModelId()==null) || + (this.modelId!=null && + this.modelId.equals(other.getModelId()))) && + ((this.modelName==null && other.getModelName()==null) || + (this.modelName!=null && + this.modelName.equals(other.getModelName()))) && + ((this.optType==null && other.getOptType()==null) || + (this.optType!=null && + this.optType.equals(other.getOptType()))) && + ((this.others==null && other.getOthers()==null) || + (this.others!=null && + this.others.equals(other.getOthers()))) && + ((this.param1==null && other.getParam1()==null) || + (this.param1!=null && + this.param1.equals(other.getParam1()))) && + ((this.param2==null && other.getParam2()==null) || + (this.param2!=null && + this.param2.equals(other.getParam2()))) && + ((this.targets==null && other.getTargets()==null) || + (this.targets!=null && + this.targets.equals(other.getTargets()))) && + this.type == other.getType(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAppName() != null) { + _hashCode += getAppName().hashCode(); + } + if (getKey() != null) { + _hashCode += getKey().hashCode(); + } + if (getModelId() != null) { + _hashCode += getModelId().hashCode(); + } + if (getModelName() != null) { + _hashCode += getModelName().hashCode(); + } + if (getOptType() != null) { + _hashCode += getOptType().hashCode(); + } + if (getOthers() != null) { + _hashCode += getOthers().hashCode(); + } + if (getParam1() != null) { + _hashCode += getParam1().hashCode(); + } + if (getParam2() != null) { + _hashCode += getParam2().hashCode(); + } + if (getTargets() != null) { + _hashCode += getTargets().hashCode(); + } + _hashCode += getType(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoRemoveContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("appName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "appName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("key"); + elemField.setXmlName(new javax.xml.namespace.QName("", "key")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("optType"); + elemField.setXmlName(new javax.xml.namespace.QName("", "optType")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("others"); + elemField.setXmlName(new javax.xml.namespace.QName("", "others")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param1")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param2"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param2")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("targets"); + elemField.setXmlName(new javax.xml.namespace.QName("", "targets")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT.java new file mode 100644 index 0000000..5726f19 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT.java @@ -0,0 +1,12 @@ +/** + * SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public interface SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT extends java.rmi.Remote { + public com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT(com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodo parameters) throws java.rmi.RemoteException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub.java new file mode 100644 index 0000000..7eea8a2 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub.java @@ -0,0 +1,196 @@ +/** + * SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public class SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub extends org.apache.axis.client.Stub implements com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[1]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodo"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodo"), com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodo.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodoResponse")); + oper.setReturnClass(com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodoResponse")); + oper.setStyle(org.apache.axis.constants.Style.DOCUMENT); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + } + + public SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodo"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodo.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodoResponse"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoAppResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.podeltodowebservice.NotifyTodoRemoveContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT(com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodo parameters) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("", "SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {parameters}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.podeltodowebservice.DeleteTodoResponse.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService.java new file mode 100644 index 0000000..91c0439 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService.java @@ -0,0 +1,21 @@ +/** + * SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public interface SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService extends javax.xml.rpc.Service { + public java.lang.String getHTTPS_PortAddress(); + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTPS_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public java.lang.String getHTTP_PortAddress(); + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTP_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java new file mode 100644 index 0000000..62dfd4f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java @@ -0,0 +1,202 @@ +/** + * SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.podeltodowebservice; + +public class SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService { + + public SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator() { + } + + + public SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for HTTPS_Port + private java.lang.String HTTPS_Port_address = "https://poqas.sh-liangxin.com:50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SHIMS&receiverParty=&receiverService=&interface=SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT&interfaceNamespace=urn%3Anader%3Acom%2FSHIMS"; + + public java.lang.String getHTTPS_PortAddress() { + return HTTPS_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTPS_PortWSDDServiceName = "HTTPS_Port"; + + public java.lang.String getHTTPS_PortWSDDServiceName() { + return HTTPS_PortWSDDServiceName; + } + + public void setHTTPS_PortWSDDServiceName(java.lang.String name) { + HTTPS_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTPS_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTPS_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTPS_Port(endpoint); + } + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(portAddress, this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTPS_PortEndpointAddress(java.lang.String address) { + HTTPS_Port_address = address; + } + + + // Use to get a proxy class for HTTP_Port + private java.lang.String HTTP_Port_address = "http://poqas.sh-liangxin.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SHIMS&receiverParty=&receiverService=&interface=SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT&interfaceNamespace=urn%3Anader%3Acom%2FSHIMS"; + + public java.lang.String getHTTP_PortAddress() { + return HTTP_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTP_PortWSDDServiceName = "HTTP_Port"; + + public java.lang.String getHTTP_PortWSDDServiceName() { + return HTTP_PortWSDDServiceName; + } + + public void setHTTP_PortWSDDServiceName(java.lang.String name) { + HTTP_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTP_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTP_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTP_Port(endpoint); + } + + public com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(portAddress, this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTP_PortEndpointAddress(java.lang.String address) { + HTTP_Port_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + * This service has multiple ports for a given interface; + * the proxy implementation returned may be indeterminate. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(new java.net.URL(HTTPS_Port_address), this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + if (com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUT.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.podeltodowebservice.SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTBindingStub(new java.net.URL(HTTP_Port_address), this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("HTTPS_Port".equals(inputPortName)) { + return getHTTPS_Port(); + } + else if ("HTTP_Port".equals(inputPortName)) { + return getHTTP_Port(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("urn:nader:com/SHIMS", "SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTP_Port")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("HTTPS_Port".equals(portName)) { + setHTTPS_PortEndpointAddress(address); + } + else +if ("HTTP_Port".equals(portName)) { + setHTTP_PortEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/NotifyTodoAppResult.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/NotifyTodoAppResult.java new file mode 100644 index 0000000..b3e425d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/NotifyTodoAppResult.java @@ -0,0 +1,152 @@ +/** + * NotifyTodoAppResult.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public class NotifyTodoAppResult implements java.io.Serializable { + private java.lang.String message; + + private int returnState; + + public NotifyTodoAppResult() { + } + + public NotifyTodoAppResult( + java.lang.String message, + int returnState) { + this.message = message; + this.returnState = returnState; + } + + + /** + * Gets the message value for this NotifyTodoAppResult. + * + * @return message + */ + public java.lang.String getMessage() { + return message; + } + + + /** + * Sets the message value for this NotifyTodoAppResult. + * + * @param message + */ + public void setMessage(java.lang.String message) { + this.message = message; + } + + + /** + * Gets the returnState value for this NotifyTodoAppResult. + * + * @return returnState + */ + public int getReturnState() { + return returnState; + } + + + /** + * Sets the returnState value for this NotifyTodoAppResult. + * + * @param returnState + */ + public void setReturnState(int returnState) { + this.returnState = returnState; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoAppResult)) return false; + NotifyTodoAppResult other = (NotifyTodoAppResult) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.message==null && other.getMessage()==null) || + (this.message!=null && + this.message.equals(other.getMessage()))) && + this.returnState == other.getReturnState(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getMessage() != null) { + _hashCode += getMessage().hashCode(); + } + _hashCode += getReturnState(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoAppResult.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnState"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnState")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/NotifyTodoSendContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/NotifyTodoSendContext.java new file mode 100644 index 0000000..faa5c26 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/NotifyTodoSendContext.java @@ -0,0 +1,749 @@ +/** + * NotifyTodoSendContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public class NotifyTodoSendContext implements java.io.Serializable { + private java.lang.String appName; + + private java.lang.String createTime; + + private java.lang.String docCreator; + + private java.lang.String extendContent; + + private java.lang.String key; + + private java.lang.String language; + + private java.lang.Integer level; + + private java.lang.String link; + + private java.lang.String mobileLink; + + private java.lang.String modelId; + + private java.lang.String modelName; + + private java.lang.String others; + + private java.lang.String padLink; + + private java.lang.String param1; + + private java.lang.String param2; + + private java.lang.String subject; + + private java.lang.String targets; + + private java.lang.Integer type; + + public NotifyTodoSendContext() { + } + + public NotifyTodoSendContext( + java.lang.String appName, + java.lang.String createTime, + java.lang.String docCreator, + java.lang.String extendContent, + java.lang.String key, + java.lang.String language, + java.lang.Integer level, + java.lang.String link, + java.lang.String mobileLink, + java.lang.String modelId, + java.lang.String modelName, + java.lang.String others, + java.lang.String padLink, + java.lang.String param1, + java.lang.String param2, + java.lang.String subject, + java.lang.String targets, + java.lang.Integer type) { + this.appName = appName; + this.createTime = createTime; + this.docCreator = docCreator; + this.extendContent = extendContent; + this.key = key; + this.language = language; + this.level = level; + this.link = link; + this.mobileLink = mobileLink; + this.modelId = modelId; + this.modelName = modelName; + this.others = others; + this.padLink = padLink; + this.param1 = param1; + this.param2 = param2; + this.subject = subject; + this.targets = targets; + this.type = type; + } + + + /** + * Gets the appName value for this NotifyTodoSendContext. + * + * @return appName + */ + public java.lang.String getAppName() { + return appName; + } + + + /** + * Sets the appName value for this NotifyTodoSendContext. + * + * @param appName + */ + public void setAppName(java.lang.String appName) { + this.appName = appName; + } + + + /** + * Gets the createTime value for this NotifyTodoSendContext. + * + * @return createTime + */ + public java.lang.String getCreateTime() { + return createTime; + } + + + /** + * Sets the createTime value for this NotifyTodoSendContext. + * + * @param createTime + */ + public void setCreateTime(java.lang.String createTime) { + this.createTime = createTime; + } + + + /** + * Gets the docCreator value for this NotifyTodoSendContext. + * + * @return docCreator + */ + public java.lang.String getDocCreator() { + return docCreator; + } + + + /** + * Sets the docCreator value for this NotifyTodoSendContext. + * + * @param docCreator + */ + public void setDocCreator(java.lang.String docCreator) { + this.docCreator = docCreator; + } + + + /** + * Gets the extendContent value for this NotifyTodoSendContext. + * + * @return extendContent + */ + public java.lang.String getExtendContent() { + return extendContent; + } + + + /** + * Sets the extendContent value for this NotifyTodoSendContext. + * + * @param extendContent + */ + public void setExtendContent(java.lang.String extendContent) { + this.extendContent = extendContent; + } + + + /** + * Gets the key value for this NotifyTodoSendContext. + * + * @return key + */ + public java.lang.String getKey() { + return key; + } + + + /** + * Sets the key value for this NotifyTodoSendContext. + * + * @param key + */ + public void setKey(java.lang.String key) { + this.key = key; + } + + + /** + * Gets the language value for this NotifyTodoSendContext. + * + * @return language + */ + public java.lang.String getLanguage() { + return language; + } + + + /** + * Sets the language value for this NotifyTodoSendContext. + * + * @param language + */ + public void setLanguage(java.lang.String language) { + this.language = language; + } + + + /** + * Gets the level value for this NotifyTodoSendContext. + * + * @return level + */ + public java.lang.Integer getLevel() { + return level; + } + + + /** + * Sets the level value for this NotifyTodoSendContext. + * + * @param level + */ + public void setLevel(java.lang.Integer level) { + this.level = level; + } + + + /** + * Gets the link value for this NotifyTodoSendContext. + * + * @return link + */ + public java.lang.String getLink() { + return link; + } + + + /** + * Sets the link value for this NotifyTodoSendContext. + * + * @param link + */ + public void setLink(java.lang.String link) { + this.link = link; + } + + + /** + * Gets the mobileLink value for this NotifyTodoSendContext. + * + * @return mobileLink + */ + public java.lang.String getMobileLink() { + return mobileLink; + } + + + /** + * Sets the mobileLink value for this NotifyTodoSendContext. + * + * @param mobileLink + */ + public void setMobileLink(java.lang.String mobileLink) { + this.mobileLink = mobileLink; + } + + + /** + * Gets the modelId value for this NotifyTodoSendContext. + * + * @return modelId + */ + public java.lang.String getModelId() { + return modelId; + } + + + /** + * Sets the modelId value for this NotifyTodoSendContext. + * + * @param modelId + */ + public void setModelId(java.lang.String modelId) { + this.modelId = modelId; + } + + + /** + * Gets the modelName value for this NotifyTodoSendContext. + * + * @return modelName + */ + public java.lang.String getModelName() { + return modelName; + } + + + /** + * Sets the modelName value for this NotifyTodoSendContext. + * + * @param modelName + */ + public void setModelName(java.lang.String modelName) { + this.modelName = modelName; + } + + + /** + * Gets the others value for this NotifyTodoSendContext. + * + * @return others + */ + public java.lang.String getOthers() { + return others; + } + + + /** + * Sets the others value for this NotifyTodoSendContext. + * + * @param others + */ + public void setOthers(java.lang.String others) { + this.others = others; + } + + + /** + * Gets the padLink value for this NotifyTodoSendContext. + * + * @return padLink + */ + public java.lang.String getPadLink() { + return padLink; + } + + + /** + * Sets the padLink value for this NotifyTodoSendContext. + * + * @param padLink + */ + public void setPadLink(java.lang.String padLink) { + this.padLink = padLink; + } + + + /** + * Gets the param1 value for this NotifyTodoSendContext. + * + * @return param1 + */ + public java.lang.String getParam1() { + return param1; + } + + + /** + * Sets the param1 value for this NotifyTodoSendContext. + * + * @param param1 + */ + public void setParam1(java.lang.String param1) { + this.param1 = param1; + } + + + /** + * Gets the param2 value for this NotifyTodoSendContext. + * + * @return param2 + */ + public java.lang.String getParam2() { + return param2; + } + + + /** + * Sets the param2 value for this NotifyTodoSendContext. + * + * @param param2 + */ + public void setParam2(java.lang.String param2) { + this.param2 = param2; + } + + + /** + * Gets the subject value for this NotifyTodoSendContext. + * + * @return subject + */ + public java.lang.String getSubject() { + return subject; + } + + + /** + * Sets the subject value for this NotifyTodoSendContext. + * + * @param subject + */ + public void setSubject(java.lang.String subject) { + this.subject = subject; + } + + + /** + * Gets the targets value for this NotifyTodoSendContext. + * + * @return targets + */ + public java.lang.String getTargets() { + return targets; + } + + + /** + * Sets the targets value for this NotifyTodoSendContext. + * + * @param targets + */ + public void setTargets(java.lang.String targets) { + this.targets = targets; + } + + + /** + * Gets the type value for this NotifyTodoSendContext. + * + * @return type + */ + public java.lang.Integer getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoSendContext. + * + * @param type + */ + public void setType(java.lang.Integer type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoSendContext)) return false; + NotifyTodoSendContext other = (NotifyTodoSendContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.appName==null && other.getAppName()==null) || + (this.appName!=null && + this.appName.equals(other.getAppName()))) && + ((this.createTime==null && other.getCreateTime()==null) || + (this.createTime!=null && + this.createTime.equals(other.getCreateTime()))) && + ((this.docCreator==null && other.getDocCreator()==null) || + (this.docCreator!=null && + this.docCreator.equals(other.getDocCreator()))) && + ((this.extendContent==null && other.getExtendContent()==null) || + (this.extendContent!=null && + this.extendContent.equals(other.getExtendContent()))) && + ((this.key==null && other.getKey()==null) || + (this.key!=null && + this.key.equals(other.getKey()))) && + ((this.language==null && other.getLanguage()==null) || + (this.language!=null && + this.language.equals(other.getLanguage()))) && + ((this.level==null && other.getLevel()==null) || + (this.level!=null && + this.level.equals(other.getLevel()))) && + ((this.link==null && other.getLink()==null) || + (this.link!=null && + this.link.equals(other.getLink()))) && + ((this.mobileLink==null && other.getMobileLink()==null) || + (this.mobileLink!=null && + this.mobileLink.equals(other.getMobileLink()))) && + ((this.modelId==null && other.getModelId()==null) || + (this.modelId!=null && + this.modelId.equals(other.getModelId()))) && + ((this.modelName==null && other.getModelName()==null) || + (this.modelName!=null && + this.modelName.equals(other.getModelName()))) && + ((this.others==null && other.getOthers()==null) || + (this.others!=null && + this.others.equals(other.getOthers()))) && + ((this.padLink==null && other.getPadLink()==null) || + (this.padLink!=null && + this.padLink.equals(other.getPadLink()))) && + ((this.param1==null && other.getParam1()==null) || + (this.param1!=null && + this.param1.equals(other.getParam1()))) && + ((this.param2==null && other.getParam2()==null) || + (this.param2!=null && + this.param2.equals(other.getParam2()))) && + ((this.subject==null && other.getSubject()==null) || + (this.subject!=null && + this.subject.equals(other.getSubject()))) && + ((this.targets==null && other.getTargets()==null) || + (this.targets!=null && + this.targets.equals(other.getTargets()))) && + ((this.type==null && other.getType()==null) || + (this.type!=null && + this.type.equals(other.getType()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAppName() != null) { + _hashCode += getAppName().hashCode(); + } + if (getCreateTime() != null) { + _hashCode += getCreateTime().hashCode(); + } + if (getDocCreator() != null) { + _hashCode += getDocCreator().hashCode(); + } + if (getExtendContent() != null) { + _hashCode += getExtendContent().hashCode(); + } + if (getKey() != null) { + _hashCode += getKey().hashCode(); + } + if (getLanguage() != null) { + _hashCode += getLanguage().hashCode(); + } + if (getLevel() != null) { + _hashCode += getLevel().hashCode(); + } + if (getLink() != null) { + _hashCode += getLink().hashCode(); + } + if (getMobileLink() != null) { + _hashCode += getMobileLink().hashCode(); + } + if (getModelId() != null) { + _hashCode += getModelId().hashCode(); + } + if (getModelName() != null) { + _hashCode += getModelName().hashCode(); + } + if (getOthers() != null) { + _hashCode += getOthers().hashCode(); + } + if (getPadLink() != null) { + _hashCode += getPadLink().hashCode(); + } + if (getParam1() != null) { + _hashCode += getParam1().hashCode(); + } + if (getParam2() != null) { + _hashCode += getParam2().hashCode(); + } + if (getSubject() != null) { + _hashCode += getSubject().hashCode(); + } + if (getTargets() != null) { + _hashCode += getTargets().hashCode(); + } + if (getType() != null) { + _hashCode += getType().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoSendContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoSendContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("appName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "appName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("createTime"); + elemField.setXmlName(new javax.xml.namespace.QName("", "createTime")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("docCreator"); + elemField.setXmlName(new javax.xml.namespace.QName("", "docCreator")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("extendContent"); + elemField.setXmlName(new javax.xml.namespace.QName("", "extendContent")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("key"); + elemField.setXmlName(new javax.xml.namespace.QName("", "key")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("language"); + elemField.setXmlName(new javax.xml.namespace.QName("", "language")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("level"); + elemField.setXmlName(new javax.xml.namespace.QName("", "level")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("link"); + elemField.setXmlName(new javax.xml.namespace.QName("", "link")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("mobileLink"); + elemField.setXmlName(new javax.xml.namespace.QName("", "mobileLink")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("others"); + elemField.setXmlName(new javax.xml.namespace.QName("", "others")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("padLink"); + elemField.setXmlName(new javax.xml.namespace.QName("", "padLink")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param1")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param2"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param2")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("subject"); + elemField.setXmlName(new javax.xml.namespace.QName("", "subject")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("targets"); + elemField.setXmlName(new javax.xml.namespace.QName("", "targets")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT.java new file mode 100644 index 0000000..1d7fceb --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT.java @@ -0,0 +1,12 @@ +/** + * SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public interface SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT extends java.rmi.Remote { + public com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT(com.api.taojw.liangxin.todo.posendtodowebservice.SendTodo parameters) throws java.rmi.RemoteException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub.java new file mode 100644 index 0000000..c61c29d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub.java @@ -0,0 +1,196 @@ +/** + * SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public class SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub extends org.apache.axis.client.Stub implements com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[1]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodo"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodo"), com.api.taojw.liangxin.todo.posendtodowebservice.SendTodo.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodoResponse")); + oper.setReturnClass(com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodoResponse")); + oper.setStyle(org.apache.axis.constants.Style.DOCUMENT); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + } + + public SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoAppResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoSendContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoSendContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodo"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.posendtodowebservice.SendTodo.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodoResponse"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT(com.api.taojw.liangxin.todo.posendtodowebservice.SendTodo parameters) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("", "SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {parameters}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.posendtodowebservice.SendTodoResponse.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService.java new file mode 100644 index 0000000..c7992f7 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService.java @@ -0,0 +1,21 @@ +/** + * SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public interface SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService extends javax.xml.rpc.Service { + public java.lang.String getHTTPS_PortAddress(); + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTPS_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public java.lang.String getHTTP_PortAddress(); + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTP_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java new file mode 100644 index 0000000..88c78b4 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java @@ -0,0 +1,202 @@ +/** + * SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public class SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService { + + public SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator() { + } + + + public SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for HTTPS_Port + private java.lang.String HTTPS_Port_address = "https://poqas.sh-liangxin.com:50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SHIMS&receiverParty=&receiverService=&interface=SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT&interfaceNamespace=urn%3Anader%3Acom%2FSHIMS"; + + public java.lang.String getHTTPS_PortAddress() { + return HTTPS_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTPS_PortWSDDServiceName = "HTTPS_Port"; + + public java.lang.String getHTTPS_PortWSDDServiceName() { + return HTTPS_PortWSDDServiceName; + } + + public void setHTTPS_PortWSDDServiceName(java.lang.String name) { + HTTPS_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTPS_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTPS_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTPS_Port(endpoint); + } + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(portAddress, this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTPS_PortEndpointAddress(java.lang.String address) { + HTTPS_Port_address = address; + } + + + // Use to get a proxy class for HTTP_Port + private java.lang.String HTTP_Port_address = "http://poqas.sh-liangxin.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SHIMS&receiverParty=&receiverService=&interface=SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT&interfaceNamespace=urn%3Anader%3Acom%2FSHIMS"; + + public java.lang.String getHTTP_PortAddress() { + return HTTP_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTP_PortWSDDServiceName = "HTTP_Port"; + + public java.lang.String getHTTP_PortWSDDServiceName() { + return HTTP_PortWSDDServiceName; + } + + public void setHTTP_PortWSDDServiceName(java.lang.String name) { + HTTP_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTP_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTP_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTP_Port(endpoint); + } + + public com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(portAddress, this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTP_PortEndpointAddress(java.lang.String address) { + HTTP_Port_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + * This service has multiple ports for a given interface; + * the proxy implementation returned may be indeterminate. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(new java.net.URL(HTTPS_Port_address), this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + if (com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUT.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.posendtodowebservice.SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTBindingStub(new java.net.URL(HTTP_Port_address), this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("HTTPS_Port".equals(inputPortName)) { + return getHTTPS_Port(); + } + else if ("HTTP_Port".equals(inputPortName)) { + return getHTTP_Port(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("urn:nader:com/SHIMS", "SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTP_Port")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("HTTPS_Port".equals(portName)) { + setHTTPS_PortEndpointAddress(address); + } + else +if ("HTTP_Port".equals(portName)) { + setHTTP_PortEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SendTodo.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SendTodo.java new file mode 100644 index 0000000..a47412a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SendTodo.java @@ -0,0 +1,120 @@ +/** + * SendTodo.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public class SendTodo implements java.io.Serializable { + private com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoSendContext arg0; + + public SendTodo() { + } + + public SendTodo( + com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoSendContext arg0) { + this.arg0 = arg0; + } + + + /** + * Gets the arg0 value for this SendTodo. + * + * @return arg0 + */ + public com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoSendContext getArg0() { + return arg0; + } + + + /** + * Sets the arg0 value for this SendTodo. + * + * @param arg0 + */ + public void setArg0(com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoSendContext arg0) { + this.arg0 = arg0; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SendTodo)) return false; + SendTodo other = (SendTodo) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.arg0==null && other.getArg0()==null) || + (this.arg0!=null && + this.arg0.equals(other.getArg0()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getArg0() != null) { + _hashCode += getArg0().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SendTodo.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodo")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("arg0"); + elemField.setXmlName(new javax.xml.namespace.QName("", "arg0")); + elemField.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoSendContext")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SendTodoResponse.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SendTodoResponse.java new file mode 100644 index 0000000..734c4aa --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SendTodoResponse.java @@ -0,0 +1,120 @@ +/** + * SendTodoResponse.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.posendtodowebservice; + +public class SendTodoResponse implements java.io.Serializable { + private com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoAppResult _return; + + public SendTodoResponse() { + } + + public SendTodoResponse( + com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoAppResult _return) { + this._return = _return; + } + + + /** + * Gets the _return value for this SendTodoResponse. + * + * @return _return + */ + public com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoAppResult get_return() { + return _return; + } + + + /** + * Sets the _return value for this SendTodoResponse. + * + * @param _return + */ + public void set_return(com.api.taojw.liangxin.todo.posendtodowebservice.NotifyTodoAppResult _return) { + this._return = _return; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SendTodoResponse)) return false; + SendTodoResponse other = (SendTodoResponse) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this._return==null && other.get_return()==null) || + (this._return!=null && + this._return.equals(other.get_return()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (get_return() != null) { + _hashCode += get_return().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SendTodoResponse.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodoResponse")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("_return"); + elemField.setXmlName(new javax.xml.namespace.QName("", "return")); + elemField.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/NotifyTodoAppResult.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/NotifyTodoAppResult.java new file mode 100644 index 0000000..8c41b67 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/NotifyTodoAppResult.java @@ -0,0 +1,152 @@ +/** + * NotifyTodoAppResult.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public class NotifyTodoAppResult implements java.io.Serializable { + private java.lang.String message; + + private int returnState; + + public NotifyTodoAppResult() { + } + + public NotifyTodoAppResult( + java.lang.String message, + int returnState) { + this.message = message; + this.returnState = returnState; + } + + + /** + * Gets the message value for this NotifyTodoAppResult. + * + * @return message + */ + public java.lang.String getMessage() { + return message; + } + + + /** + * Sets the message value for this NotifyTodoAppResult. + * + * @param message + */ + public void setMessage(java.lang.String message) { + this.message = message; + } + + + /** + * Gets the returnState value for this NotifyTodoAppResult. + * + * @return returnState + */ + public int getReturnState() { + return returnState; + } + + + /** + * Sets the returnState value for this NotifyTodoAppResult. + * + * @param returnState + */ + public void setReturnState(int returnState) { + this.returnState = returnState; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoAppResult)) return false; + NotifyTodoAppResult other = (NotifyTodoAppResult) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.message==null && other.getMessage()==null) || + (this.message!=null && + this.message.equals(other.getMessage()))) && + this.returnState == other.getReturnState(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getMessage() != null) { + _hashCode += getMessage().hashCode(); + } + _hashCode += getReturnState(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoAppResult.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnState"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnState")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/NotifyTodoRemoveContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/NotifyTodoRemoveContext.java new file mode 100644 index 0000000..0e2bc1d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/NotifyTodoRemoveContext.java @@ -0,0 +1,448 @@ +/** + * NotifyTodoRemoveContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public class NotifyTodoRemoveContext implements java.io.Serializable { + private java.lang.String appName; + + private java.lang.String key; + + private java.lang.String modelId; + + private java.lang.String modelName; + + private java.lang.Integer optType; + + private java.lang.String others; + + private java.lang.String param1; + + private java.lang.String param2; + + private java.lang.String targets; + + private int type; + + public NotifyTodoRemoveContext() { + } + + public NotifyTodoRemoveContext( + java.lang.String appName, + java.lang.String key, + java.lang.String modelId, + java.lang.String modelName, + java.lang.Integer optType, + java.lang.String others, + java.lang.String param1, + java.lang.String param2, + java.lang.String targets, + int type) { + this.appName = appName; + this.key = key; + this.modelId = modelId; + this.modelName = modelName; + this.optType = optType; + this.others = others; + this.param1 = param1; + this.param2 = param2; + this.targets = targets; + this.type = type; + } + + + /** + * Gets the appName value for this NotifyTodoRemoveContext. + * + * @return appName + */ + public java.lang.String getAppName() { + return appName; + } + + + /** + * Sets the appName value for this NotifyTodoRemoveContext. + * + * @param appName + */ + public void setAppName(java.lang.String appName) { + this.appName = appName; + } + + + /** + * Gets the key value for this NotifyTodoRemoveContext. + * + * @return key + */ + public java.lang.String getKey() { + return key; + } + + + /** + * Sets the key value for this NotifyTodoRemoveContext. + * + * @param key + */ + public void setKey(java.lang.String key) { + this.key = key; + } + + + /** + * Gets the modelId value for this NotifyTodoRemoveContext. + * + * @return modelId + */ + public java.lang.String getModelId() { + return modelId; + } + + + /** + * Sets the modelId value for this NotifyTodoRemoveContext. + * + * @param modelId + */ + public void setModelId(java.lang.String modelId) { + this.modelId = modelId; + } + + + /** + * Gets the modelName value for this NotifyTodoRemoveContext. + * + * @return modelName + */ + public java.lang.String getModelName() { + return modelName; + } + + + /** + * Sets the modelName value for this NotifyTodoRemoveContext. + * + * @param modelName + */ + public void setModelName(java.lang.String modelName) { + this.modelName = modelName; + } + + + /** + * Gets the optType value for this NotifyTodoRemoveContext. + * + * @return optType + */ + public java.lang.Integer getOptType() { + return optType; + } + + + /** + * Sets the optType value for this NotifyTodoRemoveContext. + * + * @param optType + */ + public void setOptType(java.lang.Integer optType) { + this.optType = optType; + } + + + /** + * Gets the others value for this NotifyTodoRemoveContext. + * + * @return others + */ + public java.lang.String getOthers() { + return others; + } + + + /** + * Sets the others value for this NotifyTodoRemoveContext. + * + * @param others + */ + public void setOthers(java.lang.String others) { + this.others = others; + } + + + /** + * Gets the param1 value for this NotifyTodoRemoveContext. + * + * @return param1 + */ + public java.lang.String getParam1() { + return param1; + } + + + /** + * Sets the param1 value for this NotifyTodoRemoveContext. + * + * @param param1 + */ + public void setParam1(java.lang.String param1) { + this.param1 = param1; + } + + + /** + * Gets the param2 value for this NotifyTodoRemoveContext. + * + * @return param2 + */ + public java.lang.String getParam2() { + return param2; + } + + + /** + * Sets the param2 value for this NotifyTodoRemoveContext. + * + * @param param2 + */ + public void setParam2(java.lang.String param2) { + this.param2 = param2; + } + + + /** + * Gets the targets value for this NotifyTodoRemoveContext. + * + * @return targets + */ + public java.lang.String getTargets() { + return targets; + } + + + /** + * Sets the targets value for this NotifyTodoRemoveContext. + * + * @param targets + */ + public void setTargets(java.lang.String targets) { + this.targets = targets; + } + + + /** + * Gets the type value for this NotifyTodoRemoveContext. + * + * @return type + */ + public int getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoRemoveContext. + * + * @param type + */ + public void setType(int type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoRemoveContext)) return false; + NotifyTodoRemoveContext other = (NotifyTodoRemoveContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.appName==null && other.getAppName()==null) || + (this.appName!=null && + this.appName.equals(other.getAppName()))) && + ((this.key==null && other.getKey()==null) || + (this.key!=null && + this.key.equals(other.getKey()))) && + ((this.modelId==null && other.getModelId()==null) || + (this.modelId!=null && + this.modelId.equals(other.getModelId()))) && + ((this.modelName==null && other.getModelName()==null) || + (this.modelName!=null && + this.modelName.equals(other.getModelName()))) && + ((this.optType==null && other.getOptType()==null) || + (this.optType!=null && + this.optType.equals(other.getOptType()))) && + ((this.others==null && other.getOthers()==null) || + (this.others!=null && + this.others.equals(other.getOthers()))) && + ((this.param1==null && other.getParam1()==null) || + (this.param1!=null && + this.param1.equals(other.getParam1()))) && + ((this.param2==null && other.getParam2()==null) || + (this.param2!=null && + this.param2.equals(other.getParam2()))) && + ((this.targets==null && other.getTargets()==null) || + (this.targets!=null && + this.targets.equals(other.getTargets()))) && + this.type == other.getType(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAppName() != null) { + _hashCode += getAppName().hashCode(); + } + if (getKey() != null) { + _hashCode += getKey().hashCode(); + } + if (getModelId() != null) { + _hashCode += getModelId().hashCode(); + } + if (getModelName() != null) { + _hashCode += getModelName().hashCode(); + } + if (getOptType() != null) { + _hashCode += getOptType().hashCode(); + } + if (getOthers() != null) { + _hashCode += getOthers().hashCode(); + } + if (getParam1() != null) { + _hashCode += getParam1().hashCode(); + } + if (getParam2() != null) { + _hashCode += getParam2().hashCode(); + } + if (getTargets() != null) { + _hashCode += getTargets().hashCode(); + } + _hashCode += getType(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoRemoveContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("appName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "appName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("key"); + elemField.setXmlName(new javax.xml.namespace.QName("", "key")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("optType"); + elemField.setXmlName(new javax.xml.namespace.QName("", "optType")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("others"); + elemField.setXmlName(new javax.xml.namespace.QName("", "others")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param1")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param2"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param2")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("targets"); + elemField.setXmlName(new javax.xml.namespace.QName("", "targets")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT.java new file mode 100644 index 0000000..5270e23 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT.java @@ -0,0 +1,12 @@ +/** + * SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public interface SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT extends java.rmi.Remote { + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT(com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDone parameters) throws java.rmi.RemoteException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub.java new file mode 100644 index 0000000..2b00608 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub.java @@ -0,0 +1,196 @@ +/** + * SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public class SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub extends org.apache.axis.client.Stub implements com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[1]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDone"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDone"), com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDone.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDoneResponse")); + oper.setReturnClass(com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse.class); + oper.setReturnQName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDoneResponse")); + oper.setStyle(org.apache.axis.constants.Style.DOCUMENT); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + } + + public SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoAppResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDone"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDone.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDoneResponse"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT(com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDone parameters) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1"); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("", "SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {parameters}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.poupdatetodowebservice.SetTodoDoneResponse.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService.java new file mode 100644 index 0000000..74efedf --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService.java @@ -0,0 +1,21 @@ +/** + * SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public interface SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService extends javax.xml.rpc.Service { + public java.lang.String getHTTPS_PortAddress(); + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTPS_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public java.lang.String getHTTP_PortAddress(); + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTP_Port() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java new file mode 100644 index 0000000..acac6b0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java @@ -0,0 +1,202 @@ +/** + * SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public class SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService { + + public SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator() { + } + + + public SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for HTTPS_Port + private java.lang.String HTTPS_Port_address = "https://poqas.sh-liangxin.com:50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SHIMS&receiverParty=&receiverService=&interface=SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT&interfaceNamespace=urn%3Anader%3Acom%2FSHIMS"; + + public java.lang.String getHTTPS_PortAddress() { + return HTTPS_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTPS_PortWSDDServiceName = "HTTPS_Port"; + + public java.lang.String getHTTPS_PortWSDDServiceName() { + return HTTPS_PortWSDDServiceName; + } + + public void setHTTPS_PortWSDDServiceName(java.lang.String name) { + HTTPS_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTPS_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTPS_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTPS_Port(endpoint); + } + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTPS_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(portAddress, this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTPS_PortEndpointAddress(java.lang.String address) { + HTTPS_Port_address = address; + } + + + // Use to get a proxy class for HTTP_Port + private java.lang.String HTTP_Port_address = "http://poqas.sh-liangxin.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SHIMS&receiverParty=&receiverService=&interface=SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT&interfaceNamespace=urn%3Anader%3Acom%2FSHIMS"; + + public java.lang.String getHTTP_PortAddress() { + return HTTP_Port_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String HTTP_PortWSDDServiceName = "HTTP_Port"; + + public java.lang.String getHTTP_PortWSDDServiceName() { + return HTTP_PortWSDDServiceName; + } + + public void setHTTP_PortWSDDServiceName(java.lang.String name) { + HTTP_PortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTP_Port() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(HTTP_Port_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getHTTP_Port(endpoint); + } + + public com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT getHTTP_Port(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(portAddress, this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setHTTP_PortEndpointAddress(java.lang.String address) { + HTTP_Port_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + * This service has multiple ports for a given interface; + * the proxy implementation returned may be indeterminate. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(new java.net.URL(HTTPS_Port_address), this); + _stub.setPortName(getHTTPS_PortWSDDServiceName()); + return _stub; + } + if (com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUT.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub _stub = new com.api.taojw.liangxin.todo.poupdatetodowebservice.SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTBindingStub(new java.net.URL(HTTP_Port_address), this); + _stub.setPortName(getHTTP_PortWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("HTTPS_Port".equals(inputPortName)) { + return getHTTPS_Port(); + } + else if ("HTTP_Port".equals(inputPortName)) { + return getHTTP_Port(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("urn:nader:com/SHIMS", "SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTP_Port")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("HTTPS_Port".equals(portName)) { + setHTTPS_PortEndpointAddress(address); + } + else +if ("HTTP_Port".equals(portName)) { + setHTTP_PortEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SetTodoDone.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SetTodoDone.java new file mode 100644 index 0000000..1f77721 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SetTodoDone.java @@ -0,0 +1,120 @@ +/** + * SetTodoDone.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public class SetTodoDone implements java.io.Serializable { + private com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext arg0; + + public SetTodoDone() { + } + + public SetTodoDone( + com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext arg0) { + this.arg0 = arg0; + } + + + /** + * Gets the arg0 value for this SetTodoDone. + * + * @return arg0 + */ + public com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext getArg0() { + return arg0; + } + + + /** + * Sets the arg0 value for this SetTodoDone. + * + * @param arg0 + */ + public void setArg0(com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoRemoveContext arg0) { + this.arg0 = arg0; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SetTodoDone)) return false; + SetTodoDone other = (SetTodoDone) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.arg0==null && other.getArg0()==null) || + (this.arg0!=null && + this.arg0.equals(other.getArg0()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getArg0() != null) { + _hashCode += getArg0().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SetTodoDone.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDone")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("arg0"); + elemField.setXmlName(new javax.xml.namespace.QName("", "arg0")); + elemField.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SetTodoDoneResponse.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SetTodoDoneResponse.java new file mode 100644 index 0000000..994a98b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SetTodoDoneResponse.java @@ -0,0 +1,120 @@ +/** + * SetTodoDoneResponse.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.poupdatetodowebservice; + +public class SetTodoDoneResponse implements java.io.Serializable { + private com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoAppResult _return; + + public SetTodoDoneResponse() { + } + + public SetTodoDoneResponse( + com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoAppResult _return) { + this._return = _return; + } + + + /** + * Gets the _return value for this SetTodoDoneResponse. + * + * @return _return + */ + public com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoAppResult get_return() { + return _return; + } + + + /** + * Sets the _return value for this SetTodoDoneResponse. + * + * @param _return + */ + public void set_return(com.api.taojw.liangxin.todo.poupdatetodowebservice.NotifyTodoAppResult _return) { + this._return = _return; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof SetTodoDoneResponse)) return false; + SetTodoDoneResponse other = (SetTodoDoneResponse) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this._return==null && other.get_return()==null) || + (this._return!=null && + this._return.equals(other.get_return()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (get_return() != null) { + _hashCode += get_return().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(SetTodoDoneResponse.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDoneResponse")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("_return"); + elemField.setXmlName(new javax.xml.namespace.QName("", "return")); + elemField.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/Exception.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/Exception.java new file mode 100644 index 0000000..6b7ef3e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/Exception.java @@ -0,0 +1,127 @@ +/** + * Exception.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class Exception extends org.apache.axis.AxisFault implements java.io.Serializable { + private java.lang.String message1; + + public Exception() { + } + + public Exception( + java.lang.String message1) { + this.message1 = message1; + } + + + /** + * Gets the message1 value for this Exception. + * + * @return message1 + */ + public java.lang.String getMessage1() { + return message1; + } + + + /** + * Sets the message1 value for this Exception. + * + * @param message1 + */ + public void setMessage1(java.lang.String message1) { + this.message1 = message1; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof Exception)) return false; + Exception other = (Exception) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.message1==null && other.getMessage1()==null) || + (this.message1!=null && + this.message1.equals(other.getMessage1()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getMessage1() != null) { + _hashCode += getMessage1().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(Exception.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + + + /** + * Writes the exception data to the faultDetails + */ + public void writeDetails(javax.xml.namespace.QName qname, org.apache.axis.encoding.SerializationContext context) throws java.io.IOException { + context.serialize(qname, null, this); + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebService.java new file mode 100644 index 0000000..a9a8f99 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebService.java @@ -0,0 +1,18 @@ +/** + * ISysNotifyTodoWebService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public interface ISysNotifyTodoWebService extends java.rmi.Remote { + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult getTodoCount(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetCountContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult deleteTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult setTodoDone(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult getTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult sendTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoSendContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult getTodoTargets(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult updateTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoUpdateContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceService.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceService.java new file mode 100644 index 0000000..05b6b1c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceService.java @@ -0,0 +1,16 @@ +/** + * ISysNotifyTodoWebServiceService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public interface ISysNotifyTodoWebServiceService extends javax.xml.rpc.Service { + public java.lang.String getISysNotifyTodoWebServicePortAddress(); + + public com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebService getISysNotifyTodoWebServicePort() throws javax.xml.rpc.ServiceException; + + public com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebService getISysNotifyTodoWebServicePort(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceLocator.java new file mode 100644 index 0000000..c3bee42 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceLocator.java @@ -0,0 +1,142 @@ +/** + * ISysNotifyTodoWebServiceServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class ISysNotifyTodoWebServiceServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebServiceService { + + public ISysNotifyTodoWebServiceServiceLocator() { + } + + + public ISysNotifyTodoWebServiceServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public ISysNotifyTodoWebServiceServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for ISysNotifyTodoWebServicePort + private java.lang.String ISysNotifyTodoWebServicePort_address = "http://oa.sh-liangxin.com/sys/webservice/sysNotifyTodoWebService"; + + public java.lang.String getISysNotifyTodoWebServicePortAddress() { + return ISysNotifyTodoWebServicePort_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String ISysNotifyTodoWebServicePortWSDDServiceName = "ISysNotifyTodoWebServicePort"; + + public java.lang.String getISysNotifyTodoWebServicePortWSDDServiceName() { + return ISysNotifyTodoWebServicePortWSDDServiceName; + } + + public void setISysNotifyTodoWebServicePortWSDDServiceName(java.lang.String name) { + ISysNotifyTodoWebServicePortWSDDServiceName = name; + } + + public com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebService getISysNotifyTodoWebServicePort() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(ISysNotifyTodoWebServicePort_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getISysNotifyTodoWebServicePort(endpoint); + } + + public com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebService getISysNotifyTodoWebServicePort(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebServiceServiceSoapBindingStub _stub = new com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebServiceServiceSoapBindingStub(portAddress, this); + _stub.setPortName(getISysNotifyTodoWebServicePortWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setISysNotifyTodoWebServicePortEndpointAddress(java.lang.String address) { + ISysNotifyTodoWebServicePort_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebService.class.isAssignableFrom(serviceEndpointInterface)) { + com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebServiceServiceSoapBindingStub _stub = new com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebServiceServiceSoapBindingStub(new java.net.URL(ISysNotifyTodoWebServicePort_address), this); + _stub.setPortName(getISysNotifyTodoWebServicePortWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("ISysNotifyTodoWebServicePort".equals(inputPortName)) { + return getISysNotifyTodoWebServicePort(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "ISysNotifyTodoWebServiceService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "ISysNotifyTodoWebServicePort")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("ISysNotifyTodoWebServicePort".equals(portName)) { + setISysNotifyTodoWebServicePortEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java new file mode 100644 index 0000000..6782c0a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java @@ -0,0 +1,592 @@ +/** + * ISysNotifyTodoWebServiceServiceSoapBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.axis.client.Stub implements com.api.taojw.liangxin.todo.todowebservice.ISysNotifyTodoWebService { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[7]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("deleteTodo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getTodoCount"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetCountContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetCountContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("setTodoDone"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getTodo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[3] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("sendTodo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoSendContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoSendContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[4] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getTodoTargets"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[5] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("updateTodo"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg0"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoUpdateContext"), com.api.taojw.liangxin.todo.todowebservice.NotifyTodoUpdateContext.class, false, false); + param.setOmittable(true); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + oper.setReturnClass(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "return")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + "com.api.taojw.liangxin.todo.todowebservice.Exception", + new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), + true + )); + _operations[6] = oper; + + } + + public ISysNotifyTodoWebServiceServiceSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public ISysNotifyTodoWebServiceServiceSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public ISysNotifyTodoWebServiceServiceSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.Exception.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetCountContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetCountContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoSendContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.NotifyTodoSendContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoUpdateContext"); + cachedSerQNames.add(qName); + cls = com.api.taojw.liangxin.todo.todowebservice.NotifyTodoUpdateContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult deleteTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "deleteTodo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult getTodoCount(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetCountContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "getTodoCount")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult setTodoDone(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoRemoveContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "setTodoDone")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult getTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "getTodo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult sendTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoSendContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[4]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "sendTodo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult getTodoTargets(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoGetContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[5]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "getTodoTargets")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult updateTodo(com.api.taojw.liangxin.todo.todowebservice.NotifyTodoUpdateContext arg0) throws java.rmi.RemoteException, com.api.taojw.liangxin.todo.todowebservice.Exception { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[6]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "updateTodo")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {arg0}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) _resp; + } catch (java.lang.Exception _exception) { + return (com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult) org.apache.axis.utils.JavaUtils.convert(_resp, com.api.taojw.liangxin.todo.todowebservice.NotifyTodoAppResult.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof com.api.taojw.liangxin.todo.todowebservice.Exception) { + throw (com.api.taojw.liangxin.todo.todowebservice.Exception) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoAppResult.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoAppResult.java new file mode 100644 index 0000000..c4ca1ff --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoAppResult.java @@ -0,0 +1,152 @@ +/** + * NotifyTodoAppResult.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class NotifyTodoAppResult implements java.io.Serializable { + private java.lang.String message; + + private int returnState; + + public NotifyTodoAppResult() { + } + + public NotifyTodoAppResult( + java.lang.String message, + int returnState) { + this.message = message; + this.returnState = returnState; + } + + + /** + * Gets the message value for this NotifyTodoAppResult. + * + * @return message + */ + public java.lang.String getMessage() { + return message; + } + + + /** + * Sets the message value for this NotifyTodoAppResult. + * + * @param message + */ + public void setMessage(java.lang.String message) { + this.message = message; + } + + + /** + * Gets the returnState value for this NotifyTodoAppResult. + * + * @return returnState + */ + public int getReturnState() { + return returnState; + } + + + /** + * Sets the returnState value for this NotifyTodoAppResult. + * + * @param returnState + */ + public void setReturnState(int returnState) { + this.returnState = returnState; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoAppResult)) return false; + NotifyTodoAppResult other = (NotifyTodoAppResult) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.message==null && other.getMessage()==null) || + (this.message!=null && + this.message.equals(other.getMessage()))) && + this.returnState == other.getReturnState(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getMessage() != null) { + _hashCode += getMessage().hashCode(); + } + _hashCode += getReturnState(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoAppResult.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoAppResult")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("message"); + elemField.setXmlName(new javax.xml.namespace.QName("", "message")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("returnState"); + elemField.setXmlName(new javax.xml.namespace.QName("", "returnState")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoGetContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoGetContext.java new file mode 100644 index 0000000..2c03b25 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoGetContext.java @@ -0,0 +1,290 @@ +/** + * NotifyTodoGetContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class NotifyTodoGetContext implements java.io.Serializable { + private java.lang.String fdId; + + private java.lang.String otherCond; + + private int pageNo; + + private int rowSize; + + private java.lang.String targets; + + private int type; + + public NotifyTodoGetContext() { + } + + public NotifyTodoGetContext( + java.lang.String fdId, + java.lang.String otherCond, + int pageNo, + int rowSize, + java.lang.String targets, + int type) { + this.fdId = fdId; + this.otherCond = otherCond; + this.pageNo = pageNo; + this.rowSize = rowSize; + this.targets = targets; + this.type = type; + } + + + /** + * Gets the fdId value for this NotifyTodoGetContext. + * + * @return fdId + */ + public java.lang.String getFdId() { + return fdId; + } + + + /** + * Sets the fdId value for this NotifyTodoGetContext. + * + * @param fdId + */ + public void setFdId(java.lang.String fdId) { + this.fdId = fdId; + } + + + /** + * Gets the otherCond value for this NotifyTodoGetContext. + * + * @return otherCond + */ + public java.lang.String getOtherCond() { + return otherCond; + } + + + /** + * Sets the otherCond value for this NotifyTodoGetContext. + * + * @param otherCond + */ + public void setOtherCond(java.lang.String otherCond) { + this.otherCond = otherCond; + } + + + /** + * Gets the pageNo value for this NotifyTodoGetContext. + * + * @return pageNo + */ + public int getPageNo() { + return pageNo; + } + + + /** + * Sets the pageNo value for this NotifyTodoGetContext. + * + * @param pageNo + */ + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + + /** + * Gets the rowSize value for this NotifyTodoGetContext. + * + * @return rowSize + */ + public int getRowSize() { + return rowSize; + } + + + /** + * Sets the rowSize value for this NotifyTodoGetContext. + * + * @param rowSize + */ + public void setRowSize(int rowSize) { + this.rowSize = rowSize; + } + + + /** + * Gets the targets value for this NotifyTodoGetContext. + * + * @return targets + */ + public java.lang.String getTargets() { + return targets; + } + + + /** + * Sets the targets value for this NotifyTodoGetContext. + * + * @param targets + */ + public void setTargets(java.lang.String targets) { + this.targets = targets; + } + + + /** + * Gets the type value for this NotifyTodoGetContext. + * + * @return type + */ + public int getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoGetContext. + * + * @param type + */ + public void setType(int type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoGetContext)) return false; + NotifyTodoGetContext other = (NotifyTodoGetContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.fdId==null && other.getFdId()==null) || + (this.fdId!=null && + this.fdId.equals(other.getFdId()))) && + ((this.otherCond==null && other.getOtherCond()==null) || + (this.otherCond!=null && + this.otherCond.equals(other.getOtherCond()))) && + this.pageNo == other.getPageNo() && + this.rowSize == other.getRowSize() && + ((this.targets==null && other.getTargets()==null) || + (this.targets!=null && + this.targets.equals(other.getTargets()))) && + this.type == other.getType(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getFdId() != null) { + _hashCode += getFdId().hashCode(); + } + if (getOtherCond() != null) { + _hashCode += getOtherCond().hashCode(); + } + _hashCode += getPageNo(); + _hashCode += getRowSize(); + if (getTargets() != null) { + _hashCode += getTargets().hashCode(); + } + _hashCode += getType(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoGetContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("fdId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "fdId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("otherCond"); + elemField.setXmlName(new javax.xml.namespace.QName("", "otherCond")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("pageNo"); + elemField.setXmlName(new javax.xml.namespace.QName("", "pageNo")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("rowSize"); + elemField.setXmlName(new javax.xml.namespace.QName("", "rowSize")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("targets"); + elemField.setXmlName(new javax.xml.namespace.QName("", "targets")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoGetCountContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoGetCountContext.java new file mode 100644 index 0000000..84e39c8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoGetCountContext.java @@ -0,0 +1,157 @@ +/** + * NotifyTodoGetCountContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class NotifyTodoGetCountContext implements java.io.Serializable { + private java.lang.String target; + + private java.lang.String types; + + public NotifyTodoGetCountContext() { + } + + public NotifyTodoGetCountContext( + java.lang.String target, + java.lang.String types) { + this.target = target; + this.types = types; + } + + + /** + * Gets the target value for this NotifyTodoGetCountContext. + * + * @return target + */ + public java.lang.String getTarget() { + return target; + } + + + /** + * Sets the target value for this NotifyTodoGetCountContext. + * + * @param target + */ + public void setTarget(java.lang.String target) { + this.target = target; + } + + + /** + * Gets the types value for this NotifyTodoGetCountContext. + * + * @return types + */ + public java.lang.String getTypes() { + return types; + } + + + /** + * Sets the types value for this NotifyTodoGetCountContext. + * + * @param types + */ + public void setTypes(java.lang.String types) { + this.types = types; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoGetCountContext)) return false; + NotifyTodoGetCountContext other = (NotifyTodoGetCountContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.target==null && other.getTarget()==null) || + (this.target!=null && + this.target.equals(other.getTarget()))) && + ((this.types==null && other.getTypes()==null) || + (this.types!=null && + this.types.equals(other.getTypes()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getTarget() != null) { + _hashCode += getTarget().hashCode(); + } + if (getTypes() != null) { + _hashCode += getTypes().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoGetCountContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoGetCountContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("target"); + elemField.setXmlName(new javax.xml.namespace.QName("", "target")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("types"); + elemField.setXmlName(new javax.xml.namespace.QName("", "types")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoRemoveContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoRemoveContext.java new file mode 100644 index 0000000..3b13a7e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoRemoveContext.java @@ -0,0 +1,448 @@ +/** + * NotifyTodoRemoveContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class NotifyTodoRemoveContext implements java.io.Serializable { + private java.lang.String appName; + + private java.lang.String key; + + private java.lang.String modelId; + + private java.lang.String modelName; + + private java.lang.Integer optType; + + private java.lang.String others; + + private java.lang.String param1; + + private java.lang.String param2; + + private java.lang.String targets; + + private int type; + + public NotifyTodoRemoveContext() { + } + + public NotifyTodoRemoveContext( + java.lang.String appName, + java.lang.String key, + java.lang.String modelId, + java.lang.String modelName, + java.lang.Integer optType, + java.lang.String others, + java.lang.String param1, + java.lang.String param2, + java.lang.String targets, + int type) { + this.appName = appName; + this.key = key; + this.modelId = modelId; + this.modelName = modelName; + this.optType = optType; + this.others = others; + this.param1 = param1; + this.param2 = param2; + this.targets = targets; + this.type = type; + } + + + /** + * Gets the appName value for this NotifyTodoRemoveContext. + * + * @return appName + */ + public java.lang.String getAppName() { + return appName; + } + + + /** + * Sets the appName value for this NotifyTodoRemoveContext. + * + * @param appName + */ + public void setAppName(java.lang.String appName) { + this.appName = appName; + } + + + /** + * Gets the key value for this NotifyTodoRemoveContext. + * + * @return key + */ + public java.lang.String getKey() { + return key; + } + + + /** + * Sets the key value for this NotifyTodoRemoveContext. + * + * @param key + */ + public void setKey(java.lang.String key) { + this.key = key; + } + + + /** + * Gets the modelId value for this NotifyTodoRemoveContext. + * + * @return modelId + */ + public java.lang.String getModelId() { + return modelId; + } + + + /** + * Sets the modelId value for this NotifyTodoRemoveContext. + * + * @param modelId + */ + public void setModelId(java.lang.String modelId) { + this.modelId = modelId; + } + + + /** + * Gets the modelName value for this NotifyTodoRemoveContext. + * + * @return modelName + */ + public java.lang.String getModelName() { + return modelName; + } + + + /** + * Sets the modelName value for this NotifyTodoRemoveContext. + * + * @param modelName + */ + public void setModelName(java.lang.String modelName) { + this.modelName = modelName; + } + + + /** + * Gets the optType value for this NotifyTodoRemoveContext. + * + * @return optType + */ + public java.lang.Integer getOptType() { + return optType; + } + + + /** + * Sets the optType value for this NotifyTodoRemoveContext. + * + * @param optType + */ + public void setOptType(java.lang.Integer optType) { + this.optType = optType; + } + + + /** + * Gets the others value for this NotifyTodoRemoveContext. + * + * @return others + */ + public java.lang.String getOthers() { + return others; + } + + + /** + * Sets the others value for this NotifyTodoRemoveContext. + * + * @param others + */ + public void setOthers(java.lang.String others) { + this.others = others; + } + + + /** + * Gets the param1 value for this NotifyTodoRemoveContext. + * + * @return param1 + */ + public java.lang.String getParam1() { + return param1; + } + + + /** + * Sets the param1 value for this NotifyTodoRemoveContext. + * + * @param param1 + */ + public void setParam1(java.lang.String param1) { + this.param1 = param1; + } + + + /** + * Gets the param2 value for this NotifyTodoRemoveContext. + * + * @return param2 + */ + public java.lang.String getParam2() { + return param2; + } + + + /** + * Sets the param2 value for this NotifyTodoRemoveContext. + * + * @param param2 + */ + public void setParam2(java.lang.String param2) { + this.param2 = param2; + } + + + /** + * Gets the targets value for this NotifyTodoRemoveContext. + * + * @return targets + */ + public java.lang.String getTargets() { + return targets; + } + + + /** + * Sets the targets value for this NotifyTodoRemoveContext. + * + * @param targets + */ + public void setTargets(java.lang.String targets) { + this.targets = targets; + } + + + /** + * Gets the type value for this NotifyTodoRemoveContext. + * + * @return type + */ + public int getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoRemoveContext. + * + * @param type + */ + public void setType(int type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoRemoveContext)) return false; + NotifyTodoRemoveContext other = (NotifyTodoRemoveContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.appName==null && other.getAppName()==null) || + (this.appName!=null && + this.appName.equals(other.getAppName()))) && + ((this.key==null && other.getKey()==null) || + (this.key!=null && + this.key.equals(other.getKey()))) && + ((this.modelId==null && other.getModelId()==null) || + (this.modelId!=null && + this.modelId.equals(other.getModelId()))) && + ((this.modelName==null && other.getModelName()==null) || + (this.modelName!=null && + this.modelName.equals(other.getModelName()))) && + ((this.optType==null && other.getOptType()==null) || + (this.optType!=null && + this.optType.equals(other.getOptType()))) && + ((this.others==null && other.getOthers()==null) || + (this.others!=null && + this.others.equals(other.getOthers()))) && + ((this.param1==null && other.getParam1()==null) || + (this.param1!=null && + this.param1.equals(other.getParam1()))) && + ((this.param2==null && other.getParam2()==null) || + (this.param2!=null && + this.param2.equals(other.getParam2()))) && + ((this.targets==null && other.getTargets()==null) || + (this.targets!=null && + this.targets.equals(other.getTargets()))) && + this.type == other.getType(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAppName() != null) { + _hashCode += getAppName().hashCode(); + } + if (getKey() != null) { + _hashCode += getKey().hashCode(); + } + if (getModelId() != null) { + _hashCode += getModelId().hashCode(); + } + if (getModelName() != null) { + _hashCode += getModelName().hashCode(); + } + if (getOptType() != null) { + _hashCode += getOptType().hashCode(); + } + if (getOthers() != null) { + _hashCode += getOthers().hashCode(); + } + if (getParam1() != null) { + _hashCode += getParam1().hashCode(); + } + if (getParam2() != null) { + _hashCode += getParam2().hashCode(); + } + if (getTargets() != null) { + _hashCode += getTargets().hashCode(); + } + _hashCode += getType(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoRemoveContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoRemoveContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("appName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "appName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("key"); + elemField.setXmlName(new javax.xml.namespace.QName("", "key")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("optType"); + elemField.setXmlName(new javax.xml.namespace.QName("", "optType")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("others"); + elemField.setXmlName(new javax.xml.namespace.QName("", "others")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param1")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param2"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param2")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("targets"); + elemField.setXmlName(new javax.xml.namespace.QName("", "targets")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoSendContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoSendContext.java new file mode 100644 index 0000000..ec2ac70 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoSendContext.java @@ -0,0 +1,749 @@ +/** + * NotifyTodoSendContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class NotifyTodoSendContext implements java.io.Serializable { + private java.lang.String appName; + + private java.lang.String createTime; + + private java.lang.String docCreator; + + private java.lang.String extendContent; + + private java.lang.String key; + + private java.lang.String language; + + private java.lang.Integer level; + + private java.lang.String link; + + private java.lang.String mobileLink; + + private java.lang.String modelId; + + private java.lang.String modelName; + + private java.lang.String others; + + private java.lang.String padLink; + + private java.lang.String param1; + + private java.lang.String param2; + + private java.lang.String subject; + + private java.lang.String targets; + + private java.lang.Integer type; + + public NotifyTodoSendContext() { + } + + public NotifyTodoSendContext( + java.lang.String appName, + java.lang.String createTime, + java.lang.String docCreator, + java.lang.String extendContent, + java.lang.String key, + java.lang.String language, + java.lang.Integer level, + java.lang.String link, + java.lang.String mobileLink, + java.lang.String modelId, + java.lang.String modelName, + java.lang.String others, + java.lang.String padLink, + java.lang.String param1, + java.lang.String param2, + java.lang.String subject, + java.lang.String targets, + java.lang.Integer type) { + this.appName = appName; + this.createTime = createTime; + this.docCreator = docCreator; + this.extendContent = extendContent; + this.key = key; + this.language = language; + this.level = level; + this.link = link; + this.mobileLink = mobileLink; + this.modelId = modelId; + this.modelName = modelName; + this.others = others; + this.padLink = padLink; + this.param1 = param1; + this.param2 = param2; + this.subject = subject; + this.targets = targets; + this.type = type; + } + + + /** + * Gets the appName value for this NotifyTodoSendContext. + * + * @return appName + */ + public java.lang.String getAppName() { + return appName; + } + + + /** + * Sets the appName value for this NotifyTodoSendContext. + * + * @param appName + */ + public void setAppName(java.lang.String appName) { + this.appName = appName; + } + + + /** + * Gets the createTime value for this NotifyTodoSendContext. + * + * @return createTime + */ + public java.lang.String getCreateTime() { + return createTime; + } + + + /** + * Sets the createTime value for this NotifyTodoSendContext. + * + * @param createTime + */ + public void setCreateTime(java.lang.String createTime) { + this.createTime = createTime; + } + + + /** + * Gets the docCreator value for this NotifyTodoSendContext. + * + * @return docCreator + */ + public java.lang.String getDocCreator() { + return docCreator; + } + + + /** + * Sets the docCreator value for this NotifyTodoSendContext. + * + * @param docCreator + */ + public void setDocCreator(java.lang.String docCreator) { + this.docCreator = docCreator; + } + + + /** + * Gets the extendContent value for this NotifyTodoSendContext. + * + * @return extendContent + */ + public java.lang.String getExtendContent() { + return extendContent; + } + + + /** + * Sets the extendContent value for this NotifyTodoSendContext. + * + * @param extendContent + */ + public void setExtendContent(java.lang.String extendContent) { + this.extendContent = extendContent; + } + + + /** + * Gets the key value for this NotifyTodoSendContext. + * + * @return key + */ + public java.lang.String getKey() { + return key; + } + + + /** + * Sets the key value for this NotifyTodoSendContext. + * + * @param key + */ + public void setKey(java.lang.String key) { + this.key = key; + } + + + /** + * Gets the language value for this NotifyTodoSendContext. + * + * @return language + */ + public java.lang.String getLanguage() { + return language; + } + + + /** + * Sets the language value for this NotifyTodoSendContext. + * + * @param language + */ + public void setLanguage(java.lang.String language) { + this.language = language; + } + + + /** + * Gets the level value for this NotifyTodoSendContext. + * + * @return level + */ + public java.lang.Integer getLevel() { + return level; + } + + + /** + * Sets the level value for this NotifyTodoSendContext. + * + * @param level + */ + public void setLevel(java.lang.Integer level) { + this.level = level; + } + + + /** + * Gets the link value for this NotifyTodoSendContext. + * + * @return link + */ + public java.lang.String getLink() { + return link; + } + + + /** + * Sets the link value for this NotifyTodoSendContext. + * + * @param link + */ + public void setLink(java.lang.String link) { + this.link = link; + } + + + /** + * Gets the mobileLink value for this NotifyTodoSendContext. + * + * @return mobileLink + */ + public java.lang.String getMobileLink() { + return mobileLink; + } + + + /** + * Sets the mobileLink value for this NotifyTodoSendContext. + * + * @param mobileLink + */ + public void setMobileLink(java.lang.String mobileLink) { + this.mobileLink = mobileLink; + } + + + /** + * Gets the modelId value for this NotifyTodoSendContext. + * + * @return modelId + */ + public java.lang.String getModelId() { + return modelId; + } + + + /** + * Sets the modelId value for this NotifyTodoSendContext. + * + * @param modelId + */ + public void setModelId(java.lang.String modelId) { + this.modelId = modelId; + } + + + /** + * Gets the modelName value for this NotifyTodoSendContext. + * + * @return modelName + */ + public java.lang.String getModelName() { + return modelName; + } + + + /** + * Sets the modelName value for this NotifyTodoSendContext. + * + * @param modelName + */ + public void setModelName(java.lang.String modelName) { + this.modelName = modelName; + } + + + /** + * Gets the others value for this NotifyTodoSendContext. + * + * @return others + */ + public java.lang.String getOthers() { + return others; + } + + + /** + * Sets the others value for this NotifyTodoSendContext. + * + * @param others + */ + public void setOthers(java.lang.String others) { + this.others = others; + } + + + /** + * Gets the padLink value for this NotifyTodoSendContext. + * + * @return padLink + */ + public java.lang.String getPadLink() { + return padLink; + } + + + /** + * Sets the padLink value for this NotifyTodoSendContext. + * + * @param padLink + */ + public void setPadLink(java.lang.String padLink) { + this.padLink = padLink; + } + + + /** + * Gets the param1 value for this NotifyTodoSendContext. + * + * @return param1 + */ + public java.lang.String getParam1() { + return param1; + } + + + /** + * Sets the param1 value for this NotifyTodoSendContext. + * + * @param param1 + */ + public void setParam1(java.lang.String param1) { + this.param1 = param1; + } + + + /** + * Gets the param2 value for this NotifyTodoSendContext. + * + * @return param2 + */ + public java.lang.String getParam2() { + return param2; + } + + + /** + * Sets the param2 value for this NotifyTodoSendContext. + * + * @param param2 + */ + public void setParam2(java.lang.String param2) { + this.param2 = param2; + } + + + /** + * Gets the subject value for this NotifyTodoSendContext. + * + * @return subject + */ + public java.lang.String getSubject() { + return subject; + } + + + /** + * Sets the subject value for this NotifyTodoSendContext. + * + * @param subject + */ + public void setSubject(java.lang.String subject) { + this.subject = subject; + } + + + /** + * Gets the targets value for this NotifyTodoSendContext. + * + * @return targets + */ + public java.lang.String getTargets() { + return targets; + } + + + /** + * Sets the targets value for this NotifyTodoSendContext. + * + * @param targets + */ + public void setTargets(java.lang.String targets) { + this.targets = targets; + } + + + /** + * Gets the type value for this NotifyTodoSendContext. + * + * @return type + */ + public java.lang.Integer getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoSendContext. + * + * @param type + */ + public void setType(java.lang.Integer type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoSendContext)) return false; + NotifyTodoSendContext other = (NotifyTodoSendContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.appName==null && other.getAppName()==null) || + (this.appName!=null && + this.appName.equals(other.getAppName()))) && + ((this.createTime==null && other.getCreateTime()==null) || + (this.createTime!=null && + this.createTime.equals(other.getCreateTime()))) && + ((this.docCreator==null && other.getDocCreator()==null) || + (this.docCreator!=null && + this.docCreator.equals(other.getDocCreator()))) && + ((this.extendContent==null && other.getExtendContent()==null) || + (this.extendContent!=null && + this.extendContent.equals(other.getExtendContent()))) && + ((this.key==null && other.getKey()==null) || + (this.key!=null && + this.key.equals(other.getKey()))) && + ((this.language==null && other.getLanguage()==null) || + (this.language!=null && + this.language.equals(other.getLanguage()))) && + ((this.level==null && other.getLevel()==null) || + (this.level!=null && + this.level.equals(other.getLevel()))) && + ((this.link==null && other.getLink()==null) || + (this.link!=null && + this.link.equals(other.getLink()))) && + ((this.mobileLink==null && other.getMobileLink()==null) || + (this.mobileLink!=null && + this.mobileLink.equals(other.getMobileLink()))) && + ((this.modelId==null && other.getModelId()==null) || + (this.modelId!=null && + this.modelId.equals(other.getModelId()))) && + ((this.modelName==null && other.getModelName()==null) || + (this.modelName!=null && + this.modelName.equals(other.getModelName()))) && + ((this.others==null && other.getOthers()==null) || + (this.others!=null && + this.others.equals(other.getOthers()))) && + ((this.padLink==null && other.getPadLink()==null) || + (this.padLink!=null && + this.padLink.equals(other.getPadLink()))) && + ((this.param1==null && other.getParam1()==null) || + (this.param1!=null && + this.param1.equals(other.getParam1()))) && + ((this.param2==null && other.getParam2()==null) || + (this.param2!=null && + this.param2.equals(other.getParam2()))) && + ((this.subject==null && other.getSubject()==null) || + (this.subject!=null && + this.subject.equals(other.getSubject()))) && + ((this.targets==null && other.getTargets()==null) || + (this.targets!=null && + this.targets.equals(other.getTargets()))) && + ((this.type==null && other.getType()==null) || + (this.type!=null && + this.type.equals(other.getType()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAppName() != null) { + _hashCode += getAppName().hashCode(); + } + if (getCreateTime() != null) { + _hashCode += getCreateTime().hashCode(); + } + if (getDocCreator() != null) { + _hashCode += getDocCreator().hashCode(); + } + if (getExtendContent() != null) { + _hashCode += getExtendContent().hashCode(); + } + if (getKey() != null) { + _hashCode += getKey().hashCode(); + } + if (getLanguage() != null) { + _hashCode += getLanguage().hashCode(); + } + if (getLevel() != null) { + _hashCode += getLevel().hashCode(); + } + if (getLink() != null) { + _hashCode += getLink().hashCode(); + } + if (getMobileLink() != null) { + _hashCode += getMobileLink().hashCode(); + } + if (getModelId() != null) { + _hashCode += getModelId().hashCode(); + } + if (getModelName() != null) { + _hashCode += getModelName().hashCode(); + } + if (getOthers() != null) { + _hashCode += getOthers().hashCode(); + } + if (getPadLink() != null) { + _hashCode += getPadLink().hashCode(); + } + if (getParam1() != null) { + _hashCode += getParam1().hashCode(); + } + if (getParam2() != null) { + _hashCode += getParam2().hashCode(); + } + if (getSubject() != null) { + _hashCode += getSubject().hashCode(); + } + if (getTargets() != null) { + _hashCode += getTargets().hashCode(); + } + if (getType() != null) { + _hashCode += getType().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoSendContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoSendContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("appName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "appName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("createTime"); + elemField.setXmlName(new javax.xml.namespace.QName("", "createTime")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("docCreator"); + elemField.setXmlName(new javax.xml.namespace.QName("", "docCreator")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("extendContent"); + elemField.setXmlName(new javax.xml.namespace.QName("", "extendContent")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("key"); + elemField.setXmlName(new javax.xml.namespace.QName("", "key")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("language"); + elemField.setXmlName(new javax.xml.namespace.QName("", "language")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("level"); + elemField.setXmlName(new javax.xml.namespace.QName("", "level")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("link"); + elemField.setXmlName(new javax.xml.namespace.QName("", "link")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("mobileLink"); + elemField.setXmlName(new javax.xml.namespace.QName("", "mobileLink")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("others"); + elemField.setXmlName(new javax.xml.namespace.QName("", "others")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("padLink"); + elemField.setXmlName(new javax.xml.namespace.QName("", "padLink")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param1")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param2"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param2")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("subject"); + elemField.setXmlName(new javax.xml.namespace.QName("", "subject")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("targets"); + elemField.setXmlName(new javax.xml.namespace.QName("", "targets")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoUpdateContext.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoUpdateContext.java new file mode 100644 index 0000000..2158835 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/NotifyTodoUpdateContext.java @@ -0,0 +1,670 @@ +/** + * NotifyTodoUpdateContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package com.api.taojw.liangxin.todo.todowebservice; + +public class NotifyTodoUpdateContext implements java.io.Serializable { + private java.lang.String appName; + + private java.lang.String createTime; + + private java.lang.String docCreator; + + private java.lang.String extendContent; + + private java.lang.String key; + + private java.lang.Integer level; + + private java.lang.String link; + + private java.lang.String mobileLink; + + private java.lang.String modelId; + + private java.lang.String modelName; + + private java.lang.String others; + + private java.lang.String padLink; + + private java.lang.String param1; + + private java.lang.String param2; + + private java.lang.String subject; + + private int type; + + public NotifyTodoUpdateContext() { + } + + public NotifyTodoUpdateContext( + java.lang.String appName, + java.lang.String createTime, + java.lang.String docCreator, + java.lang.String extendContent, + java.lang.String key, + java.lang.Integer level, + java.lang.String link, + java.lang.String mobileLink, + java.lang.String modelId, + java.lang.String modelName, + java.lang.String others, + java.lang.String padLink, + java.lang.String param1, + java.lang.String param2, + java.lang.String subject, + int type) { + this.appName = appName; + this.createTime = createTime; + this.docCreator = docCreator; + this.extendContent = extendContent; + this.key = key; + this.level = level; + this.link = link; + this.mobileLink = mobileLink; + this.modelId = modelId; + this.modelName = modelName; + this.others = others; + this.padLink = padLink; + this.param1 = param1; + this.param2 = param2; + this.subject = subject; + this.type = type; + } + + + /** + * Gets the appName value for this NotifyTodoUpdateContext. + * + * @return appName + */ + public java.lang.String getAppName() { + return appName; + } + + + /** + * Sets the appName value for this NotifyTodoUpdateContext. + * + * @param appName + */ + public void setAppName(java.lang.String appName) { + this.appName = appName; + } + + + /** + * Gets the createTime value for this NotifyTodoUpdateContext. + * + * @return createTime + */ + public java.lang.String getCreateTime() { + return createTime; + } + + + /** + * Sets the createTime value for this NotifyTodoUpdateContext. + * + * @param createTime + */ + public void setCreateTime(java.lang.String createTime) { + this.createTime = createTime; + } + + + /** + * Gets the docCreator value for this NotifyTodoUpdateContext. + * + * @return docCreator + */ + public java.lang.String getDocCreator() { + return docCreator; + } + + + /** + * Sets the docCreator value for this NotifyTodoUpdateContext. + * + * @param docCreator + */ + public void setDocCreator(java.lang.String docCreator) { + this.docCreator = docCreator; + } + + + /** + * Gets the extendContent value for this NotifyTodoUpdateContext. + * + * @return extendContent + */ + public java.lang.String getExtendContent() { + return extendContent; + } + + + /** + * Sets the extendContent value for this NotifyTodoUpdateContext. + * + * @param extendContent + */ + public void setExtendContent(java.lang.String extendContent) { + this.extendContent = extendContent; + } + + + /** + * Gets the key value for this NotifyTodoUpdateContext. + * + * @return key + */ + public java.lang.String getKey() { + return key; + } + + + /** + * Sets the key value for this NotifyTodoUpdateContext. + * + * @param key + */ + public void setKey(java.lang.String key) { + this.key = key; + } + + + /** + * Gets the level value for this NotifyTodoUpdateContext. + * + * @return level + */ + public java.lang.Integer getLevel() { + return level; + } + + + /** + * Sets the level value for this NotifyTodoUpdateContext. + * + * @param level + */ + public void setLevel(java.lang.Integer level) { + this.level = level; + } + + + /** + * Gets the link value for this NotifyTodoUpdateContext. + * + * @return link + */ + public java.lang.String getLink() { + return link; + } + + + /** + * Sets the link value for this NotifyTodoUpdateContext. + * + * @param link + */ + public void setLink(java.lang.String link) { + this.link = link; + } + + + /** + * Gets the mobileLink value for this NotifyTodoUpdateContext. + * + * @return mobileLink + */ + public java.lang.String getMobileLink() { + return mobileLink; + } + + + /** + * Sets the mobileLink value for this NotifyTodoUpdateContext. + * + * @param mobileLink + */ + public void setMobileLink(java.lang.String mobileLink) { + this.mobileLink = mobileLink; + } + + + /** + * Gets the modelId value for this NotifyTodoUpdateContext. + * + * @return modelId + */ + public java.lang.String getModelId() { + return modelId; + } + + + /** + * Sets the modelId value for this NotifyTodoUpdateContext. + * + * @param modelId + */ + public void setModelId(java.lang.String modelId) { + this.modelId = modelId; + } + + + /** + * Gets the modelName value for this NotifyTodoUpdateContext. + * + * @return modelName + */ + public java.lang.String getModelName() { + return modelName; + } + + + /** + * Sets the modelName value for this NotifyTodoUpdateContext. + * + * @param modelName + */ + public void setModelName(java.lang.String modelName) { + this.modelName = modelName; + } + + + /** + * Gets the others value for this NotifyTodoUpdateContext. + * + * @return others + */ + public java.lang.String getOthers() { + return others; + } + + + /** + * Sets the others value for this NotifyTodoUpdateContext. + * + * @param others + */ + public void setOthers(java.lang.String others) { + this.others = others; + } + + + /** + * Gets the padLink value for this NotifyTodoUpdateContext. + * + * @return padLink + */ + public java.lang.String getPadLink() { + return padLink; + } + + + /** + * Sets the padLink value for this NotifyTodoUpdateContext. + * + * @param padLink + */ + public void setPadLink(java.lang.String padLink) { + this.padLink = padLink; + } + + + /** + * Gets the param1 value for this NotifyTodoUpdateContext. + * + * @return param1 + */ + public java.lang.String getParam1() { + return param1; + } + + + /** + * Sets the param1 value for this NotifyTodoUpdateContext. + * + * @param param1 + */ + public void setParam1(java.lang.String param1) { + this.param1 = param1; + } + + + /** + * Gets the param2 value for this NotifyTodoUpdateContext. + * + * @return param2 + */ + public java.lang.String getParam2() { + return param2; + } + + + /** + * Sets the param2 value for this NotifyTodoUpdateContext. + * + * @param param2 + */ + public void setParam2(java.lang.String param2) { + this.param2 = param2; + } + + + /** + * Gets the subject value for this NotifyTodoUpdateContext. + * + * @return subject + */ + public java.lang.String getSubject() { + return subject; + } + + + /** + * Sets the subject value for this NotifyTodoUpdateContext. + * + * @param subject + */ + public void setSubject(java.lang.String subject) { + this.subject = subject; + } + + + /** + * Gets the type value for this NotifyTodoUpdateContext. + * + * @return type + */ + public int getType() { + return type; + } + + + /** + * Sets the type value for this NotifyTodoUpdateContext. + * + * @param type + */ + public void setType(int type) { + this.type = type; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof NotifyTodoUpdateContext)) return false; + NotifyTodoUpdateContext other = (NotifyTodoUpdateContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ((this.appName==null && other.getAppName()==null) || + (this.appName!=null && + this.appName.equals(other.getAppName()))) && + ((this.createTime==null && other.getCreateTime()==null) || + (this.createTime!=null && + this.createTime.equals(other.getCreateTime()))) && + ((this.docCreator==null && other.getDocCreator()==null) || + (this.docCreator!=null && + this.docCreator.equals(other.getDocCreator()))) && + ((this.extendContent==null && other.getExtendContent()==null) || + (this.extendContent!=null && + this.extendContent.equals(other.getExtendContent()))) && + ((this.key==null && other.getKey()==null) || + (this.key!=null && + this.key.equals(other.getKey()))) && + ((this.level==null && other.getLevel()==null) || + (this.level!=null && + this.level.equals(other.getLevel()))) && + ((this.link==null && other.getLink()==null) || + (this.link!=null && + this.link.equals(other.getLink()))) && + ((this.mobileLink==null && other.getMobileLink()==null) || + (this.mobileLink!=null && + this.mobileLink.equals(other.getMobileLink()))) && + ((this.modelId==null && other.getModelId()==null) || + (this.modelId!=null && + this.modelId.equals(other.getModelId()))) && + ((this.modelName==null && other.getModelName()==null) || + (this.modelName!=null && + this.modelName.equals(other.getModelName()))) && + ((this.others==null && other.getOthers()==null) || + (this.others!=null && + this.others.equals(other.getOthers()))) && + ((this.padLink==null && other.getPadLink()==null) || + (this.padLink!=null && + this.padLink.equals(other.getPadLink()))) && + ((this.param1==null && other.getParam1()==null) || + (this.param1!=null && + this.param1.equals(other.getParam1()))) && + ((this.param2==null && other.getParam2()==null) || + (this.param2!=null && + this.param2.equals(other.getParam2()))) && + ((this.subject==null && other.getSubject()==null) || + (this.subject!=null && + this.subject.equals(other.getSubject()))) && + this.type == other.getType(); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAppName() != null) { + _hashCode += getAppName().hashCode(); + } + if (getCreateTime() != null) { + _hashCode += getCreateTime().hashCode(); + } + if (getDocCreator() != null) { + _hashCode += getDocCreator().hashCode(); + } + if (getExtendContent() != null) { + _hashCode += getExtendContent().hashCode(); + } + if (getKey() != null) { + _hashCode += getKey().hashCode(); + } + if (getLevel() != null) { + _hashCode += getLevel().hashCode(); + } + if (getLink() != null) { + _hashCode += getLink().hashCode(); + } + if (getMobileLink() != null) { + _hashCode += getMobileLink().hashCode(); + } + if (getModelId() != null) { + _hashCode += getModelId().hashCode(); + } + if (getModelName() != null) { + _hashCode += getModelName().hashCode(); + } + if (getOthers() != null) { + _hashCode += getOthers().hashCode(); + } + if (getPadLink() != null) { + _hashCode += getPadLink().hashCode(); + } + if (getParam1() != null) { + _hashCode += getParam1().hashCode(); + } + if (getParam2() != null) { + _hashCode += getParam2().hashCode(); + } + if (getSubject() != null) { + _hashCode += getSubject().hashCode(); + } + _hashCode += getType(); + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(NotifyTodoUpdateContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "notifyTodoUpdateContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("appName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "appName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("createTime"); + elemField.setXmlName(new javax.xml.namespace.QName("", "createTime")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("docCreator"); + elemField.setXmlName(new javax.xml.namespace.QName("", "docCreator")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("extendContent"); + elemField.setXmlName(new javax.xml.namespace.QName("", "extendContent")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("key"); + elemField.setXmlName(new javax.xml.namespace.QName("", "key")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("level"); + elemField.setXmlName(new javax.xml.namespace.QName("", "level")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("link"); + elemField.setXmlName(new javax.xml.namespace.QName("", "link")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("mobileLink"); + elemField.setXmlName(new javax.xml.namespace.QName("", "mobileLink")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("modelName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "modelName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("others"); + elemField.setXmlName(new javax.xml.namespace.QName("", "others")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("padLink"); + elemField.setXmlName(new javax.xml.namespace.QName("", "padLink")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param1"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param1")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("param2"); + elemField.setXmlName(new javax.xml.namespace.QName("", "param2")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("subject"); + elemField.setXmlName(new javax.xml.namespace.QName("", "subject")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setMinOccurs(0); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("type"); + elemField.setXmlName(new javax.xml.namespace.QName("", "type")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/zsjtz/ZsjtzCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/zsjtz/ZsjtzCronJob.java new file mode 100644 index 0000000..4b5da0b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/zsjtz/ZsjtzCronJob.java @@ -0,0 +1,104 @@ +package com.api.taojw.liangxin.zsjtz; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 定时任务更新主数据台账中的数据 + * 从sap中间表中查找 项目编号在plm中间表创建日期为最新的一天的数据 且 sap中间表的sap编号不为空 的数据,将sap编号 + * 以及plm中间表的字段 同步到主数据台账中,用项目编号做主键 更新或插入; + */ +public class ZsjtzCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String sapTableName = ""; + private String plmTableName = ""; + private String mainTableName = ""; + + public String getSapTableName() { + return sapTableName; + } + + public void setSapTableName(String sapTableName) { + this.sapTableName = sapTableName; + } + + public String getPlmTableName() { + return plmTableName; + } + + public void setPlmTableName(String plmTableName) { + this.plmTableName = plmTableName; + } + + public String getMainTableName() { + return mainTableName; + } + + public void setMainTableName(String mainTableName) { + this.mainTableName = mainTableName; + } + + @Override + public void execute() { + try{ + logger.info("ZsjtzCronJob.execute begin"); + if(sapTableName == null || "".equals(sapTableName)){ + sapTableName = "uf_sapsjzjb"; + } + if(plmTableName == null || "".equals(plmTableName)){ + plmTableName = "uf_plmsjzjb"; + } + if(mainTableName == null || "".equals(mainTableName)){ + mainTableName = "uf_xmzsjtzb"; + } + RecordSet rs = new RecordSet(); + String getMaxDateSql = "select max(modedatacreatedate) as maxdate from " + plmTableName; + Map maxDateData = DaoUtil.getFirstData(rs, getMaxDateSql); + String maxDate = maxDateData.get("maxdate"); + maxDate = maxDate.substring(0,10); + logger.info("maxDate:" + maxDate); + String getDataSql = + "select " + + "t1.*,t2.sapbh as plmzsapbh " + + "from " + + plmTableName + " t1 " + + "inner join " + sapTableName + " t2 on t2.xmbh = t1.xmbh " + + "where " + + "substr(t1.modedatacreatedate,0,10) = ? " + + /*"substring(t1.modedatacreatedate,1,10) = ? " +*/ + "and t2.sapbh is not null " + + "and t2.BUKRS = ? "; + List> data = DaoUtil.getData(rs, getDataSql, maxDate,"1000"); + logger.info("data.size:" + data.size()); + String getIdSql = "select id from hrmresource where workcode = ?"; + for(Map m : data){ + JSONObject o = new JSONObject(); + o.put("spabh",m.get("plmzsapbh")); + o.put("sfwoaxtxjxm",m.get("plmzsapbh")); + o.put("xmmc",m.get("xmmc")); + o.put("xmbh",m.get("xmbh")); + o.put("xmkssj",m.get("xmksrq")); + o.put("xmlx",m.get("xmlx")); + o.put("xmgz",m.get("xmgz")); + o.put("xmzt",m.get("xmzt")); + o.put("xmjssj",m.get("xmjsrq")); + o.put("xmfzr", Util.null2String(DaoUtil.getFirstData(rs,getIdSql,m.get("xmfzr")).get("id"))); + TjwModelUtil.addOrUpdateModelData(rs,mainTableName,o,"xmbh"); + } + logger.info("ZsjtzCronJob.execute end"); + }catch(Exception e){ + logger.error("ZsjtzCronJob.execute exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/DoPrintAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/DoPrintAction.java new file mode 100644 index 0000000..65be46f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/DoPrintAction.java @@ -0,0 +1,122 @@ +package com.api.taojw.pyzl.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.pyzl.util.DoPrintUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 浦银租赁 + * action + * 打印 + */ +public class DoPrintAction implements Action { + + private String configId = ""; + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + private String columnName = ""; + + public String getColumnName() { + return columnName; + } + + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------requestId:" + requestId); + String[] baseInfo = WorkFlowDataToJsonUtil.getRequestBaseInfo(requestId,requestInfo.getRsTrans(),requestInfo.getRequestManager().getRemark(),requestInfo.getRequestManager().getBillTableName()); + JSONObject param = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,baseInfo); + + RecordSet rs = new RecordSet(); + String waterId = CommonSqlUtil.getSystemParamValue("waterQueueValue",rs); + String noWaterId = CommonSqlUtil.getSystemParamValue("noWaterQueueValue",rs); + String getFileInfoSql = "select " + columnName + ",sfjsy from " + requestInfo.getRequestManager().getBillTableName() + "_dt1 where sfxz = 0 and mainid = (select id from "+requestInfo.getRequestManager().getBillTableName()+" where requestid = ?)"; + List> data = DaoUtil.getData(rs, getFileInfoSql, requestId); + String message = ""; + JSONArray jobs = new JSONArray(); + for(Map firstData : data){ + String docIds = firstData.get(columnName.toLowerCase(Locale.ROOT)); + if(docIds == null || "".equals(docIds)){ + logger.info("docId is null"); + continue; + } + String sfjsy = firstData.get("sfjsy"); + if("0".equals(sfjsy)){ + param.put("printerQueue",waterId); + }else{ + param.put("printerQueue",noWaterId); + } + String[] docIdArr = docIds.split(","); + for(String docId:docIdArr){ + String getFileSql = "select imagefileid,imagefilename from docimagefile where docid = ? order by versionid desc"; + Map firstData1 = DaoUtil.getFirstData(rs, getFileSql, docId); + String imageFileId = firstData1.get("imagefileid"); + String imageFileName = firstData1.get("imagefilename"); + JSONObject jobSet = param.getJSONObject("jobSet"); + jobSet.put("docName",imageFileName); + param.put("jobSet",jobSet); + DoPrintUtil util = new DoPrintUtil(); + JSONObject sR = util.doPrint(param, imageFileId, imageFileName); + if(sR == null){ + JSONObject p = new JSONObject(); + p.put("jobs",jobs); + if(jobs.size() > 0){ + DoPrintUtil.cancelJob(p.toJSONString()); + } + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent(message+"文件:"+imageFileName+ ",打印失败!"); + return Action.FAILURE_AND_CONTINUE; + } + String s = sR.getString("flag"); + String rMessage = sR.getString("message"); + String jobId = sR.getString("jobId"); + if("SUCCESS".equals(s)){ + jobs.add(jobId); + }else{ + JSONObject p = new JSONObject(); + p.put("jobs",jobs); + if(jobs.size() > 0){ + DoPrintUtil.cancelJob(p.toJSONString()); + } + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent(message+"文件:"+imageFileName+ ",打印失败,信息:"+ rMessage); + return Action.FAILURE_AND_CONTINUE; + } + } + } + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/NccAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/NccAction.java new file mode 100644 index 0000000..47df07b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/NccAction.java @@ -0,0 +1,108 @@ +package com.api.taojw.pyzl.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.pyzl.util.NcUtil; +import nccloud.open.api.auto.token.cur.utils.APICurUtils; +import nccloud.open.api.auto.token.cur.utils.SHA256Util; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 浦银租赁NCC集成 + * action + * 流程数据转json 调用NCC接口 + * 需要jar包 OpenAPIUtil-1.0.1.jar + */ +public class NccAction implements Action { + + private String cusparam = ""; + + public String getCusparam() { + return cusparam; + } + + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------requestId:" + requestId); + + new Thread(){ + @Override + public void run(){ + RecordSet rs = new RecordSet(); + //step 1 ------------------------------------------------------流程数据转json + NcUtil ncUtil = new NcUtil(); + JSONObject jsonByWorkFlowData = ncUtil.execute(requestInfo,cusparam); + logger.info("NccAction.jsonByWorkFlowData done;jsonByWorkFlowData:" + jsonByWorkFlowData); + //step 2 ------------------------------------------------------调用NC token接口 + String NCC_IP = CommonSqlUtil.getSystemParamValue("nc_json_ip", rs); + String NCC_PORT = CommonSqlUtil.getSystemParamValue("nc_json_port", rs); + String NCC_BIZ_CENTER = CommonSqlUtil.getSystemParamValue("nc_json_biz_center", rs); + String NCC_CLIENT_ID = CommonSqlUtil.getSystemParamValue("nc_json_client_id", rs); + String NCC_CLIENT_SECRET = CommonSqlUtil.getSystemParamValue("nc_json_client_secret", rs); + String NCC_PUBKEY = CommonSqlUtil.getSystemParamValue("nc_json_pubKey", rs); + APICurUtils util = new APICurUtils(); + util.init(NCC_IP, NCC_PORT, NCC_BIZ_CENTER, NCC_CLIENT_ID, NCC_CLIENT_SECRET, NCC_PUBKEY, null, null); + logger.info("NccAction.token begin;NCC_IP:" + NCC_IP + ";NCC_PORT:" + NCC_PORT + ";NCC_BIZ_CENTER:" + NCC_BIZ_CENTER + ";NCC_CLIENT_ID:" + NCC_CLIENT_ID + ";NCC_CLIENT_SECRET:" + NCC_CLIENT_SECRET + ";NCC_PUBKEY:" + NCC_PUBKEY); + String tokenString = null; + try { + tokenString = util.getTokenByClient(); + } catch (Exception e) { + throw new RuntimeException(e); + } + logger.info("tokenString:"+tokenString); + JSONObject tokenJson = JSONObject.parseObject(tokenString); + String accessToken = tokenJson.getJSONObject("data").getString("access_token"); + logger.info("NccAction.token done;token:" + tokenString); + //step 3 ------------------------------------------------------调用NC 凭证接口 + String NCC_URL = CommonSqlUtil.getSystemParamValue("nc_json_url", rs); + String toSignString = NCC_CLIENT_ID+jsonByWorkFlowData.toJSONString(); + String sha256 = null; + try { + sha256 = SHA256Util.getSHA256(toSignString, NCC_PUBKEY); + } catch (Exception e) { + throw new RuntimeException(e); + } + Map headers = new HashMap<>(); + headers.put("access_token",accessToken); + headers.put("ucg_flag","Y"); + headers.put("signature",sha256); + headers.put("client_id",NCC_CLIENT_ID); + String a = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); + logger.info("here it is " + a); + Map post = TjwHttpUtil.sendHttpRequest(NCC_URL, jsonByWorkFlowData.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + logger.info("here it is " + a); + JSONObject responseData = JSONObject.parseObject((String) post.get("data")); + String success = responseData.getString("success"); + } + }.start(); + return Action.SUCCESS; + + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NccAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NccAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/NccActionBak.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/NccActionBak.java new file mode 100644 index 0000000..b32db69 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/action/NccActionBak.java @@ -0,0 +1,91 @@ +package com.api.taojw.pyzl.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.pyzl.util.NcUtil; +import nccloud.open.api.auto.token.cur.utils.APICurUtils; +import nccloud.open.api.auto.token.cur.utils.SHA256Util; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.HashMap; +import java.util.Map; + +/** + * 浦银租赁NCC集成 + * action + * 流程数据转json 调用NCC接口 + * 需要jar包 OpenAPIUtil-1.0.1.jar + */ +public class NccActionBak implements Action { + + private String cusparam = ""; + + public String getCusparam() { + return cusparam; + } + + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------requestId:" + requestId); + RecordSet rs = new RecordSet(); + //step 1 ------------------------------------------------------流程数据转json + NcUtil ncUtil = new NcUtil(); + JSONObject jsonByWorkFlowData = ncUtil.execute(requestInfo,cusparam); + logger.info("NccAction.jsonByWorkFlowData done;jsonByWorkFlowData:" + jsonByWorkFlowData); + //step 2 ------------------------------------------------------调用NC token接口 + String NCC_IP = CommonSqlUtil.getSystemParamValue("nc_json_ip", rs); + String NCC_PORT = CommonSqlUtil.getSystemParamValue("nc_json_port", rs); + String NCC_BIZ_CENTER = CommonSqlUtil.getSystemParamValue("nc_json_biz_center", rs); + String NCC_CLIENT_ID = CommonSqlUtil.getSystemParamValue("nc_json_client_id", rs); + String NCC_CLIENT_SECRET = CommonSqlUtil.getSystemParamValue("nc_json_client_secret", rs); + String NCC_PUBKEY = CommonSqlUtil.getSystemParamValue("nc_json_pubKey", rs); + APICurUtils util = new APICurUtils(); + util.init(NCC_IP, NCC_PORT, NCC_BIZ_CENTER, NCC_CLIENT_ID, NCC_CLIENT_SECRET, NCC_PUBKEY, null, null); + logger.info("NccAction.token begin;NCC_IP:" + NCC_IP + ";NCC_PORT:" + NCC_PORT + ";NCC_BIZ_CENTER:" + NCC_BIZ_CENTER + ";NCC_CLIENT_ID:" + NCC_CLIENT_ID + ";NCC_CLIENT_SECRET:" + NCC_CLIENT_SECRET + ";NCC_PUBKEY:" + NCC_PUBKEY); + String tokenString = util.getTokenByClient(); + logger.info("tokenString:"+tokenString); + JSONObject tokenJson = JSONObject.parseObject(tokenString); + String accessToken = tokenJson.getJSONObject("data").getString("access_token"); + logger.info("NccAction.token done;token:" + tokenString); + //step 3 ------------------------------------------------------调用NC 凭证接口 + String NCC_URL = CommonSqlUtil.getSystemParamValue("nc_json_url", rs); + String toSignString = NCC_CLIENT_ID+jsonByWorkFlowData.toJSONString(); + String sha256 = SHA256Util.getSHA256(toSignString, NCC_PUBKEY); + Map headers = new HashMap<>(); + headers.put("access_token",accessToken); + headers.put("ucg_flag","Y"); + headers.put("signature",sha256); + headers.put("client_id",NCC_CLIENT_ID); + Map post = TjwHttpUtil.sendHttpRequest(NCC_URL, jsonByWorkFlowData.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + JSONObject responseData = JSONObject.parseObject((String) post.get("data")); + String success = responseData.getString("success"); + if("true".equals(success)){ + return Action.SUCCESS; + } + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NccAction失败,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NccAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NccAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/api/NccApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/api/NccApi.java new file mode 100644 index 0000000..73c6f8b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/api/NccApi.java @@ -0,0 +1,114 @@ +package com.api.taojw.pyzl.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.pyzl.util.NcModeUtil; +import nccloud.open.api.auto.token.cur.utils.APICurUtils; +import nccloud.open.api.auto.token.cur.utils.SHA256Util; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * 浦银租赁NCC集成 + * action + * 流程数据转json 调用NCC接口 + * 需要jar包 OpenAPIUtil-1.0.1.jar + */ +@Path("/bogetjw") +public class NccApi { + + private String cusparam = ""; + + public String getCusparam() { + return cusparam; + } + + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/createBom") + @Produces(MediaType.APPLICATION_JSON) + public String createBom(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("----------------------" + this.getClass() + " NccApi begin"); + RecordSet rs = new RecordSet(); + String modeId = request.getParameter("modeId"); + String _dataId = request.getParameter("dataId"); + if("".equals(_dataId) || _dataId == null){ + return result.toJSONString(); + } + + String tableName = CommonSqlUtil.getTableNameByModeId(modeId,rs); + + String configId = request.getParameter("configId"); + String[] idArr = _dataId.split(","); + for(String dataId:idArr){ + //step 1 ------------------------------------------------------流程数据转json + NcModeUtil ncUtil = new NcModeUtil(); + JSONObject jsonByWorkFlowData = ncUtil.execute(modeId,dataId,configId); + logger.info("NccAction.jsonByWorkFlowData done;jsonByWorkFlowData:" + jsonByWorkFlowData); + //step 2 ------------------------------------------------------调用NC token接口 + String NCC_IP = CommonSqlUtil.getSystemParamValue("nc_json_ip", rs); + String NCC_PORT = CommonSqlUtil.getSystemParamValue("nc_json_port", rs); + String NCC_BIZ_CENTER = CommonSqlUtil.getSystemParamValue("nc_json_biz_center", rs); + String NCC_CLIENT_ID = CommonSqlUtil.getSystemParamValue("nc_json_client_id", rs); + String NCC_CLIENT_SECRET = CommonSqlUtil.getSystemParamValue("nc_json_client_secret", rs); + String NCC_PUBKEY = CommonSqlUtil.getSystemParamValue("nc_json_pubKey", rs); + APICurUtils util = new APICurUtils(); + util.init(NCC_IP, NCC_PORT, NCC_BIZ_CENTER, NCC_CLIENT_ID, NCC_CLIENT_SECRET, NCC_PUBKEY, null, null); + logger.info("NccAction.token begin;NCC_IP:" + NCC_IP + ";NCC_PORT:" + NCC_PORT + ";NCC_BIZ_CENTER:" + NCC_BIZ_CENTER + ";NCC_CLIENT_ID:" + NCC_CLIENT_ID + ";NCC_CLIENT_SECRET:" + NCC_CLIENT_SECRET + ";NCC_PUBKEY:" + NCC_PUBKEY); + String tokenString = util.getTokenByClient(); + logger.info("tokenString:"+tokenString); + JSONObject tokenJson = JSONObject.parseObject(tokenString); + String accessToken = tokenJson.getJSONObject("data").getString("access_token"); + logger.info("NccAction.token done;token:" + tokenString); + //step 3 ------------------------------------------------------调用NC 凭证接口 + String NCC_URL = CommonSqlUtil.getSystemParamValue("nc_json_url", rs); + String toSignString = NCC_CLIENT_ID+jsonByWorkFlowData.toJSONString(); + String sha256 = SHA256Util.getSHA256(toSignString, NCC_PUBKEY); + Map headers = new HashMap<>(); + headers.put("access_token",accessToken); + headers.put("ucg_flag","Y"); + headers.put("signature",sha256); + headers.put("client_id",NCC_CLIENT_ID); + Map post = TjwHttpUtil.sendHttpRequest(NCC_URL, jsonByWorkFlowData.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + JSONObject responseData = JSONObject.parseObject((String) post.get("data")); + String success = responseData.getString("success"); + if(!"true".equals(success)){ + String updateSql = "update " + tableName + " set dealresult = 2 where id = ?"; + DaoUtil.updateData(rs,updateSql,dataId); + result.put("flag","fail"); + return result.toJSONString(); + } + String updateSql = "update " + tableName + " set dealresult = 1 where id = ?"; + DaoUtil.updateData(rs,updateSql,dataId); + } + result.put("flag","success"); + return result.toJSONString(); + }catch(Throwable e){ + logger.error("NccApi error;message:" + e.getMessage()); + result.put("flag","fail"); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/DoPrintUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/DoPrintUtil.java new file mode 100644 index 0000000..3244fd2 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/DoPrintUtil.java @@ -0,0 +1,530 @@ +package com.api.taojw.pyzl.util; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.security.KeyManagementException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; + +import com.engine.integration.util.MyX509TrustManager; +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.config.ConnectionConfig; +import org.apache.http.config.SocketConfig; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.util.EntityUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import sun.misc.BASE64Encoder; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + + +@SuppressWarnings("deprecation") +public class DoPrintUtil { + private static RequestConfig requestConfig; + public static SSLConnectionSocketFactory sslsf; + + static Logger logger = MyLogger.getLogger(); + + static{ + SSLContext sslContext = null; + try { + sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + public boolean isTrusted(java.security.cert.X509Certificate[] arg0, String arg1) throws java.security.cert.CertificateException { + return true; + } + }).build(); + } catch (Throwable e) { + logger.error("sslContext init error;message:" + e.getMessage()); + } + sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); + requestConfig = RequestConfig.custom().setConnectTimeout(5000).setConnectionRequestTimeout(5000).setSocketTimeout(45000).build(); + } + + private static class PrintResponseBody implements Serializable{ + private static final long serialVersionUID = 1L; + public String result; + public String errMessage; + public String releaseCode; + public String expireTime; + public String jobId; + } + + private static class NotifyResponseBody implements Serializable{ + private static final long serialVersionUID = 1L; + public String result; + public String content; + public String contentId; + public String jobId; + public Date createTime;//for deleting no TCP response notify ,avoid memory leak + + } + + private static class MetaData implements Serializable{ + private static final long serialVersionUID = 1L; + public String loginAccount=""; + public String loginPassword=""; + public String loginDomain=""; + public String projectName = ""; + public String levelName = ""; + public String printerQueue=""; + public String releaseCodePrint; + public String callbackURL; + public JobSet jobSet=new JobSet(); + } + + private static class JobSet implements Serializable{ + private static final long serialVersionUID = 1L; + public String color=""; + public String copy=""; + public String duplex=""; + public String paperSize=""; + public String collate="1"; + public String range=""; + public String docName=""; + public String entireSheets=""; + public Finishing finishing; + public int pageCount; + + } + + private static class Finishing implements Serializable{ + private static final long serialVersionUID = 1L; + public String staple; + public String booklet; + public String fold; + public String hole; + public String holeNumber; + } + + public static JSONObject doPrint(JSONObject metaData,String imageFileId,String fileName){ + try{ + logger.info("doPrint end;metaData:" + metaData + ";imageFileId:" + imageFileId + ";fileName:" + fileName); + RecordSet rs = new RecordSet(); + String interfaceServerIP = CommonSqlUtil.getSystemParamValue("interfaceServerIP",rs); + String solutionKey = CommonSqlUtil.getSystemParamValue("solutionKey",rs); + ImageFileManager ifm = new ImageFileManager(); + InputStream in = ifm.getInputStreamById(Integer.parseInt(imageFileId)); + byte[] bytes = IOUtils.toByteArray(in); + //JSONObject result = uploadFile(solutionKey,interfaceServerIP,new String(fileName.getBytes(),"UTF-8"), new String(metaData.toString().getBytes(),"UTF-8"), bytes); + JSONObject result = uploadFile(solutionKey,interfaceServerIP,fileName, metaData.toString(), bytes,imageFileId); + logger.info("doPrint end;result:" + result); + return result; + }catch (Throwable e){ + logger.error("doPrint error;message:" + e.getMessage() + ";e:" + e); + return null; + } + } + + static HostnameVerifier ignoreHostnameVerifier = new HostnameVerifier() { + public boolean verify(String s, SSLSession sslsession) { + logger.info("WARNING: Hostname is not matched for cert."); + return true; + } + }; + + static TrustManager[] trustManagerArr = new TrustManager[]{new MyX509TrustManager()}; + + public static JSONObject cancelJob(String metaData){ + + RecordSet rs = new RecordSet(); + String url = CommonSqlUtil.getSystemParamValue("cancelJobUrl",rs); + String solutionKey = CommonSqlUtil.getSystemParamValue("solutionKey",rs); + String timestamp = String.valueOf(new Date().getTime()); + metaData = JSON.toJSON(metaData).toString(); + String signature = signUp(url,metaData, solutionKey, timestamp); + + Map headers = new HashMap<>(); + headers.put("sdkTimestamp",timestamp); + headers.put("sdkSignature",signature); + + Map post = TjwHttpUtil.sendHttpRequestWithCusLog(url, metaData, "POST", ContentType.APPLICATION_JSON, headers, null); + return null; + } + + public static JSONObject uploadFile(String solutionKey,String serverIP,String docName,String metaData,byte[] fileData,String imageFileId) throws UnsupportedEncodingException { + JSONObject result = new JSONObject(); + String contentType=null; + String res = ""; + HttpURLConnection conn = null; + String timestamp = String.valueOf(new Date().getTime()); + logger.info("old metaData:" + metaData); + metaData = JSON.toJSON(metaData).toString(); + BASE64Encoder encoder = new BASE64Encoder(); + String encode = encoder.encode(metaData.getBytes("UTF-8")); + metaData = encode; + String signature = signUp("/mobileproxy/web_upload",metaData, solutionKey, timestamp); + logger.info("end signUp;signature:" + signature); + CloseableHttpClient client =null; + String BOUNDARY = "---------------------------123821742118716"; + try { + SSLContext sslcontext = SSLContext.getInstance("SSL","SunJSSE"); + sslcontext.init(null, trustManagerArr, new java.security.SecureRandom()); + URL url = new URL("https://"+serverIP+"/mobileproxy/web_upload"); + logger.info("setDefaultHostnameVerifier begin"); + HttpsURLConnection.setDefaultHostnameVerifier(ignoreHostnameVerifier); + logger.info("setDefaultHostnameVerifier end"); + HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory()); + conn = (HttpURLConnection) url.openConnection(); + //conn.setRequestProperty("Accept-Charset", "utf-8"); + logger.info(Charset.defaultCharset()); + conn.setConnectTimeout(1000 * 60 * 5); + conn.setReadTimeout(60 * 1000 * 5); + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Charset","UTF-8"); + conn.setRequestProperty("sdkTimestamp", timestamp); + conn.setRequestProperty("sdkSignature", signature); + conn.setRequestProperty("Connection", "Keep-Alive"); + conn.setRequestProperty("paramType", "base64"); + conn.setRequestProperty("Content-Type","multipart/form-data; boundary=" + BOUNDARY); + + logger.info("DataOutputStream begin"); + OutputStream out = new DataOutputStream(conn.getOutputStream()); + logger.info("DataOutputStream end"); + // text + StringBuffer strBuf = new StringBuffer(); + strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n"); + strBuf.append("Content-Disposition: form-data; name=\"" + "metadata" + "\"\r\n\r\n"); + //strBuf.append(JSON.toJSON((new StringEntity(metaData,"UTF-8")).getContent())); + strBuf.append(metaData); + //strBuf.append(new String(JSON.toJSON(metaData).toString().getBytes(),"UTF-8")); + //out.write(strBuf.toString().getBytes()); + out.write(new String(strBuf.toString().getBytes(),"UTF-8").getBytes("utf-8")); + + if (contentType == null || "".equals(contentType)) { + contentType = "application/octet-stream"; + } + StringBuffer strBuf3 = new StringBuffer(); + strBuf3.append("\r\n").append("--").append(BOUNDARY).append("\r\n"); + //String encoderFileName = URLEncoder.encode(docName,"UTF-8"); + strBuf3.append("Content-Disposition: form-data; name=\"" + docName + "\"; filename=\"" + docName + "\"\r\n"); + strBuf3.append("Content-Type:" + contentType + "\r\n\r\n"); + out.write(new String(strBuf3.toString().getBytes(),"UTF-8").getBytes("utf-8")); + ByteArrayInputStream in = new ByteArrayInputStream(fileData); + int bytes = 0; + byte[] bufferOut = new byte[1024]; + while ((bytes = in.read(bufferOut)) != -1) { + out.write(bufferOut, 0, bytes); + } + in.close(); + + byte[] endData = ("\r\n--" + BOUNDARY + "--\r\n").getBytes(); + out.write(endData); + out.flush(); + out.close(); + StringBuffer strBuf2 = new StringBuffer(); + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8")); + String line = null; + while ((line = reader.readLine()) != null) { + strBuf2.append(line).append("\n"); + } + res = strBuf2.toString(); + reader.close(); + reader = null; + + + client = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + if(null==res) return null; + logger.info("res:" + res); + PrintResponseBody printResponseBody=JSONObject.parseObject(res,PrintResponseBody.class); + + logger.info("result:" + printResponseBody.result); + NotifyResponseBody notify=null; + if(printResponseBody.result.startsWith("OK")){ + for(int i=0;i<30;i++) { + try{ + Thread.sleep(2000); + }catch(Exception e){ + } + notify=getJobNotfiy(solutionKey,serverIP,printResponseBody.jobId,null); + if(null != notify && !notify.result.contains("WAIT")) { + break; + } + } + if(null==notify) { + result.put("flag","FAIL:Overtime"); + result.put("message","FAIL:Overtime"); + return result; + } + /*if(notify.result.equalsIgnoreCase("OK") && notify.content.contains("成功")) { + return "SUCCESS"; + }*/ + if(notify.result.equalsIgnoreCase("OK")) { + result.put("flag","SUCCESS"); + result.put("jobId",notify.jobId); + return result; + } + result.put("flag","fail"); + result.put("message",notify.content); + return result; + }else{ + result.put("flag","fail"); + result.put("message",printResponseBody.result); + return result; + } + }catch (Throwable e1) { + logger.error("uploadFile error;message:" + e1.getMessage() + ";e:" + e1); + } finally{ + try { + if(null!=client) client.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + + public static NotifyResponseBody getJobNotfiy(String solutionKey,String serverIP,String jobId,CloseableHttpClient clients) throws NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException, IOException { + + logger.info("begin getJobNotfiy;"); + InputStream is = null; + String timestamp = String.valueOf(new Date().getTime()); + HttpPost post = new HttpPost("https://"+serverIP+"/mobileproxy/getjobnotify"); + try{ + JSONObject jsonParam=new JSONObject(); + jsonParam.put("jobId",jobId); + + post.setConfig(requestConfig); + post.addHeader("Connection", "close"); + post.addHeader("Content-Type", "application/json;charset=utf-8"); + String signature = signUp("/mobileproxy/getjobnotify",jsonParam.toJSONString(), solutionKey, timestamp); + post.addHeader("sdkTimestamp", timestamp); + post.addHeader("sdkSignature", signature); + StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8"); + entity.setContentEncoding("UTF-8"); + entity.setContentType("application/json"); + post.setEntity(entity); + //HttpResponse response = client.execute(post); + //String result = EntityUtils.toString(response.getEntity(), "utf-8"); + Map headers = new HashMap<>(); + headers.put("sdkTimestamp",timestamp); + headers.put("sdkSignature",signature); + headers.put("Content-Type","application/json;charset=utf-8"); + Map post1 = TjwHttpUtil.sendHttpRequest("https://" + serverIP + "/mobileproxy/getjobnotify", jsonParam.toString(), "POST", ContentType.APPLICATION_JSON, headers); + String result = (String) post1.get("data"); + + logger.info("end getJobNotfiy;result:" + result); + return JSON.parseObject(result,NotifyResponseBody.class); + }catch(Throwable e){ + logger.error("getJobNotfiy error;message:" + e.getMessage() + ";e:" + e); + return null; + }finally{ + if(null != is){ + try { + is.close(); + } catch (Exception e) { + } + } + try { + post.releaseConnection(); + } catch (Exception e) { + } + } + } + + public static String getResponseString(CloseableHttpResponse response) { + if(null == response){ + return ""; + } + try { + String result = ""; + InputStream in = response.getEntity().getContent(); + BufferedReader reader = new BufferedReader(new InputStreamReader(in,"UTF-8")); + StringBuffer buffer = new StringBuffer(); + String line = ""; + while ((line = reader.readLine()) != null){ + buffer.append(line); + } + result = buffer.toString(); + return result; + } catch (Exception e) { + return ""; + } finally { + try { + response.close(); + } catch (IOException e) { + } + } + } + + public static boolean isBlank(String content){ + if(content == null || content.trim().length() == 0){ + return true; + }else{ + return false; + } + } + + public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException { + String data = "/mobileproxy/web_upload{\"loginDomain\":\"Sysprint_Oauth\",\"loginAccount\":\"wujm\",\"jobSet\":{\"docName\":\"测试1.docx\",\"color\":\"Mono\",\"duplex\":\"1\",\"copy\":\"1\",\"paperSize\":\"A4\"},\"printerQueue\":\"908900026\"}sqa3swc4tavgd6psb6ag1685697226143"; + logger.info("begin signUp;data:" + data); + MessageDigest md = MessageDigest.getInstance("SHA1"); + byte[] signature = md.digest(new String(data.getBytes("GBK"),"UTF-8").getBytes("UTF-8")); + //byte[] signature = md.digest(data.getBytes("GBK")); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < signature.length; offset++) { + i = signature[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + System.out.println(buf); + } + + + + + + public static String signUp(String url, String param,String solutionKey,String timestamp) { + try{ + String data = url + param + solutionKey + timestamp; + logger.info("begin signUp;data:" + data); + MessageDigest md = MessageDigest.getInstance("SHA1"); + byte[] signature = md.digest(new String(data.getBytes("GBK"),"UTF-8").getBytes("UTF-8")); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < signature.length; offset++) { + i = signature[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + return buf.toString(); + }catch (Throwable e){ + logger.error("signup error;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + public static String signUpBak(String url, String param, String solutionkey,String timestamp) { + try{ + InputStream in = (new StringEntity(param, "UTF-8")).getContent(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = -1; + while ((len = in.read(buffer)) != -1) { + baos.write(buffer, 0, len); + } + baos.close(); + in.close(); + byte[] lens = baos.toByteArray(); + String result = new String(lens,"UTF-8"); + param = result; + + }catch(Throwable e){ + logger.error("signUp error;message:" + e.getMessage() + ";e:" + e); + } + + String data = url + param + solutionkey + timestamp; + logger.info("begin signUp;data:" + data); + try { + MessageDigest md = MessageDigest.getInstance("SHA1"); + byte[] signature = md.digest(data.getBytes("utf-8")); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < signature.length; offset++) { + i = signature[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + return buf.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (Throwable e) { + e.printStackTrace(); + } + /*String fa = CommonSqlUtil.getSystemParamValue("fangan",new RecordSet()); + if("1".equals(fa)){ + signature = md.digest(data.getBytes()); + } + if("2".equals(fa)){ + String tmp = new String(data.getBytes(),"UTF-8"); + signature = md.digest(tmp.getBytes("UTF-8")); + }*/ + return ""; + } + + public static byte[] toByteArray(String filename) throws IOException { + File f = new File(filename); + if (!f.exists()) { + throw new FileNotFoundException(filename); + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + BufferedInputStream in = null; + try { + in = new BufferedInputStream(new FileInputStream(f)); + int buf_size = 1024; + byte[] buffer = new byte[buf_size]; + int len = 0; + while (-1 != (len = in.read(buffer, 0, buf_size))) { + bos.write(buffer, 0, len); + } + return bos.toByteArray(); + } catch (IOException e) { + throw e; + } finally { + try { + if (in != null) + in.close(); + } catch (IOException e) { + throw e; + } + bos.close(); + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/NcModeUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/NcModeUtil.java new file mode 100644 index 0000000..b14dd42 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/NcModeUtil.java @@ -0,0 +1,966 @@ +package com.api.taojw.pyzl.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.xml.sax.InputSource; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.StringReader; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class NcModeUtil { + + Logger logger = MyLogger.getLogger(); + private int CONNECT_TIMEOUT = 1800000;//请求超时时间 + + private String voucher_keyid = "";//单据主键(生成规则,年份+时间戳) + + //ITEM中辅助核算项配置 + private List> detail_item_ass_list = new ArrayList>(); + //借方金额Map<借方对应的贷方XML名称,金额值> + private Map debitamount_map = new HashMap(); + //ITEM中现金流量字段配置(普通借方) + private List> detail_item_cas_list = new ArrayList>(); + //ITEM中现金流量字段配置(税额借方) + private List> tax_item_cas_list = new ArrayList>(); + //明细分录序号 + private int rownum = 0; + + private String cusparam = "";//自定义参数 + + private DecimalFormat df = new DecimalFormat("#####################0.00"); + + /** + * 实现父类方法 + * @return + */ + public JSONObject execute(String modeId,String dataId,String configId){ + JSONObject result = new JSONObject(); + rownum = 0; + + debitamount_map.clear(); + detail_item_ass_list.clear(); + detail_item_cas_list.clear(); + tax_item_cas_list.clear(); + + + logger.info("-------------------------WorkflowDataToNC_Action Begin-------------------------cusparam:"+cusparam); + String billid = dataId; + //获取流程类型ID + //String workflowid = Util.null2String(requestInfo.getWorkflowid()); + //logger.info("workflowid:" + workflowid); + //获取流程请求ID + //String this_requestid = Util.null2String(requestInfo.getRequestid()); + //获取流程表单ID + String getFormIdSql = "select * from modeinfo where id = ?"; + RecordSet rs = new RecordSet(); + Map firstData = DaoUtil.getFirstData(rs, getFormIdSql, modeId); + + int formid = Util.getIntValue(firstData.get("formid"),-1); + + + //获取当前流程配置信息 + String select_main_config_sql = "select * from uf_voucher_mode_inf where id = ?"; + + + + logger.info("select_main_config_sql:" + select_main_config_sql); + + //配置表主表主键 + int config_main_key = -1; + //组织代码字段 + String orgcode_fieldname = ""; + //控制条件 + String condition = ""; + //明细表序列 + int detailindex = -1; + //是否有现金流量 + int hascash = 1; + + if(rs.executeQuery(select_main_config_sql,configId)){ + if(rs.next()){ + config_main_key = Util.getIntValue(rs.getString("id"),0); + + orgcode_fieldname = Util.null2String(rs.getString("orgcode_fieldname")); + + condition = Util.null2String(rs.getString("condition")); + + detailindex = Util.getIntValue(rs.getString("detailindex"),0); + + hascash = Util.getIntValue(rs.getString("hascash"),0); + } + } + + logger.info("配置主表主键值:[" + config_main_key + "]"); + + //凭证头字段配置 + List> voucher_head_list = new ArrayList>(); + //凭证Item字段配置(普通借方) + List> debit_detail_item_list = new ArrayList>(); + //凭证Item字段配置(税额借方) + List> tax_detail_item_list = new ArrayList>(); + + + //凭证Item字段配置(差旅税额借方) + List> trip_tax_detail_item_list = new ArrayList>(); + + //凭证Item字段配置(贷方) + List> credit_detail_item_list = new ArrayList>(); + + + if(config_main_key > 0) {//说明该流程存在配置 + //获取当前流程明细字段配置信息 + String select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_mode_inf_dt1 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //XML节点名称 + String xmlfield = Util.null2String(rs.getString("xmlfield")); + //XML节点所属 + int xmlbelongto = Util.getIntValue(rs.getString("xmlbelongto"),0); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + //特殊属性 + int special_attribute = Util.getIntValue(rs.getString("special_attribute"),0); + //相对应的贷方XML节点名称 + String counterxml = Util.null2String(rs.getString("counterXML")); + //分录类型 + int itemType = Util.getIntValue(rs.getString("itemType"),0); + //是否金额校验字段 + int isvalidate = Util.getIntValue(rs.getString("isvalidate"),0); + + if(!"".equals(xmlfield)){ + Map detail_map = new HashMap(); + + detail_map.put("xmlfield",xmlfield); + detail_map.put("xmlbelongto",xmlbelongto); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + detail_map.put("special_attribute",special_attribute); + detail_map.put("counterxml",counterxml); + detail_map.put("isvalidate",isvalidate); + detail_map.put("itemType",itemType); + + if(xmlbelongto == 0) {//凭证头字段配置集合 + voucher_head_list.add(detail_map); + }else{//明细分录字段配置 + if(xmlbelongto != 2){//details-item 明细凭证 + if(itemType == 1){//税额借方 + tax_detail_item_list.add(detail_map); + }else if(itemType == 2){//贷方 + credit_detail_item_list.add(detail_map); + }else if(itemType == 0){//普通借方 + debit_detail_item_list.add(detail_map); + }else if(itemType == 3){//差旅税额借方 + trip_tax_detail_item_list.add(detail_map); + } + }else{//cashFlow-item 现金流量 +// if(itemType == 1){//税额借方 +// tax_item_cas_list.add(detail_map); +// }else{//普通借方 + detail_item_cas_list.add(detail_map); +// } + } + } + } + } + } + + //获取辅助核算项的配置信息 + select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_mode_inf_dt2 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //辅助核算项类型(0:个人1:部门) + int checktype = Util.getIntValue(rs.getString("checktype"),0); + //辅助核算项类型编码 + String typecode = Util.null2String(rs.getString("typecode")); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + + + Map detail_map = new HashMap(); + + detail_map.put("checktype",checktype); + detail_map.put("typecode",typecode); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + + detail_item_ass_list.add(detail_map); + + } + } + } + + RecordSet rs_main = new RecordSet(); + + //流程主表主键 + int workflow_main_key = 0; + //组织代码字段值 + String orgcode_fieldvalue = ""; + + //获取流程主表信息 + String table = CommonSqlUtil.getTableNameByModeId(modeId,rs); + String select_workflow_main = "select * from " + table + " where id=? "; + + if(!"".equals(condition)){ + select_workflow_main += condition; + } + + logger.info("查询流程主表数据:[" + select_workflow_main + "],[" + dataId + "]"); + + if(rs_main.executeQuery(select_workflow_main,dataId)){ + + if(rs_main.next()) { + + workflow_main_key = Util.getIntValue(rs_main.getString("id"), 0); + + orgcode_fieldvalue = Util.null2String(rs_main.getString(orgcode_fieldname)); + }else{//若数据不存在,则直接跳过 + + logger.info("-------------------------WorkflowDataToNC_Action(未传凭证) End-------------------------"); + return result; + } + } + + StringBuffer sendxml = new StringBuffer(); + + sendxml.append(""); + sendxml.append(""); + + long timestamp = System.currentTimeMillis() / 10; + + //获取当前日期 + String currentday = TimeUtil.getCurrentDateString(); + //获取当前年份(后两位) + String year = currentday.substring(2,4); + + voucher_keyid = year + timestamp; + + sendxml.append(""); + + sendxml.append(""); + + //获取Header字段配置 + if(voucher_head_list != null && voucher_head_list.size() > 0){ + for(Map detail_map : voucher_head_list){ + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + + if("".equals(xmlfield)){//若XML节点名称为空,则直接跳过 + continue; + } + + //判断OA字段来源 + int viewtype = Util.getIntValue(detail_map.get("viewtype").toString(),0); + + if(viewtype > 0){//说明配置的字段来自明细表,则该字段配置有误,直接跳过 + logger.info("--Error-->字段【" + xmlfield + "】配置有误,请检查!"); + continue; + } + + String fieldval = getFieldValue(detail_map,rs_main,null,new String[]{"","","",""},billid); + result.put(xmlfield,fieldval); + sendxml.append("<").append(xmlfield).append(">"); + sendxml.append(fieldval); + sendxml.append(""); + } + } + + if(debit_detail_item_list != null && debit_detail_item_list.size() > 0){ + JSONArray details = new JSONArray(); + result.put("detail",details); + sendxml.append("
"); + if(detailindex > 0 && workflow_main_key > 0){ + + RecordSet rs_detail = new RecordSet(); + String select_workflow_detail = "select * from formtable_main_" + Math.abs(formid) + "_dt1 where mainid = ? "; + + if(rs_detail.executeQuery(select_workflow_detail,workflow_main_key)){ + + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,rs_detail,new String[]{"","","",""},hascash,details,billid); + + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,rs_detail,new String[]{"","","",""},hascash,details,billid); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + logger.info("差旅税额借方分录XML begin;"); + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,rs_detail,new String[]{"","","",""},hascash,details,billid); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + logger.info("普通贷方分录 begin;rownum:" + rownum); + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info("getFieldValue begin;"); + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,new String[]{"","","",""},billid); + logger.info("getFieldValue end"); + if(special_attribute == 1){//辅助核算项字段 + + if(!"".equals(fieldval) && detail_item_ass_list != null){ + logger.info("getAssistingAccountItemInfo begin"); + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,rs_detail,new String[]{"","","",""},credit_ass_xml_jsonArray,billid); + logger.info("getAssistingAccountItemInfo end"); + } + }else if (special_attribute == 3) {//贷方金额(合计) + logger.info("贷方金额(合计) begin"); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + logger.info("贷方金额(合计) end"); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + logger.info("here"); + //获取现金流量信息 + /* + String credit_cash_flow_xml = ""; + credit_cash_flow_xml += ""; + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + String fieldval = df.format(amount_sum); + + credit_cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + } + credit_cash_flow_xml += ""; + */ + + credit_item_xml.append(""); + // + credit_item_xml_json.put("detailindex",++rownum); + credit_item_xml.append("").append(rownum).append(""); + + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + + }else{//说明字段都来自主表 + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,null,new String[]{"","","",""},hascash,details,billid); + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,null,new String[]{"","","",""},hascash,details,billid); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,null,new String[]{"","","",""},hascash,details,billid); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info(""); + String fieldval = getFieldValue(detail_map, rs_main, null,new String[]{"","","",""},billid); + + if(special_attribute == 1){//辅助核算项字段 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,null,new String[]{"","","",""},credit_ass_xml_jsonArray,billid); + } + }else if (special_attribute == 3) {//贷方金额(合计) + double amount_sum = 0.0; + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + + credit_item_xml.append(""); + // + credit_item_xml.append("").append(++rownum).append(""); + credit_item_xml_json.put("detailindex",rownum); + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + sendxml.append("
"); + } + sendxml.append("
"); + sendxml.append("
"); + sendxml.append("
"); + + logger.info("发送的XML格式为:【" + sendxml.toString() + "】"); + logger.info("result json:" + result.toJSONString()); + logger.info("-------------------------WorkflowDataToNC_Action End-------------------------"); + return result; + } + + /** + * 解析XML字符串 + * @param xml + * @return + */ + @SuppressWarnings("unchecked") + public Map analysisXML(String xml){ + Map resultMap = new HashMap(); + try{ + //创建一个新的字符串 + StringReader read = new StringReader(xml); + //创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入 + InputSource source = new InputSource(read); + //创建一个新的SAXBuilder + SAXBuilder sb = new SAXBuilder(); + //通过输入源构造一个Document + Document doc = sb.build(source); + //取根元素 + Element root = doc.getRootElement(); + //获取ufinterface根节点中的子节点 + List child = root.getChildren(); + //获取ufinterface根节点中第一个子节点 sendresult + Element first_child = (Element)child.get(0); + + //获取formdata根节点中的子节点 + List first_child_grands = first_child.getChildren(); + for(int i = 0 ; i < first_child_grands.size();i++){ + Element leave = (Element)first_child_grands.get(i); + + resultMap.put(leave.getName(), leave.getText()); + //System.err.println("--------" + i + "--->" + leave.getText() + "/" + leave.getName()); + } + }catch (Exception e) { + // TODO: handle exception + logger.info("解析XML字符串异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } + + return resultMap; + } + + /** + * 生成借方分录XML + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @return + */ + private StringBuffer generate_debit_item_xml(int itemType, int itemDirection, List> detail_field_list, RecordSet rs_main, RecordSet rs_detail, String[] baseArray, int hascash, JSONArray details,String billid){ + StringBuffer debit_item_xml = new StringBuffer(""); + + if(rs_detail != null){ + while(rs_detail.next()){ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, rs_detail, baseArray, debit_item_xml,hascash,details,billid); + } + }else{ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, null, baseArray, debit_item_xml,hascash,details,billid); + } + + return debit_item_xml; + } + + /** + * + * @param itemDirection + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @param baseArray + * @param debit_item_xml + * @param hascash + */ + private void generate_debitItem_Only_xml(int itemType,int itemDirection, List> detail_field_list, + RecordSet rs_main, RecordSet rs_detail, String[] baseArray, StringBuffer debit_item_xml,int hascash,JSONArray details,String billid) { + //循环明细表记录,对借方分录进行拼接 + StringBuffer inner_xml = new StringBuffer(); + JSONObject inner_xml_json = new JSONObject(); + //辅助核算项配置 + String ass_xml = ""; + JSONArray ass_xml_jsonArray = new JSONArray(); + //该行明细是否需要生成会计分录 + boolean isValidate_Success = true; + + for(Map detail_map : detail_field_list){ + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(),0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String counterxml = Util.null2String(detail_map.get("counterxml").toString()); + String fieldval = getFieldValue(detail_map,rs_main,rs_detail,baseArray,billid); + + int isvalidate = Util.getIntValue(detail_map.get("isvalidate").toString(),0); + //借方分录金额合计值 + double amount_sum = 0.0; + + if(special_attribute == 1){//辅助核算项字段 + //获取该科目类型对应的辅助核算项有哪些 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + ass_xml = getAssistingAccountItemInfo(itemDirection,fieldval,rs_main,rs_detail,baseArray,ass_xml_jsonArray,billid); + } + }else if(special_attribute == 2){//借方金额(合计) + amount_sum = Util.getDoubleValue(fieldval,0.0); + + if (isvalidate == 1 && amount_sum == 0){//表示该字段为金额校验字段,若为空,则改行不需要生成分录 + isValidate_Success = false; + break; + } + + if(!"".equals(counterxml)){//对应的贷方XML字段名称 + if(debitamount_map.containsKey(counterxml)){//判断该字段对应的贷方XML是否存在 + double old_debitamount = debitamount_map.get(counterxml); + + double new_debitamount = amount_sum + old_debitamount; + + debitamount_map.put(counterxml,new_debitamount); + }else{ + debitamount_map.put(counterxml, amount_sum); + } + } + + fieldval = df.format(amount_sum); + }else if(special_attribute == 3){//贷方金额(合计) + fieldval = "0.00"; + } + + inner_xml.append("<").append(xmlfield).append(">"); + inner_xml.append(fieldval); + inner_xml.append(""); + inner_xml_json.put(xmlfield,fieldval); + } + + if(isValidate_Success) { + //获取现金流量信息 + JSONObject cash_flow_xml_json = new JSONObject(); + String cash_flow_xml = ""; + cash_flow_xml += ""; + +// List> cash_list = null;//new ArrayList>(); + +// if(itemDirection == 1){//税额借方 +// cash_list = tax_item_cas_list; +// }else{//普通借方 +// cash_list = detail_item_cas_list; +// } + + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String fieldname = Util.null2String(detail_map.get("fieldname").toString()); + int rowitemType = (Integer)detail_map.get("itemType"); + + logger.info("rowitemType:[" + rowitemType + "],xmlfield:[" + xmlfield + "],fieldname:[" + fieldname + "],itemType:[" + itemType + "]"); + + if(itemType != rowitemType){ + continue; + } + + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,baseArray,billid); + + logger.info("fieldval:[" + fieldval + "]"); + + cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + cash_flow_xml_json.put(xmlfield,fieldval); + } + cash_flow_xml += ""; + + JSONObject debit_item_xml_json = new JSONObject(); + + + debit_item_xml.append(""); + debit_item_xml_json.put("detailindex",++rownum); + // + debit_item_xml.append("").append(rownum).append(""); + //普通字段 + debit_item_xml.append(inner_xml.toString()); + debit_item_xml_json.putAll(inner_xml_json); + + //辅助核算项 + debit_item_xml.append(""); + debit_item_xml.append(ass_xml); + debit_item_xml.append(""); + + debit_item_xml_json.put("ass",ass_xml_jsonArray); + + + if(hascash == 1){ + //现金流量 + debit_item_xml.append(""); + debit_item_xml.append(cash_flow_xml); + debit_item_xml.append(""); + + JSONArray cashFlow = new JSONArray(); + cashFlow.add(cash_flow_xml_json); + debit_item_xml_json.put("cashflow",cashFlow); + } + + debit_item_xml.append(""); + details.add(debit_item_xml_json); + } + } + + /** + * 获取借方分录【科目】/贷方【公司银行】的辅助核算项配置 + * @param itemDirection 分录方向 [0-借方分录(普通) 、1-借方分录(税额) 、2-贷方分录] + * @param subjectid 科目主键 + * @param rs_main 流程主表查询结果数据集 + * @param rs_detail 当前行明细表查询结果数据集 + * @return String 科目辅助核算项的XML + */ + private String getAssistingAccountItemInfo(int itemDirection,String subjectid,RecordSet rs_main,RecordSet rs_detail,String[] baseArray,JSONArray ass_xml_jsonArray,String billid){ + String select_sql = ""; + RecordSet rs = new RecordSet(); + + String ass_xml = ""; + + //辅助核算项类型(0 : 部门 1-部门+人员 2:人员) + int checkType = 0; + + + if(itemDirection == 0){//若为普通的借方分录,则根据科目,获取该科目应该对应的辅助核算项类型 + select_sql = "select * from uf_kmjbxx where kembm = ?"; + + if(rs.executeQuery(select_sql,subjectid)){ + rs.next(); + + checkType = Util.getIntValue(rs.getString("fuzhslx"),0); + } + } + + for(Map detail_map : detail_item_ass_list){//循环辅助核算项字段配置信息 + int row_checktype = Util.getIntValue(detail_map.get("checktype").toString(),0); + + String typecode = Util.null2String(detail_map.get("typecode").toString()); + String fieldvalue = getFieldValue(detail_map,rs_main,rs_detail,baseArray,billid); + + if(itemDirection == 0){ + logger.info("--------------普通借方辅助核算项 Begin--------------------"); + + logger.info("checkType:[" + checkType + "],row_checktype:[" + row_checktype + "],typecode:[" + typecode + "],fieldvalue:[" + fieldvalue + "]"); + + logger.info("--------------普通借方辅助核算项 End--------------------"); + } + + if(itemDirection == 0) {//普通借方分录 + if ((checkType == 0 && row_checktype == 0) || row_checktype == 2 || row_checktype == 3) {//该科目辅助核算项只有部门,而配置中出现人员(或者辅助核算类型为税额、银行存款的也跳过),则人员配置跳过 + continue; + } + }else if(itemDirection == 1 && row_checktype != 2){//税额借方分录 + continue; + }else if(itemDirection == 2 && row_checktype != 3){//贷方分录 + continue; + } + + /* + String checkType_val = ""; + + if(row_checktype == 0){//人员 + checkType_val = "0002"; + }else{//部门 + checkType_val = "0001"; + } + */ + ass_xml += ""; + ass_xml += "" + typecode + ""; + ass_xml += "" + fieldvalue + ""; + ass_xml += ""; + JSONObject o = new JSONObject(); + o.put("checktypecode",typecode); + o.put("checkvaluecode",fieldvalue); + ass_xml_jsonArray.add(o); + } + + return ass_xml; + } + + /** + * 获取字段值 + * @param configMap + * @param rs + * @param rs_detail + * @return + */ + private String getFieldValue(Map configMap,RecordSet rs,RecordSet rs_detail,String[] baseArray,String billid){ + //流程字段名称 + String wffieldname = Util.null2String(configMap.get("fieldname").toString()); + //转换规则 + int changerule = Util.getIntValue(configMap.get("changerule").toString(),0); + //自定义规则 + String cussql = Util.null2String(configMap.get("cussql").toString()); + + //流程字段所属 + int viewtype = Util.getIntValue(configMap.get("viewtype").toString(),0); + + logger.info("wffieldname:" + wffieldname + ";changerule:" + changerule + ";cussql:" + cussql + ";viewtype:" + viewtype); + + //流程字段值 + String wffieldvalue = ""; + //明细表主键 + String detail_keyid = ""; + + + if(!"".equals(wffieldname)){ + if(viewtype == 0){//主表 + wffieldvalue = Util.null2String(rs.getString(wffieldname)); + }else{//明细表 + wffieldvalue = Util.null2String(rs_detail.getString(wffieldname)); + + } + } + if(rs_detail != null){ + detail_keyid = Util.null2String(rs_detail.getString("id")); + } + + if(changerule == 1){//表示流程REQUESTID + wffieldvalue = baseArray[0]; + }else if(changerule == 2){//表示流程标题 + wffieldvalue = baseArray[1]; + }else if(changerule == 3){//表示流程编号 + wffieldvalue = baseArray[2]; + }else if(changerule == 4) {//表示系统日期 + wffieldvalue = TimeUtil.getCurrentDateString().toString(); + }else if(changerule == 5){//系统日期时间 + wffieldvalue = TimeUtil.getCurrentTimeString(); + }else if(changerule == 6){//表示固定值 + wffieldvalue = cussql; + }else if(changerule == 7){//表示明细行号 + wffieldvalue = String.valueOf(rownum); + }else if(changerule == 8) {//表示自定义转换 + //if(!"".equals(wffieldvalue)){ + String changevalue = getValueByChangeRule(cussql, wffieldvalue,detail_keyid,baseArray[0],billid); + logger.info("changevalue:[" + changevalue + "]"); + wffieldvalue = changevalue; + //} + }else if(changerule == 9){ + wffieldvalue = voucher_keyid; + }else{//表示不转换 + //wffieldvalue + } + + //XML特殊字符处理 + wffieldvalue = wffieldvalue.replace("<", "<"); + wffieldvalue = wffieldvalue.replace(">", ">"); + wffieldvalue = wffieldvalue.replace("&", "&"); + wffieldvalue = wffieldvalue.replace("'", "'"); + wffieldvalue = wffieldvalue.replace("\"", """); + + return wffieldvalue; + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的规则 + * @param value + * @return + */ + private String getValueByChangeRule(String cus_sql,String value,String detail_keyid,String this_requestid,String billid){ + String endValue = ""; + + cus_sql = cus_sql.replace(" ", " "); + + cus_sql = cus_sql.replace("{?dt.id}", detail_keyid); + + String sqlString = cus_sql.replace("{?billid}", billid).replace("?", value); + + RecordSet rs = new RecordSet(); + + if(rs.executeSql(sqlString)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + + return endValue; + } + + + /** + * 获取系统参数设置值 + * @param ssid + * @return + */ + public String getSystemParamValue(String ssid){ + String paramvalue = ""; + + if(!"".equals(ssid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,ssid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * @return the cusparam + */ + public String getCusparam() { + return cusparam; + } + + /** + * @param cusparam the cusparam to set + */ + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/NcUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/NcUtil.java new file mode 100644 index 0000000..b537025 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/pyzl/util/NcUtil.java @@ -0,0 +1,991 @@ +package com.api.taojw.pyzl.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.xml.sax.InputSource; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; + +import java.io.StringReader; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class NcUtil { + + Logger logger = MyLogger.getLogger(); + private int CONNECT_TIMEOUT = 1800000;//请求超时时间 + + private String voucher_keyid = "";//单据主键(生成规则,年份+时间戳) + + //ITEM中辅助核算项配置 + private List> detail_item_ass_list = new ArrayList>(); + //借方金额Map<借方对应的贷方XML名称,金额值> + private Map debitamount_map = new HashMap(); + //ITEM中现金流量字段配置(普通借方) + private List> detail_item_cas_list = new ArrayList>(); + //ITEM中现金流量字段配置(税额借方) + private List> tax_item_cas_list = new ArrayList>(); + //明细分录序号 + private int rownum = 0; + + private String cusparam = "";//自定义参数 + + private DecimalFormat df = new DecimalFormat("#####################0.00"); + + /** + * 实现父类方法 + * @param requestInfo + * @return + */ + public JSONObject execute(RequestInfo requestInfo,String _cusparam){ + cusparam = _cusparam; + JSONObject result = new JSONObject(); + rownum = 0; + + debitamount_map.clear(); + detail_item_ass_list.clear(); + detail_item_cas_list.clear(); + tax_item_cas_list.clear(); + + + logger.info("-------------------------WorkflowDataToNC_Action Begin-------------------------cusparam:"+cusparam); + //获取流程类型ID + String workflowid = Util.null2String(requestInfo.getWorkflowid()); + logger.info("workflowid:" + workflowid); + //获取流程请求ID + String this_requestid = Util.null2String(requestInfo.getRequestid()); + //获取流程表单ID + int formid = requestInfo.getRequestManager().getFormid(); + + String this_requestname = "";//流程标题 + String this_requestmark = "";//流程编号 + + //获取流程事务 + RecordSetTrans rsts = requestInfo.getRsTrans(); + + //获取流程基础数据 + String select_base_sql = "select * from workflow_requestbase where requestid = ?"; + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + if(rsts.executeQuery(select_base_sql,this_requestid)){ + while(rsts.next()){ + this_requestname = Util.null2String(rsts.getString("requestname")); + this_requestmark = Util.null2String(rsts.getString("requestmark")); + } + } + logger.info("this_requestname:[" + this_requestname + "],this_requestmark:[" + this_requestmark + "],workflowid:["+workflowid+"],this_requestid:[" + this_requestid + "],formid:[" + formid + "]"); + } catch (Exception e1) { + logger.info("获取该流程事物数据集异常:[" + e1.getMessage() + "/" + e1.toString() + "]"); + return result; + } + + String[] baseArray = {this_requestid,this_requestname,this_requestmark}; + + RecordSet rs = new RecordSet(); + + //获取当前流程配置信息 + String select_main_config_sql = "select * from uf_voucher_info where workflowid in (select id from workflow_base where id = ? or activeVersionID = ?)"; + + if(!"".equals(cusparam)){ + select_main_config_sql += " and cusparam = '" + cusparam + "'"; + } + + logger.info("select_main_config_sql:" + select_main_config_sql); + + //配置表主表主键 + int config_main_key = -1; + //组织代码字段 + String orgcode_fieldname = ""; + //控制条件 + String condition = ""; + //明细表序列 + int detailindex = -1; + //是否有现金流量 + int hascash = 1; + + if(rs.executeQuery(select_main_config_sql,workflowid,workflowid)){ + if(rs.next()){ + config_main_key = Util.getIntValue(rs.getString("id"),0); + + orgcode_fieldname = Util.null2String(rs.getString("orgcode_fieldname")); + + condition = Util.null2String(rs.getString("condition")); + + detailindex = Util.getIntValue(rs.getString("detailindex"),0); + + hascash = Util.getIntValue(rs.getString("hascash"),0); + } + } + + logger.info("配置主表主键值:[" + config_main_key + "]"); + + //凭证头字段配置 + List> voucher_head_list = new ArrayList>(); + //凭证Item字段配置(普通借方) + List> debit_detail_item_list = new ArrayList>(); + //凭证Item字段配置(税额借方) + List> tax_detail_item_list = new ArrayList>(); + + + //凭证Item字段配置(差旅税额借方) + List> trip_tax_detail_item_list = new ArrayList>(); + + //凭证Item字段配置(贷方) + List> credit_detail_item_list = new ArrayList>(); + + + if(config_main_key > 0) {//说明该流程存在配置 + //获取当前流程明细字段配置信息 + String select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_info_dt1 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //XML节点名称 + String xmlfield = Util.null2String(rs.getString("xmlfield")); + //XML节点所属 + int xmlbelongto = Util.getIntValue(rs.getString("xmlbelongto"),0); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + //特殊属性 + int special_attribute = Util.getIntValue(rs.getString("special_attribute"),0); + //相对应的贷方XML节点名称 + String counterxml = Util.null2String(rs.getString("counterXML")); + //分录类型 + int itemType = Util.getIntValue(rs.getString("itemType"),0); + //是否金额校验字段 + int isvalidate = Util.getIntValue(rs.getString("isvalidate"),0); + + if(!"".equals(xmlfield)){ + Map detail_map = new HashMap(); + + detail_map.put("xmlfield",xmlfield); + detail_map.put("xmlbelongto",xmlbelongto); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + detail_map.put("special_attribute",special_attribute); + detail_map.put("counterxml",counterxml); + detail_map.put("isvalidate",isvalidate); + detail_map.put("itemType",itemType); + + if(xmlbelongto == 0) {//凭证头字段配置集合 + voucher_head_list.add(detail_map); + }else{//明细分录字段配置 + if(xmlbelongto != 2){//details-item 明细凭证 + if(itemType == 1){//税额借方 + tax_detail_item_list.add(detail_map); + }else if(itemType == 2){//贷方 + credit_detail_item_list.add(detail_map); + }else if(itemType == 0){//普通借方 + debit_detail_item_list.add(detail_map); + }else if(itemType == 3){//差旅税额借方 + trip_tax_detail_item_list.add(detail_map); + } + }else{//cashFlow-item 现金流量 +// if(itemType == 1){//税额借方 +// tax_item_cas_list.add(detail_map); +// }else{//普通借方 + detail_item_cas_list.add(detail_map); +// } + } + } + } + } + } + + //获取辅助核算项的配置信息 + select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_info_dt2 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //辅助核算项类型(0:个人1:部门) + int checktype = Util.getIntValue(rs.getString("checktype"),0); + //辅助核算项类型编码 + String typecode = Util.null2String(rs.getString("typecode")); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + + + Map detail_map = new HashMap(); + + detail_map.put("checktype",checktype); + detail_map.put("typecode",typecode); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + + detail_item_ass_list.add(detail_map); + + } + } + } + + RecordSet rs_main = new RecordSet(); + + //流程主表主键 + int workflow_main_key = 0; + //组织代码字段值 + String orgcode_fieldvalue = ""; + + //获取流程主表信息 + String select_workflow_main = "select * from formtable_main_" + Math.abs(formid) + " where requestid=? "; + + if(!"".equals(condition)){ + select_workflow_main += condition; + } + + logger.info("查询流程主表数据:[" + select_workflow_main + "],[" + this_requestid + "]"); + + if(rs_main.executeQuery(select_workflow_main,this_requestid)){ + + if(rs_main.next()) { + + workflow_main_key = Util.getIntValue(rs_main.getString("id"), 0); + + orgcode_fieldvalue = Util.null2String(rs_main.getString(orgcode_fieldname)); + }else{//若数据不存在,则直接跳过 + + logger.info("-------------------------WorkflowDataToNC_Action(未传凭证) End-------------------------"); + return result; + } + } + + StringBuffer sendxml = new StringBuffer(); + + sendxml.append(""); + sendxml.append(""); + + long timestamp = System.currentTimeMillis() / 10; + + //获取当前日期 + String currentday = TimeUtil.getCurrentDateString(); + //获取当前年份(后两位) + String year = currentday.substring(2,4); + + voucher_keyid = year + timestamp; + + sendxml.append(""); + + sendxml.append(""); + + //获取Header字段配置 + if(voucher_head_list != null && voucher_head_list.size() > 0){ + for(Map detail_map : voucher_head_list){ + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + + if("".equals(xmlfield)){//若XML节点名称为空,则直接跳过 + continue; + } + + //判断OA字段来源 + int viewtype = Util.getIntValue(detail_map.get("viewtype").toString(),0); + + if(viewtype > 0){//说明配置的字段来自明细表,则该字段配置有误,直接跳过 + logger.info("--Error-->字段【" + xmlfield + "】配置有误,请检查!"); + continue; + } + + String fieldval = getFieldValue(detail_map,rs_main,null,baseArray); + result.put(xmlfield,fieldval); + sendxml.append("<").append(xmlfield).append(">"); + sendxml.append(fieldval); + sendxml.append(""); + } + } + + if(debit_detail_item_list != null && debit_detail_item_list.size() > 0){ + JSONArray details = new JSONArray(); + result.put("detail",details); + sendxml.append("
"); + if(detailindex > 0 && workflow_main_key > 0){ + + RecordSet rs_detail = new RecordSet(); + String select_workflow_detail = "select * from formtable_main_" + Math.abs(formid) + "_dt1 where mainid = ? "; + + if(rs_detail.executeQuery(select_workflow_detail,workflow_main_key)){ + + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,rs_detail,baseArray,hascash,details); + + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,rs_detail,baseArray,hascash,details); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + logger.info("差旅税额借方分录XML begin;"); + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,rs_detail,baseArray,hascash,details); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + logger.info("普通贷方分录 begin;rownum:" + rownum); + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info("getFieldValue begin;"); + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,baseArray); + logger.info("getFieldValue end"); + if(special_attribute == 1){//辅助核算项字段 + + if(!"".equals(fieldval) && detail_item_ass_list != null){ + logger.info("getAssistingAccountItemInfo begin"); + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,rs_detail,baseArray,credit_ass_xml_jsonArray); + logger.info("getAssistingAccountItemInfo end"); + } + }else if (special_attribute == 3) {//贷方金额(合计) + logger.info("贷方金额(合计) begin"); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + logger.info("贷方金额(合计) end"); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + logger.info("here"); + //获取现金流量信息 + /* + String credit_cash_flow_xml = ""; + credit_cash_flow_xml += ""; + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + String fieldval = df.format(amount_sum); + + credit_cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + } + credit_cash_flow_xml += ""; + */ + + credit_item_xml.append(""); + // + credit_item_xml_json.put("detailindex",++rownum); + credit_item_xml.append("").append(rownum).append(""); + + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + + }else{//说明字段都来自主表 + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,null,baseArray,hascash,details); + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,null,baseArray,hascash,details); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,null,baseArray,hascash,details); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info(""); + String fieldval = getFieldValue(detail_map, rs_main, null,baseArray); + + if(special_attribute == 1){//辅助核算项字段 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,null,baseArray,credit_ass_xml_jsonArray); + } + }else if (special_attribute == 3) {//贷方金额(合计) + double amount_sum = 0.0; + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + + credit_item_xml.append(""); + // + credit_item_xml.append("").append(++rownum).append(""); + credit_item_xml_json.put("detailindex",rownum); + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + sendxml.append("
"); + } + sendxml.append("
"); + sendxml.append("
"); + sendxml.append("
"); + + logger.info("发送的XML格式为:【" + sendxml.toString() + "】"); + logger.info("result json:" + result.toJSONString()); + logger.info("-------------------------WorkflowDataToNC_Action End-------------------------"); + return result; + } + + /** + * 解析XML字符串 + * @param xml + * @return + */ + @SuppressWarnings("unchecked") + public Map analysisXML(String xml){ + Map resultMap = new HashMap(); + try{ + //创建一个新的字符串 + StringReader read = new StringReader(xml); + //创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入 + InputSource source = new InputSource(read); + //创建一个新的SAXBuilder + SAXBuilder sb = new SAXBuilder(); + //通过输入源构造一个Document + Document doc = sb.build(source); + //取根元素 + Element root = doc.getRootElement(); + //获取ufinterface根节点中的子节点 + List child = root.getChildren(); + //获取ufinterface根节点中第一个子节点 sendresult + Element first_child = (Element)child.get(0); + + //获取formdata根节点中的子节点 + List first_child_grands = first_child.getChildren(); + for(int i = 0 ; i < first_child_grands.size();i++){ + Element leave = (Element)first_child_grands.get(i); + + resultMap.put(leave.getName(), leave.getText()); + //System.err.println("--------" + i + "--->" + leave.getText() + "/" + leave.getName()); + } + }catch (Exception e) { + // TODO: handle exception + logger.info("解析XML字符串异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } + + return resultMap; + } + + /** + * 生成借方分录XML + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @return + */ + private StringBuffer generate_debit_item_xml(int itemType, int itemDirection, List> detail_field_list, RecordSet rs_main, RecordSet rs_detail, String[] baseArray, int hascash, JSONArray details){ + StringBuffer debit_item_xml = new StringBuffer(""); + + if(rs_detail != null){ + while(rs_detail.next()){ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, rs_detail, baseArray, debit_item_xml,hascash,details); + } + }else{ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, null, baseArray, debit_item_xml,hascash,details); + } + + return debit_item_xml; + } + + /** + * + * @param itemDirection + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @param baseArray + * @param debit_item_xml + * @param hascash + */ + private void generate_debitItem_Only_xml(int itemType,int itemDirection, List> detail_field_list, + RecordSet rs_main, RecordSet rs_detail, String[] baseArray, StringBuffer debit_item_xml,int hascash,JSONArray details) { + //循环明细表记录,对借方分录进行拼接 + StringBuffer inner_xml = new StringBuffer(); + JSONObject inner_xml_json = new JSONObject(); + //辅助核算项配置 + String ass_xml = ""; + JSONArray ass_xml_jsonArray = new JSONArray(); + //该行明细是否需要生成会计分录 + boolean isValidate_Success = true; + + for(Map detail_map : detail_field_list){ + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(),0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String counterxml = Util.null2String(detail_map.get("counterxml").toString()); + String fieldval = getFieldValue(detail_map,rs_main,rs_detail,baseArray); + + int isvalidate = Util.getIntValue(detail_map.get("isvalidate").toString(),0); + //借方分录金额合计值 + double amount_sum = 0.0; + + if(special_attribute == 1){//辅助核算项字段 + //获取该科目类型对应的辅助核算项有哪些 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + ass_xml = getAssistingAccountItemInfo(itemDirection,fieldval,rs_main,rs_detail,baseArray,ass_xml_jsonArray); + } + }else if(special_attribute == 2){//借方金额(合计) + amount_sum = Util.getDoubleValue(fieldval,0.0); + + if (isvalidate == 1 && amount_sum == 0){//表示该字段为金额校验字段,若为空,则改行不需要生成分录 + isValidate_Success = false; + break; + } + + if(!"".equals(counterxml)){//对应的贷方XML字段名称 + if(debitamount_map.containsKey(counterxml)){//判断该字段对应的贷方XML是否存在 + double old_debitamount = debitamount_map.get(counterxml); + + double new_debitamount = amount_sum + old_debitamount; + + debitamount_map.put(counterxml,new_debitamount); + }else{ + debitamount_map.put(counterxml, amount_sum); + } + } + + fieldval = df.format(amount_sum); + }else if(special_attribute == 3){//贷方金额(合计) + fieldval = "0.00"; + } + + inner_xml.append("<").append(xmlfield).append(">"); + inner_xml.append(fieldval); + inner_xml.append(""); + inner_xml_json.put(xmlfield,fieldval); + } + + if(isValidate_Success) { + //获取现金流量信息 + JSONObject cash_flow_xml_json = new JSONObject(); + String cash_flow_xml = ""; + cash_flow_xml += ""; + +// List> cash_list = null;//new ArrayList>(); + +// if(itemDirection == 1){//税额借方 +// cash_list = tax_item_cas_list; +// }else{//普通借方 +// cash_list = detail_item_cas_list; +// } + + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String fieldname = Util.null2String(detail_map.get("fieldname").toString()); + int rowitemType = (Integer)detail_map.get("itemType"); + + logger.info("rowitemType:[" + rowitemType + "],xmlfield:[" + xmlfield + "],fieldname:[" + fieldname + "],itemType:[" + itemType + "]"); + + if(itemType != rowitemType){ + continue; + } + + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,baseArray); + + logger.info("fieldval:[" + fieldval + "]"); + + cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + cash_flow_xml_json.put(xmlfield,fieldval); + } + cash_flow_xml += ""; + + JSONObject debit_item_xml_json = new JSONObject(); + + + debit_item_xml.append(""); + debit_item_xml_json.put("detailindex",++rownum); + // + debit_item_xml.append("").append(rownum).append(""); + //普通字段 + debit_item_xml.append(inner_xml.toString()); + debit_item_xml_json.putAll(inner_xml_json); + + //辅助核算项 + debit_item_xml.append(""); + debit_item_xml.append(ass_xml); + debit_item_xml.append(""); + + debit_item_xml_json.put("ass",ass_xml_jsonArray); + + + if(hascash == 1){ + //现金流量 + debit_item_xml.append(""); + debit_item_xml.append(cash_flow_xml); + debit_item_xml.append(""); + + JSONArray cashFlow = new JSONArray(); + cashFlow.add(cash_flow_xml_json); + debit_item_xml_json.put("cashflow",cashFlow); + } + + debit_item_xml.append(""); + details.add(debit_item_xml_json); + } + } + + /** + * 获取借方分录【科目】/贷方【公司银行】的辅助核算项配置 + * @param itemDirection 分录方向 [0-借方分录(普通) 、1-借方分录(税额) 、2-贷方分录] + * @param subjectid 科目主键 + * @param rs_main 流程主表查询结果数据集 + * @param rs_detail 当前行明细表查询结果数据集 + * @return String 科目辅助核算项的XML + */ + private String getAssistingAccountItemInfo(int itemDirection,String subjectid,RecordSet rs_main,RecordSet rs_detail,String[] baseArray,JSONArray ass_xml_jsonArray){ + String select_sql = ""; + RecordSet rs = new RecordSet(); + + String ass_xml = ""; + + //辅助核算项类型(0 : 部门 1-部门+人员 2:人员) + int checkType = 0; + + + if(itemDirection == 0){//若为普通的借方分录,则根据科目,获取该科目应该对应的辅助核算项类型 + select_sql = "select * from uf_kmjbxx where kembm = ?"; + + if(rs.executeQuery(select_sql,subjectid)){ + rs.next(); + + checkType = Util.getIntValue(rs.getString("fuzhslx"),0); + } + } + + for(Map detail_map : detail_item_ass_list){//循环辅助核算项字段配置信息 + int row_checktype = Util.getIntValue(detail_map.get("checktype").toString(),0); + + String typecode = Util.null2String(detail_map.get("typecode").toString()); + String fieldvalue = getFieldValue(detail_map,rs_main,rs_detail,baseArray); + + if(itemDirection == 0){ + logger.info("--------------普通借方辅助核算项 Begin--------------------"); + + logger.info("checkType:[" + checkType + "],row_checktype:[" + row_checktype + "],typecode:[" + typecode + "],fieldvalue:[" + fieldvalue + "]"); + + logger.info("--------------普通借方辅助核算项 End--------------------"); + } + + if(itemDirection == 0) {//普通借方分录 + if ((checkType == 0 && row_checktype == 0) || row_checktype == 2 || row_checktype == 3) {//该科目辅助核算项只有部门,而配置中出现人员(或者辅助核算类型为税额、银行存款的也跳过),则人员配置跳过 + continue; + } + }else if(itemDirection == 1 && row_checktype != 2){//税额借方分录 + continue; + }else if(itemDirection == 2 && row_checktype != 3){//贷方分录 + continue; + } + + /* + String checkType_val = ""; + + if(row_checktype == 0){//人员 + checkType_val = "0002"; + }else{//部门 + checkType_val = "0001"; + } + */ + ass_xml += ""; + ass_xml += "" + typecode + ""; + ass_xml += "" + fieldvalue + ""; + ass_xml += ""; + JSONObject o = new JSONObject(); + o.put("checktypecode",typecode); + o.put("checkvaluecode",fieldvalue); + ass_xml_jsonArray.add(o); + } + + return ass_xml; + } + + /** + * 获取字段值 + * @param configMap + * @param rs + * @param rs_detail + * @return + */ + private String getFieldValue(Map configMap,RecordSet rs,RecordSet rs_detail,String[] baseArray){ + //流程字段名称 + String wffieldname = Util.null2String(configMap.get("fieldname").toString()); + //转换规则 + int changerule = Util.getIntValue(configMap.get("changerule").toString(),0); + //自定义规则 + String cussql = Util.null2String(configMap.get("cussql").toString()); + + //流程字段所属 + int viewtype = Util.getIntValue(configMap.get("viewtype").toString(),0); + + logger.info("wffieldname:" + wffieldname + ";changerule:" + changerule + ";cussql:" + cussql + ";viewtype:" + viewtype); + + //流程字段值 + String wffieldvalue = ""; + //明细表主键 + String detail_keyid = ""; + + + if(!"".equals(wffieldname)){ + if(viewtype == 0){//主表 + wffieldvalue = Util.null2String(rs.getString(wffieldname)); + }else{//明细表 + wffieldvalue = Util.null2String(rs_detail.getString(wffieldname)); + + } + } + if(rs_detail != null){ + detail_keyid = Util.null2String(rs_detail.getString("id")); + } + + if(changerule == 1){//表示流程REQUESTID + wffieldvalue = baseArray[0]; + }else if(changerule == 2){//表示流程标题 + wffieldvalue = baseArray[1]; + }else if(changerule == 3){//表示流程编号 + wffieldvalue = baseArray[2]; + }else if(changerule == 4) {//表示系统日期 + wffieldvalue = TimeUtil.getCurrentDateString().toString(); + }else if(changerule == 5){//系统日期时间 + wffieldvalue = TimeUtil.getCurrentTimeString(); + }else if(changerule == 6){//表示固定值 + wffieldvalue = cussql; + }else if(changerule == 7){//表示明细行号 + wffieldvalue = String.valueOf(rownum); + }else if(changerule == 8) {//表示自定义转换 + //if(!"".equals(wffieldvalue)){ + String changevalue = getValueByChangeRule(cussql, wffieldvalue,detail_keyid,baseArray[0]); + logger.info("changevalue:[" + changevalue + "]"); + wffieldvalue = changevalue; + //} + }else if(changerule == 9){ + wffieldvalue = voucher_keyid; + }else{//表示不转换 + //wffieldvalue + } + + //XML特殊字符处理 + wffieldvalue = wffieldvalue.replace("<", "<"); + wffieldvalue = wffieldvalue.replace(">", ">"); + wffieldvalue = wffieldvalue.replace("&", "&"); + wffieldvalue = wffieldvalue.replace("'", "'"); + wffieldvalue = wffieldvalue.replace("\"", """); + + return wffieldvalue; + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的规则 + * @param value + * @return + */ + private String getValueByChangeRule(String cus_sql,String value,String detail_keyid,String this_requestid){ + String endValue = ""; + + cus_sql = cus_sql.replace(" ", " "); + + cus_sql = cus_sql.replace("{?dt.id}", detail_keyid); + + String sqlString = cus_sql.replace("{?requestid}", this_requestid).replace("?", value); + + RecordSet rs = new RecordSet(); + + if(rs.executeSql(sqlString)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + + return endValue; + } + + + /** + * 获取系统参数设置值 + * @param ssid + * @return + */ + public String getSystemParamValue(String ssid){ + String paramvalue = ""; + + if(!"".equals(ssid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,ssid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * @return the cusparam + */ + public String getCusparam() { + return cusparam; + } + + /** + * @param cusparam the cusparam to set + */ + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/DealLoginServlet.java b/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/DealLoginServlet.java new file mode 100644 index 0000000..a22d939 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/DealLoginServlet.java @@ -0,0 +1,61 @@ +package com.api.taojw.shqhjys.todo; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.CommonSqlUtil; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.TjwHttpUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import javax.servlet.ServletException; +import javax.servlet.http.*; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class DealLoginServlet extends HttpServlet{ + + Logger logger = MyLogger.getLogger(); + + public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + this.doGet(req, res); + } + + public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { + try{ + String code = httpServletRequest.getParameter("code"); + String requestId = httpServletRequest.getParameter("requestid"); + logger.info("DealLoginServlet begin;code:" + code + ";requestId:" + requestId); + //调接口获取人员信息 + RecordSet rs = new RecordSet(); + String url = CommonSqlUtil.getSystemParamValue("syUserInfoUrl",rs); + String appCode = CommonSqlUtil.getSystemParamValue("syAppCode",rs); + String appKey = CommonSqlUtil.getSystemParamValue("syappKey",rs); + url = url + SyncTodoUtil.getUrlParams(rs,appCode,appKey,String.valueOf(System.currentTimeMillis())); + url = url + "&code=" + code; + Map headers = new HashMap<>(); + JSONObject param = new JSONObject(); + Map message = TjwHttpUtil.sendHttpRequest(url, param.toJSONString(), "GET", ContentType.APPLICATION_JSON, headers); + String data = (String) message.get("data"); + JSONObject res = JSONObject.parseObject(data); + String resCode = res.getString("code"); + if("200".equals(resCode)){ + JSONObject d = res.getJSONObject("data"); + String logName = d.getString("logName").toLowerCase(); + String getIdSql = "select id from hrmresource where loginid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getIdSql, logName); + String userId = firstData.get("id"); + HttpSession session = httpServletRequest.getSession(); + session.setAttribute("weaver_user@bean",new weaver.hrm.User(Integer.parseInt(userId))); + Cookie cookie=new Cookie("JSESSIONID",session.getId()); + httpServletResponse.addCookie(cookie); + httpServletResponse.sendRedirect("/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId); + }else{ + logger.error("resCode error;"); + } + }catch(Exception e){ + logger.error("DealLoginServlet error;message:" + e.getMessage() + ";e:" + e); + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/SyncToDoInfo.java b/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/SyncToDoInfo.java new file mode 100644 index 0000000..0f71ca0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/SyncToDoInfo.java @@ -0,0 +1,152 @@ +package com.api.taojw.shqhjys.todo; + +import com.api.taojw.common.CommonSqlUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.ofs.interfaces.SendRequestStatusDataInterfaces; +import weaver.workflow.request.todo.DataObj; +import weaver.workflow.request.todo.RequestStatusObj; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 上海期货交易所 + * 统一待办推送、推送消息 + * 待办转已办 + */ +public class SyncToDoInfo implements SendRequestStatusDataInterfaces { + + Logger logger = MyLogger.getLogger(); + + private String mobileLink = ""; + private String pcLink = ""; + + public String getMobileLink() { + return mobileLink; + } + + public void setMobileLink(String mobileLink) { + this.mobileLink = mobileLink; + } + + public String getPcLink() { + return pcLink; + } + + public void setPcLink(String pcLink) { + this.pcLink = pcLink; + } + + /** + * 后台设置id + */ + public String id ; + /** + * 设置的系统编号 + */ + public String syscode ; + /** + * 服务器URL + */ + public String serverurl ; + /** + * 流程白名单 + */ + public ArrayList workflowwhitelist ; + /** + * 人员白名单 + */ + public ArrayList userwhitelist ; + + + public String getId() { + return id; + } + public String getSyscode() { + return syscode; + } + public String getServerurl() { + return serverurl; + } + public ArrayList getWorkflowwhitelist() { + return workflowwhitelist; + } + public ArrayList getUserwhitelist() { + return userwhitelist; + } + + @Override + public void SendRequestStatusData(ArrayList arrayList) { + logger.info("SyncToDoInfo.SendRequestStatusData begin"); + try { + RecordSet rs = new RecordSet(); + String appCode = CommonSqlUtil.getSystemParamValue("syAppCode",rs); + String appKey = CommonSqlUtil.getSystemParamValue("syappKey",rs); + String messageUrl = CommonSqlUtil.getSystemParamValue("syMessageUrl",rs); + String syDoneTodoUrl = CommonSqlUtil.getSystemParamValue("syDoneTodoUrl",rs); + String sySendTodoUrl = CommonSqlUtil.getSystemParamValue("sySendTodoUrl",rs); + String syReadTodoUrl = CommonSqlUtil.getSystemParamValue("syReadTodoUrl",rs); + String syDeleteTodoUrl = CommonSqlUtil.getSystemParamValue("syDeleteTodoUrl",rs); + Iterator arrayListIterator = arrayList.iterator(); + while(arrayListIterator.hasNext()) { + DataObj dataObj = (DataObj)arrayListIterator.next(); + ArrayList doneDataList = dataObj.getDonedatas(); + doneDataList = doneDataList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RequestStatusObj::getRequestid))), ArrayList::new)); + ArrayList todoDataList = dataObj.getTododatas(); + todoDataList = todoDataList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RequestStatusObj::getRequestid))), ArrayList::new)); + ArrayList delDataList = dataObj.getDeldatas(); + delDataList = delDataList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RequestStatusObj::getRequestid))), ArrayList::new)); + + //真正要发送的已办 = 已办信息中剔除待办信息 + ArrayList realDoneDataList = new ArrayList(); + Iterator doneDataListIterator = doneDataList.iterator(); + RequestStatusObj requestStatusObj; + while(doneDataListIterator.hasNext()) { + requestStatusObj = (RequestStatusObj)doneDataListIterator.next(); + //已办信息是否在待办信息中 + boolean isDoneInTodo = false; + Iterator todoDataListIterator = todoDataList.iterator(); + while(todoDataListIterator.hasNext()) { + RequestStatusObj var13 = (RequestStatusObj)todoDataListIterator.next(); + if (requestStatusObj.getRequestid() == var13.getRequestid() && requestStatusObj.getUser().getUID() == var13.getUser().getUID()) { + isDoneInTodo = true; + break; + } + } + //如果已办不在待办中,则发送已办信息 + if (!isDoneInTodo) { + realDoneDataList.add(requestStatusObj); + } + } + + //删除 + doneDataList = dataObj.getDonedatas(); + SyncTodoUtil.deleteTodoInfo(rs,syDeleteTodoUrl,doneDataList,appCode,appKey); + //已办 realDoneDataList + //doneDataList = dataObj.getDonedatas(); + SyncTodoUtil.updateTodoInfo(rs,syDoneTodoUrl,realDoneDataList,appCode,appKey); + //待办 todoDataList + todoDataList = dataObj.getTododatas(); + SyncTodoUtil.sendTodoInfo(rs,sySendTodoUrl,todoDataList,appCode,appKey,mobileLink,pcLink,messageUrl,syReadTodoUrl); + + } + } catch (Throwable e) { + logger.error("SyncToDoInfo.SendRequestStatusData throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + private void logList(String name,List list){ + logger.info("name:" + name + ";value:"); + for(RequestStatusObj o:list){ + logger.info("requestid:" + o.getRequestid()); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/SyncTodoUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/SyncTodoUtil.java new file mode 100644 index 0000000..c42d689 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/shqhjys/todo/SyncTodoUtil.java @@ -0,0 +1,214 @@ +package com.api.taojw.shqhjys.todo; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.TjwHttpUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.workflow.request.todo.RequestStatusObj; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class SyncTodoUtil { + + static Logger logger = MyLogger.getLogger(); + private static String OA_URL = getOAAddress(); + + private static String getUserNameSql = "select lastname,loginid from hrmresource where id = ?"; + + public static String getUrlParams(RecordSet rs,String appCode,String appKey,String timestamp){ + try{ + //String timestamp = String.valueOf(System.currentTimeMillis()); + String token = String.valueOf(UUID.randomUUID()); + String vcode = DigestUtils.md5Hex((timestamp+appCode+token+appKey)); + String param = "?timestamp="+timestamp+"&token="+token+"&app="+appCode+"&vcode="+vcode; + return param; + }catch(Throwable e){ + logger.error("getUrlParams error;message:" + e.getMessage() + ";e:" + e); + return ""; + } + } + + //发送待办 + public static void sendTodoInfo(RecordSet rs,String url, ArrayList todoDataList,String appCode,String appKey,String mobileLink,String pcLink,String messageUrl,String readUrl){ + try{ + if(todoDataList == null || todoDataList.size() == 0){ + return; + } + logger.info("sendTodoInfo begin;"); + url = url + getUrlParams(rs,appCode,appKey,String.valueOf(System.currentTimeMillis())); + //接口地址 + URL wbUrl = new URL(url); + for(RequestStatusObj requestStatusObj : todoDataList){ + String requestId = String.valueOf(requestStatusObj.getRequestid()); + int uid = requestStatusObj.getUser().getUID(); + int creatorId = requestStatusObj.getCreatorid(); + String requestName = requestStatusObj.getRequstname(); + Map firstData = DaoUtil.getFirstData(rs, getUserNameSql, creatorId); + String creatorLoginId = firstData.get("loginid"); + Map firstData1 = DaoUtil.getFirstData(rs, getUserNameSql, uid); + String receiverLoginId = firstData1.get("loginid"); + String viewType = requestStatusObj.getViewtype(); + + logger.info("sendTodoInfo begin;requestid:" + requestId + ";userId:" + uid + ";creatorId:" + creatorId + ";viewType:" + viewType); + + //已读操作 + if("-2".equals(viewType)){ + String _readUrl = readUrl + "/" + requestId + getUrlParams(rs,appCode,appKey,String.valueOf(System.currentTimeMillis())); + Map headers = new HashMap<>(); + JSONObject param = new JSONObject(); + param = new JSONObject(); + param.put("appCode",appCode); + param.put("appName","OA"); + param.put("vendorId",requestId+"u"+uid+"n"+requestStatusObj.getNodeid()); + Map message = TjwHttpUtil.sendHttpRequest(_readUrl, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + continue; + } + + //请求头 + Map headers = new HashMap<>(); + //请求体 + JSONObject param = new JSONObject(); + param.put("moduleName","OA待办"); + param.put("vendorId",requestId+"u"+uid+"n"+requestStatusObj.getNodeid()); + param.put("appCode",appCode); + param.put("receiveUserId",receiverLoginId); + param.put("urgentText","正常"); + param.put("importantText","普通"); + param.put("sendUserId",creatorLoginId); + param.put("bt",requestName); + String creatorName = firstData.get("lastname"); + param.put("sendUserName",creatorName); + if(OA_URL == null || "".equals(OA_URL)){ + OA_URL = getOAAddress(); + } + if(!"".equals(mobileLink) && mobileLink != null){ + param.put("mobileUrl",mobileLink+requestId); + }else{ + param.put("mobileUrl",OA_URL + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId); + } + param.put("appName","OA"); + + String receiveUserName = firstData1.get("lastname"); + param.put("receiveUserName",receiveUserName); + if(!"".equals(pcLink) && pcLink != null){ + param.put("url",pcLink + "?code={code}"); + }else{ + param.put("url",OA_URL + "/dealLoginServlet?requestid="+requestId + "&code={code}"); + } + String createtime = requestStatusObj.getCreatetime(); + if(StringUtils.isNotBlank(createtime)){ + if(createtime.length() < 6){ + createtime += ":00"; + } + }else { + createtime="00:00:00"; + } + param.put("receiveTime",requestStatusObj.getReceivedate() + " " + createtime); + Map post = TjwHttpUtil.sendHttpRequest(url, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + + //消息推送 + String _message = ""; + _message = messageUrl + getUrlParams(rs,appCode,appKey,String.valueOf(System.currentTimeMillis())); + param = new JSONObject(); + param.put("appCode",appCode); + param.put("content","您有一条待办待处理!"); + param.put("receiveUserId",receiverLoginId); + param.put("receiveUserName",receiveUserName); + param.put("sendTime",requestStatusObj.getReceivedate() + " " + createtime); + param.put("sendUserName",creatorName); + param.put("vendorId",requestId); + Map message = TjwHttpUtil.sendHttpRequest(_message, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + } + }catch(Throwable e){ + logger.error("SyncTodoUtil.sendTodoInfo Throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + //删除 + public static void deleteTodoInfo(RecordSet rs,String url, ArrayList todoDataList,String appCode,String appKey){ + try{ + if(todoDataList == null || todoDataList.size() == 0){ + return; + } + logger.info("deleteTodoInfo begin;"); + //接口地址 + for(RequestStatusObj requestStatusObj : todoDataList){ + String currentTimeMillis = String.valueOf(System.currentTimeMillis()); + String requestId = String.valueOf(requestStatusObj.getRequestid()); + int uid = requestStatusObj.getUser().getUID(); + String _url = url + "/" +requestId+"u"+uid+"n"+requestStatusObj.getNodeid(); + _url = _url + getUrlParams(rs,appCode,appKey,currentTimeMillis); + logger.info("deleteTodoInfo begin;requestid:" + requestId + ";userId:" + uid); + //请求头 + Map headers = new HashMap<>(); + //请求体 + JSONObject param = new JSONObject(); + Map post = TjwHttpUtil.sendHttpRequest(_url, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + } + }catch(Throwable e){ + logger.error("SyncTodoUtil.deleteTodoInfo Throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + //待办转已办 + public static void updateTodoInfo(RecordSet rs,String url, ArrayList todoDataList,String appCode,String appKey){ + try{ + if(todoDataList == null || todoDataList.size() == 0){ + return; + } + logger.info("updateTodoInfo begin;"); + //接口地址 + for(RequestStatusObj requestStatusObj : todoDataList){ + String currentTimeMillis = String.valueOf(System.currentTimeMillis()); + String requestId = String.valueOf(requestStatusObj.getRequestid()); + int uid = requestStatusObj.getUser().getUID(); + String _url = url + "/" +requestId+"u"+uid+"n"+requestStatusObj.getNodeid()+"/"+currentTimeMillis; + _url = _url + getUrlParams(rs,appCode,appKey,currentTimeMillis); + logger.info("updateTodoInfo begin;requestid:" + requestId + ";userId:" + uid); + //请求头 + Map headers = new HashMap<>(); + //请求体 + JSONObject param = new JSONObject(); + Map post = TjwHttpUtil.sendHttpRequest(_url, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + } + }catch(Throwable e){ + logger.error("SyncTodoUtil.updateTodoInfo Throwable;message:" + e.getMessage() + ";e:" + e); + } + } + + /** + *

获取oa地址

+ * @author xuanran.wang + * @dateTime 2022/12/22 13:51 + * @return OA地址 + **/ + private static String getOAAddress(){ + try{ + String sql = "select oaaddress from systemset"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + String url = Util.null2String(recordSet.getString(1)); + if(StringUtils.isBlank(url)){ + url = ""; + }else if(url.endsWith("/")){ + url = url.substring(0, url.length() - 1); + } + logger.info("OA address: [ " + url + " ]"); + return url; + }catch(Throwable e){ + logger.error("getOAAddress error;message:" + e.getMessage() + ";e:" + e); + return ""; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/test/TestCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/test/TestCronJob.java new file mode 100644 index 0000000..f12b427 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/test/TestCronJob.java @@ -0,0 +1,137 @@ +package com.api.taojw.test; + +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.ISysSynchroGetOrgWebServiceServiceLocator; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.ISysSynchroGetOrgWebServiceServiceSoapBindingStub; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.SysSynchroGetOrgBaseInfoContextV2; +import com.api.taojw.liangxin.baseinfocronjob.syncbaseinfowebservice.SysSynchroOrgResult; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.log4j.Logger; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.logging.MyLogger; + +import java.lang.reflect.Field; +import java.net.URL; +import java.util.Properties; + +public class TestCronJob extends BaseCronJob { + //接口提供方webservice地址 + private String serviceUrl = ""; + + private String kg = ""; + + public String getKg() { + return kg; + } + + public void setKg(String kg) { + this.kg = kg; + } + + //存储人员信息的建模表表名 + private String personInfoTable = ""; + //存储分部信息的建模表表名 + private String orgInfoTable = ""; + //存储部门信息的建模表表名 + private String deptInfoTable = ""; + //存储岗位信息的建模表表名 + private String jobInfoTable = ""; + + public String getServiceUrl() { + return serviceUrl; + } + + public void setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + public String getPersonInfoTable() { + return personInfoTable; + } + + public void setPersonInfoTable(String personInfoTable) { + this.personInfoTable = personInfoTable; + } + + public String getOrgInfoTable() { + return orgInfoTable; + } + + public void setOrgInfoTable(String orgInfoTable) { + this.orgInfoTable = orgInfoTable; + } + + public String getDeptInfoTable() { + return deptInfoTable; + } + + public void setDeptInfoTable(String deptInfoTable) { + this.deptInfoTable = deptInfoTable; + } + + public String getJobInfoTable() { + return jobInfoTable; + } + + public void setJobInfoTable(String jobInfoTable) { + this.jobInfoTable = jobInfoTable; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + // webServiceUrl为请求的webservice地址 + /*CallServiceFactory a = new CallServiceFactory(); + CallServiceFactory.setURL(serviceUrl); + CallServiceFactory factory = new CallServiceFactory(); + CallService callService = factory.getCallServicePort(); + + // 连接参数设定 + Client proxy = ClientProxy.getClient(callService); + HTTPConduit conduit = (HTTPConduit) proxy.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + + // 连接超时时间 + policy.setConnectionTimeout(webServiceConfig.getConnectionTimeout()); + // 请求超时时间,设置太短会出现核心还没返回就请求异常 + policy.setReceiveTimeout(webServiceConfig.getReceiveTimeout()); + conduit.setClient(policy); + // 获取返回结果 + callResult = callService.invoke(args1, args2, args3, args4, args5);*/ + + FieldUtils.getAllFields(ISysSynchroGetOrgWebServiceServiceSoapBindingStub.class); + URL wbUrl = new URL(serviceUrl); + ISysSynchroGetOrgWebServiceServiceLocator locator = new ISysSynchroGetOrgWebServiceServiceLocator(); + ISysSynchroGetOrgWebServiceServiceSoapBindingStub stub = new ISysSynchroGetOrgWebServiceServiceSoapBindingStub(wbUrl,locator); + SysSynchroGetOrgBaseInfoContextV2 orgContext = new SysSynchroGetOrgBaseInfoContextV2(); + //获取人员信息 + String returnOrgType = "[{\"type\":\"person\"}]"; + orgContext.setReturnOrgType(returnOrgType); + if("1".equals(kg)){ + /*Field field = Stub.class.getDeclaredField("cachedProperties"); + field.setAccessible(true); + Properties properties = new Properties(); + properties.put("axis.connection.timeout",11); + field.set(stub,new Properties());*/ + Field[] fields = FieldUtils.getAllFields(ISysSynchroGetOrgWebServiceServiceSoapBindingStub.class); + for(Field field : fields){ + if("cachedProperties".equals(field.getName())){ + field.setAccessible(true); + Properties properties = new Properties(); + properties.put("axis.connection.timeout",11); + field.set(stub,properties); + } + } + } + SysSynchroOrgResult elementsBaseInfoV2 = stub.getElementsBaseInfoV2(orgContext); + + }catch(Exception e){ + logger.error("SyncBaseInfoCronJob.execute() exception;messgae:" + e.getMessage() + ";e:" + e); + } + } + + + +} + diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/tuanxiao/cronjob/SyncKqCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/tuanxiao/cronjob/SyncKqCronJob.java new file mode 100644 index 0000000..6d0b457 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/tuanxiao/cronjob/SyncKqCronJob.java @@ -0,0 +1,170 @@ +package com.api.taojw.tuanxiao.cronjob; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.JsonConvertUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 团校 + * 调两个接口同步考勤、车辆信息到同一个建模中 +*/ +public class SyncKqCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String kqConfigId = ""; + + private String configPageSize = ""; + + public String getConfigPageSize() { + return configPageSize; + } + + public void setConfigPageSize(String configPageSize) { + this.configPageSize = configPageSize; + } + + private String inCarConfigId = ""; + private String outCarConfigId = ""; + + public String getInCarConfigId() { + return inCarConfigId; + } + + public void setInCarConfigId(String inCarConfigId) { + this.inCarConfigId = inCarConfigId; + } + + public String getOutCarConfigId() { + return outCarConfigId; + } + + public void setOutCarConfigId(String outCarConfigId) { + this.outCarConfigId = outCarConfigId; + } + + public String getKqConfigId() { + return kqConfigId; + } + public void setKqConfigId(String kqConfigId) { + this.kqConfigId = kqConfigId; + } + + + + private String dataDate = ""; + public String getDataDate() { + return dataDate; + } + public void setDataDate(String dataDate) { + this.dataDate = dataDate; + } + + @Override + public void execute() { + try{ + logger.info("SyncKqCronJob.execute() begin"); + + Date today = new Date();//获取今天的日期 + Calendar c = Calendar.getInstance(); + c.setTime(today); + c.add(Calendar.DAY_OF_MONTH, -1); + Date yesterday = c.getTime();//这是昨天 + //String lastDay = new SimpleDateFormat("yyyy-MM-dd").format(yesterday); + String lastDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + RecordSet rs = new RecordSet(); + + String _dataDate = ""; + if(dataDate == null || "".equals(dataDate)){ + _dataDate = lastDay; + }else{ + _dataDate = dataDate; + } + //删除昨天的数据 + String deleteSql = "delete from uf_kq_detailData where dkrq = ?"; + DaoUtil.updateData(rs,deleteSql,_dataDate); + + //获取token + String tokenUrl = CommonSqlUtil.getSystemParamValue("kqtokenurl",rs); + Map tokenResponse = TjwHttpUtil.sendHttpRequest(tokenUrl, "", "get", null, null); + String token = JSONObject.parseObject((String) tokenResponse.get("data")).getJSONObject("data").getString("access_token"); + logger.info("token done;token:" + token); + //获取昨天的考勤数据 + String kqUrl = CommonSqlUtil.getSystemParamValue("kqurl",rs); + Map headers = new HashMap<>(); + headers.put("Authorization","bearer " + token); + JSONObject paramKq = new JSONObject(); + int pageNum = 1; + boolean hasNextPage = true; + while(hasNextPage){ + kqUrl = kqUrl + "?pageNum="+pageNum+"&pageSize="+configPageSize+"&beginTime="+_dataDate+"&endTime="+_dataDate; + Map kqResponse = TjwHttpUtil.sendHttpRequest(kqUrl, paramKq.toJSONString(), "get", ContentType.APPLICATION_JSON, headers); + JSONObject data = JSONObject.parseObject((String) kqResponse.get("data")); + JSONArray dataArray = data.getJSONObject("data").getJSONArray("list"); + for(int i = 0;i < dataArray.size(); i++){ + JSONObject oldJson = (JSONObject) dataArray.get(i); + JSONObject jsonObject = JsonConvertUtil.convertJsonByConfig(oldJson, kqConfigId); + if(jsonObject.get("userCode") == null || "".equals(jsonObject.get("userCode"))){ + continue; + } + jsonObject.put("dkrq",_dataDate); + TjwModelUtil.addModelData(rs,"uf_kq_detailData",jsonObject); + } + hasNextPage = data.getJSONObject("data").getBoolean("hasNextPage"); + pageNum = pageNum + 1; + paramKq.put("pageNum",pageNum); + } + //获取昨天的车辆信息 + String carurl = CommonSqlUtil.getSystemParamValue("carurl",rs); + headers = new HashMap<>(); + headers.put("Authorization","bearer " + token); + JSONObject paramCar = new JSONObject(); + pageNum = 1; + hasNextPage = true; + while(hasNextPage){ + carurl = carurl + "?pageNum="+pageNum+"&pageSize="+configPageSize+"&beginTime="+_dataDate+"&endTime="+_dataDate; + Map kqResponse = TjwHttpUtil.sendHttpRequest(carurl, paramCar.toJSONString(), "get", ContentType.APPLICATION_JSON, headers); + JSONObject data = JSONObject.parseObject((String) kqResponse.get("data")); + JSONArray dataArray = data.getJSONObject("data").getJSONArray("list"); + for(int i = 0;i < dataArray.size(); i++){ + JSONObject oldJson = (JSONObject) dataArray.get(i); + JSONObject jsonObject = JsonConvertUtil.convertJsonByConfig(oldJson, inCarConfigId); + if(jsonObject.get("userCode") == null || "".equals(jsonObject.get("userCode"))){ + continue; + } + jsonObject.put("dkrq",_dataDate); + TjwModelUtil.addModelData(rs,"uf_kq_detailData",jsonObject); + } + for(int i = 0;i < dataArray.size(); i++){ + JSONObject oldJson = (JSONObject) dataArray.get(i); + JSONObject jsonObject = JsonConvertUtil.convertJsonByConfig(oldJson, outCarConfigId); + if(jsonObject.get("userCode") == null || "".equals(jsonObject.get("userCode"))){ + continue; + } + jsonObject.put("dkrq",_dataDate); + TjwModelUtil.addModelData(rs,"uf_kq_detailData",jsonObject); + } + hasNextPage = data.getJSONObject("data").getBoolean("hasNextPage"); + pageNum = pageNum + 1; + paramKq.put("pageNum",pageNum); + } + logger.info("SyncKqCronJob.execute() end"); + }catch(Throwable e){ + logger.error("SyncKqCronJob.execute() exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} + + diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/BackPrAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/BackPrAction.java new file mode 100644 index 0000000..c159dbf --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/BackPrAction.java @@ -0,0 +1,51 @@ +package com.api.taojw.xmzx.action; + +import com.api.taojw.xmzx.util.ModelDataUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * 提交action + * 流程提交后,根据明细表的PR勾选字段 找到建模中的数据, 更新建模的剩余数量为 申请数量减去 + * 剩余数量 减去流程明细中的数量,修改后的剩余数量应该大于0,否则不允许提交流程; + */ +public class BackPrAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestName = requestInfo.getRequestManager().getRequestname(); + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTable = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + //获取明细表中的数据 + String getDetailDataSql = + "select prgx,quantity,itemwb from " + billTable + "_dt1 where mainid = (select id from " + billTable + " where requestid = ?)"; + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + String res = ModelDataUtil.addQuantity(data); + if("Success09".equals(res)){ + return Action.SUCCESS; + } + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("台账数据更新失败,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("BackPrAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("BackPrAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/CreateEqbWorkflowAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/CreateEqbWorkflowAction.java new file mode 100644 index 0000000..26d38ff --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/CreateEqbWorkflowAction.java @@ -0,0 +1,323 @@ +package com.api.taojw.xmzx.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.util.EqbRequestHeaderUtil; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.taojw.common.CommonSqlUtil; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; +import java.net.URL; +import java.util.*; + +/** + * 调用e签宝接口上传文件 并发起e签宝流程 + */ +public class CreateEqbWorkflowAction implements Action { + + //存放待签署文件的流程字段名称 + private String fileColumns = ""; + public String getFileColumns() { + return fileColumns; + } + public void setFileColumns(String fileColumns) { + this.fileColumns = fileColumns; + } + private String configId = ""; + public String getConfigId() { + return configId; + } + public void setConfigId(String configId) { + this.configId = configId; + } + + private String localFileColumn = ""; + + public String getLocalFileColumn() { + return localFileColumn; + } + + public void setLocalFileColumn(String localFileColumn) { + this.localFileColumn = localFileColumn; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------;fileColumns:" + fileColumns); + + //获取要签署的文件 + if(fileColumns == null || "".equals(fileColumns)){ + return Action.SUCCESS; + } + String billTableName = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + String eqbAppIdColumnName = CommonSqlUtil.getSystemParamValue("eqbAppIdColumnName",rs); + String eqbAppSecretColumnName = CommonSqlUtil.getSystemParamValue("eqbAppSecretColumnName",rs); + List docIdS = new ArrayList<>(); + List> imageFileIds = new ArrayList<>(); + String[] fileColumnArr = fileColumns.split(","); + for(String col : fileColumnArr){ + String getDocIdSql = "select " + col + " from " + billTableName + " t1 where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDocIdSql, requestId); + String docIds = firstData.get(col.toLowerCase(Locale.ROOT)); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArr = docIds.split(","); + for(String docId : docIdArr){ + docIdS.add(docId); + } + } + } + String getImageFileIdSql = "select imagefileid,imagefilename from DocImageFile where docid = ? order by versionid desc"; + for(String docId : docIdS){ + Map firstData = DaoUtil.getFirstData(rs, getImageFileIdSql, docId); + Map m = new HashMap<>(); + m.put("imagefileid",firstData.get("imagefileid")); + m.put("imagefilename",firstData.get("imagefilename")); + imageFileIds.add(m); + } + //遍历待签署文件,调用e签宝接口,上传文件 + List eqbFileIds = new ArrayList<>(); + String sql = "select " + localFileColumn + ",dzqms,xdfsl,"+eqbAppIdColumnName+","+eqbAppSecretColumnName+" from " + billTableName + " where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, sql, requestId); + String eqbFileIdString = firstData1.get(localFileColumn.toLowerCase(Locale.ROOT)); + String dzqms = firstData1.get("dzqms"); + String xdfsl = firstData1.get("xdfsl"); + String eqbAppId = firstData1.get(eqbAppIdColumnName.toLowerCase(Locale.ROOT)); + String eqbAppSecret = firstData1.get(eqbAppSecretColumnName.toLowerCase(Locale.ROOT)); + if("".equals(eqbFileIdString) || eqbFileIdString == null){ + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("文件未上传至e签宝!"); + return Action.FAILURE_AND_CONTINUE; + } + String[] idArr = eqbFileIdString.split(","); + for(String id : idArr){ + eqbFileIds.add(id); + } + /*for(Map m : imageFileIds){ + String imageFileId = m.get("imagefileid"); + String eqbFileId = EqbFileUploadUtil.uploadFile(imageFileId); + eqbFileIds.add(eqbFileId); + }*/ + //查询eqb中文件状态 + String checkUrlString = CommonSqlUtil.getSystemParamValue("eqbCheckStatusUrl",rs); + String _url = ""; + for(String fileId : idArr){ + _url = checkUrlString + fileId; + URL checkUrl = new URL(_url); + Map checkHeaders = EqbRequestHeaderUtil.getHeaders(null,"", "GET", checkUrl.getPath(),eqbAppId,eqbAppSecret); + //调用e签宝接口 校验文件状态 + Map post = TjwHttpUtil.sendHttpRequest(_url, "", "GET", ContentType.APPLICATION_JSON, checkHeaders); + String res = (String) post.get("data"); + JSONObject resObj = JSONObject.parseObject(res); + String code =resObj.get("code") + ""; + if(!"0".equals(code)){ + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("文件还未上传至E签宝中,fileId:" + fileId + ";请稍后重试!"); + return Action.FAILURE_AND_CONTINUE; + } + } + logger.info("checkFileStatus DONE"); + + //--------------------------------------基于文件发起签署 + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = requestInfo.getRequestManager().getRemark(); + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId); + if(firstData.size() > 0){ + base_array[4] = firstData.get("id"); + } + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + //接口地址 + String createWorkFlowUrlString = CommonSqlUtil.getSystemParamValue("eqbCreateWorkFlowUrl",rs); + //请求体 + JSONObject jsonEntity = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,base_array); + JSONArray docs = new JSONArray(); + for(String eqbFileId : eqbFileIds){ + JSONObject o = new JSONObject(); + o.put("fileId",eqbFileId); + docs.add(o); + } + jsonEntity.put("docs",docs); + + //处理signFields + JSONArray signers = (JSONArray) jsonEntity.getJSONArray("signers").clone(); + logger.info("signers:" + signers); + JSONArray newSigners = new JSONArray(); + for(int i = 0;i < signers.size(); i++) { + JSONObject signer = signers.getJSONObject(i); + if ("0".equals(dzqms)) { + String cusdzqms = signer.getString("cusdzqms"); + if ("1".equals(cusdzqms)) { + continue; + } + } + if ("1".equals(dzqms)) { + String qsflx = signer.getString("qsflx"); + if ("0".equals(xdfsl)) { + if ("2".equals(qsflx) || "3".equals(qsflx)) { + continue; + } + } + if ("1".equals(xdfsl)) { + if ("3".equals(qsflx)) { + continue; + } + } + } + signer.remove("cusdzqms"); + + boolean autoSign = true; + JSONArray signFields = signer.getJSONArray("signFields"); + if(signFields != null && signFields.size() > 0){ + for(int j = 0;j 0){ + for(int j = 0;j headers = EqbRequestHeaderUtil.getHeaders(null, jsonEntity.toJSONString(), "POST", createWorkFlowUrl.getPath(),eqbAppId,eqbAppSecret); + //调用e签宝接口 发起签章流程 + Map post = TjwHttpUtil.sendHttpRequest(createWorkFlowUrlString, jsonEntity.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String response = (String) post.get("data"); + JSONObject res = JSONObject.parseObject(response); + String signFlowId = res.getJSONObject("data").getString("signFlowId"); + //建模中记录数据用于后续查询状态 + JSONObject modeDataJson = new JSONObject(); + modeDataJson.put("oarequestid",requestId); + modeDataJson.put("signflowid",signFlowId); + TjwModelUtil.addModelData(rs,"uf_eqbsigninfo",modeDataJson); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("CreateEqbWorkflowAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("CreateEqbWorkflowAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/EqbUploadFileAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/EqbUploadFileAction.java new file mode 100644 index 0000000..74d133f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/EqbUploadFileAction.java @@ -0,0 +1,194 @@ +package com.api.taojw.xmzx.action; + +import com.api.taojw.xmzx.util.EqbFileUploadUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; + +import java.util.*; + +/** + * 调用e签宝接口上传文件 + */ +public class EqbUploadFileAction implements Action { + + //存放待签署文件的流程字段名称 + private String fileColumns = ""; + public String getFileColumns() { + return fileColumns; + } + public void setFileColumns(String fileColumns) { + this.fileColumns = fileColumns; + } + private String configId = ""; + public String getConfigId() { + return configId; + } + public void setConfigId(String configId) { + this.configId = configId; + } + private String localFileColumn = ""; + + public String getLocalFileColumn() { + return localFileColumn; + } + + public void setLocalFileColumn(String localFileColumn) { + this.localFileColumn = localFileColumn; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------;fileColumns:" + fileColumns); + //获取要签署的文件 + if(fileColumns == null || "".equals(fileColumns)){ + return Action.SUCCESS; + } + + String billTableName = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + + String eqbAppIdColumnName = CommonSqlUtil.getSystemParamValue("eqbAppIdColumnName",rs); + String eqbAppSecretColumnName = CommonSqlUtil.getSystemParamValue("eqbAppSecretColumnName",rs); + String getConfigInfoSql = "select " + eqbAppIdColumnName + "," + eqbAppSecretColumnName + " from " + billTableName + " where requestId = ?"; + Map firstData2 = DaoUtil.getFirstData(rs, getConfigInfoSql, requestId); + String eqbAppId = firstData2.get(eqbAppIdColumnName.toLowerCase(Locale.ROOT)); + String eqbAppSecret = firstData2.get(eqbAppSecretColumnName.toLowerCase(Locale.ROOT)); + + List docIdS = new ArrayList<>(); + List> imageFileIds = new ArrayList<>(); + String[] fileColumnArr = fileColumns.split(","); + for(String col : fileColumnArr){ + String getDocIdSql = "select " + col + " from " + billTableName + " t1 where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDocIdSql, requestId); + String docIds = firstData.get(col.toLowerCase(Locale.ROOT)); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArr = docIds.split(","); + for(String docId : docIdArr){ + docIdS.add(docId); + } + } + } + String getImageFileIdSql = "select imagefileid,imagefilename from DocImageFile where docid = ? order by versionid desc"; + for(String docId : docIdS){ + Map firstData = DaoUtil.getFirstData(rs, getImageFileIdSql, docId); + Map m = new HashMap<>(); + m.put("imagefileid",firstData.get("imagefileid")); + m.put("imagefilename",firstData.get("imagefilename")); + imageFileIds.add(m); + } + //遍历待签署文件,调用e签宝接口,上传文件 + String eqbFileIdString = ""; + List eqbFileIds = new ArrayList<>(); + for(Map m : imageFileIds){ + String imageFileId = m.get("imagefileid"); + String eqbFileId = EqbFileUploadUtil.uploadFile(imageFileId,eqbAppId,eqbAppSecret); + if(eqbFileId != null && !"".equals(eqbFileId)){ + if("".equals(eqbFileIdString)){ + eqbFileIdString = eqbFileId; + }else{ + eqbFileIdString = eqbFileIdString + "," + eqbFileId; + } + } + eqbFileIds.add(eqbFileId); + } + + String updateSql = "update " + billTableName + " set " + localFileColumn + " = ? where requestid = ?"; + DaoUtil.updateData(rs,updateSql,eqbFileIdString,requestId); + logger.info("requestId:" + requestId + ";eqbFileIdString:" + eqbFileIdString); + return Action.SUCCESS; + + //--------------------------------------基于文件发起签署 + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + /*String[] base_array = new String[5]; + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = requestInfo.getRequestManager().getRemark(); + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId); + if(firstData.size() > 0){ + base_array[4] = firstData.get("id"); + } + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + //接口地址 + String createWorkFlowUrlString = CommonSqlUtil.getSystemParamValue("eqbCreateWorkFlowUrl",rs); + //请求体 + JSONObject jsonEntity = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,base_array); + JSONArray docs = new JSONArray(); + for(String eqbFileId : eqbFileIds){ + JSONObject o = new JSONObject(); + o.put("fileId",eqbFileId); + docs.add(o); + } + jsonEntity.put("docs",docs); + + //处理signFields + JSONArray signers = jsonEntity.getJSONArray("signers"); + for(int i = 0;i < signers.size(); i++){ + JSONObject signer = signers.getJSONObject(i); + JSONArray signFields = signer.getJSONArray("signFields"); + if(signFields != null && signFields.size() > 0){ + for(int j = 0;j headers = EqbRequestHeaderUtil.getHeaders(null, jsonEntity.toJSONString(), "POST", createWorkFlowUrl.getPath()); + //调用e签宝接口 发起签章流程 + Map post = TjwHttpUtil.sendHttpRequest(createWorkFlowUrlString, jsonEntity.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String response = post.get("data"); + JSONObject res = JSONObject.parseObject(response); + String signFlowId = res.getJSONObject("data").getString("signFlowId"); + //建模中记录数据用于后续查询状态 + JSONObject modeDataJson = new JSONObject(); + modeDataJson.put("oarequestid",requestId); + modeDataJson.put("signflowid",signFlowId); + TjwModelUtil.addModelData(rs,"uf_eqbsigninfo",modeDataJson); + return Action.SUCCESS;*/ + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("CreateEqbWorkflowAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("CreateEqbWorkflowAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsBackAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsBackAction.java new file mode 100644 index 0000000..55dc363 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsBackAction.java @@ -0,0 +1,65 @@ +package com.api.taojw.xmzx.action; + +import com.api.taojw.xmzx.util.UpdateFpStatus; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.fna.invoice.common.FnaInvoiceCommon; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwFpUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * bill流程退回action + * + */ +public class NsBackAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String checkFpYbxSql = "select count(1) as c from uf_ybxfp where fphm = ?"; + String getDetailDataSql = "select * from " + billTableName + "_dt3 where mainid = (select id from " + billTableName + " where requestid = ?)"; + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + + FnaInvoiceCommon util = new FnaInvoiceCommon(); + util.doWfForceOver(Integer.parseInt(requestId)); + TjwFpUtil fpUtil = new TjwFpUtil(); + for(Map m : data){ + String fphm = m.get("fphm"); + Map firstData2 = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData2.get("cloudid"); + fpUtil.updateFpStatusInCloudCommon(user,cloudId,"0","",requestId,"",""); + + //若发票已报销 将其置为已报销 + if(DaoUtil.isDataExists(rs,checkFpYbxSql,fphm)){ + UpdateFpStatus.updateStatusToYbxWithoutRequestId(fphm,user,requestId); + } + } + + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("----------------------" + this.getClass() + "NsBeginAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsBeginAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsBeginAction.java new file mode 100644 index 0000000..1c96c20 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsBeginAction.java @@ -0,0 +1,80 @@ +package com.api.taojw.xmzx.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwFpUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * NS触发bill流程后,将明细表中发票转为报销中 + */ +public class NsBeginAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + String updateFpStatusSql = "update fnainvoiceledger set status = 1 where invoiceNumber = ?"; + String getDetailDataSql = "select * from " + billTableName + "_dt3 where mainid = (select id from " + billTableName + " where requestid = ?)"; + String updateStatusSql = "update " + billTableName + "_dt3 set fpzt = 2 where id = ?"; + String updateInfoSql = + "update " + billTableName + "_dt3 set " + + "fphmll = (select id from fnainvoiceledger where invoiceNumber = ?)," + + "gmfnsrsbh = (select purchasertaxno from fnainvoiceledger where invoiceNumber = ?), " + + "hxzt = case when ye > 0 then 1 else 0 end ," + + "invoice_type = (select id from uf_fplx where name = ?) " + + "where " + + "id = ?"; + + String requestMark = ""; + String requestName = ""; + String getRequestMarkSql = "select * from workflow_requestbase where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getRequestMarkSql, requestId); + requestMark = firstData1.get("requestmark"); + requestName = firstData1.get("requestname"); + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + for(Map m : data){ + String fpzt = m.get("fpzt"); + if(!"2".equals(fpzt)){ + DaoUtil.updateData(rs,updateStatusSql,m.get("id")); + } + String fphm = m.get("fphm"); + try{ + DaoUtil.updateData(rs,updateInfoSql,fphm,fphm,m.get("fplx"), m.get("id")); + logger.info("update fp status begin;fphm:" + fphm); + + Map firstData = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData.get("cloudid"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"1",m.get("hxje"),requestId,requestMark,requestName); + + DaoUtil.updateData(rs,updateFpStatusSql,fphm); + }catch (Throwable e){ + logger.info("update fp status error;fphm:" + fphm + ";message:" + e.getMessage()); + } + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NsBeginAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NsBeginAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsCheckAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsCheckAction.java new file mode 100644 index 0000000..1764eed --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsCheckAction.java @@ -0,0 +1,86 @@ +package com.api.taojw.xmzx.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.fna.invoice.common.FnaInvoiceCommon; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * 同一张发票的核销金额不能超过 价税合计金额 + * + */ +public class NsCheckAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String billRejectTableName = CommonSqlUtil.getSystemParamValue("billrejecttablename",rs); + String getDetailDataSql = "select * from " + billTableName + "_dt3 where mainid = (select id from " + billTableName + " where requestid = ?)"; + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + String getAllAmountSql = "select sum(t1.hxje) as je from " + billTableName + "_dt3 t1 " + + "inner join "+billTableName+" t2 on t2.id = t1.mainid " + + "inner join workflow_requestbase t3 on t3.requestid = t2.requestid " + + "where t1.fphm = ? and t3.currentnodetype != 0 " + + "and t2.requestid not in (select billlc from " + billRejectTableName + ") "; + String getMaxJeSql = "select taxincludedprice as maxje from fnainvoiceledger where invoicenumber = ?"; + FnaInvoiceCommon util = new FnaInvoiceCommon(); + util.doWfForceOver(Integer.parseInt(requestId)); + for(Map m : data){ + String fphm = m.get("fphm"); + Map firstData = DaoUtil.getFirstData(rs, getAllAmountSql, fphm); + + Double sumje = 0d; + try{ + sumje = Double.valueOf(firstData.get("je")); + }catch (Exception e){ + + } + + firstData = DaoUtil.getFirstData(rs, getMaxJeSql, fphm); + Double maxje = 0d; + try{ + maxje = Double.valueOf(firstData.get("maxje")); + }catch (Exception e){ + + } + + if(sumje > maxje){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("发票:"+fphm+"的累计核销金额超过加税合计金额!"); + return Action.FAILURE_AND_CONTINUE; + } + String getCountSql = "select count(1) as c from uf_ybxfp where fphm = ?"; + if(DaoUtil.isDataExists(rs,getCountSql,fphm)){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("发票:"+fphm+"已报销!"); + return Action.FAILURE_AND_CONTINUE; + } + + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("----------------------" + this.getClass() + "NsBeginAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsEndAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsEndAction.java new file mode 100644 index 0000000..b448fed --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsEndAction.java @@ -0,0 +1,121 @@ +package com.api.taojw.xmzx.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.util.UpdateFpStatus; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.JsonConvertUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * bill流程办结后 + * 核销状态 且 余额=0 发票夹进入已报销状态 ,自动转入国信台账 + * 核销状态 且 金额不为0,自动转入抵扣台账 + */ +public class NsEndAction implements Action { + + Logger logger = MyLogger.getLogger(); + + //json数据转json配置数据id 映射bill流程明细数据和国信台账字段映射关系 + private String configId = ""; + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + String getDetailDataSql = "select * from " + billTableName + "_dt3 where mainid = (select id from " + billTableName + " where requestid = ?)"; + + String getRequestMarkSql = "select * from workflow_requestbase where requestid = ?"; + /*Map firstData1 = DaoUtil.getFirstData(rs, getRequestMarkSql, requestId); + String requestMark = firstData1.get("requestmark"); + String requestName = firstData1.get("requestname");*/ + + String getRequestIdSql = "select distinct t1.requestid from " + billTableName + " t1 inner join " + billTableName + "_dt3 t2 on t2.mainid = t1.id where t2.fphm = ?"; + String deleteDataInDkSql = "delete from uf_blckdktz where fphm = ?"; + + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + for(Map m : data){ + String fpzt = m.get("fpzt"); + Double ye = Util.getDoubleValue(m.get("ye")); + //状态不为核销的不处理 + if(!"2".equals(fpzt)){ + continue; + } + + String invoice_type = m.get("invoice_type"); + if((ye == 0 || "0.00".equals(m.get("ye"))) && (invoice_type == null || "".equals(invoice_type))){ + String fphm = m.get("fphm"); + UpdateFpStatus.updateStatusToYbx(fphm,user); + } + if((ye == 0 || "0.00".equals(m.get("ye"))) && invoice_type != null && !"".equals(invoice_type)){ + String fphm = m.get("fphm"); + UpdateFpStatus.updateStatusToYbx(fphm,user); + /*Map firstData = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData.get("cloudid"); + //余额为0的 发票夹进入已报销状态 ,自动转入国信台账 + List> data1 = DaoUtil.getData(rs, getRequestIdSql, fphm); + for(Map m1 : data1){ + String _requestId = m1.get("requestid"); + Map firstData11 = DaoUtil.getFirstData(rs, getRequestMarkSql, _requestId); + String requestMark = firstData11.get("requestmark"); + String requestName = firstData11.get("requestname"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",firstData.get("taxincludedprice"),_requestId,requestMark,requestName); + }*/ + JSONObject oldJson = new JSONObject(); + for(String key : m.keySet()){ + oldJson.put(key,m.get(key)); + } + JSONObject gxJson = JsonConvertUtil.convertJsonByConfig(oldJson,configId); + logger.info("gxJson:" + gxJson.toJSONString()); + TjwModelUtil.addModelData(rs,"uf_data_invoice",gxJson); + }else{ + //金额不为0,自动转入抵扣台账 + /*JSONObject oldJson = new JSONObject(); + for(String key : m.keySet()){ + oldJson.put(key,m.get(key)); + } + JSONObject gxJson = JsonConvertUtil.convertJsonByConfig(oldJson,configId); + logger.info("gxJson:" + gxJson.toJSONString()); + TjwModelUtil.addModelData(rs,"uf_data_invoice",gxJson);*/ + } + if(ye == 0 || "0.00".equals(m.get("ye"))){ + DaoUtil.updateData(rs,deleteDataInDkSql,m.get("fphm")); + } + if(ye != 0 && !"0.00".equals(m.get("ye"))){ + + } + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NsEndAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NsEndAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsRejectAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsRejectAction.java new file mode 100644 index 0000000..2823e41 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsRejectAction.java @@ -0,0 +1,82 @@ +package com.api.taojw.xmzx.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.fna.invoice.common.FnaInvoiceCommon; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwFpUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * 提交判断 进行中和成功的 不允许提交(只要流程中有一张发票 在国信台账是这个状态),其余状态 流程办结后,删除国信、抵扣相关发票数据,然后发票信息变成冻结状态 + */ +public class NsRejectAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getStatusInGuoxinSql = "select * from uf_data_invoice where invoice_number = ?"; + String deleteDataInDkModeSql = "delete from uf_blckdktz where fphm = ?"; + String deleteDataInGxModeSql = "delete from uf_data_invoice where invoice_number = ?"; + String getDetailDataSql = "select * from " + billTableName + "_dt1 where mainid = (select id from " + billTableName + " where requestid = ?)"; + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + for(Map m : data){ + String fphm = m.get("fphm"); + Map firstData = DaoUtil.getFirstData(rs, getStatusInGuoxinSql, fphm); + if("1".equals(firstData.get("deductible_result")) || "2".equals(firstData.get("deductible_result")) || "4".equals(firstData.get("deductible_result")) || "6".equals(firstData.get("deductible_result"))){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("国信台账中存在进行中或成功状态的发票,不允许提交!"); + return Action.FAILURE_AND_CONTINUE; + } + } + String getTableSql = "select billlc from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getTableSql, requestId); + int billlc = Integer.parseInt(firstData.get("billlc")); + FnaInvoiceCommon util = new FnaInvoiceCommon(); + util.doWfForceOver(billlc); + TjwFpUtil fpUtil = new TjwFpUtil(); + for(Map m : data){ + String fphm = m.get("fphm"); + Map firstData2 = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData2.get("cloudid"); + fpUtil.updateFpStatusInCloudCommon(user,cloudId,"0","",billlc+"","",""); + } + + for(Map m : data){ + String fphm = m.get("fphm"); + DaoUtil.updateData(rs,deleteDataInDkModeSql,fphm); + DaoUtil.updateData(rs,deleteDataInGxModeSql,fphm); + } + String deleteSql = "delete from uf_ybxfp where fphm = ?"; + for(Map m : data){ + String fphm = m.get("fphm"); + DaoUtil.updateData(rs,deleteSql,fphm); + } + + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NsBeginAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NsBeginAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsRejectCheckAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsRejectCheckAction.java new file mode 100644 index 0000000..30dfdca --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/NsRejectCheckAction.java @@ -0,0 +1,57 @@ +package com.api.taojw.xmzx.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * 提交判断 进行中和成功的 不允许提交(只要流程中有一张发票 在国信台账是这个状态), + */ +public class NsRejectCheckAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getStatusInGuoxinSql = "select * from uf_data_invoice where invoice_number = ?"; + String deleteDataInDkModeSql = "delete from uf_blckdktz where fphm = ?"; + String deleteDataInGxModeSql = "delete from uf_data_invoice where invoice_number = ?"; + String getDetailDataSql = "select * from " + billTableName + "_dt1 where mainid = (select id from " + billTableName + " where requestid = ?)"; + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + for(Map m : data){ + String fphm = m.get("fphm"); + Map firstData = DaoUtil.getFirstData(rs, getStatusInGuoxinSql, fphm); + if("1".equals(firstData.get("deductible_result")) || "2".equals(firstData.get("deductible_result")) || "4".equals(firstData.get("deductible_result")) || "6".equals(firstData.get("deductible_result"))){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("国信台账中存在进行中或成功状态的发票,不允许提交!"); + return Action.FAILURE_AND_CONTINUE; + } + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NsBeginAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NsBeginAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/SubmitPrAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/SubmitPrAction.java new file mode 100644 index 0000000..4ee70ad --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/SubmitPrAction.java @@ -0,0 +1,55 @@ +package com.api.taojw.xmzx.action; + +import com.api.taojw.xmzx.util.ModelDataUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.*; + +/** + * 小马智行action + * 提交action + * 流程提交后,根据明细表的PR勾选字段 找到建模中的数据, 更新建模的剩余数量为 申请数量减去 + * 剩余数量 减去流程明细中的数量,修改后的剩余数量应该大于0,否则不允许提交流程; + */ +public class SubmitPrAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestName = requestInfo.getRequestManager().getRequestname(); + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTable = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + //获取明细表中的数据 + String getDetailDataSql = + "select prgx,quantity,itemwb from " + billTable + "_dt1 where mainid = (select id from " + billTable + " where requestid = ?)"; + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + String res = ModelDataUtil.plusQuantity(data); + if("Exception08".equals(res)){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("SubmitPrAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + if("Success09".equals(res)){ + return Action.SUCCESS; + } + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("明细表中" + res + "对应的数量超过申请数量,请修改后提交!"); + return Action.FAILURE_AND_CONTINUE; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("SubmitPrAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("SubmitPrAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/UpdateNameAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/UpdateNameAction.java new file mode 100644 index 0000000..38f1a45 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/action/UpdateNameAction.java @@ -0,0 +1,74 @@ +package com.api.taojw.xmzx.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSetTrans; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; + +/** + * 小马智行action + * 提交action + * 流程提交后,根据明细表的PR勾选字段 找到建模中的数据, 更新建模的剩余数量为 申请数量减去 + * 剩余数量 减去流程明细中的数量,修改后的剩余数量应该大于0,否则不允许提交流程; + */ +public class UpdateNameAction implements Action { + + private String columnName = ""; + + public String getColumnName() { + return columnName; + } + + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + RecordSetTrans rsTrans = requestInfo.getRsTrans(); + if(rsTrans == null){ + rsTrans = new RecordSetTrans(); + } + String updateSql = "update workflow_requestbase set requestname = 'waibiwaibi' where requestid = ?"; + try { + rsTrans.executeUpdate(updateSql,requestId); + } catch (Exception e) { + throw new RuntimeException(e); + } + logger.info("----------------------" + this.getClass() + " action end ----------------------newName:" + ";requestId:" + requestId + ";result:"); + return Action.SUCCESS; + + + /*new Thread(){ + @Override + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + try{ + + RecordSet rs = new RecordSet(); + + String getDataSql = "select " + columnName + " from " + requestInfo.getRequestManager().getBillTableName() + " where requestid = " +requestId; + Map firstData = DaoUtil.getFirstData(rs, getDataSql); + String newName = firstData.get(columnName.toLowerCase(Locale.ROOT)); + boolean b = rs.executeUpdate(updateSql, newName, requestId); + logger.info("----------------------" + this.getClass() + " action end ----------------------newName:" + newName + ";requestId:" + requestId + ";result:" + b); + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("BackPrAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("BackPrAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + } + } + }.start(); + return Action.SUCCESS;*/ + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/AddDataToGuoxinFromDkApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/AddDataToGuoxinFromDkApi.java new file mode 100644 index 0000000..f5d88ac --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/AddDataToGuoxinFromDkApi.java @@ -0,0 +1,88 @@ +package com.api.taojw.xmzx.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.util.UpdateFpStatus; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.JsonConvertUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * 小马智行 + * 抵扣台账中勾选记录点击后将数据同步至国信台账 + */ +@Path("/xmzxtjwdk") +public class AddDataToGuoxinFromDkApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/doSend") + @Produces(MediaType.APPLICATION_JSON) + public String doSend(@Context HttpServletRequest request, @Context HttpServletResponse response){ + //勾选的抵扣台账记录数据id + String ids = Util.null2String(request.getParameter("ids")); + logger.info("AddDataToGuoxinFromDkApi.doSend begin;ids:" + ids); + if("".equals(ids)){ + return ""; + } + try{ + RecordSet rs = new RecordSet(); + String configId = CommonSqlUtil.getSystemParamValue("dktogx",rs); + String[] idArr = ids.split(","); + //String getDataSql = "select * from uf_blckdktz where id = ?"; + String getDataSql = + "select " + + "t1.*,t2.requestmark,t2.requestname,t2.requestid,t2.creater " + + "from " + + "uf_blckdktz t1 " + + "inner join workflow_requestbase t2 on t2.requestid = t1.fromrequestid " + + "where " + + "t1.id = ?"; + + String deleteSql = "delete from uf_blckdktz where id = ?"; + for(String id:idArr){ + Map firstData = DaoUtil.getFirstData(rs, getDataSql, id); + JSONObject oldJson = new JSONObject(); + for(String key : firstData.keySet()){ + oldJson.put(key,firstData.get(key)); + } + JSONObject gxJson = JsonConvertUtil.convertJsonByConfig(oldJson,configId); + TjwModelUtil.addModelData(rs,"uf_data_invoice",gxJson); + + //发票夹进入已报销状态 + + String fphm = firstData.get("fphm"); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData1.get("cloudid"); + User user = new User(Integer.parseInt(firstData.get("creater"))); + UpdateFpStatus.updateStatusToYbx(fphm,user); + //TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",firstData1.get("taxincludedprice"),firstData.get("fromrequestid"),firstData.get("requestmark"),firstData.get("requestname")); + + //删除抵扣台账数据 + DaoUtil.updateData(rs,deleteSql,id); + } + logger.info("AddDataToGuoxinFromDkApi.doSend done;"); + }catch(Throwable e){ + logger.error("AddDataToGuoxinFromDkApi.doSend exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/DoSendToNsApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/DoSendToNsApi.java new file mode 100644 index 0000000..efb0055 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/DoSendToNsApi.java @@ -0,0 +1,77 @@ +package com.api.taojw.xmzx.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.cronjob.SendFpInfoToNsCronjob; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.JsonConvertUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + + +@Path("/xmzxtjwns") +public class DoSendToNsApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/doSendToNs") + @Produces(MediaType.APPLICATION_JSON) + public String updatePoStatusApi(@Context HttpServletRequest request, @Context HttpServletResponse response){ + logger.info("DoSendToNsApi.doSendToNs begin;"); + try{ + SendFpInfoToNsCronjob job = new SendFpInfoToNsCronjob(); + job.execute(); + logger.info("DoSendToNsApi.doSendToNs done;"); + }catch(Throwable e){ + logger.error("DoSendToNsApi.doSendToNs exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + @POST + @Path("/doSendToGx") + @Produces(MediaType.APPLICATION_JSON) + public String doSendToGx(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String ids = Util.null2String(request.getParameter("ids")); + String configId = Util.null2String(request.getParameter("configId")); + logger.info("DoSendToNsApi.doSendToGx begin;ids:" + ids); + if("".equals(ids)){ + return ""; + } + try{ + RecordSet rs = new RecordSet(); + String[] idArr = ids.split(","); + String getDataSql = "select * form uf_blckdktz where id = ?"; + + for(String id:idArr){ + Map firstData = DaoUtil.getFirstData(rs, getDataSql, id); + JSONObject oldJson = new JSONObject(); + for(String key : firstData.keySet()){ + oldJson.put(key,firstData.get(key)); + } + JSONObject gxJson = JsonConvertUtil.convertJsonByConfig(oldJson,configId); + TjwModelUtil.addModelData(rs,"uf_data_invoice",gxJson); + } + SendFpInfoToNsCronjob job = new SendFpInfoToNsCronjob(); + job.execute(); + logger.info("DoSendToNsApi.doSendToGx done;"); + }catch(Throwable e){ + logger.error("DoSendToNsApi.doSendToGx exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/GetUrlApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/GetUrlApi.java new file mode 100644 index 0000000..7343dcb --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/GetUrlApi.java @@ -0,0 +1,82 @@ +package com.api.taojw.xmzx.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.util.EqbRequestHeaderUtil; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.net.URL; +import java.util.Locale; +import java.util.Map; + + +@Path("/xmzxtjweqb") +public class GetUrlApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/getUrl") + @Produces(MediaType.APPLICATION_JSON) + public String getUrl(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String requestId = Util.null2String(request.getParameter("requestId")); + logger.info("GetUrlApi.getUrl begin;requestId:" + requestId); + if("".equals(requestId)){ + return ""; + } + try{ + JSONObject result = new JSONObject(); + RecordSet rs = new RecordSet(); + String eqbAppIdColumnName = CommonSqlUtil.getSystemParamValue("eqbAppIdColumnName",rs); + String eqbAppSecretColumnName = CommonSqlUtil.getSystemParamValue("eqbAppSecretColumnName",rs); + String getLinkUrlString = CommonSqlUtil.getSystemParamValue("getLinkUrl",rs); + + //根据requestId找到workFlowId + String getWorkFlowIdSql = "select signflowid from uf_eqbsigninfo where oarequestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getWorkFlowIdSql, requestId); + String signFlowId = firstData.get("signflowid"); + if(signFlowId == null || "".equals(signFlowId)){ + return ""; + } + JSONObject jsonEntity = new JSONObject(); + jsonEntity.put("signFlowId",signFlowId); + JSONObject operator = new JSONObject(); + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + String getDataSql = "select wflxrsjh,"+eqbAppIdColumnName+","+eqbAppSecretColumnName+" from " + tableName + " where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getDataSql, requestId); + String wflxrsjh = firstData1.get("wflxrsjh"); + String eqbAppId = firstData1.get(eqbAppIdColumnName.toLowerCase(Locale.ROOT)); + String eqbAppSecret = firstData1.get(eqbAppSecretColumnName.toLowerCase(Locale.ROOT)); + operator.put("psnAccount",wflxrsjh); + jsonEntity.put("operator",operator); + getLinkUrlString = getLinkUrlString.replace("signFlowId",signFlowId); + //请求头 + URL getLinkUrl = new URL(getLinkUrlString); + Map headers = EqbRequestHeaderUtil.getHeaders(null, jsonEntity.toJSONString(), "POST", getLinkUrl.getPath(),eqbAppId,eqbAppSecret); + //调用e签宝接口 发起签章流程 + Map post = TjwHttpUtil.sendHttpRequest(getLinkUrlString, jsonEntity.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String resData = (String) post.get("data"); + JSONObject resDataJson = JSONObject.parseObject(resData); + String url = resDataJson.getJSONObject("data").getString("url"); + result.put("url",url); + logger.info("GetUrlApi.getUrl done;"); + return result.toJSONString(); + }catch(Throwable e){ + logger.error("GetUrlApi.getUrl exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/UpdatePoStatusApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/UpdatePoStatusApi.java new file mode 100644 index 0000000..de7faf0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/api/UpdatePoStatusApi.java @@ -0,0 +1,50 @@ +package com.api.taojw.xmzx.api; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + + +@Path("/xmzxtjwpo") +public class UpdatePoStatusApi { + + Logger logger = MyLogger.getLogger(); + + @GET + @Path("/updatePoStatusApi") + @Produces(MediaType.APPLICATION_JSON) + public String updatePoStatusApi(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String ids = Util.null2String(request.getParameter("ids")); + logger.info("UpdatePoStatusApi.updatePoStatusApi begin;ids:" + ids); + if("".equals(ids)){ + return ""; + } + try{ + RecordSet rs = new RecordSet(); + String getCurrentStatusSql = "select sfybpogl from uf_prlcgx where id = ?"; + String updateStatusSql = "update uf_prlcgx set sfybpogl = ? where id = ? and sfybpogl = 0"; + String[] idArr = ids.split(","); + for(String id : idArr){ + Map firstData = DaoUtil.getFirstData(rs, getCurrentStatusSql, id); + if("".equals(firstData.get("sfybpogl")) || firstData.get("sfybpogl") == null || "0".equals(firstData.get("sfybpogl"))){ + DaoUtil.updateData(rs,updateStatusSql,"1",id); + } + } + logger.info("MultiSubmitApi.multiSubmitApi done;"); + }catch(Throwable e){ + logger.error("MultiSubmitApi.multiSubmitApi exception;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/GetEqbFileCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/GetEqbFileCronjob.java new file mode 100644 index 0000000..d3ccad0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/GetEqbFileCronjob.java @@ -0,0 +1,104 @@ +package com.api.taojw.xmzx.cronjob; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.util.EqbRequestHeaderUtil; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.InputStream; +import java.net.URL; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 小马智行 + * 定时任务获取e签宝文件签署信息 + * 回写到流程表单 + */ +public class GetEqbFileCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + // + private String seccategory = ""; + private String uploadUser = ""; + private String workFlowTableName = ""; + private String workFlowColumn = ""; + + @Override + public void execute() { + try{ + RecordSet rs = new RecordSet(); + String eqbAppIdColumnName = CommonSqlUtil.getSystemParamValue("eqbAppIdColumnName",rs); + String eqbAppSecretColumnName = CommonSqlUtil.getSystemParamValue("eqbAppSecretColumnName",rs); + //查询建模中的数据 + String getModelDataSql = "select * from uf_eqbsigninfo"; + List> data = DaoUtil.getData(rs, getModelDataSql); + //遍历建模数据 调用e签宝接口 获取附件回写到对应的流程表单中 处理成功后删除建模数据 + //接口地址 + String eqbGetFileUrlString = CommonSqlUtil.getSystemParamValue("eqbGetFileUrl",rs); + + //更新流程表单附件字段 + String updateWorkflowSql = "update " + workFlowTableName + " set " + workFlowColumn + " = ? where requestId = ?"; + String getConfigInfoSql = "select " + eqbAppIdColumnName + "," + eqbAppSecretColumnName + " from " + workFlowTableName + " where requestId = ?"; + + String deleteSql = "delete from uf_eqbsigninfo where id = ?"; + + String url = ""; + for(Map m : data){ + try{ + Map firstData = DaoUtil.getFirstData(rs, getConfigInfoSql, m.get("oarequestid")); + String eqbAppId = firstData.get(eqbAppIdColumnName.toLowerCase(Locale.ROOT)); + String eqbAppSecret = firstData.get(eqbAppSecretColumnName.toLowerCase(Locale.ROOT)); + + //请求体 + JSONObject jsonEntity = new JSONObject(); + jsonEntity.put("signFlowId",m.get("signflowid")); + url = eqbGetFileUrlString.replaceAll("\\{signFlowId}",m.get("signflowid")); + //请求头 + URL eqbGetFileUrlUrl = new URL(url); + Map headers = EqbRequestHeaderUtil.getHeaders(null, null, "GET", eqbGetFileUrlUrl.getPath(),eqbAppId,eqbAppSecret); + //调用e签宝接口 获取签署好的附件 + Map post = TjwHttpUtil.sendHttpRequest(url, "", "GET", ContentType.APPLICATION_JSON, headers); + String response = (String) post.get("data"); + JSONObject res = JSONObject.parseObject(response); + JSONObject resData = res.getJSONObject("data"); + JSONArray files = resData.getJSONArray("files"); + String docIds = ""; + for(int i = 0; i < files.size(); i++){ + JSONObject o = (JSONObject) files.get(i); + String downloadUrl = o.getString("downloadUrl"); + String fileName = o.getString("fileName"); + InputStream inputStream = TjwHttpUtil.httpGetDownloadFile(downloadUrl, null, fileName); + int imageFileIdByInputSteam = TjwDocumentUtil.createFileByInputSteam(inputStream, fileName); + int docByImageFileId = TjwDocumentUtil.createDocByImageFileId(fileName, Integer.parseInt(seccategory), imageFileIdByInputSteam, Integer.parseInt(uploadUser)); + if("".equals(docIds)){ + docIds = docByImageFileId + ""; + }else { + docIds = docIds + "," + docByImageFileId; + } + } + if(!"".equals(docIds)){ + DaoUtil.updateData(rs,updateWorkflowSql,docIds,m.get("oarequestid")); + DaoUtil.updateData(rs,deleteSql,m.get("id")); + } + }catch (Throwable e){ + logger.error("get file from eqb error;requestid:" + m.get("oarequestid") + ";eqbid:" + m.get("signflowid")); + continue; + } + } + }catch (Throwable e){ + logger.error("GetEqbFileCronjob exception;message:" + e.getMessage() + ";e:" + e); + } + + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/SendFpInfoToNsCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/SendFpInfoToNsCronjob.java new file mode 100644 index 0000000..955a27f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/SendFpInfoToNsCronjob.java @@ -0,0 +1,294 @@ +package com.api.taojw.xmzx.cronjob; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.*; + +/** + * 小马智行 + * 定时任务发送发票夹中发生变更的发票到NS + * 数据库中配了触发器,监控发票台账表中的数据变化,增删改后新增记录到相应的记录表中,此定时任务遍历记录表中的记录调用NS接口,完成后删除记录表数据 + * 先处理新增 再处理修改 最后处理删除 + */ +public class SendFpInfoToNsCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + //OA发票台账和NS字段对应关系配置表的id + private String configId = ""; + public String getConfigId() { + return configId; + } + public void setConfigId(String configId) { + this.configId = configId; + } + //NS接口oauth认证相关参数 + private String consumerKey = ""; + private String consumerSecret = ""; + private String accessToken = ""; + private String accessTokenSecret = ""; + private String realmID = ""; + private String encryption = ""; + public String getConsumerKey() { + return consumerKey; + } + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getAccessTokenSecret() { + return accessTokenSecret; + } + + public void setAccessTokenSecret(String accessTokenSecret) { + this.accessTokenSecret = accessTokenSecret; + } + + public String getRealmID() { + return realmID; + } + + public void setRealmID(String realmID) { + this.realmID = realmID; + } + + public String getEncryption() { + return encryption; + } + + public void setEncryption(String encryption) { + this.encryption = encryption; + } + + //ns接口地址 + private String nsUrl = ""; + + public String getNsUrl() { + return nsUrl; + } + + public void setNsUrl(String nsUrl) { + this.nsUrl = nsUrl; + } + + + @Override + public void execute() { + //获取配置信息sql语句 + String getConfigInfoSql = "select nszd,oafpzd,zhgz,zdysql from uf_fptons_dt1 where mainid = ?"; + //获取删除标识配置信息sql语句 + String getDeleteConfigInfoSql = "select scbz,scbzz from uf_fptons where id = ?"; + //获取新增记录sql语句 + String getAddFpDataSql = "select * from fnainvoiceledger_cusadd"; + //删除新增记录sql语句 + String deleteInfoInAddTableSql = "delete from fnainvoiceledger_cusadd where id = ?"; + //获取更新记录sql语句 + String getUpdateFpDataSql = "select * from fnainvoiceledger_cusupdate order by create_datetime asc"; + //删除更新记录sql语句 + String deleteInfoInUpdateTableSql = "delete from fnainvoiceledger_cusupdate where id = ?"; + //获取删除记录sql语句 + String getDeleteFpDataSql = "select * from fnainvoiceledger_cusdelete"; + //删除删除记录sql语句 + String deleteInfoInDeleteTableSql = "delete from fnainvoiceledger_cusdelete where id = ?"; + + String getAllSql = "select * from ( " + + "select *,'0' as isdelete,'1' as ttyyppee from fnainvoiceledger_cusadd r1 " + + "union ALL " + + "select *,'0' as isdelete,'2' as ttyyppee from fnainvoiceledger_cusupdate " + + "union all " + + "select *,'1' as isdelete,'3' as ttyyppee from fnainvoiceledger_cusdelete) x order by x.create_datetime asc "; + + try{ + RecordSet rs = new RecordSet(); + + configId = CommonSqlUtil.getSystemParamValue("nsConfigId",rs); + consumerKey = CommonSqlUtil.getSystemParamValue("nsConsumerKey",rs); + consumerSecret = CommonSqlUtil.getSystemParamValue("nsConsumerSecret",rs); + accessToken = CommonSqlUtil.getSystemParamValue("nsAccessToken",rs); + accessTokenSecret = CommonSqlUtil.getSystemParamValue("nsAccessTokenSecret",rs); + realmID = CommonSqlUtil.getSystemParamValue("nsRealmID",rs); + encryption = CommonSqlUtil.getSystemParamValue("nsEncryption",rs); + nsUrl = CommonSqlUtil.getSystemParamValue("nsUrl",rs); + + logger.info("SendFpInfoToNsCronjob begin;configId:" + configId); + //oauth认证相关参数 + Map oauthConfigMap = new HashMap<>(); + oauthConfigMap.put("consumerKey",consumerKey); + oauthConfigMap.put("consumerSecret",consumerSecret); + oauthConfigMap.put("accessToken",accessToken); + oauthConfigMap.put("accessTokenSecret",accessTokenSecret); + oauthConfigMap.put("realmID",realmID); + oauthConfigMap.put("encryption",encryption); + + Map headers = new HashMap<>(); + headers.put("Content-Type","application/json"); + + //获取配置信息 用于转换数据 + Map> configMap = new HashMap<>(); + List> configData = DaoUtil.getData(rs, getConfigInfoSql, configId); + for(Map m:configData){ + configMap.put(m.get("nszd"),m); + } + + + Map firstData = DaoUtil.getFirstData(rs, getDeleteConfigInfoSql, configId); + String deleteKey = firstData.get("scbz"); + String deleteValue = firstData.get("scbzz"); + logger.info("allSql begin;allSql:" + getAllSql); + List> list = new ArrayList<>(); + if(rs.executeQuery(getAllSql)){ + while(rs.next()){ + Map m = new HashMap<>(); + for(String name:rs.getColumnName()){ + m.put(name.toLowerCase(Locale.ROOT),rs.getString(Util.null2String(rs.getString(name)))); + } + list.add(m); + } + } + + + List> allData = DaoUtil.getData(rs, getAllSql); + logger.info("getAllSql end;size:" + allData.size()); + for(Map fpInfo : allData){ + //将发票数据转为NS的json数据 + logger.info("send info to ns begin;no:" + fpInfo.get("incoicecode")); + JSONObject nsJson = getNsJsonByConfig(configMap,fpInfo); + if("1".equals(fpInfo.get("isdelete"))){ + nsJson.put(deleteKey,deleteValue); + } + Map post = TjwHttpUtil.sendHttpOAuthRequest(nsUrl, nsJson.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers, oauthConfigMap); + String res = post.get("data"); + try{ + JSONObject resJson = JSONObject.parseObject(res); + boolean success = resJson.getBoolean("success"); + if(success){ + if("1".equals(fpInfo.get("ttyyppee"))){ + DaoUtil.updateData(rs,deleteInfoInAddTableSql,fpInfo.get("id")); + } + if("2".equals(fpInfo.get("ttyyppee"))){ + DaoUtil.updateData(rs,deleteInfoInUpdateTableSql,fpInfo.get("id")); + } + if("3".equals(fpInfo.get("ttyyppee"))){ + DaoUtil.updateData(rs,deleteInfoInDeleteTableSql,fpInfo.get("id")); + } + } + }catch (Throwable e){ + logger.error("send info to ns error;no:" + fpInfo.get("incoicecode")); + } + } + + //获取记录表中新增的记录 + /*logger.info("getAddFpDataSql begin;getAddFpDataSql:" + getAddFpDataSql); + List> addData = DaoUtil.getData(rs, getAddFpDataSql); + logger.info("getAddFpDataSql end;size:" + addData.size()); + for(Map fpInfo : addData){ + //将发票数据转为NS的json数据 + logger.info("send info to ns begin;no:" + fpInfo.get("incoicecode")); + JSONObject nsJson = getNsJsonByConfig(configMap,fpInfo); + Map post = TjwHttpUtil.sendHttpOAuthRequest(nsUrl, nsJson.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers, oauthConfigMap); + String res = post.get("data"); + try{ + JSONObject resJson = JSONObject.parseObject(res); + boolean success = resJson.getBoolean("success"); + if(success){ + DaoUtil.updateData(rs,deleteInfoInAddTableSql,fpInfo.get("id")); + } + }catch (Throwable e){ + logger.error("send info to ns error;no:" + fpInfo.get("incoicecode")); + } + } + //获取记录表中修改的记录 + logger.info("getUpdateFpDataSql begin;getUpdateFpDataSql:" + getUpdateFpDataSql); + List> updateData = DaoUtil.getData(rs, getUpdateFpDataSql); + logger.info("getUpdateFpDataSql end;size:" + updateData.size()); + for(Map fpInfo : updateData){ + logger.info("update info to ns begin;no:" + fpInfo.get("incoicecode")); + //将发票数据转为NS的json数据 + JSONObject nsJson = getNsJsonByConfig(configMap,fpInfo); + Map post = TjwHttpUtil.sendHttpOAuthRequest(nsUrl, nsJson.toJSONString(), "POST", ContentType.APPLICATION_JSON,headers, oauthConfigMap); + String res = post.get("data"); + try{ + JSONObject resJson = JSONObject.parseObject(res); + boolean success = resJson.getBoolean("success"); + if(success){ + DaoUtil.updateData(rs,deleteInfoInUpdateTableSql,fpInfo.get("id")); + } + }catch (Throwable e){ + logger.error("update info to ns error;no:" + fpInfo.get("incoicecode")); + } + } + + logger.info("getDeleteFpDataSql begin;getDeleteFpDataSql:" + getDeleteFpDataSql); + List> deleteData = DaoUtil.getData(rs, getDeleteFpDataSql); + logger.info("getDeleteFpDataSql end;size:" + deleteData.size()); + for(Map fpInfo : deleteData){ + logger.info("delete info to ns begin;no:" + fpInfo.get("incoicecode")); + //将发票数据转为NS的json数据 + JSONObject nsJson = getNsJsonByConfig(configMap,fpInfo); + nsJson.put(deleteKey,deleteValue); + Map post = TjwHttpUtil.sendHttpOAuthRequest(nsUrl, nsJson.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers, oauthConfigMap); + String res = post.get("data"); + try{ + JSONObject resJson = JSONObject.parseObject(res); + boolean success = resJson.getBoolean("success"); + if(success){ + DaoUtil.updateData(rs,deleteInfoInDeleteTableSql,fpInfo.get("id")); + } + }catch (Throwable e){ + logger.error("update info to ns error;no:" + fpInfo.get("incoicecode")); + } + }*/ + logger.info("SendFpInfoToNsCronjob end"); + }catch (Throwable e){ + logger.error("SendFpInfoToNsCronjob exception;message:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 根据配置信息 将发票数据转为对应的NS数据 + * @param configMap 配置信息 + * @param fpInfo 发票西悉尼 + * @return 转换后的json + */ + private JSONObject getNsJsonByConfig(Map> configMap,Map fpInfo){ + try{ + //将发票信息转换为NS要求字段信息 + JSONObject nsJson = new JSONObject(); + for(String key : configMap.keySet()){ + Map configInfo = configMap.get(key); + nsJson.put(key, WorkFlowDataToJsonUtil.convertDataByZhgz(fpInfo.get(configInfo.get("oafpzd")),configInfo)); + } + return nsJson; + }catch(Throwable e){ + logger.error("getNsJsonByConfig error;configMap:" + configMap + ";fpInfo:" + fpInfo + ";message:" + e.getMessage()); + return new JSONObject(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/WorkflowDataToModeCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/WorkflowDataToModeCronjob.java new file mode 100644 index 0000000..e7d9450 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/cronjob/WorkflowDataToModeCronjob.java @@ -0,0 +1,90 @@ +package com.api.taojw.xmzx.cronjob; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.xmzx.util.UpdateFpStatus; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.JsonConvertUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.List; +import java.util.Map; + +/** + * 小马智行 + * 流程办结后 将进入抵扣台账的数据,7天(手动)转国信台账后 发票夹进入已报销状态 + */ +public class WorkflowDataToModeCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + //json数据转json配置数据id 映射bill流程明细数据和国信台账字段映射关系 + private String configId = ""; + public String getConfigId() { + return configId; + } + public void setConfigId(String configId) { + this.configId = configId; + } + + private String days = ""; + public String getDays() { + return days; + } + public void setDays(String days) { + this.days = days; + } + + @Override + public void execute() { + try{ + logger.info("WorkflowDataToModeCronjob begin;configId:" + configId + ";days:" + days); + RecordSet rs = new RecordSet(); + String getDataSql = + "select " + + "t1.*,t2.requestmark,t2.requestname,t2.requestid,t2.creater " + + "from " + + "uf_blckdktz t1 " + + "inner join workflow_requestbase t2 on t2.requestid = t1.fromrequestid " + + "where " + + "datediff(Now(),t1.modedatacreatedate) >= " + days; + + String deleteSql = "delete from uf_blckdktz where id = ?"; + + List> data = DaoUtil.getData(rs, getDataSql); + for(Map m : data){ + + JSONObject oldJson = new JSONObject(); + for(String key : m.keySet()){ + oldJson.put(key,m.get(key)); + } + JSONObject gxJson = JsonConvertUtil.convertJsonByConfig(oldJson,configId); + TjwModelUtil.addModelData(rs,"uf_data_invoice",gxJson); + + //发票夹进入已报销状态 + String fphm = m.get("fphm"); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + Map firstData = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData.get("cloudid"); + User user = new User(Integer.parseInt(m.get("creater"))); + UpdateFpStatus.updateStatusToYbx(fphm,user); + + //TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",firstData.get("taxincludedprice"),m.get("fromrequestid"),m.get("requestmark"),m.get("requestname")); + + //删除抵扣台账数据 + DaoUtil.updateData(rs,deleteSql,m.get("id")); + } + + logger.info("WorkflowDataToModeCronjob end"); + }catch (Throwable e){ + logger.error("WorkflowDataToModeCronjob exception;message:" + e.getMessage() + ";e:" + e); + } + } + + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/EqbFileUploadUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/EqbFileUploadUtil.java new file mode 100644 index 0000000..660fbd1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/EqbFileUploadUtil.java @@ -0,0 +1,117 @@ +package com.api.taojw.xmzx.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.net.util.Base64; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.*; +import java.net.URL; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.Map; + +/** + * e签宝接口调用工具类-----上传文件 + */ +public class EqbFileUploadUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 根据imageFileId 调用e签宝三个接口 实现文件上传 、 发起流程 + * @param imageFileId + */ + public static String uploadFile(String imageFileId,String eqbAppId,String eqbAppSecret){ + try{ + RecordSet rs = new RecordSet(); + //--------------------------------------获取文件上传地址 + //接口地址 + String urlString = CommonSqlUtil.getSystemParamValue("eqbFileUploadUrl",rs); + //请求体 + JSONObject param = new JSONObject(); + String contentMd5 = getFileContentMD5(imageFileId); + param.put("contentMd5",contentMd5); + param.put("contentType","application/octet-stream"); + String getImageFileInfoSql = "select imagefilename,filesize from ImageFile where imagefileid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getImageFileInfoSql, imageFileId); + String fileName = Util.null2String(firstData.get("imagefilename")); + String fileSize = Util.null2String(firstData.get("filesize")); + param.put("fileName",fileName); + param.put("fileSize",fileSize); + param.put("convertToPDF",true); + //请求头 + URL url = new URL(urlString); + Map headers = EqbRequestHeaderUtil.getHeaders(null,param.toJSONString(),"POST",url.getPath(),eqbAppId,eqbAppSecret); + //发送请求 + Map post = TjwHttpUtil.sendHttpRequest(urlString, param.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + String response = (String) post.get("data"); + JSONObject responseJson = JSONObject.parseObject(response); + responseJson = responseJson.getJSONObject("data"); + String fileUploadUrl = responseJson.getString("fileUploadUrl"); + String fileId = responseJson.getString("fileId"); + + //--------------------------------------上传文件流 + //请求头 + headers = new HashMap<>(); + headers.put("Content-MD5",contentMd5); + headers.put("Content-Type","application/octet-stream"); + //发送请求 + Map put = TjwHttpUtil.sendHttpRequest(fileUploadUrl, "", "PUT", ContentType.APPLICATION_JSON, headers, Integer.parseInt(imageFileId)); + String putResponse = put.get("data"); + JSONObject putResponseJson = JSONObject.parseObject(putResponse); + return fileId; + }catch (Throwable e){ + logger.error("EqbFileUploadUtil.uploadFile error;message:" + e.getMessage() + ";e:" + e); + return ""; + } + } + + /*** + * 计算文件的Content-MD5 + * @param imageFileId + * @return + */ + public static String getFileContentMD5(String imageFileId) { + ImageFileManager ifm = new ImageFileManager(); + InputStream is = ifm.getInputStreamById(Integer.parseInt(imageFileId)); + // 获取文件MD5的二进制数组(128位) + byte[] bytes = getFileMD5Bytes128(is); + // 对文件MD5的二进制数组进行base64编码 + return new String(Base64.encodeBase64(bytes)); + } + + /*** + * 获取文件MD5-二进制数组(128位) + * @return + * @throws IOException + */ + public static byte[] getFileMD5Bytes128(InputStream fis) { + byte[] md5Bytes = null; + try { + MessageDigest md5 = MessageDigest.getInstance("MD5"); + byte[] buffer = new byte[1024]; + int length = -1; + while ((length = fis.read(buffer, 0, 1024)) != -1) { + md5.update(buffer, 0, length); + } + md5Bytes = md5.digest(); + fis.close(); + } catch (FileNotFoundException e) { + logger.error("getFileMD5Bytes128 error;FileNotFoundException;message:" + e.getMessage() + ";e:" + e); + } catch (NoSuchAlgorithmException e) { + logger.error("getFileMD5Bytes128 error;NoSuchAlgorithmException;message:" + e.getMessage() + ";e:" + e); + } catch (IOException e) { + logger.error("getFileMD5Bytes128 error;IOException;message:" + e.getMessage() + ";e:" + e); + } + return md5Bytes; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/EqbRequestHeaderUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/EqbRequestHeaderUtil.java new file mode 100644 index 0000000..0884e3e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/EqbRequestHeaderUtil.java @@ -0,0 +1,165 @@ +package com.api.taojw.xmzx.util; + +import org.apache.commons.net.util.Base64; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.Map; + +/** + * e签宝接口调用工具类-----请求头相关 + */ +public class EqbRequestHeaderUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 获取e签宝接口公用请求头参数 + * @param cusHeaders + * @return + */ + public static Map getHeaders(Map cusHeaders,String bodyData,String httpMethod,String pathAndParameters,String appId,String eqbAppSecret){ + try{ + RecordSet rs = new RecordSet(); + Map headers = new HashMap<>(); + headers.put("X-Tsign-Open-App-Id", appId); + headers.put("X-Tsign-Open-Auth-Mode", "Signature"); + headers.put("X-Tsign-Open-Ca-Timestamp", String.valueOf(System.currentTimeMillis())); + headers.put("Accept", "*/*"); + if(!"get".equalsIgnoreCase(httpMethod)){ + headers.put("Content-Type","application/json; charset=UTF-8"); + } + + //设置Content-MD5 + if(!"".equals(bodyData) && bodyData != null){ + headers.put("Content-MD5",getBodyContentMD5(bodyData)); + } + if(cusHeaders != null && cusHeaders.size() > 0){ + for(String key : cusHeaders.keySet()){ + headers.put(key,cusHeaders.get(key)); + } + } + //设置签名字符串 + String toSignString = getToSignString(httpMethod,headers.get("Accept"),headers.get("Content-MD5"),headers.get("Content-Type"),pathAndParameters); + //String eqbAppSecret = CommonSqlUtil.getSystemParamValue("eqbAppSecret", rs); + String signedString = doSignatureBase64(toSignString,eqbAppSecret); + headers.put("X-Tsign-Open-Ca-Signature",signedString); + return headers; + }catch (Throwable e){ + logger.error("EqbUtil.getHeaders error;message:" + e.getMessage() + ";e:" + e); + return new HashMap<>(); + } + } + + /*** + * 计算请求Body体的Content-MD5 + * @param bodyData 请求Body体数据 + * @return + */ + public static String getBodyContentMD5(String bodyData) { + // 获取Body体的MD5的二进制数组(128位) + byte[] bytes = getBodyMD5Bytes128(bodyData); + // 对Body体MD5的二进制数组进行Base64编码 + return new String(Base64.encodeBase64(bytes)); + } + + /*** + * 获取MD5-二进制数组(128位) + * + * @param bodyData 请求Body体数据 + * @return + */ + public static byte[] getBodyMD5Bytes128(String bodyData) { + byte[] md5Bytes = null; + try { + MessageDigest md5 = MessageDigest.getInstance("MD5"); + md5.update(bodyData.getBytes(StandardCharsets.UTF_8)); + md5Bytes = md5.digest(); + } catch (Throwable e) { + logger.error("getBodyMD5Bytes128 error;bodyData:" + bodyData + ";message:" + e.getMessage() + ";e:" + e); + } + return md5Bytes; + } + + /** + * 获取待签名字符串 + * @return + */ + public static String getToSignString(String HTTPMethod,String Accept,String ContentMD5,String ContentType,String PathAndParameters) { + try{ + /*HTTPMethod = "POST";*/ + //Accept = "*/*"; + /*ContentMD5 = "uxydqKBMBy6x1siClKEQ6Q=="; + ContentType = "application/json; charset=UTF-8"; + PathAndParameters = "/v3/sign-flow/create-by-file";*/ + String Date = ""; + String Headers = ""; + + if(ContentMD5 == null){ + ContentMD5 = ""; + } + if(ContentType == null){ + ContentType = ""; + } + + // 组合拼接待签名字符串 + StringBuffer strBuff = new StringBuffer(); + strBuff.append(HTTPMethod).append("\n").append(Accept).append("\n").append(ContentMD5).append("\n") + .append(ContentType).append("\n").append(Date).append("\n"); + if ("".equals(Headers)) { + strBuff.append(Headers).append(PathAndParameters); + } else { + strBuff.append(Headers).append("\n").append(PathAndParameters); + } + String StringToSign = strBuff.toString(); + logger.info("getToSignString result:" + StringToSign); + return StringToSign; + }catch (Throwable e){ + logger.error("getToSignString error;message:" + e.getMessage() + ";e:" + e); + return ""; + } + } + + /*** + * 计算请求签名值 + * @param message 待签名字符串 + * @param secret 密钥APP KEY + * @return HmacSHA256计算后摘要值的Base64编码 + * @throws Exception 加密过程中的异常信息 + */ + public static String doSignatureBase64(String message, String secret) throws Exception { + String algorithm = "HmacSHA256"; + Mac hmacSha256; + String digestBase64 = null; + try { + hmacSha256 = Mac.getInstance(algorithm); + byte[] keyBytes = secret.getBytes("UTF-8"); + byte[] messageBytes = message.getBytes("UTF-8"); + hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, algorithm)); + // 使用HmacSHA256对二进制数据消息Bytes计算摘要 + byte[] digestBytes = hmacSha256.doFinal(messageBytes); + // 把摘要后的结果digestBytes使用Base64进行编码 + digestBase64 = new String(Base64.encodeBase64(digestBytes), "UTF-8"); + } catch (NoSuchAlgorithmException e) { + //不支持此算法 + logger.error("doSignatureBase64 error;unSupported method;message:" + message + ";secret:" + secret + ";errorMessage:" + e.getMessage() + ";e:" + e); + } catch (UnsupportedEncodingException e) { + //不支持字符编码 + logger.error("doSignatureBase64 error;unSupported charSet;message:" + message + ";secret:" + secret + ";errorMessage:" + e.getMessage() + ";e:" + e); + } catch (Throwable e) { + //无效的密钥规范 + logger.error("doSignatureBase64 error;unSupported secret;message:" + message + ";secret:" + secret + ";errorMessage:" + e.getMessage() + ";e:" + e); + } + return digestBase64; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/ModelDataUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/ModelDataUtil.java new file mode 100644 index 0000000..cd182e7 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/ModelDataUtil.java @@ -0,0 +1,131 @@ +package com.api.taojw.xmzx.util; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +public class ModelDataUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 取消扣减 + * @param data + * @return 1-数量校验失败 2-扣减成功 3-异常 + */ + public static synchronized String addQuantity(List> data){ + RecordSetTrans rsts = new RecordSetTrans(); + rsts.setAutoCommit(false); + try{ + //开始取消扣减 + String updateQuantitySql = + "update uf_prlcgx set sysl = sysl + ? where id = ?"; + for(Map m : data){ + String modelDataId = Util.null2String(m.get("prgx")); + String quantity = Util.null2String(m.get("quantity")); + if("".equals(quantity) || quantity == null){ + continue; + } + if(!"".equals(modelDataId)){ + rsts.executeUpdate(updateQuantitySql,quantity,modelDataId); + } + //更新台账状态 + dealModelDataStatus(rsts,modelDataId); + } + rsts.commit(); + return "Success09"; + }catch(Throwable e){ + rsts.rollback(); + logger.error("plusQuantity error;message:" + e.getMessage() + ";e:" + e ); + return "Exception08"; + } + } + + /** + * 扣减 + * @param data + * @return 1-数量校验失败 2-扣减成功 3-异常 + */ + public static synchronized String plusQuantity(List> data){ + RecordSetTrans rsts = new RecordSetTrans(); + rsts.setAutoCommit(false); + try{ + RecordSet rs = new RecordSet(); + String getSyslSql = "select sysl from uf_prlcgx where id = ?"; + //校验数量是否多了 多了不允许提交 + for(Map m : data){ + String modelDataId = Util.null2String(m.get("prgx")); + String quantity = Util.null2String(m.get("quantity")); + if("".equals(quantity) || quantity == null){ + continue; + } + int quantityDouble = Integer.parseInt(quantity); + if(!"".equals(modelDataId)){ + Map firstData = DaoUtil.getFirstData(rs, getSyslSql, modelDataId); + String sysl = firstData.get("sysl"); + if("".equals(sysl) || sysl == null){ + continue; + } + int syslInt = Integer.parseInt(sysl); + if(quantityDouble > syslInt){ + return m.get("itemwb"); + } + } + } + + //校验通过 开始扣减 + String updateQuantitySql = + "update uf_prlcgx set sysl = sysl - ? where id = ?"; + for(Map m : data){ + String modelDataId = Util.null2String(m.get("prgx")); + String quantity = Util.null2String(m.get("quantity")); + if("".equals(quantity) || quantity == null){ + continue; + } + int quantityDouble = Integer.parseInt(quantity); + if(!"".equals(modelDataId)){ + Map firstData = DaoUtil.getFirstData(rs, getSyslSql,modelDataId); + String sysl = firstData.get("sysl"); + if("".equals(sysl) || sysl == null){ + continue; + } + rsts.executeUpdate(updateQuantitySql,quantityDouble,modelDataId); + } + //更新台账状态 + dealModelDataStatus(rsts,modelDataId); + } + rsts.commit(); + return "Success09"; + }catch(Throwable e){ + rsts.rollback(); + logger.error("plusQuantity error;message:" + e.getMessage() + ";e:" + e ); + return "Exception08"; + } + } + + public static void dealModelDataStatus(RecordSetTrans rsts,String dataId) throws Exception { + String getSlSql ="select sysl,sqsl from uf_prlcgx where id = ?"; + String updateStatusSql = "update uf_prlcgx set sfybpogl = ? where id = ?"; + if(rsts.executeQuery(getSlSql,dataId)){ + if(rsts.next()){ + String sysl = Util.null2String(rsts.getString("sysl")); + String sqsl = Util.null2String(rsts.getString("sqsl")); + if(sysl.equals(sqsl)){ + rsts.executeUpdate(updateStatusSql,"1",dataId); + }else{ + rsts.executeUpdate(updateStatusSql,"2",dataId); + } + + if("0".equals(sysl)){ + rsts.executeUpdate(updateStatusSql,"3",dataId); + } + + } + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/MyStrategy.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/MyStrategy.java new file mode 100644 index 0000000..824957b --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/MyStrategy.java @@ -0,0 +1,45 @@ +package com.api.taojw.xmzx.util; + +import oauth.signpost.OAuth; +import oauth.signpost.exception.OAuthMessageSignerException; +import oauth.signpost.http.HttpParameters; +import oauth.signpost.http.HttpRequest; +import oauth.signpost.signature.OAuthMessageSigner; +import oauth.signpost.signature.SignatureBaseString; +import oauth.signpost.signature.SigningStrategy; + +import javax.crypto.Mac; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.security.GeneralSecurityException; + +public class MyStrategy extends OAuthMessageSigner { + + private static final String MAC_NAME = "HmacSHA256"; + + public MyStrategy() { + } + + public String getSignatureMethod() { + return "HMAC-SHA256"; + } + + public String sign(HttpRequest request, HttpParameters requestParams) throws OAuthMessageSignerException { + try { + String keyString = OAuth.percentEncode(this.getConsumerSecret()) + '&' + OAuth.percentEncode(this.getTokenSecret()); + byte[] keyBytes = keyString.getBytes("utf-8"); + SecretKey key = new SecretKeySpec(keyBytes, "HmacSHA256"); + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(key); + String sbs = (new SignatureBaseString(request, requestParams)).generate(); + OAuth.debugOut("SBS", sbs); + byte[] text = sbs.getBytes("utf-8"); + return this.base64Encode(mac.doFinal(text)).trim(); + } catch (GeneralSecurityException var9) { + throw new OAuthMessageSignerException(var9); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/NsHttpUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/NsHttpUtil.java new file mode 100644 index 0000000..1afd461 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/NsHttpUtil.java @@ -0,0 +1,207 @@ +package com.api.taojw.xmzx.util; + +import com.alibaba.fastjson.JSONObject; +import oauth.signpost.OAuthConsumer; +import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; +import oauth.signpost.exception.OAuthCommunicationException; +import oauth.signpost.exception.OAuthExpectationFailedException; +import oauth.signpost.exception.OAuthMessageSignerException; +import oauth.signpost.http.HttpParameters; +import oauth.signpost.signature.AuthorizationHeaderSigningStrategy; +import oauth.signpost.signature.HmacSha256MessageSigner; +import org.apache.http.*; +import org.apache.http.client.methods.*; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.BufferedHttpEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; + +import java.net.MalformedURLException; + +import org.apache.http.client.methods.HttpRequestBase; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +/** + * NS接口调用工具类 + */ +public class NsHttpUtil { + + static Logger logger = MyLogger.getLogger(); + private OAuthConsumer oAuthConsumer; + private static String realmID = null; + + public NsHttpUtil() { + realmID = "5059457_SB2"; + String consumerKey = "ffcf2a7baecf226e1cdf97746f425138cf522fab25cd75f9dc0215e665366b52"; + String consumerSecret = "a8a721fbdfcd37e1a1993cc772b33b62615780a5d69a4b68e7a647ececdb7d9e"; + String accessToken = "f5fbd1dc10b802c8923f3d45d24ddb454a2734183fad1728307b55dca9cfb401"; + String accessTokenSecret = "f864f4393597c0ad9c69e5fe5d3176b2a00d9161868398f4918843b5824f5307"; + this.oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); + oAuthConsumer.setMessageSigner(new HmacSha256MessageSigner()); + HttpParameters parameters = new HttpParameters(); + parameters.put("realm", realmID); + //parameters.put("version", "1.0"); + oAuthConsumer.setAdditionalParameters(parameters); + oAuthConsumer.setTokenWithSecret(accessToken, accessTokenSecret); + oAuthConsumer.setSigningStrategy(new AuthorizationHeaderSigningStrategy()); + + /*setupContext(consumerKey, consumerSecret, accessToken, accessTokenSecret);*/ + + } + + + + public void authorize(HttpRequestBase httpRequest) throws Exception { + try { + oAuthConsumer.sign(httpRequest); + } catch (OAuthMessageSignerException e) { + throw new Exception(e); + } catch (OAuthExpectationFailedException e) { + throw new Exception(e); + } catch (OAuthCommunicationException e) { + throw new Exception(e); + } + } + + /** + * 返回CloseableHttpClient 如果接口为https协议 信任所有证书 + * @return + * @throws MalformedURLException + */ + public static CloseableHttpClient createSSLClientDefault(String urlString){ + URL url = null; + try { + url = new URL(urlString); + } catch (Exception e) { + logger.error("url error;urlString:" + urlString); + } + String protocol = url.getProtocol(); + if("https".equals(protocol)){ + try { + //使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书 + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { + return true; + } + }).build(); + //NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何 + //有效的SSL会话并匹配到目标主机。 + HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return build; + } catch (Exception e) { + logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e); + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + }else{ + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + } + + public void executeGetRequest(String url){ + try{ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + HttpPost post=new HttpPost(url); + authorize(post); + JSONObject a = new JSONObject(); + a.put("oaId","10012"); + a.put("name","测试数据12"); + StringEntity entity = new StringEntity(a.toJSONString(), + ContentType.APPLICATION_JSON); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + post.addHeader("Accept","*/*"); + post.addHeader("Content-Type", "application/json"); + post.addHeader("Cookie", "NS_ROUTING_VERSION=LAGGING"); + /*Header[] allHeaders = post.getAllHeaders(); + String headerr = ""; + for(Header aa : allHeaders){ + if("Authorization".equals(aa.getName())){ + headerr = aa.getValue(); + post.removeHeader(aa); + } + } + headerr = headerr.replaceAll(" ",""); + headerr = headerr.replaceAll("OAuthrealm","OAuth realm"); + post.addHeader("Authorization",headerr);*/ + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + String s = EntityUtils.toString(en, "utf-8"); + result.put("data", s); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }catch (Exception e){ + + } + +/* + DefaultHttpClient client = new DefaultHttpClient(); + client.getParams().setParameter("http.protocol.content-charset", "UTF-8"); + + HttpRequestBase httpRequest = null; + URI uri = null; + + try { + uri = new URI(customURIString); + } catch (URISyntaxException e) { + e.printStackTrace(); + }*/ + + + //httpRequest = new HttpPost(uri); + + //httpRequest.addHeader("content-type", "application/json"); + //httpRequest.addHeader("Accept","*/*"); + + /*try { + authorize(httpRequest); + } catch (Exception e) { + e.printStackTrace(); + } + + + HttpResponse httpResponse = null; + try { + HttpHost target = new HttpHost(uri.getHost(), -1, uri.getScheme()); + httpResponse = client.execute(target, httpRequest); + System.out.println("Connection status : " + httpResponse.getStatusLine()); + + InputStream inputStraem = httpResponse.getEntity().getContent(); + + StringWriter writer = new StringWriter(); + IOUtils.copy(inputStraem, writer, "UTF-8"); + String output = writer.toString(); + + System.out.println(output); + }catch(Exception e){ + e.printStackTrace(); + }*/ + } + + public static void main(String args[]) { + NsHttpUtil withoutDevkitClient = new NsHttpUtil(); + + withoutDevkitClient.executeGetRequest("https://5059457-sb2.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=3103&deploy=1"); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/UpdateFpStatus.java b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/UpdateFpStatus.java new file mode 100644 index 0000000..d865625 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/xmzx/util/UpdateFpStatus.java @@ -0,0 +1,124 @@ +package com.api.taojw.xmzx.util; + +import com.alibaba.fastjson.JSONObject; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwFpUtil; +import weaver.taojw.common.TjwModelUtil; + +import java.util.List; +import java.util.Map; + +public class UpdateFpStatus { + + public static void updateStatusToYbxWithoutRequestId(String fphm, User user,String requestId){ + RecordSet rs = new RecordSet(); + String billTableName = CommonSqlUtil.getSystemParamValue("billtablename",rs); + String billrejectnodeid = CommonSqlUtil.getSystemParamValue("billrejectnodeid",rs); + String billRejectTableName = CommonSqlUtil.getSystemParamValue("billrejecttablename",rs); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + String getRequestMarkSql = "select * from workflow_requestbase where requestid = ?"; + String getRequestIdSql = "select distinct t1.requestid,t2.hxje from " + billTableName + " t1 " + + "inner join " + billTableName + "_dt3 t2 on t2.mainid = t1.id " + + "inner join workflow_requestbase t3 on t3.requestid = t1.requestid " + + "where t2.fphm = ? and t3.currentnodeid != " + billrejectnodeid + " " + + "and t1.requestid not in (select billlc from " + billRejectTableName + ") " + + "and t1.requestid != " + requestId; + + Map firstData = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData.get("cloudid"); + String taxincludedprice = firstData.get("taxincludedprice"); + //余额为0的 发票夹进入已报销状态 ,自动转入国信台账 + List> data1 = DaoUtil.getData(rs, getRequestIdSql, fphm); + Double taxincludedpriceD = Double.valueOf(taxincludedprice); + for(int i = 0;i < data1.size();i ++){ + if(i < data1.size() -1){ + Map m1 = data1.get(i); + String _requestId = m1.get("requestid"); + String hxje = m1.get("hxje"); + taxincludedpriceD = taxincludedpriceD - Double.valueOf(hxje); + Map firstData11 = DaoUtil.getFirstData(rs, getRequestMarkSql, _requestId); + String requestMark = firstData11.get("requestmark"); + String requestName = firstData11.get("requestname"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",hxje,_requestId,requestMark,requestName); + }else{ + Map m1 = data1.get(i); + String _requestId = m1.get("requestid"); + Map firstData11 = DaoUtil.getFirstData(rs, getRequestMarkSql, _requestId); + String requestMark = firstData11.get("requestmark"); + String requestName = firstData11.get("requestname"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",taxincludedpriceD.toString(),_requestId,requestMark,requestName); + } + } + JSONObject ybx = new JSONObject(); + ybx.put("fphm",fphm); + TjwModelUtil.addModelData(rs,"uf_ybxfp",ybx); + } + + public static void updateStatusToYbx(String fphm, User user){ + RecordSet rs = new RecordSet(); + String billTableName = CommonSqlUtil.getSystemParamValue("billtablename",rs); + String billrejectnodeid = CommonSqlUtil.getSystemParamValue("billrejectnodeid",rs); + String billRejectTableName = CommonSqlUtil.getSystemParamValue("billrejecttablename",rs); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + String getRequestMarkSql = "select * from workflow_requestbase where requestid = ?"; + String getRequestIdSql = "select distinct t1.requestid,t2.hxje from " + billTableName + " t1 " + + "inner join " + billTableName + "_dt3 t2 on t2.mainid = t1.id " + + "inner join workflow_requestbase t3 on t3.requestid = t1.requestid " + + "where t2.fphm = ? and t3.currentnodeid != " + billrejectnodeid + " " + + "and t1.requestid not in (select billlc from " + billRejectTableName + ")"; + + Map firstData = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData.get("cloudid"); + String taxincludedprice = firstData.get("taxincludedprice"); + //余额为0的 发票夹进入已报销状态 ,自动转入国信台账 + List> data1 = DaoUtil.getData(rs, getRequestIdSql, fphm); + Double taxincludedpriceD = Double.valueOf(taxincludedprice); + for(int i = 0;i < data1.size();i ++){ + if(i < data1.size() -1){ + Map m1 = data1.get(i); + String _requestId = m1.get("requestid"); + String hxje = m1.get("hxje"); + taxincludedpriceD = taxincludedpriceD - Double.valueOf(hxje); + Map firstData11 = DaoUtil.getFirstData(rs, getRequestMarkSql, _requestId); + String requestMark = firstData11.get("requestmark"); + String requestName = firstData11.get("requestname"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",hxje,_requestId,requestMark,requestName); + }else{ + Map m1 = data1.get(i); + String _requestId = m1.get("requestid"); + Map firstData11 = DaoUtil.getFirstData(rs, getRequestMarkSql, _requestId); + String requestMark = firstData11.get("requestmark"); + String requestName = firstData11.get("requestname"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2",taxincludedpriceD.toString(),_requestId,requestMark,requestName); + } + } + JSONObject ybx = new JSONObject(); + ybx.put("fphm",fphm); + TjwModelUtil.addModelData(rs,"uf_ybxfp",ybx); + } + + public static void updateStatusToWbx(String fphm, User user){ + RecordSet rs = new RecordSet(); + String billTableName = CommonSqlUtil.getSystemParamValue("billtablename",rs); + String getFpInfoInDatabaseSql = "select * from fnainvoiceledger where invoiceNumber = ?"; + String getRequestMarkSql = "select * from workflow_requestbase where requestid = ?"; + String getRequestIdSql = "select distinct t1.requestid from " + billTableName + " t1 inner join " + billTableName + "_dt3 t2 on t2.mainid = t1.id where t2.fphm = ?"; + + + Map firstData = DaoUtil.getFirstData(rs, getFpInfoInDatabaseSql, fphm); + String cloudId = firstData.get("cloudid"); + //余额为0的 发票夹进入已报销状态 ,自动转入国信台账 + List> data1 = DaoUtil.getData(rs, getRequestIdSql, fphm); + for(Map m1 : data1){ + String _requestId = m1.get("requestid"); + Map firstData11 = DaoUtil.getFirstData(rs, getRequestMarkSql, _requestId); + String requestMark = firstData11.get("requestmark"); + String requestName = firstData11.get("requestname"); + TjwFpUtil.updateFpStatusInCloudCommon(user,cloudId,"2","",_requestId,requestMark,requestName); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ydjd/action/UpdateMailInModeAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/ydjd/action/UpdateMailInModeAction.java new file mode 100644 index 0000000..c8c6359 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ydjd/action/UpdateMailInModeAction.java @@ -0,0 +1,135 @@ +package com.api.taojw.ydjd.action; + +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 洲际酒店 + * 定时任务 + * 比较酒店底表和人员信息表的数据 若有变化 则 更新酒店底表数据 并触发 + */ +public class UpdateMailInModeAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String hrmColumnName = ""; + private String modeTableName = ""; + private String modeHrmColumnName = ""; + private String modeEmailColumnName = ""; + + public String getHrmColumnName() { + return hrmColumnName; + } + + public void setHrmColumnName(String hrmColumnName) { + this.hrmColumnName = hrmColumnName; + } + + public String getModeTableName() { + return modeTableName; + } + + public void setModeTableName(String modeTableName) { + this.modeTableName = modeTableName; + } + + public String getModeHrmColumnName() { + return modeHrmColumnName; + } + + public void setModeHrmColumnName(String modeHrmColumnName) { + this.modeHrmColumnName = modeHrmColumnName; + } + + public String getModeEmailColumnName() { + return modeEmailColumnName; + } + + public void setModeEmailColumnName(String modeEmailColumnName) { + this.modeEmailColumnName = modeEmailColumnName; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestName = requestInfo.getRequestManager().getRequestname(); + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTable = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + + String getHrmSql = "select " + hrmColumnName + " from " + billTable + " where requestid = ?"; + if(hrmColumnName.startsWith("dt")){ + getHrmSql = + "select " + + hrmColumnName + " " + + "from " + + billTable + " t1 " + + "inner join " + billTable + "_" + hrmColumnName.split(".")[0] + " t2 on t2.mainid = t1.id " + + "where " + + "t1.requestid = ?"; + } + List> data = DaoUtil.getData(rs, getHrmSql, requestId); + String onlyColumnName = hrmColumnName; + if(onlyColumnName.startsWith("dt")){ + onlyColumnName = onlyColumnName.split(".")[1]; + } + + List hrmList = new ArrayList<>(); + for(Map m : data){ + String hrm = m.get(onlyColumnName.toLowerCase(Locale.ROOT)); + if(hrm != null && !"".equals(hrm)){ + String[] hrmArr = hrm.split(","); + for(String id : hrmArr){ + hrmList.add(id); + } + } + } + logger.info("hrmList:" + hrmList.toArray()); + + + for(String userId : hrmList){ + String getEmailSql = "select email from hrmresource where id = ?"; + String updateSql1 = "update " + modeTableName + " set " + modeHrmColumnName + " = '' where charindex(',',cast(" + modeHrmColumnName +" as nvarchar(2000))) = 0 and cast(" + modeHrmColumnName + " as nvarchar(2000)) = '"+userId+"'"; + String updateSql2 = "update " + modeTableName + " set " + modeHrmColumnName + " = stuff(cast("+modeHrmColumnName+" as nvarchar(2000)),charindex('"+userId+"'+',',cast("+modeHrmColumnName+" as nvarchar(2000))),len('"+userId+"')+1,'') where cast("+modeHrmColumnName+" as nvarchar(2000)) like '"+userId+"'+',%'"; + String updateSql3 = "update " + modeTableName + " set " + modeHrmColumnName + " = stuff(cast("+modeHrmColumnName+" as nvarchar(2000)),charindex(','+'"+userId+"',cast("+modeHrmColumnName+" as nvarchar(2000))),len('"+userId+"')+1,'') where cast("+modeHrmColumnName+" as nvarchar(2000)) like '%,'+'"+userId+"'"; + String updateSql4 = "update " + modeTableName + " set " + modeHrmColumnName + " = stuff(cast("+modeHrmColumnName+" as nvarchar(2000)),charindex(','+'"+userId+"'+',',cast("+modeHrmColumnName+" as nvarchar(2000))),len('"+userId+"')+2,',') where cast("+modeHrmColumnName+" as nvarchar(2000)) like '%,'+'"+userId+"'+',%'"; + + DaoUtil.updateData(rs,updateSql1); + DaoUtil.updateData(rs,updateSql2); + DaoUtil.updateData(rs,updateSql3); + DaoUtil.updateData(rs,updateSql4); + + Map firstData = DaoUtil.getFirstData(rs, getEmailSql, userId); + String email = firstData.get("email"); + if(email != null && !"".equals(email)){ + String updateSql5 = "update " + modeTableName + " set " + modeEmailColumnName + " = '' where charindex(','," + modeEmailColumnName +") = 0 and " + modeEmailColumnName + " = '"+email+"'"; + String updateSql6 = "update " + modeTableName + " set " + modeEmailColumnName + " = stuff("+modeEmailColumnName+",charindex('"+email+"'+',',"+modeEmailColumnName+"),len('"+email+"')+1,'') where "+modeEmailColumnName+" like '"+email+"'+',%'"; + String updateSql7 = "update " + modeTableName + " set " + modeEmailColumnName + " = stuff("+modeEmailColumnName+",charindex(','+'"+email+"',"+modeEmailColumnName+"),len('"+email+"')+1,'') where "+modeEmailColumnName+" like '%,'+'"+email+"'"; + String updateSql8 = "update " + modeTableName + " set " + modeEmailColumnName + " = stuff("+modeEmailColumnName+",charindex(','+'"+email+"'+',',"+modeEmailColumnName+"),len('"+email+"')+2,',') where "+modeEmailColumnName+" like '%,'+'"+email+"'+',%'"; + + DaoUtil.updateData(rs,updateSql5); + DaoUtil.updateData(rs,updateSql6); + DaoUtil.updateData(rs,updateSql7); + DaoUtil.updateData(rs,updateSql8); + } + } + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + "error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/action/CallYongYouAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/action/CallYongYouAction.java new file mode 100644 index 0000000..9d1da1a --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/action/CallYongYouAction.java @@ -0,0 +1,74 @@ +package com.api.taojw.yongwang.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.TjwHttpUtil; +import com.api.taojw.common.WorkFlowDataToJsonUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import java.util.Map; + +/** + * 用友 + * action + * 调用用友供应商新增接口 + */ + public class CallYongYouAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String yyUrl = ""; + + public String getYyUrl() { + return yyUrl; + } + + public void setYyUrl(String yyUrl) { + this.yyUrl = yyUrl; + } + + private String configId = ""; + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestName = requestInfo.getRequestManager().getRequestname(); + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTable = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + String[] requestBaseInfo = WorkFlowDataToJsonUtil.getRequestBaseInfo(requestId, requestInfo.getRsTrans(), billTable, billTable); + JSONObject json = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId,configId,requestBaseInfo); + Map post = TjwHttpUtil.sendHttpRequestWithCusLog(yyUrl, json.toJSONString(), "POST", ContentType.APPLICATION_JSON, null, null); + String data = (String) post.get("data"); + JSONObject resJson = JSONObject.parseObject(data); + boolean flag = resJson.getBoolean("Success"); + String errMsg = resJson.getString("ErrMsg"); + if(flag){ + return Action.SUCCESS; + }else{ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("新增供应商失败,用友接口响应:"+errMsg+"!"); + return Action.FAILURE_AND_CONTINUE; + } + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + "error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/action/CreateBhAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/action/CreateBhAction.java new file mode 100644 index 0000000..6841b7e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/action/CreateBhAction.java @@ -0,0 +1,57 @@ +package com.api.taojw.yongwang.action; + +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import com.api.taojw.yongwang.util.BhUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import java.util.List; +import java.util.Map; + +/** + * 用友 + * action + * 生成编号 + */ + public class CreateBhAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String fbColumnName = ""; + private String sqlWhere = ""; + private String bhColumnName = ""; + + @Override + public String execute(RequestInfo requestInfo) { + String requestName = requestInfo.getRequestManager().getRequestname(); + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTable = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + String getDetailDataSql = + "select t1."+fbColumnName+" as fb,t2.id from " + billTable + " t1 inner join " + billTable + "_dt1 t2 on t2.mainid = t1.id where t1.requestid = ? "; + if(sqlWhere != null && !"".equals(sqlWhere)){ + getDetailDataSql = getDetailDataSql + sqlWhere; + } + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + String updateBhSql = "update " + billTable + "_dt1 set " + bhColumnName + " = ? where id = ?"; + for(Map m : data){ + String id = m.get("id"); + String fb = m.get("fb"); + String bh = BhUtil.getBh(fb); + DaoUtil.updateData(rs,updateBhSql,bh,id); + } + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + "error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/util/BhUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/util/BhUtil.java new file mode 100644 index 0000000..c8ba82c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/yongwang/util/BhUtil.java @@ -0,0 +1,33 @@ +package com.api.taojw.yongwang.util; + +import com.api.taojw.common.DaoUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import java.util.Map; + +public class BhUtil { + + public static synchronized String getBh(String fb){ + //查询建模中是否有 + RecordSet rs = new RecordSet(); + String getDataSql = "select dqls from uf_bmdqls where fbid = ? "; + + Map firstData = DaoUtil.getFirstData(rs, getDataSql, fb); + String dqls = Util.null2String(firstData.get("dqls")); + + int currentLs = Integer.parseInt(dqls) + 1; + String updateSql = "update uf_bmdqls set dqls = dqls + 1 where fbid = ? "; + DaoUtil.updateData(rs,updateSql, fb); + + //判断下一流水是否保留 + String checkIsBlSql = "select count(1) as c from uf_fblsylbh t1 inner join uf_fblsylbh_dt1 t2 on t2.mainid = t1.id where t1.fbid = ? and t2.lsh = ?"; + boolean dataExists = DaoUtil.isDataExists(rs, checkIsBlSql, fb, currentLs); + if(!dataExists){ + return "88" + String.format("%4s", currentLs + "").replace(" ", "0"); + }else{ + return getBh(fb); + } + + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/CreateOrderCodeAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/CreateOrderCodeAction.java new file mode 100644 index 0000000..1195582 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/CreateOrderCodeAction.java @@ -0,0 +1,101 @@ +package com.api.taojw.ysld.action; + +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.Map; + +/** + * 雅诗兰黛 + * 生成订单编号 + * NC+9(流水倒叙)+AAA(正序流水)+年月日(6位)+AD域账号+手工填写的订单后缀 + */ +public class CreateOrderCodeAction implements Action { + + private String cusString = ""; + private String hrmColumnName = ""; + private String suffixColumnName = ""; + private String lcbhColumnName = ""; + + Logger logger = MyLogger.getLogger(); + + /** + * @param requestInfo 流程请求信息 + * @return 返回执行结果 + */ + @Override + public String execute(RequestInfo requestInfo) { + //流程请求ID + String requestId = Util.null2String(requestInfo.getRequestid()); + try{ + logger.info(this.getClass() + "---------- Begin --------------requestId:" + requestId); + //流程类型ID + String workflowId = Util.null2String(requestInfo.getWorkflowid()); + + //获取当前流程表单名称 + String billTable = requestInfo.getRequestManager().getBillTableName(); + + RecordSet rs = new RecordSet(); + String getUserIdSql = "select t2.loginid,t1."+suffixColumnName+" from " + billTable + " t1 left join hrmresource t2 on t1." + hrmColumnName + " = t2.id where t1.requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getUserIdSql, requestId); + String loginId = Util.null2String(firstData.get("loginid")); + String suffix = Util.null2String(firstData.get(suffixColumnName.toLowerCase(Locale.ROOT))); + + String andSetFlow = WorkFlowUtil.getAndSetFlow(workflowId); + String newMark = cusString + andSetFlow + new SimpleDateFormat("yyMMdd").format(new Date()) + loginId + suffix; + + String updateBhSql = "update " + billTable + " set " + lcbhColumnName + " = ? where requestid = ?"; + DaoUtil.updateData(rs,updateBhSql,newMark,requestId); + + }catch (Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + logger.info(this.getClass() + "---------- End -------------- requestId:" + requestId); + return Action.SUCCESS; + } + + public String getCusString() { + return cusString; + } + + public void setCusString(String cusString) { + this.cusString = cusString; + } + + public String getHrmColumnName() { + return hrmColumnName; + } + + public void setHrmColumnName(String hrmColumnName) { + this.hrmColumnName = hrmColumnName; + } + + public String getSuffixColumnName() { + return suffixColumnName; + } + + public void setSuffixColumnName(String suffixColumnName) { + this.suffixColumnName = suffixColumnName; + } + + public String getLcbhColumnName() { + return lcbhColumnName; + } + + public void setLcbhColumnName(String lcbhColumnName) { + this.lcbhColumnName = lcbhColumnName; + } +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealCpslAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealCpslAction.java new file mode 100644 index 0000000..2343bc2 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealCpslAction.java @@ -0,0 +1,96 @@ +package com.api.taojw.ysld.action; + +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 雅诗兰黛 + * 扣减产品数量 + */ +public class DealCpslAction implements Action { + + private String modeTableName = ""; + private String modeColumnName = ""; + private String workFlowSlColumnName = ""; + + Logger logger = MyLogger.getLogger(); + + public String getModeTableName() { + return modeTableName; + } + + public void setModeTableName(String modeTableName) { + this.modeTableName = modeTableName; + } + + public String getModeColumnName() { + return modeColumnName; + } + + public void setModeColumnName(String modeColumnName) { + this.modeColumnName = modeColumnName; + } + + public String getWorkFlowSlColumnName() { + return workFlowSlColumnName; + } + + public void setWorkFlowSlColumnName(String workFlowSlColumnName) { + this.workFlowSlColumnName = workFlowSlColumnName; + } + + /** + * @param requestInfo 流程请求信息 + * @return 返回执行结果 + */ + @Override + public String execute(RequestInfo requestInfo) { + //流程请求ID + String requestId = Util.null2String(requestInfo.getRequestid()); + try{ + logger.info(this.getClass() + "---------- Begin --------------requestId:" + requestId); + //流程类型ID + String workflowId = Util.null2String(requestInfo.getWorkflowid()); + + //获取当前流程表单名称 + String billTable = requestInfo.getRequestManager().getBillTableName(); + + RecordSet rs = new RecordSet(); + String getDetailDataSql = + "select " + + "t2.cpbh,t2." + workFlowSlColumnName + " " + + "from " + + billTable + " t1 " + + "inner join " + billTable + "_dt1 t2 on t2.mainid = t1.id " + + "where " + + "t1.requestid = ?"; + + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + for(Map m: data){ + String cpbh = Util.null2String(m.get("cpbh")); + int sl = Util.getIntValue(m.get(workFlowSlColumnName.toLowerCase(Locale.ROOT)),0); + DealSlUtil.updateSl(modeTableName,modeColumnName,sl,cpbh); + } + }catch (Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + logger.info(this.getClass() + "---------- End -------------- requestId:" + requestId); + return Action.SUCCESS; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealDetailAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealDetailAction.java new file mode 100644 index 0000000..9613b48 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealDetailAction.java @@ -0,0 +1,107 @@ +package com.api.taojw.ysld.action; + +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.List; +import java.util.Map; + +/** + * 雅诗兰黛 + * 按照产品编号合并明细 数量相加 + */ +public class DealDetailAction implements Action { + + private String modeTableName = ""; + private String modeColumnName = ""; + private String workFlowSlColumnName = ""; + + Logger logger = MyLogger.getLogger(); + + public String getModeTableName() { + return modeTableName; + } + + public void setModeTableName(String modeTableName) { + this.modeTableName = modeTableName; + } + + public String getModeColumnName() { + return modeColumnName; + } + + public void setModeColumnName(String modeColumnName) { + this.modeColumnName = modeColumnName; + } + + public String getWorkFlowSlColumnName() { + return workFlowSlColumnName; + } + + public void setWorkFlowSlColumnName(String workFlowSlColumnName) { + this.workFlowSlColumnName = workFlowSlColumnName; + } + + /** + * @param requestInfo 流程请求信息 + * @return 返回执行结果 + */ + @Override + public String execute(RequestInfo requestInfo) { + //流程请求ID + String requestId = Util.null2String(requestInfo.getRequestid()); + try{ + logger.info(this.getClass() + "---------- Begin --------------requestId:" + requestId); + //获取当前流程表单名称 + String billTable = requestInfo.getRequestManager().getBillTableName(); + + RecordSet rs = new RecordSet(); + String getDetailDataSql = + "select " + + "t1.id,max(t2.cpbh) as cpbh,max(t2.ppbm) as ppbm,GROUP_CONCAT(t2.ddbh) as ddbh,max(t2.fl) as fl,max(t2.zwms) as zwms,sum(t2.kthsl) as kthsl,sum(t2.sl) as sl,max(t2.sjthsl) as sjthsl,max(t2.lsdj) as lsdj,max(t2.bzcb) as bzcb,max(t2.itca) as itca,max(t2.se) as se " + + "from " + + billTable + " t1 " + + "inner join " + billTable + "_dt1 t2 on t2.mainid = t1.id " + + "inner join uf_OfficeInventory t3 on t3.id = t2.cpbh " + + "where " + + "t1.requestid = ? " + + "group by " + + "t3.cpbh "; + + String insertSql = "insert into " + billTable + "_dt1(mainid,cpbh,ppbm,ddbh,fl,zwms,kthsl,sl,sjthsl,lsdj,bzcb,itca,se) values(?,?,?,?,?,?,?,?,?,?,?,?,?) "; + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + String deleteSql = "delete from " + billTable + "_dt1 where mainid = (select id from "+billTable+" where requestId = ?)"; + DaoUtil.updateData(rs,deleteSql,requestId); + for(Map m: data){ + String id = Util.null2String(m.get("id")); + String cpbh = Util.null2String(m.get("cpbh"),"0"); + String ppbm = Util.null2String(m.get("ppbm")); + String ddbh = Util.null2String(m.get("ddbh")); + String fl = Util.null2String(m.get("fl")); + String zwms = Util.null2String(m.get("zwms")); + String kthsl = Util.null2String(m.get("kthsl"),"0"); + String sl = Util.null2String(m.get("sl"),"0"); + String sjthsl = Util.null2String(m.get("sjthsl"),"0"); + String lsdj = Util.null2String(m.get("lsdj"),"0"); + String bzcb = Util.null2String(m.get("bzcb"),"0"); + String itca = Util.null2String(m.get("itca")); + String se = Util.null2String(m.get("se"),"0"); + DaoUtil.updateData(rs,insertSql,id,cpbh,ppbm,ddbh,fl,zwms,kthsl.equals("")?"0":kthsl,sl.equals("")?"0":sl,sjthsl.equals("")?"0":sjthsl,lsdj.equals("")?"0":lsdj,bzcb.equals("")?"0":bzcb,itca,se.equals("")?"0":se); + } + }catch (Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + logger.info(this.getClass() + "---------- End -------------- requestId:" + requestId); + return Action.SUCCESS; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealSlUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealSlUtil.java new file mode 100644 index 0000000..faa0c48 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/DealSlUtil.java @@ -0,0 +1,47 @@ +package com.api.taojw.ysld.action; + +import com.api.taojw.common.DaoUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.util.Map; + +public class DealSlUtil { + + public static String getCurrentFlowSql = "select num,yw from uf_cusddls where lclx = ?"; + public static String addCurrentFlowSql = "insert into uf_cusddls(lclx,num,yw) values(?,?,?)"; + + public static String updateCurrentFlowSql = "update uf_cusddls set num = ?,yw = ? where lclx = ?"; + + public static synchronized void updateSl(String modeTableName,String modeColumnName,int sl,String id){ + RecordSet rs = new RecordSet(); + String updateModeSql = + "update " + + modeTableName + " " + + "set " + + "dcthsl = COALESCE(dcthsl, 0) + ? " + + "where " + + "id = ?"; + String getSlSql = + "select CASE WHEN lysl IS NULL AND thsl IS NULL and dcthsl IS NULL THEN sssl ELSE sssl - COALESCE(lysl, 0) + COALESCE(thsl, 0) -COALESCE(dcthsl, 0) END as sl from " + modeTableName + " where id = ?"; + if(id == null || "".equals(id)){ + return; + } + DaoUtil.updateData(rs,updateModeSql,sl,id); + /*String[] idArr = ids.split(","); + for(String id : idArr){ + Map firstData = DaoUtil.getFirstData(rs, getSlSql, id); + int sysl = Util.getIntValue(firstData.get("sl"),0); + if(sl > 0){ + if(sysl >= sl){ + DaoUtil.updateData(rs,updateModeSql,sl,id); + }else{ + DaoUtil.updateData(rs,updateModeSql,sysl,id); + } + sl = sl - sysl; + } + }*/ + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/WorkFlowUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/WorkFlowUtil.java new file mode 100644 index 0000000..3f8c392 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/action/WorkFlowUtil.java @@ -0,0 +1,72 @@ +package com.api.taojw.ysld.action; + +import com.api.taojw.common.DaoUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import java.util.Map; + +public class WorkFlowUtil { + + public static String getCurrentFlowSql = "select num,yw from uf_cusddls where lclx = ?"; + public static String addCurrentFlowSql = "insert into uf_cusddls(lclx,num,yw) values(?,?,?)"; + + public static String updateCurrentFlowSql = "update uf_cusddls set num = ?,yw = ? where lclx = ?"; + + public static synchronized String getAndSetFlow(String workFlowId){ + RecordSet rs = new RecordSet(); + Map firstData = DaoUtil.getFirstData(rs, getCurrentFlowSql, workFlowId); + String num = firstData.get("num"); + String yw = firstData.get("yw"); + if(num == null || "".equals(num)){ + DaoUtil.updateData(rs,addCurrentFlowSql,workFlowId,"9","AAA"); + return "9AAA"; + }else{ + if("ZZZ".equals(yw)){ + int newNum = Integer.parseInt(num) - 1; + DaoUtil.updateData(rs,updateCurrentFlowSql,newNum,"AAA",workFlowId); + return newNum+"AAA"; + }else{ + String newYw = generateLetter(yw); + DaoUtil.updateData(rs,updateCurrentFlowSql,num,newYw,workFlowId); + return num+newYw; + } + } + } + + /** + * 字母流水号生成 + * @param oldCode 历史流水号 + * @return 返回新生成的字母流水号 + */ + private static String generateLetter(String oldCode){ + if(StringUtils.isBlank(oldCode)){ + return "AAA"; + } + //将字符串转成char数组 + char[] charArray = oldCode.toCharArray(); + //获取最后一位 + arryAddOne(charArray,2); + //新的字符串 + StringBuilder newString = new StringBuilder(String.valueOf(charArray)); + return newString.toString(); + } + + /** + * 递归处理最后一位 + * @param array 字符数组 + * @param bit 处理数组的中哪一位 + * @return 返回处理后的数组 + */ + private static void arryAddOne(char[] array, int bit){ + if(bit >= 0){ + char current = array[bit]; + if(current == 90){ + array[bit] = 65; + arryAddOne(array,bit-1); + }else{ + array[bit] = (char)(current + 1); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/api/YsldTjwApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/api/YsldTjwApi.java new file mode 100644 index 0000000..ded8a82 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/api/YsldTjwApi.java @@ -0,0 +1,170 @@ +package com.api.taojw.ysld.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.*; + +/** + * 洲际酒店 + * 建模保存后触发异动流程 + */ +@Path("/ysldtjw") +public class YsldTjwApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/getCpInfo") + @Produces(MediaType.APPLICATION_JSON) + public String startWorkFlow(@Context HttpServletRequest request, @Context HttpServletResponse response){ + try{ + logger.info(this.getClass() + "---------- getCpInfo begin "); + JSONObject result = new JSONObject(); + RecordSet rs = new RecordSet(); + String cpbhIds = request.getParameter("cpbhIds"); + String modeTableName = request.getParameter("modeTableName"); + String cpbhColumnName = request.getParameter("cpbhColumnName"); + String ddbhColumnName = request.getParameter("ddbhColumnName"); + String zwmsColumnName = request.getParameter("zwmsColumnName"); + String cplxColumnName = request.getParameter("cplxColumnName"); + String kcyeslColumnName = request.getParameter("kcyeslColumnName"); + if("".equals(cpbhIds) || cpbhIds == null){ + return ""; + } + String getIdSql = "select id from " + modeTableName + " where id in (" + cpbhIds + ") order by dqrq asc"; + List> data = DaoUtil.getData(rs, getIdSql); + List idLiST = new ArrayList<>(); + for(Map m : data){ + idLiST.add(m.get("id")); + } + String[] cpbhIdArr = (String[]) idLiST.stream().toArray(); + + //String[] cpbhIdArr = cpbhIds.split(","); + //Arrays.sort(cpbhIdArr, Collections.reverseOrder()); + String cpInfoSql = + "select " + + cpbhColumnName+","+ddbhColumnName+","+zwmsColumnName+","+cplxColumnName+",CASE WHEN lysl IS NULL AND thsl IS NULL and dcthsl IS NULL THEN sssl ELSE sssl - COALESCE(lysl, 0) + COALESCE(thsl, 0) -COALESCE(dcthsl, 0) END AS kcyesl "+ + "from " + + modeTableName + " t1 " + + "where " + + "t1.id = ?"; + //返回信息: + JSONArray arr = new JSONArray(); + for(String id : cpbhIdArr){ + Map firstData = DaoUtil.getFirstData(rs, cpInfoSql, id); + String cpbh = Util.null2String(firstData.get(cpbhColumnName.toLowerCase(Locale.ROOT))); + String ddbh = Util.null2String(firstData.get(ddbhColumnName.toLowerCase(Locale.ROOT))); + String zwms = Util.null2String(firstData.get(zwmsColumnName.toLowerCase(Locale.ROOT))); + String cplx = Util.null2String(firstData.get(cplxColumnName.toLowerCase(Locale.ROOT))); + int kcyesl = Util.getIntValue(firstData.get(kcyeslColumnName.toLowerCase(Locale.ROOT)),0); + JSONObject o = result.getJSONObject(cpbh); + if(o == null){ + JSONObject cpbhJson = new JSONObject(); + cpbhJson.put("cpbhids",id); + cpbhJson.put("ddbh",ddbh); + cpbhJson.put("zwms",zwms); + cpbhJson.put("cplx",cplx); + cpbhJson.put("kcyesl",kcyesl); + cpbhJson.put("id",id); + cpbhJson.put("cpbh",cpbh); + result.put(cpbh,cpbhJson); + }else{ + String oldId = o.getString("cpbhids"); + o.put("cpbhids",oldId+","+id); + String oldDdbh = o.getString("ddbh"); + o.put("ddbh",oldDdbh+","+ddbh); + int oldKcyesl = o.getIntValue("kcyesl"); + o.put("kcyesl",oldKcyesl+kcyesl); + } + } + for(Object cpbh : result.keySet()){ + JSONObject o = result.getJSONObject((String) cpbh); + arr.add(o); + } + JSONObject r = new JSONObject(); + r.put("arr",arr); + logger.info(this.getClass() + "---------- getCpInfo end "); + return r.toJSONString(); + }catch (Throwable e){ + logger.error(this.getClass() + "---------- getCpInfo error;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + @POST + @Path("/getDetailCpInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailCpInfo(@Context HttpServletRequest request, @Context HttpServletResponse response){ + try{ + logger.info(this.getClass() + "---------- getCpInfo begin "); + JSONObject result = new JSONObject(); + RecordSet rs = new RecordSet(); + String cpbhIds = request.getParameter("cpbhIds"); + String modeTableName = request.getParameter("modeTableName"); + String cpbhColumnName = request.getParameter("cpbhColumnName"); + String ddbhColumnName = request.getParameter("ddbhColumnName"); + String slColumnName = request.getParameter("slColumnName"); + if("".equals(cpbhIds) || cpbhIds == null){ + return ""; + } + String[] cpbhIdArr = cpbhIds.split(","); + String cpInfoSql = + "select " + + "t1." +ddbhColumnName + ",t2." + cpbhColumnName + ",t2." + slColumnName + " " + + "from " + + modeTableName + " t1 " + + "inner join " + modeTableName + "_dt1 t2 on t2.mainid = t1.id " + + "where " + + "t2.id = ?"; + //返回信息: + JSONArray arr = new JSONArray(); + for(String id : cpbhIdArr){ + Map firstData = DaoUtil.getFirstData(rs, cpInfoSql, id); + String cpbh = Util.null2String(firstData.get(cpbhColumnName.toLowerCase(Locale.ROOT))); + String ddbh = Util.null2String(firstData.get(ddbhColumnName.toLowerCase(Locale.ROOT))); + int sl = Util.getIntValue(firstData.get(slColumnName.toLowerCase(Locale.ROOT)),0); + JSONObject o = result.getJSONObject(cpbh); + if(o == null){ + JSONObject cpbhJson = new JSONObject(); + cpbhJson.put("cpbhids",id); + cpbhJson.put("ddbh",ddbh); + cpbhJson.put("sl",sl); + cpbhJson.put("id",id); + cpbhJson.put("cpbh",cpbh); + result.put(cpbh,cpbhJson); + }else{ + String oldId = o.getString("cpbhids"); + o.put("cpbhids",oldId+","+id); + String oldDdbh = o.getString("ddbh"); + o.put("ddbh",oldDdbh+","+ddbh); + int oldSl = o.getIntValue("sl"); + o.put("sl",oldSl+sl); + } + } + for(Object cpbh : result.keySet()){ + JSONObject o = result.getJSONObject((String) cpbh); + arr.add(o); + } + JSONObject r = new JSONObject(); + r.put("arr",arr); + logger.info(this.getClass() + "---------- getCpInfo end "); + return r.toJSONString(); + }catch (Throwable e){ + logger.error(this.getClass() + "---------- getCpInfo error;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/ysld/cronjob/ModeToWorkflowDataCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/cronjob/ModeToWorkflowDataCronjob.java new file mode 100644 index 0000000..08c4449 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/ysld/cronjob/ModeToWorkflowDataCronjob.java @@ -0,0 +1,123 @@ +package com.api.taojw.ysld.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 雅诗兰黛 + * 扫描建模数据 和 流程数据匹配 更新字段 + */ +public class ModeToWorkflowDataCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String configId = ""; + public String getConfigId() { + return configId; + } + public void setConfigId(String configId) { + this.configId = configId; + } + + @Override + public void execute() { + try{ + logger.info(this.getClass() + " begin;"); + RecordSet rs = new RecordSet(); + String getConfigSql = "select t1.*,t2.modekey,t2.workflowkey,t2.modezdysql,t2.workflowzdysql from uf_mdtwflw t1 inner join uf_mdtwflw_dt1 t2 on t2.mainid =t1.id where t1.id = ?"; + List> firstData = DaoUtil.getData(rs, getConfigSql, configId); + String workFlowTableName = ""; + String modeTableName = ""; + String workFlowUpdateColName = ""; + String modeUpdateColName = ""; + String onString = ""; + String columnString = ""; + String modeKeyString = ""; + String workFlowKeyString = ""; + for(Map m : firstData){ + workFlowTableName = m.get("workflowtablename"); + modeTableName = m.get("modetablename"); + workFlowUpdateColName = m.get("workflowupdatecolname"); + modeUpdateColName = m.get("modeupdatecolname"); + String modekey = m.get("modekey"); + String workflowkey = m.get("workflowkey"); + String modezdysql = Util.null2String(m.get("modezdysql")); + String workflowzdysql = Util.null2String(m.get("workflowzdysql")); + + if("".equals(onString)){ + onString = " t1."+modekey+" = "+"t2."+workflowkey.split("\\.")[1]; + }else{ + onString = onString + " and t1."+modekey+" = "+"t2."+workflowkey.split("\\.")[1]; + } + + if("".equals(columnString)){ + columnString = workflowkey; + }else{ + columnString = columnString + "," + workflowkey; + } + + if("".equals(modeKeyString)){ + modeKeyString = modezdysql.equals("")?modekey:"("+modezdysql+") as " + modekey; + }else{ + modeKeyString = modeKeyString + "," + (modezdysql.equals("")?modekey:"("+modezdysql+") as " + modekey); + } + + if("".equals(workFlowKeyString)){ + workFlowKeyString = workflowzdysql.equals("")?workflowkey.split("\\.")[1]:"("+workflowzdysql+") as " + workflowkey.split("\\.")[1]; + }else{ + workFlowKeyString = workFlowKeyString + "," + (workflowzdysql.equals("")?workflowkey.split("\\.")[1]:"("+workflowzdysql+") as " + workflowkey.split("\\.")[1]); + } + + } + + String workFlowMainTableName = ""; + String workFlowDetailTableName = ""; + String[] sA = workFlowTableName.split("_"); + for(String s : sA){ + if(s.startsWith("dt") || s.startsWith("DT") || s.startsWith("dT") || s.startsWith("Dt")){ + workFlowDetailTableName = workFlowTableName; + }else{ + if("".equals(workFlowMainTableName)){ + workFlowMainTableName = s; + }else{ + workFlowMainTableName = workFlowMainTableName + "_" + s; + } + } + } + logger.info("workFlowMainTableName:" + workFlowMainTableName + ";workFlowMainDetailName:" + workFlowDetailTableName); + String getDataSql = + "select " + + "t2.id,t1." + modeUpdateColName + " " + + "from " + + "(select id,"+modeUpdateColName+","+ modeKeyString +" from " + modeTableName + ") t1 " + + ("".equals(workFlowDetailTableName)? + "inner join (select id," + workFlowKeyString + " from " + workFlowTableName + ") t2 on " + onString + " " + : + "inner join (select dt.id," + columnString + " from " + workFlowMainTableName + " m inner join " + workFlowDetailTableName + " dt on dt.mainid = m.id) t2 on " + onString + " " + ); + logger.info("sql:" + getDataSql); + String updateSql = "update " + workFlowTableName + " set "+ workFlowUpdateColName + " = ? where id = ?"; + String checkIsNullSql = "select " + workFlowUpdateColName + " from " + workFlowTableName + " where id = ?"; + List> data = DaoUtil.getData(rs, getDataSql); + for(Map m : data){ + Map firstData1 = DaoUtil.getFirstData(rs, checkIsNullSql, m.get("id")); + if(Util.null2String(firstData1.get(workFlowUpdateColName.toLowerCase(Locale.ROOT))).equals("")){ + DaoUtil.updateData(rs,updateSql,m.get(modeUpdateColName.toLowerCase(Locale.ROOT)),m.get("id")); + } + } + logger.info(this.getClass() + " end"); + }catch (Throwable e){ + logger.error(this.getClass() + " exception;message:" + e.getMessage() + ";e:" + e); + } + } + + + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/AccountListener.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/AccountListener.java new file mode 100644 index 0000000..24a63b8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/AccountListener.java @@ -0,0 +1,135 @@ +package com.api.taojw.zgtp; + +import com.cntaiping.ft.dlt.data.account.model.Account; +import com.cntaiping.ft.dlt.data.event.AccountEvent; +import com.cntaiping.ft.dlt.data.event.AccountEventType; +import org.springframework.context.ApplicationListener; +import weaver.conn.RecordSet; +import weaver.taojw.common.DaoUtil; +import java.util.List; + +public class AccountListener implements ApplicationListener { + + //TODO 改为记录日志即可 + @Override + public void onApplicationEvent(AccountEvent accountEvent) { + AccountEventType type = accountEvent.getType(); + List accounts = accountEvent.getMessage(); + RecordSet rs = new RecordSet(); + switch(type){ + case Add: + addAccount(accounts,rs); + break; + case Delete: + deleteAccount(accounts,rs); + break; + case Modify: + modifyAccount(accounts,rs); + break; + case Disable: + disableAccount(accounts,rs); + break; + case Enable: + enableAccount(accounts,rs); + break; + case ModifyPassword: + modifyPassword(accounts,rs); + break; + case VerifyAccountPassword: + break; + default: + break; + } + } + + private void addAccount(List accounts,RecordSet rs){ + String addAccountInfoSql = + "insert into uniplatform_account(" + + "unify_id,account_id,tp_id,primary_account,account_code," + + "cn,encrypt_password,account_password,sn,email," + + "mobile,account_status,id_card_number,valid_time,start_time," + + "person_type,employee_type,company_id,company_name,org," + + "org_name,org_full_name,hr_id,level_info,reclaim_account_type," + + "remark,remark_1,remark_2,create_time,update_time" + + ")values(" + + "?,?,?,?,?," + + "?,?,?,?,?," + + "?,?,?,?,?," + + "?,?,?,?,?," + + "?,?,?,?,?," + + "?,?,?,?,?" + + ")"; + for(Account account : accounts){ + DaoUtil.updateData(rs,addAccountInfoSql, + account.getUnifyId(),account.getAccountId(),account.getTpId(),account.getPrimaryAccount(),account.getAccountCode(), + account.getCn(),account.getEncryptPassword(),account.getAccountPassword(),account.getSn(),account.getEmail(), + account.getMobile(),account.getAccountStatus(),account.getIdCardNumber(),account.getValidTime(),account.getStartTime(), + account.getPersonType(),account.getEmployeeType(),account.getCompanyId(),account.getCompanyName(),account.getOrg(), + account.getOrgName(),account.getOrgFullName(),account.getHrId(),account.getLevelInfo(),account.getReclaimAccountType(), + account.getRemark(),account.getRemark1(),account.getRemark2(),account.getCreateTime(),account.getUpdateTime() + ); + } + } + + private void deleteAccount(List accounts,RecordSet rs){ + String updateStatusSql = "update uniplatform_account set account_status = 0 where unify_id = ?"; + for(Account account : accounts){ + DaoUtil.updateData(rs,updateStatusSql,account.getUnifyId()); + } + } + + private void modifyAccount(List accounts,RecordSet rs){ + String updateUserInfoSql = + "update uniplatform_account set " + + "account_id = ?,tp_id = ?,primary_account = ?,account_code = ?," + + "cn = ?,encrypt_password = ?,account_password = ?,sn = ?,email = ?," + + "mobile = ?,account_status = ?,id_card_number = ?,valid_time = ?,start_time = ?," + + "person_type = ?,employee_type = ?,company_id = ?,company_name = ?,org = ?," + + "org_name = ?,org_full_name = ?,hr_id = ?,level_info = ?,reclaim_account_type = ?," + + "remark = ?,remark_1 = ?,remark_2 = ?,create_time = ?,update_time = ? " + + "where " + + "unify_id = ?"; + for(Account account : accounts){ + DaoUtil.updateData(rs,updateUserInfoSql, + account.getAccountId(),account.getTpId(),account.getPrimaryAccount(),account.getAccountCode(), + account.getCn(),account.getEncryptPassword(),account.getAccountPassword(),account.getSn(),account.getEmail(), + account.getMobile(),account.getAccountStatus(),account.getIdCardNumber(),account.getValidTime(),account.getStartTime(), + account.getPersonType(),account.getEmployeeType(),account.getCompanyId(),account.getCompanyName(),account.getOrg(), + account.getOrgName(),account.getOrgFullName(),account.getHrId(),account.getLevelInfo(),account.getReclaimAccountType(), + account.getRemark(),account.getRemark1(),account.getRemark2(),account.getCreateTime(),account.getUpdateTime(), + account.getUnifyId() + ); + } + } + + private void disableAccount(List accounts,RecordSet rs){ + String updateStatusSql = "update uniplatform_account set account_status = 0 where unify_id = ?"; + for(Account account : accounts){ + DaoUtil.updateData(rs,updateStatusSql,account.getUnifyId()); + } + } + + private void enableAccount(List accounts,RecordSet rs){ + String updateStatusSql = "update uniplatform_account set account_status = 1 where unify_id = ?"; + for(Account account : accounts){ + DaoUtil.updateData(rs,updateStatusSql,account.getUnifyId()); + } + } + + private void modifyPassword(List accounts,RecordSet rs){ + String updateStatusSql = "update uniplatform_account set encrypt_password = ? where unify_id = ?"; + for(Account account : accounts){ + DaoUtil.updateData(rs,updateStatusSql,account.getEncryptPassword(),account.getUnifyId()); + } + } + + private void verifyAccountPassword(List accounts,RecordSet rs){ + String updateStatusSql = "update uniplatform_account set encrypt_password = ? where unify_id = ?"; + for(Account account : accounts){ + DaoUtil.updateData(rs,updateStatusSql,account.getEncryptPassword(),account.getUnifyId()); + } + } + + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/CustomAccountDao.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/CustomAccountDao.java new file mode 100644 index 0000000..b7fcc38 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/CustomAccountDao.java @@ -0,0 +1,476 @@ +package com.api.taojw.zgtp; + +import com.cntaiping.ft.dlt.data.account.dao.AccountDao; +import com.cntaiping.ft.dlt.data.account.model.Account; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import java.util.ArrayList; +import java.util.List; + +public class CustomAccountDao implements AccountDao { + + Logger logger = MyLogger.getLogger(); + + @Override + public List selectAll() { + logger.info("CustomAccountDao.selectAll begin;"); + List uids = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String sql = "select unify_id from uniplatform_account "; + if(rs.executeQuery(sql)){ + while(rs.next()){ + uids.add(Util.null2String(rs.getString("unify_id"))); + } + } + logger.info("CustomAccountDao.selectAll end;size:" + uids.size()); + return uids; + } + + @Override + public Boolean deleteAccount(List accountList) { + try{ + logger.info("CustomAccountDao.deleteAccount begin;size:" + accountList.size()); + RecordSetTrans rs = new RecordSetTrans(); + rs.setAutoCommit(true); + String sql = "DELETE FROM uniplatform_account WHERE account_id=?"; + for(Account account : accountList){ + boolean b = rs.executeUpdate(sql, account.getAccountId()); + if(b == false){ + logger.error("CustomAccountDao.deleteAccount sql error;sql:" + sql + ";id:" + account.getAccountId()); + return false; + } + } + return true; + }catch(Exception e){ + logger.error("CustomAccountDao.deleteAccount error;message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + @Override + public Boolean saveBatch(List accountList) { + try{ + logger.info("CustomAccountDao.saveBatch begin;size:" + accountList.size()); + RecordSetTrans rs = new RecordSetTrans(); + rs.setAutoCommit(true); + String sql = "insert into uniplatform_account(account_id,tp_id,unify_id,primary_account,account_code,cn,encrypt_password,account_password,sn,email,mobile,account_status,id_card_number,valid_time,start_time,person_type,employee_type,company_id,company_name,org,org_name,org_full_name,hr_id,level_info,reclaim_account_type,create_time,update_time) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + for(Account account : accountList){ + boolean b = rs.executeUpdate(sql, account.getAccountId(), account.getTpId(), account.getUnifyId(), account.getPrimaryAccount(), account.getAccountCode(), account.getCn(), account.getEncryptPassword(), account.getAccountPassword(), account.getSn(), account.getEmail(), account.getMobile(), account.getAccountStatus(), account.getIdCardNumber(), account.getValidTime(), account.getStartTime(), account.getPersonType(), account.getEmployeeType(), account.getCompanyId(), account.getCompanyName(), account.getOrg(), account.getOrgName(), account.getOrgFullName(), account.getHrId(), account.getLevelInfo(), account.getReclaimAccountType(), account.getCreateTime(), account.getUpdateTime()); + if(b == false){ + logger.error("CustomAccountDao.deleteAccount sql error;sql:" + sql + ";id:" + account.getAccountId()); + return false; + } + } + return true; + }catch(Exception e){ + logger.error("CustomAccountDao.saveBatch error;message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + @Override + public Integer updateAccount(Account account) { + try{ + logger.info("CustomAccountDao.updateAccount begin;id:" + account.getAccountId() + + "getAccountId:" + account.getAccountId() + ";" + + "getTpId:" + account.getTpId()+ ";" + + "getUnifyId:" + account.getUnifyId()+ ";" + + "getPrimaryAccount:" + account.getPrimaryAccount()+ ";" + + "getAccountCode:" + account.getAccountCode()+ ";" + + "getCn:" + account.getCn()+ ";" + + "getEncryptPassword:" + account.getEncryptPassword()+ ";" + + "getAccountPassword:" + account.getAccountPassword()+ ";" + + "getSn:" + account.getSn()+ ";" + + "getEmail:" + account.getEmail()+ ";" + + "getMobile:" + account.getMobile()+ ";" + + "getAccountStatus:" + account.getAccountStatus()+ ";" + + "getIdCardNumber:" + account.getIdCardNumber()+ ";" + + "getValidTime:" + account.getValidTime()+ ";" + + "getStartTime:" + account.getStartTime()+ ";" + + "getPersonType:" + account.getPersonType()+ ";" + + "getEmployeeType:" + account.getEmployeeType()+ ";" + + "getCompanyId:" + account.getCompanyId()+ ";" + + "getCompanyName:" + account.getCompanyName()+ ";" + + "getOrg:" + account.getOrg()+ ";" + + "getOrgName:" + account.getOrgName()+ ";" + + "getOrgFullName:" + account.getOrgFullName()+ ";" + + "getHrId:" + account.getHrId()+ ";" + + "getLevelInfo:" + account.getLevelInfo()+ ";" + + "getReclaimAccountType:" + account.getReclaimAccountType()+ ";" + + "getUpdateTime:" + account.getUpdateTime()+ ";" + + "getUnifyId:" + account.getUnifyId()); + RecordSetTrans rs = new RecordSetTrans(); + rs.setAutoCommit(true); + + String getCountSql = "select count(1) as c from uniplatform_account where unify_id = ?"; + String count = ""; + if(rs.executeQuery(getCountSql,account.getUnifyId())){ + if(rs.next()){ + count = Util.null2String(rs.getString("c")); + } + } + String sql = "update uniplatform_account SET account_id = ?,tp_id = ? ,unify_id = ?,primary_account = ?,account_code = ?,cn = ?,encrypt_password = ?,account_password = ?,sn = ?,email = ?,mobile = ?,account_status = ?,id_card_number = ?,valid_time = ?,start_time = ?,person_type = ?,employee_type = ?,company_id = ?,company_name = ?,org = ?,org_name = ?,org_full_name = ?,hr_id = ?,level_info = ?,reclaim_account_type = ?,update_time=? where unify_id = ?"; + logger.info("sql:begin;" + sql + ";"); + if(!rs.executeUpdate(sql, new Object[]{account.getAccountId(), account.getTpId(), account.getUnifyId(), account.getPrimaryAccount(), account.getAccountCode(), account.getCn(), account.getEncryptPassword(), account.getAccountPassword(), account.getSn(), account.getEmail(), account.getMobile(), account.getAccountStatus(), account.getIdCardNumber(), account.getValidTime(), account.getStartTime(), account.getPersonType(), account.getEmployeeType(), account.getCompanyId(), account.getCompanyName(), account.getOrg(), account.getOrgName(), account.getOrgFullName(), account.getHrId(), account.getLevelInfo(), account.getReclaimAccountType(), account.getUpdateTime(), account.getUnifyId()})){ + logger.error("sql error:" + sql); + logger.error("CustomAccountDao.updateAccount sql error;sql:" +sql + ";param:" + + "getAccountId:" + account.getAccountId() + ";" + + "getTpId:" + account.getTpId()+ ";" + + "getUnifyId:" + account.getUnifyId()+ ";" + + "getPrimaryAccount:" + account.getPrimaryAccount()+ ";" + + "getAccountCode:" + account.getAccountCode()+ ";" + + "getCn:" + account.getCn()+ ";" + + "getEncryptPassword:" + account.getEncryptPassword()+ ";" + + "getAccountPassword:" + account.getAccountPassword()+ ";" + + "getSn:" + account.getSn()+ ";" + + "getEmail:" + account.getEmail()+ ";" + + "getMobile:" + account.getMobile()+ ";" + + "getAccountStatus:" + account.getAccountStatus()+ ";" + + "getIdCardNumber:" + account.getIdCardNumber()+ ";" + + "getValidTime:" + account.getValidTime()+ ";" + + "getStartTime:" + account.getStartTime()+ ";" + + "getPersonType:" + account.getPersonType()+ ";" + + "getEmployeeType:" + account.getEmployeeType()+ ";" + + "getCompanyId:" + account.getCompanyId()+ ";" + + "getCompanyName:" + account.getCompanyName()+ ";" + + "getOrg:" + account.getOrg()+ ";" + + "getOrgName:" + account.getOrgName()+ ";" + + "getOrgFullName:" + account.getOrgFullName()+ ";" + + "getHrId:" + account.getHrId()+ ";" + + "getLevelInfo:" + account.getLevelInfo()+ ";" + + "getReclaimAccountType:" + account.getReclaimAccountType()+ ";" + + "getUpdateTime:" + account.getUpdateTime()+ ";" + + "getUnifyId:" + account.getUnifyId()); + } + return Integer.valueOf(count); + }catch (Exception e){ + logger.error("CustomAccountDao.updateAccount error;message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + @Override + public Account verifyAccountPassword(String uid, String accountPassword) { + try{ + logger.info("CustomAccountDao.verifyAccountPassword begin;id:" + uid + ";accountPassword:" + accountPassword); + String sql = "select account_id,tp_id,unify_id,primary_account,account_code,cn,encrypt_password,account_password,sn,email,mobile,account_status,id_card_number,valid_time,start_time,person_type,employee_type,company_id,company_name,org,org_name,org_full_name,hr_id,level_info,reclaim_account_type,create_time,update_time from uniplatform_account where unify_id = ? and account_password = ?"; + final Account account = new Account(); + RecordSet rs = new RecordSet(); + if(rs.executeQuery(sql,uid,accountPassword) && rs.next()){ + account.setUnifyId(uid); + account.setAccountPassword(accountPassword); + account.setAccountId(rs.getString("account_id")); + account.setTpId(rs.getString("tp_id")); + account.setUnifyId(rs.getString("unify_id")); + account.setPrimaryAccount(rs.getString("primary_account")); + account.setAccountCode(rs.getString("account_code")); + account.setCn(rs.getString("cn")); + account.setEncryptPassword(rs.getString("encrypt_password")); + account.setAccountPassword(rs.getString("account_password")); + account.setSn(rs.getString("sn")); + account.setEmail(rs.getString("email")); + account.setMobile(rs.getString("mobile")); + account.setAccountStatus(rs.getString("account_status")); + account.setIdCardNumber(rs.getString("id_card_number")); + account.setValidTime(rs.getString("valid_time")); + account.setStartTime(rs.getString("start_time")); + account.setPersonType(rs.getString("person_type")); + account.setEmployeeType(rs.getString("employee_type")); + account.setCompanyId(rs.getString("company_id")); + account.setCompanyName(rs.getString("company_name")); + account.setOrg(rs.getString("org")); + account.setOrgName(rs.getString("org_name")); + account.setOrgFullName(rs.getString("org_full_name")); + account.setHrId(rs.getString("hr_id")); + account.setLevelInfo(rs.getString("level_info")); + account.setReclaimAccountType(rs.getString("reclaim_account_type")); + account.setCreateTime(rs.getDate("create_time")); + account.setUpdateTime(rs.getDate("update_time")); + }else{ + logger.error("CustomAccountDao.verifyAccountPassword sql error;sql:" + sql); + } + return account; + }catch(Exception e){ + logger.error("CustomAccountDao.verifyAccountPassword error;message:" + e.getMessage() + ";e:" + e); + return null; + } + } + + @Override + public Integer selectAllReclaimAccounts() { + try{ + logger.info("CustomAccountDao.selectAllReclaimAccounts begin;"); + RecordSet rs = new RecordSet(); + String sql = "select count(1) as c from uniplatform_account"; + String count = ""; + if(rs.executeQuery(sql)){ + if(rs.next()){ + count = Util.null2String(rs.getString("c")); + } + } + logger.info("CustomAccountDao.selectAllReclaimAccounts end;count:" + count); + return Integer.valueOf(count); + }catch(Exception e){ + logger.error("CustomAccountDao.selectAllReclaimAccounts error;message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + @Override + public void updateAllReclaimAccountType(String reclaimAccountType) { + try{ + logger.info("CustomAccountDao.updateAllReclaimAccountType begin;reclaimAccountType:" + reclaimAccountType); + RecordSetTrans rs = new RecordSetTrans(); + rs.setAutoCommit(true); + String sql = " update uniplatform_account set reclaim_account_type = ? where 1 = 1"; + if(!rs.executeUpdate(sql,reclaimAccountType)){ + logger.error("CustomAccountDao.updateAllReclaimAccountType sql error;sql:" + sql); + } + }catch (Exception e){ + logger.error("CustomAccountDao.updateAllReclaimAccountType error;message:" + e.getMessage() + ";e:" + e); + } + + } + + @Override + public List selectAllReclaimAccountsPage(Integer currentPage) { + try{ + logger.info("CustomAccountDao.selectAllReclaimAccountsPage begin;reclaimAccountType:" + currentPage); + RecordSet rs = new RecordSet(); + List result = new ArrayList<>(); + String sql = " select account_id,tp_id,unify_id,primary_account,account_code,cn,encrypt_password,account_password,sn,email,mobile,account_status,id_card_number,valid_time,start_time,person_type,employee_type,company_id,company_name,org,org_name,org_full_name,hr_id,level_info,reclaim_account_type,create_time,update_time from uniplatform_account limit ?,500"; + if(rs.executeQuery(sql,currentPage)){ + while(rs.next()){ + Account account = new Account(); + account.setAccountId(rs.getString("account_id")); + account.setTpId(rs.getString("tp_id")); + account.setUnifyId(rs.getString("unify_id")); + account.setPrimaryAccount(rs.getString("primary_account")); + account.setAccountCode(rs.getString("account_code")); + account.setCn(rs.getString("cn")); + account.setEncryptPassword(rs.getString("encrypt_password")); + account.setAccountPassword(rs.getString("account_password")); + account.setSn(rs.getString("sn")); + account.setEmail(rs.getString("email")); + account.setMobile(rs.getString("mobile")); + account.setAccountStatus(rs.getString("account_status")); + account.setIdCardNumber(rs.getString("id_card_number")); + account.setValidTime(rs.getString("valid_time")); + account.setStartTime(rs.getString("start_time")); + account.setPersonType(rs.getString("person_type")); + account.setEmployeeType(rs.getString("employee_type")); + account.setCompanyId(rs.getString("company_id")); + account.setCompanyName(rs.getString("company_name")); + account.setOrg(rs.getString("org")); + account.setOrgName(rs.getString("org_name")); + account.setOrgFullName(rs.getString("org_full_name")); + account.setHrId(rs.getString("hr_id")); + account.setLevelInfo(rs.getString("level_info")); + account.setReclaimAccountType(rs.getString("reclaim_account_type")); + account.setCreateTime(rs.getDate("create_time")); + account.setUpdateTime(rs.getDate("update_time")); + result.add(account); + } + }else{ + logger.error("CustomAccountDao.selectAllReclaimAccountsPage sql error;sql:" + sql); + } + return result; + }catch (Exception e){ + logger.error("CustomAccountDao.selectAllReclaimAccountsPage error;message:" + e.getMessage() + ";e:" + e); + return null; + } + } + + @Override + public void updateReclaimTypeByUid(String reclaimType, String uid) { + logger.info("CustomAccountDao.updateReclaimTypeByUid begin;reclaimType:" + reclaimType + "uid:" + uid); + RecordSetTrans rs = new RecordSetTrans(); + rs.setAutoCommit(true); + String sql = "update uniplatform_account set reclaim_account_type = ? where unify_id = ?"; + try { + if(!rs.executeUpdate(sql,reclaimType, uid)){ + logger.error("CustomAccountDao.updateReclaimTypeByUid sql error;sql:" + sql); + } + } catch (Exception e) { + logger.error("CustomAccountDao.updateReclaimTypeByUid error;message:" + e.getMessage() + ";e:" + e); + } + } + + @Override + public Account queryByUid(String uid) { + logger.info("CustomAccountDao.queryByUid begin;" + "uid:" + uid); + RecordSet rs = new RecordSet(); + String sql = " select account_id,tp_id,unify_id,primary_account,account_code,cn,encrypt_password,account_password,sn,email,mobile,account_status,id_card_number,valid_time,start_time,person_type,employee_type,company_id,company_name,org,org_name,org_full_name,hr_id,level_info,reclaim_account_type,create_time,update_time from uniplatform_account where unify_id = ?"; + try { + if(rs.executeQuery(sql,uid)){ + if(rs.next()){ + Account account = new Account(); + account.setAccountId(rs.getString("account_id")); + account.setTpId(rs.getString("tp_id")); + account.setUnifyId(rs.getString("unify_id")); + account.setPrimaryAccount(rs.getString("primary_account")); + account.setAccountCode(rs.getString("account_code")); + account.setCn(rs.getString("cn")); + account.setEncryptPassword(rs.getString("encrypt_password")); + account.setAccountPassword(rs.getString("account_password")); + account.setSn(rs.getString("sn")); + account.setEmail(rs.getString("email")); + account.setMobile(rs.getString("mobile")); + account.setAccountStatus(rs.getString("account_status")); + account.setIdCardNumber(rs.getString("id_card_number")); + account.setValidTime(rs.getString("valid_time")); + account.setStartTime(rs.getString("start_time")); + account.setPersonType(rs.getString("person_type")); + account.setEmployeeType(rs.getString("employee_type")); + account.setCompanyId(rs.getString("company_id")); + account.setCompanyName(rs.getString("company_name")); + account.setOrg(rs.getString("org")); + account.setOrgName(rs.getString("org_name")); + account.setOrgFullName(rs.getString("org_full_name")); + account.setHrId(rs.getString("hr_id")); + account.setLevelInfo(rs.getString("level_info")); + account.setReclaimAccountType(rs.getString("reclaim_account_type")); + account.setCreateTime(rs.getDate("create_time")); + account.setUpdateTime(rs.getDate("update_time")); + return account; + } + }else{ + logger.error("CustomAccountDao.queryByUid sql error;sql:" + sql); + } + } catch (Exception e) { + logger.error("CustomAccountDao.queryByUid error;message:" + e.getMessage() + ";e:" + e); + return null; + } + logger.error("CustomAccountDao.queryByUid error;findnothing"); + return null; + } + + @Override + public Integer queryCountByTime(String findStartDate, String findEndDate) { + logger.info("CustomAccountDao.queryCountByTime begin;" + "findStartDate:" + findStartDate + ";findEndDate:" + findEndDate); + RecordSet rs = new RecordSet(); + String count = ""; + String sql = "select count(1) as c from uniplatform_account where update_time >= ? and update_time <= ?"; + if(rs.executeQuery(sql,findStartDate,findEndDate)) { + if (rs.next()) { + count = Util.null2String(rs.getString("c")); + } + }else{ + logger.error("CustomAccountDao.queryCountByTime sql error;sql:" + sql); + } + return Integer.valueOf(count); + } + + @Override + public void partReclaimAccount(String reclaimType, String findStartDate, String findEndDate) { + logger.info("CustomAccountDao.partReclaimAccount begin;reclaimType:" + reclaimType + "findStartDate:" + findStartDate + ";findEndDate:" + findEndDate); + RecordSetTrans rs = new RecordSetTrans(); + rs.setAutoCommit(true); + String sql = "update uniplatform_account set reclaim_account_type = ? where update_time >= ? and update_time <= ?"; + try { + if(!rs.executeUpdate(sql,reclaimType, findStartDate, findEndDate)){ + logger.error("CustomAccountDao.partReclaimAccount sql error;sql:" + sql); + } + } catch (Exception e) { + logger.error("CustomAccountDao.partReclaimAccount error;message:" + e.getMessage() + ";e:" + e); + } + } + + @Override + public List selectPartReclaimAccount(String findStartDate, Integer currentPage, String findEndDate) { + logger.info("CustomAccountDao.selectPartReclaimAccount begin;currentPage:" + currentPage + "findStartDate:" + findStartDate + ";findEndDate:" + findEndDate); + RecordSet rs = new RecordSet(); + List result = new ArrayList<>(); + String sql = " select account_id,tp_id,unify_id,primary_account,account_code,cn,encrypt_password,account_password,sn,email,mobile,account_status,id_card_number,valid_time,start_time,person_type,employee_type,company_id,company_name,org,org_name,org_full_name,hr_id,level_info,reclaim_account_type,create_time,update_time from uniplatform_account limit ?,500"; + if(rs.executeQuery(sql,findStartDate, findEndDate, currentPage)){ + while(rs.next()){ + Account account = new Account(); + account.setAccountId(rs.getString("account_id")); + account.setTpId(rs.getString("tp_id")); + account.setUnifyId(rs.getString("unify_id")); + account.setPrimaryAccount(rs.getString("primary_account")); + account.setAccountCode(rs.getString("account_code")); + account.setCn(rs.getString("cn")); + account.setEncryptPassword(rs.getString("encrypt_password")); + account.setAccountPassword(rs.getString("account_password")); + account.setSn(rs.getString("sn")); + account.setEmail(rs.getString("email")); + account.setMobile(rs.getString("mobile")); + account.setAccountStatus(rs.getString("account_status")); + account.setIdCardNumber(rs.getString("id_card_number")); + account.setValidTime(rs.getString("valid_time")); + account.setStartTime(rs.getString("start_time")); + account.setPersonType(rs.getString("person_type")); + account.setEmployeeType(rs.getString("employee_type")); + account.setCompanyId(rs.getString("company_id")); + account.setCompanyName(rs.getString("company_name")); + account.setOrg(rs.getString("org")); + account.setOrgName(rs.getString("org_name")); + account.setOrgFullName(rs.getString("org_full_name")); + account.setHrId(rs.getString("hr_id")); + account.setLevelInfo(rs.getString("level_info")); + account.setReclaimAccountType(rs.getString("reclaim_account_type")); + account.setCreateTime(rs.getDate("create_time")); + account.setUpdateTime(rs.getDate("update_time")); + result.add(account); + } + }else{ + logger.error("CustomAccountDao.selectPartReclaimAccount sql error;sql:" + sql); + } + return result; + } + + @Override + public Account selectAccountByTpId(String tpId) { + logger.info("CustomAccountDao.selectAccountByTpId begin;tpId:" + tpId); + RecordSet rs = new RecordSet(); + String sql = " select account_id,tp_id,unify_id,primary_account,account_code,cn,encrypt_password,account_password,sn,email,mobile,account_status,id_card_number,valid_time,start_time,person_type,employee_type,company_id,company_name,org,org_name,org_full_name,hr_id,level_info,reclaim_account_type,create_time,update_time from uniplatform_account where unify_id = ?"; + try { + if(rs.executeQuery(sql,tpId)){ + if(rs.next()){ + Account account = new Account(); + account.setAccountId(rs.getString("account_id")); + account.setTpId(rs.getString("tp_id")); + account.setUnifyId(rs.getString("unify_id")); + account.setPrimaryAccount(rs.getString("primary_account")); + account.setAccountCode(rs.getString("account_code")); + account.setCn(rs.getString("cn")); + account.setEncryptPassword(rs.getString("encrypt_password")); + account.setAccountPassword(rs.getString("account_password")); + account.setSn(rs.getString("sn")); + account.setEmail(rs.getString("email")); + account.setMobile(rs.getString("mobile")); + account.setAccountStatus(rs.getString("account_status")); + account.setIdCardNumber(rs.getString("id_card_number")); + account.setValidTime(rs.getString("valid_time")); + account.setStartTime(rs.getString("start_time")); + account.setPersonType(rs.getString("person_type")); + account.setEmployeeType(rs.getString("employee_type")); + account.setCompanyId(rs.getString("company_id")); + account.setCompanyName(rs.getString("company_name")); + account.setOrg(rs.getString("org")); + account.setOrgName(rs.getString("org_name")); + account.setOrgFullName(rs.getString("org_full_name")); + account.setHrId(rs.getString("hr_id")); + account.setLevelInfo(rs.getString("level_info")); + account.setReclaimAccountType(rs.getString("reclaim_account_type")); + account.setCreateTime(rs.getDate("create_time")); + account.setUpdateTime(rs.getDate("update_time")); + return account; + } + }else{ + logger.error("CustomAccountDao.selectAccountByTpId sql error;sql:" + sql); + } + } catch (Exception e) { + logger.error("CustomAccountDao.selectAccountByTpId error;message:" + e.getMessage() + ";e:" + e); + return null; + } + logger.error("CustomAccountDao.selectAccountByTpId error;findnothing;"); + return null; + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/LoginFilter.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/LoginFilter.java new file mode 100644 index 0000000..30a11cb --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/LoginFilter.java @@ -0,0 +1,79 @@ +package com.api.taojw.zgtp; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +public class LoginFilter implements Filter { + + Logger logger = MyLogger.getLogger(); + + private String excludedPage; + private String[] excludedPages; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + excludedPage = filterConfig.getInitParameter("ignores");//此处的ignores就是在web.xml定义的名称一样。 + if (excludedPage != null && excludedPage.length() > 0){ + excludedPages = excludedPage.split(","); + } + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException { + String url = ((HttpServletRequest)servletRequest).getRequestURL().toString(); + if(url.endsWith("/join/monitorXOperation.jsp") || url.endsWith("/join/ln.jsp") || url.endsWith("/api/hrm/common/heartbeat")){ + filterChain.doFilter(servletRequest,servletResponse); + return; + } + + + String toLogin = servletRequest.getParameter("toLogin"); + if("1".equals(toLogin)){ + filterChain.doFilter(servletRequest,servletResponse); + return; + } + boolean flag = false; + HttpServletRequest request = (HttpServletRequest) servletRequest; + for (String page:excludedPages) { + if (request.getRequestURI().equals(page)){ + flag = true; + } + } + if(flag){ + filterChain.doFilter(servletRequest,servletResponse); + return; + } + + User user = HrmUserVarify.getUser((HttpServletRequest) servletRequest, (HttpServletResponse) servletResponse); + if(user != null){ + filterChain.doFilter(servletRequest,servletResponse); + return; + } + //如果OA登录开关打开,则跳转至OA登录页面 + RecordSet rs = new RecordSet(); + String dltRedirectTarget = CommonSqlUtil.getSystemParamValue("dltRedirectTarget",rs); + String kg = CommonSqlUtil.getSystemParamValue("localLoginStatus",rs); + if(!"1".equals(kg)){ + /*((HttpServletResponse) servletResponse).sendRedirect("/dlt/sso/handler?toLogin=1&target=" + dltRedirectTarget);*/ + ((HttpServletResponse) servletResponse).sendRedirect("http://newlogintest.intra.cntaiping.com/login"); + return; + } + filterChain.doFilter(servletRequest,servletResponse); + + } + + @Override + public void destroy() { + + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/LoginImpl.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/LoginImpl.java new file mode 100644 index 0000000..21e10be --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/LoginImpl.java @@ -0,0 +1,71 @@ +package com.api.taojw.zgtp; + +import com.cntaiping.ft.dlt.common.User; +import com.cntaiping.ft.dlt.pc.session.Login; +import org.apache.log4j.Logger; +import weaver.hrm.HrmUserVarify; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.util.Map; + +public class LoginImpl implements Login { + + Logger logger = MyLogger.getLogger(); + + @Override + public boolean onSuccess(User user, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { + try{ + String uid = user.getUid(); + logger.info("LoginImpl.onSuccess begin;uid:" + uid + ";name:" + user.getUserName() + ";"); + String getUserByOutKeySql = "select id from hrmresource where outkey = ?"; + Map uderInfo = DaoUtil.getFirstData(getUserByOutKeySql, uid); + int userId = Integer.parseInt(uderInfo.get("id")); + HttpSession session = httpServletRequest.getSession(); + session.setAttribute("weaver_user@bean",new weaver.hrm.User(userId)); + Cookie cookie=new Cookie("JSESSIONID",session.getId()); + httpServletResponse.addCookie(cookie); + return true; + }catch(Exception e){ + logger.info("LoginImpl.onSuccess error;message:" + e.getMessage() + ";e:" + e); + return false; + } + + } + + @Override + public void onFailure(User user, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { + try{ + String uid = user.getUid(); + String getUserByOutKeySql = "select id from hrmresource where outkey = ?"; + Map uderInfo = DaoUtil.getFirstData(getUserByOutKeySql, uid); + int userId = Integer.parseInt(uderInfo.get("id")); + logger.error("LoginImpl.onFailure;userId:" + userId); + }catch(Exception e){ + logger.info("LoginImpl.onFailure error;message:" + e.getMessage() + ";e:" + e); + } + + } + + @Override + public boolean already(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { + //判断是否登陆过 + weaver.hrm.User user = HrmUserVarify.getUser(httpServletRequest, httpServletResponse); + if(user == null){ + return false; + }else{ + return true; + } + } + + @Override + public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { + HttpSession session = httpServletRequest.getSession(); + session.setAttribute("weaver_user@bean",null); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/ModeSaveApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/ModeSaveApi.java new file mode 100644 index 0000000..fb6f33e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/ModeSaveApi.java @@ -0,0 +1,106 @@ +package com.api.taojw.zgtp; + +import com.alibaba.fastjson.JSONObject; +import com.api.formmode.page.util.Util; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * 中国太平 + */ +@Path("/zgtpmodetjw") +public class ModeSaveApi { + + Logger logger = MyLogger.getLogger(); + + /** + * 建模保存前校验是否存在相同数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/check/issame") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject checkIsSame(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + result.put("res","0"); + String modeId = Util.null2String(request.getParameter("modeId")); + String dxjg = Util.null2String(request.getParameter("dxjg")); + String xyjgjc = Util.null2String(request.getParameter("xyjgjc")); + String type = Util.null2String(request.getParameter("type")); + String billid = Util.null2String(request.getParameter("billid")); + try{ + RecordSet rs = new RecordSet(); + String tableName = CommonSqlUtil.getTableNameByModeId(modeId,rs); + String getDataSql = ""; + Map firstData = new HashMap<>(); + if("edit".equals(type)){ + getDataSql = "select count(1) as count from " + tableName + " where dxjg = ? and xyjgjc = ? and id != ?"; + firstData = DaoUtil.getFirstData(rs,getDataSql,dxjg,xyjgjc,billid); + } + if("new".equals(type)){ + getDataSql = "select count(1) as count from " + tableName + " where dxjg = ? and xyjgjc = ? "; + firstData = DaoUtil.getFirstData(rs,getDataSql,dxjg,xyjgjc); + } + int count = Integer.parseInt(Util.null2String(firstData.get("count"))); + if(count > 0){ + result.put("res","1"); + } + return result; + }catch (Exception e){ + logger.error("ModeSaveApi.checkIsSame exception;message:" + e.getMessage() + ";e:" + e); + result.put("message",e.getMessage()); + } + return result; + } + + /** + * 保存后更新另一个台账的数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject update(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + result.put("res","0"); + String billid = Util.null2String(request.getParameter("billid")); + try{ + RecordSet rs = new RecordSet(); + String getDataSql = "select xyjgjc,dxjg from uf_dxxyjg where id = ?"; + Map data = DaoUtil.getFirstData(rs, getDataSql, billid); + String xyjgjc = Util.null2String(data.get("xyjgjc")); + String dxjg = Util.null2String(data.get("dxjg")); + if("".equals(xyjgjc)){ + return result; + } + String[] idArr = xyjgjc.split(","); + String updateDataSql = "update uf_jggl set zcdxjl = ? where id = ?"; + for(String id : idArr){ + DaoUtil.updateData(rs,updateDataSql,dxjg,id); + } + result.put("res","1"); + return result; + }catch (Exception e){ + logger.error("ModeSaveApi.update exception;message:" + e.getMessage() + ";e:" + e); + result.put("message",e.getMessage()); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/action/CheckAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/action/CheckAction.java new file mode 100644 index 0000000..a02efc0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/action/CheckAction.java @@ -0,0 +1,74 @@ +package com.api.taojw.zgtp.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 小马智行action + * bill流程退回action + * + */ +public class CheckAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String checkTableName = ""; + + public String getCheckTableName() { + return checkTableName; + } + + public void setCheckTableName(String checkTableName) { + this.checkTableName = checkTableName; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getDetailDataSql = + "select " + + "t1.jg,t1.zt,t2.djjgjc,t3.ztmc " + + "from " + + billTableName + "_dt1 t1 " + + "inner join uf_jggl t2 on t2.id = t1.jg " + + "inner join uf_ztgl t3 on t3.id = t1.zt " + + "where " + + "mainid = (select id from " + billTableName + " where requestid = ?) "; + String checkSql = "select count(1) as c from " + checkTableName + " where zt = ? and jgjc = ?"; + List> data = DaoUtil.getData(rs, getDetailDataSql, requestId); + for(Map m : data){ + String zt = Util.null2String(m.get("zt")); + String jg = Util.null2String(m.get("jg")); + String ztmc = Util.null2String(m.get("ztmc")); + String djjgjc = Util.null2String(m.get("djjgjc")); + if(DaoUtil.isDataExists(rs,checkSql,zt,jg)){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("账套:" + ztmc + ";机构:" + djjgjc + ";在流程中已存在,请勿重复发起!"); + return Action.FAILURE_AND_CONTINUE; + } + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("----------------------" + this.getClass() + "NsBeginAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/MergeToPdfApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/MergeToPdfApi.java new file mode 100644 index 0000000..0afcc6f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/MergeToPdfApi.java @@ -0,0 +1,81 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.MergePdfUtil; +import com.itextpdf.text.Document; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.pdf.PdfCopy; +import com.itextpdf.text.pdf.PdfReader; +import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.io.*; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 中国太平 + * + */ +@Path("/zgtptjwpdf") +public class MergeToPdfApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/mergePdf") + @Produces(MediaType.APPLICATION_JSON) + public String send(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + result.put("code","0"); + String ids = request.getParameter("ids"); + if(ids == null || "".equals(ids)){ + return result.toJSONString(); + } + String configId = request.getParameter("configId"); + if(configId == null || "".equals(configId)){ + configId = "1"; + } + String[] idArr = ids.split(","); + try { + RecordSet rs = new RecordSet(); + String mergePdfPath = CommonSqlUtil.getSystemParamValue("mergePdfPath",rs); + String browserMergePdfPath = CommonSqlUtil.getSystemParamValue("browserMergePdfPath",rs); + ByteArrayOutputStream byteArrayOutputStream = MergePdfUtil.mergeFilesToPdf(idArr, configId); + byte[] bytes = byteArrayOutputStream.toByteArray(); + InputStream i = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS"); + String newFilename = dateFormat.format(new Date())+".pdf"; + byte[] buf=new byte[1024]; + File targetFile = new File(mergePdfPath+newFilename); + OutputStream os = null; + os = new FileOutputStream(targetFile); + int ch = 0; + while ((ch = i.read(buf)) > 0) { + os.write(buf, 0, ch); + } + os.close(); + i.close(); + result.put("path",browserMergePdfPath); + result.put("msg",newFilename); + result.put("code","1"); + result.put("bytes", Base64.encodeBase64String(bytes)); + return result.toJSONString(); + } catch (Throwable e) { + logger.error("zgtptjwpdf.mergePdf error;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/SendMailApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/SendMailApi.java new file mode 100644 index 0000000..ced5e8d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/SendMailApi.java @@ -0,0 +1,133 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.email.EmailWorkRunnable; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * 中国太平 + * 查询页面点击按钮 根据配置 生成邮件 发送 + */ +@Path("/zgtptjwmail") +public class SendMailApi { + + Logger logger = MyLogger.getLogger(); + + //存放菜单使用记录的建模表名 + private String modelTableName = "uf_"; + + @POST + @Path("/send") + @Produces(MediaType.APPLICATION_JSON) + public String send(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + User user = HrmUserVarify.getUser(request, response); + String ids = request.getParameter("ids"); + String configId = request.getParameter("configId"); + String modeTableName = request.getParameter("modeTableName"); + logger.info("SendMailApi.send begin;ids:"+ ids + ";configId:" + configId); + + if("".equals(ids) || ids == null){ + return ""; + } + RecordSet rs = new RecordSet(); + //获取发送者和抄送者 + String sendTo = ""; + String cc = ""; + + String getSendToSql = "select yx from uf_dztzr t1 where t1.dqczr = ? and sjrlx = 0"; + List> data = DaoUtil.getData(rs, getSendToSql, user.getUID()); + for(Map m : data){ + String yx = Util.null2String(m.get("yx")); + if(!"".equals(yx)){ + if(sendTo.equals("")){ + sendTo = yx; + }else{ + sendTo = sendTo + "," + yx; + } + } + } + + getSendToSql = "select yx from uf_dztzr t1 where t1.dqczr = ? and sjrlx = 1"; + data = DaoUtil.getData(rs, getSendToSql, user.getUID()); + for(Map m : data){ + String yx = Util.null2String(m.get("yx")); + if(!"".equals(yx)){ + if(cc.equals("")){ + cc = yx; + }else{ + cc = cc + "," + yx; + } + } + } + + //获取配置内容 + String mailTitle = ""; + String mailContent = ""; + String fjzd = ""; + String imageFileIds = ""; + String getConfigSql = "select * from uf_zgtpyjmb where id = ?"; + Map firstData = DaoUtil.getFirstData(rs, getConfigSql,configId); + mailTitle = Util.null2String(firstData.get("yjbt")); + mailContent = Util.null2String(firstData.get("yjnr")); + fjzd = Util.null2String(firstData.get("fjzd")); + + //填充标题、内容 + String getDataInModeSql = "select * from " + modeTableName + " where id = ?"; + String getImageFileIdSql = "select * from docimagefile where docid = ? order by Versionid desc "; + String[] idArr = ids.split(","); + for(String id : idArr){ + String _mailTitle = mailTitle; + String _mailContent = mailContent; + Map firstData1 = DaoUtil.getFirstData(rs, getDataInModeSql, id); + for(String key : firstData1.keySet()){ + _mailTitle = _mailTitle.replaceAll(key,firstData1.get(key)); + _mailContent = _mailContent.replaceAll(key,firstData1.get(key)); + } + String _imageFileIds = ""; + if(!"".equals(fjzd)){ + String docIds = firstData1.get(fjzd); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArr = docIds.split(","); + for(String docId : docIdArr){ + Map firstData2 = DaoUtil.getFirstData(rs, getImageFileIdSql, docId); + String imageFileId = Util.null2String(firstData2.get("imagefileid")); + if(!"".equals(imageFileId)){ + if("".equals(_imageFileIds)){ + _imageFileIds = imageFileId; + }else{ + _imageFileIds = _imageFileIds + "," + imageFileId; + } + } + } + } + } + //发送邮件 + EmailWorkRunnable emailSender = new EmailWorkRunnable(); + emailSender.threadModeReminder(sendTo,cc,"", _mailTitle, _mailContent,_imageFileIds); + } + }catch (Throwable e){ + result.put("flag","2"); + logger.error("SendMailApi.send exception;message:" + e.getMessage() + ";e:" + e); + } + result.put("flag","1"); + return result.toJSONString(); + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmInfoApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmInfoApi.java new file mode 100644 index 0000000..4acfa67 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmInfoApi.java @@ -0,0 +1,83 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.*; + +/** + * 供外系统调用,用于同步人员信息 + */ +@Path("/jysczhgl") +public class ZgtpSynHrmInfoApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/staff/synStaffChange") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + List> resultList = new ArrayList<>(); + try{ + logger.info("ZgtpSynHrmInfoApi begin;"); + RecordSet rs = new RecordSet(); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONArray jsonArray = (JSONArray) param.get("jsonArray"); + for(int i = 0;i < jsonArray.size(); i++){ + JSONObject m = (JSONObject) jsonArray.get(i); + String u_id = (String) m.get("u_id"); + String staff_status = (String) m.get("staff_status"); + //向建模中记录信息 + TjwModelUtil.addModelData(rs,"uf_tbryjkjl",m); + String updateHrmStatusSql = + "update hrmresource set status = ? where outkey = ?"; + String status = ""; + if("1".equals(staff_status)){ + status = "1"; + }else if("2".equals(staff_status) || "3".equals(staff_status)){ + status = "7"; + }else if("4".equals(staff_status)){ + status = "5"; + } + if(!"".equals(status)){ + DaoUtil.updateData(rs,updateHrmStatusSql,status,u_id); + } + Map info = new HashMap<>(); + info.put("u_id",u_id); + info.put("staff_sysresult","1"); + info.put("staff_errorInfo",""); + resultList.add(info); + } + + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + JSONObject item = new JSONObject(); + item.put("target_sysid",""); + item.put("target_sysname",""); + item.put("resultList",resultList); + result.put("item",item); + logger.info("ZgtpSynHrmInfoApi done;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("ZgtpSynHrmInfoApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmJobInfoApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmJobInfoApi.java new file mode 100644 index 0000000..986b855 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmJobInfoApi.java @@ -0,0 +1,79 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.*; + +@Path("/jysczhgl") +public class ZgtpSynHrmJobInfoApi { + + Logger logger = MyLogger.getLogger(); + + //存放上游岗位信息和oa岗位信息对应关系的建模 + private String modelTableName = "uf_"; + + @POST + @Path("/post/synPostStaffChange") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("ZgtpSynHrmJobInfoApi begin;"); + RecordSet rs = new RecordSet(); + modelTableName = CommonSqlUtil.getSystemParamValue("hrmjobinfotable",rs); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONArray jsonArray = (JSONArray) param.get("jsonArray"); + + String updateHrmJobSql = "update hrmresource set jobtitle = ? where outkey = ?"; + String getOaJobIdSql = "select oaid from " + modelTableName + " where post_id = ?"; + + String u_ids = ""; + String post_id = ""; + for(int i = 0;i < jsonArray.size(); i++){ + JSONObject m = (JSONObject) jsonArray.get(i); + post_id = (String) m.get("post_id"); + String u_id = (String) m.get("u_id"); + Map oaJobIdInfo = DaoUtil.getFirstData(rs, getOaJobIdSql, post_id); + String oaJobId = oaJobIdInfo.get("oaid"); + DaoUtil.updateData(rs,updateHrmJobSql,oaJobId,u_id); + + if(i == 0){ + u_ids = post_id; + }else{ + u_ids = u_ids + "," + post_id; + } + } + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + JSONObject item = new JSONObject(); + item.put("target_sysid",""); + item.put("target_sysname",""); + item.put("post_id",post_id); + item.put("u_ids",u_ids); + result.put("item",item); + logger.info("ZgtpSynHrmJobInfoApi done;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("ZgtpSynHrmJobInfoApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmLoginInfoApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmLoginInfoApi.java new file mode 100644 index 0000000..153038e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynHrmLoginInfoApi.java @@ -0,0 +1,78 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.text.SimpleDateFormat; +import java.util.*; + +@Path("/jysczhgl") +public class ZgtpSynHrmLoginInfoApi { + + Logger logger = MyLogger.getLogger(); + + //全量推送该用户ID&最后登录时间 + @POST + @Path("/staff/queryUserLoginInfo") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("ZgtpSynHrmLoginInfoApi begin;"); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONObject jsonParam = (JSONObject) param.get("json"); + String target_sysid = jsonParam.getString("target_sysid"); + String target_sysname = jsonParam.getString("target_sysname"); + RecordSet rs = new RecordSet(); + String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + String getLoginDataSql = + "select " + + "t3.unify_id as uid,t4.ip as ip,t1.operatetime as operatetime " + + "from " + + "hrmsysmaintenancelog t1 " + + "inner join hrmresource t2 on t2.id = t1.relatedid " + + "inner join uniplatform_account t3 on t2.outkey = t3.unify_id " + + "inner join (select relatedid,max(clientaddress) as ip from hrmsysmaintenancelog where operatedate = ? and operatetype = 6 group by relatedid) t4 on t4.relatedid = t1.relatedid " + + "where " + + "t1.operatedate = ? " + + "and t1.operatetype = 6 " + + "group by " + + "t1.relatedid"; + List> resultList = new ArrayList<>(); + List> data = DaoUtil.getData(rs, getLoginDataSql, today,today); + for(Map m : data){ + Map o = new HashMap<>(); + o.put("u_id",m.get("uid")); + o.put("last_login_date",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(today + " " + m.get("operatetime"))); + o.put("ip",m.get("ip")); + resultList.add(o); + } + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + JSONObject item = new JSONObject(); + item.put("target_sysid",target_sysid); + item.put("target_sysname",target_sysname); + item.put("resultList",resultList); + result.put("item",item); + logger.info("ZgtpSynHrmLoginInfoApi.sync done;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("ZgtpSynHrmLoginInfoApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynJobAndMenuInfoApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynJobAndMenuInfoApi.java new file mode 100644 index 0000000..2a12bbd --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynJobAndMenuInfoApi.java @@ -0,0 +1,57 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +@Path("/jysczhgl") +public class ZgtpSynJobAndMenuInfoApi { + + Logger logger = MyLogger.getLogger(); + + //存放岗位菜单对应关系的建模 + private String modelTableName = "uf_"; + + @POST + @Path("/menu/synPostMenuChange") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("ZgtpSynMenuUseInfoApi begin;"); + RecordSet rs = new RecordSet(); + modelTableName = CommonSqlUtil.getSystemParamValue("jobandmenuinfotable",rs); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONArray jsonArray = (JSONArray) param.get("jsonArray"); + + for(int i = 0;i < jsonArray.size(); i++){ + JSONObject m = (JSONObject) jsonArray.get(i); + TjwModelUtil.addOrUpdateModelData(rs,modelTableName,m,"post_id"); + } + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + logger.info("ZgtpSynMenuUseInfoApi done;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("ZgtpSynMenuUseInfoApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynJobtitleInfoApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynJobtitleInfoApi.java new file mode 100644 index 0000000..374ce7f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynJobtitleInfoApi.java @@ -0,0 +1,103 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.*; + +@Path("/jysczhgl") +public class ZgtpSynJobtitleInfoApi { + + Logger logger = MyLogger.getLogger(); + + private String modelTableName = ""; + + @POST + @Path("/post/synPostChange") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + List> resultList = new ArrayList<>(); + try{ + logger.info("zgtpSynJobtitleInfoApi begin;"); + RecordSet rs = new RecordSet(); + modelTableName = CommonSqlUtil.getSystemParamValue("jobinfotable",rs); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONArray jsonArray = (JSONArray) param.get("jsonArray"); + + String updateJobInfoSql = "update hrmjobtitles set jobtitlemark = ?,jobtitlename = ?,canceled = ? where id = ?"; + String updateModelDataOaIdSql = "update " + modelTableName + " set oaid = ? where post_id = ?"; + for(int i = 0;i < jsonArray.size(); i++){ + JSONObject m = (JSONObject) jsonArray.get(i); + String post_id = (String) m.get("post_id"); + String post_name = (String) m.get("post_name"); + String post_status = (String) m.get("post_status"); + Date post_updateDate = (Date) m.get("post_updateDate"); + String post_updateUser = (String) m.get("post_updateUser"); + //向建模中新增或更新信息 + TjwModelUtil.addOrUpdateModelData(rs,modelTableName,m,"post_id"); + String getOaIdSql = "select oaid from " + modelTableName + " where post_id = ?"; + Map oaIdData = DaoUtil.getFirstData(rs, getOaIdSql, post_id); + String oaId = oaIdData.get("oaid"); + //如果建模中的oaId不为空 则更新hrmjobtitles表 + if(oaId != null && !"".equals(oaId)){ + String canceled = ""; + if("2".equals(post_status)){ + canceled = "1"; + } + DaoUtil.updateData(rs,updateJobInfoSql,post_name,post_name,canceled,post_id); + } + //如果建模中的oaId为空,则新建岗位 并更新建模里的oaId字段 + if(oaId == null || "".equals(oaId)){ + char separator = Util.getSeparator(); + String insertSql = post_name + separator + post_name + separator + "" + separator + "" + separator + "" + separator + "" + separator + ""; + if(!rs.executeProc("HrmJobTitles_Insert", insertSql)) { + logger.error("HrmJobTitles_Insert fail;postName:" + post_name); + }else{ + if(rs.next()){ + oaId = String.valueOf(rs.getInt(1)); + DaoUtil.updateData(rs,updateModelDataOaIdSql,oaId,post_id); + }else{ + logger.error("HrmJobTitles_Insert next fail;postName:" + post_name); + } + } + } + Map info = new HashMap<>(); + info.put("post_id",post_id); + info.put("post_sysresult","1"); + info.put("post_errorInfo",""); + resultList.add(info); + } + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + JSONObject item = new JSONObject(); + item.put("target_sysid",""); + item.put("target_sysname",""); + item.put("resultList",resultList); + result.put("item",item); + logger.info("zgtpSynJobtitleInfoApi done;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("zgtpSynJobtitleInfoApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynMenuApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynMenuApi.java new file mode 100644 index 0000000..edb569c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynMenuApi.java @@ -0,0 +1,184 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import com.weaver.general.TimeUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.*; + +@Path("/jysczhgl") +public class ZgtpSynMenuApi { + + Logger logger = MyLogger.getLogger(); + + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + //同步菜单 + @POST + @Path("/menu/synMenuChange") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + RecordSet rs = new RecordSet(); + try{ + logger.info("ZgtpSynMenuApi begin;"); + int modelId = CommonSqlUtil.getModeIdByTableName("uf_tbcdjl", rs); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONArray jsonParam = (JSONArray) param.get("jsonArray"); + + //遍历入参菜单 新增或修改 + for(int i = 0;i < jsonParam.size(); i++){ + JSONObject m = (JSONObject) jsonParam.get(i); + String menu_id = (String) m.get("menu_id"); + String menu_name = (String) m.get("menu_name"); + String menu_state = (String) m.get("menu_state"); + String menu_order = (String) m.get("menu_order"); + String menu_parentId = (String) m.get("menu_parentId"); + String menu_url = (String) m.get("menu_url"); + String menu_updateDate = (String) m.get("menu_updateDate"); + //若menu_id在建模中没有 则新增 否则 修改菜单信息 + String getMenuIdInModelSql = "select oamenuid,id from uf_tbcdjl where menu_id = ?"; + Map menuInfoInModel = DaoUtil.getFirstData(rs, getMenuIdInModelSql, menu_id); + String oamenuid = menuInfoInModel.get("oamenuid"); + String modelDataId = menuInfoInModel.get("id"); + if(oamenuid == null || "".equals(oamenuid)){ + //建模中插入记录 + int newDataId = -1; + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + newDataId = mdu.getModeDataNewId("uf_tbcdjl", modelId, 1, 0, currentDate, currentTime); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, 1488,newDataId); + //新建菜单 + oamenuid = createMenu(rs, menu_url, "1", "0", menu_name, menu_url); + // + String updateModelSql = + "update uf_tbcdjl set " + + "menu_id = ?,menu_name= ?,menu_state=?,menu_order=?,menu_parentId=?," + + "menu_url=?,menu_updateDate=?,oamenuid=?,oaparentmenuid='-1',oamenulevel='-1' " + + "where " + + "id = ?"; + DaoUtil.updateData(rs,updateModelSql, + menu_id,menu_name,menu_state,menu_order,menu_parentId, + menu_url,menu_updateDate,oamenuid, + newDataId); + }else{ + //更新建模数据 + String updateModelSql = + "update uf_tbcdjl set " + + "menu_id = ?,menu_name= ?,menu_state=?,menu_order=?,menu_parentId=?," + + "menu_url=?,menu_updateDate=?,oamenuid=?,oaparentmenuid='-1',oamenulevel='-1' " + + "where " + + "id = ?"; + DaoUtil.updateData(rs,updateModelSql, + menu_id,menu_name,menu_state,menu_order,menu_parentId, + menu_url,menu_updateDate,oamenuid, + modelDataId); + //更新菜单数据 + updateMenu(rs,oamenuid,menu_url,"1","0",menu_name,menu_url); + } + m.put("oamenuid",oamenuid); + } + //更新建模和菜单表的parentid + for(int i = 0;i < jsonParam.size(); i++){ + JSONObject m = (JSONObject) jsonParam.get(i); + int level = dealLevel(rs, new ArrayList(),m.get("oamenuid") + ""); + String updateOaParentMenuIdSql = + "update uf_tbcdjl t1 set t1.oamenulevel = ?,t1.oaparentmenuid = (select t2.oamenuid from uf_tbcdjl t2 where t2.menu_id = t1.menu_parentId) where t1.menu_id = ?"; + DaoUtil.updateData(rs,updateOaParentMenuIdSql,level,m.get("menu_id")); + String updateMenuLevelSq = + "update leftmenuinfo set menuLevel = ?,parentId = (select t2.oaparentmenuid from uf_tbcdjl t2 where t2.menu_id = ?) where t1.id = ?"; + DaoUtil.updateData(rs,updateMenuLevelSq,level,m.get("oamenuid"),m.get("oamenuid")); + } + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + List> itemList = new ArrayList<>(); + result.put("item",itemList); + logger.info("ZgtpSynMenuApi.sync end;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("ZgtpSynMenuApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + private int dealLevel(RecordSet rs,List parents,String oamenuid){ + String getParentSql = "select oaparentmenuid from uf_tbcdjl where oamenuid= ?"; + Map firstData = DaoUtil.getFirstData(rs, getParentSql, oamenuid); + if(firstData.get("oaparentmenuid") != null && !"".equals(firstData.get("oaparentmenuid"))){ + String _oamenuid = firstData.get("oaparentmenuid"); + parents.add(_oamenuid); + dealLevel(rs,parents,_oamenuid); + } + return parents.size() + 1; + } + + private void updateMenu(RecordSet rs,String oamenuid,String linkAddress,String menuLevel,String parentId,String customName,String fullrouteurl){ + String updateMenuSql = + "update leftmenuinfo set " + + "linkAddress = ?,menuLevel = ?,parentId = ?," + + "customName = ?,fullrouteurl = ?" + + "where " + + "id = ?"; + DaoUtil.updateData(rs,updateMenuSql, + linkAddress,menuLevel,parentId, + customName,fullrouteurl, + oamenuid); + String updateMenuConfigSql = + "update leftmenuconfig set customName = ? where infoid = ?"; + DaoUtil.updateData(rs,updateMenuConfigSql,customName,oamenuid); + } + + private String createMenu(RecordSet rs,String linkAddress,String menuLevel,String parentId,String customName,String fullrouteurl){ + // + int oamenuid = 0; + RecordSet var2 = new RecordSet(); + var2.executeProc("LeftMenuSequenceId_Get", ""); + if (var2.next()) { + oamenuid = var2.getInt(1); + } + String addMenuSql = + "insert into leftmenuinfo" + + "(id,linkAddress,menuLevel,parentId,useCustomName," + + "customName,relatedModuleId,isCustom,refersubid,fullrouteurl)" + + "values(" + + "?,?,?,?,?,?,?,?,?,?" + + ")"; + DaoUtil.updateData(rs,addMenuSql, + oamenuid,linkAddress,menuLevel,parentId,1, + customName,12,2,-1,fullrouteurl + ); + String addMenuConfigSql = + "insert into leftmenuconfig" + + "(userid,infoid,visible,resourceid,resourcetype," + + "locked,lockedById,useCustomName,customName)" + + "values(" + + "?,?,?,?,?,?,?,?,?" + + ")"; + DaoUtil.updateData(rs,addMenuConfigSql, + 0,oamenuid,1,1,1, + 0,0,0,customName + ); + return oamenuid + ""; + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynMenuUseInfoApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynMenuUseInfoApi.java new file mode 100644 index 0000000..81c47e1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/api/ZgtpSynMenuUseInfoApi.java @@ -0,0 +1,58 @@ +package com.api.taojw.zgtp.api; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zgtp.util.TranslateParameter; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +@Path("/jysczhgl") +public class ZgtpSynMenuUseInfoApi { + + Logger logger = MyLogger.getLogger(); + + //存放菜单使用记录的建模表名 + private String modelTableName = "uf_"; + + @POST + @Path("/sync") + @Produces(MediaType.APPLICATION_JSON) + public JSONObject sync(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("ZgtpSynMenuUseInfoApi begin;"); + RecordSet rs = new RecordSet(); + modelTableName = CommonSqlUtil.getSystemParamValue("menuuseinfotable",rs); + Map param = TranslateParameter.requestGetJsonArray(request.getInputStream()); + JSONArray jsonArray = (JSONArray) param.get("jsonArray"); + + for(int i = 0;i < jsonArray.size(); i++){ + JSONObject m = (JSONObject) jsonArray.get(i); + TjwModelUtil.addModelData(rs,modelTableName,m); + } + JSONObject errorObj = new JSONObject(); + errorObj.put("isSuc","1"); + errorObj.put("code","SUCCESS"); + errorObj.put("name",""); + errorObj.put("msg",""); + result.put("error",errorObj); + logger.info("ZgtpSynMenuUseInfoApi done;result:" + result.toJSONString()); + }catch (Exception e){ + logger.error("ZgtpSynMenuUseInfoApi.sync exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/cronjob/CreateFileCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/cronjob/CreateFileCronJob.java new file mode 100644 index 0000000..20c0afb --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/cronjob/CreateFileCronJob.java @@ -0,0 +1,175 @@ +package com.api.taojw.zgtp.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.general.TimeUtil; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.File; +import java.io.FileInputStream; +import java.util.*; + +/** + * 中国太平 + * 根据配置表中的记录,生成附件到建模、流程表中 + */ +public class CreateFileCronJob extends BaseCronJob { + + private String addTableName = ""; + + Logger logger = MyLogger.getLogger(); + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + + @Override + public void execute() { + try{ + logger.info("CreateFileCronJob.execute start;"); + //读取配置表的数据 + RecordSet rs = new RecordSet(); + String getConfigDataSql = "select cllx,glbm,glzj,glstzj,fjzd,wjlj,fjmc,filecreator,seccategory,fjlx,zdlx from uf_fjqy"; + List> data = DaoUtil.getData(rs, getConfigDataSql); + + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + int modelId = CommonSqlUtil.getModeIdByTableName(addTableName,rs); + int newDataId = -1; + //遍历配置 每条数据处理一次 + for(Map m : data){ + //更新 + if("1".equals(m.get("cllx"))){ + dealUpdateFile(rs,m); + } + //新增 + if("0".equals(m.get("cllx"))){ + if(newDataId < 0){ + newDataId = mdu.getModeDataNewId(addTableName, modelId, 1, 0, currentDate, currentTime); + } + dealAddFile(rs,m,newDataId); + } + } + }catch(Exception e){ + logger.error("SendMailCronJob.sendToDoCount exception:" + e.getMessage() + ";e:" + e); + } + } + + public void dealAddFile(RecordSet rs,Map configInfo,int id){ + try{ + logger.info("dealAddFile begin;id:" + id); + String fileColumn = configInfo.get("fjzd"); + String filePath = configInfo.get("wjlj"); + String fileName = configInfo.get("fjmc"); + String fileType = configInfo.get("fjlx"); + if(fileType != null && !"".equals(fileType)){ + fileName = fileName + "." + fileType; + } + int fileCreator = Integer.parseInt(configInfo.get("filecreator")); + int seccategory = Integer.parseInt(configInfo.get("seccategory")); + + File file = new File(filePath); + FileInputStream fileInputStream; + try { + fileInputStream = new FileInputStream(file); + } catch (Exception e) { + logger.error("get inputStream by file exception;filePath:" + filePath + ";message:" + e.getMessage() + ";e:" + e); + return; + } + int imageFileId = TjwDocumentUtil.createFileByInputSteam(fileInputStream, fileName); + int docByImageFileId = -1; + if("0".equals(configInfo.get("zdlx"))){ + docByImageFileId = TjwDocumentUtil.createDocByImageFileId("历史附件",fileName, seccategory, imageFileId, fileCreator); + }else{ + docByImageFileId = TjwDocumentUtil.createDocByImageFileId(fileName, seccategory, imageFileId, fileCreator); + } + //文档 + if("0".equals(configInfo.get("zdlx"))){ + //查询原文档字段是否有值 + String getOldDataSql = "select " + fileColumn + " from " + addTableName + " where id = ?"; + Map firstData = DaoUtil.getFirstData(rs, getOldDataSql, id); + String oldDocId = firstData.get(fileColumn.toLowerCase(Locale.ROOT)); + if("".equals(oldDocId) || oldDocId == null){ + String updateFileSql = "update " + addTableName + " set " + fileColumn + " = ? where id = ?"; + DaoUtil.updateData(rs,updateFileSql,docByImageFileId,id); + }else{ + TjwDocumentUtil.addDocImageInfo(Integer.parseInt(oldDocId),fileName,imageFileId); + } + + String updateFileSql = "update " + addTableName + " set " + fileColumn + " = ? where id = ?"; + DaoUtil.updateData(rs,updateFileSql,docByImageFileId,id); + } + //多文档 附件上传 + if("1".equals(configInfo.get("zdlx")) || "2".equals(configInfo.get("zdlx"))){ + String updateFileSql = "update " + addTableName + " set " + fileColumn + " = nvl(cast(" + fileColumn + " as varchar),'') || '," + docByImageFileId + "' where id = ?"; + if("sqlserver".equalsIgnoreCase(rs.getDBType())){ + updateFileSql = "update " + addTableName + " set " + fileColumn + " = isnull(cast(" + fileColumn + " as varchar),'') + '," + docByImageFileId + "' where id = ?"; + } + DaoUtil.updateData(rs,updateFileSql,id); + } + + }catch(Exception e){ + logger.error("dealAddFile exception;configInfo:" + configInfo + ";message:" + e.getMessage() + ";e:" + e); + } + + } + + public void dealUpdateFile(RecordSet rs,Map configInfo){ + try{ + String tableName = configInfo.get("glbm"); + String keyColumn = configInfo.get("glzj"); + String keyValue = configInfo.get("glstzj"); + String fileColumn = configInfo.get("fjzd"); + String filePath = configInfo.get("wjlj"); + String fileName = configInfo.get("fjmc"); + String fileType = configInfo.get("fjlx"); + if(fileType != null && !"".equals(fileType)){ + fileName = fileName + "." + fileType; + } + int fileCreator = Integer.parseInt(configInfo.get("filecreator")); + int seccategory = Integer.parseInt(configInfo.get("seccategory")); + + File file = new File(filePath); + FileInputStream fileInputStream; + try { + fileInputStream = new FileInputStream(file); + } catch (Exception e) { + logger.error("get inputStream by file exception;filePath:" + filePath + ";message:" + e.getMessage() + ";e:" + e); + return; + } + int imageFileId = TjwDocumentUtil.createFileByInputSteam(fileInputStream, fileName); + int docByImageFileId = -1; + if("0".equals(configInfo.get("zdlx"))){ + docByImageFileId = TjwDocumentUtil.createDocByImageFileId("历史附件",fileName, seccategory, imageFileId, fileCreator); + }else{ + docByImageFileId = TjwDocumentUtil.createDocByImageFileId(fileName, seccategory, imageFileId, fileCreator); + } + //文档 + if("0".equals(configInfo.get("zdlx"))){ + //查询原文档字段是否有值 + String getOldDataSql = "select " + fileColumn + " from " + tableName + " where " + keyColumn + " = ?"; + Map firstData = DaoUtil.getFirstData(rs, getOldDataSql, keyValue); + String oldDocId = firstData.get(fileColumn.toLowerCase(Locale.ROOT)); + if("".equals(oldDocId) || oldDocId == null){ + String updateFileSql = "update " + tableName + " set " + fileColumn + " = ? where " + keyColumn + " = ?"; + DaoUtil.updateData(rs,updateFileSql,docByImageFileId,keyValue); + }else{ + TjwDocumentUtil.addDocImageInfo(Integer.parseInt(oldDocId),fileName,imageFileId); + } + } + //多文档 附件上传 + if("1".equals(configInfo.get("zdlx")) || "2".equals(configInfo.get("zdlx"))){ + String updateFileSql = "update " + tableName + " set " + fileColumn + " = nvl(cast(" + fileColumn + " as varchar),'') || '," + docByImageFileId + "' where " + keyColumn + " = ?"; + if("sqlserver".equalsIgnoreCase(rs.getDBType())){ + updateFileSql = "update " + tableName + " set " + fileColumn + " = isnull(cast(" + fileColumn + " as varchar),'') + '," + docByImageFileId + "' where " + keyColumn + " = ?"; + } + DaoUtil.updateData(rs,updateFileSql,keyValue); + } + }catch (Exception e){ + logger.error("dealUpdateFile exception;configInfo:" + configInfo + ";message:" + e.getMessage() + ";e:" + e); + } + + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/cronjob/UpdateLockCronJob.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/cronjob/UpdateLockCronJob.java new file mode 100644 index 0000000..4cd50d3 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/cronjob/UpdateLockCronJob.java @@ -0,0 +1,47 @@ +package com.api.taojw.zgtp.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +/** + * 中国太平 + * 定时任务处理锁定状态 + */ +public class UpdateLockCronJob extends BaseCronJob { + + private String dltLockStatus = ""; + + public String getDltLockStatus() { + return dltLockStatus; + } + + public void setDltLockStatus(String dltLockStatus) { + this.dltLockStatus = dltLockStatus; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info("UpdateLockCronJob.execute start;"); + //读取配置表的数据 + RecordSet rs = new RecordSet(); + String updateStatusSql = + "update " + + "hrmresource t1,uniplatform_account t2 " + + "set " + + "t1.passwordlock = case when t2.account_status = ? then 1 else 0 end " + + "where " + + "t1.outkey = t2.unify_id"; + DaoUtil.updateData(rs,updateStatusSql,dltLockStatus); + logger.info("UpdateLockCronJob.execute end;"); + }catch(Exception e){ + logger.error("UpdateLockCronJob.sendToDoCount exception:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/util/MergePdfUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/util/MergePdfUtil.java new file mode 100644 index 0000000..1fa6914 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/util/MergePdfUtil.java @@ -0,0 +1,169 @@ +package com.api.taojw.zgtp.util; + +import com.api.taojw.common.TjwDocumentUtil; +import com.itextpdf.text.Document; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.pdf.*; +import org.apache.log4j.Logger; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.PDPageContentStream; +import org.apache.pdfbox.pdmodel.common.PDRectangle; +import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; + +public class MergePdfUtil { + + static Logger logger = MyLogger.getLogger(); + + //传入imageFileIdList + //替换表单域 + //拼接成一个pdf + //返回 + public static ByteArrayOutputStream mergeFilesToPdf(String[] imageFileIdList,String configId) { + try{ + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + Document document = new Document(); + try { + RecordSet rs = new RecordSet(); + String getInfoSql = "select imagefilename,imagefileid from DocImageFile where docid = ? order by versionid desc"; + ImageFileManager imageFileManager = new ImageFileManager(); + PdfCopy copy = new PdfCopy(document, bos); + document.open(); + for (String id : imageFileIdList) { + Map firstData = DaoUtil.getFirstData(rs, getInfoSql, id); + String imagefilename = Util.null2String(firstData.get("imagefilename")); + String imageFileId = Util.null2String(firstData.get("imagefileid")); + //若为pdf,则替换表单域然后拼接 + if(imagefilename.endsWith(".pdf")){ + PdfReader reader = new PdfReader(imageFileManager.getInputStreamById(Integer.parseInt(imageFileId))); + //替换表单域 + ByteArrayOutputStream generate = generate(reader, configId); + ByteArrayInputStream swapStream = new ByteArrayInputStream(generate.toByteArray()); + reader = new PdfReader(swapStream); + + int pageCount = reader.getNumberOfPages(); + for (int pageNum = 0; pageNum < pageCount; pageNum++) { + copy.addPage(copy.getImportedPage(reader, pageNum + 1)); + } + reader.close(); + } + //若不为pdf,转为pdf然后拼接 + if (imagefilename.endsWith("docx") || imagefilename.endsWith("doc")) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + File file = new File(id); + TjwDocumentUtil.copyInputStreamToFile(imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)),file); + convertToPdf(file,baos,"docx"); + ByteArrayInputStream swapStream = new ByteArrayInputStream(baos.toByteArray()); + PdfReader reader = new PdfReader(swapStream); + int pageCount = reader.getNumberOfPages(); + for (int pageNum = 0; pageNum < pageCount; pageNum++) { + copy.addPage(copy.getImportedPage(reader, pageNum + 1)); + } + reader.close(); + } + if (imagefilename.endsWith("png") || imagefilename.endsWith("jpg")) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + File file = new File(id); + TjwDocumentUtil.copyInputStreamToFile(imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)),file); + convertToPdf(file,baos,"png"); + ByteArrayInputStream swapStream = new ByteArrayInputStream(baos.toByteArray()); + PdfReader reader = new PdfReader(swapStream); + int pageCount = reader.getNumberOfPages(); + for (int pageNum = 0; pageNum < pageCount; pageNum++) { + copy.addPage(copy.getImportedPage(reader, pageNum + 1)); + } + reader.close(); + } + } + copy.close(); + } catch (IOException | DocumentException e) { + logger.error("mergeFilesToPdf IOException | DocumentException;message:" + e.getMessage() + ";e:" + e); + } finally { + document.close(); + } + return bos; + }catch(Exception e){ + logger.error("mergeFilesToPdf error;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + public static void convertToPdf(File inputFile, OutputStream outputFile,String type) throws IOException { + PDDocument document = new PDDocument(); + if (type.toLowerCase().endsWith("doc") || type.toLowerCase().endsWith("docx")) { + // 使用 Apache PDFBox 将 doc/docx 文件转换为 PDF + document = PDDocument.load(inputFile); + } else if (type.toLowerCase().endsWith("png") || type.toLowerCase().endsWith("jpg")) { + // 使用 Apache PDFBox 将图片文件转换为 PDF + BufferedImage image = ImageIO.read(inputFile); + document.addPage(new PDPage()); + org.apache.pdfbox.pdmodel.PDPage page = document.getPage(0); + page.setMediaBox(new PDRectangle(image.getWidth(), image.getHeight())); + PDImageXObject imageXObject = PDImageXObject.createFromFileByContent(inputFile,document); + PDPageContentStream contentStream = new PDPageContentStream(document, page); + contentStream.drawImage(imageXObject, 0, 0); + contentStream.close(); + } else { + logger.error("unSupport file Type"); + return; + } + document.save(outputFile); + document.close(); + } + + + public static ByteArrayOutputStream generate(PdfReader template, String configId){ + try { + Map data = new HashMap<>(); + RecordSet rs = new RecordSet(); + String getConfigSql = "select * from uf_cusmpr_dt1 where mainid = ?"; + List> datas = DaoUtil.getData(rs, getConfigSql, configId); + for(Map m : datas){ + String bdy = Util.null2String(m.get("bdy")); + String zdysql = Util.null2String(m.get("zdysql")); + String zdlx = Util.null2String(m.get("zdlx")); + if("0".equals(zdlx)){ + data.put(bdy,zdysql); + }else{ + Map firstData = DaoUtil.getFirstData(rs, zdysql); + for(String key : firstData.keySet()){ + data.put(bdy,firstData.get(key)); + } + } + } + + BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + PdfStamper stamp = new PdfStamper(template, out); + AcroFields form = stamp.getAcroFields(); + for (Iterator it = data.keySet().iterator(); it.hasNext(); ) { + String key = (String) it.next(); + String value = data.get(key); + form.setFieldProperty(key, "textfont", bfChinese, null); + form.setField(key, value); + } + stamp.setFormFlattening(true); + stamp.close(); + template.close(); + return out; + } catch (Throwable e) { + logger.error("generate error;message:" + e.getMessage() + ";e:" + e); + return null; + } + } + +} + diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/util/TranslateParameter.java b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/util/TranslateParameter.java new file mode 100644 index 0000000..4ef64fd --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zgtp/util/TranslateParameter.java @@ -0,0 +1,55 @@ +package com.api.taojw.zgtp.util; + +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.ServletInputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.*; + +public class TranslateParameter { + + static Logger logger = MyLogger.getLogger(); + + /** + * 获取流中的json + * + * @param stream + * @return + */ + public static Map requestGetJsonArray(ServletInputStream stream) { + try { + Map result = new HashMap<>(); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); + StringBuilder bf = new StringBuilder(); + String inputStr; + while ((inputStr = reader.readLine()) != null) { + bf.append(inputStr); + } + String toStrJson = bf.toString(); + logger.info("get data:" + toStrJson); + if (JSONUtil.isJson(toStrJson)) { + JSONObject resultJson = (JSONObject) JSONObject.parse(toStrJson); + logger.info("resultJson:" + resultJson.toJSONString()); + result.put("json",resultJson); + return result; + } + if(JSONUtil.isJsonArray(toStrJson)){ + JSONArray resultJsonArray = (JSONArray) JSONObject.parse(toStrJson); + logger.info("resultJsonArray:" + resultJsonArray.toJSONString()); + result.put("jsonArray",resultJsonArray); + return result; + } + logger.error("data is not json or jsonArray!"); + return new HashMap<>(); + } catch (Exception e) { + logger.error("data is not correct!"); + return new HashMap<>(); + } + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zhenkunhang/DealYsDetailAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/zhenkunhang/DealYsDetailAction.java new file mode 100644 index 0000000..787f5cc --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zhenkunhang/DealYsDetailAction.java @@ -0,0 +1,214 @@ +package com.api.taojw.zhenkunhang; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; + +/** + * 震坤行 + * 处理预算相关明细数据 + */ +public class DealYsDetailAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String cbzxColumn = ""; + private String yskmColumn = ""; + private String tzjeColumn = ""; + + public String getCbzxColumn() { + return cbzxColumn; + } + + public void setCbzxColumn(String cbzxColumn) { + this.cbzxColumn = cbzxColumn; + } + + public String getYskmColumn() { + return yskmColumn; + } + + public void setYskmColumn(String yskmColumn) { + this.yskmColumn = yskmColumn; + } + + public String getTzjeColumn() { + return tzjeColumn; + } + + public void setTzjeColumn(String tzjeColumn) { + this.tzjeColumn = tzjeColumn; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String tableName = requestInfo.getRequestManager().getBillTableName(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + + String currentYear = new SimpleDateFormat("yyyy").format(new Date()); + String currentMonth = new SimpleDateFormat("MM").format(new Date()); + + RecordSet rs = new RecordSet(); + String zrrq = ""; + int currentQ = 0; + if(currentMonth.equals("01") || currentMonth.equals("02") || currentMonth.equals("03")){ + currentQ = 1; + zrrq = currentYear + "-01-01"; + } + if(currentMonth.equals("04") || currentMonth.equals("05") || currentMonth.equals("06")){ + currentQ = 2; + zrrq = currentYear + "-04-01"; + } + if(currentMonth.equals("07") || currentMonth.equals("08") || currentMonth.equals("09")){ + currentQ = 3; + zrrq = currentYear + "-07-01"; + } + + + + String getCurrentQSql = "select zysszjd from " + tableName + " where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getCurrentQSql, requestId); + if(!"".equals(firstData1.get("zysszjd")) && firstData1.get("zysszjd") != null){ + currentQ = Integer.parseInt(firstData1.get("zysszjd")); + currentQ = currentQ + 1; + if(currentQ == 1){ + zrrq = currentYear + "-01-01"; + } + if(currentQ == 2){ + zrrq = currentYear + "-04-01"; + } + if(currentQ == 3){ + zrrq = currentYear + "-07-01"; + } + } + + //当前为第四季度 不做处理 + if(currentQ == 4){ + return Action.SUCCESS; + } + + //获取当前流程表单的成本中心、科目 + + String getRequestInfoSql = "select id,"+cbzxColumn+","+yskmColumn+","+tzjeColumn+" from " + tableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getRequestInfoSql, requestId); + String ysgjbm = firstData.get(cbzxColumn); + String ywxl = firstData.get(yskmColumn); + String djje = firstData.get(tzjeColumn); + String id = firstData.get("id"); + + if("".equals(djje)){ + requestInfo.getRequestManager().setMessageid("2022082691002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,金额必输!"); + return Action.FAILURE_AND_CONTINUE; + } + + Double amount = Double.parseDouble(djje); + int q = currentQ; + String addDetailSql = "insert into " + tableName + "_dt1(mainid,szjd,dzbm,djbm,dzztlx,djztlx,dzqj,djqj,djkm,djje) values (?,?,?,?,?,?,?,?,?,?)"; + for(int i = currentQ;i < 4;i++){ + if(amount > 0){ + Double nextQAvailableAmount = getAavailableAmount(ywxl,ysgjbm,q+1); + if(nextQAvailableAmount >= amount){ + DaoUtil.updateData(rs,addDetailSql,id,q,ysgjbm,ysgjbm,3,3,zrrq,getQFirstDay(q+1),ywxl,amount); + amount = -1d; + }else{ + DaoUtil.updateData(rs,addDetailSql,id,q,ysgjbm,ysgjbm,3,3,zrrq,getQFirstDay(q+1),ywxl,nextQAvailableAmount); + amount = amount - nextQAvailableAmount; + } + q = q + 1; + } + } + return Action.SUCCESS; + }catch(Exception e){ + requestInfo.getRequestManager().setMessageid("2022082691002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action DealYsDetailAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + + private String getQFirstDay(int q){ + String currentYear = new SimpleDateFormat("yyyy").format(new Date()); + if(q == 1){ + return currentYear + "-01-01"; + }else if(q == 2){ + return currentYear + "-04-01"; + }else if(q == 3){ + return currentYear + "-07-01"; + }else if(q == 4){ + return currentYear + "-10-01"; + } + return ""; + } + + + private Double getAavailableAmount(String ywxl,String ysgjbm,int q){ + + logger.info("getAavailableAmount begin;q:" + q + ";ywxl:" + ywxl + ";ysgjbm:" + ysgjbm + ";begin" ); + + + RecordSet rs = new RecordSet(); + String currentYear = new SimpleDateFormat("yyyy").format(new Date()); + //根据当前年份、所属季度、成本中心、科目获取预算总额 + String getAllAmountSql = + "select " + + "t2.budgetaccount as amount " + + "from " + + "fnabudgetinfo t1 " + + "inner join fnabudgetinfodetail t2 on t2.budgetinfoid = t1.id " + + "inner join fnayearsperiods t3 on t3.id = t1.budgetperiods " + + "where " + + "t3.fnayear = ? " + + "and t1.status = 1 " + + "and t2.budgetperiodslist = ? " + + "and t2.budgettypeid = ? " + + "and t1.budgetorganizationid = ? " + + "and t1.organizationtype = 18004 "; + + //根据 + String getAlreadyAmountSql = + "select " + + "sum(case when t1.type = 1 then t1.amount else case when t1.type = 2 then t1.amount else case when t1.type = 3 then -1 * t1.amount else 0 end end end) as amount " + + "from " + + "fnaexpenseinfo t1 " + + "inner join fnayearsperiods t2 on t2.id = t1.budgetperiods " + + "where " + + "t1.organizationid = ? " + + "and t1.organizationtype = 18004 " + + "and t2.fnayear = ? " + + "and t1.subject = ? " + + "and t1.status = 1 " + + "and t1.budgetperiodslist = ?"; + + Map firstData1 = DaoUtil.getFirstData(rs, getAllAmountSql, currentYear, q, ywxl, ysgjbm); + String allAmount = firstData1.get("amount"); + Map firstData2 = DaoUtil.getFirstData(rs, getAlreadyAmountSql, ysgjbm, currentYear, ywxl, q); + String alreadyAmount = firstData2.get("amount"); + + logger.info("allAmount:" + allAmount); + logger.info("alreadyAmount:" + alreadyAmount); + + if("".equals(allAmount) || allAmount == null){ + allAmount = "0"; + } + if("".equals(alreadyAmount) || alreadyAmount == null){ + alreadyAmount = "0"; + } + + double availableAmount = Double.parseDouble(allAmount) - Double.parseDouble(alreadyAmount); + + logger.info("getAavailableAmount end;q:" + q + ";ywxl:" + ywxl + ";ysgjbm:" + ysgjbm + ";availableAmount:" + availableAmount); + return availableAmount; + } + + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zhenkunhang/FpApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zhenkunhang/FpApi.java new file mode 100644 index 0000000..5a60455 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zhenkunhang/FpApi.java @@ -0,0 +1,153 @@ +package com.api.taojw.zhenkunhang; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 震坤行 + */ +@Path("/zkhjw") +public class FpApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/getUsedJe") + @Produces(MediaType.APPLICATION_JSON) + public String getUsedJe(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String workFlowIds = request.getParameter("workFlowIds"); + String tables = request.getParameter("tables"); + String hejeNames = request.getParameter("hejeNames"); + String heseNames = request.getParameter("heseNames"); + String fphmColumns = request.getParameter("fphmColumns"); + String requestId = request.getParameter("requestId"); + String fp = request.getParameter("fp"); + JSONObject result = new JSONObject(); + double yhxje = 0d; + double yhxse = 0d; + try{ + RecordSet rs = new RecordSet(); + + String[] workFlowIdArr = workFlowIds.split(","); + String[] tablesArr = tables.split(","); + String[] hejeNamesArr = hejeNames.split(","); + String[] heseNamesArr = heseNames.split(","); + String[] fphmColumnsArr = fphmColumns.split(","); + for(int i = 0;i < workFlowIdArr.length;i++){ + String workFlowId = workFlowIdArr[i]; + String table = tablesArr[i]; + String heje = hejeNamesArr[i]; + String hese = heseNamesArr[i]; + String fphm = fphmColumnsArr[i]; + String tableName = CommonSqlUtil.getTableNameByWorkflowId(workFlowId,rs); + if(requestId == null || "".equals(requestId)){ + if("0".equals(table)){ + String getDataSql = "select t1."+heje+",t1." + hese +" from " + tableName + " t1 inner join workflow_requestbase t2 on t2.requestid = t1.requestid where t2.currentnodetype = 3 and t1." + fphm + " = ?"; + List> firstData2 = DaoUtil.getData(rs, getDataSql, fp); + for(Map firstData : firstData2){ + yhxje = yhxje + Util.getDoubleValue(firstData.get(heje.toLowerCase(Locale.ROOT)),0); + yhxse = yhxse + Util.getDoubleValue(firstData.get(hese.toLowerCase(Locale.ROOT)),0); + } + }else{ + String getDataSql = "select t1."+heje+",t1." + hese +" from " + tableName + "_dt" + table + " t1 inner join " + tableName + " t2 on t2.id = t1.mainid inner join workflow_requestbase t3 on t3.requestid = t2.requestid where t3.currentnodetype = 3 and t1." + fphm + " = ?"; + List> firstData2 = DaoUtil.getData(rs, getDataSql, fp); + for(Map firstData : firstData2){ + yhxje = yhxje + Util.getDoubleValue(firstData.get(heje.toLowerCase(Locale.ROOT)),0); + yhxse = yhxse + Util.getDoubleValue(firstData.get(hese.toLowerCase(Locale.ROOT)),0); + } + } + }else{ + if("0".equals(table)){ + String getDataSql = "select t1."+heje+",t1." + hese +" from " + tableName + " t1 inner join workflow_requestbase t2 on t2.requestid = t1.requestid where t2.currentnodetype = 3 and t1." + fphm + " = ? and t1.requestid != ?"; + List> firstData2 = DaoUtil.getData(rs, getDataSql, fp,requestId); + for(Map firstData : firstData2){ + yhxje = yhxje + Util.getDoubleValue(firstData.get(heje.toLowerCase(Locale.ROOT)),0); + yhxse = yhxse + Util.getDoubleValue(firstData.get(hese.toLowerCase(Locale.ROOT)),0); + } + }else{ + String getDataSql = "select t1."+heje+",t1." + hese +" from " + tableName + "_dt" + table + " t1 inner join " + tableName + " t2 on t2.id = t1.mainid inner join workflow_requestbase t3 on t3.requestid = t2.requestid where t3.currentnodetype = 3 and t1." + fphm + " = ? and t2.requestid != ?"; + List> firstData2 = DaoUtil.getData(rs, getDataSql, fp,requestId); + for(Map firstData : firstData2){ + yhxje = yhxje + Util.getDoubleValue(firstData.get(heje.toLowerCase(Locale.ROOT)),0); + yhxse = yhxse + Util.getDoubleValue(firstData.get(hese.toLowerCase(Locale.ROOT)),0); + } + + } + } + } + + result.put("yhxje",yhxje); + result.put("yhxse",yhxse); + return result.toJSONString(); + }catch(Exception e){ + logger.error("GetDetailDataApi.getUsedJe exception;requestId:" + requestId + ";fp:" + fp +";message:" + e.getMessage() + ";e:" + e); + } + return result.toJSONString(); + } + + @POST + @Path("/checkUsed") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailData(@Context HttpServletRequest request, @Context HttpServletResponse response){ + String workFlowIds = request.getParameter("workFlowIds"); + String tables = request.getParameter("tables"); + String columnNames = request.getParameter("fphmColumns"); + String requestId = request.getParameter("requestId"); + String fp = request.getParameter("fp"); + JSONObject result = new JSONObject(); + result.put("flag",0); + try{ + RecordSet rs = new RecordSet(); + String[] workFlowIdArr = workFlowIds.split(","); + String[] columnNameArr = columnNames.split(","); + String[] tablesArr = tables.split(","); + for(int i = 0;i < workFlowIdArr.length; i++){ + String workFlowId = workFlowIdArr[i]; + String tableName = CommonSqlUtil.getTableNameByWorkflowId(workFlowId,rs); + String columnName = columnNameArr[i]; + String table = tablesArr[i]; + boolean exists = false; + if(requestId == null || "".equals(requestId)){ + if(!"0".equals(table)){ + String sql = "select count(1) as c from " + tableName + " t1 inner join " + tableName + "_dt" + table + " t2 on t2.mainid = t1.id where t2." + columnName + " = ?"; + exists = DaoUtil.isDataExists(rs,sql,fp); + }else{ + String sql = "select count(1) as c from " + tableName + " where " + columnName + " = ?"; + exists = DaoUtil.isDataExists(rs,sql,fp); + } + }else{ + if(!"0".equals(table)){ + String sql = "select count(1) as c from " + tableName + " t1 inner join " + tableName + "_dt" + table + " t2 on t2.mainid = t1.id where t2." + columnName + " = ? and t1.requestid != ?"; + exists = DaoUtil.isDataExists(rs,sql,fp,requestId); + }else{ + String sql = "select count(1) as c from " + tableName + " where " + columnName + " = ? and requestid != ?"; + exists = DaoUtil.isDataExists(rs,sql,fp,requestId); + } + } + if(exists){ + result.put("flag","1"); + } + } + return result.toJSONString(); + }catch(Exception e){ + logger.error("GetDetailDataApi.getDetailData exception;requestId:" + requestId + ";fp:" + fp +";message:" + e.getMessage() + ";e:" + e); + } + return result.toJSONString(); + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/action/FeishuAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/action/FeishuAction.java new file mode 100644 index 0000000..d84753d --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/action/FeishuAction.java @@ -0,0 +1,144 @@ +package com.api.taojw.zjfs.action; + +import com.api.taojw.zjfs.util.ZjfsUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 飞书集成 + * 先看流程中的部门对应的文件夹是否已在飞书中创建,若未创建,职责先创建文件夹 + * 调飞书接口上传流程表单中的附件到飞书 + */ +public class FeishuAction implements Action { + + Logger logger = MyLogger.getLogger(); + + private String wjmjColumnName = ""; + private String zwjscColumnName = ""; + private String fjscColumnName = ""; + + public String getWjmjColumnName() { + return wjmjColumnName; + } + + public void setWjmjColumnName(String wjmjColumnName) { + this.wjmjColumnName = wjmjColumnName; + } + + public String getZwjscColumnName() { + return zwjscColumnName; + } + + public void setZwjscColumnName(String zwjscColumnName) { + this.zwjscColumnName = zwjscColumnName; + } + + public String getFjscColumnName() { + return fjscColumnName; + } + + public void setFjscColumnName(String fjscColumnName) { + this.fjscColumnName = fjscColumnName; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //查询流程中的部门及密级 用于获取飞书中的文件夹id + RecordSet rs = new RecordSet(); + String getInfoFromBillSql = "select "+wjmjColumnName+","+zwjscColumnName+","+fjscColumnName+" from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getInfoFromBillSql, requestId); + String wjmj = firstData.get(wjmjColumnName.toLowerCase(Locale.ROOT)); + //上传附件 + String zwjsc = firstData.get(zwjscColumnName.toLowerCase(Locale.ROOT)); + String fjsc = firstData.get(fjscColumnName.toLowerCase(Locale.ROOT)); + + if(wjmj == null || "".equals(wjmj)){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("文件密级字段不可为空,请填写后提交!"); + return Action.FAILURE_AND_CONTINUE; + } + + List fjscDocIds = new ArrayList<>(); + List zwjscDocIds = new ArrayList<>(); + if(zwjsc != null && !"".equals(zwjsc)){ + String[] zwjscArr = zwjsc.split(","); + for(String id:zwjscArr){ + if(!"".equals(id)){ + zwjscDocIds.add(id); + } + } + } + if(fjsc != null && !"".equals(fjsc)){ + String[] fjscArr = fjsc.split(","); + for(String id:fjscArr){ + if(!"".equals(id)){ + fjscDocIds.add(id); + } + } + } + String C1FolderToken = CommonSqlUtil.getSystemParamValue("C1FolderToken", rs); + String C2FolderToken = CommonSqlUtil.getSystemParamValue("C2FolderToken", rs); + String C3FolderToken = CommonSqlUtil.getSystemParamValue("C3FolderToken", rs); + String FjFolderToken = CommonSqlUtil.getSystemParamValue("FjFolderToken", rs); + + + + String getImageFileInfoSql = + "select " + + "t3.imagefilename,t3.filerealpath,t3.imagefileid,t3.filesize " + + "from " + + "docdetail t1 " + + "left join DocImageFile t2 on t2.docid = t1.id " + + "left join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "where " + + "t1.id = ? " + + "order by " + + "t2.versionid desc "; + for(String docId : zwjscDocIds){ + String parentNode = ""; + if("0".equals(wjmj)){ + parentNode = C1FolderToken; + }else if("1".equals(wjmj)){ + parentNode = C2FolderToken; + }else if("2".equals(wjmj)){ + parentNode = C3FolderToken; + }else { + continue; + } + Map firstData2 = DaoUtil.getFirstData(rs, getImageFileInfoSql, docId); + int imageFileId = Integer.parseInt(firstData2.get("imagefileid")); + String fileName = firstData2.get("imagefilename"); + String fileSize = firstData2.get("filesize"); + ZjfsUtil.uploadFile(imageFileId,fileName,parentNode,fileSize); + } + for(String docId : fjscDocIds){ + Map firstData2 = DaoUtil.getFirstData(rs, getImageFileInfoSql, docId); + int imageFileId = Integer.parseInt(firstData2.get("imagefileid")); + String fileName = firstData2.get("imagefilename"); + String fileSize = firstData2.get("filesize"); + ZjfsUtil.uploadFile(imageFileId,fileName,FjFolderToken,fileSize); + } + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("FeishuAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("FeishuAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/action/FeishuBakAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/action/FeishuBakAction.java new file mode 100644 index 0000000..33d2136 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/action/FeishuBakAction.java @@ -0,0 +1,141 @@ +package com.api.taojw.zjfs.action; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.zjfs.util.ZjfsUtil; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 飞书集成 + * 先看流程中的部门对应的文件夹是否已在飞书中创建,若未创建,职责先创建文件夹 + * 调飞书接口上传流程表单中的附件到飞书 + */ +public class FeishuBakAction implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //查询流程中的部门及密级 用于获取飞书中的文件夹id + RecordSet rs = new RecordSet(); + String getInfoFromBillSql = "select sqbm,wjmj,zwjsc,fjsc from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getInfoFromBillSql, requestId); + String sqbm = firstData.get("sqbm"); + String wjmj = firstData.get("wjmj"); + if(sqbm == null || "".equals(sqbm) || wjmj == null || "".equals(wjmj)){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("部门字段、文件密级字段补课为空,请填写后提交!"); + return Action.FAILURE_AND_CONTINUE; + } + //在建模中查找部门及密级 对应的飞书中的文件夹id 如存在,上传附件;若不存在,则先创建文件夹,再上传附件 + boolean fsFolderIdExists = false; + String getFileFolderSql = "select fswjjid from uf_bmfsmapping where bm = ? and wjmj = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getFileFolderSql, sqbm, wjmj); + String fsFolderId = firstData1.get("fswjjid"); + if(fsFolderId == null || "".equals(fsFolderId)){ + fsFolderIdExists = false; + }else{ + fsFolderIdExists = true; + } + //若mapping表中不存在数据,则创建文件夹 + String C1Folder = ""; + String C2Folder = ""; + String C3Folder = ""; + if(!fsFolderIdExists){ + String feishuparentfolderid = CommonSqlUtil.getSystemParamValue("feishuparentfolderid", rs); + //创建文件夹 + String bmFolder = ZjfsUtil.createFsFolder("OABM" + sqbm, feishuparentfolderid); + C1Folder = ZjfsUtil.createFsFolder("C1", bmFolder); + C2Folder = ZjfsUtil.createFsFolder("C2", bmFolder); + C3Folder = ZjfsUtil.createFsFolder("C3", bmFolder); + //mapping建模中创建数据 + JSONObject modelDataJson = new JSONObject(); + modelDataJson.put("bm",sqbm); + modelDataJson.put("wjmj",0); + modelDataJson.put("fswjjid",C1Folder); + TjwModelUtil.addModelData(rs,"uf_bmfsmapping",modelDataJson); + modelDataJson.put("wjmj",1); + modelDataJson.put("fswjjid",C2Folder); + TjwModelUtil.addModelData(rs,"uf_bmfsmapping",modelDataJson); + modelDataJson.put("wjmj",2); + modelDataJson.put("fswjjid",C3Folder); + TjwModelUtil.addModelData(rs,"uf_bmfsmapping",modelDataJson); + } + //上传附件 + String zwjsc = firstData.get("zwjsc"); + String fjsc = firstData.get("fjsc"); + List docIds = new ArrayList<>(); + if(zwjsc != null && !"".equals(zwjsc)){ + String[] zwjscArr = zwjsc.split(","); + for(String id:zwjscArr){ + if(!"".equals(id)){ + docIds.add(id); + } + } + } + if(fjsc != null && !"".equals(fjsc)){ + String[] fjscArr = fjsc.split(","); + for(String id:fjscArr){ + if(!"".equals(id)){ + docIds.add(id); + } + } + } + String parentNode = ""; + if(fsFolderIdExists){ + parentNode = fsFolderId; + }else{ + if("0".equals(wjmj)){ + parentNode = C1Folder; + } + if("1".equals(wjmj)){ + parentNode = C2Folder; + } + if("2".equals(wjmj)){ + parentNode = C3Folder; + } + } + + String getImageFileInfoSql = + "select " + + "t3.imagefilename,t3.filerealpath,t3.imagefileid,t3.filesize " + + "from " + + "docdetail t1 " + + "left join DocImageFile t2 on t2.docid = t1.id " + + "left join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "where " + + "t1.id = ? " + + "order by " + + "t2.versionid desc "; + for(String docId : docIds){ + Map firstData2 = DaoUtil.getFirstData(rs, getImageFileInfoSql, docId); + int imageFileId = Integer.parseInt(firstData2.get("imagefileid")); + String fileName = firstData2.get("imagefilename"); + String fileSize = firstData2.get("filesize"); + ZjfsUtil.uploadFile(imageFileId,fileName,parentNode,fileSize); + } + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("FeishuAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("FeishuAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/util/ZjfsUtil.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/util/ZjfsUtil.java new file mode 100644 index 0000000..f440a5c --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjfs/util/ZjfsUtil.java @@ -0,0 +1,116 @@ +package com.api.taojw.zjfs.util; + +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.dev.api.util.Util_DataCache; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.HashMap; +import java.util.Map; + +public class ZjfsUtil { + + static Logger logger = MyLogger.getLogger(); + + public static void uploadFile(int imageFileId,String fileName,String parentNode,String size){ + logger.info("uploadFile begin;imageFileId:" + imageFileId + ";fileName:" + fileName + ";parentNode:" + parentNode + ";size:" + size); + try { + RecordSet rs = new RecordSet(); + String feishu_uploadfileurl = CommonSqlUtil.getSystemParamValue("feishu_uploadfileurl", rs); + //CloseableHttpClient httpClient = HttpUtil.createSSLClientDefault(feishu_uploadfileurl); + /*RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(200000).build(); + HttpPost httpPost = new HttpPost(feishu_uploadfileurl); + httpPost.setConfig(requestConfig); + MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create(); + multipartEntityBuilder.setCharset(StandardCharsets.UTF_8); + multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);*/ + + Map headers = new HashMap<>(); + headers.put("Authorization", "Bearer " + getToken()); + Map textParam = new HashMap<>(); + textParam.put("file_name",fileName); + textParam.put("parent_type","explorer"); + textParam.put("parent_node",parentNode); + textParam.put("size",size); + logger.info("here it is"); + TjwHttpUtil.uploadFileUtil(feishu_uploadfileurl, String.valueOf(imageFileId),headers,textParam,"file"); + + /*ImageFileManager imageFileManager = new ImageFileManager(); + multipartEntityBuilder.addBinaryBody("file",imageFileManager.getInputStreamById(imageFileId), ContentType.MULTIPART_FORM_DATA,fileName); + multipartEntityBuilder.addTextBody("file_name",fileName); + multipartEntityBuilder.addTextBody("parent_type","explorer"); + multipartEntityBuilder.addTextBody("parent_node",parentNode); + multipartEntityBuilder.addTextBody("size",size); + + HttpEntity httpEntity = multipartEntityBuilder.build(); + httpPost.setEntity(httpEntity); + //请求头设置 + httpPost.addHeader(HTTP.CONTENT_ENCODING, "UTF-8"); + httpPost.addHeader("Authorization", "Bearer " + getToken()); + //httpPost.addHeader("Content-Type", "multipart/form-data;"); + CloseableHttpResponse execute = httpClient.execute(httpPost); + int statusCode = execute.getStatusLine().getStatusCode(); + HttpEntity en = execute.getEntity(); + en = new BufferedHttpEntity(en); + logger.info("code:"+statusCode); + logger.info("response:" + EntityUtils.toString(en, "utf-8")); + logger.info("");*/ + } catch (Throwable e) { + logger.error("uploadFile exception;message:" + e.getMessage() + ";e:" + e); + } + } + + public static String createFsFolder(String folderName,String parentFolderId){ + RecordSet rs = new RecordSet(); + //获取飞书token 用于后续接口调用 + String token = getToken(); + //创建部门文件夹 + String feishu_createfolderurl = CommonSqlUtil.getSystemParamValue("feishu_createfolderurl", rs); + ContentType contentType = ContentType.create("application/json","UTF-8"); + JSONObject param = new JSONObject(); + param.put("name",folderName); + param.put("folder_token",parentFolderId); + Map headers = new HashMap<>(); + headers.put("Content-Type","application/json; charset=utf-8"); + headers.put("Authorization","Bearer " + token); + Map response = TjwHttpUtil.sendHttpRequest(feishu_createfolderurl, param.toJSONString(), "post", contentType,headers); + String responseData = (String) response.get("data"); + JSONObject responseJson = JSONObject.parseObject(responseData); + String folderId = responseJson.getJSONObject("data").getString("token"); + return folderId; + } + + public static String getToken(){ + String tokenKey = "tjwfstoken"; + String token = (String) Util_DataCache.getObjVal(tokenKey); + if(token == null || "".equals(token)) { + synchronized (ZjfsUtil.class) { + token = (String) Util_DataCache.getObjVal(tokenKey); + if (token == null || "".equals(token)) { + RecordSet rs = new RecordSet(); + String feishu_tokenurl = CommonSqlUtil.getSystemParamValue("feishu_tokenurl", rs); + String feishuapp_id = CommonSqlUtil.getSystemParamValue("feishuapp_id", rs); + String feishuapp_secret = CommonSqlUtil.getSystemParamValue("feishuapp_secret", rs); + ContentType contentType = ContentType.create("application/json","UTF-8"); + JSONObject param = new JSONObject(); + param.put("app_id",feishuapp_id); + param.put("app_secret",feishuapp_secret); + Map headers = new HashMap<>(); + headers.put("Content-Type","application/json; charset=utf-8"); + Map response = TjwHttpUtil.sendHttpRequest(feishu_tokenurl, param.toJSONString(), "post", contentType,headers); + String tokenResponse = (String) response.get("data"); + JSONObject tokenJson = JSONObject.parseObject(tokenResponse); + token = tokenJson.getString("tenant_access_token"); + int expiresIn = tokenJson.getIntValue("expire"); + Util_DataCache.setObjVal(tokenKey, token,expiresIn - 60); + } + } + } + logger.info("get token success;token:" + token); + return token; + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/action/HrmChangeAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/action/HrmChangeAction.java new file mode 100644 index 0000000..bce137f --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/action/HrmChangeAction.java @@ -0,0 +1,224 @@ +package com.api.taojw.zjjd.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.CommonSqlUtil; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.TjwRightMoveUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import java.util.List; +import java.util.Map; + +/** + * 洲际酒店 + * 2.1.触发标准权限转移接口,将A的已办、待办转移给B + * 2.2.修改某个workflowid下B的待办 将流程表单中某字段(任务接收人)改为B + * 2.3.任务清单台账中两个人力资源字段 从A改成B + */ +public class HrmChangeAction implements Action { + + Logger logger = MyLogger.getLogger(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + private String todoAndDoneWorkFlowIds = ""; + + public String getTodoAndDoneWorkFlowIds() { + return todoAndDoneWorkFlowIds; + } + + public void setTodoAndDoneWorkFlowIds(String todoAndDoneWorkFlowIds) { + this.todoAndDoneWorkFlowIds = todoAndDoneWorkFlowIds; + } + + private String requestIdColumnName = ""; + + public String getRequestIdColumnName() { + return requestIdColumnName; + } + + public void setRequestIdColumnName(String requestIdColumnName) { + this.requestIdColumnName = requestIdColumnName; + } + + public String getWorkFlowIds() { + return workFlowIds; + } + + public void setWorkFlowIds(String workFlowIds) { + this.workFlowIds = workFlowIds; + } + + private String columns = ""; + + private String workFlowIds = ""; + + public String getColumns() { + return columns; + } + + public void setColumns(String columns) { + this.columns = columns; + } + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + RecordSet rs = new RecordSet(); + String getHrmSql = "select ydqryxm,ydhryxm,qxzylcid from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getHrmSql, requestId); + String oldId = firstData.get("ydqryxm"); + String newId = firstData.get("ydhryxm"); + String qxzylcid = firstData.get("qxzylcid"); + if(oldId == null || "".equals(oldId) || newId == null || "".equals(newId)){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("人员不可为空!"); + return Action.FAILURE_AND_CONTINUE; + } + //1.触发标准权限转移接口,将A的已办、待办转移给B 只涉及某些workflowid + List> doneInfo = CommonSqlUtil.getDoneInfo(oldId); + List> todoInfo = CommonSqlUtil.getTodoInfo(oldId); + String todoRequestIdStr = ""; + String doneRequestIdStr = ""; + String[] todoAndDoneWorkFlowIdArr = todoAndDoneWorkFlowIds.split(","); + + for(Map m : doneInfo){ + String workFlowId = m.get("workflowid"); + String _requestId = m.get("requestid"); + + for(String wfid : todoAndDoneWorkFlowIdArr){ + if(wfid.equals(workFlowId)){ + logger.info("doneInfo.workFlowId:" + workFlowId + ";_requestId:" + _requestId ); + if("".equals(doneRequestIdStr)){ + doneRequestIdStr = _requestId; + }else{ + doneRequestIdStr = doneRequestIdStr + "," + _requestId; + } + } + } + } + for(Map m : todoInfo){ + String workFlowId = m.get("workflowid"); + String _requestId = m.get("requestid"); + for(String wfid : todoAndDoneWorkFlowIdArr){ + if(wfid.equals(workFlowId)){ + logger.info("todoInfo.workFlowId:" + workFlowId + ";_requestId:" + _requestId ); + if("".equals(doneRequestIdStr)){ + todoRequestIdStr = _requestId; + }else{ + todoRequestIdStr = todoRequestIdStr + "," + _requestId; + } + } + } + } + if(qxzylcid == null || "".equals(qxzylcid)){ + JSONObject changeRightJson = new JSONObject(); + changeRightJson.put("fromid",oldId); + changeRightJson.put("toid",newId); + changeRightJson.put("transferType","resource"); + changeRightJson.put("authorityTag","transfer"); + changeRightJson.put("T133IdStr",todoRequestIdStr); + changeRightJson.put("T133AllNum","1"); + changeRightJson.put("T134IdStr",doneRequestIdStr); + changeRightJson.put("T134AllNum","1"); + TjwRightMoveUtil.moveRight(changeRightJson); + }else{ + JSONObject changeRightJson = new JSONObject(); + changeRightJson.put("fromid",oldId); + changeRightJson.put("toid",newId); + changeRightJson.put("transferType","resource"); + changeRightJson.put("authorityTag","transfer"); + changeRightJson.put("T133IdStr",qxzylcid); + changeRightJson.put("T133AllNum","1"); + TjwRightMoveUtil.moveRight(changeRightJson); + } + + //2.修改某个workflowid下的流程表单中某字段(任务接收人)从A改为B 单笔场景也涉及 + if(workFlowIds != null && !"".equals(workFlowIds)){ + String[] workFlowIdArr = workFlowIds.split(","); + String[] columnArr = columns.split(","); + for(Map m : todoInfo){ + String todoWorkFlowId = m.get("workflowid"); + String todoRequestId = m.get("requestid"); + for(int i = 0; i < workFlowIdArr.length;i ++){ + String workFlowId = workFlowIdArr[i]; + if(workFlowId.equals(todoWorkFlowId)){ + String tableName = CommonSqlUtil.getTableNameByWorkflowId(workFlowId,rs); + String column = columnArr[i]; + String updateSql = "update " + tableName + " set " + column + " = " + newId + " where " + column + " = " + oldId + " and requestid = ?"; + DaoUtil.updateData(rs,updateSql,todoRequestId); + } + } + } + } + + //3.任务清单台账中两个人力资源字段 从A改成B 状态为完成、取消 不改 + int modeId = CommonSqlUtil.getModeIdByTableName("uf_rwtzeq",rs); + String modeIdParam = CommonSqlUtil.getSystemParamValue("rwModeId",rs); + if(modeIdParam != null && !"".equals(modeIdParam)){ + modeId = Integer.parseInt(modeIdParam); + } + if(qxzylcid == null || "".equals(qxzylcid)){ + String getDataSql = "select id from where rwjsr = ? and zt in (1,4)"; + String updateSql = "update uf_rwtzeq set rwjsr = ? where id = ?"; + List> data = DaoUtil.getData(rs, getDataSql, oldId); + for(Map m : data){ + String id = m.get("id"); + DaoUtil.updateData(rs,updateSql,newId,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,Integer.parseInt(id)); + } + + String getDataSql2 = "select id from where hdcjr = ? and zt in (1,4)"; + String updateSql2 = "update uf_rwtzeq set hdcjr = ? where id = ?"; + List> data2 = DaoUtil.getData(rs, getDataSql2, oldId); + for(Map m : data2){ + String id = m.get("id"); + DaoUtil.updateData(rs,updateSql2,newId,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,Integer.parseInt(id)); + } + /*String updateSql1 = "update uf_rwtzeq set rwjsr = ? where rwjsr = ? and zt in (1,4)"; + String updateSql2 = "update uf_rwtzeq set hdcjr = ? where hdcjr = ? and zt in (1,4)"; + DaoUtil.updateData(rs,updateSql1,newId,oldId); + DaoUtil.updateData(rs,updateSql2,newId,oldId);*/ + }else{ + String getDataSql = "select id from where rwjsr = ? and zt in (1,4) and rwjslcid = ?"; + String updateSql = "update uf_rwtzeq set rwjsr = ? where id = ?"; + List> data = DaoUtil.getData(rs, getDataSql, oldId,qxzylcid); + for(Map m : data){ + String id = m.get("id"); + DaoUtil.updateData(rs,updateSql,newId,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,Integer.parseInt(id)); + } + + String getDataSql2 = "select id from where hdcjr = ? and zt in (1,4) and rwjslcid = ?"; + String updateSql2 = "update uf_rwtzeq set hdcjr = ? where id = ?"; + List> data2 = DaoUtil.getData(rs, getDataSql2, oldId,qxzylcid); + for(Map m : data2){ + String id = m.get("id"); + DaoUtil.updateData(rs,updateSql2,newId,id); + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,Integer.parseInt(id)); + } + /*String updateSql1 = "update uf_rwtzeq set rwjsr = ? where rwjsr = ? and rwjslcid = ? and zt in (1,4)"; + String updateSql2 = "update uf_rwtzeq set hdcjr = ? where hdcjr = ? and rwjslcid = ? and zt in (1,4)"; + DaoUtil.updateData(rs,updateSql1,newId,oldId,qxzylcid); + DaoUtil.updateData(rs,updateSql2,newId,oldId,qxzylcid);*/ + } + logger.info("----------------------" + this.getClass() + " action end ----------------------"); + return Action.SUCCESS; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error(this.getClass() + " error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/api/ZjjdTjwApi.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/api/ZjjdTjwApi.java new file mode 100644 index 0000000..b27b079 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/api/ZjjdTjwApi.java @@ -0,0 +1,108 @@ +package com.api.taojw.zjjd.api; + +import com.api.taojw.common.CommonSqlUtil; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.TjwWorkFlowUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.workflow.webservices.WorkflowService; +import weaver.workflow.webservices.WorkflowServiceImpl; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.*; + +/** + * 洲际酒店 + * 建模保存后触发异动流程 + */ +@Path("/zjjdtjw") +public class ZjjdTjwApi { + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/startWorkFlow") + @Produces(MediaType.APPLICATION_JSON) + public String startWorkFlow(@Context HttpServletRequest request, @Context HttpServletResponse response){ + try{ + logger.info(this.getClass() + "---------- startWorkFlow begin "); + String workFlowId = request.getParameter("workFlowId"); + String oldId = request.getParameter("oldId"); + String newId = request.getParameter("newId"); + String requestId = request.getParameter("requestId"); + String requestIdColumn = request.getParameter("requestIdColumn"); + if(oldId == null || newId == null || "".equals(oldId) || "".equals(newId)){ + return ""; + } + String[] oldIdArr = oldId.split(","); + String[] newIdArr = newId.split(","); + if(oldIdArr.length != newIdArr.length){ + return ""; + } + Arrays.sort(oldIdArr); + Arrays.sort(newIdArr); + for(int i = 0;i < oldIdArr.length;i ++){ + String oldValue = oldIdArr[i]; + String newValue = newIdArr[i]; + if(oldValue != null && !"".equals(oldValue) && newValue != null && !"".equals(newValue) && !oldValue.equals(newValue)){ + Map mainTableData = new HashMap<>(); + mainTableData.put("ydqryxm",oldValue); + mainTableData.put("ydhryxm",newValue); + if(requestId != null && !"".equals(requestId)){ + mainTableData.put(requestIdColumn,requestId); + } + TjwWorkFlowUtil.createWorkFlow("人员异动","1",workFlowId,"1",mainTableData,null); + } + } + logger.info(this.getClass() + "---------- startWorkFlow end "); + }catch (Throwable e){ + logger.error(this.getClass() + "---------- startWorkFlow error;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + @POST + @Path("/doForceOver") + @Produces(MediaType.APPLICATION_JSON) + public String doForceOver(@Context HttpServletRequest request, @Context HttpServletResponse response){ + try{ + logger.info(this.getClass() + "---------- doForceOver begin "); + String requestId = request.getParameter("requestId"); + if(requestId == null || "".equals(requestId)){ + return ""; + } + + RecordSet rs = new RecordSet(); + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + String updateSql = "update " + tableName + " set rwzt = 3 where requestid = ?"; + DaoUtil.updateData(rs,updateSql,requestId); + + int person = 1; + //查询流程当前处理人 + List> workFlowCurrentUser = CommonSqlUtil.getWorkFlowCurrentUser(requestId); + for(Map m : workFlowCurrentUser){ + person = Integer.parseInt(m.get("id")); + } + logger.info("person:" + person); + WorkflowService service = new WorkflowServiceImpl(); + String message = service.doForceOver(Integer.parseInt(requestId), person); + + + + logger.info("message:" + message +";requestId:" + requestId); + logger.info(this.getClass() + "---------- doForceOver end "); + }catch (Throwable e){ + logger.error(this.getClass() + "---------- doForceOver error;message:" + e.getMessage() + ";e:" + e); + } + return ""; + } + + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/cronjob/ChangeModeDataCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/cronjob/ChangeModeDataCronjob.java new file mode 100644 index 0000000..f00a95e --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/cronjob/ChangeModeDataCronjob.java @@ -0,0 +1,35 @@ +package com.api.taojw.zjjd.cronjob; + +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 洲际酒店 + * 定时更新建模数据 比较日期字段和当前时间 赋值为不同的状态 + */ +public class ChangeModeDataCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try{ + logger.info(this.getClass() + " begin;" ); + RecordSet rs = new RecordSet(); + String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + String updateSql = "update uf_rwtzeq set zt = 4 where hddqr < '" + currentDate + "' and zt = 1"; + DaoUtil.updateData(rs,updateSql); + //updateSql = "update uf_rwtzeq set zt = 1 where hddqr >= '" + currentDate + "' and zt = "; + //DaoUtil.updateData(rs,updateSql); + logger.info(this.getClass() + " end"); + }catch (Throwable e){ + logger.error(this.getClass() + " exception;message:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/cronjob/CheckDataCronjob.java b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/cronjob/CheckDataCronjob.java new file mode 100644 index 0000000..2369821 --- /dev/null +++ b/src/main/jinwei_tao_old_src/com/api/taojw/zjjd/cronjob/CheckDataCronjob.java @@ -0,0 +1,219 @@ +package com.api.taojw.zjjd.cronjob; + +import com.alibaba.fastjson.JSONObject; +import com.api.taojw.common.DaoUtil; +import com.api.taojw.common.TjwRightMoveUtil; +import com.api.taojw.common.TjwTimeUtil; +import com.api.taojw.common.logging.MyLogger; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 洲际酒店 + * 定时查询前一天的人员信息 处理异动人员 + */ +public class CheckDataCronjob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + //json数据转json配置数据id 映射bill流程明细数据和国信台账字段映射关系 + private String configId = ""; + public String getConfigId() { + return configId; + } + public void setConfigId(String configId) { + this.configId = configId; + } + + private String dataDate = ""; + + public String getDataDate() { + return dataDate; + } + + public void setDataDate(String dataDate) { + this.dataDate = dataDate; + } + + @Override + public void execute() { + try{ + logger.info(this.getClass() + " begin;configId:" + configId + ";"); + RecordSet rs = new RecordSet(); + //job code - 酒店底表的字段名称 + Map configInfo = new HashMap<>(); + String getConfigDataSql = + "select " + + "t1.* " + + "from " + + "uf_jddbzdys_dt1 t1 " + + "where " + + "t1.mainid = ?"; + List> configData = DaoUtil.getData(rs, getConfigDataSql, configId); + for(Map m : configData){ + configInfo.put(m.get("jobcode"),m.get("zdmc")); + } + + String _lastDay = TjwTimeUtil.getLastDay(); + List days = new ArrayList<>(); + if(dataDate != null && !"".equals(dataDate)){ + days = getTwoDaysDayDes(dataDate,new SimpleDateFormat("yyyy-MM-dd").format(new Date())); + }else{ + days.add(_lastDay); + } + + for(String lastDay : days){ + //酒店 岗位 人 + Map> updateDatas = new HashMap<>(); + logger.info("dataDate:" + lastDay); + String getDataSql = + "select " + + "t1.*,t2.id as realUserId " + + "from " + + "uf_hrinfo t1 " + + "inner join hrmresource t2 on t2.loginid = t1.userid " + + "where " + + "t1.modedatacreatedate like '" + lastDay + "%' and t2.status != 5 "; + List> data = DaoUtil.getData(rs, getDataSql); + for(Map m : data){ + String hrmId = m.get("realuserid"); + if(hrmId == null || "".equals(hrmId)){ + continue; + } + String hotel_code = m.get("hotel_code"); + if(hotel_code == null || "".equals(hotel_code)){ + continue; + } + String jobs = m.get("job"); + if(jobs != null && !"".equals(jobs)){ + String[] jobArr = jobs.split(","); + for(String job : jobArr){ + if(updateDatas.containsKey(hotel_code)){ + Map jobAndHrm = updateDatas.get(hotel_code); + if(jobAndHrm.containsKey(job)){ + String ids = jobAndHrm.get(job); + jobAndHrm.put(job,ids+","+hrmId); + }else{ + jobAndHrm.put(job,hrmId); + } + }else{ + Map x = new HashMap<>(); + x.put(job,hrmId); + updateDatas.put(hotel_code,x); + } + } + } + } + String s = JSONObject.toJSONString(updateDatas); + logger.info("updateDatas:" + updateDatas); + + //更新酒店底表 + for(String hotel_code : updateDatas.keySet()){ + Map jobAndHrm = updateDatas.get(hotel_code); + for(String job : jobAndHrm.keySet()){ + String hrmId = jobAndHrm.get(job); + String columnName = configInfo.get(job); + if(columnName == null || "".equals(columnName)){ + continue; + } + String getOldDataSql = + "select " + + "t1." + columnName + " " + + "from " + + "uf_hotelinfo t1 " + + "where " + + "t1.holidex = ? "; + String updateSql = "update uf_hotelinfo set " + columnName + " = ? where holidex = ?"; + Map firstData = DaoUtil.getFirstData(rs, getOldDataSql, hotel_code); + String oldData = firstData.get(columnName.toLowerCase(Locale.ROOT)); + if(oldData == null || "".equals(oldData)){ + DaoUtil.updateData(rs,updateSql,hrmId,hotel_code); + continue; + } + JSONObject status = getStatus(hrmId, oldData); + String flag = status.getString("flag"); + if("1".equals(flag)){ + DaoUtil.updateData(rs,updateSql,hrmId,hotel_code); + } + if("2".equals(flag)){ + DaoUtil.updateData(rs,updateSql,hrmId,hotel_code); + JSONObject o = status.getJSONObject("diffId"); + for(Object oldId:o.keySet()){ + JSONObject changeRightJson = new JSONObject(); + changeRightJson.put("fromid",oldId); + changeRightJson.put("toid",o.get(oldId)); + changeRightJson.put("transferType","resource"); + changeRightJson.put("authorityTag","transfer"); + changeRightJson.put("T133All","1"); + changeRightJson.put("T133AllNum","1"); + changeRightJson.put("T134All","1"); + changeRightJson.put("T134AllNum","1"); + TjwRightMoveUtil.moveRight(changeRightJson); + } + } + } + } + } + logger.info(this.getClass() + " end"); + }catch (Throwable e){ + logger.error(this.getClass() + " exception;message:" + e.getMessage() + ";e:" + e); + } + } + + private JSONObject getStatus(String newData,String oldData){ + JSONObject result = new JSONObject(); + try{ + String[] newDataArr = newData.split(","); + String[] oldDataArr = oldData.split(","); + Arrays.sort(newDataArr); + Arrays.sort(oldDataArr); + if(newDataArr.length != oldDataArr.length){ + result.put("flag","1"); + return result; + } + JSONObject diffId = new JSONObject(); + for(int i = 0;i < newDataArr.length;i++){ + String oldId = oldDataArr[i]; + String newId = newDataArr[i]; + if(!newId.equals(oldId)){ + result.put("flag","2"); + diffId.put(oldId,newId); + } + } + result.put("diffId",diffId); + }catch (Throwable e){ + logger.error("getStatus error;newData:"+newData+";oldData:"+oldData+";message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据一段时间获取该段时间的所有日期 正序排序 + * @param startDate + * @param endDate + * @return + */ + public static List getTwoDaysDayDes(String startDate, String endDate) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + List dateList = new ArrayList(); + try { + Date dateOne = sdf.parse(startDate); + Date dateTwo = sdf.parse(endDate); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dateOne); + dateList.add(startDate); + while (dateTwo.after(calendar.getTime())) { + calendar.add(Calendar.DAY_OF_MONTH, 1); + dateList.add(sdf.format(calendar.getTime())); + } + } catch (Exception e) { + e.printStackTrace(); + } + return dateList; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/bomei/action/SendChdaToU8Action.java b/src/main/jinwei_tao_old_src/weaver/taojw/bomei/action/SendChdaToU8Action.java new file mode 100644 index 0000000..99b249e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/bomei/action/SendChdaToU8Action.java @@ -0,0 +1,141 @@ +package weaver.taojw.bomei.action; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.bomei.util.U8Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.Map; + +/** + * 向U8推送存货档案 + */ +public class SendChdaToU8Action implements Action { + + //配置id + private String configId = ""; + //U8提供的添加存货档案的接口地址 + private String addInfoUrl = ""; + //调用添加存货分类的接口时的入参 不配不传 + private String ds_sequence = ""; + + public String getDs_sequence() { + return ds_sequence; + } + + public void setDs_sequence(String ds_sequence) { + this.ds_sequence = ds_sequence; + } + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + public String getAddInfoUrl() { + return addInfoUrl; + } + + public void setAddInfoUrl(String addInfoUrl) { + this.addInfoUrl = addInfoUrl; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + JSONObject params = new JSONObject(); + try{ + logger.info("SendChdaToU8Action begin;requestid:" + requestId); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = requestInfo.getRequestManager().getRemark(); + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId); + if(firstData.size() > 0){ + base_array[4] = firstData.get("id"); + } + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + params = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId, configId, base_array); + //获取token + String token = U8Util.getToken(); + //调用接口推送信息 + RecordSet rs = new RecordSet(); + JSONObject result = sendTypeInfo(params, token, rs); + String resCode = result.getString("errcode"); + if(!"0".equals(resCode)){ + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("推送存货档案数据接口响应异常,requestId:"+ requestInfo.getRequestid() +",响应信息:" + result.getString("errmsg")); + return Action.FAILURE_AND_CONTINUE; + } + }catch(Exception e){ + logger.error("SendChdaToU8Action exception;message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("推送存货档案数据异常,requestId:"+ requestInfo.getRequestid() +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + } + + private JSONObject sendTypeInfo(JSONObject params,String token,RecordSet rs){ + JSONObject result = new JSONObject(); + try{ + String code = (String) params.get("code"); + String fromAccount = CommonSqlUtil.getSystemParamValue("u8from_account", rs); + String appKey = CommonSqlUtil.getSystemParamValue("u8app_key", rs); + String toAccount = CommonSqlUtil.getSystemParamValue("u8to_account", rs); + String url = addInfoUrl + "?from_account=" + fromAccount + "&to_account=" + toAccount + "&app_key=" + appKey + "&token=" + token + "&tradeid=addchda" + code + "&sync=1"; + if(ds_sequence != null && !"".equals(ds_sequence)){ + url = url + "&ds_sequence=" + ds_sequence; + } + Map response = TjwHttpUtil.sendHttpRequest( + url, params.toJSONString(), "post", null); + String data = response.get("data"); + result = JSONObject.parseObject(data); + }catch(Exception e){ + logger.error("getTypeInfo exception;typeInfo:" + params.toJSONString() + ";token:" + token + ";addInfoUrl:" + addInfoUrl + ";ds_sequence:" + ds_sequence); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/bomei/action/SendChflToU8Action.java b/src/main/jinwei_tao_old_src/weaver/taojw/bomei/action/SendChflToU8Action.java new file mode 100644 index 0000000..96b7959 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/bomei/action/SendChflToU8Action.java @@ -0,0 +1,146 @@ +package weaver.taojw.bomei.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.bomei.util.U8Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.Map; + +/** + * 向U8推送存货分类 + */ +public class SendChflToU8Action implements Action { + + //U8提供的查询存货分类的接口地址 + private String queryInfoUrl = ""; + //U8提供的添加存货分类的接口地址 + private String addInfoUrl = ""; + //调用查询存货分类的接口时的入参 + private String databaseName = ""; + //调用添加存货分类的接口时的入参 不配不传 + private String ds_sequence = ""; + + public String getDs_sequence() { + return ds_sequence; + } + + public void setDs_sequence(String ds_sequence) { + this.ds_sequence = ds_sequence; + } + + public String getAddInfoUrl() { + return addInfoUrl; + } + + public void setAddInfoUrl(String addInfoUrl) { + this.addInfoUrl = addInfoUrl; + } + + public String getDatabaseName() { + return databaseName; + } + + public void setDatabaseName(String databaseName) { + this.databaseName = databaseName; + } + + public String getQueryInfoUrl() { + return queryInfoUrl; + } + + public void setQueryInfoUrl(String queryInfoUrl) { + this.queryInfoUrl = queryInfoUrl; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + try{ + logger.info("SendChflToU8Action begin;requestid:" + requestId); + String tableName = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + if(databaseName == null || "".equals(databaseName)){ + databaseName = "BME_V_inventoryclass"; + } + //获取存货分类code + String getCodeSql = "select chfl from " + tableName + " where requestid = ?"; + Map codeData = DaoUtil.getFirstData(rs, getCodeSql, requestId); + String code = codeData.get("chfl"); + //调接口获取分类信息 + JSONObject typeInfo = getTypeInfo(code); + //获取token + String token = U8Util.getToken(); + //调用接口推送信息 + JSONObject result = sendTypeInfo(typeInfo, token, rs); + String resCode = result.getString("errcode"); + if(!"0".equals(resCode)){ + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("推送存货分类数据接口响应异常,requestId:"+ requestInfo.getRequestid() +",响应信息:" + result.getString("errmsg")); + return Action.FAILURE_AND_CONTINUE; + } + }catch(Exception e){ + logger.error("SendChflToU8Action exception;message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("推送存货分类数据异常,requestId:"+ requestInfo.getRequestid() +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + } + + private JSONObject getTypeInfo(String code){ + JSONObject result = new JSONObject(); + try{ + Map response = TjwHttpUtil.sendHttpRequest(queryInfoUrl + "?cinvccode=" + code + "&databaseName=" + databaseName, "", "get", null); + String data = response.get("data"); + JSONObject jsonObject = JSONObject.parseObject(data); + JSONArray arr = jsonObject.getJSONArray("Data"); + result = (JSONObject) arr.get(0); + }catch(Exception e){ + logger.error("getTypeInfo exception;code:" + code + ";queryInfoUrl:" + queryInfoUrl + ";databaseName:" + databaseName); + } + return result; + } + + private JSONObject sendTypeInfo(JSONObject typeInfo,String token,RecordSet rs){ + JSONObject result = new JSONObject(); + try{ + String code = (String) typeInfo.get("CinvCCode"); + String fromAccount = CommonSqlUtil.getSystemParamValue("u8from_account", rs); + String appKey = CommonSqlUtil.getSystemParamValue("u8app_key", rs); + String toAccount = CommonSqlUtil.getSystemParamValue("u8to_account", rs); + String url = addInfoUrl + "?from_account=" + fromAccount + "&to_account=" + toAccount + "&app_key=" + appKey + "&token=" + token + "&tradeid=addchfl" + code + "&sync=1"; + if(ds_sequence != null && !"".equals(ds_sequence)){ + url = url + "&ds_sequence=" + ds_sequence; + } + JSONObject params = new JSONObject(); + JSONObject inventoryclass = new JSONObject(); + inventoryclass.put("code",code); + inventoryclass.put("name",typeInfo.get("CinvCName")); + inventoryclass.put("rank",typeInfo.get("iInvCGrade")); + inventoryclass.put("end_rank_flag",typeInfo.get("bInvCEnd")); + params.put("inventoryclass",inventoryclass); + Map response = TjwHttpUtil.sendHttpRequest( + url, params.toJSONString(), "post", null); + String data = response.get("data"); + result = JSONObject.parseObject(data); + }catch(Exception e){ + logger.error("getTypeInfo exception;typeInfo:" + typeInfo.toJSONString() + ";token:" + token + ";addInfoUrl:" + addInfoUrl + ";ds_sequence:" + ds_sequence); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/bomei/util/U8Util.java b/src/main/jinwei_tao_old_src/weaver/taojw/bomei/util/U8Util.java new file mode 100644 index 0000000..fe5cf38 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/bomei/util/U8Util.java @@ -0,0 +1,42 @@ +package weaver.taojw.bomei.util; + +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.dev.api.util.Util_DataCache; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.util.Map; + +public class U8Util { + + static Logger logger = MyLogger.getLogger(); + + public static String getToken(){ + String tokenKey = "tjwu8token"; + String token = (String) Util_DataCache.getObjVal(tokenKey); + if(token == null || "".equals(token)) { + synchronized (U8Util.class) { + token = (String) Util_DataCache.getObjVal(tokenKey); + if (token == null || "".equals(token)) { + RecordSet rs = new RecordSet(); + String getTokenUrl = CommonSqlUtil.getSystemParamValue("u8gettokenurl", rs); + String fromAccount = CommonSqlUtil.getSystemParamValue("u8from_account", rs); + String appKey = CommonSqlUtil.getSystemParamValue("u8app_key", rs); + String appSecret = CommonSqlUtil.getSystemParamValue("u8app_secret", rs); + Map response = TjwHttpUtil.sendHttpRequest(getTokenUrl + "?from_account=" + fromAccount + "&app_key=" + appKey + "&app_secret=" + appSecret, "", "get", null); + String tokenResponse = response.get("data"); + JSONObject tokenJson = JSONObject.parseObject(tokenResponse); + token = tokenJson.getJSONObject("token").getString("id"); + int expiresIn = tokenJson.getJSONObject("token").getIntValue("expiresIn"); + Util_DataCache.setObjVal(tokenKey, token,expiresIn - 60); + } + } + } + logger.info("get token success;token:" + token); + return token; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/chuanbo/cronjob/GetDataAndStartWorkFlow.java b/src/main/jinwei_tao_old_src/weaver/taojw/chuanbo/cronjob/GetDataAndStartWorkFlow.java new file mode 100644 index 0000000..7c05553 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/chuanbo/cronjob/GetDataAndStartWorkFlow.java @@ -0,0 +1,222 @@ +package weaver.taojw.chuanbo.cronjob; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.crypto.digest.DigestUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.json.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwJsonToWorkflowByConfigUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.webservices.WorkflowBaseInfo; +import weaver.workflow.webservices.WorkflowRequestInfo; +import weaver.workflow.webservices.WorkflowService; +import weaver.workflow.webservices.WorkflowServiceImpl; +import java.util.Date; +import java.util.Map; +import java.util.Random; + +//调接口获取数据 发起流程 +public class GetDataAndStartWorkFlow extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String secretKey = ""; + private String url = ""; + private String shipNameKey = ""; + private String lastDateKey = ""; + private String timeStampKey = ""; + private String randomKey = ""; + private String workFlowId = ""; + private String configId = ""; + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getShipNameKey() { + return shipNameKey; + } + + public void setShipNameKey(String shipNameKey) { + this.shipNameKey = shipNameKey; + } + + public String getLastDateKey() { + return lastDateKey; + } + + public void setLastDateKey(String lastDateKey) { + this.lastDateKey = lastDateKey; + } + + public String getTimeStampKey() { + return timeStampKey; + } + + public void setTimeStampKey(String timeStampKey) { + this.timeStampKey = timeStampKey; + } + + public String getRandomKey() { + return randomKey; + } + + public void setRandomKey(String randomKey) { + this.randomKey = randomKey; + } + + public String getWorkFlowId() { + return workFlowId; + } + + public void setWorkFlowId(String workFlowId) { + this.workFlowId = workFlowId; + } + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + /** + * 获取精确到秒的时间戳 + * + * @return 时间戳 + */ + public static int getSecondTimestamp(Date date) { + if (null == date) { + return 0; + } + String timestamp = String.valueOf(date.getTime()); + int length = timestamp.length(); + if (length > 3) { + return Integer.parseInt(timestamp.substring(0, length - 3)); + } else { + return 0; + } + } + + @Override + public void execute() { + try{ + logger.info("GetDataAndStartWorkFlow.execute begin;"); + if("".equals(secretKey) || secretKey==null){ + secretKey = "ab7e1f8a9d96414087c4c5a736605ef4"; + } + if("".equals(url) || url==null){ + url = "https://10.9.54.228/out/fw/ship-daily"; + } + if("".equals(shipNameKey) || shipNameKey==null){ + shipNameKey = "shipName"; + } + if("".equals(workFlowId) || workFlowId==null){ + workFlowId = "46"; + } + if("".equals(lastDateKey) || lastDateKey==null){ + lastDateKey = "dailyDate"; + } + if("".equals(timeStampKey) || timeStampKey==null){ + timeStampKey = "ts"; + } + if("".equals(randomKey) || randomKey==null){ + randomKey = "rn"; + } + DateTime dateNow = DateUtil.date(); + String lastDateValue = DateUtil.yesterday().toString().split(" ")[0]; + String timeStampValue = getSecondTimestamp(dateNow) + ""; + String randomValue = String.format("%04d", new Random().nextInt(9999)); + String sql = "select * from uf_cbrbwh"; + RecordSet rs = new RecordSet(); + if(rs.execute(sql)){ + while (rs.next()) { + String shipNameValue = Util.null2String(rs.getString("cbmcms")); + String encodeStr = "||" + lastDateKey + lastDateValue + randomKey + randomValue + + shipNameKey + shipNameValue + timeStampKey + timeStampValue + "||" + timeStampValue + + randomValue + secretKey; + logger.info("ship name" + shipNameValue); + logger.info("sign before md5Hex" + encodeStr); + String md5Hex = DigestUtil.md5Hex(encodeStr); + logger.info("sign after md5Hex" + md5Hex); + String url_all = url + "?" + lastDateKey + "=" + lastDateValue + "&" + shipNameKey + "=" + shipNameValue + + "&" + timeStampKey + "=" + timeStampValue + "&" + randomKey + "=" + randomValue; + logger.info("url_all:" + url_all); + String body = HttpRequest.get(url_all).header("sign", md5Hex).execute().body(); + logger.info("response:" + body); + JSONObject body_obj = new JSONObject(body.trim()); + logger.info("body_obj:" + body_obj); + String code = body_obj.get("code") + ""; + String requestId = ""; + if ("200".equals(code)) { + logger.info("get success;begin start workflow"); + if ("".equals(new JSONObject(body).getStr("data"))) { + logger.info("data is null"); + continue; + } + requestId = syncAndInit(body, shipNameValue,rs); + if (Integer.parseInt(requestId) > 0) { + logger.info("workflow start success;requestId=" + requestId); + } else { + logger.error("workflow start error;requestId=" + requestId); + } + } else { + logger.info("response code is not 200;code:" + code); + } + } + } + logger.error("GetDataAndStartWorkFlow.execute done;"); + }catch(Exception e){ + logger.error("GetDataAndStartWorkFlow.execute exception;message:" + e.getMessage() + ";e:" + e); + } + } + + private String syncAndInit(String jsonString, String shipName,RecordSet rs){ + try{ + logger.info("syncAndInit begin;shipName:" + shipName + ";jsonString:" + jsonString); + String shipId = ""; + String getIdSql = "select id from hrmresource where lastname = ?"; + Map firstData = DaoUtil.getFirstData(rs, getIdSql, shipName); + shipId = firstData.get("id"); + if(shipId == null || "".equals(shipId)){ + logger.info(shipName + "无对应id"); + return "-1"; + } + WorkflowBaseInfo wbi = new WorkflowBaseInfo(); + wbi.setWorkflowId(workFlowId);//workflowid + WorkflowRequestInfo wri = new WorkflowRequestInfo();//流程基本信息 + wri.setCreatorId(shipId);//创建人id + wri.setIsnextflow("0");//自动流转到下一节点 + wri.setRequestLevel("0");//0 正常,1重要,2紧急 + wri.setRequestName(shipName + "-船舶日报-" + DateUtil.yesterday().toString().split(" ")[0]);//流程标题 + wri.setWorkflowBaseInfo(wbi); + TjwJsonToWorkflowByConfigUtil.dealWorkflowRequestInfoByConfigId(configId,wri,com.alibaba.fastjson.JSONObject.parseObject(jsonString)); + WorkflowService workflowService = new WorkflowServiceImpl(); + String requestid = workflowService.doCreateWorkflowRequest(wri,Integer.parseInt(shipId)); + logger.info("syncAndInit end;shipName:" + shipName + ";requestid:" + requestid); + return requestid; + }catch (Exception e){ + logger.error("syncAndInit exception;message:" + e.getMessage() + ";e:" + e); + return "-1"; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/CommonSqlUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/CommonSqlUtil.java new file mode 100644 index 0000000..0cf37ec --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/CommonSqlUtil.java @@ -0,0 +1,297 @@ +package weaver.taojw.common; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CommonSqlUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 查询所有上级部门id + * @param id + * @return + */ + public static void getAllParentDepartment(List result,String id){ + RecordSet rs = new RecordSet(); + String getParentDepartmentSql = "select supdepid from hrmdepartment where id = ?"; + Map firstData = DaoUtil.getFirstData(rs, getParentDepartmentSql, id); + String parentId = Util.null2String(firstData.get("supdepid")); + if("".equals(parentId)){ + return ; + }else{ + result.add(parentId); + getAllParentDepartment(result,parentId); + } + } + + /** + * 查询所有下级部门id + * @param id + * @return + */ + public static void getAllSonDepartment(List result,String id){ + RecordSet rs = new RecordSet(); + String getParentDepartmentSql = "select id from hrmdepartment where supdepid = ?"; + List> data = DaoUtil.getData(rs, getParentDepartmentSql, id); + if(data.size() == 0){ + return ; + }else{ + for(Map m : data){ + result.add(m.get("id")); + getAllSonDepartment(result,m.get("id")); + } + } + } + + + /** + * 获取系统参数设置值 + * @param uuid 参数标识 + * @return 返回配置值 + */ + public static String getSystemParamValue(String uuid,RecordSet rs){ + String result = ""; + try{ + String getDataByUuidSql = + "select paramvalue as result from uf_systemconfig where uuid = ?"; + if(rs.executeQuery(getDataByUuidSql,uuid)){ + if(rs.next()){ + result = Util.null2String(rs.getString("result")); + } + }else{ + logger.error("CommonSqlUtil.getSystemParamValue.getDataByUuidSql execute error;sql:" + getDataByUuidSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getSystemParamValue exception;uuid:" + uuid); + } + return result; + } + + /** + * 根据流程类型ID获取其对应的表单名称 + * @param workFlowId 流程类型ID + * @return 字符串 + */ + public static String getTableNameByWorkflowId(String workFlowId,RecordSet rs){ + String tableName = ""; + try{ + String getTableNameByWorkFlowIdSql = + "select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)"; + if(rs.executeQuery(getTableNameByWorkFlowIdSql,workFlowId)){ + if(rs.next()){ + tableName = Util.null2String(rs.getString("tablename")); + }else{ + logger.error("CommonSqlUtil.getTableNameByWorkflowId.getTableNameByWorkFlowIdSql execute success but found nothing;sql:" + getTableNameByWorkFlowIdSql); + } + }else{ + logger.error("CommonSqlUtil.getTableNameByWorkflowId.getTableNameByWorkFlowIdSql execute error;sql:" + getTableNameByWorkFlowIdSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getTableNameByWorkflowId exception;workFlowId:" + workFlowId); + } + return tableName; + } + + /** + * 根据requestId查询主表表名 + * @param requestId + * @param rs 数据库链接 + * @return + */ + public static String getTableNameByRequetId(String requestId, RecordSet rs){ + String tableName = ""; + try{ + String getTableNameByRequetIdSql = + "select tablename from workflow_bill where id = (Select formid from workflow_base where id = (select workflowid from workflow_requestbase where requestid = ? ))"; + if(rs.executeQuery(getTableNameByRequetIdSql,requestId)){ + if(rs.next()){ + tableName = Util.null2String(rs.getString("tablename")); + }else{ + logger.error("CommonSqlUtil.getTableNameByRequetId.getTableNameByRequetIdSql execute success but found nothing;sql:" + getTableNameByRequetIdSql); + } + }else{ + logger.error("CommonSqlUtil.getTableNameByRequetId.getTableNameByRequetIdSql execute error;sql:" + getTableNameByRequetIdSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getTableNameByRequetId exception;requestId:" + requestId); + } + return tableName; + } + + /** + * 根据modeId查询建模表表名 + * @param modeId 建模表表名 + * @param rs 数据库链接 + * @return + */ + public static String getTableNameByModeId(String modeId, RecordSet rs){ + String tableName = ""; + try{ + String getTableNameSql = + "select t2.tablename from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid where t1.id = ?"; + if(rs.executeQuery(getTableNameSql,modeId)){ + if(rs.next()){ + tableName = Util.null2String(rs.getString("tablename")); + }else{ + logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql execute success but found nothing;sql:" + getTableNameSql + ";modeId:" + modeId); + } + }else{ + logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql execute error;sql:" + getTableNameSql+ ";modeId:" + modeId); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql exception;modeId:" + modeId); + } + return tableName; + } + + /** + * 根据建模表表名查询modeId + * @param tableName 建模表表名 + * @param rs 数据库链接 + * @return + */ + public static int getModeIdByTableName(String tableName, RecordSet rs){ + int modeId = -1; + try{ + String getModeIdSql = + "select t1.id from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid where t2.tablename = '" + tableName + "' and t1.isdelete = 0"; + if(rs.executeQuery(getModeIdSql)){ + if(rs.next()){ + modeId = Util.getIntValue(rs.getString("id"),0); + }else{ + logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql execute success but found nothing;sql:" + getModeIdSql); + } + }else{ + logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql execute error;sql:" + getModeIdSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql exception;tableName:" + tableName); + } + return modeId; + } + + /** + * 根据requestId获取流程审批意见 + * @param requestId + * @return + */ + public static List> getProcessInfoList(String requestId,RecordSet rs){ + List> result = new ArrayList<>(); + try{ + if(rs == null){ + rs = new RecordSet(); + } + String selectSQL = + "Select " + + "t2.departmentid as deptid," + + "t3.departmentname as deptname," + + "t1.operator as createuserid," + + "t2.lastname as createusername," + + "t1.operatedate as operatedate," + + "t1.operatetime as operatetime," + + "t1.logtype as serviceactioncode," + + "t1.remark as suggestion " + + "from " + + "workflow_requestlog t1 " + + "left join Hrmresource t2 on t2.id= t1.operator " + + "left join hrmdepartment t3 on t3.id= t2.departmentid " + + "where " + + "t1.requestid = ? " + + "order by " + + "t1.operatedate asc,t1.operatetime asc"; + if(rs.executeQuery(selectSQL,requestId)){ + while(rs.next()){ + Map processInfo = new HashMap<>(); + processInfo.put("deptid",Util.null2String(rs.getString("deptid"))); + processInfo.put("deptname",Util.null2String(rs.getString("deptname"))); + processInfo.put("createuserid",Util.null2String(rs.getString("createuserid"))); + processInfo.put("createusername",Util.null2String(rs.getString("createusername"))); + processInfo.put("serviceactiontime",Util.null2String(rs.getString("operatedate")) + " " + Util.null2String(rs.getString("operatetime"))); + String serviceactioncode = Util.null2String(rs.getString("serviceactioncode")); + String serviceaction = ""; + switch (serviceactioncode){ + case "0": serviceaction = "批准"; break; + case "1": serviceaction = "保存"; break; + case "2": serviceaction = "提交"; break; + case "3": serviceaction = "退回"; break; + case "4": serviceaction = "重新打开"; break; + case "5": serviceaction = "删除"; break; + case "6": serviceaction = "激活"; break; + case "7": serviceaction = "转发"; break; + case "9": serviceaction = "批注"; break; + case "a": serviceaction = "意见征询"; break; + case "b": serviceaction = "意见征询回复"; break; + case "e": serviceaction = "强制归档"; break; + case "h": serviceaction = "转办"; break; + case "i": serviceaction = "干预"; break; + case "j": serviceaction = "转办反馈"; break; + case "s": serviceaction = "督办"; break; + case "t": serviceaction = "抄送"; break; + default: serviceaction = "其他"; break; + } + processInfo.put("serviceaction",serviceaction); + String suggestion = Util.null2String(rs.getString("suggestion")); + if(!"".equals(suggestion)){ + suggestion = CommonUtil.delHTMLTag(suggestion); + } + processInfo.put("suggestion",suggestion); + result.add(processInfo); + } + }else{ + logger.error("CommonSqlUtil.getProcessInfoList.sql error;sql:" + selectSQL + ";requestId:" + requestId); + } + }catch(Exception e){ + logger.error("CommonSqlUtil.getProcessInfoList exception;requestId:" + requestId + ";message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据requestid,获取流程审批意见 + * @param rs + * @param requestId + * @return + */ + public static String getWorkFlowSuggestion(RecordSetTrans rs, String requestId){ + String result = ""; + String getWorkFlowSuggestionSql = + "Select " + + "t2.departmentid as deptid," + + "t3.departmentname as deptname," + + "t1.operator as createuserid," + + "t2.lastname as createusername," + + "t1.operatedate as operatedate," + + "t1.operatetime as operatetime," + + "t1.logtype as logtype," + + "t1.remark as suggestion " + + "from " + + "workflow_requestlog t1 " + + "left join Hrmresource t2 on t2.id= t1.operator " + + "left join hrmdepartment t3 on t3.id= t2.departmentid " + + "where " + + "requestid = ? " + + "order by " + + "t1.operatedate desc,t1.operatetime desc"; + try{ + if(rs.executeQuery(getWorkFlowSuggestionSql,requestId)){ + if(rs.next()){ + result = Util.null2String(rs.getString("suggestion")); + } + }else{ + logger.error("CommonSqlUtil.getWorkFlowSuggestion execute error;getWorkFlowSuggestionSql:" + getWorkFlowSuggestionSql); + } + }catch (Exception e){ + logger.error("CommonSqlUtil.getFormatTimeByTimeMillis execute error;getWorkFlowSuggestionSql:" + getWorkFlowSuggestionSql + "exception:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/CommonUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/CommonUtil.java new file mode 100644 index 0000000..7e01961 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/CommonUtil.java @@ -0,0 +1,317 @@ +package weaver.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class CommonUtil { + + static Logger logger = MyLogger.getLogger(); + static SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + static DecimalFormat jeFormat = new DecimalFormat("###,##0.00"); + static DecimalFormat twoXsFormat = new DecimalFormat("0.00"); + + /** + * + * @return + */ + public static JSONObject getLastMonthDate(){ + JSONObject result = new JSONObject(); + try{ + SimpleDateFormat df =new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + String berforeFirstDay = df.format(calendar.getTime()); + result.put("lastMonthBegin",berforeFirstDay); + Calendar calendar1 = Calendar.getInstance(); + calendar1.set(Calendar.DAY_OF_MONTH, 1); + calendar1.add(Calendar.DATE, -1); + String berforeLastDay = df.format(calendar1.getTime()); + result.put("berforeLastDay",berforeLastDay); + //logger.error("CommonUtil.getLastMonthDate done;result:" + result.toJSONString()); + }catch(Exception e){ + logger.error("CommonUtil.getLastMonthDate exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 减法 + * @param js + * @param bjs + * @return + */ + public static String minusString(String js,String bjs) { + try{ + Float jsFloat; + try { + jsFloat = Float.parseFloat(js); + } catch (Exception e) { + logger.error("CommonUtil.minusString.parseFloat data error;js:" + js); + return "0.00"; + } + Float bjsFloat; + try { + bjsFloat = Float.parseFloat(bjs); + } catch (Exception e) { + logger.error("CommonUtil.minusString.parseFloat data error;bjs:" + bjs); + return "0.00"; + } + return twoXsFormat.format(bjsFloat - jsFloat); + }catch(Exception e){ + logger.error("CommonUtil.multiplyHundred exception;js:" + js + ";bjs:" + bjs + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 将字符串转为乘100 + * @param data + * @return + */ + public static String multiplyHundred(String data) { + try{ + Float dataFloat; + try { + dataFloat = Float.parseFloat(data); + } catch (Exception e) { + logger.error("CommonUtil.multiplyHundred.parseFloat data error;data:" + data); + return "0.00"; + } + dataFloat = dataFloat * 100; + return twoXsFormat.format(dataFloat); + }catch(Exception e){ + logger.error("CommonUtil.multiplyHundred exception;data:" + data + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 将字符串转为带逗号的金额 + * @param data + * @return + */ + public static String formatMoney(String data) { + try{ + Float dataFloat; + try { + dataFloat = Float.parseFloat(data); + } catch (Exception e) { + logger.error("CommonUtil.formatMoney.parseFloat data error;data:" + data); + return "0.00"; + } + return jeFormat.format(dataFloat); + }catch(Exception e){ + logger.error("CommonUtil.formatMoney exception;data:" + data + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 计算占比,保留两位小数返回字符串 + * 已乘100 + * @param fz 分子 + * @param fm 分母 + * @return + */ + public static String getBl(String fz,String fm,String needMultiplyHundred) { + try { + String result = ""; + Float fzFloat; + Float fmFloat; + try { + fzFloat = Float.parseFloat(fz); + } catch (Exception e) { + logger.error("CommonUtil.getBl.parseFloat fz error;fz:" + fz); + return "0.00"; + } + try { + fmFloat = Float.parseFloat(fm); + } catch (Exception e) { + logger.error("CommonUtil.getBl.parseFloat fm error;fm:" + fm); + return "0.00"; + } + + BigDecimal oldDataBd = new BigDecimal(fm); + if(oldDataBd.compareTo(BigDecimal.ZERO)==0){ + return "0.00"; + } + + if("1".equals(needMultiplyHundred)){ + result = twoXsFormat.format(100 * fzFloat / fmFloat); + }else{ + result = twoXsFormat.format(fzFloat / fmFloat); + } + return result; + } catch (Exception e) { + logger.error("CommonUtil.getBl exception;fz:" + fz + ";fm:"+ fm + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 计算增长率,保留两位小数返回字符串 + * 已乘100 + * @param oldData + * @param newData + * @return + */ + public static String getGrowthRate(String oldData,String newData) { + try { + String result = ""; + Float oldDataFloat; + Float newDataFloat; + try { + oldDataFloat = Float.parseFloat(oldData); + } catch (Exception e) { + logger.error("CommonUtil.getGrowthRate.parseFloat oldData error;oldData:" + oldData); + return "100.00"; + } + try { + newDataFloat = Float.parseFloat(newData); + } catch (Exception e) { + logger.error("CommonUtil.getGrowthRate.parseFloat newData error;newData:" + newData); + return "-100.00"; + } + BigDecimal oldDataBd = new BigDecimal(oldData); + if(oldDataBd.compareTo(BigDecimal.ZERO)==0){ + return "100.00"; + } + result = twoXsFormat.format(100*(newDataFloat - oldDataFloat) / oldDataFloat); + return result; + } catch (Exception e) { + logger.error("CommonUtil.getGrowthRate exception;oldData:" + oldData + ";newData:"+ newData + ";message:" + e.getMessage() + ";e:" + e); + return "0.00"; + } + } + + /** + * 剔除字符串中的html标签 + * @param htmlStr + * @return + */ + public static String delHTMLTag(String htmlStr){ + String regEx_script="]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式 + String regEx_style="]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式 + String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式 + + Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE); + Matcher m_script=p_script.matcher(htmlStr); + htmlStr=m_script.replaceAll(""); //过滤script标签 + + Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); + Matcher m_style=p_style.matcher(htmlStr); + htmlStr=m_style.replaceAll(""); //过滤style标签 + + Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE); + Matcher m_html=p_html.matcher(htmlStr); + htmlStr=m_html.replaceAll(""); //过滤html标签 + + return htmlStr.trim(); //返回文本字符串 + } + + /** + * 获取json指定路径的JSONArray 路径中有数组,则获取数组的第一个明细中的数据 + * @param obj 待查询的JSONObject + * @param path 格式为a/b/c + * @return JSONArray + */ + public static JSONArray getJsonArrayByPath(JSONObject obj, String path){ + try{ + int index = path.indexOf("/"); + if(index > -1){ + JSONObject son; + Object sons = obj.get(path.substring(0,index)); + if(sons instanceof JSONArray){ + son = (JSONObject) ((JSONArray) sons).get(0); + }else{ + son = obj.getJSONObject(path.substring(0,index)); + } + return getJsonArrayByPath(son,path.substring(index+1)); + }else{ + return obj.getJSONArray(path); + } + }catch(Exception e){ + logger.error("CommonUtil.getJsonArrayByPath error;exception:" + e.getMessage() + ";e:" + e); + return new JSONArray(); + } + } + + /** + * 获取json指定路径的值 路径中有数组,则获取数组的第一个明细中的数据 + * @param obj 待查询的JSONObject + * @param path 格式为a/b/c + * @return 值 + */ + public static String getJsonValueByPath(JSONObject obj, String path){ + try{ + int index = path.indexOf("/"); + if(index > -1){ + JSONObject son; + Object sons = obj.get(path.substring(0,index)); + if(sons instanceof JSONArray){ + son = (JSONObject) ((JSONArray) sons).get(0); + }else{ + son = obj.getJSONObject(path.substring(0,index)); + } + return getJsonValueByPath(son,path.substring(index+1)); + }else{ + return obj.get(path).toString(); + } + }catch(Exception e){ + logger.error("CommonUtil.getJsonValueByPath error;path:" + path + ";obj" + obj + "exception:" + e.getMessage() + ";e:" + e); + return ""; + } + } + + /** + * 多行文本转字符串 剔除
、  标签; 全角转半角 + * @param input 待转换的字符串 + * @return 转换后的字符串 + */ + public static String manyLineToString(String input) { + if("".equals(input) || input == null){ + return ""; + } + String result = ""; + input = input.replaceAll("
"," "); + input = input.replaceAll(" "," "); + result = fullToHalfAngle(input); + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + } + } + return result; + } + + /** + * 全角转半角 + * @param input 待转换的字符串 + * @return 转换后的字符串 + */ + public static String fullToHalfAngle(String input) { + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + return returnString; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/Constant.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/Constant.java new file mode 100644 index 0000000..afbf781 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/Constant.java @@ -0,0 +1,118 @@ +package weaver.taojw.common; + + +/** + * 一些静态常量定义 + */ +public class Constant { + + //action接口调用配置表名称 + public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd"; + + //------------------------------------------------------------------------------接口请求日志表名及字段 + //action调用接口日志记录表表名 + public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd"; + //action调用接口日志记录表requestId字段名称 + public static String LOG_REQUESTID_COLUMN = "lcrequestid"; + //action调用接口日志记录表请求正文字段名称 + public static String LOG_REQUEST_COLUMN = "qqbw"; + //action调用接口日志记录表响应文字段名称 + public static String LOG_RESPONSE_COLUMN = "xybw"; + //action调用接口日志记录表响应码字段名称 + public static String LOG_RESPONSECODE_COLUMN = "xym"; + //action调用接口日志记录表请求地址字段名称 + public static String LOG_REQUEST_ADDRESS_COLUMN = "qqdz"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUEST_HEADER_COLUMN = "qqt"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUEST_RESULT_COLUMN = "qqjg"; + + //------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志 + public static final String PARAM_BEGIN = "{"; + public static final String PARAM_END = "}"; + + //------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功 + public static final String CALL_SUCCESS = "1"; + public static final String CALL_FAILED = "0"; + + //------------------------------------------------------------------------------选择框 0-否 1-是 + public static final String SELECT_TYPE_IS = "1"; + public static final String SELECT_TYPE_NOT = "0"; + + //------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次 + public static final String CALL_TYPE_ONLY_ONE = "0"; + public static final String CALL_TYPE_EVERY_DETAIL = "1"; + + //------------------------------------------------------------------------------接口请求类型 0-get 1-post + //GET + public static final String REQUEST_METHOD_GET = "0"; + //POST + public static final String REQUEST_METHOD_POST = "1"; + + //------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对 + //xml + public static final String REQUEST_DATA_TYPE_XML = "0"; + //json + public static final String REQUEST_DATA_TYPE_JSON = "1"; + //键值对 + public static final String REQUEST_DATA_TYPE_PAIR = "2"; + //MultipartFile + public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3"; + + //------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json + //xml + public static final String RESPONSE_DATA_TYPE_XML = "0"; + //json + public static final String RESPONSE_DATA_TYPE_JSON = "1"; + + //------------------------------------------------------------------------------节点类型 + //文本 + public static final String NODE_TYPE_STRING = "0"; + //对象 + public static final String NODE_TYPE_OBJECT = "1"; + //文本数组 + public static final String NODE_TYPE_STRING_ARRAY = "2"; + //数组 + public static final String NODE_TYPE_ARRAY = "3"; + //json对象字符串 + public static final String NODE_TYPE_JSONSTRING = "4"; + //数字 + public static final String NODE_TYPE_NUMBER = "5"; + //布尔 + public static final String NODE_TYPE_BOOLEAN = "6"; + //浮点数 + public static final String NODE_TYPE_FLOAT = "7"; + //辅助核算项 + public static final String NODE_TYPE_FZHSX = "8"; + + + //------------------------------------------------------------------------------转换规则 + //不转换 + public static final String CHANGE_TYPE_NONE = "0"; + //固定值 + public static final String CHANGE_TYPE_FIXED = "1"; + //自定义sql + public static final String CHANGE_TYPE_SQL = "2"; + //字段求和 + public static final String CHANGE_TYPE_SUM = "3"; + //文本数组 + public static final String CHANGE_TYPE_STRING_ARRAY = "4"; + //明细序号 + public static final String CHANGE_TYPE_ROW_NUMBER = "5"; + //流程审批意见 + public static final String CHANGE_TYPE_SUGGESTION = "6"; + //加密处理 + public static final String CHANGE_TYPE_MD5 = "7"; + //requestId + public static final String CHANGE_TYPE_REQUEST_ID = "8"; + //流程标题 + public static final String CHANGE_TYPE_REQUEST_NAME = "9"; + + //------------------------------------------------------------------------------sql转义 + //默认换行符 + public static final String Default_Line_Break = "
"; + //默认空格HTML代码 + public static final String Default_Html_Blank = " "; + //默认空格字符 + public static final String Default_Blank_Char = " "; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/DaoUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/DaoUtil.java new file mode 100644 index 0000000..b261b7c --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/DaoUtil.java @@ -0,0 +1,217 @@ +package weaver.taojw.common; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import java.util.*; + + +/** + * 数据库操作添加try catch 以及日志输出 + */ +public class DaoUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 将结果行转为map + * @param rs + * @return + */ + public static Map setRsToMap(RecordSet rs){ + try{ + Map result = new HashMap<>(); + for(String name:rs.getColumnName()){ + result.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name))); + } + return result; + }catch(Exception e){ + logger.error("DaoUtil.setRsToMap execute error;exception:" + e.getMessage() + ";e:" + e); + return new HashMap<>(); + } + } + + /** + * 判断数据是否存在 + * @param sql + * @param params + * @return + */ + public static boolean isDataExists(String sql,Object...params) { + try{ + RecordSet rs = new RecordSet(); + return isDataExists(rs,sql,params); + }catch(Exception e){ + logger.error("DaoUtil.isDataExists Exception;sql:" + sql + ";params:" + params + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 判断数据是否存在 + * @param rs + * @param sql + * @param params + * @return + */ + public static boolean isDataExists(RecordSet rs,String sql,Object...params) { + try{ + int count = 0; + if(rs.executeQuery(sql,params)){ + if(rs.next()){ + count = Util.getIntValue(rs.getString(1),0); + } + }else{ + logger.error("DaoUtil.isDataExists sql error;sql:" + sql + ";params:" + params); + } + if(count > 0){ + return true; + }else{ + return false; + } + }catch(Exception e){ + logger.error("DaoUtil.isDataExists Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 查询第一行数据 + * @param rs + * @param sql + * @param params + * @return + */ + public static Map getFirstData(RecordSet rs, String sql, Object...params){ + Map result = new HashMap<>(); + try{ + if(rs.executeQuery(sql,params)){ + if(rs.next()){ + for(String name:rs.getColumnName()){ + result.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name))); + } + }else{ + logger.error("DaoUtil.getFirstData sql found nothing;sql:" + sql + ";params:" + params); + } + }else{ + logger.error("DaoUtil.getFirstData sql error;sql:" + sql + ";params:" + params); + } + return result; + }catch(Exception e){ + logger.error("DaoUtil.getFirstData Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 查询 + * @param sql + * @param params + * @return + */ + public static Map getFirstData(String sql, Object...params){ + Map result = new HashMap<>(); + try{ + RecordSet rs = new RecordSet(); + result = getFirstData(rs,sql,params); + return result; + }catch(Exception e){ + logger.error("DaoUtil.getFirstData Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 查询 + * @param rs + * @param sql + * @param params + * @return + */ + public static List> getData(RecordSet rs, String sql, Object...params){ + List> result = new ArrayList<>(); + try{ + if(rs.executeQuery(sql,params)){ + while(rs.next()){ + Map m = new HashMap<>(); + for(String name:rs.getColumnName()){ + if("zdysql".equalsIgnoreCase(name) || Util.null2String(name).toLowerCase(Locale.ROOT).indexOf("zdysql") > -1){ + String zdysql = Util.null2String(rs.getString(name)); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + m.put(name.toLowerCase(Locale.ROOT),zdysql); + }else{ + m.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name))); + } + } + result.add(m); + } + }else{ + logger.error("DaoUtil.getData sql error;sql:" + sql + ";params:" + params); + } + return result; + }catch(Exception e){ + logger.error("DaoUtil.getData Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 查询 + * @param sql + * @param params + * @return + */ + public static List> getData(String sql, Object...params){ + List> result = new ArrayList<>(); + try{ + RecordSet rs = new RecordSet(); + result = getData(rs,sql,params); + return result; + }catch(Exception e){ + logger.error("DaoUtil.getData Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return result; + } + } + + /** + * 更新数据 + * @param rs + * @param sql + * @param params + * @return + */ + public static boolean updateData(RecordSet rs,String sql, Object...params){ + try{ + if(!rs.executeUpdate(sql,params)){ + logger.error("DaoUtil.updateData sql error;sql:" + sql + ";params:" + params); + return false; + }else{ + return true; + } + }catch(Exception e){ + logger.error("DaoUtil.updateData Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 更新数据 + * @param sql + * @param params + */ + public static boolean updateData(String sql, Object...params){ + try{ + RecordSet rs = new RecordSet(); + return updateData(rs,sql,params); + }catch(Exception e){ + logger.error("DaoUtil.updateData Exception;sql:" + sql + ";params:" + params + e.getMessage() + ";e:" + e); + return false; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/HrmCommonUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/HrmCommonUtil.java new file mode 100644 index 0000000..759f152 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/HrmCommonUtil.java @@ -0,0 +1,77 @@ +package weaver.taojw.common; + +import com.weaver.general.Util; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.finance.SalaryManager; +import weaver.hrm.resource.ResourceComInfo; +import weaver.taojw.common.logging.MyLogger; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +public class HrmCommonUtil { + + static Logger logger = MyLogger.getLogger(); + + public static Map addUser(Map userInfo,RecordSet rsSch){ + Map result = new HashMap<>(); + try{ + if(rsSch == null){ + rsSch = new RecordSet(); + } + + char separator = Util.getSeparator(); + Calendar todaycal = Calendar.getInstance(); + String today = Util.add0(todaycal.get(Calendar.YEAR), 4) + "-" + + Util.add0(todaycal.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(todaycal.get(Calendar.DAY_OF_MONTH), 2); + String userpara = "" + 1 + separator + today; + + + rsSch.executeProc("HrmResourceMaxId_Get", ""); + rsSch.next(); + //新增的人员id + String newId = "" + rsSch.getInt(1); + //使用sql新增人员 + String insertSql = + "insert into HrmResource(" + + "id,systemlanguage,workcode,departmentid,subcompanyid1," + + "jobtitle,status,createrid,createdate,lastmodid," + + "lastmoddate,lastname,sex,loginid,password," + + "managerid,seclevel,dsporder) " + + "values(" + + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean addUser = DaoUtil.updateData(insertSql, + newId, userInfo.get("systemlanguage"), userInfo.get("workcode"), userInfo.get("departmentid"), userInfo.get("subcompanyid1"), + userInfo.get("jobtitle"), userInfo.get("status"), userInfo.get("createrid"), userInfo.get("createdate"), userInfo.get("lastmodid"), + userInfo.get("lastmoddate"), userInfo.get("lastname"), userInfo.get("sex"), userInfo.get("loginid"), userInfo.get("password"), + userInfo.get("managerid"), userInfo.get("seclevel"), userInfo.get("dsporder")); + if(addUser){ + rsSch.executeProc("HrmResource_CreateInfo", "" + newId + separator + userpara + separator + userpara); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + resourceComInfo.addResourceInfoCache(newId); + SalaryManager salaryManager = new SalaryManager(); + salaryManager.initResourceSalary(newId); + String para1 = "" + newId + separator + "" + separator + userInfo.get("departmentid") + separator + userInfo.get("subcompanyid1") + separator + "0" + separator + "0"; + rsSch.executeProc("HrmResource_Trigger_Insert", para1); + String sql_1 = ("insert into HrmInfoStatus (itemid,hrmid) values(1," + newId + ")"); + rsSch.execute(sql_1); + String sql_2 = ("insert into HrmInfoStatus (itemid,hrmid) values(2," + newId + ")"); + rsSch.execute(sql_2); + String sql_3 = ("insert into HrmInfoStatus (itemid,hrmid) values(3," + newId + ")"); + rsSch.execute(sql_3); + String sql_10 = ("insert into HrmInfoStatus (itemid,hrmid) values(10," + newId + ")"); + rsSch.execute(sql_10); + resourceComInfo.updateResourceInfoCache(newId); + result.put("newId",newId); + }else{ + logger.error("HrmCommonUtil.addUser.addUserSql error;userInfo:" + userInfo); + } + }catch(Exception e){ + logger.error("HrmCommonUtil.addUser exception;userInfo:" + userInfo + "message:" + e.getMessage() + ";e:" + e); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/HttpGetWithEntity.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/HttpGetWithEntity.java new file mode 100644 index 0000000..4d47e32 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/HttpGetWithEntity.java @@ -0,0 +1,29 @@ +package weaver.taojw.common; + +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; + +import java.net.URI; + +public class HttpGetWithEntity extends HttpEntityEnclosingRequestBase { + private final static String METHOD_NAME = "GET"; + + @Override + public String getMethod() { + return METHOD_NAME; + } + + public HttpGetWithEntity() { + super(); + } + + public HttpGetWithEntity(final URI uri) { + super(); + setURI(uri); + } + + HttpGetWithEntity(final String uri) { + super(); + setURI(URI.create(uri)); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/JsonConvertUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/JsonConvertUtil.java new file mode 100644 index 0000000..8e9d5d7 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/JsonConvertUtil.java @@ -0,0 +1,32 @@ +package weaver.taojw.common; + +import com.alibaba.fastjson.JSONObject; +import weaver.conn.RecordSet; + +import java.util.List; +import java.util.Map; + +public class JsonConvertUtil { + + public static JSONObject convertJsonByConfig(JSONObject oldJson,String configId){ + RecordSet rs = new RecordSet(); + //获取配置信息 + String getConfigSql = + "select " + + "t2.zhgz,t2.zdysql,t2.xzdmc,t2.yzdmc " + + "from " + + "uf_jsontojson t1 " + + "inner join uf_jsontojson_dt1 t2 on t2.mainid = t1.id " + + "where " + + "t1.id = ?"; + List> configData = DaoUtil.getData(rs, getConfigSql, configId); + JSONObject result = new JSONObject(); + for(Map configMap : configData){ + String oldValue = oldJson.getString(configMap.get("yzdmc")); + String newValue = WorkFlowDataToJsonUtil.convertDataByZhgz(oldValue,configMap); + result.put(configMap.get("xzdmc"),newValue); + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/Md5Util.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/Md5Util.java new file mode 100644 index 0000000..ab066c3 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/Md5Util.java @@ -0,0 +1,72 @@ +package weaver.taojw.common; + +import com.weaverboot.tools.logTools.LogTools; +import javax.xml.bind.DatatypeConverter; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.security.MessageDigest; + +public class Md5Util { + + public static String MD5Encode(String originalString) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(originalString.getBytes()); + byte[] digest = md.digest(); + String hash = DatatypeConverter.printHexBinary(digest).toUpperCase(); + return hash; + } catch (Exception var5) { + var5.printStackTrace(); + return ""; + } + } + + /** + * 对文件全文生成MD5摘要 + * + * @param file + * 要加密的文件 + * @return MD5摘要码 + */ + public static String getMD5OfFile(final File file) throws IOException { + FileInputStream fis = null; + try { + final MessageDigest md = MessageDigest.getInstance("MD5"); + fis = new FileInputStream(file); + final byte[] buffer = new byte[2048]; + int length = -1; + final long s = System.currentTimeMillis(); + while ((length = fis.read(buffer)) != -1) { + md.update(buffer, 0, length); + } + final byte[] b = md.digest(); + return byteToHexStringSingle(b); + } catch (final Exception ex) { + LogTools.error(file.getName()+"生成md5码时发生异常:"+ex.getMessage()); + return null; + } finally { + fis.close(); + } + } + + /** + * 独立把byte[]数组转换成十六进制字符串表示形式 + * + * @param byteArray + * 字节数组 + * @return String + */ + public static String byteToHexStringSingle(final byte[] byteArray) { + final StringBuffer md5StrBuff = new StringBuffer(); + for (int i = 0; i < byteArray.length; i++) { + if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) { + md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i])); + } else { + md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i])); + } + } + return md5StrBuff.toString(); + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/ModelDataToJsonUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/ModelDataToJsonUtil.java new file mode 100644 index 0000000..1b433e5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/ModelDataToJsonUtil.java @@ -0,0 +1,498 @@ +package weaver.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; + +import java.text.SimpleDateFormat; +import java.util.*; + +public class ModelDataToJsonUtil { + + static Logger logger = MyLogger.getLogger(); + + public static JSONObject getJsonByModelData(String billId,String configId){ + JSONObject result = new JSONObject(); + try{ + logger.info("ModelDataToJsonUtil.getJsonByModelData begin;billId:" + billId + ";configId:" + configId); + + RecordSet rs = new RecordSet(); + //-----------------------根据配置id获取配置信息 + //根节点配置信息 + List> rootJsonConfigInfo = new ArrayList<>(); + //明细配置信息 + List> requestBodyConfigList = new ArrayList<>(); + getConfigInfo(rs,configId,requestBodyConfigList,rootJsonConfigInfo); + + String modeId = ""; + String getModeIdSql = "select mkid from uf_jmsjzjson where id = ?"; + if(rs.executeQuery(getModeIdSql,configId)){ + if(rs.next()){ + modeId = Util.null2String(rs.getString("mkid")); + } + } + String[] base_array = new String[5]; + base_array[0] = ""; + base_array[1] = ""; + base_array[2] = ""; + base_array[3] = CommonSqlUtil.getTableNameByModeId(modeId,rs); + base_array[4] = billId; + + //-----------------------获取主表数据 用于拼装json + Map mainTableData = new HashMap<>(); + String getMainTableDataSql = "select * from " + base_array[3] + " where id = " + base_array[4]; + if(rs.executeQuery(getMainTableDataSql)) { + if (rs.next()) { + mainTableData = DaoUtil.setRsToMap(rs); + } + } + //-----------------------生成json + logger.info("recursionGenerateJson begin;"); + recursionGenerateJson(null,rs,rs,0,result,rootJsonConfigInfo,base_array,mainTableData,requestBodyConfigList,"",""); + }catch(Throwable e){ + logger.error("WorkFlowDataToJsonUtil.getJsonByWorkFlowData exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据转换规则 获取转换后的数据 + */ + public static String convertDataByZhgz(String oldValue,Map configMap){ + //函数返回值 + String result = ""; + try{ + //转换规则 + String zhgz = configMap.get("zhgz"); + //自定义sql + String zdysql = configMap.get("zdysql"); + String requestId = Util.null2String(configMap.get("requestId")); + //不同转换规则处理 + switch(zhgz){ + //不转换 + case "0": + result = oldValue; + break; + //固定值 + case "1": + result = zdysql; + break; + //自定义sql + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId); + Map firstData = DaoUtil.getFirstData(zdysql); + for(String key : firstData.keySet()){ + result = firstData.get(key); + } + break; + //日期格式化 + case "3": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd").parse(oldValue)); + break; + //日期时间格式化 + case "4": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(oldValue)); + break; + //当前日期 + case "5": + result = new SimpleDateFormat(zdysql).format(new Date()); + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.convertDataByZhgz error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + + /** + * 根据configId获取配置信息 + * @param rs 数据库链接 + * @param configId 配置id + * @param requestBodyConfigList 明细配置 + * @param rootJsonConfigInfo 根节点配置 + */ + public static void getConfigInfo(RecordSet rs,String configId,List> requestBodyConfigList,List> rootJsonConfigInfo){ + //获取明细表 请求体字段详细配置信息 + String selectDetailSQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from uf_jmsjzjson_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetailSQL,configId)){ + while(rs.next()){ + //节点序号 + String xmljdxh = Util.null2String(rs.getString("jdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("jdmc")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("jdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Constant.Default_Line_Break,Constant.Default_Blank_Char); + zdysql = zdysql.replace(Constant.Default_Html_Blank,Constant.Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Constant.Default_Line_Break,Constant.Default_Blank_Char); + sjtj = sjtj.replace(Constant.Default_Html_Blank,Constant.Default_Blank_Char); + sjtj = CommonUtil.fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("jdxh",xmljdxh); + dtMap.put("jdmc",xmljdmc); + dtMap.put("jdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("zdgz",zdgz); + dtMap.put("detailtable",detailtable); + dtMap.put("fieldName",fieldName.toLowerCase()); + if("".equals(fjdxh)){ + rootJsonConfigInfo.add(dtMap); + } + requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL sql execute error;sql:" + selectDetailSQL); + } + logger.info("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL done;requestBodyConfigList:" + requestBodyConfigList); + } + + /** + * 递归生成json报文 + */ + public static Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence,JSONObject jsonDoc, + List> rootJsonConfigInfo, + String[] baseArray,Map mainTableData, + List> requestBodyConfigList,String currentTableIndex,String currentDetailDataId){ + String getMainDataByConditionSql = "select count(1) as c from " + baseArray[3] + " t1 where "; + String getDetailDataByConditionSql = "select count(1) as c from " + baseArray[3] + " t1 inner join " + baseArray[3] + "_dt" + currentTableIndex + " t2 where t2.id = ? and "; + + if(configMap == null){ + for(Map configInfo:rootJsonConfigInfo){ + + String sjtj = configInfo.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null && !Constant.NODE_TYPE_ARRAY.equals(configInfo.get("jdlx"))){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,"","")); + } + }else{ + jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,"","")); + } + + } + }else{ + switch(configMap.get("jdlx")){ + case Constant.NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + return getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + case Constant.NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + return "true".equals(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + case Constant.NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case Constant.NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + d = Double.parseDouble(f); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case Constant.NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = m.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + return json; + case Constant.NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + String sjtj = m.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + return jsonObj.toString(); + case Constant.NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + JSONArray stringArray = new JSONArray(); + stringArray.addAll(Arrays.asList(stringArrayValue.split(","))); + return stringArray; + case Constant.NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && Constant.CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = son.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = son.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + }else{ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId)); + } + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select t2.id as detailid,* from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " t2 inner join " + baseArray[3] + " t1 on t1.id = t2.mainid where t2.mainid = " + baseArray[4] + " and "; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + + String sjtj = son.get("sjtj"); + if(!"".equals(sjtj) && sjtj != null){ + //若当前currentTableIndex不为空,用明细校验 + if("".equals(currentTableIndex)){ + getMainDataByConditionSql = getMainDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getMainDataByConditionSql)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid"))); + } + }else{ + getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj; + if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid"))); + } + } + }else{ + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid"))); + } + } + } + array.add(o); + } + } + return array; + default: + break; + } + } + return null; + } + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + */ + public static String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs,String[] baseArray,Map mainTableData){ + //函数返回值 + StringBuilder result = new StringBuilder(); + try{ + Map detailDataMap = DaoUtil.setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //字段所属明细表表名 + String detailtable = configMap.get("detailtable"); + //不同转换规则处理 + switch(zhgz){ + case Constant.CHANGE_TYPE_REQUEST_ID: + result = new StringBuilder(baseArray[0]); + break; + case Constant.CHANGE_TYPE_REQUEST_NAME: + result = new StringBuilder(baseArray[1]); + break; + case Constant.CHANGE_TYPE_MD5: + result = new StringBuilder("Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes())); + break; + case Constant.CHANGE_TYPE_SUGGESTION: + result = new StringBuilder(baseArray[2]); + break; + case Constant.CHANGE_TYPE_ROW_NUMBER: + result = new StringBuilder(configMap.get("detailRowNum")); + break; + case Constant.CHANGE_TYPE_FIXED: + result = new StringBuilder(configMap.get("zdysql")); + break; + case Constant.CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = new StringBuilder(mainTableData.get(fieldName)); + }else{ + result = new StringBuilder(detailDataMap.get(fieldName)); + } + break; + case Constant.CHANGE_TYPE_SQL: + String oldValue; + if(!"".equals(viewType) && !"".equals(fieldName)){ + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + } + zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + } + } + break; + case Constant.CHANGE_TYPE_SUM: + if("0".equals(viewType)){ + logger.error("want sum but config main field"); + break; + } + String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4]; + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString("val"))); + } + } + break; + case Constant.CHANGE_TYPE_STRING_ARRAY: + if("0".equals(viewType)){ + logger.error("want array but config main field"); + break; + } + String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4]; + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + }else{ + result.append(",").append(Util.null2String(rs.getString(1))); + } + i = i + 1; + } + } + break; + default: + result = new StringBuilder(); + break; + } + return result.toString(); + }catch(Exception e){ + result = new StringBuilder(); + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result.toString(); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/OauthOneHttpUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/OauthOneHttpUtil.java new file mode 100644 index 0000000..fd2d854 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/OauthOneHttpUtil.java @@ -0,0 +1,51 @@ +package weaver.taojw.common; + +import oauth.signpost.OAuthConsumer; +import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; +import oauth.signpost.http.HttpParameters; +import oauth.signpost.signature.AuthorizationHeaderSigningStrategy; +import oauth.signpost.signature.HmacSha1MessageSigner; +import oauth.signpost.signature.HmacSha256MessageSigner; +import org.apache.http.client.methods.*; +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; + +/** + * OAuth1.0接口调用工具类 + * jar包 + * signpost-commonshttp4-1.2.jar + * signpost-core-2.1.1.jar + */ +public class OauthOneHttpUtil { + + Logger logger = MyLogger.getLogger(); + + public String consumerKey = ""; + public String consumerSecret = ""; + public String accessToken = ""; + public String accessTokenSecret = ""; + public String realmID = ""; + public String encryption = ""; + + public void authorize(HttpRequestBase httpRequest){ + try { + OAuthConsumer oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); + if("HMAC-SHA256".equalsIgnoreCase(encryption)){ + oAuthConsumer.setMessageSigner(new HmacSha256MessageSigner()); + }else if("HMAC-SHA1".equalsIgnoreCase(encryption)){ + oAuthConsumer.setMessageSigner(new HmacSha1MessageSigner()); + } + if(realmID != null && !"".equals(realmID)){ + HttpParameters parameters = new HttpParameters(); + parameters.put("realm", realmID); + oAuthConsumer.setAdditionalParameters(parameters); + } + oAuthConsumer.setTokenWithSecret(accessToken, accessTokenSecret); + oAuthConsumer.setSigningStrategy(new AuthorizationHeaderSigningStrategy()); + oAuthConsumer.sign(httpRequest); + }catch(Throwable e) { + logger.info("OauthOneHttpUtil.authorize error;message:" + e.getMessage() + ";e:" + e); + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwAesUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwAesUtil.java new file mode 100644 index 0000000..b6d40a8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwAesUtil.java @@ -0,0 +1,65 @@ +package weaver.taojw.common; + +import org.apache.log4j.Logger; +import weaver.file.AESCoder; +import weaver.taojw.common.logging.MyLogger; +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +public class TjwAesUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String aesEncrypt(String param,String key){ + String result = ""; + try{ + result = AESCoder.encrypt(param,key); + }catch (Exception e){ + logger.error("AesUtil.aesEncrypt error;message" + e.getMessage() + ";e:" + e); + } + logger.info("aesEncrypt result:" + result); + return result; + } + + // 加密 + public static String Encrypt(String sKey, String sSrc) throws Exception { + byte[] raw = sKey.getBytes("utf-8"); + SecretKeySpec sks = new SecretKeySpec(raw, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式" + cipher.init(Cipher.ENCRYPT_MODE, sks); + byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8")); + return bytesToHexString(encrypted); + } + + // 解密 + public static String Decrypt(String sKey, String sSrc) throws Exception { + byte[] raw = sKey.getBytes("utf-8"); + SecretKeySpec sks = new SecretKeySpec(raw, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, sks); + byte[] encrypted1 = hexStringToBytes(sSrc); //new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密 + byte[] original = cipher.doFinal(encrypted1); + String originalString = new String(original,"utf-8"); + return originalString; + } + + //字节数组转16进制字符串 + public static String bytesToHexString(byte[] b){ + StringBuffer result = new StringBuffer(); + for(int i = 0;i < b.length;i++){ + result.append(String.format("%02X",b[i])); + } + return result.toString(); + } + + //16进制字符串转字节数组 + public static byte[] hexStringToBytes(String src){ + int l = src.length()/2; + byte[] ret = new byte[l]; + for(int i = 0;i> srcFiles , OutputStream out) { + ZipOutputStream zos = null; + try{ + zos = new ZipOutputStream(out); + for (Map imageFileInfo : srcFiles) { + String imageFileId = imageFileInfo.get("imageFileId"); + String imageFileName = imageFileInfo.get("imageFileName"); + byte[] buf = new byte[2 * 1024]; + zos.putNextEntry(new ZipEntry(imageFileName)); + int len; + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + while ((len = in.read(buf)) != -1){ + zos.write(buf, 0, len); + } + zos.closeEntry(); + in.close(); + } + }catch (Throwable e){ + logger.error("TjwDocumentUtil.toZip error;message:" + e.getMessage() + ";e:" + e); + }finally{ + if(zos != null){ + try { + zos.close(); + } catch (IOException e) { + logger.error("TjwDocumentUtil.toZip zos close error;message:" + e.getMessage() + ";e:" + e); + } + } + } + } + + public static String getBase64StringByImageFileId(String imageFileId){ + String base64 = ""; + InputStream is = null; + try { + ImageFileManager imageFileManager = new ImageFileManager(); + is = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + String getFileSizeSql = "select filesize from imagefile where imagefileid = ?"; + String filesize = DaoUtil.getFirstData(new RecordSet(), getFileSizeSql, imageFileId).get("filesize"); + byte[] bytes = new byte[Integer.parseInt(filesize)]; + is.read(bytes); + BASE64Encoder encoder = new BASE64Encoder(); + base64 = encoder.encode(bytes); + } catch (Exception e) { + logger.error("TjwDocumentUtil.getBase64StringByImageFileId exception;imageFileId:" + imageFileId + ";message:" + e.getMessage() + ";e:" + e); + } finally { + if (is != null) { + try { + is.close(); + } catch (Exception e) { + logger.error("TjwDocumentUtil.getBase64StringByImageFileId io close exception;imageFileId:" + imageFileId + ";message:" + e.getMessage() + ";e:" + e); + } + } + } + return base64; + } + + /** + * 根据docId复制文档;返回新docId + * @param olddocid 被复制的docId + * @param userid + * @param docsubject 新的文件名称 + * @param seccategory 目录id + * @return + */ + public static int copyDocToNewDoc(int olddocid, int userid,String docsubject,int seccategory){ + int newdocid = -1; + try { + logger.info("TjwDocumentUtil.copyDocToNewDoc begin;olddocid:" + olddocid + ";userid:" + userid + ";docsubject:" + docsubject + ";seccategory:" + seccategory); + //复制文档 + DocComInfo dc = new DocComInfo(); + DocViewer dv = new DocViewer(); + DocManager docManager = new DocManager(); + docManager.setId(olddocid); + docManager.setUserid(userid); + docManager.setUsertype("0"); + docManager.setDocsubject(docsubject); + docManager.setClientAddress("127.0.0.1"); + docManager.setSeccategory(seccategory); + docManager.copyDoc(); + newdocid = docManager.getId(); + // 文档赋权操作 + DocManager docNewManager = new DocManager(); + docNewManager.setIsreply("0"); + docNewManager.setId(newdocid); + docNewManager.setSeccategory(seccategory); + docNewManager.setUserid(userid); + docNewManager.setUsertype("1"); + docManager.AddShareInfo(); + dc.addDocInfoCache("" + newdocid); + dv.setDocShareByDoc("" + newdocid); + //TODO 据我观察 上面虽然传了docsubject,但代码并未更新文件名称,因此在下面更新文件名称 + RecordSet rs = new RecordSet(); + String oldname = ""; + String docfiletype = ""; + String getExtendSql = "select imagefilename,docfiletype from DocImageFile where docid = ?"; + if(rs.executeQuery(getExtendSql,olddocid)){ + if(rs.next()){ + oldname = Util.null2String(rs.getString("imagefilename")); + docfiletype = Util.null2String(rs.getString("docfiletype")); + } + } + logger.info("oldname:" + oldname + ";docfiletype:" + docfiletype); + String extend = ""; + switch (docfiletype){ + case "7": + extend = ".docx"; + break; + case "3": + extend = ".doc"; + break; + case "4": + extend = ".xls"; + break; + case "5": + extend = ".ppt"; + break; + case "6": + extend = ".wps"; + break; + case "8": + extend = ".xlsx"; + break; + case "9": + extend = ".pptx"; + break; + default: + break; + } + String newName = docsubject + extend; + String updateDocImageFileNameSql = "update DocImageFile set imagefilename = ? where docid = ?"; + if(!rs.executeUpdate(updateDocImageFileNameSql,newName,newdocid)){ + logger.error("updateDocImageFileNameSql error"); + } + String updateImagefileName2Sql = "update imagefile set imagefilename = ? where imagefileid in (select imagefileid from DocImageFile where docid = ?)"; + if(!rs.executeUpdate(updateImagefileName2Sql,newName,newdocid)){ + logger.error("updateImagefileName2Sql error"); + } + String updateDocdetailSql = "update docdetail set docsubject = ?,keyword = ? where id = ?"; + if(!rs.executeUpdate(updateDocdetailSql,docsubject,docsubject,newdocid)){ + logger.error("updateDocdetailSql error"); + } + } catch (Exception e) { + logger.error("TjwDocumentUtil.copyDocToNewDoc exception;message:" + e.getMessage() + ";e:" + e); + } + return newdocid; + } + + public static int addDocImageInfo(int docId,String fileName, int imageFileId) { + try{ + DocImageManager imgManger = new DocImageManager(); + imgManger.resetParameter(); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFileId); + imgManger.setImagefilename(fileName); + imgManger.setIsextfile("1"); + String ext = fileName.substring(fileName.lastIndexOf(".") + 1); + if ("doc".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("3"); + } else if ("xls".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("4"); + } else if ("ppt".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("5"); + } else if ("wps".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("6"); + } else if ("docx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("7"); + } else if ("xlsx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("8"); + } else if ("pptx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("9"); + } else { + imgManger.setDocfiletype("2"); + } + imgManger.AddDocImageInfo(); + return docId; + }catch(Exception e){ + logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";imageFileId" + imageFileId + ";docId:" + docId + ";message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + /** + * 根据imageFileId生成docId + * @param fileName 文件名称 + * @param seccategory 文件目录 + * @param imageFileId 物理文件ID + * @param userId 用户ID + * @return docId + */ + public static int createDocByImageFileId(String docSubject, String fileName, int seccategory, int imageFileId, Integer userId) { + try{ + DocInfo docInfo = new DocInfo(); + docInfo.setImagefileId(imageFileId); + docInfo.setSeccategory(seccategory); + docInfo.setDocSubject(docSubject); + docInfo.setDoccontent(""); + DocServiceImpl docService = new DocServiceImpl(); + int docId = docService.createDocByUser(docInfo, new User(userId)); + DocImageManager imgManger = new DocImageManager(); + imgManger.resetParameter(); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFileId); + imgManger.setImagefilename(fileName); + imgManger.setIsextfile("1"); + String ext = fileName.substring(fileName.lastIndexOf(".") + 1); + if ("doc".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("3"); + } else if ("xls".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("4"); + } else if ("ppt".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("5"); + } else if ("wps".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("6"); + } else if ("docx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("7"); + } else if ("xlsx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("8"); + } else if ("pptx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("9"); + } else { + imgManger.setDocfiletype("2"); + } + imgManger.AddDocImageInfo(); + return docId; + }catch(Exception e){ + logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";seccategory:" + seccategory + ";imageFileId" + imageFileId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + /** + * 根据imageFileId生成docId + * @param fileName 文件名称 + * @param seccategory 文件目录 + * @param imageFileId 物理文件ID + * @param userId 用户ID + * @return docId + */ + public static int createDocByImageFileId(String fileName, int seccategory, int imageFileId, Integer userId) { + try{ + DocInfo docInfo = new DocInfo(); + docInfo.setImagefileId(imageFileId); + docInfo.setSeccategory(seccategory); + docInfo.setDocSubject(fileName); + docInfo.setDoccontent(""); + DocServiceImpl docService = new DocServiceImpl(); + int docId = docService.createDocByUser(docInfo, new User(userId)); + DocImageManager imgManger = new DocImageManager(); + imgManger.resetParameter(); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFileId); + imgManger.setImagefilename(fileName); + imgManger.setIsextfile("1"); + String ext = fileName.substring(fileName.lastIndexOf(".") + 1); + if ("doc".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("3"); + } else if ("xls".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("4"); + } else if ("ppt".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("5"); + } else if ("wps".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("6"); + } else if ("docx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("7"); + } else if ("xlsx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("8"); + } else if ("pptx".equalsIgnoreCase(ext)) { + imgManger.setDocfiletype("9"); + } else { + imgManger.setDocfiletype("2"); + } + imgManger.AddDocImageInfo(); + return docId; + }catch(Exception e){ + logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";seccategory:" + seccategory + ";imageFileId" + imageFileId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e); + return 0; + } + } + + /** + * 创建物理文件 + * + * @param content 文件流 + * @param fileName 文件名 + * @return 文件id + */ + public static int createFileByInputSteam(InputStream content, String fileName) { + try{ + /*byte[] bytes = IOUtils.toBytes(content); + logger.info("bytes.size:" + bytes.length);*/ + ImageFileManager imageFileManager = new ImageFileManager(); + int imgFileId = -1; + try { + ImageFileManager.class.getMethod("saveImageFileByInputStream", InputStream.class, String.class); + imgFileId = imageFileManager.saveImageFileByInputStream(content, fileName); + }catch (NoSuchMethodException e) { + logger.error("createFileByInputSteam.NoSuchMethodException"); + imageFileManager.setImagFileName(fileName); + try { + imageFileManager.setData(IOUtils.toBytes(content)); + } catch (Exception ex) { + logger.error("CommonUtil.createFileByInputSteam toBytes exception;fileName:" + fileName + ";message:" + e.getMessage() + ";e:" + e); + throw new Exception("创建文件失败,文件流转换失败", e); + } + imgFileId = imageFileManager.saveImageFile(); + } + return imgFileId; + }catch (Exception e){ + logger.error("CommonUtil.createFileByInputSteam exception;fileName:" + fileName + ";message:" + e.getMessage() + ";e:" + e); + return -1; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwFpUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwFpUtil.java new file mode 100644 index 0000000..8171143 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwFpUtil.java @@ -0,0 +1,248 @@ +package weaver.taojw.common; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.fna.invoice.utils.InvoiceCloudUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.taojw.common.logging.MyLogger; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +public class TjwFpUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String getTimestamp(String date){ + String timestamp = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date d = sdf.parse(date); + timestamp = Util.null2String(d.getTime()/1000); + }catch (Throwable e){ + logger.error("TjwFpUtil.getTimestamp error;message:" + e.getMessage() + ";e:" + e); + } + return timestamp; + } + + /** + * @param cloudIdParam 发票的cloudid + * @param user + * @param sreim 0-取消 1-报销 2-核销 + * @param je 金额 + * @param requestId + * @param requestmark + * @param requestName + */ + public static void updateFpStatusInCloudCommon(User user,String cloudIdParam,String sreim,String je,String requestId,String requestmark,String requestName){ + try{ + RecordSet rs = new RecordSet(); + + String getTimeSql = "select CREATEDATE,CREATETIME from workflow_requestbase where requestid = ?"; + Map firstData1 = DaoUtil.getFirstData(rs, getTimeSql, requestId); + String CREATEDATE = firstData1.get("createdate"); + String CREATETIME = firstData1.get("createtime"); + + String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs); + String getdjbhSql = "select djbh from " + tableName + " where requestid = ?"; + Map firstData2 = DaoUtil.getFirstData(rs, getdjbhSql, requestId); + requestmark = Util.null2String(firstData2.get("djbh")); + + + String getDataSql = "select * from fnainvoiceledger where cloudid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam); + String userId = firstData.get("userid_new"); + //其中key为userid_new, value为的List + Map> mapCloud = new HashMap<>(); + List cloudIds = new ArrayList<>(); + cloudIds.add(cloudIdParam); + mapCloud.put(userId,cloudIds); + //发票云报销修改发票云数据 + for(Map.Entry> entry : mapCloud.entrySet()){ + String userid_new = entry.getKey(); + int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0); + JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true); + JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud"); + + String cid = Util.null2String(cloudInfo.getString("cid")); + String userName = Util.null2String(cloudInfo.getString("userName")); + String password = Util.null2String(cloudInfo.getString("password")); + String aesKey = Util.null2String(cloudInfo.getString("aesKey")); + String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl")); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("cid",cid); + bodyJson.put("userId",user.getUID()); + //2表示修改状态 3表示校验 + bodyJson.put("flag","2"); + JSONArray fnaInvoiceReimburseInfoJa = new JSONArray(); + + JSONObject fnaInvoiceReimburseInfoJo = new JSONObject(); + fnaInvoiceReimburseInfoJo.put("dataid", requestId); + fnaInvoiceReimburseInfoJo.put("number", requestmark); + DecimalFormat df = new DecimalFormat("#####################0.00"); + fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00))); + fnaInvoiceReimburseInfoJo.put("uid", user.getUID()); + //fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2))); + fnaInvoiceReimburseInfoJo.put("date", getTimestamp(CREATEDATE+" "+CREATETIME)); + fnaInvoiceReimburseInfoJo.put("name", requestName); + fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam); + fnaInvoiceReimburseInfoJo.put("cid", cid); + fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + + //1表示报销中 2表示已报销 + bodyJson.put("sreim",sreim); + + JSONArray reimburseInfoJa = new JSONArray(); + reimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + bodyJson.put("infos", reimburseInfoJa); + JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据"); + logger.info("reimburseJson:" + reimburseJson); + } + }catch (Throwable e){ + logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e); + } + + } + + /** + * @param cloudIdParam 发票的cloudid + * @param user 当前操作用户 + */ + public static void updateFpStatusInCloud3(User user,String cloudIdParam,String flag,String je,String requestId,String requestmark,String requestName){ + try{ + RecordSet rs = new RecordSet(); + String getDataSql = "select * from fnainvoiceledger where cloudid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam); + String userId = firstData.get("userid_new"); + DecimalFormat df = new DecimalFormat("#####################0.00"); + //其中key为userid_new, value为的List + Map> mapCloud = new HashMap<>(); + List cloudIds = new ArrayList<>(); + cloudIds.add(cloudIdParam); + mapCloud.put(userId,cloudIds); + //发票云报销修改发票云数据 + RecordSet rs5= new RecordSet(); + for(Map.Entry> entry : mapCloud.entrySet()){ + String userid_new = entry.getKey(); + int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0); + JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true); + JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud"); + boolean existEffectCloud = cloudInfo.getBoolean("existEffectCloud"); + logger.info("existEffectCloud:" + existEffectCloud); + + String cid = Util.null2String(cloudInfo.getString("cid")); + String userName = Util.null2String(cloudInfo.getString("userName")); + String password = Util.null2String(cloudInfo.getString("password")); + String aesKey = Util.null2String(cloudInfo.getString("aesKey")); + String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl")); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("cid",cid); + bodyJson.put("userId",user.getUID()); + bodyJson.put("flag",flag); + JSONArray fnaInvoiceReimburseInfoJa = new JSONArray(); + + logger.info("requestid:" + requestId); + logger.info("requestmark:" + requestmark); + logger.info("je:" + je); + + JSONObject fnaInvoiceReimburseInfoJo = new JSONObject(); + fnaInvoiceReimburseInfoJo.put("dataid", requestId);//requestid + fnaInvoiceReimburseInfoJo.put("number", requestmark);//requestmark + fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00))); + fnaInvoiceReimburseInfoJo.put("uid", user.getUID()); + fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2))); + fnaInvoiceReimburseInfoJo.put("name", requestName); + fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam); + fnaInvoiceReimburseInfoJo.put("cid", cid); + fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + + bodyJson.put("sreim","2"); + + JSONArray reimburseInfoJa = new JSONArray(); + reimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + bodyJson.put("infos", reimburseInfoJa); + JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据"); + logger.info("reimburseJson:" + reimburseJson); + } + }catch (Throwable e){ + logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e); + } + + } + + /** + * @param cloudIdParam 发票的cloudid + * @param user 当前操作用户 + */ + public static void updateFpStatusInCloud(User user,String cloudIdParam,String flag,String je,String requestId,String requestmark,String requestName){ + try{ + RecordSet rs = new RecordSet(); + String getDataSql = "select * from fnainvoiceledger where cloudid = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam); + String userId = firstData.get("userid_new"); + DecimalFormat df = new DecimalFormat("#####################0.00"); + //其中key为userid_new, value为的List + Map> mapCloud = new HashMap<>(); + List cloudIds = new ArrayList<>(); + cloudIds.add(cloudIdParam); + mapCloud.put(userId,cloudIds); + //发票云报销修改发票云数据 + RecordSet rs5= new RecordSet(); + for(Map.Entry> entry : mapCloud.entrySet()){ + String userid_new = entry.getKey(); + int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0); + JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true); + JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud"); + boolean existEffectCloud = cloudInfo.getBoolean("existEffectCloud"); + logger.info("existEffectCloud:" + existEffectCloud); + + String cid = Util.null2String(cloudInfo.getString("cid")); + String userName = Util.null2String(cloudInfo.getString("userName")); + String password = Util.null2String(cloudInfo.getString("password")); + String aesKey = Util.null2String(cloudInfo.getString("aesKey")); + String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl")); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("cid",cid); + bodyJson.put("userId",user.getUID()); + bodyJson.put("flag",flag); + JSONArray fnaInvoiceReimburseInfoJa = new JSONArray(); + + logger.info("requestid:" + requestId); + logger.info("requestmark:" + requestmark); + logger.info("je:" + je); + + JSONObject fnaInvoiceReimburseInfoJo = new JSONObject(); + fnaInvoiceReimburseInfoJo.put("dataid", requestId);//requestid + fnaInvoiceReimburseInfoJo.put("number", requestmark);//requestmark + fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00))); + fnaInvoiceReimburseInfoJo.put("uid", user.getUID()); + fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2))); + fnaInvoiceReimburseInfoJo.put("name", requestName); + fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam); + fnaInvoiceReimburseInfoJo.put("cid", cid); + fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + + bodyJson.put("sreim","1"); + + JSONArray reimburseInfoJa = new JSONArray(); + reimburseInfoJa.add(fnaInvoiceReimburseInfoJo); + bodyJson.put("infos", reimburseInfoJa); + JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据"); + logger.info("reimburseJson:" + reimburseJson); + } + }catch (Throwable e){ + logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e); + } + + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwHttpUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwHttpUtil.java new file mode 100644 index 0000000..2c45e81 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwHttpUtil.java @@ -0,0 +1,675 @@ +package weaver.taojw.common; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.io.IOUtils; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.*; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.BufferedHttpEntity; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.StringBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import javax.net.ssl.*; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.cert.X509Certificate; +import java.util.*; + +public class TjwHttpUtil { + + static Logger logger = MyLogger.getLogger(); + + /** + * 附件上传 + */ + public static JSONObject uploadFileUtil(String url, String imageFileIds, Map headers,Map textParams,String fileParamName){ + JSONObject result = new JSONObject(); + try{ + logger.info("TjwHttpUtil.uploadFileUtil begin;url:" + url + ";imageFileIds:" + imageFileIds); + //根据docIds获取文件信息 + String[] imageFileIdsArray = imageFileIds.split(","); + if(imageFileIdsArray == null || imageFileIdsArray.length == 0){ + return result; + } + List> fileInfos = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String getFileInfoSql = "select t2.imagefilename,t2.imagefileid from docimagefile t1 inner join imagefile t2 on t2.imagefileid = t1.imagefileid where t2.imagefileid = ?"; + for(String imageFileId:imageFileIdsArray){ + if(rs.executeQuery(getFileInfoSql,imageFileId)){ + while(rs.next()){ + Map file = new HashMap<>(); + file.put("imagefileid", Util.null2String(rs.getString("imagefileid"))); + file.put("imagefilename", Util.null2String(rs.getString("imagefilename"))); + fileInfos.add(file); + } + } + } + CloseableHttpClient httpClient = createSSLClientDefault(url); + HttpPost httpPost = new HttpPost(url); + MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create(); + multipartEntityBuilder.setCharset(StandardCharsets.UTF_8); + multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + ImageFileManager imageFileManager = new ImageFileManager(); + for(Map file:fileInfos){ + String fileName = file.get("imagefilename"); + fileName = fileName.replaceAll("&","&"); + fileName = fileName.replaceAll(">",">"); + fileName = fileName.replaceAll("<","<"); + fileName = fileName.replaceAll("'","'"); + fileName = fileName.replaceAll(""","\""); + InputStream imagefileid = imageFileManager.getInputStreamById(Integer.parseInt(file.get("imagefileid"))); + multipartEntityBuilder.addBinaryBody(fileParamName,imagefileid, ContentType.MULTIPART_FORM_DATA,fileName); + } + + ContentType contentType = ContentType.create("text/plain", StandardCharsets.UTF_8); + for(String key : textParams.keySet()){ + StringBody stringBody = new StringBody(String.valueOf(textParams.get(key)), contentType); + multipartEntityBuilder.addPart(key, stringBody); + } + + HttpEntity httpEntity = multipartEntityBuilder.build(); + httpPost.setEntity(httpEntity); + + //请求头设置 + if(headers != null && headers.size() > 0){ + for(String key:headers.keySet()){ + if(!"Content-Type".equals(key)){ + httpPost.setHeader(key,headers.get(key)); + } + } + } + //httpPost.addHeader("Content-Type", "multipart/form-data;"); + + logger.info("FilePostUtil.uploadFileUtil.httpClient.execute begin;imageFileIds:" + imageFileIds + ";url:" + url); + + CloseableHttpResponse httpResponse = httpClient.execute(httpPost); + HttpEntity responseEntity = httpResponse.getEntity(); + int statusCode= httpResponse.getStatusLine().getStatusCode(); + BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent())); + StringBuffer buffer = new StringBuffer(); + String str = ""; + while((str = reader.readLine()) != null) { + buffer.append(str); + } + logger.info("FilePostUtil.uploadFileUtil.httpClient.execute done;statusCode:" + statusCode + ";message:" + buffer); + result = JSONObject.parseObject(buffer.toString()); + httpClient.close(); + if(httpResponse!=null){ + httpResponse.close(); + } + }catch(Throwable e){ + logger.error("FilePostUtil.uploadFileUtil exception;url:" + url + ";imageFileIds:" + imageFileIds); + } + return result; + } + + public static void addLogInMode(String url,int code,String requestParam,String responseData){ + try{ + RecordSet rs = new RecordSet(); + JSONObject loggerJson = new JSONObject(); + loggerJson.put("qqdz",url); + loggerJson.put("qqxx",requestParam); + loggerJson.put("xyxx",responseData); + loggerJson.put("xym",code); + TjwModelUtil.addModelData(rs,"uf_tjwhttplog",loggerJson); + }catch (Throwable e){ + logger.error("TjwHttpUtil.addLogInMode error;message:" + e.getMessage() + ";e:" + e); + } + } + + public static void addLogInModeWithCusLog(String url,int code,String requestParam,String responseData,Map cusLogInfo){ + try{ + RecordSet rs = new RecordSet(); + JSONObject loggerJson = new JSONObject(); + loggerJson.put("qqdz",url); + loggerJson.put("qqxx",requestParam); + loggerJson.put("xyxx",responseData); + loggerJson.put("xym",code); + if(cusLogInfo != null && cusLogInfo.size() > 0){ + for(String key : cusLogInfo.keySet()){ + loggerJson.put(key,cusLogInfo.get(cusLogInfo)); + } + } + TjwModelUtil.addModelData(rs,"uf_tjwhttplog",loggerJson); + }catch (Throwable e){ + logger.error("TjwHttpUtil.addLogInMode error;message:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 下载文件 + * @param url + * @param headMap 请求头 + * @param fileName 文件名称 + */ + public static InputStream httpGetDownloadFile(String url,Map headMap,String fileName) { + CloseableHttpClient httpclient = createSSLClientDefault(url); + try { + HttpGet httpGet = new HttpGet(url); + if (headMap != null && headMap.size() > 0) { + Set keySet = headMap.keySet(); + for (String key : keySet) { + httpGet.addHeader(key, headMap.get(key)); + } + } + CloseableHttpResponse response = httpclient.execute(httpGet); + try { + int statusCode = response.getStatusLine().getStatusCode(); + logger.info("url:" + url + ";download file end;code:" + statusCode); + HttpEntity httpEntity = response.getEntity(); + InputStream is = httpEntity.getContent(); + // 根据InputStream 下载文件 + ByteArrayOutputStream output = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int r = 0; + while ((r = is.read(buffer)) > 0) { + output.write(buffer, 0, r); + } + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(output.toByteArray()); + output.flush(); + output.close(); + EntityUtils.consume(httpEntity); + logger.info("url:" + url + ";download file success"); + return byteArrayInputStream; + } finally { + response.close(); + } + } catch (Throwable e) { + logger.error("httpGetDownloadFile exception;message:" + e.getMessage() + ";e:" + e); + } finally { + try { + httpclient.close(); + } catch (Throwable e) { + logger.error("httpGetDownloadFile httpclient close exception;message:" + e.getMessage() + ";e:" + e); + } + } + return null; + } + + public static void oauthOneSignHeader(HttpRequestBase httpRequest,Map oauthConfigMap){ + OauthOneHttpUtil oAuthUtil = new OauthOneHttpUtil(); + oAuthUtil.consumerKey = oauthConfigMap.get("consumerKey"); + oAuthUtil.consumerSecret = oauthConfigMap.get("consumerSecret"); + oAuthUtil.accessToken = oauthConfigMap.get("accessToken"); + oAuthUtil.accessTokenSecret = oauthConfigMap.get("accessTokenSecret"); + oAuthUtil.realmID = oauthConfigMap.get("realmID"); + oAuthUtil.encryption = oauthConfigMap.get("encryption"); + oAuthUtil.authorize(httpRequest); + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpOAuthRequest(String url, String param, String method, ContentType contentType,Map headers,Map oauthConfigMap){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + oauthOneSignHeader(post,oauthConfigMap); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + oauthOneSignHeader(get,oauthConfigMap); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Throwable e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequest(String url, String param, String method, ContentType contentType,Map headers,int imageFileId){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + + if(imageFileId > 0){ + ImageFileManager ifm = new ImageFileManager(); + InputStream is = ifm.getInputStreamById(imageFileId); + ByteArrayEntity byteArrayEntity = new ByteArrayEntity(IOUtils.toByteArray(is)); + post.setEntity(byteArrayEntity); + } + + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + + if(imageFileId > 0){ + ImageFileManager ifm = new ImageFileManager(); + InputStream is = ifm.getInputStreamById(imageFileId); + ByteArrayEntity byteArrayEntity = new ByteArrayEntity(IOUtils.toByteArray(is)); + put.setEntity(byteArrayEntity); + } + + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequestWithCusLog(String url, String param, String method, ContentType contentType,Map headers,Map cusLogInfo){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + JSONObject responseHeaders = new JSONObject(); + Header[] allHeaders = response.getAllHeaders(); + for(Header header:allHeaders){ + responseHeaders.put(header.getName(),header.getValue()); + } + result.put("responseHeaders",responseHeaders.toJSONString()); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("getWithEntity".equalsIgnoreCase(method)){ + HttpGetWithEntity get=new HttpGetWithEntity(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + HttpEntity httpEntity = new StringEntity(param, contentType); + get.setEntity(httpEntity); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + Header[] allHeaders = response.getAllHeaders(); + Header[] clone = allHeaders.clone(); + result.put("responseHeaders",clone); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequest(String url, String param, String method, ContentType contentType,Map headers){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + for(String key : headers.keySet()){ + post.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + JSONObject responseHeaders = new JSONObject(); + Header[] allHeaders = response.getAllHeaders(); + for(Header header:allHeaders){ + responseHeaders.put(header.getName(),header.getValue()); + } + result.put("responseHeaders",responseHeaders.toJSONString()); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("put".equalsIgnoreCase(method)){ + HttpPut put = new HttpPut(url); + for(String key : headers.keySet()){ + put.setHeader(key,headers.get(key)); + } + CloseableHttpResponse response = client.execute(put); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("getWithEntity".equalsIgnoreCase(method)){ + HttpGetWithEntity get=new HttpGetWithEntity(url); + if(headers != null && headers.size() > 0){ + for(String key : headers.keySet()){ + get.setHeader(key,headers.get(key)); + } + } + HttpEntity httpEntity = new StringEntity(param, contentType); + get.setEntity(httpEntity); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + Header[] allHeaders = response.getAllHeaders(); + Header[] clone = allHeaders.clone(); + result.put("responseHeaders",clone); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + /** + * 发送http请求 获取响应 + * @param url + * @param param 请求报文 + * @param method + * @param contentType + * @return 响应报文 + * @throws Exception + */ + public static Map sendHttpRequest(String url, String param, String method, ContentType contentType){ + Map result = new HashMap<>(); + CloseableHttpClient client = createSSLClientDefault(url); + try{ + logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method); + if("post".equalsIgnoreCase(method)){ + HttpPost post=new HttpPost(url); + StringEntity entity = new StringEntity(param, contentType); + //StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + CloseableHttpResponse response = client.execute(post); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + }else if("get".equalsIgnoreCase(method)){ + HttpGet get=new HttpGet(url); + CloseableHttpResponse response = client.execute(get); + int statusCode = response.getStatusLine().getStatusCode(); + HttpEntity en = response.getEntity(); + en = new BufferedHttpEntity(en); + result.put("code", String.valueOf(statusCode)); + result.put("data",EntityUtils.toString(en, "utf-8")); + addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8")); + logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8")); + } + }catch(Exception e){ + logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + }finally { + try { + client.close(); + } catch (IOException e) { + logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e); + throw new RuntimeException(e); + } + } + return result; + } + + + /** + * 返回CloseableHttpClient 如果接口为https协议 信任所有证书 + * @return + * @throws MalformedURLException + */ + public static CloseableHttpClient createSSLClientDefault(String urlString){ + URL url = null; + try { + url = new URL(urlString); + } catch (Exception e) { + logger.error("url error;urlString:" + urlString); + } + String protocol = url.getProtocol(); + if("https".equals(protocol)){ + try { + //使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书 + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { + return true; + } + }).build(); + //NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何 + //有效的SSL会话并匹配到目标主机。 + HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return build; + } catch (Exception e) { + logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e); + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + }else{ + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + } + + private static final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + + private static final HostnameVerifier NOT_VERYFY = new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwJsonToWorkflowByConfigUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwJsonToWorkflowByConfigUtil.java new file mode 100644 index 0000000..14ba1ad --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwJsonToWorkflowByConfigUtil.java @@ -0,0 +1,158 @@ +package weaver.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.webservices.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TjwJsonToWorkflowByConfigUtil { + + static Logger logger = MyLogger.getLogger(); + + + public static String getValueByConfig(Map configMap, JSONObject jsonData, RecordSet rs){ + String result = ""; + try{ + String path = configMap.get("jsonbwzdlj"); + String zhgz = configMap.get("zhgz"); + String zdysql = configMap.get("zdysql"); + String oldValue = CommonUtil.getJsonValueByPath(jsonData,path); + switch(zhgz){ + case "0": + result = oldValue; + break; + case "1": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + }else{ + logger.error("zdysql execute but find nothing;sql:" + zdysql); + } + }else{ + logger.error("zdysql execute error;sql:" + zdysql); + } + break; + case "2": + result = zdysql; + break; + default: + break; + } + }catch(Exception e){ + logger.error("TjwJsonToWorkflowByConfigUtil.getValueByConfig exception;configMap:" + configMap + ";jsonData:" + jsonData + ";message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public static void dealWorkflowRequestInfoByConfigId(String configId, WorkflowRequestInfo info,JSONObject jsonData){ + try{ + logger.info("dealWorkflowRequestInfoByConfigId begin;configId:" + configId + ";jsonData:" + jsonData.toJSONString()); + RecordSet rs = new RecordSet(); + String getConfigDataSql = + "select " + + "t1.lclx," + + "t2.bdzd," + + "t2.zdgz," + + "t2.jsonbwzdlj," + + "t2.zhgz," + + "t2.zdysql," + + "wb.fieldName," + + "wb.viewType," + + "wb.detailtable " + + "from " + + "uf_jsonzlcbdsj t1 " + + "inner join uf_jsonzlcbdsj_dt1 t2 on t2.mainid = t1.id " + + "inner join workflow_billField wb on t2.bdzd = wb.id " + + "where " + + "t1.id = ?"; + List> configData = DaoUtil.getData(rs, getConfigDataSql, configId); + + //主表字段数量 + int mainTableFieldCount = 0; + //主表字段配置信息 + List> mainFieldConfigInfoList = new ArrayList<>(); + //明细表字段配置信息 + Map>> detailFieldConfigInfo = new HashMap<>(); + + for(Map m : configData){ + String zdgz = m.get("zdgz"); + if("".equals(zdgz) || "0".equals(zdgz)){ + mainTableFieldCount = mainTableFieldCount + 1; + mainFieldConfigInfoList.add(m); + }else{ + List> detailFieldConfigInfoList = detailFieldConfigInfo.get(zdgz); + if(detailFieldConfigInfoList == null){ + detailFieldConfigInfoList = new ArrayList<>(); + detailFieldConfigInfoList.add(m); + detailFieldConfigInfo.put(zdgz,detailFieldConfigInfoList); + }else{ + detailFieldConfigInfoList.add(m); + } + } + } + + ////////////处理主表字段 + WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[mainTableFieldCount]; + for(int i = 0; i < mainTableFieldCount; i ++){ + String fieldName = mainFieldConfigInfoList.get(i).get("fieldName"); + String value = getValueByConfig(mainFieldConfigInfoList.get(i),jsonData,rs); + wrti[i]=new WorkflowRequestTableField(); + wrti[i].setFieldName(fieldName); + wrti[i].setFieldValue(value); + wrti[i].setEdit(true);//是否能编辑 + wrti[i].setView(true);//是否可以查看 + wrti[i].setMand(false);//是否必填 + } + + WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据 + tablre[0]=new WorkflowRequestTableRecord(); + tablre[0].setWorkflowRequestTableFields(wrti); + WorkflowMainTableInfo maininfo=new WorkflowMainTableInfo(); + maininfo.setRequestRecords(tablre); + info.setWorkflowMainTableInfo(maininfo); + + /////////////处理明细表字段 + WorkflowDetailTableInfo[] WorkflowDetailTableInfo = new WorkflowDetailTableInfo[detailFieldConfigInfo.size()]; + for(int i = 0;i> detailFieldConfigInfoList = detailFieldConfigInfo.get(i); + //根据path查询有多少行明细 + String path = detailFieldConfigInfoList.get(0).get("jsonbwzdlj"); + path = path.substring(0,path.lastIndexOf("/")); + JSONArray array = CommonUtil.getJsonArrayByPath(jsonData,path); + if(array == null || array.size() == 0){ + continue; + } + WorkflowRequestTableRecord[] tablre1 = new WorkflowRequestTableRecord[array.size()]; + for(int j = 0;j< array.size();j++){ + wrti = new WorkflowRequestTableField[detailFieldConfigInfoList.size()]; + for(int k = 0;j keyList){ + try{ + //根据dataKey判断数据是否存在,有则更新 无则新增 + String idWhere = " 1 = 1 "; + Object[] keyData = new Object[keyList.size()]; + for(int i = 0;i < keyList.size(); i++){ + keyData[i] = dataInfo.get(keyList.get(i)); + } + for(String key:keyList){ + idWhere = idWhere + " and " + key + " = ?"; + } + + String getDataSql = "select id from " + tableName + " where " + idWhere; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, keyData); + String id = firstData.get("id"); + if("".equals(id) || id == null){ + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs); + int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime); + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = newDataId; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId); + return newDataId; + }else{ + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = id; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + return Integer.parseInt(id); + } + }catch(Exception e){ + logger.error("TjwModelUtil addOrUpdateModelData;tableName:" + tableName + ";dataInfo:" + dataInfo + ";messahe:" + e.getMessage() + ";e:" + e); + return -1; + } + } + + /** + * 新增或更新建模数据 + */ + public static int addOrUpdateModelData(RecordSet rs, String tableName, JSONObject dataInfo,String dataKey){ + try{ + //根据dataKey判断数据是否存在,有则更新 无则新增 + String getDataSql = "select id from " + tableName + " where " + dataKey + " = ?"; + Map firstData = DaoUtil.getFirstData(rs, getDataSql, dataInfo.get(dataKey)); + String id = firstData.get("id"); + if("".equals(id) || id == null){ + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs); + int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime); + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = newDataId; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId); + return newDataId; + }else{ + //拼接字段名称 + String setString = ""; + Object[] data = new Object[dataInfo.size()+1]; + int index = 0; + for(Object key : dataInfo.keySet()){ + setString = setString + key + " = ? ,"; + data[index] = dataInfo.get(key); + index++; + } + data[index] = id; + setString = setString.substring(0,setString.length() - 1); + String updateDataSql = + "update " + tableName + " set " + setString + " where id = ?"; + DaoUtil.updateData(rs,updateDataSql,data); + return Integer.parseInt(id); + } + }catch(Exception e){ + logger.error("TjwModelUtil addOrUpdateModelData;tableName:" + tableName + ";dataInfo:" + dataInfo + ";messahe:" + e.getMessage() + ";e:" + e); + return -1; + } + } + +} \ No newline at end of file diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwTimeUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwTimeUtil.java new file mode 100644 index 0000000..4de9884 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwTimeUtil.java @@ -0,0 +1,38 @@ +package weaver.taojw.common; + +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class TjwTimeUtil { + + static Logger logger = MyLogger.getLogger(); + static SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + /** + * 将时间戳转换为固定格式 + * @param format 日期格式 + * @param time 时间戳 毫秒 + * @return + */ + public static String getFormatTimeByTimeMillis(String format, long time){ + try{ + String result = ""; + Date date= new Date(time); + switch (format){ + case "yyyy-MM-dd HH:mm:ss": + result = sdfDateAndTime.format(date); + break; + default: + break; + } + return result; + }catch(Exception e){ + logger.error("CommonUtil.getFormatTimeByTimeMillis execute error;exception:" + e.getMessage() + ";e:" + e); + return ""; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwWorkFlowUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwWorkFlowUtil.java new file mode 100644 index 0000000..5e8a213 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TjwWorkFlowUtil.java @@ -0,0 +1,176 @@ +package weaver.taojw.common; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.formmode.interfaces.action.WorkflowToMode; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.soa.workflow.request.RequestService; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.request.RequestManager; +import weaver.workflow.webservices.*; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +public class TjwWorkFlowUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String createWorkFlow(String requestName, String creator, String workFlowId, String isNextFlow, Map mainTableData, List>> detailTableData){ + try{ + logger.info("TjwWorkFlowUtil.createWorkFlow begin;requestName:" + requestName); + WorkflowService service = new WorkflowServiceImpl(); + WorkflowRequestInfo info = new WorkflowRequestInfo(); + info.setRequestName(requestName); + //创建人 + info.setCreatorId(creator); + //0正常,1重要,2紧急 + info.setRequestLevel("0"); + WorkflowBaseInfo base = new WorkflowBaseInfo(); + //流程id + RecordSet rs = new RecordSet(); + base.setWorkflowId(workFlowId); + info.setWorkflowBaseInfo(base); + //流转到下一个节点 + info.setIsnextflow(isNextFlow); + + WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[mainTableData.size()]; + int i = 0; + for(String key : mainTableData.keySet()){ + wrti[i]=new WorkflowRequestTableField(); + wrti[i].setFieldName(key); + wrti[i].setFieldValue(mainTableData.get(key)); + wrti[i].setEdit(true);//是否能编辑 + wrti[i].setView(true);//是否可以查看 + wrti[i].setMand(true);//是否必填 + i = i + 1; + } + + WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据 + tablre[0]=new WorkflowRequestTableRecord(); + tablre[0].setWorkflowRequestTableFields(wrti); + WorkflowMainTableInfo mainInfo=new WorkflowMainTableInfo(); + mainInfo.setRequestRecords(tablre); + //添加主字段数据 + info.setWorkflowMainTableInfo(mainInfo); + + //添加到明细表中 + if(detailTableData != null && detailTableData.size() > 0){ + WorkflowDetailTableInfo WorkflowDetailTableInfo[] = new WorkflowDetailTableInfo[detailTableData.size()]; + for(int j = 0; j> tableData = detailTableData.get(j); + if(tableData != null && tableData.size() > 0){ + WorkflowRequestTableRecord[] detailTablre = new WorkflowRequestTableRecord[tableData.size()]; + for(int m = 0;m < tableData.size();m ++){ + Map datas = tableData.get(m); + WorkflowRequestTableField[] d = new WorkflowRequestTableField[datas.size()]; + int n = 0; + for(String key : datas.keySet()){ + d[n] = new WorkflowRequestTableField(); + d[n].setFieldName(key); + d[n].setFieldValue(datas.get(key)); + d[n].setView(true);//字段是否可见 + d[n].setEdit(true);//字段是否可编辑 + } + detailTablre[n] = new WorkflowRequestTableRecord(); + detailTablre[n].setWorkflowRequestTableFields(d); + } + WorkflowDetailTableInfo[j] = new WorkflowDetailTableInfo(); + WorkflowDetailTableInfo[j].setWorkflowRequestTableRecords(detailTablre); + } + } + info.setWorkflowDetailTableInfos(WorkflowDetailTableInfo);//添加明细数据 + } + //发起流程 + String returnMsg = service.doCreateWorkflowRequest(info, Integer.parseInt(creator)); + logger.info("TjwWorkFlowUtil.createWorkFlow end;returnMsg:" + returnMsg); + return returnMsg; + }catch (Throwable e){ + logger.error("TjwWorkFlowUtil.createWorkFlow error;requestName:" + requestName); + return ""; + } + + } + + + /** + * 提交流程至下一节点 + * @param requestId + * @param userId + */ + public static boolean submitWorkFlow(int requestId,int userId){ + try{ + WorkflowService service = new WorkflowServiceImpl(); + String message = service.submitWorkflowRequest(null, requestId, userId,"submit",""); + if("success".equals(message)){ + return true; + }else{ + logger.error("TjwWorkFlowUtil.submitWorkFlow false;requestId:" + requestId + ";userId:" + userId + ";message:" + message); + return false; + } + }catch (Exception e){ + logger.error("TjwWorkFlowUtil.submitWorkFlow exception;requestId:" + requestId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e); + return false; + } + } + + /** + * 触发流程转数据 + * @param requestId 流程请求id + * @param configId 流程转数据的配置id + * @param rs 数据库连接 + * @return 1-成功; + */ + public static String doWorkFlowToMode(int requestId,int configId,RecordSet rs){ + try{ + if(rs == null){ + rs = new RecordSet(); + } + //获取流程转数据的配置信息 + String getWorkFlowToModeSetInfoSql = "select triggernodeid,actionid from mode_workflowtomodeset where id = ?"; + Map configInfo = DaoUtil.getFirstData(rs,getWorkFlowToModeSetInfoSql,configId); + int nodeId = Integer.parseInt(configInfo.get("triggernodeid")); + int actionId = Integer.parseInt(configInfo.get("actionid")); + //获取流程基本信息 + String getRequestBaseInfoSql = "select t1.workflowid,t2.formid,t1.creater,t1.requestname from workflow_requestbase t1 inner join workflow_base t2 on t2.id = t1.workflowid where t1.requestid = ?"; + Map requestBaseInfo = DaoUtil.getFirstData(rs,getRequestBaseInfoSql,requestId); + int workFlowId = Integer.parseInt(requestBaseInfo.get("workflowid")); + int formId = Integer.parseInt(requestBaseInfo.get("formid")); + int creater = Integer.parseInt(requestBaseInfo.get("creater")); + User user = new User(creater); + String requestName = requestBaseInfo.get("requestname"); + //构造请求参数 + RequestService x = new RequestService(); + RequestInfo requestInfo = x.getRequest(requestId); + //只记录日志 triggerType + requestInfo.setIspreadd("0"); + RequestManager requestManager = new RequestManager(); + requestManager.setNodeid(nodeId); + //只记录日志 + requestManager.setNextNodeid(0); + requestManager.setWorkflowid(workFlowId); + requestManager.setFormid(formId); + requestManager.setRequestid(requestId); + requestManager.setCreater(creater); + //用于区分流程类型 + requestManager.setIsbill(1); + requestManager.setUser(user); + requestManager.setRequestname(requestName); + requestInfo.setRequestManager(requestManager); + WorkflowToMode wtm = new WorkflowToMode(); + Class classType = WorkflowToMode.class; + Field field = classType.getDeclaredField("actionid"); + field.setAccessible(true); + field.set(wtm, actionId); + String result = wtm.execute(requestInfo); + logger.info("doWorkFlowToMode done;requestId:" + requestId + ";configId:" + configId + ";result:" + result); + return result; + }catch(Exception e){ + logger.error("doWorkFlowToMode exception;requestId:" + requestId + ";configId:" + configId + ";messahe:" + e.getMessage() + ";e:" + e); + return "error"; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/ToolUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/ToolUtil.java new file mode 100644 index 0000000..7bcb068 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/ToolUtil.java @@ -0,0 +1,403 @@ +package weaver.taojw.common; + +import org.apache.log4j.Logger; +import weaver.conn.ConnStatementDataSource; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.GCONST; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import java.io.*; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +/** + * 常用工具方法-公用类 + * @author bleach + * @date 2018-01-18 + * @version 2.0 Modify By Weilin.Zhu 添加日志级别 2018-12-05 + * @version 3.0 Modify By Weilin.Zhu 修改日志输出方式,使用log4j 2020-03-10 + * @version 4.0 Modify By Weilin.Zhu 去除根据建模配置来控制日志输出功能 2021-06-29 + */ +public class ToolUtil extends BaseBean { + + Logger logger = MyLogger.getLogger(); + + + private RecordSet rs = new RecordSet(); + + + /** + * 构造方法 + */ + public ToolUtil() { + //logger = LoggerFactory.getLogger("cus"); + } + + /** + * 根据流程类型ID获取其对应的表单名称 + * @param workflowid 流程类型ID + * @return 字符串 + */ + public String getBillTableNameByWorkflowId(String workflowid){ + String tablename = ""; + + if(!"".equals(workflowid)){ + String select_data = "select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)"; + + if(rs.executeQuery(select_data, workflowid)){ + if(rs.next()){ + tablename = Util.null2String(rs.getString(1)); + } + } + } + + return tablename; + } + + /** + * 查询满足模糊查询的所有标识集合 + * @param likestr 模糊条件 + * @return + */ + public Map getSystemParamValueMap(String likestr){ + return getSystemParamList(likestr); + } + + /** + * 查询系统中所有参数配置 + * @return + */ + public Map getAllSystemParamValue(){ + return getSystemParamList(""); + } + + + /** + * 获取参数集合 + * @param likestr 模糊查询的条件 + * @return 集合 + */ + private Map getSystemParamList(String likestr){ + Map param_map = new HashMap(); + + String select_sql = "select uuid,paramvalue from uf_systemconfig"; + + RecordSet rs = new RecordSet(); + + if(!"".equals(likestr)){ + select_sql += " where uuid like '%" + likestr + "%'"; + } + + if(rs.execute(select_sql)){ + while(rs.next()){ + String uuid = Util.null2String(rs.getString(1)); + String paramvalue = Util.null2String(rs.getString(2)); + param_map.put(uuid, paramvalue); + } + } + + return param_map; + + } + + /** + * 获取系统参数设置值 + * @param uuid 参数标识 + * @return 返回配置值 + */ + public static String getSystemParamValue(String uuid){ + String paramvalue = ""; + + if(!"".equals(uuid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,uuid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @return 配置值 + */ + public String getValueByChangeRule(String userId,String cus_sql,String value){ + + return getValueByChangeRule(userId,cus_sql,value,""); + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @param requestid 流程请求ID + * @return + */ + public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid){ + + return getValueByChangeRule(userId,cus_sql,value,requestid,0); + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @param requestid 流程请求ID + * @param detailKeyvalue 明细表主键值 + * @return + */ + public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid,int detailKeyvalue){ + return getValueByChangeRule(userId,cus_sql,value,requestid,detailKeyvalue,null); + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @param requestid 流程请求ID + * @param detailKeyvalue 明细表主键值 + * @pram datasourceid 外部数据源ID + * @return + */ + public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid,int detailKeyvalue,String datasourceid){ + String endValue = ""; + cus_sql = ToDBC(cus_sql); + + cus_sql = cus_sql.replace(" ", " "); + + cus_sql = cus_sql.replace("{?dt.id}", String.valueOf(detailKeyvalue)); + + cus_sql = cus_sql.replace("{?currentUserId}", String.valueOf(userId)); + + //参数进行替换 + String sqlString = cus_sql.replace("{?requestid}", requestid); + + sqlString = sqlString.replace("?", value); + + try { + if(datasourceid != null && !"".equals(datasourceid)){ + ConnStatementDataSource csds = new ConnStatementDataSource(datasourceid); + + csds.setStatementSql(sqlString); + + csds.executeQuery(); + + if(csds.next()){ + endValue = Util.null2String(csds.getString(1)); + } + + csds.close(); + }else{ + + RecordSet rs = new RecordSet(); + if(rs.executeQuery(sqlString)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return endValue; + } + + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的SQL + * @param value 参数值 + * @return + */ + public String getValueByChangeRule_SingleParam(String cus_sql,String value){ + String endValue = ""; + + cus_sql = cus_sql.replace(" ", " "); + + RecordSet rs = new RecordSet(); + + if(rs.executeQuery(cus_sql,value)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + + return endValue; + } + + /** + * 全角转半角 + * @param input + * @return + */ + public static String ToDBC(String input) { + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + return returnString; + } + + /** + * 根据字段ID获取其对应的字段名称 + * @param fieldid + * @return + */ + public String getFieldNameByFieldid(int fieldid){ + if(fieldid > 0){ + return getFieldNameByFieldid(String.valueOf(fieldid)); + }else{ + return ""; + } + } + + /** + * 根据字段ID获取其对应的字段名称 + * @param fieldid + * @return + */ + public String getFieldNameByFieldid(String fieldid){ + String fieldname = ""; + + if(!"".equals(fieldid)){ + + if(fieldid.startsWith(",")){ + fieldid = fieldid.substring(1); + } + + if(fieldid.endsWith(",")){ + fieldid =fieldid.substring(0,fieldid.length() - 1); + } + + String select_sql = "select fieldname from workflow_billfield where id in (" + fieldid + ")"; + + RecordSet rs = new RecordSet(); + + if(rs.execute(select_sql)){ + while(rs.next()){ + + fieldname += "," + Util.null2String(rs.getString(1)); + } + } + } + + if(fieldname.startsWith(",")){ + fieldname = fieldname.substring(1); + } + + return fieldname; + } + + /** + * 输出调试日志 + * @param className 类名称 + * @param logstr 日志信息 + */ + public void writeDebuggerLog(String className,String logstr){ + logger.info(logstr); + } + + /** + * 输出警告日志 + * @param className 类名称 + * @param logstr 日志信息 + */ + public void writeWarningLog(String className,String logstr){ + logger.warn(logstr); + } + + /** + * 输出错误日志 + * @param className 类名称 + * @param logstr 日志信息 + */ + public void writeErrorLog(String className,String logstr){ + logger.error(logstr); + } + + + /** + * 日志输出 + * @param logstr + */ + public void writeDebugLog(Object logstr){ + logger.info(logstr); + } + + /** + * 日志输出 + * @param logstr + */ + public void writeErrorLog(Object logstr){ + logger.error(logstr); + } + + /** + * 日志输出 + * @param logstr + */ + public void writeNewDebuggerLog(Object o,Object logstr){ + logger.info(logstr); + } + + /** + * 写入同步的日志文件 + * @param o + * @param s + * @deprecated 该写入文件的日志输出方式删除 + */ + protected void writeNewLog(String o,String s){ + try { + String filename = "cus_" + TimeUtil.getCurrentDateString() + "_ecology.log"; + + + String folder = GCONST.getRootPath() + "log" + File.separatorChar + "cus"; + + //this.writeDebugLog("folder:[" + folder + "]"); + + File f = new File(folder); + + // 创建文件夹 + if (!f.exists()) { + f.mkdirs(); + } + + f = new File(folder + File.separatorChar + filename); + //文件不存在,则直接创建 + if(!f.exists()){ + f.createNewFile(); + } + + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true))); + + out.write("[" + o + "][" + TimeUtil.getCurrentTimeString() + "]:"+ s + "\r\n"); + + //关闭写入流 + out.close(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + writeDebugLog("创建日志文件存在异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/TwoDimensionalCodeUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/TwoDimensionalCodeUtil.java new file mode 100644 index 0000000..588c629 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/TwoDimensionalCodeUtil.java @@ -0,0 +1,66 @@ +package weaver.taojw.common; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.common.BitMatrix; +import org.apache.log4j.Logger; +import weaver.taojw.common.logging.MyLogger; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class TwoDimensionalCodeUtil { + + private static final int BLACK = 0xFF000000; + private static final int WHITE = 0xFFFFFFFF; + + static Logger logger = MyLogger.getLogger(); + + /** + * 在指定位置生成二维码图片 + * @param content 二维码内容;eg:https://www.baidu.com + * @param path 生成的图片路径;eg:F:/测试 + * @param codeName 生成的图片名称;eg:UUID.randomUUID().toString() + * @param imageType 生成的图片类型;eg:jpg + */ + public static void getImage(String content,String path,String codeName,String imageType) { + try { + MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); + Map hints = new HashMap<>(); + hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); + BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints); + File file = new File(path, codeName + "." + imageType); + writeToFile(bitMatrix, imageType, file); + } catch (Exception e) { + logger.error("TwoDimensionalCodeUtil.getImage exception;content:" + content + "message:" + e.getMessage() + ";e:" + e); + } + } + + public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException { + BufferedImage image = toBufferedImage(matrix); + if (!ImageIO.write(image, format, file)) { + throw new IOException("Could not write an image of format " + format + " to " + file); + } + } + + public static BufferedImage toBufferedImage(BitMatrix matrix) { + int width = matrix.getWidth(); + int height = matrix.getHeight(); + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE); + } + } + return image; + } + + + + + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/WorkFlowDataToJsonUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/WorkFlowDataToJsonUtil.java new file mode 100644 index 0000000..5b3e435 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/WorkFlowDataToJsonUtil.java @@ -0,0 +1,435 @@ +package weaver.taojw.common; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import java.text.SimpleDateFormat; +import java.util.*; + +public class WorkFlowDataToJsonUtil { + + static Logger logger = MyLogger.getLogger(); + + public static String[] getRequestBaseInfo(String requestId,RecordSetTrans rsts,String requestMark,String billTableName){ + //--------------------------------------基于文件发起签署 + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId); + if(firstData.size() > 0){ + base_array[4] = firstData.get("id"); + } + return base_array; + } catch (Throwable e) { + logger.error("WorkFlowDataToJsonUtil getRequestBaseInfo error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return null; + } + } + + + /** + * 根据转换规则 获取转换后的数据 + */ + public static String convertDataByZhgz(String oldValue,Map configMap){ + //函数返回值 + String result = ""; + try{ + //转换规则 + String zhgz = configMap.get("zhgz"); + //自定义sql + String zdysql = configMap.get("zdysql"); + String requestId = Util.null2String(configMap.get("requestId")); + //不同转换规则处理 + switch(zhgz){ + //不转换 + case "0": + result = oldValue; + break; + //固定值 + case "1": + result = zdysql; + break; + //自定义sql + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId); + Map firstData = DaoUtil.getFirstData(zdysql); + for(String key : firstData.keySet()){ + result = firstData.get(key); + } + break; + //日期格式化 + case "3": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd").parse(oldValue)); + break; + //日期时间格式化 + case "4": + result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(oldValue)); + break; + //当前日期 + case "5": + result = new SimpleDateFormat(zdysql).format(new Date()); + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.convertDataByZhgz error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public static JSONObject getJsonByWorkFlowData(String requestId,String configId,String[] base_array){ + JSONObject result = new JSONObject(); + try{ + logger.info("WorkFlowDataToJsonUtil.getJsonByWorkFlowData begin;requestId:" + requestId + ";configId:" + configId); + RecordSet rs = new RecordSet(); + //-----------------------根据配置id获取配置信息 + //根节点配置信息 + List> rootJsonConfigInfo = new ArrayList<>(); + //明细配置信息 + List> requestBodyConfigList = new ArrayList<>(); + getConfigInfo(rs,configId,requestBodyConfigList,rootJsonConfigInfo); + //-----------------------获取主表数据 用于拼装json + Map mainTableData = new HashMap<>(); + String getMainTableDataSql = "select * from " + base_array[3] + " where id = " + base_array[4]; + if(rs.executeQuery(getMainTableDataSql)) { + if (rs.next()) { + mainTableData = DaoUtil.setRsToMap(rs); + } + } + //-----------------------生成json + logger.info("recursionGenerateJson begin;"); + recursionGenerateJson(null,rs,rs,0,result,rootJsonConfigInfo,base_array,mainTableData,requestBodyConfigList); + }catch(Throwable e){ + logger.error("WorkFlowDataToJsonUtil.getJsonByWorkFlowData exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + /** + * 根据configId获取配置信息 + * @param rs 数据库链接 + * @param configId 配置id + * @param requestBodyConfigList 明细配置 + * @param rootJsonConfigInfo 根节点配置 + */ + public static void getConfigInfo(RecordSet rs,String configId,List> requestBodyConfigList,List> rootJsonConfigInfo){ + //获取明细表 请求体字段详细配置信息 + String selectDetailSQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from uf_lcsjzjson_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetailSQL,configId)){ + while(rs.next()){ + //节点序号 + String xmljdxh = Util.null2String(rs.getString("jdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("jdmc")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("jdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char); + sjtj = sjtj.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char); + sjtj = CommonUtil.fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("jdxh",xmljdxh); + dtMap.put("jdmc",xmljdmc); + dtMap.put("jdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("zdgz",zdgz); + dtMap.put("detailtable",detailtable); + dtMap.put("fieldName",fieldName.toLowerCase()); + if("".equals(fjdxh)){ + rootJsonConfigInfo.add(dtMap); + } + requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL sql execute error;sql:" + selectDetailSQL); + } + logger.info("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL done;requestBodyConfigList:" + requestBodyConfigList); + } + + + /** + * 递归生成json报文 + */ + public static Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence,JSONObject jsonDoc, + List> rootJsonConfigInfo, + String[] baseArray,Map mainTableData, + List> requestBodyConfigList){ + if(configMap == null){ + for(Map configInfo:rootJsonConfigInfo){ + jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + }else{ + switch(configMap.get("jdlx")){ + case Constant.NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + return getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + case Constant.NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + return "true".equals(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + case Constant.NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case Constant.NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + d = Double.parseDouble(f); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case Constant.NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return json; + case Constant.NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("jdxh"))) { + jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return jsonObj.toString(); + case Constant.NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData); + JSONArray stringArray = new JSONArray(); + stringArray.addAll(Arrays.asList(stringArrayValue.split(","))); + return stringArray; + case Constant.NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && Constant.CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh"))) { + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh")) && !"自定义对象".equals(son.get("jdmc"))) { + o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + } + } + array.add(o); + } + } + for(Map son : requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("jdxh")) && "自定义对象".equals(son.get("jdmc")) && Constant.NODE_TYPE_OBJECT.equals(son.get("jdlx"))) { + logger.info("begin iii"); + array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList)); + logger.info("end iii"); + } + } + return array; + default: + break; + } + } + return null; + } + + + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + */ + public static String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs,String[] baseArray,Map mainTableData){ + //函数返回值 + StringBuilder result = new StringBuilder(); + try{ + Map detailDataMap = DaoUtil.setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //数据条件 + String sjtj = configMap.get("sjtj"); + //字段所属明细表表名 + String detailtable = configMap.get("detailtable"); + //不同转换规则处理 + switch(zhgz){ + case Constant.CHANGE_TYPE_REQUEST_ID: + result = new StringBuilder(baseArray[0]); + break; + case Constant.CHANGE_TYPE_REQUEST_NAME: + result = new StringBuilder(baseArray[1]); + break; + case Constant.CHANGE_TYPE_MD5: + result = new StringBuilder("Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes())); + break; + case Constant.CHANGE_TYPE_SUGGESTION: + result = new StringBuilder(baseArray[2]); + break; + case Constant.CHANGE_TYPE_ROW_NUMBER: + result = new StringBuilder(configMap.get("detailRowNum")); + break; + case Constant.CHANGE_TYPE_FIXED: + result = new StringBuilder(configMap.get("zdysql")); + break; + case Constant.CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = new StringBuilder(mainTableData.get(fieldName)); + }else{ + result = new StringBuilder(detailDataMap.get(fieldName)); + } + break; + case Constant.CHANGE_TYPE_SQL: + String oldValue; + if(!"".equals(viewType) && !"".equals(fieldName)){ + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + } + zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + } + } + break; + case Constant.CHANGE_TYPE_SUM: + if("0".equals(viewType)){ + logger.error("want sum but config main field"); + break; + } + String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getSumSql = getSumSql + " " + sjtj; + } + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = new StringBuilder(Util.null2String(rs.getString("val"))); + } + } + break; + case Constant.CHANGE_TYPE_STRING_ARRAY: + if("0".equals(viewType)){ + logger.error("want array but config main field"); + break; + } + String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getArraySql = getArraySql + " " + sjtj; + } + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = new StringBuilder(Util.null2String(rs.getString(1))); + }else{ + result.append(",").append(Util.null2String(rs.getString(1))); + } + i = i + 1; + } + } + break; + default: + result = new StringBuilder(); + break; + } + return result.toString(); + }catch(Exception e){ + result = new StringBuilder(); + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result.toString(); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java new file mode 100644 index 0000000..68fa61b --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java @@ -0,0 +1,106 @@ +package weaver.taojw.common.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.taojw.common.action.util.CallApiByWorkFlowDataUtil; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; +import java.util.Map; + +/** + * taojingwei @2022-05-26 + * 1、获取建模配置,将流程数据封装成需要的请求报文 + * 2、调用http接口传输报文信息,获取接口返回信息 + */ +public class RequestDataToApiAction implements Action { + + //自定义参数值 + private String cusParam = ""; + + Logger logger = MyLogger.getLogger(); + + /** + * 实现父类方法 + * 具体的业务实现 + * @param requestInfo 流程请求信息 + * @return 流程是否允许提交标识 + */ + @Override + public String execute(RequestInfo requestInfo) { + //流程请求ID + String requestId = ""; + try { + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + //流程请求ID + requestId = requestInfo.getRequestid(); + //流程类型ID + String workflowId = requestInfo.getWorkflowid(); + //流程表单名称 + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = ""; + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + requestMark = Util.null2String(rsts.getString("requestMark")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + logger.info("requestName:[" + requestName + "],requestMark:[" + requestMark + "],workflowId:["+workflowId+"],requestId:[" + requestId + "],billTableName:[" + billTableName + "],cusParam[" + cusParam + "]"); + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + //获取当前流程信息 + String selectData = "select * from " + billTableName + " where requestId = ?"; + RecordSet rs = new RecordSet(); + if(rs.executeQuery(selectData,requestId)){ + rs.next(); + base_array[4] = Util.null2String(rs.getString("id")); + } + + CallApiByWorkFlowDataUtil callApiByWorkFlowDataUtil = new CallApiByWorkFlowDataUtil(); + callApiByWorkFlowDataUtil.setBaseArray(base_array); + callApiByWorkFlowDataUtil.setRsts(rsts); + Map result = callApiByWorkFlowDataUtil.execute(workflowId, cusParam); + if("CALL_FAILED".equals(result.get("code"))){ + requestInfo.getRequestManager().setMessageid("2022052791402"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",接口响应:" + result.get("message")); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + }catch (Throwable e) { + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString()+requestId); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +";" + "请联系管理员TJW!异常信息:" + e.getMessage()); + logger.error("Action Exception;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + + public String getCusParam() { + return cusParam; + } + + public void setCusParam(String cusParam) { + this.cusParam = cusParam; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/constant/Constant.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/constant/Constant.java new file mode 100644 index 0000000..3bc4fd0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/constant/Constant.java @@ -0,0 +1,107 @@ +package weaver.taojw.common.action.constant; + + +/** + * 一些静态常量定义 + */ +public class Constant { + + //action接口调用配置表名称 + public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd"; + //action调用接口日志记录表表名 + public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd"; + //action调用接口日志记录表requestId字段名称 + public static String LOG_REQUESTID_COLUMN = "lcrequestid"; + //action调用接口日志记录表请求正文字段名称 + public static String LOG_REQUEST_COLUMN = "qqbw"; + //action调用接口日志记录表响应文字段名称 + public static String LOG_RESPONSE_COLUMN = "xybw"; + //action调用接口日志记录表响应码字段名称 + public static String LOG_RESPONSECODE_COLUMN = "xym"; + //action调用接口日志记录表请求地址字段名称 + public static String LOG_REQUESTURL_COLUMN = "qqdz"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUESTHEADER_COLUMN = "qqt"; + + //------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志 + public static final String PARAM_BEGIN = "{"; + public static final String PARAM_END = "}"; + + //------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功 + public static final String CALL_SUCCESS = "1"; + public static final String CALL_FAILED = "0"; + + //------------------------------------------------------------------------------选择框 0-否 1-是 + public static final String SELECT_TYPE_IS = "1"; + public static final String SELECT_TYPE_NOT = "0"; + + //------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次 + public static final String CALL_TYPE_ONLY_ONE = "0"; + public static final String CALL_TYPE_EVERY_DETAIL = "1"; + + //------------------------------------------------------------------------------接口请求类型 0-get 1-post + //GET + public static final String REQUEST_METHOD_GET = "0"; + //POST + public static final String REQUEST_METHOD_POST = "1"; + + //------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对 + //xml + public static final String REQUEST_DATA_TYPE_XML = "0"; + //json + public static final String REQUEST_DATA_TYPE_JSON = "1"; + //键值对 + public static final String REQUEST_DATA_TYPE_PAIR = "2"; + //MultipartFile + public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3"; + + //------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json + //xml + public static final String RESPONSE_DATA_TYPE_XML = "0"; + //json + public static final String RESPONSE_DATA_TYPE_JSON = "1"; + + //------------------------------------------------------------------------------节点类型 + //文本 + public static final String NODE_TYPE_STRING = "0"; + //对象 + public static final String NODE_TYPE_OBJECT = "1"; + //文本数组 + public static final String NODE_TYPE_STRING_ARRAY = "2"; + //数组 + public static final String NODE_TYPE_ARRAY = "3"; + //json对象字符串 + public static final String NODE_TYPE_JSONSTRING = "4"; + //数字 + public static final String NODE_TYPE_NUMBER = "5"; + //布尔 + public static final String NODE_TYPE_BOOLEAN = "6"; + //浮点数 + public static final String NODE_TYPE_FLOAT = "7"; + + //------------------------------------------------------------------------------转换规则 + //不转换 + public static final String CHANGE_TYPE_NONE = "0"; + //固定值 + public static final String CHANGE_TYPE_FIXED = "1"; + //自定义sql + public static final String CHANGE_TYPE_SQL = "2"; + //字段求和 + public static final String CHANGE_TYPE_SUM = "3"; + //文本数组 + public static final String CHANGE_TYPE_STRING_ARRAY = "4"; + //明细序号 + public static final String CHANGE_TYPE_ROW_NUMBER = "5"; + //流程审批意见 + public static final String CHANGE_TYPE_SUGGESTION = "6"; + //加密处理 + public static final String CHANGE_TYPE_MD5 = "7"; + + //------------------------------------------------------------------------------sql转义 + //默认换行符 + public static final String Default_Line_Break = "
"; + //默认空格HTML代码 + public static final String Default_Html_Blank = " "; + //默认空格字符 + public static final String Default_Blank_Char = " "; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/entity/ConfigInfoEntity.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/entity/ConfigInfoEntity.java new file mode 100644 index 0000000..bc28fe8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/entity/ConfigInfoEntity.java @@ -0,0 +1,54 @@ +package weaver.taojw.common.action.entity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ConfigInfoEntity { + + //接口调用类型 0-仅调用一次 1-每条明细调用一次 + public String callType; + //请求方式 0-get 1-post + public String requestMethod; + //失败是否阻止流程提交 + public String failedAndReturn; + //明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口 + public String detailTableIndex; + //数据条件 + public String sqlCondition; + //接口报文类型 0-xml 1-json 2-键值对 + public String requestDataType; + //响应报文类型 0-xml 1-json + public String responseDataType; + //接口地址 + public String callAddress; + //日志记录表名称 + public String logTableName; + //日志记录表requestid字段名称 + public String logRequestIdFieldName; + //日志记录表接口地址字段名称 + public String logRequestUrlFieldName; + //日志记录表请求头字段名称 + public String logRequestHeaderFieldName; + //日志记录表请求报文字段名称 + public String logRequestBodyFieldName; + //日志记录表响应报文字段名称 + public String logResponseBodyFieldName; + //日志记录表响应码字段名称 + public String logResponseStatusFieldName; + //接口地址参数配置详情 + public List> requestAddressConfigList = new ArrayList<>(); + //请求头参数配置详情 + public List> requestHeaderConfigList = new ArrayList<>(); + //请求体字段详细配置 + public List> requestBodyConfigList = new ArrayList<>(); + //xml节点属性详细配置 + public List> xmlNodeAttrConfigList = new ArrayList<>(); + //响应信息详细配置 + public List> responseConfigList = new ArrayList<>(); + + //json请求报文根节点配置信息 + public List> rootJsonConfigInfo = new ArrayList<>(); + //xml请求报文根节点配置信息 + public Map rootXmlConfigInfo; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/entity/RequestAndResponseInfoEntity.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/entity/RequestAndResponseInfoEntity.java new file mode 100644 index 0000000..e94aa79 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/entity/RequestAndResponseInfoEntity.java @@ -0,0 +1,40 @@ +package weaver.taojw.common.action.entity; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.message.BasicNameValuePair; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RequestAndResponseInfoEntity { + + //请求头参数 + public Map headers = new HashMap<>(); + //生成的xml请求报文对象 + public Document xmlDoc = DocumentHelper.createDocument(); + //生成的json请求报文对象 + public JSONObject jsonDoc = new JSONObject(); + //生成的键值对参数 + public List pairList = new ArrayList<>(); + //文件信息参数 + public List> multiPartFileInfos = new ArrayList<>(); + //接口响应信息 + public CloseableHttpResponse response; + //接口响应体 + public String responseString; + //接口响应码 + public int responseCode; + //JSON类型响应体 + public JSONObject responseJson; + //XML类型响应体 + public Document responseXml; + //响应的成功失败标识值 + public String resultValue = ""; + //接口调用提示信息 + public String responseMessage = ""; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/util/CallApiByWorkFlowDataUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/util/CallApiByWorkFlowDataUtil.java new file mode 100644 index 0000000..a5a9efc --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/util/CallApiByWorkFlowDataUtil.java @@ -0,0 +1,1280 @@ +package weaver.taojw.common.action.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.action.entity.ConfigInfoEntity; +import weaver.file.ImageFileManager; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.taojw.common.action.entity.RequestAndResponseInfoEntity; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.workflow.WorkflowVersion; +import javax.net.ssl.*; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.text.DecimalFormat; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static weaver.taojw.common.action.constant.Constant.*; + +/** + *

+ * 功能描述: + * 流程数据推送工具类 + * 获取配置信息 生成请求 解析响应 + * 创建日期: + * 2022-05-26 + *

+ * @author taojingwei + * @version 1.0 + */ +public class CallApiByWorkFlowDataUtil { + + //建模工具类 + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + private RecordSetTrans rsts = null; + + //流程类型 + private String workflowId = ""; + //自定义配置值 + private String paramValue = ""; + //配置主表id + private int mainConfigInfoId; + //流程基础数据数组[流程请求ID\流程标题\流程编号\流程主表表名\流程主表主键值] + private String[] baseArray = new String[5]; + + //建模中的配置信息 + private ConfigInfoEntity configInfoEntity = new ConfigInfoEntity(); + //请求和响应内容 + private RequestAndResponseInfoEntity rarInfoEntity = new RequestAndResponseInfoEntity(); + + //流程主表数据 + private Map mainTableData = new HashMap<>(); + //流程明细表数据 + private Map>> detailTableData = new HashMap<>(); + + Logger logger = MyLogger.getLogger(); + + /** + * 获取对应配置信息 + * @param rs 数据库链接 + * @throws Exception + */ + public void getConfigurationByWorkflowId(RecordSet rs) throws Exception{ + //获取该流程类型对应的所有类型ID + String allWfIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId); + String selectMainSQL = "select * from " + CONFIG_TABLE_NAME + " where lclx in (" + allWfIds + ")"; + if(!"".equals(paramValue)){ + selectMainSQL += " and pzid = '" + paramValue + "'"; + } + if(rs.executeQuery(selectMainSQL)){ + if(rs.next()){ + //配置主表id + mainConfigInfoId = Util.getIntValue(rs.getString("id"),0); + //接口调用类型 0-仅调用一次 1-每条明细调用一次 + configInfoEntity.callType = Util.null2String(rs.getString("jkdylx")); + //请求方式 0-get 1-post + configInfoEntity.requestMethod = Util.null2String(rs.getString("qqfs")); + //失败是否阻止流程提交 + configInfoEntity.failedAndReturn = Util.null2String(rs.getString("sbsfzzlctj")); + //明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口 + configInfoEntity.detailTableIndex = Util.null2String(rs.getString("mxbxb")); + //数据条件 用于筛选明细表中需要调用接口的记录 + configInfoEntity.sqlCondition = Util.null2String(rs.getString("sjtj")); + //接口报文类型 0-xml 1-json 2-键值对 + configInfoEntity.requestDataType = Util.null2String(rs.getString("jkbwlx")); + //接口响应报文类型 0-xml 1-json + configInfoEntity.responseDataType = Util.null2String(rs.getString("xybwlx")); + //接口地址 + configInfoEntity.callAddress = Util.null2String(rs.getString("jkdz")); + //日志记录表名称 + configInfoEntity.logTableName = LOG_TABLE_NAME; + //日志记录表requestid字段名称 + configInfoEntity.logRequestIdFieldName = LOG_REQUESTID_COLUMN; + //日志记录表请求报文字段名称 + configInfoEntity.logRequestBodyFieldName = LOG_REQUEST_COLUMN; + //日志记录表响应报文字段名称 + configInfoEntity.logResponseBodyFieldName = LOG_RESPONSE_COLUMN; + //日志记录表响应码文字段名称 + configInfoEntity.logResponseStatusFieldName = LOG_RESPONSECODE_COLUMN; + //日志记录表请求地址字段名称 + configInfoEntity.logRequestUrlFieldName = LOG_REQUESTURL_COLUMN; + //日志记录表请求头字段名称 + configInfoEntity.logRequestHeaderFieldName = LOG_REQUESTHEADER_COLUMN; + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.getMainConfigInfo sql execute success and found nothing;sql:" + selectMainSQL); + throw new Exception("接口调用前未到获取配置信息,请联系管理员!"); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.getMainConfigInfo sql execute error;sql:" + selectMainSQL); + throw new Exception("接口调用前获取配置信息失败,请联系管理员!"); + } + + //获取明细表1 接口地址详细配置 + String selectDetail1SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail1SQL,mainConfigInfoId)){ + while(rs.next()){ + //参数名称 + String csmc = Util.null2String(rs.getString("csmc")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("csmc",csmc); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("fieldName",fieldName); + detailMap.put("zdgz",zdgz); + detailMap.put("zhgz",zhgz); + detailMap.put("zdysql",zdysql); + detailMap.put("viewType",viewType); + configInfoEntity.requestAddressConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail1SQL sql execute error;sql:" + selectDetail1SQL); + throw new Exception("接口调用前获取明细1配置信息失败,请联系管理员!"); + } + + //获取明细表2 请求头参数详细配置 + String selectDetail2SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt2 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail2SQL,mainConfigInfoId)){ + while(rs.next()){ + //参数名称 + String csmc = Util.null2String(rs.getString("csmc")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + logger.info("configInfo:requestHeaderConfigList.zdysql:" + zdysql); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("csmc",csmc); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("fieldName",fieldName); + detailMap.put("zdgz",zdgz); + detailMap.put("zhgz",zhgz); + detailMap.put("zdysql",zdysql); + detailMap.put("viewType",viewType); + logger.info("configInfo:requestHeaderConfigList.zdysql:" + zdysql); + configInfoEntity.requestHeaderConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail2SQL sql execute error;sql:" + selectDetail2SQL); + throw new Exception("接口调用前获取明细2配置信息失败,请联系管理员!"); + } + + //获取明细表3 请求体字段详细配置信息 + String selectDetail3SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt3 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail3SQL,mainConfigInfoId)){ + while(rs.next()){ + //xml节点序号 + String xmljdxh = Util.null2String(rs.getString("xmljdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("xmljdmc")); + //是否科目字段 + String sfkmzd = Util.null2String(rs.getString("sfkmzd")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("xmljdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Default_Line_Break,Default_Blank_Char); + sjtj = sjtj.replace(Default_Html_Blank,Default_Blank_Char); + sjtj = CommonUtil.fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("xmljdxh",xmljdxh); + dtMap.put("xmljdmc",xmljdmc); + dtMap.put("xmljdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("sfkmzd",sfkmzd); + dtMap.put("zdgz",zdgz); + dtMap.put("fieldName",fieldName); + if("".equals(fjdxh)){ + configInfoEntity.rootXmlConfigInfo = dtMap; + configInfoEntity.rootJsonConfigInfo.add(dtMap); + } + configInfoEntity.requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail3SQL sql execute error;sql:" + selectDetail3SQL); + throw new Exception("接口调用前获取明细3配置信息失败,请联系管理员!"); + } + + //获取明细表4 xml节点属性详细配置信息 + String selectDetail4SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt4 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail4SQL,mainConfigInfoId)){ + while(rs.next()){ + //属性名称 + String sxmc = Util.null2String(rs.getString("sxmc")); + //对应字段序号 + String dyzdxh = Util.null2String(rs.getString("dyzdxh")); + //表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //取值方式 + String zhgz = Util.null2String(rs.getString("zhgz")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = CommonUtil.fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("sxmc",sxmc); + detailMap.put("dyzdxh",dyzdxh); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("zhgz",zhgz); + detailMap.put("zdgz",zdgz); + detailMap.put("zdysql",zdysql); + detailMap.put("fieldName",fieldName); + detailMap.put("viewType",viewType); + configInfoEntity.xmlNodeAttrConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail4SQL sql execute error;sql:" + selectDetail4SQL); + throw new Exception("接口调用前获取明细4配置信息失败,请联系管理员!"); + } + + //获取明细表5 接口响应信息详细配置 + String selectDetail5SQL = "select dt.*,wb.fieldName,wb.viewType from " + CONFIG_TABLE_NAME + "_dt5 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail5SQL,mainConfigInfoId)){ + while(rs.next()){ + //响应字段名称 + String xyzdmc = Util.null2String(rs.getString("xyzdmc")); + //响应字段父节点路径 + String xyzdfjdlj = Util.null2String(rs.getString("xyzdfjdlj")); + //回写流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //是否为成功失败标识字段 + String sfwcgsbbszd = Util.null2String(rs.getString("sfwcgsbbszd")); + //是否为提示信息字段 + String sftsxxzd = Util.null2String(rs.getString("sftsxxzd")); + //成功标识 + String cgbs = Util.null2String(rs.getString("cgbs")); + //失败标识 + String sbbs = Util.null2String(rs.getString("sbbs")); + Map detailMap = new HashMap<>(); + detailMap.put("xyzdmc",xyzdmc); + detailMap.put("xyzdfjdlj",xyzdfjdlj); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("sfwcgsbbszd",sfwcgsbbszd); + detailMap.put("cgbs",cgbs); + detailMap.put("sbbs",sbbs); + detailMap.put("fieldName",fieldName); + detailMap.put("viewType",viewType); + detailMap.put("sftsxxzd",sftsxxzd); + configInfoEntity.responseConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail5SQL sql execute error;sql:" + selectDetail5SQL); + throw new Exception("接口调用前获取明细5配置信息失败,请联系管理员!"); + } + + } + + /** + * 根据流程类型、自定义参数找到对应的配置,生成请求-发送请求-处理响应 + * @param workflowId 流程类型 + * @param paramValue 自定义配置 + * @return {code:接口调用成功失败标识,message:接口响应提示信息} + * @throws Exception + */ + public Map execute(String workflowId, String paramValue) throws Exception { + this.workflowId = workflowId; + this.paramValue = paramValue; + //返回值 + Map result = new HashMap<>(); + result.put("code",CALL_SUCCESS); + result.put("message",""); + //数据库链接 + RecordSet rs = new RecordSet(); + //获取配置信息 + getConfigurationByWorkflowId(rs); + //根据配置的接口调用类型 查询数据 然后遍历每一行数据分别调用接口 + String getMainTableDataSql = "select * from " + baseArray[3] + " where id = " + baseArray[4]; + RecordSet detailRs = new RecordSet(); + switch(configInfoEntity.callType){ + case CALL_TYPE_ONLY_ONE: + if(!"".equals(configInfoEntity.sqlCondition)){ + getMainTableDataSql = getMainTableDataSql + configInfoEntity.sqlCondition; + } + if(rs.executeQuery(getMainTableDataSql)){ + if(rs.next()){ + mainTableData = DaoUtil.setRsToMap(rs); + commonExecute(rs,rs); + //如果配置为失败阻止流程提交 且接口响应失败 则返回信息 + if(SELECT_TYPE_IS.equals(configInfoEntity.failedAndReturn)){ + if(CALL_FAILED.equals(rarInfoEntity.resultValue)){ + result.put("code",CALL_FAILED); + result.put("message",rarInfoEntity.responseMessage); + return result; + } + } + } + } + break; + case CALL_TYPE_EVERY_DETAIL: + if("".equals(configInfoEntity.detailTableIndex)){ + throw new Exception("参数配置中未配置明细表下标!"); + } + if(rs.executeQuery(getMainTableDataSql)){ + if(rs.next()){ + mainTableData = DaoUtil.setRsToMap(rs); + } + } + String getDetailSql = "select id from " + baseArray[3] + "_dt" + configInfoEntity.detailTableIndex + " where mainid = " + baseArray[4]; + //如果配置了数据条件,则添加在sql后,用于筛选出需要调用接口的数据 + if(!"".equals(configInfoEntity.sqlCondition)){ + getDetailSql = getDetailSql + configInfoEntity.sqlCondition; + } + //查询需要调用接口的数据 然后遍历每一行数据分别调用接口 + if(detailRs.executeQuery(getDetailSql)){ + while(detailRs.next()){ + //数据id + commonExecute(rs,detailRs); + //如果配置为失败阻止流程提交 且接口响应失败 则返回信息 + if(SELECT_TYPE_IS.equals(configInfoEntity.failedAndReturn)){ + if(!CALL_SUCCESS.equals(rarInfoEntity.resultValue)){ + result.put("code",CALL_FAILED); + result.put("message",rarInfoEntity.responseMessage); + return result; + } + } + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.execute.getDetailSql sql execute error;sql:" + getDetailSql); + throw new Exception("action接口调用失败!"); + } + break; + default: + break; + } + return result; + } + + /** + * 处理请求 - 处理响应 + * @param rs + * @param detailRs + * @throws Exception + */ + public void commonExecute(RecordSet rs,RecordSet detailRs) throws Exception { + //请求地址处理 + dealUrl(rs,detailRs); + //请求头处理 + dealHeaders(rs,detailRs); + //请求报文处理 + dealRequestBody(rs,detailRs); + //发送请求 + sendRequest(); + //日志处理 + dealLog(rs); + //解析响应 + dealResponseInfo(detailRs,rs); + } + + /** + * 处理配置的接口地址,将参数转换为实际值 + * @param rs 数据库链接 + * @param detailRs 明细数据行 + */ + public void dealUrl(RecordSet rs,RecordSet detailRs) throws Exception { + if("".equals(configInfoEntity.callAddress)){ + throw new Exception("接口地址未配置!"); + } + int index = configInfoEntity.callAddress.indexOf(PARAM_BEGIN); + if(configInfoEntity.callAddress.indexOf(PARAM_BEGIN) > -1){ + //截取配置的请求地址中的参数项 + String paramKey = configInfoEntity.callAddress.substring(index + 1,configInfoEntity.callAddress.indexOf(PARAM_END)); + //获取字段对应的配置信息 + Map configMap = new HashMap<>(); + for(Map configInfo:configInfoEntity.requestAddressConfigList){ + if(paramKey.equals(configInfo.get("csmc"))){ + configMap = configInfo; + break; + } + } + //获取实际值 + String value = getFieldValue(configMap,rs,detailRs); + //将配置的地址中的参数替换成实际值 + configInfoEntity.callAddress = configInfoEntity.callAddress.replaceAll("\\{"+paramKey+PARAM_END,value); + dealUrl(rs,detailRs); + } + } + + /** + * 生成请求头参数 + * @param rs + * @param detailRs 数据id 空表示从主表取数据 其余值表示明细表id + */ + public void dealHeaders(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestHeaderConfigList){ + String fieldValue = getFieldValue(m, rs, detailRs); + rarInfoEntity.headers.put(m.get("csmc"),fieldValue); + } + } + + /** + * 生成请求报文 + * @param rs 数据库链接 + * @param detailRs 数据id + */ + public void dealRequestBody(RecordSet rs,RecordSet detailRs){ + //根据配置调用不同的方法生成相应报文 + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + recursionGenerateXML(null,null,rs,detailRs,0); + break; + case REQUEST_DATA_TYPE_JSON: + recursionGenerateJson(null,rs,detailRs,0); + break; + case REQUEST_DATA_TYPE_PAIR: + dealPairRequestData(rs,detailRs); + break; + default: + break; + } + } + + /** + * 以流的形式发送请求 方便控制编码格式 + * @throws Exception + */ + public void sendRequestWithUtf8() throws Exception { + OutputStreamWriter out = null; + BufferedReader in = null; + try{ + //创建URL对象 + URL url = new URL(configInfoEntity.callAddress); + //https信任所有证书设置 + HttpsURLConnection.setDefaultHostnameVerifier(NOT_VERYFY); + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + //请求协议 + String protocol = url.getProtocol(); + //打开链接 + URLConnection conn = url.openConnection(); + //设置请求头 + //设置通用的请求属性 + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("contentType", "UTF-8"); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + conn.setRequestProperty(key,rarInfoEntity.headers.get(key)); + } + } + //发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + //设置请求体信息 + String requestBody = ""; + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + requestBody = rarInfoEntity.xmlDoc.toString(); + break; + case REQUEST_DATA_TYPE_JSON: + requestBody = rarInfoEntity.jsonDoc.toString(); + break; + case REQUEST_DATA_TYPE_PAIR: + if(rarInfoEntity.pairList != null && rarInfoEntity.pairList.size() > 0){ + for(BasicNameValuePair pair:rarInfoEntity.pairList){ + if("".equals(requestBody)){ + requestBody = pair.getName() + "=" + pair.getValue(); + }else{ + requestBody = requestBody + "&" + pair.getName() + "=" + pair.getValue(); + } + } + } + break; + default: + break; + } + //发送请求 + out = null; + out = new OutputStreamWriter(conn.getOutputStream(),"UTF-8"); + out.write(requestBody); + out.flush(); + out.close(); + //获取响应码 + if("http".equals(protocol)){ + rarInfoEntity.responseCode = ((HttpURLConnection) conn).getResponseCode(); + }else{ + rarInfoEntity.responseCode = ((HttpsURLConnection) conn).getResponseCode(); + } + //获取响应体 + in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8")); + String line; + while ((line = in.readLine()) != null) { + rarInfoEntity.responseString += line; + } + switch (configInfoEntity.responseDataType){ + case REQUEST_DATA_TYPE_XML: + rarInfoEntity.responseXml = DocumentHelper.parseText(rarInfoEntity.responseString); + break; + case REQUEST_DATA_TYPE_JSON: + rarInfoEntity.responseJson = JSONObject.parseObject(rarInfoEntity.responseString); + break; + default: + break; + } + }catch(Exception e){ + logger.error("sendRequestWithUtf8 exception;info" + e.getMessage() + ";e:" + e); + rarInfoEntity.responseCode = 9999; + rarInfoEntity.responseString = e.getMessage(); + }finally { + if(in != null){ + in.close(); + } + if(out != null){ + out.close(); + } + } + } + + /** + * 发送请求 获取响应信息 + * @throws Exception + */ + public void sendRequest() throws Exception { + CloseableHttpClient client = createSSLClientDefault(); + try{ + switch(configInfoEntity.requestMethod){ + case REQUEST_METHOD_GET: + HttpGet get = new HttpGet(configInfoEntity.callAddress); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + get.setHeader(key,rarInfoEntity.headers.get(key)); + } + } + get.setHeader("Charset","UTF-8"); + rarInfoEntity.response = client.execute(get); + break; + case REQUEST_METHOD_POST: + HttpPost post = new HttpPost(configInfoEntity.callAddress); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + post.setHeader(key,rarInfoEntity.headers.get(key)); + } + } + post.setHeader("Charset","UTF-8"); + //请求信息设置 + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + StringEntity xmlEntity = new StringEntity(rarInfoEntity.xmlDoc.toString(), "UTF-8"); + post.setEntity(xmlEntity); + break; + case REQUEST_DATA_TYPE_JSON: + StringEntity jsonEntity = new StringEntity(rarInfoEntity.jsonDoc.toString(), "UTF-8"); + post.setEntity(jsonEntity); + break; + case REQUEST_DATA_TYPE_PAIR: + post.setEntity(new UrlEncodedFormEntity(rarInfoEntity.pairList, "UTF-8")); + break; + case REQUEST_DATA_TYPE_MULTIPARTFILE: + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(Charset.forName("utf-8")); + //加上此行代码解决返回中文乱码问题 + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + //文件流处理 + ImageFileManager imageFileManager = new ImageFileManager(); + for(Map map : rarInfoEntity.multiPartFileInfos){ + if(map != null){ + builder.addBinaryBody(map.get("xmljdmc"), imageFileManager.getInputStreamById(Integer.parseInt(map.get("imagefileid"))), ContentType.MULTIPART_FORM_DATA, map.get("imagefilename")); + } + } + HttpEntity entity = builder.build(); + post.setEntity(entity); + break; + default: + break; + } + rarInfoEntity.response = client.execute(post); + break; + default: + break; + } + //响应信息设置 + rarInfoEntity.responseCode = rarInfoEntity.response.getStatusLine().getStatusCode(); + logger.info("response code:" + rarInfoEntity.responseCode); + HttpEntity en = rarInfoEntity.response.getEntity(); + String content = EntityUtils.toString(en, "utf-8"); + logger.info("response entity:" + content); + switch (configInfoEntity.responseDataType){ + case RESPONSE_DATA_TYPE_XML: + rarInfoEntity.responseXml = DocumentHelper.parseText(content); + break; + case RESPONSE_DATA_TYPE_JSON: + rarInfoEntity.responseJson = JSONObject.parseObject(content); + break; + default: + rarInfoEntity.responseString = content; + break; + } + }catch(Exception e){ + logger.error("DealWorkFlowDataToRequestUtil.sendRequest exception;url:"+configInfoEntity.callAddress+";info:"+e.getMessage()+";e"+e); + rarInfoEntity.responseCode = 91919; + rarInfoEntity.resultValue = CALL_FAILED; + }finally { + client.close(); + } + } + + /** + * 记录日志 + * @param rs + */ + public void dealLog(RecordSet rs){ + try{ + if("".equals(configInfoEntity.logTableName) || "".equals(configInfoEntity.logRequestIdFieldName)){ + return; + } + //查询modeid + int modeId = -1; + String getModeIdSql = "select t1.id from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid " + + " where t2.tablename = '" + configInfoEntity.logTableName + "' and t1.isdelete = 0"; + if(rs.executeQuery(getModeIdSql)){ + if(rs.next()){ + modeId = Util.getIntValue(rs.getString("id"),0); + }else{ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.getModeIdSql execute success but found nothing;sql:" + getModeIdSql); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.getModeIdSql execute error;sql:" + getModeIdSql); + } + if(modeId == -1){ + return; + } + //日志表新增记录 + int dataId = -1; + dataId = mdu.getModeDataNewId(configInfoEntity.logTableName, modeId, 1, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString()); + //设置请求数据 + String requestHeaderString = ""; + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + requestHeaderString = requestHeaderString + key + ":" + rarInfoEntity.headers.get(key) + "\n"; + } + } + String requestString = ""; + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + requestString = requestString + rarInfoEntity.xmlDoc.asXML(); + break; + case REQUEST_DATA_TYPE_JSON: + requestString = requestString + rarInfoEntity.jsonDoc.toString(); + break; + case REQUEST_DATA_TYPE_PAIR: + requestString = requestString + rarInfoEntity.pairList.toString(); + break; + default: + break; + } + + //设置响应数据 + String responseString = ""; + switch (configInfoEntity.responseDataType){ + case RESPONSE_DATA_TYPE_XML: + responseString = rarInfoEntity.responseXml.asXML(); + break; + case RESPONSE_DATA_TYPE_JSON: + responseString = rarInfoEntity.responseJson.toString(); + break; + default: + responseString = rarInfoEntity.responseString; + break; + } + if(rarInfoEntity.responseCode == 9999){ + responseString = rarInfoEntity.responseString; + } + //更新日志表记录 + String updateLogTableSql = + "update " + + configInfoEntity.logTableName + + " set " + + configInfoEntity.logRequestIdFieldName + " = " + baseArray[0] + + "," + configInfoEntity.logResponseStatusFieldName + " = ? " + + "," + configInfoEntity.logRequestBodyFieldName + " = ? " + + "," + configInfoEntity.logResponseBodyFieldName + " = ? " + + "," + configInfoEntity.logRequestUrlFieldName + " = ? " + + "," + configInfoEntity.logRequestHeaderFieldName + " = ? " + + " where " + + "id = " + dataId; + if(!rs.executeUpdate(updateLogTableSql,rarInfoEntity.responseCode,requestString,responseString,configInfoEntity.callAddress,requestHeaderString)){ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.updateLogTableSql execute error;sql:" + updateLogTableSql); + } + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,dataId); + }catch(Throwable e){ + logger.error("DealWorkFlowDataToRequestUtil.dealLog execute error;requestId:" + baseArray[0] + "exception:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 解析响应信息 回写表单字段 + * @param detailRs + * @param rs + */ + public void dealResponseInfo(RecordSet detailRs,RecordSet rs){ + for(Map m : configInfoEntity.responseConfigList){ + //获取响应信息字段的值 + String value = ""; + switch (configInfoEntity.responseDataType){ + case REQUEST_DATA_TYPE_XML: + value = rarInfoEntity.responseXml.selectSingleNode(m.get("xyzdfjdlj")).getText(); + break; + case REQUEST_DATA_TYPE_JSON: + value = CommonUtil.getJsonValueByPath(rarInfoEntity.responseJson,m.get("xyzdfjdlj")); + break; + default: + break; + } + //将响应值回写表单字段 + if(!"".equals(m.get("fieldName"))){ + String updateDataSql = ""; + if(configInfoEntity.callType.equals(CALL_TYPE_ONLY_ONE)){ + updateDataSql = "update " + baseArray[3] + " set " + m.get("fieldName") + " = ? where id = " + baseArray[4]; + if(!rs.executeUpdate(updateDataSql,value)){ + logger.error("DealWorkFlowDataToRequestUtil.dealResponseInfo.updateDataSql execute error;sql:" + updateDataSql); + } + }else{ + updateDataSql = "update " + baseArray[3] + "_dt" + configInfoEntity.detailTableIndex + " set " + m.get("fieldName") + " = ? where id = " + Util.null2String(detailRs.getString("id")); + if(!rs.executeUpdate(updateDataSql)){ + logger.error("DealWorkFlowDataToRequestUtil.dealResponseInfo.updateDataSql execute error;sql:" + updateDataSql); + } + } + + } + //设置成功失败标识字段的值 + if(SELECT_TYPE_IS.equals(m.get("sfwcgsbbszd"))){ + if(!"".equals(m.get("cgbs"))){ + if(m.get("cgbs").equals(value)){ + rarInfoEntity.resultValue = CALL_SUCCESS; + }else{ + rarInfoEntity.resultValue = CALL_FAILED; + } + } + if(!"".equals(m.get("sbbs"))){ + if(m.get("cgbs").equals(value)){ + rarInfoEntity.resultValue = CALL_FAILED; + }else{ + rarInfoEntity.resultValue = CALL_SUCCESS; + } + } + } + //设置提示信息 + if(SELECT_TYPE_IS.equals(m.get("sftsxxzd"))){ + rarInfoEntity.responseMessage = value; + } + } + logger.info("dealResponseInfo end;rarInfoEntity.resultValue:" + rarInfoEntity.resultValue + ";rarInfoEntity.resultValue:" + rarInfoEntity.responseMessage); + } + + /** + * 根据配置信息 生成请求的键值对参数 + * @param rs + */ + public void dealPairRequestData(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestBodyConfigList){ + rarInfoEntity.pairList.add(new BasicNameValuePair(m.get("xmljdmc"),getFieldValue(m,rs,detailRs))); + } + } + + /** + * 根据配置信息 生成文件参数 + * @param rs + */ + public void dealMultipartFileRequestData(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestBodyConfigList){ + String docIds = getFieldValue(m,rs,detailRs); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArray = docIds.split(","); + for(String docId:docIdArray){ + if(docId != null && !"".equals(docId)){ + String getFileInfoSql = + "select " + + "t3.imagefileid as imagefileid," + + "t3.imagefilename as imagefilename " + + "from " + + "docdetail t1 " + + "inner join DocImageFile t2 on t2.docid = t1.id " + + "inner join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "where " + + "t1.id = ?"; + if(rs.executeQuery(getFileInfoSql,docId)){ + while(rs.next()){ + Map map = DaoUtil.setRsToMap(rs); + map.put("xmljdmc",m.get("xmljdmc")); + rarInfoEntity.multiPartFileInfos.add(map); + } + }else{ + logger.error("getFileInfoSql error;getFileInfoSql:" + getFileInfoSql + ";docId:" + docId); + } + } + } + } + } + logger.info("dealMultipartFileRequestData done;result:" + rarInfoEntity.multiPartFileInfos); + } + + /** + * 递归生成json报文 + * @param configMap + * @param rs + * @param detailRs + * @param sequence + * @return + */ + public Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence){ + if(configMap == null){ + for(Map configInfo:configInfoEntity.rootJsonConfigInfo){ + rarInfoEntity.jsonDoc.put(configInfo.get("xmljdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence)); + } + }else{ + switch(configMap.get("xmljdlx")){ + case NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + String value = getFieldValue(configMap,rs,detailRs); + return value; + case NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + if("true".equals(getFieldValue(configMap,rs,detailRs))){ + return true; + }else{ + return false; + } + case NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs); + DecimalFormat myformat= new DecimalFormat("#0.00"); + d = Double.parseDouble(myformat.format(f)); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : configInfoEntity.requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("xmljdxh"))) { + json.put(m.get("xmljdmc"),recursionGenerateJson(m,rs,detailRs,sequence)); + } + } + return json; + case NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : configInfoEntity.requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("xmljdxh"))) { + jsonObj.put(m.get("xmljdmc"),recursionGenerateJson(m,rs,detailRs,sequence)); + } + } + return jsonObj.toString(); + case NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs); + JSONArray stringArray = new JSONArray(); + for(String v : stringArrayValue.split(",")){ + stringArray.add(v); + } + return stringArray; + case NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + array.add(recursionGenerateJson(son,rs,detailRs,sequence)); + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + o.put(son.get("xmljdmc"),recursionGenerateJson(son,rs,detailRs,sequence)); + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + o.put(son.get("xmljdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence)); + } + } + array.add(o); + } + } + return array; + default: + break; + } + } + return null; + } + + /** + * 生成父节点的所有下级节点 + * @param parentMap 父节点的配置信息 + * @param parentNode 父节点对象 + * @param rs 数据库链接 + * @param detailRs 明细表数据id + * @param sequence 明细序列号 + */ + public void recursionGenerateXML(Map parentMap,Element parentNode,RecordSet rs, + RecordSet detailRs,int sequence){ + if(parentNode == null){ + Element root = rarInfoEntity.xmlDoc.addElement(configInfoEntity.rootXmlConfigInfo.get("xmljdmc")); + setElementAttribute(detailRs,rs,root, configInfoEntity.rootXmlConfigInfo); + recursionGenerateXML(configInfoEntity.rootXmlConfigInfo,root,rs,detailRs,0); + }else{ + //查找parentNode的所有子节点 + for(Map m : configInfoEntity.requestBodyConfigList){ + if(m.get("fjdxh").equals(parentMap.get("xmljdxh"))){ + switch(m.get("xmljdlx")){ + case NODE_TYPE_STRING: + Element ele = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailRs,rs,ele,m); + m.put("detailRowNum", String.valueOf(sequence)); + String value = getFieldValue(m,rs,detailRs); + ele.setText(value); + break; + case NODE_TYPE_OBJECT: + Element objEle = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailRs,rs,objEle,m); + recursionGenerateXML(m,objEle,rs,detailRs,sequence); + break; + case NODE_TYPE_ARRAY: + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + m.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(m.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + m.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + sequence = sequence + 1; + Element arrayEle = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailDataRs,rs,arrayEle,m); + recursionGenerateXML(m,arrayEle,rs,detailDataRs,sequence); + } + } + break; + default: + break; + } + } + } + } + } + + + /** + * 返回CloseableHttpClient 如果接口为https协议 信任所有证书 + * @return + * @throws MalformedURLException + */ + public CloseableHttpClient createSSLClientDefault() throws MalformedURLException { + URL url = new URL(configInfoEntity.callAddress); + String protocol = url.getProtocol(); + if("https".equals(protocol)){ + try { + //使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书 + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { + return true; + } + }).build(); + //NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何 + //有效的SSL会话并匹配到目标主机。 + HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return build; + } catch (Exception e) { + logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e); + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + }else{ + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + } + + private static final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + + private static final HostnameVerifier NOT_VERYFY = new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; + + /** + * 根据明细表3中的配置获取xml节点的属性 + * @param detailRs 明细表数据id + * @param rs 数据库链接 + * @param element xml节点 + * @param map 字段配置信息 + */ + public void setElementAttribute(RecordSet detailRs,RecordSet rs,Element element,Map map){ + //根据节点序号在明细配置中找到对应的配置项 并生成属性 + for(Map configInfo : configInfoEntity.xmlNodeAttrConfigList){ + if(configInfo.get("dyzdxh").equals(map.get("xmljdxh"))){ + String value = getFieldValue(configInfo,rs,detailRs); + element.addAttribute(configInfo.get("sxmc"),value); + } + } + } + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + * @return + */ + public String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs){ + //函数返回值 + String result = ""; + try{ + Map detailDataMap = DaoUtil.setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //数据条件 + String sjtj = configMap.get("sjtj"); + //不同转换规则处理 + switch(zhgz){ + case CHANGE_TYPE_MD5: + result = "Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes()); + break; + case CHANGE_TYPE_SUGGESTION: + result = CommonSqlUtil.getWorkFlowSuggestion(rsts,baseArray[0]); + break; + case CHANGE_TYPE_ROW_NUMBER: + result = configMap.get("detailRowNum"); + break; + case CHANGE_TYPE_FIXED: + result = configMap.get("zdysql"); + break; + case CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = mainTableData.get(fieldName); + }else{ + result = detailDataMap.get(fieldName); + } + break; + case CHANGE_TYPE_SQL: + String oldValue = ""; + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + } + } + break; + case CHANGE_TYPE_SUM: + String getSumSql = "select sum(" + fieldName + ") as val from " + baseArray[3] + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getSumSql = getSumSql + " " + sjtj; + } + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = Util.null2String(rs.getString("val")); + } + } + break; + case CHANGE_TYPE_STRING_ARRAY: + String getArraySql = "select " + fieldName + " as val from " + baseArray[3] + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getArraySql = getArraySql + " " + sjtj; + } + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = Util.null2String(rs.getString(1)); + }else{ + result = result + "," + Util.null2String(rs.getString(1)); + } + i = i + 1; + } + } + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public RecordSetTrans getRsts() { + return rsts; + } + + public void setRsts(RecordSetTrans rsts) { + this.rsts = rsts; + } + + public String[] getBaseArray() { + return baseArray; + } + + public void setBaseArray(String[] baseArray) { + this.baseArray = baseArray; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/Log4JLogger.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/Log4JLogger.java new file mode 100644 index 0000000..b046846 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/Log4JLogger.java @@ -0,0 +1,89 @@ +package weaver.taojw.common.logging; + +/** + * 写日志(log4j) + * @date 2020-03-10 + * @version 1.0 + */ +public class Log4JLogger implements Logger { + + private org.apache.log4j.Logger log; + //类名 + private String classname; + + @Override + public String getClassname() { + return classname; + } + + @Override + public void setClassname(String classname) { + this.classname = classname; + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public void debug(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.debug(classname+"."+method+"() - "+message); + } + + @Override + public void debug(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.debug(classname+"."+method+"() - "+message, exception); + } + + @Override + public void info(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.info(classname+"."+method+"() - "+message); + } + + @Override + public void info(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.info(classname+"."+method+"() - "+message, exception); + } + + @Override + public void warn(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.warn(classname+"."+method+"() - "+message); + } + + @Override + public void warn(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.warn(classname+"."+method+"() - "+message, exception); + } + + @Override + public void error(Object message) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.error(classname+"."+method+"() - "+message); + } + + @Override + public void error(Object message, Throwable exception) { + String method = Thread.currentThread().getStackTrace()[2].getMethodName(); + log.error(classname+"."+method+"() - "+message, exception); + } + + @Override + public void init(String name) { + if("".equals(name)) { + name = "cuslog"; + } + log = org.apache.log4j.Logger.getLogger(name); + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/Logger.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/Logger.java new file mode 100644 index 0000000..aaef015 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/Logger.java @@ -0,0 +1,78 @@ +package weaver.taojw.common.logging; + +/** + * 日志接口(写) + * + * @author zwl + * @date 2020-03-10 + */ +public interface Logger extends weaver.integration.logging.Logger { + + public boolean isDebugEnabled(); + + /** + * 打印debug日志 + * @param message 消息 + */ + public void debug(Object message); + + /** + * 打印debug日志 + * @param message 消息 + * @param exception 异常 + */ + public void debug(Object message, Throwable exception); + + public boolean isInfoEnabled(); + + /** + * 打印info日志 + * @param message 消息 + */ + public void info(Object message); + + + /** + * 打印info日志 + * @param message 消息 + * @param exception 异常 + */ + public void info(Object message, Throwable exception); + + /** + * 打印warn日志 + * @param message 消息 + */ + public void warn(Object message); + + /** + * 打印warn日志 + * @param message 消息 + * @param exception 异常 + */ + public void warn(Object message, Throwable exception); + + /** + * 打印error日志 + * @param message + */ + public void error(Object message); + + /** + * 打印error日志 + * @param message 消息 + * @param exception 异常 + */ + public void error(Object message, Throwable exception); + + public String getClassname(); + + public void setClassname(String classname); + + /** + * 初始化 + * + * @param name logger名称 + */ + public void init(String name); +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/LoggerFactory.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/LoggerFactory.java new file mode 100644 index 0000000..f685111 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/LoggerFactory.java @@ -0,0 +1,50 @@ +package weaver.taojw.common.logging; + + +/** + * 日志工厂类 + * + * @author zwl + * @date 2020-03-10 + * @version 1.0 + */ +public class LoggerFactory { + private static final String loggerName = "cus"; + + public static Logger getLogger(String LogName, String clazz) { + if("".equals(LogName)) { + LogName = loggerName; + } + Logger logger = new Log4JLogger(); + logger.setClassname(clazz); + logger.init(LogName); + return logger; + } + + /** + * 获取指定类的logger对象 + * @param clazz + * @return + */ + public static Logger getLogger(Class clazz) { + return getLogger(loggerName,clazz.getCanonicalName()); + } + + /** + * 获取指定类的logger对象 + * @param className + * @return + */ + public static Logger getLogger(String className) { + return getLogger(loggerName,className); + } + /** + * 获取未指定指定类的logger对象 + * @param + * @return + */ + public static Logger getLogger() { + String className = Thread.currentThread().getStackTrace()[2].getClassName(); + return getLogger(loggerName, className); + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/MyLogger.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/MyLogger.java new file mode 100644 index 0000000..e4781f6 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/logging/MyLogger.java @@ -0,0 +1,38 @@ +package weaver.taojw.common.logging; + +import org.apache.log4j.*; +import org.apache.log4j.Logger; + +import java.io.File; + +public class MyLogger { + + private static volatile Logger log = null; + + /** + * 获取日志对象 + * + * @return 日志对象 + */ + public static org.apache.log4j.Logger getLogger() { + if (log == null) { + synchronized (MyLogger.class) { + if (log == null) { + DailyRollingFileAppender appender = new DailyRollingFileAppender(); + log = Logger.getLogger("tjw_cus"); + appender.setName("tjw_cus"); + appender.setEncoding("UTF-8"); + appender.setDatePattern("'_'yyyyMMdd'.log'"); + appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "tjw_cus" + File.separator + "cus.log"); + appender.setThreshold(Priority.DEBUG); + appender.setLayout(new PatternLayout("[%-5p][%d{yyyy-MM-dd HH:mm:ss,SSS}][Thread:%t][%F.%M:%L] ==> : %m %x %n")); + appender.setAppend(true); + appender.activateOptions(); + log.addAppender(appender); + log.setLevel(Level.INFO); + } + } + } + return log; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/cronjob/SendMailCronJob.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/cronjob/SendMailCronJob.java new file mode 100644 index 0000000..b25036e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/cronjob/SendMailCronJob.java @@ -0,0 +1,333 @@ +package weaver.taojw.dameile.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.email.EmailWorkRunnable; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.dameile.util.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 达美乐推送邮件 + * 邮件内容为报表附件 + */ +public class SendMailCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + private String content = ""; + private String mailTitle = ""; + + private String allMailContent = ""; + private String allMailTitle = ""; + + public String getAllMailContent() { + return allMailContent; + } + + public void setAllMailContent(String allMailContent) { + this.allMailContent = allMailContent; + } + + public String getAllMailTitle() { + return allMailTitle; + } + + public void setAllMailTitle(String allMailTitle) { + this.allMailTitle = allMailTitle; + } + + public String getMailTitle() { + return mailTitle; + } + + public void setMailTitle(String mailTitle) { + this.mailTitle = mailTitle; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + private String configIds = ""; + + public String getConfigIds() { + return configIds; + } + + public void setConfigIds(String configIds) { + this.configIds = configIds; + } + + @Override + public void execute() { + try{ + logger.info("SendMailCronJob.sendToDoCount start."); + //test begin + //cwjh + /*List cwjhPersonss = CwjhDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + String personss = cwjhPersonss.get(0); + CwjhDataToExcel.getExcelStream(personss); + + cwjhPersonss = DyfdDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + DyfdDataToExcel.getExcelStream(personss); + + cwjhPersonss = FseDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + FseDataToExcel.getExcelStream(personss); + + cwjhPersonss = JdjhScordCardDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + JdjhScordCardDataToExcel.getExcelStream(personss); + + cwjhPersonss = OerScordCardDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + OerScordCardDataToExcel.getExcelStream(personss); + + cwjhPersonss = RsjzDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + RsjzDataToExcel.getExcelStream(personss); + + cwjhPersonss = XljhDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + XljhDataToExcel.getExcelStream(personss); + + cwjhPersonss = XtzzDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + XtzzDataToExcel.getExcelStream(personss); + + cwjhPersonss = ZbgjDataToExcel.getPersonList(); + logger.info("SendMailCronJob.cwjhPersonss.size:" + cwjhPersonss.size()); + personss = cwjhPersonss.get(0); + ZbgjDataToExcel.getExcelStream(personss); + + + logger.info("SendMailCronJob end"); + if(1 == 1){ + return; + }*/ + + RecordSet rs = new RecordSet(); + //查询要发送邮件的人员 + List persons = new ArrayList<>(); + //cwjh + List cwjhPersons = CwjhDataToExcel.getPersonList(); + for(String person : cwjhPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //dyfd + List dyfdPersons = DyfdDataToExcel.getPersonList(); + for(String person : dyfdPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //fse + List fsePersons = FseDataToExcel.getPersonList(); + for(String person : fsePersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //jdjh + List jdjhPersons = JdjhScordCardDataToExcel.getPersonList(); + for(String person : jdjhPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //oer人员 + List oerPersons = OerScordCardDataToExcel.getPersonList(); + for(String person : oerPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //rsjz + List rsjzPersons = RsjzDataToExcel.getPersonList(); + for(String person : rsjzPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //xljh + List xljhPersons = XljhDataToExcel.getPersonList(); + for(String person : xljhPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //xtzz + List xtzzPersons = XtzzDataToExcel.getPersonList(); + for(String person : xtzzPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + //zbgj + List zbgjPersons = ZbgjDataToExcel.getPersonList(); + for(String person : zbgjPersons){ + if(!persons.contains(person)){ + persons.add(person); + } + } + logger.info("oer persons:" + oerPersons.toString()); + logger.info("cwjhPersons persons:" + cwjhPersons.toString()); + logger.info("dyfdPersons persons:" + dyfdPersons.toString()); + logger.info("fsePersons persons:" + fsePersons.toString()); + logger.info("jdjhPersons persons:" + jdjhPersons.toString()); + logger.info("rsjzPersons persons:" + rsjzPersons.toString()); + logger.info("xljhPersons persons:" + xljhPersons.toString()); + logger.info("xtzzPersons persons:" + xtzzPersons.toString()); + logger.info("zbgjPersons persons:" + zbgjPersons.toString()); + String getHrmInfoSql = + "select email from hrmresource where id = ?"; + //发送邮件 + EmailWorkRunnable emailSender = new EmailWorkRunnable(); + if(mailTitle != null && !"".equals(mailTitle)){ + for(String people : persons){ + Map firstData = DaoUtil.getFirstData(rs, getHrmInfoSql, people); + String emailAddress = firstData.get("email"); + + //每个人获取8张报表信息,生成excel附件 + String imageFileIds = ""; + if(cwjhPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(CwjhDataToExcel.getExcelStream(people,""), "财务稽核.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("财务稽核.xlsx",CwjhDataToExcel.getExcelStream(people)); + } + if(dyfdPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(DyfdDataToExcel.getExcelStream(people,""), "打烊访店.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("打烊访店.xlsx",DyfdDataToExcel.getExcelStream(people)); + } + if(fsePersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(FseDataToExcel.getExcelStream(people,""), "FSE.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("FSE.xlsx",FseDataToExcel.getExcelStream(people)); + } + if(jdjhPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(JdjhScordCardDataToExcel.getExcelStream(people,""), "机动稽核.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("机动稽核.xlsx",JdjhScordCardDataToExcel.getExcelStream(people)); + } + if(oerPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(OerScordCardDataToExcel.getExcelStream(people,""), "OERScoreCard.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("OERScoreCard.xlsx",OerScordCardDataToExcel.getExcelStream(people)); + } + if(rsjzPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(RsjzDataToExcel.getExcelStream(people,""), "人事校准.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("人事校准.xlsx",RsjzDataToExcel.getExcelStream(people)); + } + if(xljhPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(XljhDataToExcel.getExcelStream(people,""), "训练稽核.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("训练稽核.xlsx",XljhDataToExcel.getExcelStream(people)); + } + if(xtzzPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(XtzzDataToExcel.getExcelStream(people,""), "系统追踪.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("系统追踪.xlsx",XtzzDataToExcel.getExcelStream(people)); + } + if(zbgjPersons.contains(people) || "1".equals("1")){ + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(ZbgjDataToExcel.getExcelStream(people,""), "值班管理.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + //filename_stream.put("值班管理.xlsx",ZbgjDataToExcel.getExcelStream(people)); + } + imageFileIds = imageFileIds.substring(0,imageFileIds.length() - 1); + logger.info("people:"+people+";emailAddress:"+emailAddress+";imageFileIds:" + imageFileIds); + //emailSender.setImagefileids(imageFileIds); + /*File xx = new File("a.txt"); + + xx.createNewFile(); + filename_stream = new HashMap<>(); + filename_stream.put("a.txt",new FileInputStream(xx)); + emailSender.setFilename_stream(filename_stream);*/ + //发送邮件 + emailSender.threadModeReminder(emailAddress,"","", mailTitle, content,imageFileIds); + Thread.sleep(1000*3); + } + } + + + List allDataUser = getAllDataUser(configIds); + logger.info("allDataUser:" + allDataUser); + for(String people : allDataUser){ + Map firstData = DaoUtil.getFirstData(rs, getHrmInfoSql, people); + String emailAddress = firstData.get("email"); + String imageFileIds = ""; + int fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(CwjhDataToExcel.getExcelStream(people,"1"), "财务稽核.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(DyfdDataToExcel.getExcelStream(people,"1"), "打烊访店.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(FseDataToExcel.getExcelStream(people,"1"), "FSE.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(JdjhScordCardDataToExcel.getExcelStream(people,"1"), "机动稽核.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(OerScordCardDataToExcel.getExcelStream(people,"1"), "OERScoreCard.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(RsjzDataToExcel.getExcelStream(people,"1"), "人事校准.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(XljhDataToExcel.getExcelStream(people,"1"), "训练稽核.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(XtzzDataToExcel.getExcelStream(people,"1"), "系统追踪.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(ZbgjDataToExcel.getExcelStream(people,"1"), "值班管理.xlsx"); + imageFileIds = imageFileIds + fileByInputSteam + ","; + + imageFileIds = imageFileIds.substring(0,imageFileIds.length() - 1); + emailSender.threadModeReminder(emailAddress,"","", allMailTitle, allMailContent,imageFileIds); + Thread.sleep(1000*3); + } + logger.info("SendMailCronJob.sendToDoCount end."); + }catch(Exception e){ + logger.error("SendMailCronJob.sendToDoCount exception:" + e.getMessage() + ";e:" + e); + } + } + + public List getAllDataUser(String configId){ + List result = new ArrayList<>(); + if(configId == null || "".equals(configId)){ + return result; + } + String[] configIdArr = configId.split(","); + RecordSet rs = new RecordSet(); + String getConfigSql = "select ry from uf_uf_dmlalldatamai where id = ?"; + for(String id : configIdArr){ + Map data = DaoUtil.getFirstData(rs, getConfigSql, id); + String ry = Util.null2String(data.get("ry")); + String[] ryArr = ry.split(","); + for(String ryId : ryArr){ + if(!result.contains(ryId)){ + result.add(ryId); + } + } + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/CwjhDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/CwjhDataToExcel.java new file mode 100644 index 0000000..e5fad6e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/CwjhDataToExcel.java @@ -0,0 +1,318 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class CwjhDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + /** + * 获取需要看到财务稽核报表的人员 + * @return + */ + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t2.managerid " + + "from " + + "uf_fna_check_result t1 " + + "left join hrmresource t2 on t2.id = t1.om_manageer " + + "where " + + "(t1.status = 1)"; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_fna_check_paper_dt1 t1 left join uf_fna_check_item t2 on t2.id = t1.check_item left join uf_fna_category_1st t3 on t3.id = t1.category_1st order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_fna_check_paper_dt1 t1 left join uf_fna_check_item t2 on t2.id = t1.check_item left join uf_fna_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_fna_check_result t1 " + + "inner join uf_fna_check_result_dt1 t2 on t2.mainid= t1.id " + + "inner join uf_fna_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + //查询一级分类分数sql + String getFirstScoreSql = + "select " + + "t1.name_1st as category_1st_name,t2.score,t1.category_order " + + "from " + + "(select distinct t3.name_1st,t3.id,t3.category_order from uf_fna_check_paper_dt1 t1 left join uf_fna_check_item t2 on t2.id = t1.check_item left join uf_fna_category_1st t3 on t3.id = t1.category_1st) t1 " + + "left join View_fna_checkitem_sum t2 on t2.category_1st = t1.id and t2.id = ? " + + "order by " + + "t1.category_order"; + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,t2.score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_fna_check_paper_dt1 t1 left join uf_fna_check_item t2 on t2.id = t1.check_item left join uf_fna_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_fna_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> firstScoreData = DaoUtil.getData(rs, getFirstScoreSql, m.get("id")); + data.put("firstScoreData",firstScoreData); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try{ + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("财务稽核 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for(int i = 0;i < 14;i ++){ + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + //处理第二行 一级分类部分 + for(int i = 0;i < allFirstFl.size();i ++){ + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("name_1st")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14+i, 14+i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + index = 14+allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14 + allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + List checkItems = allFirstAndCheckItem.get(firsFl); + for(String item : checkItems){ + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for(Map m : excelDataList){ + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + for(Map data : firstScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + List> detailScoreData = (List>) m.get("detailScoreData"); + for(Map data : detailScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + dataIndex = dataIndex + 1; + } + + /*File file=new File("cwjh.xlsx"); + OutputStream os=new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + }catch(Exception e){ + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + }finally { + /*try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + }*/ + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/DyfdDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/DyfdDataToExcel.java new file mode 100644 index 0000000..1f4f28e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/DyfdDataToExcel.java @@ -0,0 +1,306 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class DyfdDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t2.managerid " + + "from " + + "uf_oc_check_result t1 " + + "left join hrmresource t2 on t2.id = t1.om_manageer " + + "where " + + "(t1.status = 1)"; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_oc_check_paper_dt1 t1 left join uf_oc_check_item t2 on t2.id = t1.check_item left join uf_oc_category_1st t3 on t3.id = t1.category_1st order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_oc_check_paper_dt1 t1 left join uf_oc_check_item t2 on t2.id = t1.check_item left join uf_oc_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_oc_check_result t1 " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /* "and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + "and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,upper(CASE check_result WHEN '是' THEN 'Y' ELSE 'N' END) as score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_oc_check_paper_dt1 t1 left join uf_oc_check_item t2 on t2.id = t1.check_item left join uf_oc_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_oc_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("开店打烊 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for (int i = 0; i < 14; i++) { + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + /*//处理第二行 一级分类部分 + for (int i = 0; i < allFirstFl.size(); i++) { + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("category_1st_name")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14 + i, 14 + i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + }*/ + int index = 14; + //处理第2行明细部分 + //index = 14 + allFirstFl.size(); + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + for (String firsFl : allFirstAndCheckItem.keySet()) { + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14; + for (String firsFl : allFirstAndCheckItem.keySet()) { + List checkItems = allFirstAndCheckItem.get(firsFl); + for (String item : checkItems) { + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for (Map m : excelDataList) { + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("city") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("store") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("checker") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("check_date") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("subsidiary_area") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + /*for (Map data : firstScoreData) { + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex++; + }*/ + List> detailScoreData = (List>) m.get("detailScoreData"); + for (Map data : detailScoreData) { + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex++; + } + dataIndex = dataIndex + 1; + } + + /*File file = new File("dyfd.xlsx"); + OutputStream os = new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + } catch (Exception e) { + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + } finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/FseDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/FseDataToExcel.java new file mode 100644 index 0000000..2ff010b --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/FseDataToExcel.java @@ -0,0 +1,320 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class FseDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t6.managerid " + + "from " + + "uf_fse_check_result t1 " + + "inner join uf_fse_check_result_dt1 t2 on t2.mainid = t1.id " + + "inner join uf_fse_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "left join HrmResource t6 on t6.id = t1.om_manageer " + + "where " + + "(t1.status = 1 and t3.category_1st != 4) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_fse_check_paper_dt1 t1 left join uf_fse_check_item t2 on t2.id = t1.check_item left join uf_fse_category_1st t3 on t3.id = t1.category_1st order by t3.category_order "; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_fse_check_paper_dt1 t1 left join uf_fse_check_item t2 on t2.id = t1.check_item left join uf_fse_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct " + + "t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_fse_check_result t1 " + + "inner join uf_fse_check_result_dt1 t2 on t2.mainid = t1.id " + + "inner join uf_fse_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /*"and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + //查询一级分类分数sql + String getFirstScoreSql = + "select " + + "t1.name_1st as category_1st_name,t2.score,t1.category_order " + + "from " + + "(select distinct t3.name_1st,t3.id,t3.category_order from uf_fse_check_paper_dt1 t1 left join uf_fse_check_item t2 on t2.id = t1.check_item left join uf_fse_category_1st t3 on t3.id = t1.category_1st) t1 " + + "left join View_fse_checkitem_sum t2 on t2.category_1st = t1.id and t2.id = ? " + + "order by " + + "t1.category_order"; + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,t2.score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_fse_check_paper_dt1 t1 left join uf_fse_check_item t2 on t2.id = t1.check_item left join uf_fse_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_fse_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> firstScoreData = DaoUtil.getData(rs, getFirstScoreSql, m.get("id")); + data.put("firstScoreData",firstScoreData); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try{ + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("FSE相关 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for(int i = 0;i < 14;i ++){ + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + //处理第二行 一级分类部分 + for(int i = 0;i < allFirstFl.size();i ++){ + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("name_1st")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14+i, 14+i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + index = 14+allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14 + allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + List checkItems = allFirstAndCheckItem.get(firsFl); + for(String item : checkItems){ + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for(Map m : excelDataList){ + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + for(Map data : firstScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + List> detailScoreData = (List>) m.get("detailScoreData"); + for(Map data : detailScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + dataIndex = dataIndex + 1; + } + + /*File file=new File("fse.xlsx"); + OutputStream os=new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + }catch(Exception e){ + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + }finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/JdjhScordCardDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/JdjhScordCardDataToExcel.java new file mode 100644 index 0000000..6d7a1b2 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/JdjhScordCardDataToExcel.java @@ -0,0 +1,307 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class JdjhScordCardDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t3.managerid " + + "from " + + "uf_cus_check_result t1 " + + "left join HrmResource t3 on t3.id = t1.om_manageer " + + "where " + + "(t1.status = 1) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_cus_check_paper_dt1 t1 left join uf_cus_check_item t2 on t2.id = t1.check_item left join uf_cus_category_1st t3 on t3.id = t1.category_1st order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_cus_check_paper_dt1 t1 left join uf_cus_check_item t2 on t2.id = t1.check_item left join uf_cus_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t12.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t12.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t12.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_cus_check_result t1 " + + "inner join uf_cus_check_result_dt1 t21 on t21.mainid = t1.id " + + "inner join uf_cus_check_paper_dt1 t22 on t22.check_item = t21.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t12 on t12.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /*"and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + "and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,t2.score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_cus_check_paper_dt1 t1 left join uf_cus_check_item t2 on t2.id = t1.check_item left join uf_cus_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_cus_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("机动稽核 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for (int i = 0; i < 14; i++) { + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + /*//处理第二行 一级分类部分 + for (int i = 0; i < allFirstFl.size(); i++) { + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("category_1st_name")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14 + i, 14 + i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + }*/ + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + //index = 14 + allFirstFl.size(); + for (String firsFl : allFirstAndCheckItem.keySet()) { + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14; + for (String firsFl : allFirstAndCheckItem.keySet()) { + List checkItems = allFirstAndCheckItem.get(firsFl); + for (String item : checkItems) { + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for (Map m : excelDataList) { + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + /*for (Map data : firstScoreData) { + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex++; + }*/ + List> detailScoreData = (List>) m.get("detailScoreData"); + for (Map data : detailScoreData) { + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex++; + } + dataIndex = dataIndex + 1; + } + + /*File file = new File("jdjh.xlsx"); + OutputStream os = new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + } catch (Exception e) { + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + } finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/OerScordCardDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/OerScordCardDataToExcel.java new file mode 100644 index 0000000..f6590b2 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/OerScordCardDataToExcel.java @@ -0,0 +1,308 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class OerScordCardDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t10.managerid " + + "from " + + "uf_oer_check_result t1 " + + "inner join uf_oer_check_result_dt1 t2 on t2.mainid = t1.id " + + "inner join uf_oer_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "left join hrmresource t10 on t10.id = t1.om_manageer " + + "where " + + "(t1.status = 1 and t3.category_1st != 4) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_oer_check_paper_dt1 t1 left join uf_oer_check_item t2 on t2.id = t1.check_item left join uf_oer_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4 order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_oer_check_paper_dt1 t1 left join uf_oer_check_item t2 on t2.id = t1.check_item left join uf_oer_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4 order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct " + + "t1.id,t1.city,t01.name as store,t02.lastname as checker,t1.check_date," + + "case when t9.jclx = 0 then 'AM' ELSE CASE WHEN t9.jclx = 1 then 'DM' ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "case when t5.subsidiary_area = 0 then '华东' ELSE CASE WHEN t5.subsidiary_area = 1 then '华南' ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score,t1.check_star " + + "from " + + "uf_oer_check_result t1 " + + "inner join uf_oer_check_result_dt1 t2 on t2.mainid = t1.id " + + "inner join uf_oer_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' and t3.category_1st != 4 " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /*"and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + "and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + //查询明细分数sql + String getDetailScoreSql = + "select " + + /*"t1.name_1st,t1.check_item_name,upper(CASE check_result WHEN '是' THEN 'Y' ELSE 'N' END) as score " +*/ + "t1.name_1st,t1.check_item_name,t2.score as score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_oer_check_paper_dt1 t1 left join uf_oer_check_item t2 on t2.id = t1.check_item left join uf_oer_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4) t1 " + + "left join uf_oer_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("OER SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + Cell cell114 = row1.createCell(14); + cell114.setCellValue("星数"); + for (int i = 0; i < 15; i++) { + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + /*//处理第二行 一级分类部分 + for (int i = 0; i < allFirstFl.size(); i++) { + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("category_1st_name")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14 + i, 14 + i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + }*/ + int index = 15; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + //index = 14 + allFirstFl.size(); + for (String firsFl : allFirstAndCheckItem.keySet()) { + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 15; + for (String firsFl : allFirstAndCheckItem.keySet()) { + List checkItems = allFirstAndCheckItem.get(firsFl); + for (String item : checkItems) { + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for (Map m : excelDataList) { + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + Cell celln114 = row.createCell(14); + celln114.setCellValue(m.get("check_star") + ""); + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + /*for (Map data : firstScoreData) { + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex++; + }*/ + List> detailScoreData = (List>) m.get("detailScoreData"); + for (Map data : detailScoreData) { + Cell cellnn = row.createCell(15 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex++; + } + dataIndex = dataIndex + 1; + } + + /*File file = new File("oer.xlsx"); + OutputStream os = new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + } catch (Exception e) { + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + } finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/RsjzDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/RsjzDataToExcel.java new file mode 100644 index 0000000..4607c19 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/RsjzDataToExcel.java @@ -0,0 +1,319 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class RsjzDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t6.managerid " + + "from " + + "uf_hr_check_result t1 " + + "inner join uf_hr_check_result_dt1 t2 on t2.mainid= t1.id " + + "inner join uf_hr_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "left join hrmresource t6 on t6.id = t1.om_manageer " + + "where " + + "(t1.status = 1 and t3.category_1st != 4) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_hr_check_paper_dt1 t1 left join uf_hr_check_item t2 on t2.id = t1.check_item left join uf_hr_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4 order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_hr_check_paper_dt1 t1 left join uf_hr_check_item t2 on t2.id = t1.check_item left join uf_hr_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4 order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_hr_check_result t1 " + + "inner join uf_hr_check_result_dt1 t2 on t2.mainid= t1.id " + + "inner join uf_hr_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' and t3.category_1st != 4 " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /*"and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + //查询一级分类分数sql + String getFirstScoreSql = + "select " + + "t1.name_1st as category_1st_name,t2.score,t1.category_order " + + "from " + + "(select distinct t3.name_1st,t3.id,t3.category_order from uf_hr_check_paper_dt1 t1 left join uf_hr_check_item t2 on t2.id = t1.check_item left join uf_hr_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4 ) t1 " + + "left join View_hr_checkitem_sum t2 on t2.category_1st = t1.id and t2.id = ? " + + "order by " + + "t1.category_order"; + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,t2.score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_hr_check_paper_dt1 t1 left join uf_hr_check_item t2 on t2.id = t1.check_item left join uf_hr_category_1st t3 on t3.id = t1.category_1st where t1.category_1st != 4 ) t1 " + + "left join uf_hr_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> firstScoreData = DaoUtil.getData(rs, getFirstScoreSql, m.get("id")); + data.put("firstScoreData",firstScoreData); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try{ + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("人事校准 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for(int i = 0;i < 14;i ++){ + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + //处理第二行 一级分类部分 + for(int i = 0;i < allFirstFl.size();i ++){ + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("name_1st")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14+i, 14+i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + index = 14+allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14 + allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + List checkItems = allFirstAndCheckItem.get(firsFl); + for(String item : checkItems){ + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for(Map m : excelDataList){ + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + for(Map data : firstScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + List> detailScoreData = (List>) m.get("detailScoreData"); + for(Map data : detailScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + dataIndex = dataIndex + 1; + } + + /*File file=new File("rsjz.xlsx"); + OutputStream os=new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + }catch(Exception e){ + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + }finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/XljhDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/XljhDataToExcel.java new file mode 100644 index 0000000..420942a --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/XljhDataToExcel.java @@ -0,0 +1,317 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class XljhDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t6.managerid " + + "from " + + "uf_ta_check_result t1 " + + "left join HrmResource t6 on t6.id = t1.om_manageer " + + "where " + + "(t1.status = 1) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_ta_check_paper_dt1 t1 left join uf_ta_chenk_item t2 on t2.id = t1.check_item left join uf_ta_category_1st t3 on t3.id = t1.category_1st order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_ta_check_paper_dt1 t1 left join uf_ta_chenk_item t2 on t2.id = t1.check_item left join uf_ta_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_ta_check_result t1 " + + "inner join uf_ta_check_result_dt1 t2 on t2.mainid= t1.id " + + "inner join uf_ta_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /* "and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + //查询一级分类分数sql + String getFirstScoreSql = + "select " + + "t1.name_1st as category_1st_name,t2.score,t1.category_order " + + "from " + + "(select distinct t3.name_1st,t3.id,t3.category_order from uf_ta_check_paper_dt1 t1 left join uf_ta_chenk_item t2 on t2.id = t1.check_item left join uf_ta_category_1st t3 on t3.id = t1.category_1st) t1 " + + "left join View_ta_checkitem_sum t2 on t2.category_1st = t1.id and t2.id = ? " + + "order by " + + "t1.category_order"; + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,t2.score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_ta_check_paper_dt1 t1 left join uf_ta_chenk_item t2 on t2.id = t1.check_item left join uf_ta_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_ta_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> firstScoreData = DaoUtil.getData(rs, getFirstScoreSql, m.get("id")); + data.put("firstScoreData",firstScoreData); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try{ + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("训练稽核 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for(int i = 0;i < 14;i ++){ + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + //处理第二行 一级分类部分 + for(int i = 0;i < allFirstFl.size();i ++){ + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("name_1st")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14+i, 14+i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + index = 14+allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14 + allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + List checkItems = allFirstAndCheckItem.get(firsFl); + for(String item : checkItems){ + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for(Map m : excelDataList){ + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + for(Map data : firstScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + List> detailScoreData = (List>) m.get("detailScoreData"); + for(Map data : detailScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + dataIndex = dataIndex + 1; + } + + /*File file=new File("xljh.xlsx"); + OutputStream os=new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + }catch(Exception e){ + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + }finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/XtzzDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/XtzzDataToExcel.java new file mode 100644 index 0000000..01ccbe6 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/XtzzDataToExcel.java @@ -0,0 +1,319 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class XtzzDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t6.managerid " + + "from " + + "uf_ip_check_result t1 " + + "inner join uf_ip_check_result_dt1 t21 on t21.mainid = t1.id " + + "inner join uf_ip_check_paper_dt1 t22 on t22.check_item = t21.check_item " + + "left join HrmResource t6 on t6.id = t1.om_manageer " + + "where " + + "(t1.status = 1 and t22.category_1st != 4) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_ip_check_paper_dt1 t1 left join uf_ip_check_item t2 on t2.id = t1.check_item left join uf_ip_category_1st t3 on t3.id = t1.category_1st order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_ip_check_paper_dt1 t1 left join uf_ip_check_item t2 on t2.id = t1.check_item left join uf_ip_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_ip_check_result t1 " + + "inner join uf_ip_check_result_dt1 t2 on t2.mainid= t1.id " + + "inner join uf_ip_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /* "and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + //查询一级分类分数sql + String getFirstScoreSql = + "select " + + "t1.name_1st as category_1st_name,t2.score,t1.category_order " + + "from " + + "(select distinct t3.name_1st,t3.id,t3.category_order from uf_ip_check_paper_dt1 t1 left join uf_ip_check_item t2 on t2.id = t1.check_item left join uf_ip_category_1st t3 on t3.id = t1.category_1st) t1 " + + "left join View_ip_checkitem_sum t2 on t2.category_1st = t1.id and t2.id = ? " + + "order by " + + "t1.category_order"; + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,upper(CASE check_result WHEN '是' THEN 'Y' ELSE 'N' END) as score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_ip_check_paper_dt1 t1 left join uf_ip_check_item t2 on t2.id = t1.check_item left join uf_ip_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_ip_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> firstScoreData = DaoUtil.getData(rs, getFirstScoreSql, m.get("id")); + data.put("firstScoreData",firstScoreData); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try{ + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("系统追踪 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for(int i = 0;i < 14;i ++){ + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + //处理第二行 一级分类部分 + for(int i = 0;i < allFirstFl.size();i ++){ + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("name_1st")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14+i, 14+i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + index = 14+allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14 + allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + List checkItems = allFirstAndCheckItem.get(firsFl); + for(String item : checkItems){ + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for(Map m : excelDataList){ + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + for(Map data : firstScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + List> detailScoreData = (List>) m.get("detailScoreData"); + for(Map data : detailScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + dataIndex = dataIndex + 1; + } + + /*File file=new File("xtzz.xlsx"); + OutputStream os=new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + }catch(Exception e){ + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + }finally { + try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/ZbgjDataToExcel.java b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/ZbgjDataToExcel.java new file mode 100644 index 0000000..8defe8a --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dameile/util/ZbgjDataToExcel.java @@ -0,0 +1,318 @@ +package weaver.taojw.dameile.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.*; +import java.util.*; + +public class ZbgjDataToExcel { + + static Logger logger = MyLogger.getLogger(); + + public static List getPersonList(){ + RecordSet rs = new RecordSet(); + List personList = new ArrayList<>(); + String getAllPeopleSql = + "select " + + "distinct t1.om_manageer,t1.oc_manageer,t10.managerid " + + "from " + + "uf_duty_check_result t1 " + + "left join hrmresource t10 on t10.id = t1.om_manageer " + + "where " + + "(t1.status = 1) "; + JSONObject date = CommonUtil.getLastMonthDate(); + getAllPeopleSql = getAllPeopleSql + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'"; + List> data = DaoUtil.getData(rs, getAllPeopleSql); + for(Map m : data){ + if(!personList.contains(m.get("om_manageer"))){ + personList.add(m.get("om_manageer")); + } + if(!personList.contains(m.get("oc_manageer"))){ + personList.add(m.get("oc_manageer")); + } + if(!personList.contains(m.get("managerid"))){ + personList.add(m.get("managerid")); + } + } + return personList; + } + + /** + * 生成财务稽核excel + * @param people + * @return + */ + public static InputStream getExcelStream(String people,String isAll){ + try{ + RecordSet rs = new RecordSet(); + JSONObject date = CommonUtil.getLastMonthDate(); + List> excelDataList = new ArrayList<>(); + //查询所有一级分类 + String getAllFirstFlSql = + "select distinct t3.name_1st,t3.category_order from uf_duty_check_paper_dt1 t1 left join uf_duty_check_item t2 on t2.id = t1.check_item left join uf_duty_category_1st t3 on t3.id = t1.category_1st order by t3.category_order"; + List> allFirstFl = DaoUtil.getData(rs, getAllFirstFlSql); + //查询所有一级分类和checkitem的对应关系 + Map> allFirstAndCheckItem = new LinkedHashMap<>(); + String getFirstAndCheckItemSql = + "select distinct t3.name_1st,t2.check_item_name,t3.category_order,t1.check_item_order from uf_duty_check_paper_dt1 t1 left join uf_duty_check_item t2 on t2.id = t1.check_item left join uf_duty_category_1st t3 on t3.id = t1.category_1st order by t3.category_order,t1.check_item_order "; + List> allFirstAndCheckItemDatas = DaoUtil.getData(rs, getFirstAndCheckItemSql); + for(Map m : allFirstAndCheckItemDatas){ + if(allFirstAndCheckItem.containsKey(m.get("name_1st"))){ + List checkItems = allFirstAndCheckItem.get(m.get("name_1st")); + checkItems.add(m.get("check_item_name")); + }else{ + List checkItems = new ArrayList<>(); + checkItems.add(m.get("check_item_name")); + allFirstAndCheckItem.put(m.get("name_1st"),checkItems); + } + } + //查询数据sql + String getDataSql = + "select " + + "distinct t1.id,t1.city,t01.name as store,t02.lastname as checker," + + "case when t9.jclx = 0 then 'AM' ELSE " + + "CASE WHEN t9.jclx = 1 then 'DM' " + + "ELSE CASE WHEN t9.jclx = 2 then 'DPC' ELSE '' END END END AS jclx," + + "t1.check_date," + + "case when t5.subsidiary_area = 0 then '华东' ELSE " + + "CASE WHEN t5.subsidiary_area = 1 then '华南' " + + "ELSE CASE WHEN t5.subsidiary_area = 2 then '华北' else " + + "case when t5.subsidiary_area = 3 then '华西' else '' END END END end AS subsidiary_area," + + "t03.lastname as om_manageer,t04.lastname as oc_manageer,t1.store_manager," + + "t1.zbjl,t05.lastname as regioncdo,t1.bz,t1.score " + + "from " + + "uf_duty_check_result t1 " + + "inner join uf_duty_check_result_dt1 t2 on t2.mainid= t1.id " + + "inner join uf_duty_check_paper_dt1 t3 on t3.check_item = t2.check_item " + + "right join HrmDepartmentDefined t4 on t1.store_code = t4.depnum " + + "right join uf_subsidiaries t5 on t5.id = t4.defaultcomp " + + "left join uf_check_level_type t9 on t9.person = t1.checker " + + "left join uf_locations t01 on t01.id = t1.store " + + "left join hrmresource t02 on t02.id = t1.checker " + + "left join hrmresource t03 on t03.id = t1.om_manageer " + + "left join hrmresource t04 on t04.id = t1.oc_manageer " + + "left join hrmresource t05 on t05.id = t03.managerid " + + "where " + + "t1.status = '1' " + + ("1".equals(isAll)?"":" and (t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) ") + + /*"and " + + "(t1.om_manageer = ? or t1.oc_manageer = ? or t03.managerid = ? ) " +*/ + " and t1.check_date <= '" + date.get("berforeLastDay") + " 23:59' and t1.check_date >= '" + date.get("lastMonthBegin") + " 00:00'" + + "order by " + + "t1.id"; + List> dataList = "1".equals(isAll)?DaoUtil.getData(rs, getDataSql):DaoUtil.getData(rs, getDataSql, people, people, people); + /*List> dataList = DaoUtil.getData(rs, getDataSql, people, people, people);*/ + //查询一级分类分数sql + String getFirstScoreSql = + "select " + + "t1.name_1st as category_1st_name,t2.score,t1.category_order " + + "from " + + "(select distinct t3.name_1st,t3.id,t3.category_order from uf_duty_check_paper_dt1 t1 left join uf_duty_check_item t2 on t2.id = t1.check_item left join uf_duty_category_1st t3 on t3.id = t1.category_1st) t1 " + + "left join View_duty_checkitem_sum t2 on t2.category_1st = t1.id and t2.id = ? " + + "order by " + + "t1.category_order"; + //查询明细分数sql + String getDetailScoreSql = + "select " + + "t1.name_1st,t1.check_item_name,t2.score,t1.category_order,t1.check_item_order " + + "from " + + "(select distinct t3.name_1st,t2.check_item_name,t1.check_item,t3.category_order,t1.check_item_order from uf_duty_check_paper_dt1 t1 left join uf_duty_check_item t2 on t2.id = t1.check_item left join uf_duty_category_1st t3 on t3.id = t1.category_1st ) t1 " + + "left join uf_duty_check_result_dt1 t2 on t2.check_item = t1.check_item and t2.mainid = ? " + + "order by " + + "t1.category_order,t1.check_item_order"; + for(Map m : dataList){ + Map data = new HashMap<>(); + data.putAll(m); + List> firstScoreData = DaoUtil.getData(rs, getFirstScoreSql, m.get("id")); + data.put("firstScoreData",firstScoreData); + List> detailScoreData = DaoUtil.getData(rs, getDetailScoreSql, m.get("id")); + data.put("detailScoreData",detailScoreData); + excelDataList.add(data); + } + InputStream stream = getStream(allFirstFl, allFirstAndCheckItem, excelDataList); + return stream; + }catch(Exception e){ + logger.error("CwjhDataToExcel.getExcelStream excception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + /** + * 生成财务稽核excel + * @param allFirstFl 所有一级分类 + * @param allFirstAndCheckItem 所有一级分类和check item对应关系 + * @param excelDataList 报表数据 + * @return + */ + private static InputStream getStream(List> allFirstFl,Map> allFirstAndCheckItem,List> excelDataList) { + ByteArrayOutputStream dstStream = null; + ByteArrayInputStream byteStream = null; + try{ + XSSFWorkbook workbook = new XSSFWorkbook(); + + XSSFSheet sheet = workbook.createSheet("报表"); + Row row0 = sheet.createRow(0); + Row row1 = sheet.createRow(1); + Row row2 = sheet.createRow(2); + + //处理第一行 + Cell cell0 = row0.createCell(0); + cell0.setCellValue("值班管理 SCORE CARD"); + CellRangeAddress region = new CellRangeAddress(0, 0, 0, 13); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(region); + //处理第2行前半部分 + Cell cell10 = row1.createCell(0); + cell10.setCellValue("检查ID"); + Cell cell11 = row1.createCell(1); + cell11.setCellValue("检查时间"); + Cell cell12 = row1.createCell(2); + cell12.setCellValue("所属区域"); + Cell cell13 = row1.createCell(3); + cell13.setCellValue("城市"); + Cell cell14 = row1.createCell(4); + cell14.setCellValue("检查类型"); + Cell cell15 = row1.createCell(5); + cell15.setCellValue("门店"); + Cell cell16 = row1.createCell(6); + cell16.setCellValue("检查人"); + Cell cell17 = row1.createCell(7); + cell17.setCellValue("大区经理"); + Cell cell18 = row1.createCell(8); + cell18.setCellValue("小区经理"); + Cell cell19 = row1.createCell(9); + cell19.setCellValue("店经理"); + Cell cell110 = row1.createCell(10); + cell110.setCellValue("值班经理"); + Cell cell111 = row1.createCell(11); + cell111.setCellValue("DO"); + Cell cell112 = row1.createCell(12); + cell112.setCellValue("备注"); + Cell cell113 = row1.createCell(13); + cell113.setCellValue("稽核分数"); + for(int i = 0;i < 14;i ++){ + CellRangeAddress regionN = new CellRangeAddress(1, 2, i, i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + //处理第二行 一级分类部分 + for(int i = 0;i < allFirstFl.size();i ++){ + Cell cell1 = row1.createCell(14 + i); + cell1.setCellValue(allFirstFl.get(i).get("name_1st")); + CellRangeAddress regionN = new CellRangeAddress(1, 2, 14+i, 14+i); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + int index = 14; + //处理第2行明细部分 + XSSFCellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + index = 14+allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + Cell cell1 = row1.createCell(index); + if(allFirstAndCheckItem.get(firsFl).size() > 1){ + CellRangeAddress regionN = new CellRangeAddress(1, 1, index, index + allFirstAndCheckItem.get(firsFl).size() - 1); //初始行,终止行,初始列,终止列 + sheet.addMergedRegion(regionN); + } + cell1.setCellValue(firsFl); + cell1.setCellStyle(style); + index = index + allFirstAndCheckItem.get(firsFl).size(); + } + + //处理第三行 + index = 14 + allFirstFl.size(); + for(String firsFl: allFirstAndCheckItem.keySet()){ + List checkItems = allFirstAndCheckItem.get(firsFl); + for(String item : checkItems){ + Cell cell1 = row2.createCell(index); + cell1.setCellValue(item); + index++; + } + } + + int dataIndex = 3; + for(Map m : excelDataList){ + Row row = sheet.createRow(dataIndex); + Cell celln10 = row.createCell(0); + celln10.setCellValue(m.get("id") + ""); + Cell celln11 = row.createCell(1); + celln11.setCellValue(m.get("check_date") + ""); + Cell celln12 = row.createCell(2); + celln12.setCellValue(m.get("subsidiary_area") + ""); + Cell celln13 = row.createCell(3); + celln13.setCellValue(m.get("city") + ""); + Cell celln14 = row.createCell(4); + celln14.setCellValue(m.get("jclx") + ""); + Cell celln15 = row.createCell(5); + celln15.setCellValue(m.get("store") + ""); + Cell celln16 = row.createCell(6); + celln16.setCellValue(m.get("checker") + ""); + Cell celln17 = row.createCell(7); + celln17.setCellValue(m.get("om_manageer") + ""); + Cell celln18 = row.createCell(8); + celln18.setCellValue(m.get("oc_manageer") + ""); + Cell celln19 = row.createCell(9); + celln19.setCellValue(m.get("store_manager") + ""); + Cell celln110 = row.createCell(10); + celln110.setCellValue(m.get("zbjl") + ""); + Cell celln111 = row.createCell(11); + celln111.setCellValue(m.get("regioncdo") + ""); + Cell celln112 = row.createCell(12); + celln112.setCellValue(m.get("bz") + ""); + Cell celln113 = row.createCell(13); + celln113.setCellValue(m.get("score") + ""); + + List> firstScoreData = (List>) m.get("firstScoreData"); + int detailIndex = 0; + for(Map data : firstScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + List> detailScoreData = (List>) m.get("detailScoreData"); + for(Map data : detailScoreData){ + Cell cellnn = row.createCell(14 + detailIndex); + cellnn.setCellValue(data.get("score") + ""); + detailIndex ++; + } + dataIndex = dataIndex + 1; + } + + /*File file=new File("zbgl.xlsx"); + OutputStream os=new FileOutputStream(file); + workbook.write(os); + os.flush(); + os.close();*/ + + dstStream = new ByteArrayOutputStream(); + workbook.write(dstStream); + byte[] bytes = dstStream.toByteArray(); + byteStream = new ByteArrayInputStream(bytes); + return byteStream; + }catch(Exception e){ + logger.error("getStream exception;message:" + e.getMessage() + ";e:" + e); + return null; + }finally { + /*try { + dstStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + byteStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + }*/ + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/DemoAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/DemoAction.java new file mode 100644 index 0000000..58cc17a --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/DemoAction.java @@ -0,0 +1,19 @@ +package weaver.taojw.demoxm.action; + +import org.apache.log4j.Logger; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.common.ToolUtil; + + + +public class DemoAction extends ToolUtil implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + return ""; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/DemoCallWorkflowToModeAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/DemoCallWorkflowToModeAction.java new file mode 100644 index 0000000..670debd --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/DemoCallWorkflowToModeAction.java @@ -0,0 +1,22 @@ +package weaver.taojw.demoxm.action; + +import com.caucho.java.ExternalCompiler; +import org.apache.log4j.Logger; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.ToolUtil; +import weaver.taojw.common.logging.MyLogger; + +public class DemoCallWorkflowToModeAction extends ToolUtil implements Action { + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + ExternalCompiler x = new ExternalCompiler(null); + logger.debug("debug"); + logger.info("info"); + logger.error("error"); + return Action.SUCCESS; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/RequestDataToApiAction.java new file mode 100644 index 0000000..18fb3f1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/RequestDataToApiAction.java @@ -0,0 +1,105 @@ +package weaver.taojw.demoxm.action; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.demoxm.action.util.CallApiByWorkFlowDataUtil; +import java.util.Map; +import static weaver.taojw.demoxm.action.constant.Constant.*; + +/** + * taojingwei @2022-05-26 + * 1、获取建模配置,将流程数据封装成需要的请求报文 + * 2、调用http接口传输报文信息,获取接口返回信息 + */ +public class RequestDataToApiAction implements Action { + + //自定义参数值 + private String cusParam = ""; + + Logger logger = MyLogger.getLogger(); + + /** + * 实现父类方法 + * 具体的业务实现 + * @param requestInfo 流程请求信息 + * @return 流程是否允许提交标识 + */ + @Override + public String execute(RequestInfo requestInfo) { + //流程请求ID + String requestId = ""; + try { + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + //流程请求ID + requestId = requestInfo.getRequestid(); + //流程类型ID + String workflowId = requestInfo.getWorkflowid(); + //流程表单名称 + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = requestInfo.getRequestManager().getRemark(); + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + logger.info("requestName:[" + requestName + "],requestMark:[" + requestMark + "],workflowId:["+workflowId+"],requestId:[" + requestId + "],billTableName:[" + billTableName + "],cusParam[" + cusParam + "]"); + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + //获取当前流程信息 + String selectData = "select * from " + billTableName + " where requestId = ?"; + RecordSet rs = new RecordSet(); + if(rs.executeQuery(selectData,requestId)){ + rs.next(); + base_array[4] = Util.null2String(rs.getString("id")); + } + //调用接口 + CallApiByWorkFlowDataUtil callApiByWorkFlowDataUtil = new CallApiByWorkFlowDataUtil(); + callApiByWorkFlowDataUtil.setBaseArray(base_array); + callApiByWorkFlowDataUtil.setRsts(rsts); + Map result = callApiByWorkFlowDataUtil.execute(workflowId, cusParam); + if(CALL_FAILED.equals(result.get("code"))){ + requestInfo.getRequestManager().setMessageid("2022052791402"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",接口响应:" + result.get("message")); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + }catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +";" + "请联系管理员!异常信息:" + e.getMessage()); + logger.error("Action Exception;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + + public String getCusParam() { + return cusParam; + } + + public void setCusParam(String cusParam) { + this.cusParam = cusParam; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/constant/Constant.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/constant/Constant.java new file mode 100644 index 0000000..6032727 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/constant/Constant.java @@ -0,0 +1,115 @@ +package weaver.taojw.demoxm.action.constant; + + +/** + * 一些静态常量定义 + */ +public class Constant { + + //action接口调用配置表名称 + public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd"; + + //------------------------------------------------------------------------------接口请求日志表名及字段 + //action调用接口日志记录表表名 + public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd"; + //action调用接口日志记录表requestId字段名称 + public static String LOG_REQUESTID_COLUMN = "lcrequestid"; + //action调用接口日志记录表请求正文字段名称 + public static String LOG_REQUEST_COLUMN = "qqbw"; + //action调用接口日志记录表响应文字段名称 + public static String LOG_RESPONSE_COLUMN = "xybw"; + //action调用接口日志记录表响应码字段名称 + public static String LOG_RESPONSECODE_COLUMN = "xym"; + //action调用接口日志记录表请求地址字段名称 + public static String LOG_REQUEST_ADDRESS_COLUMN = "qqdz"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUEST_HEADER_COLUMN = "qqt"; + //action调用接口日志记录表请求头字段名称 + public static String LOG_REQUEST_RESULT_COLUMN = "qqjg"; + + //------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志 + public static final String PARAM_BEGIN = "{"; + public static final String PARAM_END = "}"; + + //------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功 + public static final String CALL_SUCCESS = "1"; + public static final String CALL_FAILED = "0"; + + //------------------------------------------------------------------------------选择框 0-否 1-是 + public static final String SELECT_TYPE_IS = "1"; + public static final String SELECT_TYPE_NOT = "0"; + + //------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次 + public static final String CALL_TYPE_ONLY_ONE = "0"; + public static final String CALL_TYPE_EVERY_DETAIL = "1"; + + //------------------------------------------------------------------------------接口请求类型 0-get 1-post + //GET + public static final String REQUEST_METHOD_GET = "0"; + //POST + public static final String REQUEST_METHOD_POST = "1"; + + //------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对 + //xml + public static final String REQUEST_DATA_TYPE_XML = "0"; + //json + public static final String REQUEST_DATA_TYPE_JSON = "1"; + //键值对 + public static final String REQUEST_DATA_TYPE_PAIR = "2"; + //MultipartFile + public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3"; + + //------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json + //xml + public static final String RESPONSE_DATA_TYPE_XML = "0"; + //json + public static final String RESPONSE_DATA_TYPE_JSON = "1"; + + //------------------------------------------------------------------------------节点类型 + //文本 + public static final String NODE_TYPE_STRING = "0"; + //对象 + public static final String NODE_TYPE_OBJECT = "1"; + //文本数组 + public static final String NODE_TYPE_STRING_ARRAY = "2"; + //数组 + public static final String NODE_TYPE_ARRAY = "3"; + //json对象字符串 + public static final String NODE_TYPE_JSONSTRING = "4"; + //数字 + public static final String NODE_TYPE_NUMBER = "5"; + //布尔 + public static final String NODE_TYPE_BOOLEAN = "6"; + //浮点数 + public static final String NODE_TYPE_FLOAT = "7"; + + //------------------------------------------------------------------------------转换规则 + //不转换 + public static final String CHANGE_TYPE_NONE = "0"; + //固定值 + public static final String CHANGE_TYPE_FIXED = "1"; + //自定义sql + public static final String CHANGE_TYPE_SQL = "2"; + //字段求和 + public static final String CHANGE_TYPE_SUM = "3"; + //文本数组 + public static final String CHANGE_TYPE_STRING_ARRAY = "4"; + //明细序号 + public static final String CHANGE_TYPE_ROW_NUMBER = "5"; + //流程审批意见 + public static final String CHANGE_TYPE_SUGGESTION = "6"; + //加密处理 + public static final String CHANGE_TYPE_MD5 = "7"; + //requestId + public static final String CHANGE_TYPE_REQUEST_ID = "8"; + //流程标题 + public static final String CHANGE_TYPE_REQUEST_NAME = "9"; + + //------------------------------------------------------------------------------sql转义 + //默认换行符 + public static final String Default_Line_Break = "
"; + //默认空格HTML代码 + public static final String Default_Html_Blank = " "; + //默认空格字符 + public static final String Default_Blank_Char = " "; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/entity/ConfigInfoEntity.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/entity/ConfigInfoEntity.java new file mode 100644 index 0000000..ad91df5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/entity/ConfigInfoEntity.java @@ -0,0 +1,82 @@ +package weaver.taojw.demoxm.action.entity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ConfigInfoEntity { + + //接口调用类型 0-仅调用一次 1-每条明细调用一次 + public String callType; + //请求方式 0-get 1-post + public String requestMethod; + //失败是否阻止流程提交 + public String failedAndReturn; + //明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口 + public String detailTableIndex; + //数据条件 + public String sqlCondition; + //接口报文类型 0-xml 1-json 2-键值对 + public String requestDataType; + //响应报文类型 0-xml 1-json + public String responseDataType; + //接口地址 + public String callAddress; + //日志记录表名称 + public String logTableName; + //日志记录表requestid字段名称 + public String logRequestIdFieldName; + //日志记录表请求报文字段名称 + public String logRequestBodyFieldName; + //日志记录表响应报文字段名称 + public String logResponseBodyFieldName; + //日志记录表响应码字段名称 + public String logResponseStatusFieldName; + //日志记录表请求头字段名称 + public String logRequestHeaderFieldName; + //日志记录表请求地址字段名称 + public String logRequestAddressFieldName; + //接口地址参数配置详情 + public List> requestAddressConfigList = new ArrayList<>(); + //请求头参数配置详情 + public List> requestHeaderConfigList = new ArrayList<>(); + //请求体字段详细配置 + public List> requestBodyConfigList = new ArrayList<>(); + //xml节点属性详细配置 + public List> xmlNodeAttrConfigList = new ArrayList<>(); + //响应信息详细配置 + public List> responseConfigList = new ArrayList<>(); + + //json请求报文根节点配置信息 + public List> rootJsonConfigInfo = new ArrayList<>(); + //xml请求报文根节点配置信息 + public Map rootXmlConfigInfo; + + @Override + public String toString() { + return "ConfigInfoEntity{" + + "callType='" + callType + '\'' + + ", requestMethod='" + requestMethod + '\'' + + ", failedAndReturn='" + failedAndReturn + '\'' + + ", detailTableIndex='" + detailTableIndex + '\'' + + ", sqlCondition='" + sqlCondition + '\'' + + ", requestDataType='" + requestDataType + '\'' + + ", responseDataType='" + responseDataType + '\'' + + ", callAddress='" + callAddress + '\'' + + ", logTableName='" + logTableName + '\'' + + ", logRequestIdFieldName='" + logRequestIdFieldName + '\'' + + ", logRequestBodyFieldName='" + logRequestBodyFieldName + '\'' + + ", logResponseBodyFieldName='" + logResponseBodyFieldName + '\'' + + ", logResponseStatusFieldName='" + logResponseStatusFieldName + '\'' + + ", logRequestHeaderFieldName='" + logRequestHeaderFieldName + '\'' + + ", logRequestAddressFieldName='" + logRequestAddressFieldName + '\'' + + ", requestAddressConfigList=" + requestAddressConfigList + + ", requestHeaderConfigList=" + requestHeaderConfigList + + ", requestBodyConfigList=" + requestBodyConfigList + + ", xmlNodeAttrConfigList=" + xmlNodeAttrConfigList + + ", responseConfigList=" + responseConfigList + + ", rootJsonConfigInfo=" + rootJsonConfigInfo + + ", rootXmlConfigInfo=" + rootXmlConfigInfo + + '}'; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/entity/RequestAndResponseInfoEntity.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/entity/RequestAndResponseInfoEntity.java new file mode 100644 index 0000000..49c6dd0 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/entity/RequestAndResponseInfoEntity.java @@ -0,0 +1,42 @@ +package weaver.taojw.demoxm.action.entity; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.message.BasicNameValuePair; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RequestAndResponseInfoEntity { + + //接口调用地址 + public String callAddress = ""; + //请求头参数 + public Map headers = new HashMap<>(); + //生成的xml请求报文对象 + public Document xmlDoc = DocumentHelper.createDocument(); + //生成的json请求报文对象 + public JSONObject jsonDoc = new JSONObject(); + //生成的键值对参数 + public List pairList = new ArrayList<>(); + //文件信息参数 + public List> multiPartFileInfos = new ArrayList<>(); + //接口响应信息 + public CloseableHttpResponse response; + //接口响应体 + public String responseString; + //接口响应码 + public int responseCode; + //JSON类型响应体 + public JSONObject responseJson; + //XML类型响应体 + public Document responseXml; + //响应的成功失败标识值 + public String resultValue = ""; + //接口调用提示信息 + public String responseMessage = ""; + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/util/CallApiByWorkFlowDataUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/util/CallApiByWorkFlowDataUtil.java new file mode 100644 index 0000000..1b9a509 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/demoxm/action/util/CallApiByWorkFlowDataUtil.java @@ -0,0 +1,1229 @@ +package weaver.taojw.demoxm.action.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.file.ImageFileManager; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.demoxm.action.entity.ConfigInfoEntity; +import weaver.taojw.demoxm.action.entity.RequestAndResponseInfoEntity; +import weaver.workflow.workflow.WorkflowVersion; +import javax.net.ssl.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; +import java.security.cert.X509Certificate; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import static weaver.taojw.common.CommonUtil.*; +import static weaver.taojw.common.DaoUtil.*; +import static weaver.taojw.demoxm.action.constant.Constant.*; + +/** + *

+ * 功能描述: + * 流程数据推送工具类 + * 获取配置信息 生成请求 解析响应 + * 创建日期: + * 2022-05-26 + *

+ * @author taojingwei + * @version 1.0 + */ +public class CallApiByWorkFlowDataUtil { + + //建模工具类 + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + + private RecordSetTrans rsts = null; + + //流程类型 + private String workflowId = ""; + //自定义配置值 + private String paramValue = ""; + //配置主表id + private int mainConfigInfoId; + //流程基础数据数组[流程请求ID\流程标题\流程编号\流程主表表名\流程主表主键值] + private String[] baseArray = new String[5]; + + //建模中的配置信息 + private ConfigInfoEntity configInfoEntity = new ConfigInfoEntity(); + //请求和响应内容 + private RequestAndResponseInfoEntity rarInfoEntity = new RequestAndResponseInfoEntity(); + + //流程主表数据 + private Map mainTableData = new HashMap<>(); + + Logger logger = MyLogger.getLogger(); + + /** + * 根据流程类型、自定义参数找到对应的配置,生成请求-发送请求-处理响应 + * @param workflowId 流程类型 + * @param paramValue 自定义配置 + * @return {code:接口调用成功失败标识,message:接口响应提示信息} + * @throws Exception + */ + public Map execute(String workflowId, String paramValue) throws Exception { + logger.info("CallApiByWorkFlowDataUtil.execute begin;workflowId:" + workflowId + ";paramValue:" + paramValue); + this.workflowId = workflowId; + this.paramValue = paramValue; + //返回值 + Map result = new HashMap<>(); + result.put("code",CALL_SUCCESS); + result.put("message",""); + //数据库链接 + RecordSet rs = new RecordSet(); + //获取配置信息 + getConfigurationByWorkflowId(rs); + //根据配置的接口调用类型 查询数据 然后遍历每一行数据分别调用接口 + String getMainTableDataSql = "select * from " + baseArray[3] + " where id = " + baseArray[4]; + RecordSet detailRs = new RecordSet(); + switch(configInfoEntity.callType){ + case CALL_TYPE_ONLY_ONE: + if(!"".equals(configInfoEntity.sqlCondition)){ + getMainTableDataSql = getMainTableDataSql + configInfoEntity.sqlCondition; + } + if(rs.executeQuery(getMainTableDataSql)){ + if(rs.next()){ + mainTableData = setRsToMap(rs); + commonExecute(rs,rs); + //如果配置为失败阻止流程提交 且接口响应失败 则返回信息 + if(SELECT_TYPE_IS.equals(configInfoEntity.failedAndReturn)){ + if(CALL_FAILED.equals(rarInfoEntity.resultValue)){ + result.put("code",CALL_FAILED); + result.put("message",rarInfoEntity.responseMessage); + return result; + } + } + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.execute.getMainTableDataSql sql execute error;sql:" + getMainTableDataSql); + } + break; + case CALL_TYPE_EVERY_DETAIL: + if("".equals(configInfoEntity.detailTableIndex)){ + logger.error("configInfoEntity.detailTableIndex did not config!"); + throw new Exception("参数配置中未配置明细表下标!"); + } + if(rs.executeQuery(getMainTableDataSql)){ + if(rs.next()){ + mainTableData = setRsToMap(rs); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.execute.getMainTableDataSql sql execute error;sql:" + getMainTableDataSql); + } + String getDetailSql = "select id from " + baseArray[3] + "_dt" + configInfoEntity.detailTableIndex + " where mainid = " + baseArray[4]; + //如果配置了数据条件,则添加在sql后,用于筛选出需要调用接口的数据 + if(!"".equals(configInfoEntity.sqlCondition)){ + getDetailSql = getDetailSql + configInfoEntity.sqlCondition; + } + //查询需要调用接口的数据 然后遍历每一行数据分别调用接口 + if(detailRs.executeQuery(getDetailSql)){ + while(detailRs.next()){ + //数据id + commonExecute(rs,detailRs); + //如果配置为失败阻止流程提交 且接口响应失败 则返回信息 + if(SELECT_TYPE_IS.equals(configInfoEntity.failedAndReturn)){ + if(!CALL_SUCCESS.equals(rarInfoEntity.resultValue)){ + result.put("code",CALL_FAILED); + result.put("message",rarInfoEntity.responseMessage); + return result; + } + } + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.execute.getDetailSql sql execute error;sql:" + getDetailSql); + throw new Exception("action接口调用失败!"); + } + break; + default: + logger.error("configInfoEntity.callType did not config!"); + break; + } + return result; + } + + /** + * 获取对应配置信息 + * @param rs 数据库链接 + * @throws Exception + */ + public void getConfigurationByWorkflowId(RecordSet rs) throws Exception{ + logger.info("getConfigurationByWorkflowId begin"); + //获取该流程类型对应的所有类型ID + String allWfIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId); + String selectMainSQL = "select * from " + CONFIG_TABLE_NAME + " where lclx in (" + allWfIds + ")"; + if(!"".equals(paramValue)){ + selectMainSQL += " and pzid = '" + paramValue + "'"; + } + if(rs.executeQuery(selectMainSQL)){ + if(rs.next()){ + //配置主表id + mainConfigInfoId = Util.getIntValue(rs.getString("id"),0); + //接口调用类型 0-仅调用一次 1-每条明细调用一次 + configInfoEntity.callType = Util.null2String(rs.getString("jkdylx")); + //请求方式 0-get 1-post + configInfoEntity.requestMethod = Util.null2String(rs.getString("qqfs")); + //失败是否阻止流程提交 + configInfoEntity.failedAndReturn = Util.null2String(rs.getString("sbsfzzlctj")); + //明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口 + configInfoEntity.detailTableIndex = Util.null2String(rs.getString("mxbxb")); + //数据条件 用于筛选明细表中需要调用接口的记录 + configInfoEntity.sqlCondition = Util.null2String(rs.getString("sjtj")); + //接口报文类型 0-xml 1-json 2-键值对 + configInfoEntity.requestDataType = Util.null2String(rs.getString("jkbwlx")); + //接口响应报文类型 0-xml 1-json + configInfoEntity.responseDataType = Util.null2String(rs.getString("xybwlx")); + //接口地址 + configInfoEntity.callAddress = Util.null2String(rs.getString("jkdz")); + //日志记录表名称 + configInfoEntity.logTableName = LOG_TABLE_NAME; + //日志记录表requestid字段名称 + configInfoEntity.logRequestIdFieldName = LOG_REQUESTID_COLUMN; + //日志记录表请求报文字段名称 + configInfoEntity.logRequestBodyFieldName = LOG_REQUEST_COLUMN; + //日志记录表响应报文字段名称 + configInfoEntity.logResponseBodyFieldName = LOG_RESPONSE_COLUMN; + //日志记录表响应码文字段名称 + configInfoEntity.logResponseStatusFieldName = LOG_RESPONSECODE_COLUMN; + //日志记录表请求头字段名称 + configInfoEntity.logRequestHeaderFieldName = LOG_REQUEST_HEADER_COLUMN; + //日志记录表请求地址字段名称 + configInfoEntity.logRequestAddressFieldName = LOG_REQUEST_ADDRESS_COLUMN; + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.getMainConfigInfo sql execute success and found nothing;sql:" + selectMainSQL); + throw new Exception("接口调用前未到获取配置信息,请联系管理员!"); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.getMainConfigInfo sql execute error;sql:" + selectMainSQL); + throw new Exception("接口调用前获取配置信息失败,请联系管理员!"); + } + + //获取明细表1 接口地址详细配置 + String selectDetail1SQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from " + CONFIG_TABLE_NAME + "_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail1SQL,mainConfigInfoId)){ + while(rs.next()){ + //参数名称 + String csmc = Util.null2String(rs.getString("csmc")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("csmc",csmc); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("fieldName",fieldName.toLowerCase()); + detailMap.put("zdgz",zdgz); + detailMap.put("zhgz",zhgz); + detailMap.put("zdysql",zdysql); + detailMap.put("viewType",viewType); + detailMap.put("detailtable",detailtable); + configInfoEntity.requestAddressConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail1SQL sql execute error;sql:" + selectDetail1SQL); + throw new Exception("接口调用前获取明细1配置信息失败,请联系管理员!"); + } + + //获取明细表2 请求头参数详细配置 + String selectDetail2SQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from " + CONFIG_TABLE_NAME + "_dt2 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail2SQL,mainConfigInfoId)){ + while(rs.next()){ + //参数名称 + String csmc = Util.null2String(rs.getString("csmc")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + logger.info("configInfo:requestHeaderConfigList.zdysql:" + zdysql); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("csmc",csmc); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("fieldName",fieldName.toLowerCase()); + detailMap.put("zdgz",zdgz); + detailMap.put("zhgz",zhgz); + detailMap.put("zdysql",zdysql); + detailMap.put("viewType",viewType); + detailMap.put("detailtable",detailtable); + configInfoEntity.requestHeaderConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail2SQL sql execute error;sql:" + selectDetail2SQL); + throw new Exception("接口调用前获取明细2配置信息失败,请联系管理员!"); + } + + //获取明细表3 请求体字段详细配置信息 + String selectDetail3SQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from " + CONFIG_TABLE_NAME + "_dt3 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail3SQL,mainConfigInfoId)){ + while(rs.next()){ + //xml节点序号 + String xmljdxh = Util.null2String(rs.getString("xmljdxh")); + //xml节点名称 + String xmljdmc = Util.null2String(rs.getString("xmljdmc")); + //是否科目字段 + String sfkmzd = Util.null2String(rs.getString("sfkmzd")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //xml节点类型 + String xmljdlx = Util.null2String(rs.getString("xmljdlx")); + //父节点序号 + String fjdxh = Util.null2String(rs.getString("fjdxh")); + //流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //流程表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //转换规则 + String zhgz = Util.null2String(rs.getString("zhgz")); + //辅助核算项类型 + String fzhsxlx = Util.null2String(rs.getString("fzhsxlx")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = fullToHalfAngle(zdysql); + } + //数据条件 + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace(Default_Line_Break,Default_Blank_Char); + sjtj = sjtj.replace(Default_Html_Blank,Default_Blank_Char); + sjtj = fullToHalfAngle(sjtj); + } + Map dtMap = new HashMap<>(); + dtMap.put("xmljdxh",xmljdxh); + dtMap.put("xmljdmc",xmljdmc); + dtMap.put("xmljdlx",xmljdlx); + dtMap.put("fjdxh",fjdxh); + dtMap.put("lcbdzd",lcbdzd); + dtMap.put("viewType",viewType); + dtMap.put("zhgz",zhgz); + dtMap.put("zdysql",zdysql); + dtMap.put("sjtj",sjtj); + dtMap.put("fzhsxlx",fzhsxlx); + dtMap.put("sfkmzd",sfkmzd); + dtMap.put("zdgz",zdgz); + dtMap.put("detailtable",detailtable); + dtMap.put("fieldName",fieldName.toLowerCase()); + if("".equals(fjdxh)){ + configInfoEntity.rootXmlConfigInfo = dtMap; + configInfoEntity.rootJsonConfigInfo.add(dtMap); + } + configInfoEntity.requestBodyConfigList.add(dtMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail3SQL sql execute error;sql:" + selectDetail3SQL); + throw new Exception("接口调用前获取明细3配置信息失败,请联系管理员!"); + } + + //获取明细表4 xml节点属性详细配置信息 + String selectDetail4SQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from " + CONFIG_TABLE_NAME + "_dt4 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail4SQL,mainConfigInfoId)){ + while(rs.next()){ + //属性名称 + String sxmc = Util.null2String(rs.getString("sxmc")); + //对应字段序号 + String dyzdxh = Util.null2String(rs.getString("dyzdxh")); + //表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //取值方式 + String zhgz = Util.null2String(rs.getString("zhgz")); + //字段归属 + String zdgz = Util.null2String(rs.getString("zdgz")); + //自定义sql + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace(Default_Line_Break,Default_Blank_Char); + zdysql = zdysql.replace(Default_Html_Blank,Default_Blank_Char); + zdysql = fullToHalfAngle(zdysql); + } + Map detailMap = new HashMap<>(); + detailMap.put("sxmc",sxmc); + detailMap.put("dyzdxh",dyzdxh); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("zhgz",zhgz); + detailMap.put("zdgz",zdgz); + detailMap.put("zdysql",zdysql); + detailMap.put("fieldName",fieldName.toLowerCase()); + detailMap.put("viewType",viewType); + detailMap.put("detailtable",detailtable); + configInfoEntity.xmlNodeAttrConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail4SQL sql execute error;sql:" + selectDetail4SQL); + throw new Exception("接口调用前获取明细4配置信息失败,请联系管理员!"); + } + + //获取明细表5 接口响应信息详细配置 + String selectDetail5SQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from " + CONFIG_TABLE_NAME + "_dt5 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?"; + if(rs.executeQuery(selectDetail5SQL,mainConfigInfoId)){ + while(rs.next()){ + //响应字段名称 + String xyzdmc = Util.null2String(rs.getString("xyzdmc")); + //响应字段父节点路径 + String xyzdfjdlj = Util.null2String(rs.getString("xyzdfjdlj")); + //回写流程表单字段 + String lcbdzd = Util.null2String(rs.getString("lcbdzd")); + //表单字段 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属明细表表名 + String detailtable = Util.null2String(rs.getString("detailtable")); + //流程表单字段类型 + String viewType = Util.null2String(rs.getString("viewType")); + //是否为成功失败标识字段 + String sfwcgsbbszd = Util.null2String(rs.getString("sfwcgsbbszd")); + //是否为提示信息字段 + String sftsxxzd = Util.null2String(rs.getString("sftsxxzd")); + //成功标识 + String cgbs = Util.null2String(rs.getString("cgbs")); + //失败标识 + String sbbs = Util.null2String(rs.getString("sbbs")); + Map detailMap = new HashMap<>(); + detailMap.put("xyzdmc",xyzdmc); + detailMap.put("xyzdfjdlj",xyzdfjdlj); + detailMap.put("lcbdzd",lcbdzd); + detailMap.put("sfwcgsbbszd",sfwcgsbbszd); + detailMap.put("cgbs",cgbs); + detailMap.put("sbbs",sbbs); + detailMap.put("fieldName",fieldName.toLowerCase()); + detailMap.put("viewType",viewType); + detailMap.put("sftsxxzd",sftsxxzd); + detailMap.put("detailtable",detailtable); + configInfoEntity.responseConfigList.add(detailMap); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId.selectDetail5SQL sql execute error;sql:" + selectDetail5SQL); + throw new Exception("接口调用前获取明细5配置信息失败,请联系管理员!"); + } + logger.info("DealWorkFlowDataToRequestUtil.getConfigurationByWorkflowId end;configInfo:" + configInfoEntity); + } + + /** + * 处理请求 - 处理响应 + * @param rs + * @param detailRs + * @throws Exception + */ + public void commonExecute(RecordSet rs,RecordSet detailRs) throws Exception { + logger.info("DealWorkFlowDataToRequestUtil.commonExecute begin"); + //请求地址处理 + dealUrl(rs,detailRs); + //请求头处理 + dealHeaders(rs,detailRs); + //请求报文处理 + dealRequestBody(rs,detailRs); + //发送请求 + sendRequest(); + //日志处理 + dealLog(rs); + //解析响应 + dealResponseInfo(detailRs,rs); + logger.info("DealWorkFlowDataToRequestUtil.commonExecute end"); + } + + /** + * 处理配置的接口地址,将参数转换为实际值 + * @param rs 数据库链接 + * @param detailRs 明细数据行 + */ + public void dealUrl(RecordSet rs,RecordSet detailRs) throws Exception { + if("".equals(configInfoEntity.callAddress)){ + logger.error("configInfoEntity.callAddress is empty"); + throw new Exception("接口地址未配置!"); + } + int index = configInfoEntity.callAddress.indexOf(PARAM_BEGIN); + if(configInfoEntity.callAddress.indexOf(PARAM_BEGIN) > -1){ + //截取配置的请求地址中的参数项 + String paramKey = configInfoEntity.callAddress.substring(index + 1,configInfoEntity.callAddress.indexOf(PARAM_END)); + //获取字段对应的配置信息 + Map configMap = new HashMap<>(); + for(Map configInfo:configInfoEntity.requestAddressConfigList){ + if(paramKey.equals(configInfo.get("csmc"))){ + configMap = configInfo; + break; + } + } + //获取实际值 + String value = getFieldValue(configMap,rs,detailRs); + //将配置的地址中的参数替换成实际值 + configInfoEntity.callAddress = configInfoEntity.callAddress.replaceAll("\\{"+paramKey+PARAM_END,value); + dealUrl(rs,detailRs); + }else{ + rarInfoEntity.callAddress = configInfoEntity.callAddress; + logger.info("DealWorkFlowDataToRequestUtil.dealUrl end;url:" + rarInfoEntity.callAddress); + } + } + + /** + * 生成请求头参数 + * @param rs + * @param detailRs 数据id 空表示从主表取数据 其余值表示明细表id + */ + public void dealHeaders(RecordSet rs,RecordSet detailRs){ + logger.info("DealWorkFlowDataToRequestUtil.dealHeaders begin"); + for(Map m : configInfoEntity.requestHeaderConfigList){ + String fieldValue = getFieldValue(m, rs, detailRs); + rarInfoEntity.headers.put(m.get("csmc"),fieldValue); + } + rarInfoEntity.headers.put("Charset","UTF-8"); + logger.info("DealWorkFlowDataToRequestUtil.dealHeaders end;headers:" + rarInfoEntity.headers); + } + + /** + * 生成请求报文 + * @param rs 数据库链接 + * @param detailRs 数据id + */ + public void dealRequestBody(RecordSet rs,RecordSet detailRs){ + logger.info("dealRequestBody begin;type:" + configInfoEntity.requestDataType); + //根据配置调用不同的方法生成相应报文 + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + recursionGenerateXML(null,null,rs,detailRs,0); + logger.info("recursionGenerateXML end;rarInfoEntity.xmlDoc:" + rarInfoEntity.xmlDoc.asXML()); + break; + case REQUEST_DATA_TYPE_JSON: + recursionGenerateJson(null,rs,detailRs,0); + logger.info("recursionGenerateJson end;rarInfoEntity.jsonDoc:" + rarInfoEntity.jsonDoc.toJSONString()); + break; + case REQUEST_DATA_TYPE_PAIR: + dealPairRequestData(rs,detailRs); + logger.info("dealPairRequestData end;rarInfoEntity.pairList:" + rarInfoEntity.pairList); + break; + case REQUEST_DATA_TYPE_MULTIPARTFILE: + dealMultipartFileRequestData(rs,detailRs); + logger.info("dealMultipartFileRequestData end;rarInfoEntity.multiPartFileInfos:" + rarInfoEntity.multiPartFileInfos); + break; + default: + break; + } + } + + /** + * 发送请求 获取响应信息 + * @throws Exception + */ + public void sendRequest() throws Exception { + logger.info("sendRequest begin;configInfoEntity.requestMethod:" + configInfoEntity.requestMethod + ";configInfoEntity.requestDataType:" + configInfoEntity.requestDataType); + CloseableHttpClient client = createSSLClientDefault(); + try{ + switch(configInfoEntity.requestMethod){ + case REQUEST_METHOD_GET: + HttpGet get = new HttpGet(rarInfoEntity.callAddress); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + get.setHeader(key,rarInfoEntity.headers.get(key)); + } + } + logger.info("client.execute begin"); + rarInfoEntity.response = client.execute(get); + break; + case REQUEST_METHOD_POST: + HttpPost post = new HttpPost(rarInfoEntity.callAddress); + //请求头设置 + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + post.setHeader(key,rarInfoEntity.headers.get(key)); + } + } + //请求信息设置 + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + StringEntity xmlEntity = new StringEntity(rarInfoEntity.xmlDoc.toString(), "UTF-8"); + post.setEntity(xmlEntity); + break; + case REQUEST_DATA_TYPE_JSON: + StringEntity jsonEntity = new StringEntity(rarInfoEntity.jsonDoc.toString(), "UTF-8"); + post.setEntity(jsonEntity); + break; + case REQUEST_DATA_TYPE_PAIR: + post.setEntity(new UrlEncodedFormEntity(rarInfoEntity.pairList, "UTF-8")); + break; + case REQUEST_DATA_TYPE_MULTIPARTFILE: + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(Charset.forName("utf-8")); + //加上此行代码解决返回中文乱码问题 + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + //文件流处理 + ImageFileManager imageFileManager = new ImageFileManager(); + for(Map map : rarInfoEntity.multiPartFileInfos){ + if(map != null){ + builder.addBinaryBody(map.get("xmljdmc"), imageFileManager.getInputStreamById(Integer.parseInt(map.get("imagefileid"))), ContentType.MULTIPART_FORM_DATA, map.get("imagefilename")); + } + } + HttpEntity entity = builder.build(); + post.setEntity(entity); + break; + default: + break; + } + logger.info("client.execute begin"); + rarInfoEntity.response = client.execute(post); + break; + default: + break; + } + //响应信息设置 + rarInfoEntity.responseCode = rarInfoEntity.response.getStatusLine().getStatusCode(); + logger.info("response code:" + rarInfoEntity.responseCode); + HttpEntity en = rarInfoEntity.response.getEntity(); + String content = EntityUtils.toString(en, "utf-8"); + logger.info("response entity:" + content); + switch (configInfoEntity.responseDataType){ + case RESPONSE_DATA_TYPE_XML: + rarInfoEntity.responseXml = DocumentHelper.parseText(content); + break; + case RESPONSE_DATA_TYPE_JSON: + rarInfoEntity.responseJson = JSONObject.parseObject(content); + break; + default: + rarInfoEntity.responseString = content; + break; + } + }catch(Exception e){ + logger.error("DealWorkFlowDataToRequestUtil.sendRequest exception;url:"+rarInfoEntity.callAddress+";info:"+e.getMessage()+";e"+e); + rarInfoEntity.responseCode = 91919; + rarInfoEntity.resultValue = CALL_FAILED; + }finally { + client.close(); + } + } + + /** + * 记录日志 + * @param rs + */ + public void dealLog(RecordSet rs){ + logger.info("dealLog begin"); + try{ + if("".equals(configInfoEntity.logTableName) || "".equals(configInfoEntity.logRequestIdFieldName)){ + return; + } + //查询modeid + int modeId = -1; + String getModeIdSql = "select t1.id from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid " + + " where t2.tablename = '" + configInfoEntity.logTableName + "' and t1.isdelete = 0"; + if(rs.executeQuery(getModeIdSql)){ + if(rs.next()){ + modeId = Util.getIntValue(rs.getString("id"),0); + }else{ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.getModeIdSql execute success but found nothing;sql:" + getModeIdSql); + } + }else{ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.getModeIdSql execute error;sql:" + getModeIdSql); + } + if(modeId == -1){ + return; + } + //日志表新增记录 + int dataId = -1; + dataId = mdu.getModeDataNewId(configInfoEntity.logTableName, modeId, 1, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString()); + + //设置请求头 + String requestHeaderString = ""; + if(rarInfoEntity.headers != null && rarInfoEntity.headers.size() > 0){ + for(String key:rarInfoEntity.headers.keySet()){ + requestHeaderString = requestHeaderString + key + ":" + rarInfoEntity.headers.get(key) + "\n"; + } + } + //设置请求数据 + String requestString = ""; + switch(configInfoEntity.requestDataType){ + case REQUEST_DATA_TYPE_XML: + requestString = requestString + rarInfoEntity.xmlDoc.asXML(); + break; + case REQUEST_DATA_TYPE_JSON: + requestString = requestString + rarInfoEntity.jsonDoc.toString(); + break; + case REQUEST_DATA_TYPE_PAIR: + requestString = requestString + rarInfoEntity.pairList.toString(); + break; + default: + break; + } + + //设置响应数据 + String responseString = ""; + switch (configInfoEntity.responseDataType){ + case RESPONSE_DATA_TYPE_XML: + responseString = rarInfoEntity.responseXml.asXML(); + break; + case RESPONSE_DATA_TYPE_JSON: + responseString = rarInfoEntity.responseJson.toString(); + break; + default: + responseString = rarInfoEntity.responseString; + break; + } + if(rarInfoEntity.responseCode == 9999){ + responseString = rarInfoEntity.responseString; + } + //更新日志表记录 + String updateLogTableSql = "update " + configInfoEntity.logTableName + " set " + + configInfoEntity.logRequestIdFieldName + " = " + baseArray[0] + + "," + configInfoEntity.logResponseStatusFieldName + " = ? " + + "," + configInfoEntity.logRequestBodyFieldName + " = ? " + + "," + configInfoEntity.logResponseBodyFieldName + " = ? " + + "," + configInfoEntity.logRequestAddressFieldName + " = ? " + + "," + configInfoEntity.logRequestHeaderFieldName + " = ? " + + " where id = " + dataId; + if(!rs.executeUpdate(updateLogTableSql,rarInfoEntity.responseCode,requestString,responseString,rarInfoEntity.callAddress,requestHeaderString)){ + logger.error("DealWorkFlowDataToRequestUtil.dealLog.updateLogTableSql execute error;sql:" + updateLogTableSql); + } + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modeId,dataId); + logger.info("dealLog end"); + }catch(Exception e){ + logger.error("DealWorkFlowDataToRequestUtil.dealLog execute error;requestId:" + baseArray[0] + "exception:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 解析响应信息 回写表单字段 + * @param detailRs + * @param rs + */ + public void dealResponseInfo(RecordSet detailRs,RecordSet rs){ + logger.info("dealResponseInfo begin;configInfoEntity.responseDataType:" + configInfoEntity.responseDataType); + for(Map m : configInfoEntity.responseConfigList){ + //获取响应信息字段的值 + String value = ""; + switch (configInfoEntity.responseDataType){ + case REQUEST_DATA_TYPE_XML: + value = rarInfoEntity.responseXml.selectSingleNode(m.get("xyzdfjdlj")).getText(); + break; + case REQUEST_DATA_TYPE_JSON: + value = getJsonValueByPath(rarInfoEntity.responseJson,m.get("xyzdfjdlj")); + break; + default: + logger.error("configInfoEntity.responseDataType did not config!"); + break; + } + //将响应值回写表单字段 + if(!"".equals(m.get("fieldName"))){ + String updateDataSql = ""; + if(configInfoEntity.callType.equals(CALL_TYPE_ONLY_ONE)){ + updateDataSql = "update " + baseArray[3] + " set " + m.get("fieldName") + " = ? where id = " + baseArray[4]; + if(!rs.executeUpdate(updateDataSql,value)){ + logger.error("DealWorkFlowDataToRequestUtil.dealResponseInfo.updateDataSql execute error;sql:" + updateDataSql); + } + }else{ + updateDataSql = "update " + baseArray[3] + "_dt" + configInfoEntity.detailTableIndex + " set " + m.get("fieldName") + " = ? where id = " + Util.null2String(detailRs.getString("id")); + if(!rs.executeUpdate(updateDataSql)){ + logger.error("DealWorkFlowDataToRequestUtil.dealResponseInfo.updateDataSql execute error;sql:" + updateDataSql); + } + } + } + //设置成功失败标识字段的值 + if(SELECT_TYPE_IS.equals(m.get("sfwcgsbbszd"))){ + if(!"".equals(m.get("cgbs"))){ + if(m.get("cgbs").equals(value)){ + rarInfoEntity.resultValue = CALL_SUCCESS; + }else{ + rarInfoEntity.resultValue = CALL_FAILED; + } + } + if(!"".equals(m.get("sbbs"))){ + if(m.get("cgbs").equals(value)){ + rarInfoEntity.resultValue = CALL_FAILED; + }else{ + rarInfoEntity.resultValue = CALL_SUCCESS; + } + } + } + //设置提示信息 + if(SELECT_TYPE_IS.equals(m.get("sftsxxzd"))){ + rarInfoEntity.responseMessage = value; + } + } + logger.info("dealResponseInfo end;rarInfoEntity.resultValue:" + rarInfoEntity.resultValue + ";rarInfoEntity.responseMessage:" + rarInfoEntity.responseMessage); + } + + /** + * 根据配置信息 生成请求的键值对参数 + * @param rs + */ + public void dealPairRequestData(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestBodyConfigList){ + rarInfoEntity.pairList.add(new BasicNameValuePair(m.get("xmljdmc"),getFieldValue(m,rs,detailRs))); + } + } + + /** + * 根据配置信息 生成文件参数 + * @param rs + */ + public void dealMultipartFileRequestData(RecordSet rs,RecordSet detailRs){ + for(Map m : configInfoEntity.requestBodyConfigList){ + String docIds = getFieldValue(m,rs,detailRs); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArray = docIds.split(","); + for(String docId:docIdArray){ + if(docId != null && !"".equals(docId)){ + String getFileInfoSql = + "select " + + "t3.imagefileid as imagefileid," + + "t3.imagefilename as imagefilename " + + "from " + + "docdetail t1 " + + "inner join DocImageFile t2 on t2.docid = t1.id " + + "inner join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "where " + + "t1.id = ?"; + if(rs.executeQuery(getFileInfoSql,docId)){ + while(rs.next()){ + Map map = setRsToMap(rs); + map.put("xmljdmc",m.get("xmljdmc")); + rarInfoEntity.multiPartFileInfos.add(map); + } + }else{ + logger.error("getFileInfoSql error;getFileInfoSql:" + getFileInfoSql + ";docId:" + docId); + } + } + } + } + } + } + + /** + * 递归生成json报文 + * @param configMap + * @param rs + * @param detailRs + * @param sequence + * @return + */ + public Object recursionGenerateJson(Map configMap,RecordSet rs, + RecordSet detailRs,int sequence){ + if(configMap == null){ + for(Map configInfo:configInfoEntity.rootJsonConfigInfo){ + rarInfoEntity.jsonDoc.put(configInfo.get("xmljdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence)); + } + }else{ + switch(configMap.get("xmljdlx")){ + case NODE_TYPE_STRING: + configMap.put("detailRowNum", String.valueOf(sequence)); + String value = getFieldValue(configMap,rs,detailRs); + return value; + case NODE_TYPE_BOOLEAN: + configMap.put("detailRowNum", String.valueOf(sequence)); + if("true".equals(getFieldValue(configMap,rs,detailRs))){ + return true; + }else{ + return false; + } + case NODE_TYPE_NUMBER: + configMap.put("detailRowNum", String.valueOf(sequence)); + int r = 0; + try{ + r = Integer.parseInt(getFieldValue(configMap,rs,detailRs)); + }catch(Exception e){ + logger.error("change data to int error;configMap:" + configMap + ";e:" + e); + } + return r; + case NODE_TYPE_FLOAT: + double d = 0; + try{ + configMap.put("detailRowNum", String.valueOf(sequence)); + String f = getFieldValue(configMap,rs,detailRs); + d = Double.parseDouble(f); + }catch(Exception e){ + logger.error("change data to float error;configMap:" + configMap + ";e:" + e); + } + return d; + case NODE_TYPE_OBJECT: + JSONObject json = new JSONObject(); + for(Map m : configInfoEntity.requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("xmljdxh"))) { + json.put(m.get("xmljdmc"),recursionGenerateJson(m,rs,detailRs,sequence)); + } + } + return json; + case NODE_TYPE_JSONSTRING: + JSONObject jsonObj = new JSONObject(); + for(Map m : configInfoEntity.requestBodyConfigList) { + if (m.get("fjdxh").equals(configMap.get("xmljdxh"))) { + jsonObj.put(m.get("xmljdmc"),recursionGenerateJson(m,rs,detailRs,sequence)); + } + } + return jsonObj.toString(); + case NODE_TYPE_STRING_ARRAY: + String stringArrayValue = getFieldValue(configMap,rs,detailRs); + JSONArray stringArray = new JSONArray(); + for(String v : stringArrayValue.split(",")){ + stringArray.add(v); + } + return stringArray; + case NODE_TYPE_ARRAY: + JSONArray array = new JSONArray(); + if("".equals(configMap.get("zdgz")) && CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){ + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + array.add(recursionGenerateJson(son,rs,detailRs,sequence)); + } + } + return array; + } + if("".equals(configMap.get("zdgz"))){ + JSONObject o = new JSONObject(); + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + o.put(son.get("xmljdmc"),recursionGenerateJson(son,rs,detailRs,sequence)); + } + } + array.add(o); + return array; + } + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(configMap.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + JSONObject o = new JSONObject(); + sequence = sequence + 1; + for(Map son : configInfoEntity.requestBodyConfigList) { + if (son.get("fjdxh").equals(configMap.get("xmljdxh"))) { + o.put(son.get("xmljdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence)); + } + } + array.add(o); + } + } + return array; + default: + break; + } + } + return null; + } + + /** + * 生成父节点的所有下级节点 + * @param parentMap 父节点的配置信息 + * @param parentNode 父节点对象 + * @param rs 数据库链接 + * @param detailRs 明细表数据id + * @param sequence 明细序列号 + */ + public void recursionGenerateXML(Map parentMap,Element parentNode,RecordSet rs, + RecordSet detailRs,int sequence){ + if(parentNode == null){ + Element root = rarInfoEntity.xmlDoc.addElement(configInfoEntity.rootXmlConfigInfo.get("xmljdmc")); + setElementAttribute(detailRs,rs,root, configInfoEntity.rootXmlConfigInfo); + recursionGenerateXML(configInfoEntity.rootXmlConfigInfo,root,rs,detailRs,0); + }else{ + //查找parentNode的所有子节点 + for(Map m : configInfoEntity.requestBodyConfigList){ + if(m.get("fjdxh").equals(parentMap.get("xmljdxh"))){ + switch(m.get("xmljdlx")){ + case NODE_TYPE_STRING: + Element ele = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailRs,rs,ele,m); + m.put("detailRowNum", String.valueOf(sequence)); + String value = getFieldValue(m,rs,detailRs); + ele.setText(value); + break; + case NODE_TYPE_OBJECT: + Element objEle = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailRs,rs,objEle,m); + recursionGenerateXML(m,objEle,rs,detailRs,sequence); + break; + case NODE_TYPE_ARRAY: + //查询明细表数据 + String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + m.get("zdgz") + " where mainid = " + baseArray[4]; + if(!"".equals(m.get("sjtj"))){ + getDetailDataSql = getDetailDataSql + " " + m.get("sjtj"); + } + RecordSet detailDataRs = new RecordSet(); + if(detailDataRs.executeQuery(getDetailDataSql)){ + sequence = 0; + while(detailDataRs.next()){ + sequence = sequence + 1; + Element arrayEle = parentNode.addElement(m.get("xmljdmc")); + setElementAttribute(detailDataRs,rs,arrayEle,m); + recursionGenerateXML(m,arrayEle,rs,detailDataRs,sequence); + } + } + break; + default: + break; + } + } + } + } + } + + + /** + * 返回CloseableHttpClient 如果接口为https协议 信任所有证书 + * @return + * @throws MalformedURLException + */ + public CloseableHttpClient createSSLClientDefault() throws MalformedURLException { + URL url = new URL(rarInfoEntity.callAddress); + String protocol = url.getProtocol(); + if("https".equals(protocol)){ + try { + //使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书 + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { + return true; + } + }).build(); + //NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何 + //有效的SSL会话并匹配到目标主机。 + HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return build; + } catch (Exception e) { + logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e); + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + }else{ + CloseableHttpClient aDefault = HttpClients.createDefault(); + return aDefault; + } + } + + private static final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + + private static final HostnameVerifier NOT_VERYFY = new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; + + /** + * 根据明细表3中的配置获取xml节点的属性 + * @param detailRs 明细表数据id + * @param rs 数据库链接 + * @param element xml节点 + * @param map 字段配置信息 + */ + public void setElementAttribute(RecordSet detailRs,RecordSet rs,Element element,Map map){ + //根据节点序号在明细配置中找到对应的配置项 并生成属性 + for(Map configInfo : configInfoEntity.xmlNodeAttrConfigList){ + if(configInfo.get("dyzdxh").equals(map.get("xmljdxh"))){ + String value = getFieldValue(configInfo,rs,detailRs); + element.addAttribute(configInfo.get("sxmc"),value); + } + } + } + + /** + * 获取字段实际值 + * @param configMap 配置信息,包含字段归属、字段名称、转换规则等 + * @param rs 数据库链接 + * @param detailRs 明细表数据 + * @return + */ + public String getFieldValue(Map configMap,RecordSet rs,RecordSet detailRs){ + //函数返回值 + String result = ""; + try{ + Map detailDataMap = setRsToMap(detailRs); + //字段类型 0-主表 1-明细表 + String viewType = configMap.get("viewType"); + //转换规则 + String zhgz = configMap.get("zhgz"); + //字段名称 + String fieldName = configMap.get("fieldName"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //数据条件 + String sjtj = configMap.get("sjtj"); + //字段所属明细表表名 + String detailtable = configMap.get("detailtable"); + //不同转换规则处理 + switch(zhgz){ + case CHANGE_TYPE_REQUEST_ID: + result = baseArray[0]; + break; + case CHANGE_TYPE_REQUEST_NAME: + result = baseArray[1]; + break; + case CHANGE_TYPE_MD5: + result = "Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes()); + break; + case CHANGE_TYPE_SUGGESTION: + result = baseArray[2]; + break; + case CHANGE_TYPE_ROW_NUMBER: + result = configMap.get("detailRowNum"); + break; + case CHANGE_TYPE_FIXED: + result = configMap.get("zdysql"); + break; + case CHANGE_TYPE_NONE: + if("0".equals(viewType)){ + result = mainTableData.get(fieldName); + }else{ + result = detailDataMap.get(fieldName); + } + break; + case CHANGE_TYPE_SQL: + String oldValue = ""; + if(!"".equals(viewType) && !"".equals(fieldName)){ + if("0".equals(viewType)){ + oldValue = mainTableData.get(fieldName); + }else{ + oldValue = detailDataMap.get(fieldName); + } + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + } + zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + } + } + break; + case CHANGE_TYPE_SUM: + if("0".equals(viewType)){ + logger.error("want sum but config main field"); + break; + } + String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getSumSql = getSumSql + " " + sjtj; + } + if(rs.executeQuery(getSumSql)){ + if(rs.next()){ + result = Util.null2String(rs.getString("val")); + } + } + break; + case CHANGE_TYPE_STRING_ARRAY: + if("0".equals(viewType)){ + logger.error("want array but config main field"); + break; + } + String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4]; + if(!"".equals(sjtj)){ + getArraySql = getArraySql + " " + sjtj; + } + if(rs.executeQuery(getArraySql)){ + int i = 0; + while(rs.next()){ + if(i == 0){ + result = Util.null2String(rs.getString(1)); + }else{ + result = result + "," + Util.null2String(rs.getString(1)); + } + i = i + 1; + } + } + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public RecordSetTrans getRsts() { + return rsts; + } + + public void setRsts(RecordSetTrans rsts) { + this.rsts = rsts; + } + + public String[] getBaseArray() { + return baseArray; + } + + public void setBaseArray(String[] baseArray) { + this.baseArray = baseArray; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/dianzhuang/cronjob/UpdateHrmSecuLvCronJob.java b/src/main/jinwei_tao_old_src/weaver/taojw/dianzhuang/cronjob/UpdateHrmSecuLvCronJob.java new file mode 100644 index 0000000..5e035eb --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/dianzhuang/cronjob/UpdateHrmSecuLvCronJob.java @@ -0,0 +1,66 @@ +package weaver.taojw.dianzhuang.cronjob; + +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.logging.MyLogger; + +public class UpdateHrmSecuLvCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + @Override + public void execute() { + try { + logger.info("UpdateHrmSecuLvCronJob begin"); + RecordSet rs = new RecordSet(); + String dmcfId = ""; + String getFbIdSql = "select id from HrmSubCompany where subcompanyname = 'DMCF'"; + if(rs.executeQuery(getFbIdSql)){ + if(rs.next()){ + dmcfId = Util.null2String(rs.getString("id")); + }else{ + logger.error("getFbIdSql find nothing;sql:" + getFbIdSql); + } + }else{ + logger.error("getFbIdSql error;sql:" + getFbIdSql); + } + logger.info("dmcfId:" + dmcfId); + + String getToUpdatePeopleSql = + "select " + + "t1.id,t2.field0,t3.aqjb " + + "from " + + "hrmresource t1 " + + "inner join cus_fielddata t2 on t2.id = t1.id and t2.scopeid = -1 and t2.scope = 'HrmCustomFieldByInfoType' " + + "inner join uf_cljbb t3 on t3.dygwjbhzwmc = t2.field0 " + + "where " + + "t2.field0 != '' " + + "and t2.field0 is not null " + + "and t3.gsmc = ? " + + "and t1.subcompanyid1 = ? " + + "and t3.dygwjbhzwmc is not null " + + "and t3.dygwjbhzwmc != '' "; + String updateSeecurityLvSql = "update hrmresource set seclevel = ? where id = ?"; + RecordSet detailRs = new RecordSet(); + if(rs.executeQuery(getToUpdatePeopleSql,dmcfId,dmcfId)){ + while(rs.next()){ + if(!"".equals(Util.null2String(rs.getString("field0")))){ + if(rs.getString("aqjb") != null && !"".equals(rs.getString("aqjb"))){ + if(!detailRs.executeUpdate(updateSeecurityLvSql,Util.null2String(rs.getString("aqjb")),Util.null2String(rs.getString("id")))){ + logger.error("UpdateHrmSecuLvCronJob.execute getToUpdatePeopleSql error;getToUpdatePeopleSql:" + getToUpdatePeopleSql); + } + } + } + } + }else{ + logger.error("UpdateHrmSecuLvCronJob.execute getToUpdatePeopleSql error;getToUpdatePeopleSql:" + getToUpdatePeopleSql); + } + logger.info("UpdateHrmSecuLvCronJob done"); + } catch (Exception e) { + logger.error("UpdateHrmSecuLvCronJob.execute exception;e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/action/UpdateOANumberAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/action/UpdateOANumberAction.java new file mode 100644 index 0000000..c11c078 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/action/UpdateOANumberAction.java @@ -0,0 +1,256 @@ +package weaver.taojw.jinghe.action; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.WorkFlowDataToJsonUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.jinghe.webservice.WSCasPaybillFacadeSoapBindingStub; +import weaver.taojw.jinghe.webservice.WSCasPaybillFacadeSrvProxyServiceLocator; +import weaver.taojw.jinghe.wxr.webservice.EASLoginProxyServiceLocator; +import weaver.taojw.jinghe.wxr.webservice.EASLoginSoapBindingStub; +import weaver.taojw.jinghe.wxr.webservice.WSContext; +import java.net.URL; +import java.util.Map; + +/** + * 锦和 + * 文档代扣代缴OA单号更新 + */ +public class UpdateOANumberAction implements Action { + + private String easNumberConfigId = ""; + private String oaNumberConfigId = ""; + private String errorMessage = ""; + private String updateOANumberUrl = ""; + //登录接口地址 + private String loginUrl; + //登录相关配置 + private String loginUserName = ""; + private String loginPassWord = ""; + private String loginSinName = ""; + private String loginDcName = ""; + private String loginLanguage = ""; + private String loginDbType = ""; + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String response = ""; + JSONObject easNumberInfo = new JSONObject(); + JSONObject oaNumberInfo = new JSONObject(); + try{ + RecordSet rs = new RecordSet(); + if("".equals(updateOANumberUrl) || updateOANumberUrl == null){ + updateOANumberUrl = CommonSqlUtil.getSystemParamValue("updateOANumberUrl",rs); + } + if("".equals(errorMessage) || errorMessage == null){ + errorMessage = CommonSqlUtil.getSystemParamValue("errorMessage",rs); + } + if("".equals(loginUrl) || loginUrl == null){ + loginUrl = CommonSqlUtil.getSystemParamValue("loginUrl",rs); + } + if("".equals(loginUserName) || loginUserName == null){ + loginUserName = CommonSqlUtil.getSystemParamValue("loginUserName",rs); + } + if("".equals(loginPassWord) || loginPassWord == null){ + loginPassWord = CommonSqlUtil.getSystemParamValue("loginPassWord",rs); + } + if("".equals(loginSinName) || loginSinName == null){ + loginSinName = CommonSqlUtil.getSystemParamValue("loginSinName",rs); + } + if("".equals(loginDcName) || loginDcName == null){ + loginDcName = CommonSqlUtil.getSystemParamValue("loginDcName",rs); + } + if("".equals(loginLanguage) || loginLanguage == null){ + loginLanguage = CommonSqlUtil.getSystemParamValue("loginLanguage",rs); + } + if("".equals(loginDbType) || loginDbType == null){ + loginDbType = CommonSqlUtil.getSystemParamValue("loginDbType",rs); + } + + logger.info("UpdateDocAction begin;requestId:" + requestId + ";easNumberConfigId:" + easNumberConfigId + ";oaNumberConfigId:" + oaNumberConfigId); + //--------------------------------------------------------------------------------------调用客户端代码,登录 + try{ + URL url = new URL(loginUrl); + EASLoginProxyServiceLocator loginLocator = new EASLoginProxyServiceLocator(); + EASLoginSoapBindingStub easLoginStub = new EASLoginSoapBindingStub(url, loginLocator); + WSContext wsContext = easLoginStub.login(loginUserName, loginPassWord, loginSinName, loginDcName, loginLanguage, Integer.parseInt(loginDbType)); + String sessionId = wsContext.getSessionId(); + if(StringUtils.isBlank(sessionId)){ + logger.info("loginUserName:" + loginUserName + ";loginPassWord:" + loginPassWord + ";loginSinName:" + loginSinName + ";loginDcName:" + loginDcName + ";loginLanguage:" + loginLanguage + ";loginDbType:" + loginDbType); + logger.error("GetBillStateCronJob.login error"); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid("202210240899231"); + requestInfo.getRequestManager().setMessagecontent("updateOaNumber接口异常,requestId:"+ requestInfo.getRequestid() +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + logger.info("sessionId:" + sessionId); + }catch(Exception e){ + logger.info("loginUserName:" + loginUserName + ";loginPassWord:" + loginPassWord + ";loginSinName:" + loginSinName + ";loginDcName:" + loginDcName + ";loginLanguage:" + loginLanguage + ";loginDbType:" + loginDbType); + logger.error("GetBillStateCronJob.login exception;message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid("202210240899211"); + requestInfo.getRequestManager().setMessagecontent("updateOaNumber接口异常,requestId:"+ requestInfo.getRequestid() +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + //--------------------------------------------------------------------------------------调用银行付款状态查询接口 + URL wbUrl = new URL(updateOANumberUrl); + WSCasPaybillFacadeSrvProxyServiceLocator locator = new WSCasPaybillFacadeSrvProxyServiceLocator(); + WSCasPaybillFacadeSoapBindingStub stub = new WSCasPaybillFacadeSoapBindingStub(wbUrl,locator); + // + //流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值] + String[] base_array = new String[5]; + //流程表单名称 + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //获取请求中的数据库链接 + RecordSetTrans rsts = requestInfo.getRsTrans(); + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + String select_base_sql = "select * from workflow_requestBase where requestId = ?"; + String requestName = ""; + String requestMark = requestInfo.getRequestManager().getRemark(); + if(rsts.executeQuery(select_base_sql,requestId)){ + while(rsts.next()){ + requestName = Util.null2String(rsts.getString("requestName")); + } + } + base_array[0] = requestId; + base_array[1] = requestName; + base_array[2] = requestMark; + base_array[3] = billTableName; + String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?"; + Map firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId); + if(firstData.size() > 0){ + base_array[4] = firstData.get("id"); + } + } catch (Exception e) { + requestInfo.getRequestManager().setMessageid("2022052791002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + easNumberInfo = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId, easNumberConfigId, base_array); + oaNumberInfo = WorkFlowDataToJsonUtil.getJsonByWorkFlowData(requestId, oaNumberConfigId, base_array); + + response = stub.updateOANumber(easNumberInfo.toJSONString(),oaNumberInfo.toJSONString()); + JSONObject responseJson = JSONObject.parseObject(response); + String result = responseJson.getString("result"); + if(!"SUCCESS".equals(result)){ + logger.error("response:" + response + ";easNumber:" + easNumberInfo.toJSONString() + ";oaNumber:" + oaNumberInfo.toJSONString()); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid("20221024162309"); + requestInfo.getRequestManager().setMessagecontent(errorMessage); + return Action.FAILURE_AND_CONTINUE; + }else{ + logger.error("response:" + response + ";easNumber:" + easNumberInfo.toJSONString() + ";oaNumber:" + oaNumberInfo.toJSONString()); + return Action.SUCCESS; + } + }catch(Exception e){ + logger.error("response:" + response + ";easNumber:" + easNumberInfo.toJSONString() + ";oaNumber:" + oaNumberInfo.toJSONString()); + logger.error("UpdateDocAction exception;requestId:" + requestId + ";message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid("202210240899201"); + requestInfo.getRequestManager().setMessagecontent(errorMessage); + return Action.FAILURE_AND_CONTINUE; + } + } + + public String getEasNumberConfigId() { + return easNumberConfigId; + } + + public void setEasNumberConfigId(String easNumberConfigId) { + this.easNumberConfigId = easNumberConfigId; + } + + public String getOaNumberConfigId() { + return oaNumberConfigId; + } + + public void setOaNumberConfigId(String oaNumberConfigId) { + this.oaNumberConfigId = oaNumberConfigId; + } + + public String getUpdateOANumberUrl() { + return updateOANumberUrl; + } + + public void setUpdateOANumberUrl(String updateOANumberUrl) { + this.updateOANumberUrl = updateOANumberUrl; + } + + public String getLoginUrl() { + return loginUrl; + } + + public void setLoginUrl(String loginUrl) { + this.loginUrl = loginUrl; + } + + public String getLoginUserName() { + return loginUserName; + } + + public void setLoginUserName(String loginUserName) { + this.loginUserName = loginUserName; + } + + public String getLoginPassWord() { + return loginPassWord; + } + + public void setLoginPassWord(String loginPassWord) { + this.loginPassWord = loginPassWord; + } + + public String getLoginSinName() { + return loginSinName; + } + + public void setLoginSinName(String loginSinName) { + this.loginSinName = loginSinName; + } + + public String getLoginDcName() { + return loginDcName; + } + + public void setLoginDcName(String loginDcName) { + this.loginDcName = loginDcName; + } + + public String getLoginLanguage() { + return loginLanguage; + } + + public void setLoginLanguage(String loginLanguage) { + this.loginLanguage = loginLanguage; + } + + public String getLoginDbType() { + return loginDbType; + } + + public void setLoginDbType(String loginDbType) { + this.loginDbType = loginDbType; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/cronjob/GetBillStateCronJob.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/cronjob/GetBillStateCronJob.java new file mode 100644 index 0000000..fd2940e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/cronjob/GetBillStateCronJob.java @@ -0,0 +1,329 @@ +package weaver.taojw.jinghe.cronjob; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.jinghe.webservice.WSCasPaybillFacadeSoapBindingStub; +import weaver.taojw.jinghe.webservice.WSCasPaybillFacadeSrvProxyServiceLocator; +import weaver.taojw.jinghe.wxr.webservice.EASLoginProxyServiceLocator; +import weaver.taojw.jinghe.wxr.webservice.EASLoginSoapBindingStub; +import weaver.taojw.jinghe.wxr.webservice.WSContext; +import weaver.workflow.webservices.WorkflowService; +import weaver.workflow.webservices.WorkflowServiceImpl; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 锦和 + * 定时任务调接口 从接口响应信息里匹配到具体某一条流程,然后根据响应信息 来提交或退回流程 + */ +public class GetBillStateCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + //配置表数据id + private String configDataId = ""; + //查询接口地址 + private String getBillStateUrl = ""; + //登录接口地址 + private String loginUrl; + //登录相关配置 + private String loginUserName = ""; + private String loginPassWord = ""; + private String loginSinName = ""; + private String loginDcName = ""; + private String loginLanguage = ""; + private String loginDbType = ""; + + //查询最近几天的记录的天数 + private String days = ""; + + private String df = "yyyy-MM-dd"; + + @Override + public void execute() { + try { + logger.info("GetBillStateCronJob begin;loginUrl:" + loginUrl + ";configDataId:" + configDataId + ";getBillStateUrl:" + getBillStateUrl + ";days:" + days); + + if(loginUserName == null){ + loginUserName = ""; + } + if(loginPassWord == null){ + loginPassWord = ""; + } + if(loginSinName == null || "".equals(loginSinName)){ + loginSinName = "eas"; + } + if(loginDcName == null || "".equals(loginDcName)){ + loginDcName = "eas"; + } + if(loginLanguage == null || "".equals(loginLanguage)){ + loginLanguage = "l2"; + } + if(loginDbType == null || "".equals(loginDbType)){ + loginDbType = "2"; + } + + //--------------------------------------------------------------------------------------调用客户端代码,登录 + try{ + URL url = new URL(loginUrl); + EASLoginProxyServiceLocator loginLocator = new EASLoginProxyServiceLocator(); + EASLoginSoapBindingStub easLoginStub = new EASLoginSoapBindingStub(url, loginLocator); + WSContext wsContext = easLoginStub.login(loginUserName, loginPassWord, loginSinName, loginDcName, loginLanguage, Integer.parseInt(loginDbType)); + String sessionId = wsContext.getSessionId(); + if(StringUtils.isBlank(sessionId)){ + logger.info("loginUserName:" + loginUserName + ";loginPassWord:" + loginPassWord + ";loginSinName:" + loginSinName + ";loginDcName:" + loginDcName + ";loginLanguage:" + loginLanguage + ";loginDbType:" + loginDbType); + logger.error("GetBillStateCronJob.login error"); + return; + } + logger.info("sessionId:" + sessionId); + }catch(Exception e){ + logger.info("loginUserName:" + loginUserName + ";loginPassWord:" + loginPassWord + ";loginSinName:" + loginSinName + ";loginDcName:" + loginDcName + ";loginLanguage:" + loginLanguage + ";loginDbType:" + loginDbType); + logger.error("GetBillStateCronJob.login exception;message:" + e.getMessage() + ";e:" + e); + return; + } + + String[] configIdArr = configDataId.split(","); + for(String confgiId : configIdArr){ + //-------------------------------------------------------------------------获取配置信息 + Map mainConfigInfo = new HashMap<>(); + RecordSet rs = new RecordSet(); + String getConfigSql = + "select " + + "t1.lclx,t1.xyxxzdjbhzd,t1.lcbdzdjbhzd,t1.xyxxzcgsbbszd,t1.tjlcdbs,t1.thlcdbs,t1.xycldjd,t1.lcbdzcfxyxxdzdmc, " + + "wb.fieldName " + + "from " + + "uf_jhyhfkztjkpz t1 " + + "left join workflow_billField wb on t1.lcbdzdjbhzd = wb.id " + + "where " + + "t1.id = ?"; + if(rs.executeQuery(getConfigSql,confgiId)){ + while(rs.next()){ + mainConfigInfo.put("lclx",Util.null2String(rs.getString("lclx"))); + mainConfigInfo.put("xyxxzdjbhzd",Util.null2String(rs.getString("xyxxzdjbhzd"))); + mainConfigInfo.put("lcbdzdjbhzd",Util.null2String(rs.getString("lcbdzdjbhzd"))); + mainConfigInfo.put("xyxxzcgsbbszd",Util.null2String(rs.getString("xyxxzcgsbbszd"))); + mainConfigInfo.put("tjlcdbs",Util.null2String(rs.getString("tjlcdbs"))); + mainConfigInfo.put("thlcdbs",Util.null2String(rs.getString("thlcdbs"))); + mainConfigInfo.put("fieldName",Util.null2String(rs.getString("fieldName"))); + mainConfigInfo.put("xycldjd",Util.null2String(rs.getString("xycldjd"))); + mainConfigInfo.put("lcbdzcfxyxxdzdmc",Util.null2String(rs.getString("lcbdzcfxyxxdzdmc"))); + } + }else{ + logger.error("GetBillStateCronJob.sql error;sql:" + getConfigSql + ";"); + return; + } + logger.info("mainConfigInfo:" + mainConfigInfo + ";"); + //--------------------------校验配置信息 + if( + "".equals(mainConfigInfo.get("lclx")) || mainConfigInfo.get("lclx") == null || + "".equals(mainConfigInfo.get("xyxxzdjbhzd")) || mainConfigInfo.get("xyxxzdjbhzd") == null || + "".equals(mainConfigInfo.get("lcbdzdjbhzd")) || mainConfigInfo.get("lcbdzdjbhzd") == null || + "".equals(mainConfigInfo.get("xyxxzcgsbbszd")) || mainConfigInfo.get("xyxxzcgsbbszd") == null || + "".equals(mainConfigInfo.get("tjlcdbs")) || mainConfigInfo.get("tjlcdbs") == null || + //"".equals(mainConfigInfo.get("thlcdbs")) || mainConfigInfo.get("thlcdbs") == null || + "".equals(mainConfigInfo.get("fieldName")) || mainConfigInfo.get("fieldName") == null || + "".equals(mainConfigInfo.get("lcbdzcfxyxxdzdmc")) || mainConfigInfo.get("lcbdzcfxyxxdzdmc") == null || + "".equals(mainConfigInfo.get("xycldjd")) || mainConfigInfo.get("xycldjd") == null + ){ + logger.error("miss config info!"); + return; + } + + //--------------------------------------------------------------------------------------调用银行付款状态查询接口 + URL wbUrl = new URL(getBillStateUrl); + WSCasPaybillFacadeSrvProxyServiceLocator locator = new WSCasPaybillFacadeSrvProxyServiceLocator(); + WSCasPaybillFacadeSoapBindingStub stub = new WSCasPaybillFacadeSoapBindingStub(wbUrl,locator); + Date now = new Date(); + for(int x = Integer.parseInt(days);x <= 0; x++){ + String date = getBeforeOrAfterDate(now,x); + String response = stub.getBillState("", "", date); + try{ + JSONObject responseJson = JSONObject.parseObject(response); + String result = responseJson.getString("result"); + if(!"SUCCESS".equals(result)){ + logger.error("deal response error;date:"+date+";response:" + response); + continue; + } + //查询流程表单表名 + String billTableName = CommonSqlUtil.getTableNameByWorkflowId(mainConfigInfo.get("lclx"), rs); + mainConfigInfo.put("billTableName",billTableName); + JSONArray data = (JSONArray) responseJson.get("data"); + data.forEach((o) -> { + dealRequest((JSONObject) o,mainConfigInfo,rs); + }); + }catch(Exception e){ + logger.error("deal response exception;date:" + date + ";response:" + response); + continue; + } + } + } + logger.info("job done"); + } catch (Exception e) { + logger.error("GetDocInfoCronJob.execute exception;e:" + e); + } + } + + /** + * 处理响应信息,提交或退回流程 + * @param data + * @param mainConfigInfo + */ + private void dealRequest(JSONObject data,Map mainConfigInfo,RecordSet rs){ + //根据配置信息判断需要提交还是退回流程 + String operate = ""; + String responseFlag = data.getString(mainConfigInfo.get("xyxxzcgsbbszd")); + if(mainConfigInfo.get("tjlcdbs").indexOf(responseFlag) > -1){ + operate = "submit"; + }else if(mainConfigInfo.get("thlcdbs").indexOf(responseFlag) > -1){ + operate = "reject"; + } + //将响应信息转义 流程提交时作为签字意见 + String remark = ""; + String getRemarkSql = "select zyxx from uf_jhfkztzypz_dt1 where xyxx = ?"; + Map firstData = DaoUtil.getFirstData(rs, getRemarkSql, responseFlag); + if(firstData.size() > 0){ + remark = firstData.get("zyxx"); + } + + //根据配置信息查找响应信息对应的流程requestId + String getRequestIdSql = "select t1.requestid,t3.nodename from " + mainConfigInfo.get("billTableName") + " t1 inner join workflow_requestbase t2 on t2.requestid = t1.requestid inner join workflow_nodebase t3 on t3.id = t2.currentnodeid where t1." + mainConfigInfo.get("fieldName") + " = ?"; + List> requestInfos = DaoUtil.getData(rs, getRequestIdSql, data.get(mainConfigInfo.get("xyxxzdjbhzd"))); + for(Map requestInfo : requestInfos){ + if(requestInfo != null){ + String requestId = requestInfo.get("requestid"); + //将响应信息回写到流程表单里 + String updateBackInfoSql = "update " + mainConfigInfo.get("billTableName") + " set " + mainConfigInfo.get("lcbdzcfxyxxdzdmc") + " = ? where requestid = ?"; + DaoUtil.updateData(rs,updateBackInfoSql,responseFlag,requestId); + logger.info("updateBackInfoSql done"); + String currentNodeName = requestInfo.get("nodename"); + if(mainConfigInfo.get("xycldjd").indexOf(currentNodeName) > -1 && ("submit".equals(operate) || "reject".equals(operate))){ + operateRequest(operate,requestId,remark); + } + } + } + } + + private void operateRequest(String operate,String requestId,String remark){ + try{ + WorkflowService service = new WorkflowServiceImpl(); + String message = service.submitWorkflowRequest(null, Integer.parseInt(requestId), 1,operate,remark); + if(!"success".equals(message)){ + logger.error("submitWorkFlow exception;requestId:" + requestId + ";operate:" + operate + ";message:" + message); + } + }catch (Exception e){ + logger.error("submitWorkFlow exception;requestId:" + requestId + ";operate:" + operate + ";message:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 根据当前时间,添加或减去指定的时间量。例如,要从当前日历时间减去 5 天,可以通过调用以下方法做到这一点: + * add(Calendar.DAY_OF_MONTH, -5)。 + * @param date 指定时间 + * @param num 为时间添加或减去的时间天数 + * @return + */ + public String getBeforeOrAfterDate(Date date, int num) { + Calendar calendar = Calendar.getInstance();//获取日历 + calendar.setTime(date);//当date的值是当前时间,则可以不用写这段代码。 + calendar.add(Calendar.DATE, num); + Date d = calendar.getTime();//把日历转换为Date + return new SimpleDateFormat(df).format(d); + } + + public String getLoginUrl() { + return loginUrl; + } + + public void setLoginUrl(String loginUrl) { + this.loginUrl = loginUrl; + } + + public String getConfigDataId() { + return configDataId; + } + + public void setConfigDataId(String configDataId) { + this.configDataId = configDataId; + } + + public String getGetBillStateUrl() { + return getBillStateUrl; + } + + public void setGetBillStateUrl(String getBillStateUrl) { + this.getBillStateUrl = getBillStateUrl; + } + + public String getLoginUserName() { + return loginUserName; + } + + public void setLoginUserName(String loginUserName) { + this.loginUserName = loginUserName; + } + + public String getLoginPassWord() { + return loginPassWord; + } + + public void setLoginPassWord(String loginPassWord) { + this.loginPassWord = loginPassWord; + } + + public String getLoginSinName() { + return loginSinName; + } + + public void setLoginSinName(String loginSinName) { + this.loginSinName = loginSinName; + } + + public String getLoginDcName() { + return loginDcName; + } + + public void setLoginDcName(String loginDcName) { + this.loginDcName = loginDcName; + } + + public String getLoginLanguage() { + return loginLanguage; + } + + public void setLoginLanguage(String loginLanguage) { + this.loginLanguage = loginLanguage; + } + + public String getLoginDbType() { + return loginDbType; + } + + public void setLoginDbType(String loginDbType) { + this.loginDbType = loginDbType; + } + + public String getDf() { + return df; + } + + public void setDf(String df) { + this.df = df; + } + + public String getDays() { + return days; + } + + public void setDays(String days) { + this.days = days; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSoapBindingStub.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSoapBindingStub.java new file mode 100644 index 0000000..c37fa94 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSoapBindingStub.java @@ -0,0 +1,249 @@ +/** + * WSCasPaybillFacadeSoapBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.webservice; + +public class WSCasPaybillFacadeSoapBindingStub extends org.apache.axis.client.Stub implements WSCasPaybillFacadeSrvProxy { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[2]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getBillState"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "EASNumber"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string"), java.lang.String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "OANumber"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string"), java.lang.String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "bizDate"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string"), java.lang.String.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getBillStateReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://10.6.0.93:8080/ormrpc/services/WSCasPaybillFacade", "fault"), + "weaver.taojw.jinghe.cronjob.webservice.WSInvokeException", + new javax.xml.namespace.QName("urn:client.caspaybillfacade", "WSInvokeException"), + true + )); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("updateOANumber"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "EASNumber"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string"), java.lang.String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "OANumber"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string"), java.lang.String.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "updateOANumberReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://10.6.0.93:8080/ormrpc/services/WSCasPaybillFacade", "fault"), + "weaver.taojw.jinghe.cronjob.webservice.WSInvokeException", + new javax.xml.namespace.QName("urn:client.caspaybillfacade", "WSInvokeException"), + true + )); + _operations[1] = oper; + + } + + public WSCasPaybillFacadeSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public WSCasPaybillFacadeSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public WSCasPaybillFacadeSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + java.lang.Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("urn:client.caspaybillfacade", "WSInvokeException"); + cachedSerQNames.add(qName); + cls = WSInvokeException.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public java.lang.String getBillState(java.lang.String EASNumber, java.lang.String OANumber, java.lang.String bizDate) throws java.rmi.RemoteException, WSInvokeException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.yc.eas.kingdee.com", "getBillState")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {EASNumber, OANumber, bizDate}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof WSInvokeException) { + throw (WSInvokeException) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public java.lang.String updateOANumber(java.lang.String EASNumber, java.lang.String OANumber) throws java.rmi.RemoteException, WSInvokeException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.yc.eas.kingdee.com", "updateOANumber")); + + setRequestHeaders(_call); + setAttachments(_call); + try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {EASNumber, OANumber}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof WSInvokeException) { + throw (WSInvokeException) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxy.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxy.java new file mode 100644 index 0000000..e0f0b31 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxy.java @@ -0,0 +1,13 @@ +/** + * WSCasPaybillFacadeSrvProxy.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.webservice; + +public interface WSCasPaybillFacadeSrvProxy extends java.rmi.Remote { + public java.lang.String getBillState(java.lang.String EASNumber, java.lang.String OANumber, java.lang.String bizDate) throws java.rmi.RemoteException, WSInvokeException; + public java.lang.String updateOANumber(java.lang.String EASNumber, java.lang.String OANumber) throws java.rmi.RemoteException, WSInvokeException; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxyService.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxyService.java new file mode 100644 index 0000000..ded3e77 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxyService.java @@ -0,0 +1,16 @@ +/** + * WSCasPaybillFacadeSrvProxyService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.webservice; + +public interface WSCasPaybillFacadeSrvProxyService extends javax.xml.rpc.Service { + public java.lang.String getWSCasPaybillFacadeAddress(); + + public WSCasPaybillFacadeSrvProxy getWSCasPaybillFacade() throws javax.xml.rpc.ServiceException; + + public WSCasPaybillFacadeSrvProxy getWSCasPaybillFacade(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxyServiceLocator.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxyServiceLocator.java new file mode 100644 index 0000000..ae08dbb --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSCasPaybillFacadeSrvProxyServiceLocator.java @@ -0,0 +1,142 @@ +/** + * WSCasPaybillFacadeSrvProxyServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.webservice; + +public class WSCasPaybillFacadeSrvProxyServiceLocator extends org.apache.axis.client.Service implements WSCasPaybillFacadeSrvProxyService { + + public WSCasPaybillFacadeSrvProxyServiceLocator() { + } + + + public WSCasPaybillFacadeSrvProxyServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public WSCasPaybillFacadeSrvProxyServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for WSCasPaybillFacade + private java.lang.String WSCasPaybillFacade_address = "http://10.6.0.93:8080/ormrpc/services/WSCasPaybillFacade"; + + public java.lang.String getWSCasPaybillFacadeAddress() { + return WSCasPaybillFacade_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String WSCasPaybillFacadeWSDDServiceName = "WSCasPaybillFacade"; + + public java.lang.String getWSCasPaybillFacadeWSDDServiceName() { + return WSCasPaybillFacadeWSDDServiceName; + } + + public void setWSCasPaybillFacadeWSDDServiceName(java.lang.String name) { + WSCasPaybillFacadeWSDDServiceName = name; + } + + public WSCasPaybillFacadeSrvProxy getWSCasPaybillFacade() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(WSCasPaybillFacade_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getWSCasPaybillFacade(endpoint); + } + + public WSCasPaybillFacadeSrvProxy getWSCasPaybillFacade(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + WSCasPaybillFacadeSoapBindingStub _stub = new WSCasPaybillFacadeSoapBindingStub(portAddress, this); + _stub.setPortName(getWSCasPaybillFacadeWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setWSCasPaybillFacadeEndpointAddress(java.lang.String address) { + WSCasPaybillFacade_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (WSCasPaybillFacadeSrvProxy.class.isAssignableFrom(serviceEndpointInterface)) { + WSCasPaybillFacadeSoapBindingStub _stub = new WSCasPaybillFacadeSoapBindingStub(new java.net.URL(WSCasPaybillFacade_address), this); + _stub.setPortName(getWSCasPaybillFacadeWSDDServiceName()); + return _stub; + } + } + catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + java.lang.String inputPortName = portName.getLocalPart(); + if ("WSCasPaybillFacade".equals(inputPortName)) { + return getWSCasPaybillFacade(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("http://10.6.0.93:8080/ormrpc/services/WSCasPaybillFacade", "WSCasPaybillFacadeSrvProxyService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("http://10.6.0.93:8080/ormrpc/services/WSCasPaybillFacade", "WSCasPaybillFacade")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + +if ("WSCasPaybillFacade".equals(portName)) { + setWSCasPaybillFacadeEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSInvokeException.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSInvokeException.java new file mode 100644 index 0000000..79008ef --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/webservice/WSInvokeException.java @@ -0,0 +1,87 @@ +/** + * WSInvokeException.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.webservice; + +public class WSInvokeException extends org.apache.axis.AxisFault implements java.io.Serializable { + public WSInvokeException() { + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof WSInvokeException)) return false; + WSInvokeException other = (WSInvokeException) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true; + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(WSInvokeException.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:client.caspaybillfacade", "WSInvokeException")); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + + + /** + * Writes the exception data to the faultDetails + */ + public void writeDetails(javax.xml.namespace.QName qname, org.apache.axis.encoding.SerializationContext context) throws java.io.IOException { + context.serialize(qname, null, this); + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/action/WorkFlowDataToThirdSystem.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/action/WorkFlowDataToThirdSystem.java new file mode 100644 index 0000000..bc9d4a8 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/action/WorkFlowDataToThirdSystem.java @@ -0,0 +1,163 @@ +package weaver.taojw.jinghe.wxr.action; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.jinghe.wxr.eneity.DetailRequestConfig; +import weaver.taojw.jinghe.wxr.eneity.MainRequestConfig; +import weaver.taojw.jinghe.wxr.util.ReadConfigUtil; +import weaver.taojw.jinghe.wxr.webservice.*; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author xuanran.wang + * @Date 2022/10/16 10:44 + * 锦和 流程数据推送第三方系统 + */ +public class WorkFlowDataToThirdSystem implements Action { + // 配置唯一编码 + private String uniqueCode; + private String logInUrl; + Logger logger = MyLogger.getLogger(); + private String wsExternalUrl; + @Override + public String execute(RequestInfo requestInfo) { + try { + String xml = getXml(requestInfo.getRequestid(), requestInfo.getRequestManager().getBillTableName()); + URL logInURL = new URL(logInUrl); + EASLoginProxyServiceLocator loginLocator = new EASLoginProxyServiceLocator(); + EASLoginSoapBindingStub easLoginStub = new EASLoginSoapBindingStub(logInURL, loginLocator); + WSContext wsContext = easLoginStub.login("", "", "eas", "eas", "l2", 2); + String sessionId = wsContext.getSessionId(); + if(StringUtils.isBlank(sessionId)){ + throw new RuntimeException("调用登录webservice接口失败!"); + } + URL wsExternalURL = new URL(wsExternalUrl); + WSExternalDataExchangeFacadeSrvProxyServiceLocator wsExternalDataExchangeFacadeSrvProxyServiceLocator = new WSExternalDataExchangeFacadeSrvProxyServiceLocator(); + WSExternalDataExchangeFacadeSoapBindingStub soapBindingStub = new WSExternalDataExchangeFacadeSoapBindingStub(wsExternalURL, wsExternalDataExchangeFacadeSrvProxyServiceLocator); + String[][] res = soapBindingStub.importBizData("payingBill", xml, true); + }catch (Exception e){ + logger.info("执行WorkFlowDataToThirdSystemAction发生异常,异常原因 => " + e.getMessage()); + } + return null; + } + + public String getXml(String requestId, String tableName){ + String sql = "select * from " + tableName + " where requestid = ?"; + MainRequestConfig config = ReadConfigUtil.getConfig(uniqueCode, tableName); + String configFilePath = config.getConfigFilePath(); + if(StringUtils.isBlank(configFilePath)){ + throw new RuntimeException("建模主表配置文件不能为空!"); + } + String requestUrl = config.getRequestUrl(); + if(StringUtils.isBlank(requestUrl)){ + throw new RuntimeException("获取配置文件明细表为空!"); + } + this.wsExternalUrl = requestUrl; + List requestConfigList = config.getDetailRequestConfigList(); + if(CollectionUtils.isEmpty(requestConfigList)){ + throw new RuntimeException("获取配置文件明细表为空!"); + } + this.wsExternalUrl = requestUrl; + String dataSource = config.getDataSource(); + RecordSet mainRs = new RecordSet(); + RecordSet detailRs = new RecordSet(); + mainRs.executeQuery(sql, requestId); + mainRs.next(); + String mainId = mainRs.getString("id"); + StringBuilder sb = new StringBuilder(); + // 主表 + if ("0".equals(dataSource)) { + List collect = requestConfigList.stream() + // !"0".equals(item.getGetValueType()) 表示不是取流程字段 + // "0".equals(item.getDetailId()) 取字段来自主表的 + .filter(item -> !"0".equals(item.getGetValueType()) + || "0".equals(item.getDetailId())).collect(Collectors.toList()); + appendXml(sb, collect, mainRs, detailRs); + } else { + // 明细 + String detailIdStr = config.getDetailId(); + String[] detailIdArr = detailIdStr.split(","); + for (String detailId : detailIdArr) { + List collect = requestConfigList.stream() + // !"0".equals(item.getGetValueType()) 表示不是取流程字段 + // "0".equals(item.getDetailId()) 取字段来自主表的 + // detailId.equals(item.getDetailId()) 取当前明细表字段 + .filter(item -> !"0".equals(item.getGetValueType()) + || detailId.equals(item.getDetailId()) + || "0".equals(item.getDetailId()) + ).collect(Collectors.toList()); + String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?"; + if (detailRs.executeQuery(detailSql, mainId)) { + while (detailRs.next()) { + appendXml(sb, collect, mainRs, detailRs); + } + } + } + } + StringBuilder xml = new StringBuilder(); + try { + FileInputStream in = new FileInputStream(configFilePath); + InputStreamReader inReader = new InputStreamReader(in, StandardCharsets.UTF_8); + BufferedReader bufReader = new BufferedReader(inReader); + String line = null; + while ((line = bufReader.readLine()) != null) { + if(line.contains("{record}")){ + line = sb.toString(); + xml.append(line); + }else { + xml.append(line).append("\n"); + } + } + bufReader.close(); + inReader.close(); + in.close(); + } catch (Exception e) { + throw new RuntimeException("读取配置文件失败!文件路径=> " + configFilePath); + } + return xml.toString(); + } + + public void appendXml(StringBuilder xml, List configList, + RecordSet mainRs, RecordSet detailRs){ + xml.append("").append("\n"); + for (DetailRequestConfig requestConfig : configList) { + xml.append("") + .append(ReadConfigUtil.getParamValue(requestConfig, mainRs, detailRs)) + .append("") + .append("\n"); + } + xml.append("").append("\n"); + } + + public String getUniqueCode() { + return uniqueCode; + } + + public void setUniqueCode(String uniqueCode) { + this.uniqueCode = uniqueCode; + } + + public String getLogInUrl() { + return logInUrl; + } + + public void setLogInUrl(String logInUrl) { + this.logInUrl = logInUrl; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/eneity/DetailRequestConfig.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/eneity/DetailRequestConfig.java new file mode 100644 index 0000000..57a1536 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/eneity/DetailRequestConfig.java @@ -0,0 +1,95 @@ +package weaver.taojw.jinghe.wxr.eneity; + + +/** + * @Author xuanran.wang + * @Date 2022/6/18 16:47 + */ +public class DetailRequestConfig { + private String paramName; + private String paramType; + private String getValueType; + private String valueContext; + private String tableName; + private String workFlowField; + private String fieldName; + private String detailId; + + public String getParamName() { + return paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamType() { + return paramType; + } + + public void setParamType(String paramType) { + this.paramType = paramType; + } + + public String getGetValueType() { + return getValueType; + } + + public void setGetValueType(String getValueType) { + this.getValueType = getValueType; + } + + public String getValueContext() { + return valueContext; + } + + public void setValueContext(String valueContext) { + this.valueContext = valueContext; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getWorkFlowField() { + return workFlowField; + } + + public void setWorkFlowField(String workFlowField) { + this.workFlowField = workFlowField; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getDetailId() { + return detailId; + } + + public void setDetailId(String detailId) { + this.detailId = detailId; + } + + @Override + public String toString() { + return "DetailRequestConfig{" + + "paramName='" + paramName + '\'' + + ", paramType='" + paramType + '\'' + + ", getValueType='" + getValueType + '\'' + + ", valueContext='" + valueContext + '\'' + + ", tableName='" + tableName + '\'' + + ", workFlowField='" + workFlowField + '\'' + + ", fieldName='" + fieldName + '\'' + + ", detailId='" + detailId + '\'' + + '}'; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/eneity/MainRequestConfig.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/eneity/MainRequestConfig.java new file mode 100644 index 0000000..7c11911 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/eneity/MainRequestConfig.java @@ -0,0 +1,107 @@ +package weaver.taojw.jinghe.wxr.eneity; + + +import java.util.List; + +/** + * @Author xuanran.wang + * @Date 2022/6/18 15:43 + */ +public class MainRequestConfig { + private String id; + private String uniqueCode; + private String workflow; + private String requestUrl; + private String dataSource; + private String detailId; + private String cusSql; + private String configFilePath; + private List detailRequestConfigList; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUniqueCode() { + return uniqueCode; + } + + public void setUniqueCode(String uniqueCode) { + this.uniqueCode = uniqueCode; + } + + public String getWorkflow() { + return workflow; + } + + public void setWorkflow(String workflow) { + this.workflow = workflow; + } + + public String getRequestUrl() { + return requestUrl; + } + + public void setRequestUrl(String requestUrl) { + this.requestUrl = requestUrl; + } + + public String getDataSource() { + return dataSource; + } + + public void setDataSource(String dataSource) { + this.dataSource = dataSource; + } + + public String getDetailId() { + return detailId; + } + + public void setDetailId(String detailId) { + this.detailId = detailId; + } + + public String getCusSql() { + return cusSql; + } + + public void setCusSql(String cusSql) { + this.cusSql = cusSql; + } + + public String getConfigFilePath() { + return configFilePath; + } + + public void setConfigFilePath(String configFilePath) { + this.configFilePath = configFilePath; + } + + public List getDetailRequestConfigList() { + return detailRequestConfigList; + } + + public void setDetailRequestConfigList(List detailRequestConfigList) { + this.detailRequestConfigList = detailRequestConfigList; + } + + @Override + public String toString() { + return "MainRequestConfig{" + + "id='" + id + '\'' + + ", uniqueCode='" + uniqueCode + '\'' + + ", workflow='" + workflow + '\'' + + ", requestUrl='" + requestUrl + '\'' + + ", dataSource='" + dataSource + '\'' + + ", detailId='" + detailId + '\'' + + ", cusSql='" + cusSql + '\'' + + ", configFilePath='" + configFilePath + '\'' + + ", detailRequestConfigList=" + detailRequestConfigList + + '}'; + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/util/ReadConfigUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/util/ReadConfigUtil.java new file mode 100644 index 0000000..10ded2a --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/util/ReadConfigUtil.java @@ -0,0 +1,217 @@ +package weaver.taojw.jinghe.wxr.util; + +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.taojw.common.ToolUtil; +import weaver.taojw.jinghe.wxr.eneity.DetailRequestConfig; +import weaver.taojw.jinghe.wxr.eneity.MainRequestConfig; +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @Author xuanran.wang + * @Date 2022/10/16 14:24 + */ +public class ReadConfigUtil extends ToolUtil { + private static final ToolUtil toolUtil = new ToolUtil(); + public static MainRequestConfig getConfig(String uniqueCode, String mainTableName) { + MainRequestConfig res = new MainRequestConfig(); + RecordSet queryRs = new RecordSet(); + String sql = "select * from uf_jhcreatexml where uniqueCode = ? "; + if (queryRs.executeQuery(sql, uniqueCode)) { + if (queryRs.next()) { + res = getInstance(queryRs, MainRequestConfig.class); + } + } + if (res == null || StringUtils.isBlank(res.getId()) || (-1 == Util.getIntValue(res.getId(), -1))) { + throw new RuntimeException("配置不存在"); + } + int mainId = Util.getIntValue(res.getId()); + // 配置明细表 + sql = "select paramName,paramType,getValueType,workflowField,valueContext,fv.tableName," + + " fv.id fieldId,fv.fieldname,fv.indexdesc " + + " from uf_jhcreatexml_dt1 config " + + " left join workflow_field_table_view fv on config.workflowField = fv.id " + + " where mainid = ? "; + if (queryRs.executeQuery(sql, mainId)) { + ArrayList detailConfigs = new ArrayList<>(); + while (queryRs.next()) { + DetailRequestConfig detailConfig = getInstance(queryRs, DetailRequestConfig.class); + String tableName = detailConfig.getTableName(); + // 主表默认0 + String detailId = "0"; + // 明细id替换 + if(!mainTableName.equals(detailConfig.getTableName())){ + detailId = tableName.replaceAll(mainTableName + "_dt", ""); + } + detailConfig.setDetailId(detailId); + detailConfigs.add(detailConfig); + } + res.setDetailRequestConfigList(detailConfigs); + } + return res; + } + + public static T getInstance(RecordSet queryRs, Class clazz) { + T res = null; + try { + res = clazz.newInstance(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + // 判断字段类型 + if (field.getType().isAssignableFrom(List.class) || field.getType().isAssignableFrom(Map.class)) { + continue; + } + field.setAccessible(true); + String fieldName = field.getName(); + if ("oracle".equals(queryRs.getDBType())) { + fieldName = fieldName.toUpperCase(); + } + String value = Util.null2String(queryRs.getString(fieldName)); + field.set(res, value); + } + } catch (Exception e) { + throw new RuntimeException("实体类生成异常"); + } + return res; + } + + public static Object getParamValue(DetailRequestConfig detailRequestConfig, RecordSet mainRs, RecordSet detailRs){ + Object value = ""; + try { + // 参数类型 + String paramType = detailRequestConfig.getParamType(); + // 取值方式 + String getValueType = detailRequestConfig.getGetValueType(); + // 明细id + String detailId = detailRequestConfig.getDetailId(); + switch (getValueType){ + // 流程字段 + case "0":{ + String fieldName = detailRequestConfig.getFieldName(); + if("0".equals(detailId)){ + value = Util.null2String(mainRs.getString(fieldName)); + }else{ + value = Util.null2String(detailRs.getString(fieldName)); + } + break; + } + // 固定值 + case "1":{ + value = Util.null2String(detailRequestConfig.getValueContext()); + break; + } + // 当前时间 + case "3":{ + // 当前时间 + value = TimeUtil.getCurrentTimeString(); + break; + } + // 自定义sql + case "4":{ + String fieldName = detailRequestConfig.getFieldName(); + String tempValue; + if("0".equals(detailId)){ + tempValue = Util.null2String(mainRs.getString(fieldName)); + }else{ + tempValue = Util.null2String(detailRs.getString(fieldName)); + } + String requestId = Util.null2String(mainRs.getString("requestid")); + value = toolUtil.getValueByChangeRule(detailRequestConfig.getValueContext(), tempValue, requestId); + break; + } + // 自定义sql + case "5" : { + value = Util.null2String(mainRs.getString("requestid")); + } + default:break; + } + // 参数类型 + switch (paramType){ + // String + case "0":{ + value = Util.null2String(value); + break; + } + // Int + case "1":{ + value = Util.getIntValue(String.valueOf(value),0); + break; + } + // Double + case "2":{ + value = Util.getDoubleValue(String.valueOf(value),0); + break; + } + //日期类型 + case "3" : { + try { + value = diyDateFortMat((Date) value,"yyyy-MM-dd"); + }catch (Exception e){ + throw new Exception("时间处理异常:参数 => " + detailRequestConfig.getParamName()); + } + }break; + //时间日期类型 + case "4" : { + try { + value = diyDateFortMat((Date) value,"yyyy-MM-dd HH:mm:ss"); + }catch (Exception e){ + throw new Exception("时间处理异常:参数 => " + detailRequestConfig.getParamName()); + } + }break; + case "7":{ + String valueContext = detailRequestConfig.getValueContext(); + if(!StringUtils.isBlank(valueContext)){ + try { + String[] rule = valueContext.split("=>"); + SimpleDateFormat s1 = new SimpleDateFormat(rule[0]); + Date parse = s1.parse(Util.null2String(value)); + SimpleDateFormat s2 = new SimpleDateFormat(rule[1]); + value = s2.format(parse.getTime()); + }catch (Exception e){ + throw new Exception("时间处理异常:参数 => " + detailRequestConfig.getParamName()); + } + } + } + //时间戳类型 + case "8" : { + try{ + Date tempDate = (Date) value; + value = tempDate.getTime(); + }catch (Exception e){ + throw new Exception("时间处理异常:参数 => " + detailRequestConfig.getParamName()); + } + }break; + default:break; + } + }catch (Exception e){ + throw new RuntimeException("执行setCommonParamValue发生异常 : " + e.getMessage()); + } + + if(value instanceof String){ + value = StringEscapeUtils.escapeXml(Util.null2String(value)); + } + + return value; + } + + /** + * 自定义时间格式化 + * @param date 日期 + * @param tempStr 格式化字符串 + * @return + */ + private static String diyDateFortMat(Date date,String tempStr){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(tempStr); + return simpleDateFormat.format(date); + } + + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxy.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxy.java new file mode 100644 index 0000000..ce993fa --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxy.java @@ -0,0 +1,16 @@ +/** + * EASLoginProxy.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public interface EASLoginProxy extends java.rmi.Remote { + public WSContext loginByLtpaToken(String userName, String ltpaToken, String slnName, String dcName, String language, int dbType) throws java.rmi.RemoteException; + public WSContext login(String userName, String password, String slnName, String dcName, String language, int dbType) throws java.rmi.RemoteException; + public WSContext login(String userName, String password, String slnName, String dcName, String language, int dbType, String authPattern) throws java.rmi.RemoteException; + public WSContext login(String userName, String password, String slnName, String dcName, String language, int dbType, String authPattern, int isEncodePwd) throws java.rmi.RemoteException; + public boolean logout(String userName, String slnName, String dcName, String language) throws java.rmi.RemoteException; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxyService.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxyService.java new file mode 100644 index 0000000..ebb6de9 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxyService.java @@ -0,0 +1,16 @@ +/** + * EASLoginProxyService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public interface EASLoginProxyService extends javax.xml.rpc.Service { + public String getEASLoginAddress(); + + public EASLoginProxy getEASLogin() throws javax.xml.rpc.ServiceException; + + public EASLoginProxy getEASLogin(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxyServiceLocator.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxyServiceLocator.java new file mode 100644 index 0000000..e8e8fac --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginProxyServiceLocator.java @@ -0,0 +1,142 @@ +/** + * EASLoginProxyServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public class EASLoginProxyServiceLocator extends org.apache.axis.client.Service implements EASLoginProxyService { + + public EASLoginProxyServiceLocator() { + } + + + public EASLoginProxyServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public EASLoginProxyServiceLocator(String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for EASLogin + private String EASLogin_address = "http://47.102.220.6:6888/ormrpc/services/EASLogin"; + + public String getEASLoginAddress() { + return EASLogin_address; + } + + // The WSDD service name defaults to the port name. + private String EASLoginWSDDServiceName = "EASLogin"; + + public String getEASLoginWSDDServiceName() { + return EASLoginWSDDServiceName; + } + + public void setEASLoginWSDDServiceName(String name) { + EASLoginWSDDServiceName = name; + } + + public EASLoginProxy getEASLogin() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(EASLogin_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getEASLogin(endpoint); + } + + public EASLoginProxy getEASLogin(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + EASLoginSoapBindingStub _stub = new EASLoginSoapBindingStub(portAddress, this); + _stub.setPortName(getEASLoginWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setEASLoginEndpointAddress(String address) { + EASLogin_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (EASLoginProxy.class.isAssignableFrom(serviceEndpointInterface)) { + EASLoginSoapBindingStub _stub = new EASLoginSoapBindingStub(new java.net.URL(EASLogin_address), this); + _stub.setPortName(getEASLoginWSDDServiceName()); + return _stub; + } + } + catch (Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + String inputPortName = portName.getLocalPart(); + if ("EASLogin".equals(inputPortName)) { + return getEASLogin(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/EASLogin", "EASLoginProxyService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/EASLogin", "EASLogin")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(String portName, String address) throws javax.xml.rpc.ServiceException { + +if ("EASLogin".equals(portName)) { + setEASLoginEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginSoapBindingStub.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginSoapBindingStub.java new file mode 100644 index 0000000..1233b75 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/EASLoginSoapBindingStub.java @@ -0,0 +1,393 @@ +/** + * EASLoginSoapBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public class EASLoginSoapBindingStub extends org.apache.axis.client.Stub implements EASLoginProxy { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[5]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("loginByLtpaToken"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "userName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "ltpaToken"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "slnName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dcName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "language"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dbType"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("urn:client", "WSContext")); + oper.setReturnClass(WSContext.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "loginByLtpaTokenReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("login"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "userName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "password"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "slnName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dcName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "language"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dbType"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("urn:client", "WSContext")); + oper.setReturnClass(WSContext.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "loginReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("login"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "userName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "password"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "slnName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dcName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "language"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dbType"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "authPattern"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("urn:client", "WSContext")); + oper.setReturnClass(WSContext.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "loginReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("login"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "userName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "password"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "slnName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dcName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "language"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dbType"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "authPattern"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "isEncodePwd"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("urn:client", "WSContext")); + oper.setReturnClass(WSContext.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "loginReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[3] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("logout"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "userName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "slnName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "dcName"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "language"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); + oper.setReturnClass(boolean.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "logoutReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[4] = oper; + + } + + public EASLoginSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public EASLoginSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public EASLoginSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("urn:client", "WSContext"); + cachedSerQNames.add(qName); + cls = WSContext.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + Class cls = (Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + Class sf = (Class) + cachedSerFactories.get(i); + Class df = (Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public WSContext loginByLtpaToken(String userName, String ltpaToken, String slnName, String dcName, String language, int dbType) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://login.webservice.bos.kingdee.com", "loginByLtpaToken")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {userName, ltpaToken, slnName, dcName, language, new Integer(dbType)}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (WSContext) _resp; + } catch (Exception _exception) { + return (WSContext) org.apache.axis.utils.JavaUtils.convert(_resp, WSContext.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public WSContext login(String userName, String password, String slnName, String dcName, String language, int dbType) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://login.webservice.bos.kingdee.com", "login")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {userName, password, slnName, dcName, language, new Integer(dbType)}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (WSContext) _resp; + } catch (Exception _exception) { + return (WSContext) org.apache.axis.utils.JavaUtils.convert(_resp, WSContext.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public WSContext login(String userName, String password, String slnName, String dcName, String language, int dbType, String authPattern) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://login.webservice.bos.kingdee.com", "login")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {userName, password, slnName, dcName, language, new Integer(dbType), authPattern}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (WSContext) _resp; + } catch (Exception _exception) { + return (WSContext) org.apache.axis.utils.JavaUtils.convert(_resp, WSContext.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public WSContext login(String userName, String password, String slnName, String dcName, String language, int dbType, String authPattern, int isEncodePwd) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://login.webservice.bos.kingdee.com", "login")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {userName, password, slnName, dcName, language, new Integer(dbType), authPattern, new Integer(isEncodePwd)}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (WSContext) _resp; + } catch (Exception _exception) { + return (WSContext) org.apache.axis.utils.JavaUtils.convert(_resp, WSContext.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + + public boolean logout(String userName, String slnName, String dcName, String language) throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[4]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://login.webservice.bos.kingdee.com", "logout")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {userName, slnName, dcName, language}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return ((Boolean) _resp).booleanValue(); + } catch (Exception _exception) { + return ((Boolean) org.apache.axis.utils.JavaUtils.convert(_resp, boolean.class)).booleanValue(); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSContext.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSContext.java new file mode 100644 index 0000000..ee8178e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSContext.java @@ -0,0 +1,295 @@ +/** + * WSContext.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public class WSContext implements java.io.Serializable { + private int dbType; + + private String dcName; + + private String password; + + private String sessionId; + + private String slnName; + + private String userName; + + public WSContext() { + } + + public WSContext( + int dbType, + String dcName, + String password, + String sessionId, + String slnName, + String userName) { + this.dbType = dbType; + this.dcName = dcName; + this.password = password; + this.sessionId = sessionId; + this.slnName = slnName; + this.userName = userName; + } + + + /** + * Gets the dbType value for this WSContext. + * + * @return dbType + */ + public int getDbType() { + return dbType; + } + + + /** + * Sets the dbType value for this WSContext. + * + * @param dbType + */ + public void setDbType(int dbType) { + this.dbType = dbType; + } + + + /** + * Gets the dcName value for this WSContext. + * + * @return dcName + */ + public String getDcName() { + return dcName; + } + + + /** + * Sets the dcName value for this WSContext. + * + * @param dcName + */ + public void setDcName(String dcName) { + this.dcName = dcName; + } + + + /** + * Gets the password value for this WSContext. + * + * @return password + */ + public String getPassword() { + return password; + } + + + /** + * Sets the password value for this WSContext. + * + * @param password + */ + public void setPassword(String password) { + this.password = password; + } + + + /** + * Gets the sessionId value for this WSContext. + * + * @return sessionId + */ + public String getSessionId() { + return sessionId; + } + + + /** + * Sets the sessionId value for this WSContext. + * + * @param sessionId + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + + /** + * Gets the slnName value for this WSContext. + * + * @return slnName + */ + public String getSlnName() { + return slnName; + } + + + /** + * Sets the slnName value for this WSContext. + * + * @param slnName + */ + public void setSlnName(String slnName) { + this.slnName = slnName; + } + + + /** + * Gets the userName value for this WSContext. + * + * @return userName + */ + public String getUserName() { + return userName; + } + + + /** + * Sets the userName value for this WSContext. + * + * @param userName + */ + public void setUserName(String userName) { + this.userName = userName; + } + + private Object __equalsCalc = null; + public synchronized boolean equals(Object obj) { + if (!(obj instanceof WSContext)) return false; + WSContext other = (WSContext) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + this.dbType == other.getDbType() && + ((this.dcName==null && other.getDcName()==null) || + (this.dcName!=null && + this.dcName.equals(other.getDcName()))) && + ((this.password==null && other.getPassword()==null) || + (this.password!=null && + this.password.equals(other.getPassword()))) && + ((this.sessionId==null && other.getSessionId()==null) || + (this.sessionId!=null && + this.sessionId.equals(other.getSessionId()))) && + ((this.slnName==null && other.getSlnName()==null) || + (this.slnName!=null && + this.slnName.equals(other.getSlnName()))) && + ((this.userName==null && other.getUserName()==null) || + (this.userName!=null && + this.userName.equals(other.getUserName()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + _hashCode += getDbType(); + if (getDcName() != null) { + _hashCode += getDcName().hashCode(); + } + if (getPassword() != null) { + _hashCode += getPassword().hashCode(); + } + if (getSessionId() != null) { + _hashCode += getSessionId().hashCode(); + } + if (getSlnName() != null) { + _hashCode += getSlnName().hashCode(); + } + if (getUserName() != null) { + _hashCode += getUserName().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(WSContext.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:client", "WSContext")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("dbType"); + elemField.setXmlName(new javax.xml.namespace.QName("", "dbType")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); + elemField.setNillable(false); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("dcName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "dcName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setNillable(true); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("password"); + elemField.setXmlName(new javax.xml.namespace.QName("", "password")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setNillable(true); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("sessionId"); + elemField.setXmlName(new javax.xml.namespace.QName("", "sessionId")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setNillable(true); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("slnName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "slnName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setNillable(true); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("userName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "userName")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setNillable(true); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + String mechType, + Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + String mechType, + Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSoapBindingStub.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSoapBindingStub.java new file mode 100644 index 0000000..1610b7c --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSoapBindingStub.java @@ -0,0 +1,387 @@ +/** + * WSExternalDataExchangeFacadeSoapBindingStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public class WSExternalDataExchangeFacadeSoapBindingStub extends org.apache.axis.client.Stub implements WSExternalDataExchangeFacadeSrvProxy { + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc [] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[4]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1(){ + org.apache.axis.description.OperationDesc oper; + org.apache.axis.description.ParameterDesc param; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("exportData"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "easTemplateNumber"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "mainQueryPK"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "mainQuery"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "exportDataReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "fault"), + "weaver.jinghe.wxr.webservice.WSInvokeException", + new javax.xml.namespace.QName("urn:client.externaldataexchangefacade", "WSInvokeException"), + true + )); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("importBizData"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "easTemplaeNum"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "xmlData"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "isUpdate"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"), boolean.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "ArrayOfArrayOf_xsd_string")); + oper.setReturnClass(String[][].class); + oper.setReturnQName(new javax.xml.namespace.QName("", "importBizDataReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "fault"), + "weaver.jinghe.wxr.webservice.WSInvokeException", + new javax.xml.namespace.QName("urn:client.externaldataexchangefacade", "WSInvokeException"), + true + )); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("importData"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "easTemplateNumber"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "key"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "ArrayOf_xsd_string"), String[].class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "data"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "ArrayOf_xsd_string"), String[].class, false, false); + oper.addParameter(param); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "isUpdate"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"), boolean.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "ArrayOfArrayOf_xsd_string")); + oper.setReturnClass(String[][].class); + oper.setReturnQName(new javax.xml.namespace.QName("", "importDataReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "fault"), + "weaver.jinghe.wxr.webservice.WSInvokeException", + new javax.xml.namespace.QName("urn:client.externaldataexchangefacade", "WSInvokeException"), + true + )); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("test"); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "param"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false); + oper.addParameter(param); + oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "testReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + oper.addFault(new org.apache.axis.description.FaultDesc( + new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "fault"), + "weaver.jinghe.wxr.webservice.WSInvokeException", + new javax.xml.namespace.QName("urn:client.externaldataexchangefacade", "WSInvokeException"), + true + )); + _operations[3] = oper; + + } + + public WSExternalDataExchangeFacadeSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public WSExternalDataExchangeFacadeSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public WSExternalDataExchangeFacadeSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); + Class cls; + javax.xml.namespace.QName qName; + javax.xml.namespace.QName qName2; + Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "ArrayOf_xsd_string"); + cachedSerQNames.add(qName); + cls = String[].class; + cachedSerClasses.add(cls); + qName = new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"); + qName2 = null; + cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2)); + cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory()); + + qName = new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "ArrayOfArrayOf_xsd_string"); + cachedSerQNames.add(qName); + cls = String[][].class; + cachedSerClasses.add(cls); + qName = new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"); + qName2 = null; + cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2)); + cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory()); + + qName = new javax.xml.namespace.QName("urn:client.externaldataexchangefacade", "WSInvokeException"); + cachedSerQNames.add(qName); + cls = WSInvokeException.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = super._createCall(); + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + for (int i = 0; i < cachedSerFactories.size(); ++i) { + Class cls = (Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + Object x = cachedSerFactories.get(i); + if (x instanceof Class) { + Class sf = (Class) + cachedSerFactories.get(i); + Class df = (Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { + org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) + cachedSerFactories.get(i); + org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + } + return _call; + } + catch (Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + } + } + + public String exportData(String easTemplateNumber, String mainQueryPK, String mainQuery) throws java.rmi.RemoteException, WSInvokeException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.app.datatask.tools.eas.kingdee.com", "exportData")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {easTemplateNumber, mainQueryPK, mainQuery}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (String) _resp; + } catch (Exception _exception) { + return (String) org.apache.axis.utils.JavaUtils.convert(_resp, String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof WSInvokeException) { + throw (WSInvokeException) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public String[][] importBizData(String easTemplaeNum, String xmlData, boolean isUpdate) throws java.rmi.RemoteException, WSInvokeException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.app.datatask.tools.eas.kingdee.com", "importBizData")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {easTemplaeNum, xmlData, new Boolean(isUpdate)}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (String[][]) _resp; + } catch (Exception _exception) { + return (String[][]) org.apache.axis.utils.JavaUtils.convert(_resp, String[][].class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof WSInvokeException) { + throw (WSInvokeException) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public String[][] importData(String easTemplateNumber, String[] key, String[] data, boolean isUpdate) throws java.rmi.RemoteException, WSInvokeException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.app.datatask.tools.eas.kingdee.com", "importData")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {easTemplateNumber, key, data, new Boolean(isUpdate)}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (String[][]) _resp; + } catch (Exception _exception) { + return (String[][]) org.apache.axis.utils.JavaUtils.convert(_resp, String[][].class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof WSInvokeException) { + throw (WSInvokeException) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + + public String test(String param) throws java.rmi.RemoteException, WSInvokeException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("http://webservice.app.datatask.tools.eas.kingdee.com", "test")); + + setRequestHeaders(_call); + setAttachments(_call); + try { Object _resp = _call.invoke(new Object[] {param}); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException)_resp; + } + else { + extractAttachments(_call); + try { + return (String) _resp; + } catch (Exception _exception) { + return (String) org.apache.axis.utils.JavaUtils.convert(_resp, String.class); + } + } + } catch (org.apache.axis.AxisFault axisFaultException) { + if (axisFaultException.detail != null) { + if (axisFaultException.detail instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) axisFaultException.detail; + } + if (axisFaultException.detail instanceof WSInvokeException) { + throw (WSInvokeException) axisFaultException.detail; + } + } + throw axisFaultException; +} + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxy.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxy.java new file mode 100644 index 0000000..c465be6 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxy.java @@ -0,0 +1,15 @@ +/** + * WSExternalDataExchangeFacadeSrvProxy.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public interface WSExternalDataExchangeFacadeSrvProxy extends java.rmi.Remote { + public String exportData(String easTemplateNumber, String mainQueryPK, String mainQuery) throws java.rmi.RemoteException, WSInvokeException; + public String[][] importBizData(String easTemplaeNum, String xmlData, boolean isUpdate) throws java.rmi.RemoteException, WSInvokeException; + public String[][] importData(String easTemplateNumber, String[] key, String[] data, boolean isUpdate) throws java.rmi.RemoteException, WSInvokeException; + public String test(String param) throws java.rmi.RemoteException, WSInvokeException; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxyService.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxyService.java new file mode 100644 index 0000000..6c1f5ab --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxyService.java @@ -0,0 +1,16 @@ +/** + * WSExternalDataExchangeFacadeSrvProxyService.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public interface WSExternalDataExchangeFacadeSrvProxyService extends javax.xml.rpc.Service { + public String getWSExternalDataExchangeFacadeAddress(); + + public WSExternalDataExchangeFacadeSrvProxy getWSExternalDataExchangeFacade() throws javax.xml.rpc.ServiceException; + + public WSExternalDataExchangeFacadeSrvProxy getWSExternalDataExchangeFacade(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxyServiceLocator.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxyServiceLocator.java new file mode 100644 index 0000000..fa0d5e5 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSExternalDataExchangeFacadeSrvProxyServiceLocator.java @@ -0,0 +1,142 @@ +/** + * WSExternalDataExchangeFacadeSrvProxyServiceLocator.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public class WSExternalDataExchangeFacadeSrvProxyServiceLocator extends org.apache.axis.client.Service implements WSExternalDataExchangeFacadeSrvProxyService { + + public WSExternalDataExchangeFacadeSrvProxyServiceLocator() { + } + + + public WSExternalDataExchangeFacadeSrvProxyServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public WSExternalDataExchangeFacadeSrvProxyServiceLocator(String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { + super(wsdlLoc, sName); + } + + // Use to get a proxy class for WSExternalDataExchangeFacade + private String WSExternalDataExchangeFacade_address = "http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade"; + + public String getWSExternalDataExchangeFacadeAddress() { + return WSExternalDataExchangeFacade_address; + } + + // The WSDD service name defaults to the port name. + private String WSExternalDataExchangeFacadeWSDDServiceName = "WSExternalDataExchangeFacade"; + + public String getWSExternalDataExchangeFacadeWSDDServiceName() { + return WSExternalDataExchangeFacadeWSDDServiceName; + } + + public void setWSExternalDataExchangeFacadeWSDDServiceName(String name) { + WSExternalDataExchangeFacadeWSDDServiceName = name; + } + + public WSExternalDataExchangeFacadeSrvProxy getWSExternalDataExchangeFacade() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + try { + endpoint = new java.net.URL(WSExternalDataExchangeFacade_address); + } + catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + return getWSExternalDataExchangeFacade(endpoint); + } + + public WSExternalDataExchangeFacadeSrvProxy getWSExternalDataExchangeFacade(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { + try { + WSExternalDataExchangeFacadeSoapBindingStub _stub = new WSExternalDataExchangeFacadeSoapBindingStub(portAddress, this); + _stub.setPortName(getWSExternalDataExchangeFacadeWSDDServiceName()); + return _stub; + } + catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setWSExternalDataExchangeFacadeEndpointAddress(String address) { + WSExternalDataExchangeFacade_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + try { + if (WSExternalDataExchangeFacadeSrvProxy.class.isAssignableFrom(serviceEndpointInterface)) { + WSExternalDataExchangeFacadeSoapBindingStub _stub = new WSExternalDataExchangeFacadeSoapBindingStub(new java.net.URL(WSExternalDataExchangeFacade_address), this); + _stub.setPortName(getWSExternalDataExchangeFacadeWSDDServiceName()); + return _stub; + } + } + catch (Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + String inputPortName = portName.getLocalPart(); + if ("WSExternalDataExchangeFacade".equals(inputPortName)) { + return getWSExternalDataExchangeFacade(); + } + else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "WSExternalDataExchangeFacadeSrvProxyService"); + } + + private java.util.HashSet ports = null; + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("http://47.102.220.6:6888/ormrpc/services/WSExternalDataExchangeFacade", "WSExternalDataExchangeFacade")); + } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(String portName, String address) throws javax.xml.rpc.ServiceException { + +if ("WSExternalDataExchangeFacade".equals(portName)) { + setWSExternalDataExchangeFacadeEndpointAddress(address); + } + else +{ // Unknown Port Name + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSInvokeException.java b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSInvokeException.java new file mode 100644 index 0000000..491f247 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jinghe/wxr/webservice/WSInvokeException.java @@ -0,0 +1,87 @@ +/** + * WSInvokeException.java + * + * This file was auto-generated from WSDL + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. + */ + +package weaver.taojw.jinghe.wxr.webservice; + +public class WSInvokeException extends org.apache.axis.AxisFault implements java.io.Serializable { + public WSInvokeException() { + } + + private Object __equalsCalc = null; + public synchronized boolean equals(Object obj) { + if (!(obj instanceof WSInvokeException)) return false; + WSInvokeException other = (WSInvokeException) obj; + if (obj == null) return false; + if (this == obj) return true; + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true; + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(WSInvokeException.class, true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:client.externaldataexchangefacade", "WSInvokeException")); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + String mechType, + Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanSerializer( + _javaType, _xmlType, typeDesc); + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + String mechType, + Class _javaType, + javax.xml.namespace.QName _xmlType) { + return + new org.apache.axis.encoding.ser.BeanDeserializer( + _javaType, _xmlType, typeDesc); + } + + + /** + * Writes the exception data to the faultDetails + */ + public void writeDetails(javax.xml.namespace.QName qname, org.apache.axis.encoding.SerializationContext context) throws java.io.IOException { + context.serialize(qname, null, this); + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/jkzcdemo/action/CreateTaskAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/jkzcdemo/action/CreateTaskAction.java new file mode 100644 index 0000000..10358dd --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/jkzcdemo/action/CreateTaskAction.java @@ -0,0 +1,129 @@ +package weaver.taojw.jkzcdemo.action; + +import org.apache.log4j.Logger; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.util.List; +import java.util.Map; + +/** + * 盘点计划归档后创建任务 + */ +public class CreateTaskAction implements Action { + + public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance(); + + public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo(); + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + try{ + logger.info("CreateTaskAction begin;requestid:" + requestId); + String getGlySql = + "select " + + "distinct " + + "t1.id,t1.lcbh,t1.fqr,t1.fqbm,t1.pdksrq,t1.pdjsrq,cast(t2.zczrr as varchar(800)) as zczrr,t3.departmentid,cast(t1.fqjg as varchar(800)) as fqjg,t1.fqrq,cast(t1.pdjhsm as varchar(800)) as pdjhsm " + + "from " + + "formtable_main_2340 t1 " + + "inner join formtable_main_2340_dt1 t2 on t2.mainid = t1.id " + + "inner join hrmresource t3 on t3.id = t2.zczrr " + + "where " + + "t1.requestid = ?"; + List> data = DaoUtil.getData(getGlySql, requestId); + int number = 0; + String lcbh = ""; + for(Map m : data){ + lcbh = m.get("lcbh"); + String mainid = m.get("id"); + String fqr = m.get("fqr"); + String fqbm = m.get("fqbm"); + String pdksrq = m.get("pdksrq"); + String pdjsrq = m.get("pdjsrq"); + String zczrr = m.get("zczrr"); + String fqjg = m.get("fqjg"); + String fqrq = m.get("fqrq"); + String pdjhsm = m.get("pdjhsm"); + String departmentid = m.get("departmentid"); + + + + String count = "0"; + String getCountSql = "select count(1) as c from formtable_main_2340_dt1 where mainid = ? and zczrr = ?"; + Map firstData = DaoUtil.getFirstData(getCountSql, mainid, zczrr); + count = firstData.get("c"); + + int newDataId = -1; + newDataId = mdu.getModeDataNewId("uf_PDRWGL", 1485, 1, 0, currentDate, currentTime); + //权限重构 + MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, 1485,newDataId); + + int finalNewDataId = newDataId; + new Thread(){ + @Override + public void run() { + try { + Thread.sleep(1000 * 10); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + String getSonLcIdSql = "select subrequestid from workflow_subwfrequest where mainrequestid = ?"; + List> data1 = DaoUtil.getData(getSonLcIdSql, requestId); + + for(Map m : data1){ + String sonRequestId = m.get("subrequestid"); + String getCreaterSql = "select creater from workflow_requestbase where requestid = ?"; + Map firstData = DaoUtil.getFirstData(getCreaterSql, sonRequestId); + logger.info("zczrr:" + zczrr + ";creater:" + firstData.get("creater") + ";finalNewDataId:" + finalNewDataId); + if(zczrr.equals(firstData.get("creater"))){ + String updateCountSql = "update uf_PDRWGL set xglc = ? where id = ?"; + DaoUtil.updateData(updateCountSql,sonRequestId, finalNewDataId); + logger.info("finalNewDataId:" + finalNewDataId + ";sonRequestId:" + sonRequestId); + } + } + } + }.start(); + + + + //更新数据 + String updateDateSql = + "update uf_PDRWGL set " + + "pdrwzt = 0, " + + "jsbm = ?,jsr = ?,jhbh = ?,xglc = ?,lcbh = ?," + + "fqr = ?,fqjg= ?,fqbm = ?,fqrq = ?,pdksrq = ?," + + "pdjsrq = ?,pdjhsm = ?,ypdzcsl = 0,sjzczs = ? " + + "where " + + "id = ?"; + DaoUtil.updateData(updateDateSql, + departmentid,zczrr,lcbh,requestId,lcbh, + fqr,fqjg,fqbm,fqrq,pdksrq, + pdjsrq,pdjhsm,count, + newDataId); + } + + //更新计划台账的资产数量 + String getCountSql = "select count(1) as c from formtable_main_2340 t1 inner join formtable_main_2340_dt1 t2 on t2.mainid = t1.id where t1.requestid = ?"; + Map m = DaoUtil.getFirstData(getCountSql, requestId); + String count = m.get("c"); + String updateSql = "update uf_PDJHGL set zcpdzs = ?,ypdsl = 0,pdjd = 0 where lcbh = ?"; + DaoUtil.updateData(updateSql,count,lcbh); + }catch(Exception e){ + logger.error("action exception;message:" + e.getMessage() + ";e:" + e); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("创建资产盘点计划任务数据异常,requestId:"+ requestInfo.getRequestid() +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/action/NccAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/action/NccAction.java new file mode 100644 index 0000000..7988ea1 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/action/NccAction.java @@ -0,0 +1,90 @@ +package weaver.taojw.pyzl.action; + +import com.alibaba.fastjson.JSONObject; +import nccloud.open.api.auto.token.cur.utils.APICurUtils; +import nccloud.open.api.auto.token.cur.utils.SHA256Util; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.pyzl.util.NcUtil; +import java.util.HashMap; +import java.util.Map; + +/** + * 浦银租赁NCC集成 + * action + * 流程数据转json 调用NCC接口 + * 需要jar包 OpenAPIUtil-1.0.1.jar + */ +public class NccAction implements Action { + + private String cusparam = ""; + + public String getCusparam() { + return cusparam; + } + + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------requestId:" + requestId); + RecordSet rs = new RecordSet(); + //step 1 ------------------------------------------------------流程数据转json + NcUtil ncUtil = new NcUtil(); + JSONObject jsonByWorkFlowData = ncUtil.execute(requestInfo,cusparam); + logger.info("NccAction.jsonByWorkFlowData done;jsonByWorkFlowData:" + jsonByWorkFlowData); + //step 2 ------------------------------------------------------调用NC token接口 + String NCC_IP = CommonSqlUtil.getSystemParamValue("nc_json_ip", rs); + String NCC_PORT = CommonSqlUtil.getSystemParamValue("nc_json_port", rs); + String NCC_BIZ_CENTER = CommonSqlUtil.getSystemParamValue("nc_json_biz_center", rs); + String NCC_CLIENT_ID = CommonSqlUtil.getSystemParamValue("nc_json_client_id", rs); + String NCC_CLIENT_SECRET = CommonSqlUtil.getSystemParamValue("nc_json_client_secret", rs); + String NCC_PUBKEY = CommonSqlUtil.getSystemParamValue("nc_json_pubKey", rs); + APICurUtils util = new APICurUtils(); + util.init(NCC_IP, NCC_PORT, NCC_BIZ_CENTER, NCC_CLIENT_ID, NCC_CLIENT_SECRET, NCC_PUBKEY, null, null); + logger.info("NccAction.token begin;NCC_IP:" + NCC_IP + ";NCC_PORT:" + NCC_PORT + ";NCC_BIZ_CENTER:" + NCC_BIZ_CENTER + ";NCC_CLIENT_ID:" + NCC_CLIENT_ID + ";NCC_CLIENT_SECRET:" + NCC_CLIENT_SECRET + ";NCC_PUBKEY:" + NCC_PUBKEY); + String tokenString = util.getTokenByClient(); + logger.info("tokenString:"+tokenString); + JSONObject tokenJson = JSONObject.parseObject(tokenString); + String accessToken = tokenJson.getJSONObject("data").getString("access_token"); + logger.info("NccAction.token done;token:" + tokenString); + //step 3 ------------------------------------------------------调用NC 凭证接口 + String NCC_URL = CommonSqlUtil.getSystemParamValue("nc_json_url", rs); + String toSignString = NCC_CLIENT_ID+jsonByWorkFlowData.toJSONString(); + String sha256 = SHA256Util.getSHA256(toSignString, NCC_PUBKEY); + Map headers = new HashMap<>(); + headers.put("access_token",accessToken); + headers.put("ucg_flag","Y"); + headers.put("signature",sha256); + headers.put("client_id",NCC_CLIENT_ID); + Map post = TjwHttpUtil.sendHttpRequest(NCC_URL, jsonByWorkFlowData.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + JSONObject responseData = JSONObject.parseObject((String) post.get("data")); + String success = responseData.getString("success"); + if("true".equals(success)){ + return Action.SUCCESS; + } + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NccAction失败,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + }catch(Throwable e){ + requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString() + requestId); + requestInfo.getRequestManager().setMessagecontent("NccAction接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("NccAction error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/action/NccApi.java b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/action/NccApi.java new file mode 100644 index 0000000..d97926e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/action/NccApi.java @@ -0,0 +1,106 @@ +package weaver.taojw.pyzl.action; + +import com.alibaba.fastjson.JSONObject; +import nccloud.open.api.auto.token.cur.utils.APICurUtils; +import nccloud.open.api.auto.token.cur.utils.SHA256Util; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.TjwHttpUtil; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.pyzl.util.NcModeUtil; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * 浦银租赁NCC集成 + * action + * 流程数据转json 调用NCC接口 + * 需要jar包 OpenAPIUtil-1.0.1.jar + */ +@Path("/bogetjw") +public class NccApi { + + private String cusparam = ""; + + public String getCusparam() { + return cusparam; + } + + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + + Logger logger = MyLogger.getLogger(); + + @POST + @Path("/createBom") + @Produces(MediaType.APPLICATION_JSON) + public String createBom(@Context HttpServletRequest request, @Context HttpServletResponse response){ + JSONObject result = new JSONObject(); + try{ + logger.info("----------------------" + this.getClass() + " NccApi begin"); + RecordSet rs = new RecordSet(); + String modeId = request.getParameter("modeId"); + String _dataId = request.getParameter("dataId"); + if("".equals(_dataId) || _dataId == null){ + return result.toJSONString(); + } + String configId = request.getParameter("configId"); + String[] idArr = _dataId.split(","); + for(String dataId:idArr){ + //step 1 ------------------------------------------------------流程数据转json + NcModeUtil ncUtil = new NcModeUtil(); + JSONObject jsonByWorkFlowData = ncUtil.execute(modeId,dataId,configId); + logger.info("NccAction.jsonByWorkFlowData done;jsonByWorkFlowData:" + jsonByWorkFlowData); + //step 2 ------------------------------------------------------调用NC token接口 + String NCC_IP = CommonSqlUtil.getSystemParamValue("nc_json_ip", rs); + String NCC_PORT = CommonSqlUtil.getSystemParamValue("nc_json_port", rs); + String NCC_BIZ_CENTER = CommonSqlUtil.getSystemParamValue("nc_json_biz_center", rs); + String NCC_CLIENT_ID = CommonSqlUtil.getSystemParamValue("nc_json_client_id", rs); + String NCC_CLIENT_SECRET = CommonSqlUtil.getSystemParamValue("nc_json_client_secret", rs); + String NCC_PUBKEY = CommonSqlUtil.getSystemParamValue("nc_json_pubKey", rs); + APICurUtils util = new APICurUtils(); + util.init(NCC_IP, NCC_PORT, NCC_BIZ_CENTER, NCC_CLIENT_ID, NCC_CLIENT_SECRET, NCC_PUBKEY, null, null); + logger.info("NccAction.token begin;NCC_IP:" + NCC_IP + ";NCC_PORT:" + NCC_PORT + ";NCC_BIZ_CENTER:" + NCC_BIZ_CENTER + ";NCC_CLIENT_ID:" + NCC_CLIENT_ID + ";NCC_CLIENT_SECRET:" + NCC_CLIENT_SECRET + ";NCC_PUBKEY:" + NCC_PUBKEY); + String tokenString = util.getTokenByClient(); + logger.info("tokenString:"+tokenString); + JSONObject tokenJson = JSONObject.parseObject(tokenString); + String accessToken = tokenJson.getJSONObject("data").getString("access_token"); + logger.info("NccAction.token done;token:" + tokenString); + //step 3 ------------------------------------------------------调用NC 凭证接口 + String NCC_URL = CommonSqlUtil.getSystemParamValue("nc_json_url", rs); + String toSignString = NCC_CLIENT_ID+jsonByWorkFlowData.toJSONString(); + String sha256 = SHA256Util.getSHA256(toSignString, NCC_PUBKEY); + Map headers = new HashMap<>(); + headers.put("access_token",accessToken); + headers.put("ucg_flag","Y"); + headers.put("signature",sha256); + headers.put("client_id",NCC_CLIENT_ID); + Map post = TjwHttpUtil.sendHttpRequest(NCC_URL, jsonByWorkFlowData.toJSONString(), "POST", ContentType.APPLICATION_JSON, headers); + JSONObject responseData = JSONObject.parseObject((String) post.get("data")); + String success = responseData.getString("success"); + if(!"true".equals(success)){ + result.put("flag","fail"); + return result.toJSONString(); + } + } + result.put("flag","success"); + return result.toJSONString(); + }catch(Throwable e){ + logger.error("NccApi error;message:" + e.getMessage()); + result.put("flag","fail"); + return result.toJSONString(); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/util/NcModeUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/util/NcModeUtil.java new file mode 100644 index 0000000..93b6770 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/util/NcModeUtil.java @@ -0,0 +1,965 @@ +package weaver.taojw.pyzl.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.xml.sax.InputSource; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.taojw.common.CommonSqlUtil; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.StringReader; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class NcModeUtil { + + Logger logger = MyLogger.getLogger(); + private int CONNECT_TIMEOUT = 1800000;//请求超时时间 + + private String voucher_keyid = "";//单据主键(生成规则,年份+时间戳) + + //ITEM中辅助核算项配置 + private List> detail_item_ass_list = new ArrayList>(); + //借方金额Map<借方对应的贷方XML名称,金额值> + private Map debitamount_map = new HashMap(); + //ITEM中现金流量字段配置(普通借方) + private List> detail_item_cas_list = new ArrayList>(); + //ITEM中现金流量字段配置(税额借方) + private List> tax_item_cas_list = new ArrayList>(); + //明细分录序号 + private int rownum = 0; + + private String cusparam = "";//自定义参数 + + private DecimalFormat df = new DecimalFormat("#####################0.00"); + + /** + * 实现父类方法 + * @return + */ + public JSONObject execute(String modeId,String dataId,String configId){ + JSONObject result = new JSONObject(); + rownum = 0; + + debitamount_map.clear(); + detail_item_ass_list.clear(); + detail_item_cas_list.clear(); + tax_item_cas_list.clear(); + + + logger.info("-------------------------WorkflowDataToNC_Action Begin-------------------------cusparam:"+cusparam); + String billid = dataId; + //获取流程类型ID + //String workflowid = Util.null2String(requestInfo.getWorkflowid()); + //logger.info("workflowid:" + workflowid); + //获取流程请求ID + //String this_requestid = Util.null2String(requestInfo.getRequestid()); + //获取流程表单ID + String getFormIdSql = "select * from modeinfo where id = ?"; + RecordSet rs = new RecordSet(); + Map firstData = DaoUtil.getFirstData(rs, getFormIdSql, modeId); + + int formid = Util.getIntValue(firstData.get("formid"),-1); + + + //获取当前流程配置信息 + String select_main_config_sql = "select * from uf_voucher_mode_inf where id = ?"; + + + + logger.info("select_main_config_sql:" + select_main_config_sql); + + //配置表主表主键 + int config_main_key = -1; + //组织代码字段 + String orgcode_fieldname = ""; + //控制条件 + String condition = ""; + //明细表序列 + int detailindex = -1; + //是否有现金流量 + int hascash = 1; + + if(rs.executeQuery(select_main_config_sql,configId)){ + if(rs.next()){ + config_main_key = Util.getIntValue(rs.getString("id"),0); + + orgcode_fieldname = Util.null2String(rs.getString("orgcode_fieldname")); + + condition = Util.null2String(rs.getString("condition")); + + detailindex = Util.getIntValue(rs.getString("detailindex"),0); + + hascash = Util.getIntValue(rs.getString("hascash"),0); + } + } + + logger.info("配置主表主键值:[" + config_main_key + "]"); + + //凭证头字段配置 + List> voucher_head_list = new ArrayList>(); + //凭证Item字段配置(普通借方) + List> debit_detail_item_list = new ArrayList>(); + //凭证Item字段配置(税额借方) + List> tax_detail_item_list = new ArrayList>(); + + + //凭证Item字段配置(差旅税额借方) + List> trip_tax_detail_item_list = new ArrayList>(); + + //凭证Item字段配置(贷方) + List> credit_detail_item_list = new ArrayList>(); + + + if(config_main_key > 0) {//说明该流程存在配置 + //获取当前流程明细字段配置信息 + String select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_mode_inf_dt1 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //XML节点名称 + String xmlfield = Util.null2String(rs.getString("xmlfield")); + //XML节点所属 + int xmlbelongto = Util.getIntValue(rs.getString("xmlbelongto"),0); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + //特殊属性 + int special_attribute = Util.getIntValue(rs.getString("special_attribute"),0); + //相对应的贷方XML节点名称 + String counterxml = Util.null2String(rs.getString("counterXML")); + //分录类型 + int itemType = Util.getIntValue(rs.getString("itemType"),0); + //是否金额校验字段 + int isvalidate = Util.getIntValue(rs.getString("isvalidate"),0); + + if(!"".equals(xmlfield)){ + Map detail_map = new HashMap(); + + detail_map.put("xmlfield",xmlfield); + detail_map.put("xmlbelongto",xmlbelongto); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + detail_map.put("special_attribute",special_attribute); + detail_map.put("counterxml",counterxml); + detail_map.put("isvalidate",isvalidate); + detail_map.put("itemType",itemType); + + if(xmlbelongto == 0) {//凭证头字段配置集合 + voucher_head_list.add(detail_map); + }else{//明细分录字段配置 + if(xmlbelongto != 2){//details-item 明细凭证 + if(itemType == 1){//税额借方 + tax_detail_item_list.add(detail_map); + }else if(itemType == 2){//贷方 + credit_detail_item_list.add(detail_map); + }else if(itemType == 0){//普通借方 + debit_detail_item_list.add(detail_map); + }else if(itemType == 3){//差旅税额借方 + trip_tax_detail_item_list.add(detail_map); + } + }else{//cashFlow-item 现金流量 +// if(itemType == 1){//税额借方 +// tax_item_cas_list.add(detail_map); +// }else{//普通借方 + detail_item_cas_list.add(detail_map); +// } + } + } + } + } + } + + //获取辅助核算项的配置信息 + select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_mode_inf_dt2 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //辅助核算项类型(0:个人1:部门) + int checktype = Util.getIntValue(rs.getString("checktype"),0); + //辅助核算项类型编码 + String typecode = Util.null2String(rs.getString("typecode")); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + + + Map detail_map = new HashMap(); + + detail_map.put("checktype",checktype); + detail_map.put("typecode",typecode); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + + detail_item_ass_list.add(detail_map); + + } + } + } + + RecordSet rs_main = new RecordSet(); + + //流程主表主键 + int workflow_main_key = 0; + //组织代码字段值 + String orgcode_fieldvalue = ""; + + //获取流程主表信息 + String table = CommonSqlUtil.getTableNameByModeId(modeId,rs); + String select_workflow_main = "select * from " + table + " where id=? "; + + if(!"".equals(condition)){ + select_workflow_main += condition; + } + + logger.info("查询流程主表数据:[" + select_workflow_main + "],[" + dataId + "]"); + + if(rs_main.executeQuery(select_workflow_main,dataId)){ + + if(rs_main.next()) { + + workflow_main_key = Util.getIntValue(rs_main.getString("id"), 0); + + orgcode_fieldvalue = Util.null2String(rs_main.getString(orgcode_fieldname)); + }else{//若数据不存在,则直接跳过 + + logger.info("-------------------------WorkflowDataToNC_Action(未传凭证) End-------------------------"); + return result; + } + } + + StringBuffer sendxml = new StringBuffer(); + + sendxml.append(""); + sendxml.append(""); + + long timestamp = System.currentTimeMillis() / 10; + + //获取当前日期 + String currentday = TimeUtil.getCurrentDateString(); + //获取当前年份(后两位) + String year = currentday.substring(2,4); + + voucher_keyid = year + timestamp; + + sendxml.append(""); + + sendxml.append(""); + + //获取Header字段配置 + if(voucher_head_list != null && voucher_head_list.size() > 0){ + for(Map detail_map : voucher_head_list){ + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + + if("".equals(xmlfield)){//若XML节点名称为空,则直接跳过 + continue; + } + + //判断OA字段来源 + int viewtype = Util.getIntValue(detail_map.get("viewtype").toString(),0); + + if(viewtype > 0){//说明配置的字段来自明细表,则该字段配置有误,直接跳过 + logger.info("--Error-->字段【" + xmlfield + "】配置有误,请检查!"); + continue; + } + + String fieldval = getFieldValue(detail_map,rs_main,null,new String[]{"","","",""},billid); + result.put(xmlfield,fieldval); + sendxml.append("<").append(xmlfield).append(">"); + sendxml.append(fieldval); + sendxml.append(""); + } + } + + if(debit_detail_item_list != null && debit_detail_item_list.size() > 0){ + JSONArray details = new JSONArray(); + result.put("detail",details); + sendxml.append("
"); + if(detailindex > 0 && workflow_main_key > 0){ + + RecordSet rs_detail = new RecordSet(); + String select_workflow_detail = "select * from formtable_main_" + Math.abs(formid) + "_dt1 where mainid = ? "; + + if(rs_detail.executeQuery(select_workflow_detail,workflow_main_key)){ + + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,rs_detail,new String[]{"","","",""},hascash,details,billid); + + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,rs_detail,new String[]{"","","",""},hascash,details,billid); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + logger.info("差旅税额借方分录XML begin;"); + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,rs_detail,new String[]{"","","",""},hascash,details,billid); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + logger.info("普通贷方分录 begin;rownum:" + rownum); + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info("getFieldValue begin;"); + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,new String[]{"","","",""},billid); + logger.info("getFieldValue end"); + if(special_attribute == 1){//辅助核算项字段 + + if(!"".equals(fieldval) && detail_item_ass_list != null){ + logger.info("getAssistingAccountItemInfo begin"); + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,rs_detail,new String[]{"","","",""},credit_ass_xml_jsonArray,billid); + logger.info("getAssistingAccountItemInfo end"); + } + }else if (special_attribute == 3) {//贷方金额(合计) + logger.info("贷方金额(合计) begin"); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + logger.info("贷方金额(合计) end"); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + logger.info("here"); + //获取现金流量信息 + /* + String credit_cash_flow_xml = ""; + credit_cash_flow_xml += ""; + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + String fieldval = df.format(amount_sum); + + credit_cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + } + credit_cash_flow_xml += ""; + */ + + credit_item_xml.append(""); + // + credit_item_xml_json.put("detailindex",++rownum); + credit_item_xml.append("").append(rownum).append(""); + + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + + }else{//说明字段都来自主表 + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,null,new String[]{"","","",""},hascash,details,billid); + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,null,new String[]{"","","",""},hascash,details,billid); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,null,new String[]{"","","",""},hascash,details,billid); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info(""); + String fieldval = getFieldValue(detail_map, rs_main, null,new String[]{"","","",""},billid); + + if(special_attribute == 1){//辅助核算项字段 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,null,new String[]{"","","",""},credit_ass_xml_jsonArray,billid); + } + }else if (special_attribute == 3) {//贷方金额(合计) + double amount_sum = 0.0; + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + + credit_item_xml.append(""); + // + credit_item_xml.append("").append(++rownum).append(""); + credit_item_xml_json.put("detailindex",rownum); + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + sendxml.append("
"); + } + sendxml.append("
"); + sendxml.append("
"); + sendxml.append("
"); + + logger.info("发送的XML格式为:【" + sendxml.toString() + "】"); + logger.info("result json:" + result.toJSONString()); + logger.info("-------------------------WorkflowDataToNC_Action End-------------------------"); + return result; + } + + /** + * 解析XML字符串 + * @param xml + * @return + */ + @SuppressWarnings("unchecked") + public Map analysisXML(String xml){ + Map resultMap = new HashMap(); + try{ + //创建一个新的字符串 + StringReader read = new StringReader(xml); + //创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入 + InputSource source = new InputSource(read); + //创建一个新的SAXBuilder + SAXBuilder sb = new SAXBuilder(); + //通过输入源构造一个Document + Document doc = sb.build(source); + //取根元素 + Element root = doc.getRootElement(); + //获取ufinterface根节点中的子节点 + List child = root.getChildren(); + //获取ufinterface根节点中第一个子节点 sendresult + Element first_child = (Element)child.get(0); + + //获取formdata根节点中的子节点 + List first_child_grands = first_child.getChildren(); + for(int i = 0 ; i < first_child_grands.size();i++){ + Element leave = (Element)first_child_grands.get(i); + + resultMap.put(leave.getName(), leave.getText()); + //System.err.println("--------" + i + "--->" + leave.getText() + "/" + leave.getName()); + } + }catch (Exception e) { + // TODO: handle exception + logger.info("解析XML字符串异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } + + return resultMap; + } + + /** + * 生成借方分录XML + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @return + */ + private StringBuffer generate_debit_item_xml(int itemType, int itemDirection, List> detail_field_list, RecordSet rs_main, RecordSet rs_detail, String[] baseArray, int hascash, JSONArray details,String billid){ + StringBuffer debit_item_xml = new StringBuffer(""); + + if(rs_detail != null){ + while(rs_detail.next()){ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, rs_detail, baseArray, debit_item_xml,hascash,details,billid); + } + }else{ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, null, baseArray, debit_item_xml,hascash,details,billid); + } + + return debit_item_xml; + } + + /** + * + * @param itemDirection + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @param baseArray + * @param debit_item_xml + * @param hascash + */ + private void generate_debitItem_Only_xml(int itemType,int itemDirection, List> detail_field_list, + RecordSet rs_main, RecordSet rs_detail, String[] baseArray, StringBuffer debit_item_xml,int hascash,JSONArray details,String billid) { + //循环明细表记录,对借方分录进行拼接 + StringBuffer inner_xml = new StringBuffer(); + JSONObject inner_xml_json = new JSONObject(); + //辅助核算项配置 + String ass_xml = ""; + JSONArray ass_xml_jsonArray = new JSONArray(); + //该行明细是否需要生成会计分录 + boolean isValidate_Success = true; + + for(Map detail_map : detail_field_list){ + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(),0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String counterxml = Util.null2String(detail_map.get("counterxml").toString()); + String fieldval = getFieldValue(detail_map,rs_main,rs_detail,baseArray,billid); + + int isvalidate = Util.getIntValue(detail_map.get("isvalidate").toString(),0); + //借方分录金额合计值 + double amount_sum = 0.0; + + if(special_attribute == 1){//辅助核算项字段 + //获取该科目类型对应的辅助核算项有哪些 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + ass_xml = getAssistingAccountItemInfo(itemDirection,fieldval,rs_main,rs_detail,baseArray,ass_xml_jsonArray,billid); + } + }else if(special_attribute == 2){//借方金额(合计) + amount_sum = Util.getDoubleValue(fieldval,0.0); + + if (isvalidate == 1 && amount_sum == 0){//表示该字段为金额校验字段,若为空,则改行不需要生成分录 + isValidate_Success = false; + break; + } + + if(!"".equals(counterxml)){//对应的贷方XML字段名称 + if(debitamount_map.containsKey(counterxml)){//判断该字段对应的贷方XML是否存在 + double old_debitamount = debitamount_map.get(counterxml); + + double new_debitamount = amount_sum + old_debitamount; + + debitamount_map.put(counterxml,new_debitamount); + }else{ + debitamount_map.put(counterxml, amount_sum); + } + } + + fieldval = df.format(amount_sum); + }else if(special_attribute == 3){//贷方金额(合计) + fieldval = "0.00"; + } + + inner_xml.append("<").append(xmlfield).append(">"); + inner_xml.append(fieldval); + inner_xml.append(""); + inner_xml_json.put(xmlfield,fieldval); + } + + if(isValidate_Success) { + //获取现金流量信息 + JSONObject cash_flow_xml_json = new JSONObject(); + String cash_flow_xml = ""; + cash_flow_xml += ""; + +// List> cash_list = null;//new ArrayList>(); + +// if(itemDirection == 1){//税额借方 +// cash_list = tax_item_cas_list; +// }else{//普通借方 +// cash_list = detail_item_cas_list; +// } + + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String fieldname = Util.null2String(detail_map.get("fieldname").toString()); + int rowitemType = (Integer)detail_map.get("itemType"); + + logger.info("rowitemType:[" + rowitemType + "],xmlfield:[" + xmlfield + "],fieldname:[" + fieldname + "],itemType:[" + itemType + "]"); + + if(itemType != rowitemType){ + continue; + } + + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,baseArray,billid); + + logger.info("fieldval:[" + fieldval + "]"); + + cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + cash_flow_xml_json.put(xmlfield,fieldval); + } + cash_flow_xml += ""; + + JSONObject debit_item_xml_json = new JSONObject(); + + + debit_item_xml.append(""); + debit_item_xml_json.put("detailindex",++rownum); + // + debit_item_xml.append("").append(rownum).append(""); + //普通字段 + debit_item_xml.append(inner_xml.toString()); + debit_item_xml_json.putAll(inner_xml_json); + + //辅助核算项 + debit_item_xml.append(""); + debit_item_xml.append(ass_xml); + debit_item_xml.append(""); + + debit_item_xml_json.put("ass",ass_xml_jsonArray); + + + if(hascash == 1){ + //现金流量 + debit_item_xml.append(""); + debit_item_xml.append(cash_flow_xml); + debit_item_xml.append(""); + + JSONArray cashFlow = new JSONArray(); + cashFlow.add(cash_flow_xml_json); + debit_item_xml_json.put("cashflow",cashFlow); + } + + debit_item_xml.append(""); + details.add(debit_item_xml_json); + } + } + + /** + * 获取借方分录【科目】/贷方【公司银行】的辅助核算项配置 + * @param itemDirection 分录方向 [0-借方分录(普通) 、1-借方分录(税额) 、2-贷方分录] + * @param subjectid 科目主键 + * @param rs_main 流程主表查询结果数据集 + * @param rs_detail 当前行明细表查询结果数据集 + * @return String 科目辅助核算项的XML + */ + private String getAssistingAccountItemInfo(int itemDirection,String subjectid,RecordSet rs_main,RecordSet rs_detail,String[] baseArray,JSONArray ass_xml_jsonArray,String billid){ + String select_sql = ""; + RecordSet rs = new RecordSet(); + + String ass_xml = ""; + + //辅助核算项类型(0 : 部门 1-部门+人员 2:人员) + int checkType = 0; + + + if(itemDirection == 0){//若为普通的借方分录,则根据科目,获取该科目应该对应的辅助核算项类型 + select_sql = "select * from uf_kmjbxx where kembm = ?"; + + if(rs.executeQuery(select_sql,subjectid)){ + rs.next(); + + checkType = Util.getIntValue(rs.getString("fuzhslx"),0); + } + } + + for(Map detail_map : detail_item_ass_list){//循环辅助核算项字段配置信息 + int row_checktype = Util.getIntValue(detail_map.get("checktype").toString(),0); + + String typecode = Util.null2String(detail_map.get("typecode").toString()); + String fieldvalue = getFieldValue(detail_map,rs_main,rs_detail,baseArray,billid); + + if(itemDirection == 0){ + logger.info("--------------普通借方辅助核算项 Begin--------------------"); + + logger.info("checkType:[" + checkType + "],row_checktype:[" + row_checktype + "],typecode:[" + typecode + "],fieldvalue:[" + fieldvalue + "]"); + + logger.info("--------------普通借方辅助核算项 End--------------------"); + } + + if(itemDirection == 0) {//普通借方分录 + if ((checkType == 0 && row_checktype == 0) || row_checktype == 2 || row_checktype == 3) {//该科目辅助核算项只有部门,而配置中出现人员(或者辅助核算类型为税额、银行存款的也跳过),则人员配置跳过 + continue; + } + }else if(itemDirection == 1 && row_checktype != 2){//税额借方分录 + continue; + }else if(itemDirection == 2 && row_checktype != 3){//贷方分录 + continue; + } + + /* + String checkType_val = ""; + + if(row_checktype == 0){//人员 + checkType_val = "0002"; + }else{//部门 + checkType_val = "0001"; + } + */ + ass_xml += ""; + ass_xml += "" + typecode + ""; + ass_xml += "" + fieldvalue + ""; + ass_xml += ""; + JSONObject o = new JSONObject(); + o.put("checktypecode",typecode); + o.put("checkvaluecode",fieldvalue); + ass_xml_jsonArray.add(o); + } + + return ass_xml; + } + + /** + * 获取字段值 + * @param configMap + * @param rs + * @param rs_detail + * @return + */ + private String getFieldValue(Map configMap,RecordSet rs,RecordSet rs_detail,String[] baseArray,String billid){ + //流程字段名称 + String wffieldname = Util.null2String(configMap.get("fieldname").toString()); + //转换规则 + int changerule = Util.getIntValue(configMap.get("changerule").toString(),0); + //自定义规则 + String cussql = Util.null2String(configMap.get("cussql").toString()); + + //流程字段所属 + int viewtype = Util.getIntValue(configMap.get("viewtype").toString(),0); + + logger.info("wffieldname:" + wffieldname + ";changerule:" + changerule + ";cussql:" + cussql + ";viewtype:" + viewtype); + + //流程字段值 + String wffieldvalue = ""; + //明细表主键 + String detail_keyid = ""; + + + if(!"".equals(wffieldname)){ + if(viewtype == 0){//主表 + wffieldvalue = Util.null2String(rs.getString(wffieldname)); + }else{//明细表 + wffieldvalue = Util.null2String(rs_detail.getString(wffieldname)); + + } + } + if(rs_detail != null){ + detail_keyid = Util.null2String(rs_detail.getString("id")); + } + + if(changerule == 1){//表示流程REQUESTID + wffieldvalue = baseArray[0]; + }else if(changerule == 2){//表示流程标题 + wffieldvalue = baseArray[1]; + }else if(changerule == 3){//表示流程编号 + wffieldvalue = baseArray[2]; + }else if(changerule == 4) {//表示系统日期 + wffieldvalue = TimeUtil.getCurrentDateString().toString(); + }else if(changerule == 5){//系统日期时间 + wffieldvalue = TimeUtil.getCurrentTimeString(); + }else if(changerule == 6){//表示固定值 + wffieldvalue = cussql; + }else if(changerule == 7){//表示明细行号 + wffieldvalue = String.valueOf(rownum); + }else if(changerule == 8) {//表示自定义转换 + //if(!"".equals(wffieldvalue)){ + String changevalue = getValueByChangeRule(cussql, wffieldvalue,detail_keyid,baseArray[0],billid); + logger.info("changevalue:[" + changevalue + "]"); + wffieldvalue = changevalue; + //} + }else if(changerule == 9){ + wffieldvalue = voucher_keyid; + }else{//表示不转换 + //wffieldvalue + } + + //XML特殊字符处理 + wffieldvalue = wffieldvalue.replace("<", "<"); + wffieldvalue = wffieldvalue.replace(">", ">"); + wffieldvalue = wffieldvalue.replace("&", "&"); + wffieldvalue = wffieldvalue.replace("'", "'"); + wffieldvalue = wffieldvalue.replace("\"", """); + + return wffieldvalue; + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的规则 + * @param value + * @return + */ + private String getValueByChangeRule(String cus_sql,String value,String detail_keyid,String this_requestid,String billid){ + String endValue = ""; + + cus_sql = cus_sql.replace(" ", " "); + + cus_sql = cus_sql.replace("{?dt.id}", detail_keyid); + + String sqlString = cus_sql.replace("{?billid}", billid).replace("?", value); + + RecordSet rs = new RecordSet(); + + if(rs.executeSql(sqlString)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + + return endValue; + } + + + /** + * 获取系统参数设置值 + * @param ssid + * @return + */ + public String getSystemParamValue(String ssid){ + String paramvalue = ""; + + if(!"".equals(ssid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,ssid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * @return the cusparam + */ + public String getCusparam() { + return cusparam; + } + + /** + * @param cusparam the cusparam to set + */ + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/util/NcUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/util/NcUtil.java new file mode 100644 index 0000000..71d175e --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/pyzl/util/NcUtil.java @@ -0,0 +1,990 @@ +package weaver.taojw.pyzl.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.xml.sax.InputSource; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; +import java.io.StringReader; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class NcUtil { + + Logger logger = MyLogger.getLogger(); + private int CONNECT_TIMEOUT = 1800000;//请求超时时间 + + private String voucher_keyid = "";//单据主键(生成规则,年份+时间戳) + + //ITEM中辅助核算项配置 + private List> detail_item_ass_list = new ArrayList>(); + //借方金额Map<借方对应的贷方XML名称,金额值> + private Map debitamount_map = new HashMap(); + //ITEM中现金流量字段配置(普通借方) + private List> detail_item_cas_list = new ArrayList>(); + //ITEM中现金流量字段配置(税额借方) + private List> tax_item_cas_list = new ArrayList>(); + //明细分录序号 + private int rownum = 0; + + private String cusparam = "";//自定义参数 + + private DecimalFormat df = new DecimalFormat("#####################0.00"); + + /** + * 实现父类方法 + * @param requestInfo + * @return + */ + public JSONObject execute(RequestInfo requestInfo,String _cusparam){ + cusparam = _cusparam; + JSONObject result = new JSONObject(); + rownum = 0; + + debitamount_map.clear(); + detail_item_ass_list.clear(); + detail_item_cas_list.clear(); + tax_item_cas_list.clear(); + + + logger.info("-------------------------WorkflowDataToNC_Action Begin-------------------------cusparam:"+cusparam); + //获取流程类型ID + String workflowid = Util.null2String(requestInfo.getWorkflowid()); + logger.info("workflowid:" + workflowid); + //获取流程请求ID + String this_requestid = Util.null2String(requestInfo.getRequestid()); + //获取流程表单ID + int formid = requestInfo.getRequestManager().getFormid(); + + String this_requestname = "";//流程标题 + String this_requestmark = "";//流程编号 + + //获取流程事务 + RecordSetTrans rsts = requestInfo.getRsTrans(); + + //获取流程基础数据 + String select_base_sql = "select * from workflow_requestbase where requestid = ?"; + try { + if(rsts == null){ + rsts = new RecordSetTrans(); + } + if(rsts.executeQuery(select_base_sql,this_requestid)){ + while(rsts.next()){ + this_requestname = Util.null2String(rsts.getString("requestname")); + this_requestmark = Util.null2String(rsts.getString("requestmark")); + } + } + logger.info("this_requestname:[" + this_requestname + "],this_requestmark:[" + this_requestmark + "],workflowid:["+workflowid+"],this_requestid:[" + this_requestid + "],formid:[" + formid + "]"); + } catch (Exception e1) { + logger.info("获取该流程事物数据集异常:[" + e1.getMessage() + "/" + e1.toString() + "]"); + return result; + } + + String[] baseArray = {this_requestid,this_requestname,this_requestmark}; + + RecordSet rs = new RecordSet(); + + //获取当前流程配置信息 + String select_main_config_sql = "select * from uf_voucher_info where workflowid in (select id from workflow_base where id = ? or activeVersionID = ?)"; + + if(!"".equals(cusparam)){ + select_main_config_sql += " and cusparam = '" + cusparam + "'"; + } + + logger.info("select_main_config_sql:" + select_main_config_sql); + + //配置表主表主键 + int config_main_key = -1; + //组织代码字段 + String orgcode_fieldname = ""; + //控制条件 + String condition = ""; + //明细表序列 + int detailindex = -1; + //是否有现金流量 + int hascash = 1; + + if(rs.executeQuery(select_main_config_sql,workflowid,workflowid)){ + if(rs.next()){ + config_main_key = Util.getIntValue(rs.getString("id"),0); + + orgcode_fieldname = Util.null2String(rs.getString("orgcode_fieldname")); + + condition = Util.null2String(rs.getString("condition")); + + detailindex = Util.getIntValue(rs.getString("detailindex"),0); + + hascash = Util.getIntValue(rs.getString("hascash"),0); + } + } + + logger.info("配置主表主键值:[" + config_main_key + "]"); + + //凭证头字段配置 + List> voucher_head_list = new ArrayList>(); + //凭证Item字段配置(普通借方) + List> debit_detail_item_list = new ArrayList>(); + //凭证Item字段配置(税额借方) + List> tax_detail_item_list = new ArrayList>(); + + + //凭证Item字段配置(差旅税额借方) + List> trip_tax_detail_item_list = new ArrayList>(); + + //凭证Item字段配置(贷方) + List> credit_detail_item_list = new ArrayList>(); + + + if(config_main_key > 0) {//说明该流程存在配置 + //获取当前流程明细字段配置信息 + String select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_info_dt1 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //XML节点名称 + String xmlfield = Util.null2String(rs.getString("xmlfield")); + //XML节点所属 + int xmlbelongto = Util.getIntValue(rs.getString("xmlbelongto"),0); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + //特殊属性 + int special_attribute = Util.getIntValue(rs.getString("special_attribute"),0); + //相对应的贷方XML节点名称 + String counterxml = Util.null2String(rs.getString("counterXML")); + //分录类型 + int itemType = Util.getIntValue(rs.getString("itemType"),0); + //是否金额校验字段 + int isvalidate = Util.getIntValue(rs.getString("isvalidate"),0); + + if(!"".equals(xmlfield)){ + Map detail_map = new HashMap(); + + detail_map.put("xmlfield",xmlfield); + detail_map.put("xmlbelongto",xmlbelongto); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + detail_map.put("special_attribute",special_attribute); + detail_map.put("counterxml",counterxml); + detail_map.put("isvalidate",isvalidate); + detail_map.put("itemType",itemType); + + if(xmlbelongto == 0) {//凭证头字段配置集合 + voucher_head_list.add(detail_map); + }else{//明细分录字段配置 + if(xmlbelongto != 2){//details-item 明细凭证 + if(itemType == 1){//税额借方 + tax_detail_item_list.add(detail_map); + }else if(itemType == 2){//贷方 + credit_detail_item_list.add(detail_map); + }else if(itemType == 0){//普通借方 + debit_detail_item_list.add(detail_map); + }else if(itemType == 3){//差旅税额借方 + trip_tax_detail_item_list.add(detail_map); + } + }else{//cashFlow-item 现金流量 +// if(itemType == 1){//税额借方 +// tax_item_cas_list.add(detail_map); +// }else{//普通借方 + detail_item_cas_list.add(detail_map); +// } + } + } + } + } + } + + //获取辅助核算项的配置信息 + select_detail_config_sql = "select dt.*,wb.fieldname,wb.viewtype from uf_voucher_info_dt2 dt left join workflow_billfield wb on dt.oafieldid = wb.id where dt.mainid = ?"; + + if(rs.executeQuery(select_detail_config_sql,config_main_key)){ + while(rs.next()){ + //辅助核算项类型(0:个人1:部门) + int checktype = Util.getIntValue(rs.getString("checktype"),0); + //辅助核算项类型编码 + String typecode = Util.null2String(rs.getString("typecode")); + //OA流程字段 + String fieldname = Util.null2String(rs.getString("fieldname")); + //OA流程字段所属 + int viewtype = Util.getIntValue(rs.getString("viewtype"),0); + //转换规则 + int changerule = Util.getIntValue(rs.getString("changerule"),0); + //自定义转换规则 + String cussql = Util.null2String(rs.getString("cussql")); + + + Map detail_map = new HashMap(); + + detail_map.put("checktype",checktype); + detail_map.put("typecode",typecode); + detail_map.put("fieldname",fieldname); + detail_map.put("viewtype",viewtype); + detail_map.put("changerule",changerule); + detail_map.put("cussql",cussql); + + detail_item_ass_list.add(detail_map); + + } + } + } + + RecordSet rs_main = new RecordSet(); + + //流程主表主键 + int workflow_main_key = 0; + //组织代码字段值 + String orgcode_fieldvalue = ""; + + //获取流程主表信息 + String select_workflow_main = "select * from formtable_main_" + Math.abs(formid) + " where requestid=? "; + + if(!"".equals(condition)){ + select_workflow_main += condition; + } + + logger.info("查询流程主表数据:[" + select_workflow_main + "],[" + this_requestid + "]"); + + if(rs_main.executeQuery(select_workflow_main,this_requestid)){ + + if(rs_main.next()) { + + workflow_main_key = Util.getIntValue(rs_main.getString("id"), 0); + + orgcode_fieldvalue = Util.null2String(rs_main.getString(orgcode_fieldname)); + }else{//若数据不存在,则直接跳过 + + logger.info("-------------------------WorkflowDataToNC_Action(未传凭证) End-------------------------"); + return result; + } + } + + StringBuffer sendxml = new StringBuffer(); + + sendxml.append(""); + sendxml.append(""); + + long timestamp = System.currentTimeMillis() / 10; + + //获取当前日期 + String currentday = TimeUtil.getCurrentDateString(); + //获取当前年份(后两位) + String year = currentday.substring(2,4); + + voucher_keyid = year + timestamp; + + sendxml.append(""); + + sendxml.append(""); + + //获取Header字段配置 + if(voucher_head_list != null && voucher_head_list.size() > 0){ + for(Map detail_map : voucher_head_list){ + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + + if("".equals(xmlfield)){//若XML节点名称为空,则直接跳过 + continue; + } + + //判断OA字段来源 + int viewtype = Util.getIntValue(detail_map.get("viewtype").toString(),0); + + if(viewtype > 0){//说明配置的字段来自明细表,则该字段配置有误,直接跳过 + logger.info("--Error-->字段【" + xmlfield + "】配置有误,请检查!"); + continue; + } + + String fieldval = getFieldValue(detail_map,rs_main,null,baseArray); + result.put(xmlfield,fieldval); + sendxml.append("<").append(xmlfield).append(">"); + sendxml.append(fieldval); + sendxml.append(""); + } + } + + if(debit_detail_item_list != null && debit_detail_item_list.size() > 0){ + JSONArray details = new JSONArray(); + result.put("detail",details); + sendxml.append("
"); + if(detailindex > 0 && workflow_main_key > 0){ + + RecordSet rs_detail = new RecordSet(); + String select_workflow_detail = "select * from formtable_main_" + Math.abs(formid) + "_dt1 where mainid = ? "; + + if(rs_detail.executeQuery(select_workflow_detail,workflow_main_key)){ + + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,rs_detail,baseArray,hascash,details); + + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,rs_detail,baseArray,hascash,details); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + logger.info("差旅税额借方分录XML begin;"); + //将明细结果集的游标移到第一个位置,允许再次循环 + rs_detail.beforFirst(); + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,rs_detail,baseArray,hascash,details); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + logger.info("普通贷方分录 begin;rownum:" + rownum); + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info("getFieldValue begin;"); + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,baseArray); + logger.info("getFieldValue end"); + if(special_attribute == 1){//辅助核算项字段 + + if(!"".equals(fieldval) && detail_item_ass_list != null){ + logger.info("getAssistingAccountItemInfo begin"); + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,rs_detail,baseArray,credit_ass_xml_jsonArray); + logger.info("getAssistingAccountItemInfo end"); + } + }else if (special_attribute == 3) {//贷方金额(合计) + logger.info("贷方金额(合计) begin"); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + logger.info("贷方金额(合计) end"); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + logger.info("here"); + //获取现金流量信息 + /* + String credit_cash_flow_xml = ""; + credit_cash_flow_xml += ""; + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + double amount_sum = 0.0; + + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + String fieldval = df.format(amount_sum); + + credit_cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + } + credit_cash_flow_xml += ""; + */ + + credit_item_xml.append(""); + // + credit_item_xml_json.put("detailindex",++rownum); + credit_item_xml.append("").append(rownum).append(""); + + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + + }else{//说明字段都来自主表 + //---------------------------------普通借方分录 Begin---------------------------------------------- + //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + StringBuffer debit_item_xml = generate_debit_item_xml(0,0,debit_detail_item_list,rs_main,null,baseArray,hascash,details); + logger.info("普通借方分录XML:[" + debit_item_xml.toString() + "]\r\n"); + //---------------------------------普通借方分录 End---------------------------------------------- + + + //---------------------------------税额借方分录 Begin---------------------------------------------- + //税额分录XML + StringBuffer tax_item_xml = new StringBuffer(); + if(tax_detail_item_list != null && tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + tax_item_xml = generate_debit_item_xml(1,1,tax_detail_item_list,rs_main,null,baseArray,hascash,details); + logger.info("税额借方分录XML:[" + tax_item_xml.toString() + "]\r\n"); + } + //---------------------------------税额借方分录 End---------------------------------------------- + + //---------------------------------差旅税额借方分录 Begin---------------------------------------------- + //差旅税额分录XML + StringBuffer trip_tax_item_xml = new StringBuffer(); + if(trip_tax_detail_item_list != null && trip_tax_detail_item_list.size() > 0) {//税额借方分录配置存在 + //差旅税额分录XML //itemType 0-普通借方 1-税额借方 2-贷方 3-差旅税额借方 + trip_tax_item_xml = generate_debit_item_xml(3,1,trip_tax_detail_item_list,rs_main,null,baseArray,hascash,details); + logger.info("差旅税额借方分录XML:[" + trip_tax_item_xml.toString() + "]\r\n"); + } + //----------------------------------差旅税额借方分录 End------------------------------------------------ + + + //---------------------------------普通贷方分录 Begin---------------------------------------------- + //贷方分录XML + StringBuffer credit_item_xml = new StringBuffer(); + JSONObject credit_item_xml_json = new JSONObject(); + if (rownum > 0) {//说明借方分录存在,则开始生成贷方分录 + StringBuffer inner_credit_xml = new StringBuffer(); + JSONObject inner_credit_xml_json = new JSONObject(); + //辅助核算项配置 + String credit_ass_xml = ""; + JSONArray credit_ass_xml_jsonArray = new JSONArray(); + if (credit_detail_item_list != null && credit_detail_item_list.size() > 0) {//贷方分录字段配置不为空 + for (Map detail_map : credit_detail_item_list) {//循环贷方分录字段映射配置 + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(), 0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + logger.info(""); + String fieldval = getFieldValue(detail_map, rs_main, null,baseArray); + + if(special_attribute == 1){//辅助核算项字段 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + credit_ass_xml = getAssistingAccountItemInfo(2,fieldval,rs_main,null,baseArray,credit_ass_xml_jsonArray); + } + }else if (special_attribute == 3) {//贷方金额(合计) + double amount_sum = 0.0; + if (debitamount_map.containsKey(xmlfield)) { + amount_sum = debitamount_map.get(xmlfield); + } + fieldval = df.format(amount_sum); + } else if (special_attribute == 2) {//借方金额(合计) + fieldval = "0.00"; + } + inner_credit_xml.append("<").append(xmlfield).append(">"); + inner_credit_xml.append(fieldval); + inner_credit_xml.append(""); + inner_credit_xml_json.put(xmlfield,fieldval); + } + + credit_item_xml.append(""); + // + credit_item_xml.append("").append(++rownum).append(""); + credit_item_xml_json.put("detailindex",rownum); + //普通字段 + credit_item_xml.append(inner_credit_xml.toString()); + credit_item_xml_json.putAll(inner_credit_xml_json); + //辅助核算项 + credit_item_xml.append(""); + credit_item_xml.append(credit_ass_xml); + credit_item_xml.append(""); + credit_item_xml_json.put("ass",credit_ass_xml_jsonArray); + /* + //现金流量 + credit_item_xml.append(""); + credit_item_xml.append(credit_cash_flow_xml); + credit_item_xml.append(""); + */ + + credit_item_xml.append(""); + } + } + logger.info("普通贷方分录XML:[" + credit_item_xml.toString() + "]\r\n"); + //---------------------------------普通贷方分录 End---------------------------------------------- + + //普通借方分录 + sendxml.append(debit_item_xml); + //税额借方分录 + sendxml.append(tax_item_xml); + //差旅税额借方分录 + sendxml.append(trip_tax_item_xml); + //贷方分录 + sendxml.append(credit_item_xml); + details.add(credit_item_xml_json); + } + sendxml.append("
"); + } + sendxml.append("
"); + sendxml.append("
"); + sendxml.append("
"); + + logger.info("发送的XML格式为:【" + sendxml.toString() + "】"); + logger.info("result json:" + result.toJSONString()); + logger.info("-------------------------WorkflowDataToNC_Action End-------------------------"); + return result; + } + + /** + * 解析XML字符串 + * @param xml + * @return + */ + @SuppressWarnings("unchecked") + public Map analysisXML(String xml){ + Map resultMap = new HashMap(); + try{ + //创建一个新的字符串 + StringReader read = new StringReader(xml); + //创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入 + InputSource source = new InputSource(read); + //创建一个新的SAXBuilder + SAXBuilder sb = new SAXBuilder(); + //通过输入源构造一个Document + Document doc = sb.build(source); + //取根元素 + Element root = doc.getRootElement(); + //获取ufinterface根节点中的子节点 + List child = root.getChildren(); + //获取ufinterface根节点中第一个子节点 sendresult + Element first_child = (Element)child.get(0); + + //获取formdata根节点中的子节点 + List first_child_grands = first_child.getChildren(); + for(int i = 0 ; i < first_child_grands.size();i++){ + Element leave = (Element)first_child_grands.get(i); + + resultMap.put(leave.getName(), leave.getText()); + //System.err.println("--------" + i + "--->" + leave.getText() + "/" + leave.getName()); + } + }catch (Exception e) { + // TODO: handle exception + logger.info("解析XML字符串异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } + + return resultMap; + } + + /** + * 生成借方分录XML + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @return + */ + private StringBuffer generate_debit_item_xml(int itemType, int itemDirection, List> detail_field_list, RecordSet rs_main, RecordSet rs_detail, String[] baseArray, int hascash, JSONArray details){ + StringBuffer debit_item_xml = new StringBuffer(""); + + if(rs_detail != null){ + while(rs_detail.next()){ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, rs_detail, baseArray, debit_item_xml,hascash,details); + } + }else{ + generate_debitItem_Only_xml(itemType,itemDirection, detail_field_list, rs_main, null, baseArray, debit_item_xml,hascash,details); + } + + return debit_item_xml; + } + + /** + * + * @param itemDirection + * @param detail_field_list + * @param rs_main + * @param rs_detail + * @param baseArray + * @param debit_item_xml + * @param hascash + */ + private void generate_debitItem_Only_xml(int itemType,int itemDirection, List> detail_field_list, + RecordSet rs_main, RecordSet rs_detail, String[] baseArray, StringBuffer debit_item_xml,int hascash,JSONArray details) { + //循环明细表记录,对借方分录进行拼接 + StringBuffer inner_xml = new StringBuffer(); + JSONObject inner_xml_json = new JSONObject(); + //辅助核算项配置 + String ass_xml = ""; + JSONArray ass_xml_jsonArray = new JSONArray(); + //该行明细是否需要生成会计分录 + boolean isValidate_Success = true; + + for(Map detail_map : detail_field_list){ + //获取字段的属性 + int special_attribute = Util.getIntValue(detail_map.get("special_attribute").toString(),0); + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String counterxml = Util.null2String(detail_map.get("counterxml").toString()); + String fieldval = getFieldValue(detail_map,rs_main,rs_detail,baseArray); + + int isvalidate = Util.getIntValue(detail_map.get("isvalidate").toString(),0); + //借方分录金额合计值 + double amount_sum = 0.0; + + if(special_attribute == 1){//辅助核算项字段 + //获取该科目类型对应的辅助核算项有哪些 + if(!"".equals(fieldval) && detail_item_ass_list != null){ + ass_xml = getAssistingAccountItemInfo(itemDirection,fieldval,rs_main,rs_detail,baseArray,ass_xml_jsonArray); + } + }else if(special_attribute == 2){//借方金额(合计) + amount_sum = Util.getDoubleValue(fieldval,0.0); + + if (isvalidate == 1 && amount_sum == 0){//表示该字段为金额校验字段,若为空,则改行不需要生成分录 + isValidate_Success = false; + break; + } + + if(!"".equals(counterxml)){//对应的贷方XML字段名称 + if(debitamount_map.containsKey(counterxml)){//判断该字段对应的贷方XML是否存在 + double old_debitamount = debitamount_map.get(counterxml); + + double new_debitamount = amount_sum + old_debitamount; + + debitamount_map.put(counterxml,new_debitamount); + }else{ + debitamount_map.put(counterxml, amount_sum); + } + } + + fieldval = df.format(amount_sum); + }else if(special_attribute == 3){//贷方金额(合计) + fieldval = "0.00"; + } + + inner_xml.append("<").append(xmlfield).append(">"); + inner_xml.append(fieldval); + inner_xml.append(""); + inner_xml_json.put(xmlfield,fieldval); + } + + if(isValidate_Success) { + //获取现金流量信息 + JSONObject cash_flow_xml_json = new JSONObject(); + String cash_flow_xml = ""; + cash_flow_xml += ""; + +// List> cash_list = null;//new ArrayList>(); + +// if(itemDirection == 1){//税额借方 +// cash_list = tax_item_cas_list; +// }else{//普通借方 +// cash_list = detail_item_cas_list; +// } + + for (Map detail_map : detail_item_cas_list) { + String xmlfield = Util.null2String(detail_map.get("xmlfield").toString()); + String fieldname = Util.null2String(detail_map.get("fieldname").toString()); + int rowitemType = (Integer)detail_map.get("itemType"); + + logger.info("rowitemType:[" + rowitemType + "],xmlfield:[" + xmlfield + "],fieldname:[" + fieldname + "],itemType:[" + itemType + "]"); + + if(itemType != rowitemType){ + continue; + } + + String fieldval = getFieldValue(detail_map, rs_main, rs_detail,baseArray); + + logger.info("fieldval:[" + fieldval + "]"); + + cash_flow_xml += "<" + xmlfield + ">" + fieldval + ""; + cash_flow_xml_json.put(xmlfield,fieldval); + } + cash_flow_xml += ""; + + JSONObject debit_item_xml_json = new JSONObject(); + + + debit_item_xml.append(""); + debit_item_xml_json.put("detailindex",++rownum); + // + debit_item_xml.append("").append(rownum).append(""); + //普通字段 + debit_item_xml.append(inner_xml.toString()); + debit_item_xml_json.putAll(inner_xml_json); + + //辅助核算项 + debit_item_xml.append(""); + debit_item_xml.append(ass_xml); + debit_item_xml.append(""); + + debit_item_xml_json.put("ass",ass_xml_jsonArray); + + + if(hascash == 1){ + //现金流量 + debit_item_xml.append(""); + debit_item_xml.append(cash_flow_xml); + debit_item_xml.append(""); + + JSONArray cashFlow = new JSONArray(); + cashFlow.add(cash_flow_xml_json); + debit_item_xml_json.put("cashflow",cashFlow); + } + + debit_item_xml.append(""); + details.add(debit_item_xml_json); + } + } + + /** + * 获取借方分录【科目】/贷方【公司银行】的辅助核算项配置 + * @param itemDirection 分录方向 [0-借方分录(普通) 、1-借方分录(税额) 、2-贷方分录] + * @param subjectid 科目主键 + * @param rs_main 流程主表查询结果数据集 + * @param rs_detail 当前行明细表查询结果数据集 + * @return String 科目辅助核算项的XML + */ + private String getAssistingAccountItemInfo(int itemDirection,String subjectid,RecordSet rs_main,RecordSet rs_detail,String[] baseArray,JSONArray ass_xml_jsonArray){ + String select_sql = ""; + RecordSet rs = new RecordSet(); + + String ass_xml = ""; + + //辅助核算项类型(0 : 部门 1-部门+人员 2:人员) + int checkType = 0; + + + if(itemDirection == 0){//若为普通的借方分录,则根据科目,获取该科目应该对应的辅助核算项类型 + select_sql = "select * from uf_kmjbxx where kembm = ?"; + + if(rs.executeQuery(select_sql,subjectid)){ + rs.next(); + + checkType = Util.getIntValue(rs.getString("fuzhslx"),0); + } + } + + for(Map detail_map : detail_item_ass_list){//循环辅助核算项字段配置信息 + int row_checktype = Util.getIntValue(detail_map.get("checktype").toString(),0); + + String typecode = Util.null2String(detail_map.get("typecode").toString()); + String fieldvalue = getFieldValue(detail_map,rs_main,rs_detail,baseArray); + + if(itemDirection == 0){ + logger.info("--------------普通借方辅助核算项 Begin--------------------"); + + logger.info("checkType:[" + checkType + "],row_checktype:[" + row_checktype + "],typecode:[" + typecode + "],fieldvalue:[" + fieldvalue + "]"); + + logger.info("--------------普通借方辅助核算项 End--------------------"); + } + + if(itemDirection == 0) {//普通借方分录 + if ((checkType == 0 && row_checktype == 0) || row_checktype == 2 || row_checktype == 3) {//该科目辅助核算项只有部门,而配置中出现人员(或者辅助核算类型为税额、银行存款的也跳过),则人员配置跳过 + continue; + } + }else if(itemDirection == 1 && row_checktype != 2){//税额借方分录 + continue; + }else if(itemDirection == 2 && row_checktype != 3){//贷方分录 + continue; + } + + /* + String checkType_val = ""; + + if(row_checktype == 0){//人员 + checkType_val = "0002"; + }else{//部门 + checkType_val = "0001"; + } + */ + ass_xml += ""; + ass_xml += "" + typecode + ""; + ass_xml += "" + fieldvalue + ""; + ass_xml += ""; + JSONObject o = new JSONObject(); + o.put("checktypecode",typecode); + o.put("checkvaluecode",fieldvalue); + ass_xml_jsonArray.add(o); + } + + return ass_xml; + } + + /** + * 获取字段值 + * @param configMap + * @param rs + * @param rs_detail + * @return + */ + private String getFieldValue(Map configMap,RecordSet rs,RecordSet rs_detail,String[] baseArray){ + //流程字段名称 + String wffieldname = Util.null2String(configMap.get("fieldname").toString()); + //转换规则 + int changerule = Util.getIntValue(configMap.get("changerule").toString(),0); + //自定义规则 + String cussql = Util.null2String(configMap.get("cussql").toString()); + + //流程字段所属 + int viewtype = Util.getIntValue(configMap.get("viewtype").toString(),0); + + logger.info("wffieldname:" + wffieldname + ";changerule:" + changerule + ";cussql:" + cussql + ";viewtype:" + viewtype); + + //流程字段值 + String wffieldvalue = ""; + //明细表主键 + String detail_keyid = ""; + + + if(!"".equals(wffieldname)){ + if(viewtype == 0){//主表 + wffieldvalue = Util.null2String(rs.getString(wffieldname)); + }else{//明细表 + wffieldvalue = Util.null2String(rs_detail.getString(wffieldname)); + + } + } + if(rs_detail != null){ + detail_keyid = Util.null2String(rs_detail.getString("id")); + } + + if(changerule == 1){//表示流程REQUESTID + wffieldvalue = baseArray[0]; + }else if(changerule == 2){//表示流程标题 + wffieldvalue = baseArray[1]; + }else if(changerule == 3){//表示流程编号 + wffieldvalue = baseArray[2]; + }else if(changerule == 4) {//表示系统日期 + wffieldvalue = TimeUtil.getCurrentDateString().toString(); + }else if(changerule == 5){//系统日期时间 + wffieldvalue = TimeUtil.getCurrentTimeString(); + }else if(changerule == 6){//表示固定值 + wffieldvalue = cussql; + }else if(changerule == 7){//表示明细行号 + wffieldvalue = String.valueOf(rownum); + }else if(changerule == 8) {//表示自定义转换 + //if(!"".equals(wffieldvalue)){ + String changevalue = getValueByChangeRule(cussql, wffieldvalue,detail_keyid,baseArray[0]); + logger.info("changevalue:[" + changevalue + "]"); + wffieldvalue = changevalue; + //} + }else if(changerule == 9){ + wffieldvalue = voucher_keyid; + }else{//表示不转换 + //wffieldvalue + } + + //XML特殊字符处理 + wffieldvalue = wffieldvalue.replace("<", "<"); + wffieldvalue = wffieldvalue.replace(">", ">"); + wffieldvalue = wffieldvalue.replace("&", "&"); + wffieldvalue = wffieldvalue.replace("'", "'"); + wffieldvalue = wffieldvalue.replace("\"", """); + + return wffieldvalue; + } + + /** + * 用数据库值,根据规则转换,获取其最终结果 + * @param cus_sql 自定义转换的规则 + * @param value + * @return + */ + private String getValueByChangeRule(String cus_sql,String value,String detail_keyid,String this_requestid){ + String endValue = ""; + + cus_sql = cus_sql.replace(" ", " "); + + cus_sql = cus_sql.replace("{?dt.id}", detail_keyid); + + String sqlString = cus_sql.replace("{?requestid}", this_requestid).replace("?", value); + + RecordSet rs = new RecordSet(); + + if(rs.executeSql(sqlString)){ + rs.next(); + + endValue = Util.null2String(rs.getString(1)); + } + + return endValue; + } + + + /** + * 获取系统参数设置值 + * @param ssid + * @return + */ + public String getSystemParamValue(String ssid){ + String paramvalue = ""; + + if(!"".equals(ssid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,ssid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * @return the cusparam + */ + public String getCusparam() { + return cusparam; + } + + /** + * @param cusparam the cusparam to set + */ + public void setCusparam(String cusparam) { + this.cusparam = cusparam; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/sqjtzxda/action/DealFileInfoAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/sqjtzxda/action/DealFileInfoAction.java new file mode 100644 index 0000000..6c88dcc --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/sqjtzxda/action/DealFileInfoAction.java @@ -0,0 +1,463 @@ +package weaver.taojw.sqjtzxda.action; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.SAXReader; +import org.dom4j.io.XMLWriter; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.taojw.common.TjwAesUtil; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.Md5Util; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.TjwModelUtil; +import weaver.taojw.common.logging.MyLogger; +import java.io.*; +import java.util.*; +import static weaver.taojw.common.CommonUtil.*; +import static weaver.taojw.common.TjwHttpUtil.*; + +/** + * 上期集团中信档案接口对接 + */ +public class DealFileInfoAction implements Action { + + //配置主表表名; + private String configTableName = ""; + + //配置id;配置表的主键值;用于获取配置表中的记录; + private String configId = ""; + + public String getConfigId() { + return configId; + } + + public void setConfigId(String configId) { + this.configId = configId; + } + + + public String getConfigTableName() { + return configTableName; + } + + public void setConfigTableName(String configTableName) { + this.configTableName = configTableName; + } + + static Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getOnlyCurrentTimeString(); + logger.info("DealFileInfoAction begin;requestId:" + requestId); + try { + String requestName = requestInfo.getRequestManager().getRequestname(); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + logger.info("Thread begin;requestId:" + requestId + ";billTableName:" + billTableName + ";requestName:" + requestName); + if (configTableName == null || "".equals(configTableName)) { + configTableName = "uf_sqjtdaxtjkpz"; + } + //获取配置信息 + RecordSet rs = new RecordSet(); + String getMainConfigInfoSql = "select * from " + configTableName + " where id = ?"; + Map mainConfigInfo = DaoUtil.getFirstData(rs, getMainConfigInfoSql, configId); + String sjtj = mainConfigInfo.get("sjtj"); + sjtj = manyLineToString(sjtj); + mainConfigInfo.put("sjtj", sjtj); + String getDetailConfigInfoSql = "select t1.*,wb.fieldName from " + configTableName + "_dt1 t1 left join workflow_billField wb on t1.lczd = wb.id where t1.mainid = ?"; + List> detailConfigInfo = DaoUtil.getData(rs, getDetailConfigInfoSql, configId); + for (Map m : detailConfigInfo) { + m.put("zdysql", manyLineToString(m.get("zdysql"))); + } + logger.info("mainConfigInfo:" + mainConfigInfo + ";" + "detailConfigInfo:" + detailConfigInfo + ";"); + //如果数据条件有值,则根据数据条件判断是否发送请求 + if (!"".equals(mainConfigInfo.get("sjtj"))) { + String checckSendSql = "select count(1) as cc from " + billTableName + " where requestid = ? " + mainConfigInfo.get("sjtj"); + if (!DaoUtil.isDataExists(rs, checckSendSql, requestId)) { + logger.info("cc == 0;end action"); + return Action.SUCCESS; + } + } + //获取pdfColumnValue + String pdfDocId = getPdfDocId(mainConfigInfo.get("pdfcolumnname"), billTableName, requestId); + //根据配置信息拼接请求报文 + String requestContent = ""; + String getDataSql = "select * from " + billTableName + " where requestid = ?"; + if (rs.executeQuery(getDataSql, requestId)) { + if(rs.next()){ + requestContent = dealRequestContent(detailConfigInfo, rs, requestName, requestId, mainConfigInfo.get("bxtdz"),pdfDocId); + }else{ + logger.error("getDataSql error;found nothing"); + } + } else { + logger.error("getDataSql error;"); + } + //发送请求 + Map headers = new HashMap<>(); + headers.put("Content-type","text/xml;charset=UTF-8"); + headers.put("SOAPAction",""); + requestContent = requestContent.replace("",""); + requestContent = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \t" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + JSONObject logInfo = new JSONObject(); + logInfo.put("lcid",requestId); + //logInfo.put("req",requestContent); + logInfo.put("res","暂无响应"); + TjwModelUtil.addOrUpdateModelData(new RecordSet(),"uf_sqzxdajkrz",logInfo,"lcid"); + Map httpResponse = sendHttpRequest(mainConfigInfo.get("daxtjkdz"), requestContent, "post", ContentType.APPLICATION_JSON,headers); + //处理响应 + String response = (String) httpResponse.get("data"); + JSONObject resp = dealResponse(response); + logInfo.put("res",resp.toJSONString()); + TjwModelUtil.addOrUpdateModelData(new RecordSet(),"uf_sqzxdajkrz",logInfo,"lcid"); + if (!"1".equals(resp.getString("status"))) { + logger.error("http response fail!requestId:" + requestId + ";message:" + requestContent + ";response:" + resp); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("推送附件至档案系统失败!;requestId:"+ requestInfo.getRequestid() +"!"); + return Action.FAILURE_AND_CONTINUE; + }else{ + logger.info("http response success!requestId:" + requestId + ";message:" + requestContent + ";response:" + resp); + } + } catch(Throwable e){ + JSONObject logInfo = new JSONObject(); + logInfo.put("lcid",requestId); + //logInfo.put("req",requestContent); + logInfo.put("res","接口异常;message:" + e.getMessage()); + TjwModelUtil.addOrUpdateModelData(new RecordSet(),"uf_sqzxdajkrz",logInfo,"lcid"); + logger.error("推送文件信息接口请求发生异常!requestId:" + requestInfo.getRequestid() + ";异常信息:" + e.getMessage()); + //阻止流程提交,提示语句 + requestInfo.getRequestManager().setMessageid(currentDate + currentTime); + requestInfo.getRequestManager().setMessagecontent("推送附件至档案系统失败!;requestId:"+ requestInfo.getRequestid() +"!"); + return Action.FAILURE_AND_CONTINUE; + } + return Action.SUCCESS; + } + + public JSONObject dealResponse(String response){ + try{ + JSONObject result = new JSONObject(); + + SAXReader reader = new SAXReader(); + Document doc = reader.read(new StringReader(response)); + Element root = doc.getRootElement(); + Element element = (Element) root.elementIterator().next(); + Element importFileReturn = (Element) element.elementIterator().next(); + String value = importFileReturn.getStringValue().trim(); + + String code = ""; + String message = ""; + doc = reader.read(new StringReader(value)); + root = doc.getRootElement(); + for (Iterator i = root.elementIterator(); i.hasNext();) { + Element elements = (Element) i.next(); + if("RETURN_STATUS".equalsIgnoreCase(elements.getName())){ + code = elements.getTextTrim(); + } + if("RETURN_MESSAGE".equalsIgnoreCase(elements.getName())){ + message = elements.getTextTrim(); + } + } + result.put("status",code); + result.put("message",message); + return result; + }catch(Exception e){ + logger.error("dealResponse exception;message:" + e.getMessage() + ";e:" + e); + } + return null; + } + + //获取pdfColumnName字段的值 + public String getPdfDocId(String pdfColumnName,String billTableName,String requestId){ + String result = ""; + if(pdfColumnName != null && !"".equals(pdfColumnName)){ + String getFileIdSql = + " select " + + pdfColumnName + + " from " + + billTableName + + " where " + + "requestid = ? "; + Date begin = new Date(); + while("".equals(result) && (new Date().getTime() - begin.getTime())/1000 < 20){ + Map map = DaoUtil.getFirstData(getFileIdSql,requestId); + result = map.get(pdfColumnName.toLowerCase(Locale.ROOT)); + } + logger.info("get pdfColumnName value;value:" + result); + } + return result; + } + + public static String getValue(String zhgz,String oldValue,String zdysql,String requestName,String requestId){ + String result = ""; + switch(zhgz){ + case "": + case "0": + result = oldValue; + break; + case "1": + result = zdysql; + break; + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId); + RecordSet thisRs = new RecordSet(); + if(thisRs.executeQuery(zdysql)){ + if(thisRs.next()){ + result = Util.null2String(thisRs.getString(1)); + } + }else{ + logger.error("zdysql execute error;sql:" + zdysql); + } + break; + case "3": + result = requestName; + break; + default: + break; + } + return result; + } + + //根据配置信息拼接请求报文 + public static String dealRequestContent(List> detailConfigInfo,RecordSet rs,String requestName,String requestId,String thisSystemAddress,String pdfFieldValue){ + Document doc = DocumentHelper.createDocument(); + Element fileEle = doc.addElement("file"); + //Element fileEle = rootEle.addElement("FILE"); + + List> documentInfoList = new ArrayList<>(); + List> pdfDocumentInfoList = getDocumentInfoList(pdfFieldValue,thisSystemAddress); + for(Map m : detailConfigInfo){ + String zhgz = m.get("zhgz"); + String zdmc = m.get("zdmc"); + String fieldname = m.get("fieldname"); + String zdysql = m.get("zdysql"); + String oldValue = Util.null2String(rs.getString(fieldname)); + if("4".equals(zhgz)){ + //获取文件document信息 + documentInfoList.addAll(getDocumentInfoList(oldValue,thisSystemAddress)); + }else{ + Element item = fileEle.addElement(zdmc); + item.setText(getValue(zhgz,oldValue,zdysql,requestName,requestId)); + } + } + + logger.info("dealRequestContent element done"); + //获取审批意见信息 + //List> processInfoList = getProcessInfoList(requestId,null); + + //documents节点数据拼装 + Element documents = fileEle.addElement("documents"); + for(Map documentInfo:documentInfoList){ + Element documentInfoItem = documents.addElement("document"); + + Element titleProper = documentInfoItem.addElement("path"); + titleProper.setText(documentInfo.get("titleProper")); + + /*Element url = documentInfoItem.addElement("url"); + url.setText(documentInfo.get("url").replaceAll("&","&"));*/ + + Element contents = documentInfoItem.addElement("contents"); + contents.setText(TjwDocumentUtil.getBase64StringByImageFileId(documentInfo.get("imagefileid"))); + + Element fileSize = documentInfoItem.addElement("filesize"); + fileSize.setText(documentInfo.get("fileSize")); + + /* Element titleProper = documentInfoItem.addElement("TITLE_PROPER"); + titleProper.setText(documentInfo.get("titleProper")); + + Element url = documentInfoItem.addElement("URL"); + url.setText(documentInfo.get("url").replaceAll("&","&")); + + Element md5Code = documentInfoItem.addElement("md5_code"); + md5Code.setText(documentInfo.get("md5Code")); + + Element fileCreateTime = documentInfoItem.addElement("File_creat_time"); + fileCreateTime.setText(documentInfo.get("filecreatetime")); + + Element fileUploadTime = documentInfoItem.addElement("File_upload_time"); + fileUploadTime.setText(documentInfo.get("fileuploadtime")); + + Element fileUploadUser = documentInfoItem.addElement("File_upload_user"); + fileUploadUser.setText(documentInfo.get("fileuploaduser")); + + Element docId = documentInfoItem.addElement("DOC_ID"); + docId.setText(documentInfo.get("docId"));*/ + } + + logger.info("dealRequestContent documentInfoList done"); + for(Map documentInfo:pdfDocumentInfoList){ + Element documentInfoItem = documents.addElement("document"); + + Element titleProper = documentInfoItem.addElement("path"); + titleProper.setText(documentInfo.get("titleProper")); + + /*Element url = documentInfoItem.addElement("url"); + url.setText(documentInfo.get("url").replaceAll("&","&"));*/ + + Element contents = documentInfoItem.addElement("contents"); + contents.setText(TjwDocumentUtil.getBase64StringByImageFileId(documentInfo.get("imagefileid"))); + + Element fileSize = documentInfoItem.addElement("filesize"); + fileSize.setText(documentInfo.get("fileSize")); + + /*Element md5Code = documentInfoItem.addElement("md5_code"); + md5Code.setText(documentInfo.get("md5Code")); + + Element fileCreateTime = documentInfoItem.addElement("File_creat_time"); + fileCreateTime.setText(documentInfo.get("filecreatetime")); + + Element fileUploadTime = documentInfoItem.addElement("File_upload_time"); + fileUploadTime.setText(documentInfo.get("fileuploadtime")); + + Element fileUploadUser = documentInfoItem.addElement("File_upload_user"); + fileUploadUser.setText(documentInfo.get("fileuploaduser")); + + Element docId = documentInfoItem.addElement("DOC_ID"); + docId.setText(documentInfo.get("docId"));*/ + } + logger.info("dealRequestContent pdfDocumentInfoList done"); + //processInfos节点数据拼装 + /*Element processInfos = fileEle.addElement("PROCESSINFOS"); + for(Map processInfo:processInfoList){ + Element processInfoItem = processInfos.addElement("PROCESSINFO"); + + Element deptId = processInfoItem.addElement("DEPT_ID"); + deptId.setText(processInfo.get("deptid")); + + Element deptName = processInfoItem.addElement("DEPT_NAME"); + deptName.setText(processInfo.get("deptname")); + + Element createUserId = processInfoItem.addElement("CREATE_USER_ID"); + createUserId.setText(processInfo.get("createuserid")); + + Element createUserName = processInfoItem.addElement("CREATE_USER_NAME"); + createUserName.setText(processInfo.get("createusername")); + + Element serviceActionTime = processInfoItem.addElement("SERVICE_ACTION_TIME"); + serviceActionTime.setText(processInfo.get("serviceactiontime")); + + Element serviceAction = processInfoItem.addElement("SERVICE_ACTION"); + serviceAction.setText(processInfo.get("serviceaction")); + + Element suggestion = processInfoItem.addElement("SUGGESTION"); + suggestion.setText(processInfo.get("suggestion")); + }*/ + + StringWriter result = new StringWriter(); + OutputFormat format = OutputFormat.createPrettyPrint(); + format.setEncoding("utf-8"); + try { + XMLWriter xmlWriter = new XMLWriter(result, format); + xmlWriter.write(doc); + } catch (Exception ex) { + logger.error("dealRequestContent.XMLWriter exception;message:"+ex.getMessage()+";e:"+ex); + }finally{ + try { + result.close(); + } catch (Exception e) { + logger.error("dealRequestContent.result.close() exception;message:"+e.getMessage()+";e:"+e); + } + } + logger.info("dealRequestContent result:" + result); + return result.toString(); + } + + //根据附件id获取document信息 + public static List> getDocumentInfoList(String docIds,String thisSystemAddress){ + List> result = new ArrayList<>(); + try{ + //根据docid获取imageid + String[] docIdArr = docIds.split(","); + RecordSet rs = new RecordSet(); + String selectSQL = + "select " + + "t3.imagefilename,t3.filerealpath,t3.imagefileid," + + "t1.doccreatedate,t1.doccreatetime,t3.filesize, " + + "t4.lastname " + + "from " + + "docdetail t1 " + + "left join DocImageFile t2 on t2.docid = t1.id " + + "left join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "left join Hrmresource t4 on t4.id = t1.doccreaterid " + + "where " + + "t1.id = ? order by t2.versionid desc "; + for(String docId :docIdArr){ + Map m = DaoUtil.getFirstData(selectSQL, docId); + Map fileInfo = new HashMap<>(); + fileInfo.put("imagefileid",m.get("imagefileid")); + fileInfo.put("titleProper",m.get("imagefilename")); + String filecreatetime = m.get("doccreatedate") + " " + m.get("doccreatetime"); + fileInfo.put("filecreatetime",filecreatetime); + fileInfo.put("fileuploadtime",filecreatetime); + fileInfo.put("fileuploaduser",m.get("lastname")); + fileInfo.put("filerealpath",m.get("filerealpath")); + fileInfo.put("docId",docId); + fileInfo.put("path",m.get("imagefilename")); + fileInfo.put("fileSize",m.get("filesize")); + fileInfo.put("contents",""); + //在原位置处新建一个文件夹存放文件 文件夹名称为imagefileid+filename用MD5加密后的码值 将原文件放入文件夹中 对原文件取md5码 + dealOldFile(fileInfo,thisSystemAddress); + result.add(fileInfo); + } + logger.info("result:" + result); + }catch(Exception e){ + logger.error("getDocumentInfoList exception;message:" + e.getMessage() + ";e:" + e); + } + return result; + } + + public static void dealOldFile(Map fileInfo,String thisSystemAddress) throws Exception{ + //在原文件同级目录下新建一个文件夹,文件夹名称为原文件id+name,aes加密后的字符串,用于存放解压后的文件 + File file = new File(fileInfo.get("filerealpath")); + //String directoryName = AesUtil.Encrypt(fileInfo.get("imagefileid")+","+fileInfo.get("titleProper")); + String directoryName = TjwAesUtil.Encrypt("y12717hd7120okhh",fileInfo.get("imagefileid")); + String directory = file.getParentFile().getPath() + File.separator + directoryName; + File dir = new File(directory); + dir.mkdir(); + //将解压后的文件复制到新建的文件夹中 + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream is = imageFileManager.getInputStreamById(Integer.parseInt(fileInfo.get("imagefileid"))); + File newFile = new File(directory + File.separator + fileInfo.get("titleProper")); + try{ + newFile.createNewFile(); + FileOutputStream fos = new FileOutputStream(newFile); + byte datas[] = new byte[1024*8]; + int len = 0; + while((len = is.read(datas))!=-1){ + fos.write(datas,0,len); + } + is.close(); + }catch(Throwable e){ + logger.error("向档案系统推送文件信息,复制文件时发送异常!异常信息:"+e.getMessage()); + throw e; + }finally { + is.close(); + } + //md5加密 + String md5String = Md5Util.getMD5OfFile(newFile); + fileInfo.put("md5Code",md5String); + fileInfo.put("url",thisSystemAddress + "/colifile/" + directoryName); + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/sqjtzxda/servlet/FileDownloadServlet.java b/src/main/jinwei_tao_old_src/weaver/taojw/sqjtzxda/servlet/FileDownloadServlet.java new file mode 100644 index 0000000..d571e25 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/sqjtzxda/servlet/FileDownloadServlet.java @@ -0,0 +1,93 @@ +package weaver.taojw.sqjtzxda.servlet; + +import com.weaverboot.tools.logTools.LogTools; +import weaver.conn.RecordSet; +import weaver.general.Util; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URLEncoder; +import weaver.taojw.common.TjwAesUtil; +public class FileDownloadServlet extends HttpServlet{ + + public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + this.doGet(req, res); + } + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + String pathInfo = req.getPathInfo(); + String fileId = ""; + String fileName = ""; + try { + /*String[] infos = AesUtil.Decrypt(pathInfo.replace("/","")).split(","); + fileId = infos[0]; + fileName = infos[1];*/ + String param = TjwAesUtil.Decrypt("y12717hd7120okhh",pathInfo.replace("/","")); + if(param.indexOf(",") != -1){ + String[] infos = param.split(","); + fileId = infos[0]; + fileName = infos[1]; + }else{ + fileId = param; + String getFileNameSql = "select imagefilename from imagefile where imagefileid = ?"; + RecordSet rs = new RecordSet(); + if(rs.executeQuery(getFileNameSql,fileId)){ + if(rs.next()){ + fileName = Util.null2String(rs.getString("imagefilename")); + } + }else{ + LogTools.error("FileDownloadUtil getFileNameSql error;id:" + fileId); + } + } + } catch (Exception e) { + LogTools.error("文件下载异常!文件路径:"+ pathInfo +";异常信息:"+ e.getMessage()); + return; + } + //根据fileId查询文件路径 + RecordSet rs = new RecordSet(); + String selectSQL = "Select filerealpath from imagefile where imagefileid = ?"; + String oldFilePath = ""; + if(rs.executeQuery(selectSQL,fileId)){ + if(rs.next()){ + oldFilePath =rs.getString("filerealpath"); + } + } + res.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(fileName,"UTF-8")); + File oldFile = new File(oldFilePath); + File fileDirectory = oldFile.getParentFile(); + if(fileDirectory.isDirectory()){ + String[] files = fileDirectory.list(); + for (int i = 0; i < files.length; i++) {// + File file = new File(fileDirectory, files[i]); + if (file.isDirectory() && ("/"+file.getName()).equals(pathInfo)) {// + File newFile = new File(file,file.list()[0]); + if(newFile.getName().equals(fileName)){ + FileInputStream fis = new FileInputStream(newFile); + ServletOutputStream servletOutputStream = res.getOutputStream(); + try{ + int len = 0; + byte[] bytes = new byte[1024]; + while((len = fis.read(bytes))>0){ + servletOutputStream.write(bytes, 0, len); + } + //关闭资源 + servletOutputStream.close(); + fis.close(); + }catch(Throwable e){ + LogTools.error("文件下载异常!文件路径:"+ pathInfo +";异常信息:"+ e.getMessage()); + return; + }finally { + servletOutputStream.close(); + fis.close(); + } + } + } + } + } + } +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/wcst/action/UpdateDocAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/wcst/action/UpdateDocAction.java new file mode 100644 index 0000000..899acbd --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/wcst/action/UpdateDocAction.java @@ -0,0 +1,121 @@ +package weaver.taojw.wcst.action; + +import com.spire.doc.Document; +import com.spire.doc.FileFormat; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.DaoUtil; +import weaver.taojw.common.TjwDocumentUtil; +import weaver.taojw.common.logging.MyLogger; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * 微创神通 + * 文档附件去除批注、接受修订 + * 需要jar包 spire.doc.free-5.2.0.jar + */ +public class UpdateDocAction implements Action { + + //附件字段 + private String docIdColumns = ""; + + public String getDocIdColumns() { + return docIdColumns; + } + + public void setDocIdColumns(String docIdColumns) { + this.docIdColumns = docIdColumns; + } + + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + try{ + logger.info("UpdateDocAction begin;requestId:" + requestId + ";docIdColumns:" + docIdColumns); + String billTableName = requestInfo.getRequestManager().getBillTableName(); + //根据docIdColumns获取附件信息 + List docIdList = new ArrayList<>(); + String[] docIdColumnArray = docIdColumns.split(","); + RecordSet rs = new RecordSet(); + if(docIdColumnArray != null && docIdColumnArray.length > 0){ + for(String docIdColumn : docIdColumnArray){ + String getDocIdSql = "select " + docIdColumn + " from " + billTableName + " where requestid = ?"; + Map dataMap = DaoUtil.getFirstData(rs, getDocIdSql, requestId); + String docIds = dataMap.get(docIdColumn.toLowerCase(Locale.ROOT)); + if(docIds != null && !"".equals(docIds)){ + String[] docIdArray = docIds.split(","); + for(String docId : docIdArray){ + docIdList.add(docId); + } + } + logger.info("docIdColumn:" + docIdColumn + ";docIds:" + docIds); + } + } + logger.info("docIdList:" + docIdList); + //根据docId获取文件 + for(String docId:docIdList){ + dealDocId(docId); + } + logger.info("UpdateDocAction end"); + return Action.SUCCESS; + }catch(Throwable e){ + logger.error("UpdateDocAction exception;requestId:" + requestId + ";message:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + + /** + * 根据docId 获取文档信息;然后清除标注、接受修订内容 + * @param docId + */ + public void dealDocId(String docId){ + try{ + RecordSet rs = new RecordSet(); + //获取文件信息 + String getFileInfoSql = "select imagefilename,imagefileid,docfiletype from DocImageFile where docid = ?"; + List> imageFileInfoList = DaoUtil.getData(rs, getFileInfoSql, docId); + for(Map m : imageFileInfoList){ + String docfiletype = m.get("docfiletype"); + if("3".equals(docfiletype) || "7".equals(docfiletype)){ + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream is = imageFileManager.getInputStreamById(Integer.parseInt(m.get("imagefileid"))); + Document document = new Document(is); + document.getComments().clear(); + document.acceptChanges(); + ByteArrayOutputStream ops = new ByteArrayOutputStream(); + if("3".equals(docfiletype)){ + document.saveToStream(ops,FileFormat.Doc); + }else{ + document.saveToStream(ops,FileFormat.Docx); + } + byte[] buffer = ops.toByteArray(); + ImageFileManager saveFileManager = new ImageFileManager(); + saveFileManager.setData(buffer); + saveFileManager.setImagFileName(m.get("imagefilename")); + logger.info("saveFileManager.saveImageFile begin"); + int imageFileId = saveFileManager.saveImageFile(); + logger.info("saveFileManager.saveImageFile end"); + TjwDocumentUtil.addDocImageInfo(Integer.parseInt(docId),m.get("imagefilename"),imageFileId); + + //int imageFileId = imageFileManager.saveImageFileByInputStream(new ByteArrayInputStream(buffer), m.get("imagefilename")); + String updateImageFileIdSql = "update DocImageFile set imagefileid = ? where imagefileid = ?"; + DaoUtil.updateData(rs,updateImageFileIdSql,imageFileId,m.get("imagefileid")); + } + } + }catch(Throwable e){ + logger.error("dealDocId exception;docId:" + docId + ";message:" + e.getMessage() + ";e:" + e); + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/xtxgw/action/SendInfoAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/xtxgw/action/SendInfoAction.java new file mode 100644 index 0000000..3357d08 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/xtxgw/action/SendInfoAction.java @@ -0,0 +1,276 @@ +package weaver.taojw.xtxgw.action; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.Md5Util; +import weaver.taojw.common.logging.MyLogger; +import weaver.taojw.xtxgw.util.RequestMessageUtil; +import weaver.taojw.xtxgw.util.RequestSendUtil; +import java.text.SimpleDateFormat; +import java.util.*; + +import static weaver.taojw.common.CommonUtil.fullToHalfAngle; + +/** + * 信托发文action + */ +public class SendInfoAction implements Action { + + //配置表主键;uf_fwjkpz表id + private String configDataId = ""; + + public String getConfigDataId() { + return configDataId; + } + + public void setConfigDataId(String configDataId) { + this.configDataId = configDataId; + } + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + String requestName = requestInfo.getRequestManager().getRequestname(); + try{ + logger.info("----------------------" + this.getClass() + " action begin ----------------------"); + //流程主表表名 + String tableName = requestInfo.getRequestManager().getBillTableName(); + //根据configId获取配置信息 + Map mainConfigInfo = new HashMap<>(); + List> detailConfigInfo = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String getConfigSql = + "select " + + "t1.lclx,t1.fwjkdz,t1.scwjjkdz,t1.qzyjjd,t1.sjtj,t1.systemname,t1.systemkey, " + + "t2.jkzd,t2.lczd,t2.zhgz,t2.zdysql, " + + "wb.fieldName " + + "from " + + "uf_fwjkpz t1 " + + "left join uf_fwjkpz_dt1 t2 on t2.mainid = t1.id " + + "left join workflow_billField wb on t2.lczd = wb.id " + + "where " + + "t1.id = ?"; + String creator = ""; + if(rs.executeQuery(getConfigSql,configDataId)){ + while(rs.next()){ + mainConfigInfo.put("lclx", Util.null2String(rs.getString("lclx"))); + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace("
"," "); + sjtj = sjtj.replace(" "," "); + sjtj = fullToHalfAngle(sjtj); + } + mainConfigInfo.put("sjtj", sjtj); + mainConfigInfo.put("fwjkdz",Util.null2String(rs.getString("fwjkdz"))); + mainConfigInfo.put("scwjjkdz",Util.null2String(rs.getString("scwjjkdz"))); + mainConfigInfo.put("qzyjjd",Util.null2String(rs.getString("qzyjjd"))); + mainConfigInfo.put("systemname",Util.null2String(rs.getString("systemname"))); + mainConfigInfo.put("systemkey",Util.null2String(rs.getString("systemkey"))); + Map detailConfig = new HashMap<>(); + detailConfig.put("jkzd",Util.null2String(rs.getString("jkzd"))); + detailConfig.put("fieldName",Util.null2String(rs.getString("fieldName"))); + detailConfig.put("zhgz",Util.null2String(rs.getString("zhgz"))); + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace("
"," "); + zdysql = zdysql.replace(" "," "); + zdysql = fullToHalfAngle(zdysql); + } + detailConfig.put("zdysql",zdysql); + detailConfigInfo.add(detailConfig); + if("creator".equals(Util.null2String(rs.getString("jkzd")))){ + creator = zdysql; + } + } + }else{ + logger.error("sql error;sql:" + getConfigSql + ";configDataId:" + configDataId); + requestInfo.getRequestManager().setMessageid("2022082391122"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + logger.info("creator:"+creator+";mainConfigInfo:" + mainConfigInfo + ";"); + logger.info("detailConfigInfo:" + detailConfigInfo + ";"); + //如果数据条件有值,则根据数据条件判断是否发送请求 + if(!"".equals(mainConfigInfo.get("sjtj"))){ + String checckSendSql = "select count(1) as cc from " + tableName + " where requestid = ? " + mainConfigInfo.get("sjtj"); + if(rs.executeQuery(checckSendSql,requestId)){ + if(rs.next()){ + int cc = Util.getIntValue(rs.getString("cc"),0); + if(cc == 0){ + logger.info("cc == 0;end action"); + return Action.SUCCESS; + } + } + }else{ + logger.error("checckSendSql error;sql:" + checckSendSql + ";sjtj:" + mainConfigInfo.get("sjtj")); + } + } + //根据配置信息拼接请求报文 + JSONObject json = new JSONObject(); + String getDataSql = "select * from " + tableName + " where requestid = ?"; + if(rs.executeQuery(getDataSql,requestId)){ + if(rs.next()){ + json = dealJson(creator,requestId,mainConfigInfo,detailConfigInfo,rs,requestName); + } + } + //请求、处理响应 + logger.info("start deal message"); + JSONObject result = RequestSendUtil.sendMessage(json.toString(),mainConfigInfo.get("fwjkdz")); + logger.info("http result:" + result); + logger.info("resultCode:" + result.get("resultCode")); + if(!"0".equals(result.get("resultCode") + "")){ + logger.error("SendInfoAction接口请求发生异常!requestId:"+ requestInfo.getRequestid() +";请求报文:"+json + "; 响应:"+result); + requestInfo.getRequestManager().setMessageid("20220823990211"); + requestInfo.getRequestManager().setMessagecontent("SendInfoAction接口请求失败,requestId:"+ requestInfo.getRequestid() +";接口响应:"+result.get("errMsg")); + return Action.FAILURE_AND_CONTINUE; + }else{ + logger.info("BackWorkFlowAction接口请求发生成功!requestId:"+ requestInfo.getRequestid() +";请求报文:"+json + "; 响应:"+result); + } + return Action.SUCCESS; + }catch(Exception e){ + requestInfo.getRequestManager().setMessageid("2022082691002"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + logger.error("Action.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + return Action.FAILURE_AND_CONTINUE; + } + } + + //根据配置信息拼接json报文 + private JSONObject dealJson(String creator,String requestId,Map mainConfigInfo,List> detailConfigInfo,RecordSet rs,String requestName) throws Exception { + JSONObject result = new JSONObject(); + Map zwMap = new HashMap<>(); + Map fjlbMap = new HashMap<>(); + for(Map config : detailConfigInfo){ + if("4".equals(config.get("zhgz"))){ + //正文 + String zwValue = zwMap.get(config.get("jkzd")); + if("".equals(zwValue) || zwValue == null){ + zwMap.put(config.get("jkzd"),Util.null2String(rs.getString(config.get("fieldName")))); + }else{ + zwValue = zwValue + "," + Util.null2String(rs.getString(config.get("fieldName"))); + zwMap.put(config.get("jkzd"),zwValue); + } + }else if("5".equals(config.get("zhgz"))){ + //附件列表 + String fjlbValue = fjlbMap.get(config.get("jkzd")); + if("".equals(fjlbValue) || fjlbValue == null){ + fjlbMap.put(config.get("jkzd"),Util.null2String(rs.getString(config.get("fieldName")))); + }else{ + fjlbValue = fjlbValue + "," + Util.null2String(rs.getString(config.get("fieldName"))); + fjlbMap.put(config.get("jkzd"),fjlbValue); + } + }else if("3".equals(config.get("zhgz"))){ + //签字意见 + String suggestion = ""; + String nodeIds = mainConfigInfo.get("qzyjjd"); + String getSuggestionSql = + "select " + + "t1.remark,t2.nodename,t3.lastname " + + "from " + + "workflow_requestlog t1 " + + "inner join workflow_nodebase t2 on t2.id = t1.nodeid " + + "left join hrmresource t3 on t3.id = t1.operator " + + "where " + + "t1.requestid = ? " + + "and t1.nodeid in (" + nodeIds + ")"; + RecordSet rss = new RecordSet(); + if(rss.executeQuery(getSuggestionSql,requestId)){ + while(rss.next()){ + String remark = Util.null2String(rss.getString("remark")); + String nodename = Util.null2String(rss.getString("nodename")); + String lastname = Util.null2String(rss.getString("lastname")); + //remark = delHTMLTag(remark); + if("".equals(suggestion)){ + suggestion = "节点:"+nodename + ";操作者:" + lastname + ";意见:" + remark + "
"; + }else{ + suggestion = suggestion + "节点:"+nodename + ";操作者:" + lastname + ";意见:" + remark + "
"; + } + } + }else{ + logger.error("getSuggestionSql error;sql:" + getSuggestionSql + ";requestId:" + requestId); + } + result.put(config.get("jkzd"),suggestion); + }else{ + result.put(config.get("jkzd"),getValueByZhgz(Util.null2String(rs.getString(config.get("fieldName"))),config.get("zhgz"),config.get("zdysql"),requestName)); + } + } + logger.info("zwMap:" + zwMap + ";fjlbMap:" + fjlbMap); + //开始处理文档 + try { + dealDocument(creator,zwMap,result,mainConfigInfo.get("systemname"),mainConfigInfo.get("systemkey"),mainConfigInfo.get("scwjjkdz"),"1"); + dealDocument(creator,fjlbMap,result,mainConfigInfo.get("systemname"),mainConfigInfo.get("systemkey"),mainConfigInfo.get("scwjjkdz"),"0"); + } catch (Exception e) { + logger.error("dealDocument exception;message:" + e.getMessage() + ";e:" + e); + throw new Exception("FileUploadAction接口请求发生异常!"); + } + result.put("systemName",mainConfigInfo.get("systemname")); + String timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + result.put("timestamp",timestamp); + result.put("mac", Md5Util.MD5Encode(mainConfigInfo.get("systemkey")+timestamp)); + logger.info("result:" + result); + return result; + } + + private void dealDocument(String creator,Map docMap,JSONObject json,String systemName,String systemKey,String uploadFileUrl,String type) throws Exception { + for(String key:docMap.keySet()){ + List docIdList = new ArrayList<>(); + String docIds = docMap.get(key); + if(docIds != null && !"".equals(docIds)){ + List messageList = RequestMessageUtil.getFileUploadRequestMessage(creator,systemName,systemKey,docIds,type); + for(String message:messageList){ + //logger.info("send document begin;message:" + message); + JSONObject result = RequestSendUtil.sendMessage(message,uploadFileUrl); + logger.info("send document done;result:"+result); + //处理响应 + if(!"0".equals(result.get("resultCode"))){ + logger.error("FileUploadAction接口请求发生异常!;请求报文:"+message + "; 响应:"+result); + throw new Exception("FileUploadAction接口请求发生异常!"); + }else{ + String docinfoID = result.getString("docinfoID"); + logger.info("FileUploadAction接口,更新流程表单成功!;docinfoID:"+result.getString("docinfoID")); + String[] dcoIdArray = docinfoID.split(","); + for(String docId:dcoIdArray){ + docIdList.add(docId); + } + json.put(key,docIdList); + } + } + } + } + } + + private String getValueByZhgz(String oldValue,String zhgz,String zdysql,String requestName){ + String result = ""; + switch(zhgz){ + case "0": + result = oldValue; + break; + case "1": + result = zdysql; + break; + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + RecordSet thisRs = new RecordSet(); + if(thisRs.executeQuery(zdysql)){ + if(thisRs.next()){ + result = Util.null2String(thisRs.getString(1)); + } + }else{ + logger.error("zdysql execute error;sql:" + zdysql); + } + break; + case "6": + result = requestName; + break; + default: + break; + } + return result; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/xtxgw/util/RequestMessageUtil.java b/src/main/jinwei_tao_old_src/weaver/taojw/xtxgw/util/RequestMessageUtil.java new file mode 100644 index 0000000..db23c2b --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/xtxgw/util/RequestMessageUtil.java @@ -0,0 +1,186 @@ +package weaver.taojw.xtxgw.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.taojw.common.Md5Util; +import weaver.taojw.common.logging.MyLogger; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.security.MessageDigest; +import java.text.SimpleDateFormat; +import java.util.*; + +public class RequestMessageUtil { + + static Logger logger = MyLogger.getLogger(); + + public static List getFileUploadRequestMessage(String creator,String systemName,String systemKey,String docIds,String type) throws Exception { + List r = new ArrayList<>(); + + List> documentInfoList = getDocumentInfoList(docIds,type); + if(documentInfoList != null && documentInfoList.size() > 0){ + for(Map fileInfo : documentInfoList){ + JSONObject result = new JSONObject(); + result.put("systemName",systemName); + String timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + result.put("timestamp",timestamp); + result.put("mac", Md5Util.MD5Encode(systemKey+timestamp)); + result.put("creator",creator); + result.put("docName",fileInfo.get("docName")); + result.put("docContentType",fileInfo.get("docContentType")); + result.put("docContent",fileInfo.get("docContent")); + result.put("MD5",fileInfo.get("MD5")); + r.add(result.toString()); + } + } + return r; + } + + //获取签发意见 + public static List> getOpinions(String requestId){ + List> result = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String selectSQL = "Select " + + "t2.loginid as userid, " + + "t1.operatedate as dateTime, " + + "t1.remark as content " + + "from workflow_requestlog t1 " + + "left join Hrmresource t2 on t2.id= t1.operator " + + "where t1.requestid = ? order by t1.operatedate asc,t1.operatetime asc"; + if(rs.executeQuery(selectSQL,requestId)){ + while(rs.next()){ + Map processInfo = new HashMap<>(); + processInfo.put("userId",rs.getString("userId")); + processInfo.put("dateTime",rs.getString("dateTime")); + processInfo.put("content",rs.getString("content")); + result.add(processInfo); + } + } + return result; + } + + + //根据附件id获取document信息 + public static List> getDocumentInfoList(String fileIds,String type) throws Exception{ + List> result = new ArrayList<>(); + //根据docid获取imageid + String[] docIdArr = fileIds.split(","); + for(String docId :docIdArr){ + RecordSet rs = new RecordSet(); + String selectSQL = + "select t4.loginid,t3.imagefileid, " + + "t3.imagefilename " + + "from " + + "docdetail t1 " + + "left join DocImageFile t2 on t2.docid = t1.id " + + "left join imagefile t3 on t3.imagefileid = t2.imagefileid " + + "left join Hrmresource t4 on t4.id = t1.doccreaterid " + + "where t1.id = ? " + + "order by t2.operatedate desc,t2.operatetime desc "; + if("1".equals(type)){ + if(rs.executeQuery(selectSQL,docId)){ + if(rs.next()){ + Map fileInfo = new HashMap<>(); + + //字段1 creator + fileInfo.put("creator",rs.getString("loginid")); + //字段2 docName + String docName = rs.getString("imagefilename"); + fileInfo.put("docName",docName); + //字段3 docContentType + fileInfo.put("docContentType",getFileType(docName)); + //字段4 docContent + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream is = imageFileManager.getInputStreamById(Integer.parseInt(rs.getString("imagefileid"))); + + byte[] bytes = streamToByte(is); + String md5 = getFileMd5(bytes); + + String docContent = Base64.getMimeEncoder().encodeToString(bytes); + fileInfo.put("docContent",docContent); + //字段5 MD5 + fileInfo.put("MD5",md5); + + result.add(fileInfo); + } + } + }else { + if (rs.executeQuery(selectSQL, docId)) { + while (rs.next()) { + Map fileInfo = new HashMap<>(); + + //字段1 creator + fileInfo.put("creator", rs.getString("loginid")); + //字段2 docName + String docName = rs.getString("imagefilename"); + fileInfo.put("docName", docName); + //字段3 docContentType + fileInfo.put("docContentType", getFileType(docName)); + //字段4 docContent + ImageFileManager imageFileManager = new ImageFileManager(); + InputStream is = imageFileManager.getInputStreamById(Integer.parseInt(rs.getString("imagefileid"))); + + byte[] bytes = streamToByte(is); + String md5 = getFileMd5(bytes); + + String docContent = Base64.getMimeEncoder().encodeToString(bytes); + fileInfo.put("docContent", docContent); + //字段5 MD5 + fileInfo.put("MD5", md5); + + result.add(fileInfo); + } + } + } + } + return result; + } + + public static String getFileMd5(byte[] fileTypes) throws Exception{ + MessageDigest MD5 = MessageDigest.getInstance("MD5"); + MD5.update(fileTypes); + byte[] res = MD5.digest(); + StringBuilder su = new StringBuilder(); + for(int offset = 0, resLen = res.length; offset 0){ + List list = new ArrayList<>(); + //添加参数 + list.add(new BasicNameValuePair("params", param)); + post.setEntity(new UrlEncodedFormEntity(list, "UTF-8")); + }else{ + StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON); + post.setEntity(entity); + } + //3.执行post方法:得到结果 + CloseableHttpResponse response = client.execute(post); + //4.处理结果 + //@1.得到状态码 + int statusCode = response.getStatusLine().getStatusCode(); + logger.info("statusCode:"+statusCode); + logger.info("url:"+url); + logger.info("params:"+post.getParams()); + //@2.得到实体内容 + HttpEntity en = response.getEntity(); + String content = EntityUtils.toString(en, "utf-8"); + JSONObject resp = JSONObject.parseObject(content); + //5.关闭连接 + client.close(); + return resp; + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/zdj/CronJob/GetDocInfoCronJob.java b/src/main/jinwei_tao_old_src/weaver/taojw/zdj/CronJob/GetDocInfoCronJob.java new file mode 100644 index 0000000..89caf50 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/zdj/CronJob/GetDocInfoCronJob.java @@ -0,0 +1,340 @@ +package weaver.taojw.zdj.CronJob; + +import com.yirong.exchange.bll.ClientReceive1; +import com.yirong.exchange.model.Accessory; +import com.yirong.exchange.model.Document; +import com.yirong.exchange.model.Reference; +import com.yirong.exchange.util.StringUtil; +import com.yirong.exchange.util.json.JSONArray; +import com.yirong.exchange.util.json.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.taojw.common.logging.MyLogger; +import weaver.workflow.webservices.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.*; +import static com.yirong.exchange.bll.ClientParent.*; +import static weaver.taojw.common.CommonUtil.*; +import static weaver.taojw.common.TjwDocumentUtil.*; + +/** + * 中电建项目定时任务 获取数据 根据配置信息 填充流程表单数据发起流程 + */ +public class GetDocInfoCronJob extends BaseCronJob { + + Logger logger = MyLogger.getLogger(); + + //http://10.1.231.24:9000/exchange/ + //private String dtRootUrl = ""; + //5977DC132AB93D97BE0CECBAD8B1B7D9 + //private String user = ""; + //CB0FF67FBDF9A14FE535104E8E30F39A + //private String pwd = ""; + + private String configDataId = ""; + + @Override + public void execute() { + try { + logger.info("GetDocInfoCronJob begin"); + //-------------------------------------------------------------------------获取配置信息 + Map mainConfigInfo = new HashMap<>(); + List> detailConfigInfo = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String getConfigSql = + "select " + + "t1.lclx,t1.lcbt,t1.lcfqr,t1.sftjdxyjd,t1.wdml,t1.dtrooturl,t1.user1,t1.pwd,t1.temppath, " + + "t2.xyzdmc,t2.lczd,t2.zhgz,t2.zdysql, " + + "wb.fieldName " + + "from " + + "uf_swjkpz t1 " + + "left join uf_swjkpz_dt1 t2 on t2.mainid = t1.id " + + "left join workflow_billField wb on t2.lczd = wb.id " + + "where " + + "t1.id = ?"; + if(rs.executeQuery(getConfigSql,configDataId)){ + while(rs.next()){ + mainConfigInfo.put("lclx",Util.null2String(rs.getString("lclx"))); + String lcbt = Util.null2String(rs.getString("lcbt")); + lcbt = lcbt.replaceAll("yyyy",new SimpleDateFormat("yyyy").format(new Date())); + lcbt = lcbt.replaceAll("MM",new SimpleDateFormat("MM").format(new Date())); + lcbt = lcbt.replaceAll("dd",new SimpleDateFormat("dd").format(new Date())); + lcbt = lcbt.replaceAll("HH",new SimpleDateFormat("HH").format(new Date())); + lcbt = lcbt.replaceAll("mm",new SimpleDateFormat("mm").format(new Date())); + lcbt = lcbt.replaceAll("ss",new SimpleDateFormat("ss").format(new Date())); + mainConfigInfo.put("lcbt",lcbt); + mainConfigInfo.put("temppath",Util.null2String(rs.getString("temppath"))); + mainConfigInfo.put("dtrooturl",Util.null2String(rs.getString("dtrooturl"))); + mainConfigInfo.put("user",Util.null2String(rs.getString("user1"))); + mainConfigInfo.put("pwd",Util.null2String(rs.getString("pwd"))); + mainConfigInfo.put("lcfqr",Util.null2String(rs.getString("lcfqr"))); + mainConfigInfo.put("sftjdxyjd",Util.null2String(rs.getString("sftjdxyjd"))); + mainConfigInfo.put("wdml",Util.null2String(rs.getString("wdml"))); + Map detailConfig = new HashMap<>(); + detailConfig.put("xyzdmc",Util.null2String(rs.getString("xyzdmc"))); + detailConfig.put("fieldName",Util.null2String(rs.getString("fieldName"))); + detailConfig.put("zhgz",Util.null2String(rs.getString("zhgz"))); + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace("
"," "); + zdysql = zdysql.replace(" "," "); + zdysql = fullToHalfAngle(zdysql); + } + detailConfig.put("zdysql",zdysql); + detailConfigInfo.add(detailConfig); + } + }else{ + logger.error("sql error;sql:" + getConfigSql + ";"); + return; + } + logger.info("mainConfigInfo:" + mainConfigInfo + ";"); + logger.info("detailConfigInfo:" + detailConfigInfo + ";"); + if( + "".equals(mainConfigInfo.get("lclx")) || mainConfigInfo.get("lclx") == null || + "".equals(mainConfigInfo.get("lcbt")) || mainConfigInfo.get("lcbt") == null || + "".equals(mainConfigInfo.get("dtrooturl")) || mainConfigInfo.get("dtrooturl") == null || + "".equals(mainConfigInfo.get("user")) || mainConfigInfo.get("user") == null || + "".equals(mainConfigInfo.get("pwd")) || mainConfigInfo.get("pwd") == null || + "".equals(mainConfigInfo.get("lcfqr")) || mainConfigInfo.get("lcfqr") == null || + "".equals(mainConfigInfo.get("sftjdxyjd")) || mainConfigInfo.get("sftjdxyjd") == null || + "".equals(mainConfigInfo.get("wdml")) || mainConfigInfo.get("wdml") == null || + detailConfigInfo == null || detailConfigInfo.size() == 0 + ){ + logger.error("miss config info!"); + return; + } + //--------------------------------------------------------------------------------------调用客户端代码,获取公文数据 + //ClientReceive1公文下载完成事件,子类可以重写本方法监听文档的下载完成事件 将公文信息保存到各自OA系统中 + ClientReceive1 clientReceive = new ClientReceive1(){ + protected void onDownloaded(Document document) { + logger.info("download doc done,begin deal,save file to OA"); + onDocumentDownloaded(document, this,mainConfigInfo,detailConfigInfo,rs); + } + }; + clientReceive.setDTRootUrl(mainConfigInfo.get("dtrooturl")); + //测试用户User=中国电建测试 + /* clientReceive.setUser("5977DC132AB93D97BE0CECBAD8B1B7D9", "CB0FF67FBDF9A14FE535104E8E30F39A");*/ + clientReceive.setUser(mainConfigInfo.get("user"), mainConfigInfo.get("pwd")); + if(!"".equals(mainConfigInfo.get("temppath"))){ + clientReceive.setLocalTempDir(mainConfigInfo.get("temppath"));//默下载路径为 c:/exchangetemp/ + } + String result = clientReceive.getReceivingDocuments(); + logger.info("clientReceive.getReceivingDocuments():" + result); + JSONObject json = new JSONObject(result); + JSONArray arr = json.getJSONArray("list"); + int len = arr.length(); + //-------------------------------------------------------------------------------------每个json单独处理:根据json中的数据 填充流程表单数据 发起流程 + for (int i = 0; i < len; i++) { + JSONObject obj = arr.getJSONObject(i); + logger.info("obj:" + obj); + String unids = obj.getString("wrapperid"); + clientReceive.setRequestDocuments(unids, "", ""); + clientReceive.download(); + } + logger.info("job done"); + } catch (Exception e) { + logger.error("GetDocInfoCronJob.execute exception;e:" + e); + } + } + + /** + * 根据doc对象中的数据 填充流程表单数据 发起流程 + * @param doc + * @param clientReceiver + * @param mainConfigInfo 主表配置信息 + * @param detailConfigInfo 明细表配置信息 + */ + private void onDocumentDownloaded(Document doc, ClientReceive1 clientReceiver,Map mainConfigInfo,List> detailConfigInfo,RecordSet rs) { + try{ + logger.info("onDocumentDownloaded begin;"); + ImageFileManager imageFileManager = new ImageFileManager(); + Map docInfo = new HashMap<>(); + logger.info("doc.getAccessories():" + doc.getAccessories()); + logger.info("doc:" + doc); + String docIds = ""; + // 下载并保存正文附件 + java.util.List accs = doc.getAccessories(); // 正文附件列表集合 + if (accs != null && !accs.isEmpty()) { + java.util.Iterator itr = accs.iterator(); // 正文附件列表集合迭代器 + int accIdx = 0; // 已下载正文附件计数 + boolean isMSS = false; // 是作为正文还是附件保存的标记(true为正文或者原文) + String tmpFN = null;// 下载的正文附件本地路径 + for (Iterator iterator2 = accs.iterator(); iterator2.hasNext();) { + Accessory acc = (Accessory) iterator2.next(); + acc = (Accessory) itr.next(); + if (acc == null) continue; + Reference accType = acc.getAccessoryType(); + //判断是否是转版正文或者原文true false表示附件 + isMSS = accType != null && ClientReceive1.isDocAccessory(accType.getUnid()); + String extName = StringUtil.stringRight(acc.getPath(), ".", 0); // 文件扩展名 + String FN = acc.getUNID() + "." + extName; // 下载的正文附件本地文件名 + tmpFN = clientReceiver.getAccessoryFile(acc); + if (tmpFN == null){ + logger.error("tmpFN is null" + FN); + throw new IOException("下载的附件本地临时文件为空!"); + } + if (isMSS == true) { + if(accType.getUnid().indexOf(ACT_actNoStampDoc)>=0){ + logger.error("panduan shifouweigaizhang zhengwen ceb==" + FN); + }else if(accType.getUnid().indexOf(ACT_actStampDoc)>=0){ + logger.error("panduan shifouyigaizhang zhengwen ceb==" + FN); + }else if(accType.getUnid().indexOf(ACT_actCommonDoc)>=0){ + logger.error("panduan shifougongwenyuanwen ceb==" + FN); + } + } else { + if(accType.getUnid().indexOf(ACT_actAttachment)>=0){ + logger.error("panduan shifougongwenfujian==" + FN); + } + } + logger.info("tmpFN:" + tmpFN); + logger.info("FN:" + FN); + File tmpFile = new File(tmpFN); // 下载的正文附件本地临时文件 + int imageFileId = imageFileManager.saveImageFileByInputStream(new FileInputStream(tmpFile), FN); + logger.info("imageFileId:" + imageFileId); + int docId = createDocByImageFileId(FN,Integer.parseInt(mainConfigInfo.get("wdml")),imageFileId,Integer.parseInt(mainConfigInfo.get("lcfqr"))); + logger.info("docId:" + docId); + if(docIds.equals("")){ + docIds = String.valueOf(docId); + }else{ + docIds = docIds + "," + docId; + } + if (tmpFile.exists()) tmpFile.delete(); + accIdx++; + } + } + logger.info("docIds:"+docIds); + logger.info("doc.items:" + doc.getItems()); + docInfo.put("fld_senddept",doc.getItemValue("fld_senddept")); + docInfo.put("fld_subject",doc.getItemValue("fld_subject")); + docInfo.put("fld_docnum",doc.getItemValue("fld_docnum")); + docInfo.put("fld_keyword",doc.getItemValue("fld_keyword")); + docInfo.put("fld_doctype",doc.getItemValue("fld_doctype")); + docInfo.put("fld_docdirection",doc.getItemValue("fld_docdirection")); + docInfo.put("fld_page_count",doc.getItemValue("fld_page_count")); + docInfo.put("fld_memo",doc.getItemValue("fld_memo")); + docInfo.put("fld_senddate",doc.getItemValue("fld_senddate")); + docInfo.put("_receiveUN",doc.getItemValue("_receiveUN")); + docInfo.put("fld_mobile",doc.getItemValue("fld_mobile")); + docInfo.put("fld_signdate",doc.getItemValue("fld_signdate")); + docInfo.put("unid",doc.getUNID()); + docInfo.put("docIds",docIds); + for(Object key:doc.getItems().keySet()){ + docInfo.put(key.toString(),doc.getItemValue(key.toString())); + } + logger.info("docInfo:" + docInfo); + startWorkFlow(docInfo,mainConfigInfo,detailConfigInfo,rs); + }catch(Exception ex){ + logger.error("onDocumentDownloaded exception;message:" + ex.getMessage() + ";e:" + ex); + throw new RuntimeException(ex); + } + + } + + /** + * 根据配置信息发起流程 + * @param docInfo + * @param mainConfigInfo + * @param detailConfigInfo + */ + private void startWorkFlow(Map docInfo,Map mainConfigInfo,List> detailConfigInfo,RecordSet rs){ + try{ + logger.info("startWorkFlow begin;docInfo:" + docInfo); + WorkflowService service = new WorkflowServiceImpl(); + WorkflowRequestInfo info = new WorkflowRequestInfo(); + //流程标题 + info.setRequestName(mainConfigInfo.get("lcbt")); + //创建人 + info.setCreatorId(mainConfigInfo.get("lcfqr")); + //0正常,1重要,2紧急 + info.setRequestLevel("0"); + //流转到下一个节点 + info.setIsnextflow(mainConfigInfo.get("sftjdxyjd")); + WorkflowBaseInfo base = new WorkflowBaseInfo(); + //流程id + String workFlowId = mainConfigInfo.get("lclx"); + base.setWorkflowId(workFlowId); + info.setWorkflowBaseInfo(base); + + WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[detailConfigInfo.size()]; + for(int i = 0;i < detailConfigInfo.size(); i++){ + Map configInfo = detailConfigInfo.get(i); + configInfo.put("oldValue",docInfo.get(configInfo.get("xyzdmc"))); + configInfo.put("docIds",docInfo.get("docIds")); + wrti[i]=new WorkflowRequestTableField(); + wrti[i].setFieldName(configInfo.get("fieldName")); + wrti[i].setFieldValue(getFieldValue(configInfo,rs)); + wrti[i].setEdit(true); + wrti[i].setView(true); + wrti[i].setMand(true); + } + + WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据 + tablre[0]=new WorkflowRequestTableRecord(); + tablre[0].setWorkflowRequestTableFields(wrti); + WorkflowMainTableInfo maininfo=new WorkflowMainTableInfo(); + maininfo.setRequestRecords(tablre); + info.setWorkflowMainTableInfo(maininfo);//添加主字段数据 + + //发起流程 + String requestId = service.doCreateWorkflowRequest(info, Integer.parseInt(mainConfigInfo.get("lcfqr"))); + logger.info("startWorkFlow done;requestId:" + requestId); + }catch(Exception e){ + logger.error("startWorkFlow exception;message:" + e.getMessage() + ";e:" + e); + } + } + + /** + * 根据配置信息将响应数据转换为流程表单中的字段 + * @param configMap + * @param rs + * @return + */ + public String getFieldValue(Map configMap,RecordSet rs){ + //函数返回值 + String result = ""; + try{ + //转换规则 + String zhgz = configMap.get("zhgz"); + //自定义sql + String zdysql = configMap.get("zdysql"); + //不同转换规则处理 + switch(zhgz){ + case "0": + result = configMap.get("oldValue"); + break; + case "1": + result = configMap.get("zdysql"); + break; + case "2": + String oldValue = configMap.get("oldValue"); + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(rs.executeQuery(zdysql)){ + if(rs.next()){ + result = Util.null2String(rs.getString(1)); + } + }else{ + logger.error("zdysql execute error;sql:" + zdysql); + } + break; + case "3": + result = configMap.get("docIds"); + break; + default: + result = ""; + break; + } + return result; + }catch(Exception e){ + result = ""; + logger.error("getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e); + return result; + } + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/zdj/Test.java b/src/main/jinwei_tao_old_src/weaver/taojw/zdj/Test.java new file mode 100644 index 0000000..d52e7c7 --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/zdj/Test.java @@ -0,0 +1,120 @@ +package weaver.taojw.zdj; + +import com.yirong.exchange.model.Accessory; +import com.yirong.exchange.model.Reference; +import com.yirong.exchange.util.StringUtil; +import com.yirong.exchange.util.json.JSONArray; +import com.yirong.exchange.util.json.JSONObject; +import com.yirong.exchange.bll.ClientReceive1; +import com.yirong.exchange.model.Document; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; + +import static com.yirong.exchange.bll.ClientParent.*; + +public class Test { + + public static void main(String[] args) { + try { + //ClientReceive1公文下载完成事件,子类可以重写本方法监听文档的下载完成事件 将公文信息保存到各自OA系统中 + ClientReceive1 clientReceive = new ClientReceive1(){ + protected void onDownloaded(Document document) { + System.out.println("下载公文完成,开始处理:将临时目录文件保存到各个OA系统中"); + onDocumentDownloaded(document, this); + } + }; + clientReceive.setDTRootUrl("http://10.1.231.24:9000/exchange/"); + //测试用户User=中国电建测试 + /* clientReceive.setUser("5977DC132AB93D97BE0CECBAD8B1B7D9", "CB0FF67FBDF9A14FE535104E8E30F39A");*/ + clientReceive.setUser("5977DC132AB93D97BE0CECBAD8B1B7D9", "CB0FF67FBDF9A14FE535104E8E30F39A"); + //clientReceive.setLocalTempDir("c:/temp/");//默下载路径为 c:/exchangetemp/ + String result = clientReceive.getReceivingDocuments(); + System.out.println("待收公文列表:"+result); + JSONObject json = new JSONObject(result); + JSONArray arr = json.getJSONArray("list"); + int len = arr.length(); + for (int i = 0; i < len; i++) { + JSONObject obj = arr.getJSONObject(i); + System.out.println("obj:" + obj); + String unids = obj.getString("wrapperid"); + clientReceive.setRequestDocuments(unids, "", ""); + clientReceive.download(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + private static void onDocumentDownloaded(Document doc, ClientReceive1 clientReceiver) { + try{ + // 根据接收的信息设置接收文档的各字段值 + System.out.println("doc:" + doc); + System.out.println(doc.getItemValue("fld_senddept")); // 来文单位 + System.out.println(doc.getItemValue("fld_subject")); // 公文标题,不能为空 + System.out.println(doc.getItemValue("fld_docnum")); // 文件字号 + System.out.println(doc.getItemValue("fld_keyword")); // 主题词 + System.out.println(doc.getItemValue("fld_doctype")); // 文种 + System.out.println(doc.getItemValue("fld_docdirection")); // 收发关系 + System.out.println(doc.getItemValue("fld_page_count")); // 正文页数 + System.out.println(doc.getItemValue("fld_memo")); // 备注 + System.out.println(doc.getItemValue("fld_senddate")); // 发送时间 + System.out.println(doc.getItemValue("_receiveUN")); // 接收部门 + System.out.println(doc.getItemValue("fld_mobile")); // 发送用户手机号 + System.out.println(doc.getItemValue("fld_signdate")); // 获取签发日期 + System.out.println(doc.getUNID()); // 来自公文交换对应公文的unid + // 初始化流程文档 + + // 下载并保存正文附件 + java.util.List accs = doc.getAccessories(); // 正文附件列表集合 + System.out.println(accs); + if (accs != null && !accs.isEmpty()) { + java.util.Iterator itr = accs.iterator(); // 正文附件列表集合迭代器 + int accIdx = 0; // 已下载正文附件计数 + boolean isMSS = false; // 是作为正文还是附件保存的标记(true为正文或者原文) + String tmpFN = null;// 下载的正文附件本地路径 + for (Iterator iterator2 = accs.iterator(); iterator2.hasNext();) { + Accessory acc = (Accessory) iterator2.next(); + acc = (Accessory) itr.next(); + if (acc == null) continue; + Reference accType = acc.getAccessoryType(); + //判断是否是转版正文或者原文true false表示附件 + isMSS = accType != null && ClientReceive1.isDocAccessory(accType.getUnid()); + + String extName = StringUtil.stringRight(acc.getPath(), ".", 0); // 文件扩展名 + String FN = acc.getUNID() + "." + extName; // 下载的正文附件本地文件名 + System.out.println("FN:" + FN); + tmpFN = clientReceiver.getAccessoryFile(acc); + + if (tmpFN == null) throw new IOException("下载的附件本地临时文件为空!"); + if (isMSS == true) { + if(accType.getUnid().indexOf(ACT_actNoStampDoc)>=0){ + System.out.println("判断是否未盖章正文ceb==" + FN); + }else if(accType.getUnid().indexOf(ACT_actStampDoc)>=0){ + System.out.println("判断是否已盖章正文ceb==" + FN); + }else if(accType.getUnid().indexOf(ACT_actCommonDoc)>=0){ + System.out.println("判断是否公文原文doc==" + FN); + } + } else { + if(accType.getUnid().indexOf(ACT_actAttachment)>=0){ + System.out.println("判断是否公文附件==" + FN); + } + } + + File tmpFile = new File(tmpFN); // 下载的正文附件本地临时文件 + //if (tmpFile.exists()) tmpFile.delete(); + accIdx++; + } + + + } + }catch(Exception ex){ + throw new RuntimeException(ex); + } + + } + +} diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/zdj/action/SendDocumentAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/zdj/action/SendDocumentAction.java new file mode 100644 index 0000000..e1fbdba --- /dev/null +++ b/src/main/jinwei_tao_old_src/weaver/taojw/zdj/action/SendDocumentAction.java @@ -0,0 +1,346 @@ +package weaver.taojw.zdj.action; + +import com.yirong.exchange.bll.ClientSend; +import com.yirong.exchange.bll.ClientSend1; +import com.yirong.exchange.model.Accessory; +import com.yirong.exchange.model.Document; +import com.yirong.exchange.model.DocumentImpl; +import com.yirong.exchange.model.Reference; +import com.yirong.exchange.util.DateTime; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.taojw.common.logging.MyLogger; +import java.io.*; +import java.util.*; +import static com.yirong.exchange.bll.ClientParent.*; +import static weaver.taojw.common.CommonUtil.fullToHalfAngle; + +public class SendDocumentAction implements Action { + + private String configDataId = ""; + Logger logger = MyLogger.getLogger(); + + @Override + public String execute(RequestInfo requestInfo) { + String requestId = requestInfo.getRequestid(); + ClientSend clientSend = null; + try{ + String tableName = requestInfo.getRequestManager().getBillTableName(); + logger.info("----------------------" + this.getClass() + " action begin;requestId:" + requestId); + //1.根据cusParam查找配置表中的配置信息 + Map mainConfigInfo = new HashMap<>(); + List> detailConfigInfo = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String getConfigSql = + "select " + + "t1.lclx,t1.dtrooturl,t1.user1,t1.pwd,t1.sjtj, " + + "t2.zdmc,t2.lczd,t2.zhgz,t2.zdysql, " + + "wb.fieldName " + + "from " + + "uf_lwfsgwjkpz t1 " + + "left join uf_lwfsgwjkpz_dt1 t2 on t2.mainid = t1.id " + + "left join workflow_billField wb on t2.lczd = wb.id " + + "where " + + "t1.id = ?"; + if(rs.executeQuery(getConfigSql,configDataId)){ + while(rs.next()){ + mainConfigInfo.put("lclx", Util.null2String(rs.getString("lclx"))); + String sjtj = Util.null2String(rs.getString("sjtj")); + if(!"".equals(sjtj)){ + sjtj = sjtj.replace("
"," "); + sjtj = sjtj.replace(" "," "); + sjtj = fullToHalfAngle(sjtj); + } + mainConfigInfo.put("sjtj", sjtj); + mainConfigInfo.put("dtrooturl",Util.null2String(rs.getString("dtrooturl"))); + mainConfigInfo.put("user",Util.null2String(rs.getString("user1"))); + mainConfigInfo.put("pwd",Util.null2String(rs.getString("pwd"))); + Map detailConfig = new HashMap<>(); + detailConfig.put("zdmc",Util.null2String(rs.getString("zdmc"))); + detailConfig.put("fieldName",Util.null2String(rs.getString("fieldName"))); + detailConfig.put("zhgz",Util.null2String(rs.getString("zhgz"))); + String zdysql = Util.null2String(rs.getString("zdysql")); + if(!"".equals(zdysql)){ + zdysql = zdysql.replace("
"," "); + zdysql = zdysql.replace(" "," "); + zdysql = fullToHalfAngle(zdysql); + } + detailConfig.put("zdysql",zdysql); + detailConfigInfo.add(detailConfig); + } + }else{ + logger.error("sql error;sql:" + getConfigSql + ";configDataId:" + configDataId); + requestInfo.getRequestManager().setMessageid("2022081591022"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + logger.info("mainConfigInfo:" + mainConfigInfo + ";"); + logger.info("detailConfigInfo:" + detailConfigInfo + ";"); + //如果数据条件有值,则根据数据条件判断是否发送请求 + if(!"".equals(mainConfigInfo.get("sjtj"))){ + String checckSendSql = "select count(1) as cc from " + tableName + " where requestid = ? " + mainConfigInfo.get("sjtj"); + if(rs.executeQuery(checckSendSql,requestId)){ + if(rs.next()){ + int cc = Util.getIntValue(rs.getString("cc"),0); + if(cc == 0){ + logger.info("cc == 0;end action"); + return Action.SUCCESS; + } + } + }else{ + logger.error("checckSendSql error;sql:" + checckSendSql + ";sjtj:" + mainConfigInfo.get("sjtj")); + } + } + //2.根据配置信息拼接请求信息 + clientSend = new ClientSend1(); + Document document = new DocumentImpl(); + clientSend.setDocument(document, "", ""); + Hashtable items = new Hashtable(); + DateTime dt = new DateTime(); + String DTString = dt.getNowDTString(); + String DTDate = dt.getDate(); + String getDataSql = "select * from " + tableName + " where requestid = ?"; + if(rs.executeQuery(getDataSql,requestId)){ + if(rs.next()){ + dealItems(tableName,detailConfigInfo,DTDate,DTString,items,clientSend,rs); + }else{ + logger.error("getDataSql did not find record"); + } + }else{ + logger.error("getDataSql error;"); + } + document.setItems(items); + + clientSend.setDTRootUrl(mainConfigInfo.get("dtrooturl")); + //测试用户User=中国电建测试 + clientSend.setUser(mainConfigInfo.get("user"), mainConfigInfo.get("pwd")); + + //3.发送请求处理响应 + boolean isSuccess = clientSend.sendDocument(); + if(isSuccess){ + logger.info("clientSend.sendDocument() success;document.getUNID():" + document.getUNID()); + clientSend.clear(); + return Action.SUCCESS; + }else{ + logger.info("clientSend.sendDocument() fail;document.getUNID():" + document.getUNID()); + clientSend.clear(); + requestInfo.getRequestManager().setMessageid("2022081591242"); + requestInfo.getRequestManager().setMessagecontent("Action接口失败,requestId:"+ requestId +";" + "请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + }catch(Exception e){ + if(clientSend != null){ + clientSend.clear(); + } + logger.error("action exception;requestid:" + requestId + ";message:" + e.getMessage() + ";e:" + e); + requestInfo.getRequestManager().setMessageid("2022081591202"); + requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +";" + "请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + } + + //根据配置信息拼接请求报文 + private void dealItems(String tableName,List> detailConfigInfo,String DTDate,String DTString,Hashtable items,ClientSend clientSend,RecordSet rs) throws IOException { + RecordSet thisRs = new RecordSet(); + for(Map configMap : detailConfigInfo){ + String oldValue = Util.null2String(rs.getString(configMap.get("fieldName"))); + String zdysql = configMap.get("zdysql"); + String zdmc = configMap.get("zdmc"); + logger.info("configMap:" + configMap); + switch(configMap.get("zhgz")){ + case "0": + items.put(zdmc,oldValue); + break; + case "1": + items.put(zdmc,zdysql); + break; + case "2": + zdysql = zdysql.replaceAll("\\{\\?}",oldValue); + if(thisRs.executeQuery(zdysql)){ + if(thisRs.next()){ + items.put(zdmc, Util.null2String(thisRs.getString(1))); + } + }else{ + logger.error("zdysql execute error;sql:" + zdysql); + } + break; + case "3": + dealAccessory(oldValue,clientSend,ACT_actNoStampDoc); + break; + case "4": + dealAccessory(oldValue,clientSend,ACT_actStampDoc); + break; + case "5": + dealAccessory(oldValue,clientSend,ACT_actAttachment); + break; + case "6": + dealAccessory(oldValue,clientSend,ACT_actCommonDoc); + break; + case "7": + dealAccessory(oldValue,clientSend,ACT_actOther); + break; + case "8": + items.put(zdmc, DTString + oldValue); + break; + case "9": + items.put(zdmc, DTString); + break; + case "10": + items.put(zdmc, oldValue + DTString); + break; + case "11": + items.put(zdmc, DTDate); + break; + default: + break; + } + logger.info("items:" + items); + } + } + + public void dealAccessory(String docIds,ClientSend clientSend,String unid) throws IOException { + ImageFileManager imageFileManager = new ImageFileManager(); + RecordSet rs = new RecordSet(); + String[] docIdArray = docIds.split(","); + if(docIdArray != null && docIdArray.length > 0){ + for(String docId:docIdArray){ + String getImageFileInfoSql = + "select " + + "t1.imagefileid,t1.imagefilename,t1.filesize " + + "from " + + "imagefile t1 " + + "left join DocImageFile t2 on t2.imagefileid = t1.imagefileid " + + "left join docdetail t3 on t3.id = t2.docid " + + "where " + + "t3.id = ?"; + if(rs.executeQuery(getImageFileInfoSql,docId)){ + while(rs.next()){ + String imageFileId = Util.null2String(rs.getString("imagefileid")); + String imageFileName = Util.null2String(rs.getString("imagefilename")); + String fileSize = Util.null2String(rs.getString("filesize")); + Accessory accessory = new Accessory(); + Reference type = new Reference(); + type.setUnid(unid); + accessory.setAccessoryType(type); + accessory.setName(imageFileName); + accessory.setPath(imageFileName); + InputStream is = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + clientSend.addAccessory(accessory, is, Integer.parseInt(fileSize)); + logger.info("addAccessory done;fileSize:" + fileSize + ";imageFileName:" + imageFileName + ";type:" + type + ";imageFileId:" + imageFileId); + } + }else{ + logger.error("getImageFileInfoSql error"); + } + } + } + } + + public String getConfigDataId() { + return configDataId; + } + + public void setConfigDataId(String configDataId) { + this.configDataId = configDataId; + } + + public static void testSend() throws IOException { + Document document = new DocumentImpl(); + Hashtable items = new Hashtable(); + DateTime dt = new DateTime(); + String DTString = dt.getNowDTString(); + //2014-11-24 00:19:49 + String DTDate = dt.getDate(); + items.put("fld_subject", "测试公文主题"+DTString); + items.put("fld_draftdate", DTDate); + items.put("fld_docnum", DTString+"号"); + items.put("fld_keyword", "主题词2014-003"); + items.put("fld_drafter", "拟稿人"); + items.put("fld_draftdept", "中国电建测试"); + items.put("fld_filetype", "公文发文"); + items.put("fld_docdirection", "上行文"); + items.put("fld_doctype", "请示"); + items.put("fld_signdate", DTString); + //主送单位和发送单位参数一致 + items.put("fld_mainsend", "中国电建测试,中国电建测试2");//主送单位 + items.put("fld_sendunits", "中国电建测试,中国电建测试2");//发送单位 + items.put("fld_signer", "签发人姓名"); + items.put("fld_accessorynum", "5");//附件数量 + items.put("fld_page_count", "5");//正文页数 + items.put("fld_memo", "备注"); + items.put("fld_senddept", "发文部门"); + items.put("fld_senddate", DTString); + items.put("fld_mobile", "18650058382"); //新增发文用户手机号码 + + document.setItems(items); + + //1、默认附件收文单位都可见。2、以下代码可以单独设置附件分发表:指定附件分发给各单位。 + //Map accTable = new HashMap(); + //accTable.put("办公厅", "test11.pdf"); + //accTable.put("中国电建测试2", "aa.txt"); + //document.replaceItemValue("_accessorytable", accTable); + + ClientSend clientSend = new ClientSend1(); + clientSend.setDTRootUrl("http://localhost:8080/exchange/"); + clientSend.setDocument(document, "", ""); + //测试用户User=中国电建测试 + clientSend.setUser("5977DC132AB93D97BE0CECBAD8B1B7D9", "CB0FF67FBDF9A14FE535104E8E30F39A"); + + Accessory accessory = new Accessory(); + Reference type = new Reference(); + type.setUnid(ACT_actAttachment); + accessory.setAccessoryType(type); + accessory.setName("test11.pdf"); + accessory.setPath("test11.pdf"); + File f = new File("c:/test11.pdf"); + FileInputStream fi = new FileInputStream(f); + clientSend.addAccessory(accessory, fi, (int) f.length()); + + accessory = new Accessory(); + type = new Reference(); + type.setUnid(ACT_actAttachment); + accessory.setAccessoryType(type); + accessory.setName("aa.txt"); + accessory.setPath("aa.txt"); + f = new File("c:/aa.txt"); + fi = new FileInputStream(f); + clientSend.addAccessory(accessory, fi, (int) f.length()); + + //新增公文原文 + accessory = new Accessory(); + type = new Reference(); + type.setUnid(ACT_actCommonDoc); + accessory.setAccessoryType(type); + accessory.setName("中电建公文测试001.docx"); + accessory.setPath("中电建公文测试001.docx"); + f = new File("c:/中电建公文测试001.docx"); + fi = new FileInputStream(f); + clientSend.addAccessory(accessory, fi, (int) f.length()); + + accessory = new Accessory(); + type = new Reference(); + //type.setUnid(ACT_actStampDoc);//盖章公文 + type.setUnid(ACT_actNoStampDoc);//未盖章公文 + accessory.setAccessoryType(type); + accessory.setName("公文传输测试文件.ceb"); + accessory.setPath("公文传输测试文件.ceb"); + f = new File("c:/公文传输测试文件.ceb"); + fi = new FileInputStream(f); + clientSend.addAccessory(accessory, fi, (int) f.length()); + boolean isSuccess = clientSend.sendDocument(); + + if(isSuccess){ + System.out.println("发送公文成功!"); + System.out.println(document.getUNID()+"unid=发送公文成功后对应的公文UNID应保持到本地OA系统作为记录,用于以后补发和收回等操作使用"); + }else{ + System.out.println("发送公文失败!"); + } + clientSend.clear(); + + } + + +}