From 5a69fb8fceef313129b4c211d34afbcbb5891e16 Mon Sep 17 00:00:00 2001
From: tangft <32189@DESKTOP-M6TAG3K>
Date: Tue, 18 Dec 2018 10:56:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8C=97=E8=B4=A2=E6=8E=A5=E5=8F=A3=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=8F=8A=E6=8E=A5=E5=8F=A3=E5=AE=9E?=
=?UTF-8?q?=E7=8E=B0=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
WebContent/WEB-INF/etc/jbo/jbo_doc.xml | 30 +
WebContent/WEB-INF/web.xml | 23 +
config/META-INF/xfire/services.xml | 13 +
.../tenwa/makeContract/McontractService.java | 6 +
.../com/tenwa/makeContract/ReturnMessage.java | 41 ++
.../tenwa/makeContract/WebServiceFilter.java | 42 ++
.../impl/McontractServiceImpl.java | 381 ++++++++++++
.../util/BqBaseWordCallBackServiceImpl.java | 145 +++++
.../util/BqCreateOfficeCallBackService.java | 136 +++++
.../util/BqCreateOfficeService.java | 171 ++++++
.../util/MakeOneCodeAndContractModel.java | 547 ++++++++++++++++++
.../util/McCalcConditionCopyService.java | 201 +++++++
12 files changed, 1736 insertions(+)
create mode 100644 config/META-INF/xfire/services.xml
create mode 100644 src_tenwa/com/tenwa/makeContract/McontractService.java
create mode 100644 src_tenwa/com/tenwa/makeContract/ReturnMessage.java
create mode 100644 src_tenwa/com/tenwa/makeContract/WebServiceFilter.java
create mode 100644 src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java
create mode 100644 src_tenwa/com/tenwa/makeContract/util/BqBaseWordCallBackServiceImpl.java
create mode 100644 src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeCallBackService.java
create mode 100644 src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeService.java
create mode 100644 src_tenwa/com/tenwa/makeContract/util/MakeOneCodeAndContractModel.java
create mode 100644 src_tenwa/com/tenwa/makeContract/util/McCalcConditionCopyService.java
diff --git a/WebContent/WEB-INF/etc/jbo/jbo_doc.xml b/WebContent/WEB-INF/etc/jbo/jbo_doc.xml
index 20129f20f..541bf9295 100644
--- a/WebContent/WEB-INF/etc/jbo/jbo_doc.xml
+++ b/WebContent/WEB-INF/etc/jbo/jbo_doc.xml
@@ -165,5 +165,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml
index c20b734cf..654b9025b 100644
--- a/WebContent/WEB-INF/web.xml
+++ b/WebContent/WEB-INF/web.xml
@@ -54,6 +54,16 @@
RunFilter
/servlet/view/*
+
+
+ WebServiceFilter
+ com.tenwa.makeContract.WebServiceFilter
+
+
+ WebServiceFilter
+ /services/*
+
+
InitAREServlet
com.amarsoft.are.InitAREServlet
@@ -497,6 +507,19 @@
RestfullServlet
/webapi/resf/*
+
+
+ XFireServlet
+
+ org.codehaus.xfire.transport.http.XFireConfigurableServlet
+
+
+
+ XFireServlet
+ /services/*
+
+
+
restfull自动扫描路径设置
RestfullScanPackage
diff --git a/config/META-INF/xfire/services.xml b/config/META-INF/xfire/services.xml
new file mode 100644
index 000000000..369b84603
--- /dev/null
+++ b/config/META-INF/xfire/services.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ McontractService
+ com.tenwa.makeContract.McontractService
+ com.tenwa.makeContract.impl.McontractServiceImpl
+
+
\ No newline at end of file
diff --git a/src_tenwa/com/tenwa/makeContract/McontractService.java b/src_tenwa/com/tenwa/makeContract/McontractService.java
new file mode 100644
index 000000000..d4af869eb
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/McontractService.java
@@ -0,0 +1,6 @@
+package com.tenwa.makeContract;
+
+public interface McontractService {
+
+ public ReturnMessage Mcontract(String projectNo,String carNumber,String carNo,String Mstatus);
+}
diff --git a/src_tenwa/com/tenwa/makeContract/ReturnMessage.java b/src_tenwa/com/tenwa/makeContract/ReturnMessage.java
new file mode 100644
index 000000000..b04bbcf74
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/ReturnMessage.java
@@ -0,0 +1,41 @@
+package com.tenwa.makeContract;
+
+public class ReturnMessage {
+
+ private String contractStatus;
+ private String fileName;
+ private String outputFile;
+ private String male;
+ private String standby;
+ public String getContractStatus() {
+ return contractStatus;
+ }
+ public void setContractStatus(String contractStatus) {
+ this.contractStatus = contractStatus;
+ }
+ public String getFileName() {
+ return fileName;
+ }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+ public String getOutputFile() {
+ return outputFile;
+ }
+ public void setOutputFile(String outputFile) {
+ this.outputFile = outputFile;
+ }
+ public String getMale() {
+ return male;
+ }
+ public void setMale(String male) {
+ this.male = male;
+ }
+ public String getStandby() {
+ return standby;
+ }
+ public void setStandby(String standby) {
+ this.standby = standby;
+ }
+
+}
diff --git a/src_tenwa/com/tenwa/makeContract/WebServiceFilter.java b/src_tenwa/com/tenwa/makeContract/WebServiceFilter.java
new file mode 100644
index 000000000..96acbd102
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/WebServiceFilter.java
@@ -0,0 +1,42 @@
+package com.tenwa.makeContract;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class WebServiceFilter implements Filter {
+
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest req, ServletResponse res,
+ FilterChain chain) throws IOException, ServletException {
+ // TODO Auto-generated method stub
+ String ips = "0:0:0:0:0:0:0:1|192.168.0.1|127.0.0.1|172.16.21.220|219.142.26.222|172.16.21.48";
+ if(ips.indexOf(req.getRemoteAddr()) != -1){
+ chain.doFilter(req, res);
+ }else{
+ res.setCharacterEncoding("UTF-8");
+ res.getWriter().println("error");
+ }
+// System.out.println(req.getRemoteAddr());
+// System.out.println("ԶIP" + req.getRemoteHost());
+
+ }
+
+ @Override
+ public void init(FilterConfig arg0) throws ServletException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java b/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java
new file mode 100644
index 000000000..b52b10b82
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java
@@ -0,0 +1,381 @@
+package com.tenwa.makeContract.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
+
+import jbo.app.tenwa.calc.LC_FUND_INCOME;
+import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
+import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST;
+import jbo.com.tenwa.entity.comm.flow.FLOW_WORK_FLAG;
+import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
+import jbo.com.tenwa.lease.comm.LB_CONTRACT_STATUS;
+import jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR;
+import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO;
+
+import com.amarsoft.are.jbo.BizObject;
+import com.amarsoft.are.jbo.BizObjectManager;
+import com.amarsoft.are.jbo.JBOException;
+import com.amarsoft.are.jbo.JBOFactory;
+import com.amarsoft.are.jbo.JBOTransaction;
+import com.amarsoft.awe.Configure;
+import com.amarsoft.awe.util.ASResultSet;
+import com.amarsoft.awe.util.SqlObject;
+import com.amarsoft.awe.util.Transaction;
+import com.tenwa.doc.util.BASE64;
+import com.tenwa.makeContract.McontractService;
+import com.tenwa.makeContract.ReturnMessage;
+import com.tenwa.makeContract.util.MakeOneCodeAndContractModel;
+import com.tenwa.makeContract.util.McCalcConditionCopyService;
+import com.tenwa.util.SerialNumberUtil;
+
+public class McontractServiceImpl implements McontractService{
+
+ MakeOneCodeAndContractModel modc = new MakeOneCodeAndContractModel();
+ Configure CurConfig = Configure.getInstance();
+ @Override
+ public ReturnMessage Mcontract(String projectNo,String carNumber, String carNo,String Mstatus){
+ ReturnMessage rMage = new ReturnMessage();
+ if(projectNo==null||projectNo==""||projectNo.length()<=0){
+ rMage.setContractStatus("error");
+ rMage.setMale("ŲΪ");
+ }else if (carNumber==null||carNumber==""||carNumber.length()<=0){
+ rMage.setContractStatus("error");
+ rMage.setMale("ܺŲΪ");
+ }else if(carNo==null||carNo==""||carNo.length()<=0){
+ rMage.setContractStatus("error");
+ rMage.setMale("ŲΪ");
+ }else if(Mstatus==null||Mstatus==""||Mstatus.length()<=0){
+ rMage.setContractStatus("error");
+ rMage.setMale("ʶΪ");
+ }else if("NEW".equalsIgnoreCase(Mstatus)){
+ String carColor = "ԳǼ֤ǼɫΪ";
+ return makeContract(projectNo,carNumber,carNo,carColor);
+ }else if("UPDATE".equalsIgnoreCase(Mstatus)){
+ return changeContract(projectNo,carNumber,carNo);
+ }else{
+ rMage.setContractStatus("error");
+ rMage.setMale("ʶ");
+ }
+ return rMage;
+ }
+
+ public ReturnMessage makeContract(String projectNo,String carNumber, String carNo,String carColor){
+ McCalcConditionCopyService mcs = new McCalcConditionCopyService();
+ ReturnMessage rMage = new ReturnMessage();
+
+ MakeOneCodeAndContractModel modc = new MakeOneCodeAndContractModel();
+ String tempid="";//ģid
+ String sTemplateParam="{'CurUserId':'8006U00000003','CurOrgId':'8006003'";//wordҪIJ
+ JBOTransaction tx = null;
+ try {
+ tx =JBOFactory.createJBOTransaction();
+ BizObjectManager lpiManage = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx);
+ BizObjectManager caManage = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME,tx);
+ BizObjectManager lciManage = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx);
+ BizObject lpi = lpiManage.createQuery("PROJECT_NO=:projectNo ").setParameter("projectNo", projectNo).getSingleResult(false);
+ if(lpi==null){
+ rMage.setContractStatus("error");
+ rMage.setMale("ϵͳţͬ");
+ return rMage;
+ }
+ /* BizObject ca = caManage.createQuery("PROJECT_ID=:projectId").setParameter("projectId", lpi.getAttribute("ID").getString()).getSingleResult(false);
+ if(ca==null){
+ rMage.setContractStatus("error");
+ rMage.setMale("ϵͳûв鵽ӦۿϢϵԱ");
+ return rMage;
+ }else if(!"Y".equals(ca.getAttribute("SIGN_STATUS").getString())){
+ rMage.setContractStatus("error");
+ rMage.setMale("ûǩԼ֤ѿͻ鿴ֻţɿۿǩԼ֤");
+ return rMage;
+ }*/
+ BizObject lci = lciManage.createQuery("PROJECT_ID=:projectId").setParameter("projectId", lpi.getAttribute("ID").getString()).getSingleResult(false);
+ if(lci!=null){
+ rMage.setContractStatus("success");
+ rMage.setMale("Ѻͬ");
+ Map fileBase = modc.fileBase(lci.getAttribute("ID").getString());
+ if(fileBase.size()>0){
+ rMage.setFileName(fileBase.get("fileName"));
+ rMage.setOutputFile(fileBase.get("outputFile"));
+ }else{
+ rMage.setMale("ûҵļϵԱ");
+ }
+ return rMage;
+ }
+ //ɺͬ
+ String area_code="0";
+ String contractno="";
+ String dept="";
+ dept+="A";
+ if(lpi.getAttribute("LEAS_FORM").toString().equals("01")){//ֱ
+ dept+="Z";
+ tempid="ed20493a9234495f9ba9a88a040e3a26";
+ }else{//
+ dept+="H";
+ tempid="7cd0bccfc26b4a71aeb159cf36d7bc4f";
+ }
+ contractno=SerialNumberUtil.getContractSerialNaumber(dept,area_code, tx);//ͬ
+ String contractId = java.util.UUID.randomUUID().toString().replaceAll("-", "");//ɺͬID
+ Transaction Sqlca =null;
+ Sqlca = Transaction.createTransaction(tx);
+ String projectId = lpi.getAttribute("ID").getString();
+ String SQL="{call proc_contract_Making('"+projectId+"','"+contractId+"','"+contractno+"','"+carNumber+"','"+carColor+"','"+carNo+"')} ";
+ SqlObject asql = new SqlObject(SQL);
+ ASResultSet rs = null;
+ try {
+ rs = Sqlca.getASResultSet(asql);
+ mcs.tempToContractOne(projectId, projectNo, contractno, contractId, tx);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ finally{
+ Sqlca.disConnect();
+ Sqlca=null;
+ };
+ String diskPath=CurConfig.getConfigure("OneDimensionalCode");
+ //ݺͬһάͼƬ
+// JBOTransaction onetx =JBOFactory.createJBOTransaction();
+ String path = modc.MOneDimensionalCode(contractno, contractId, projectId,diskPath,tx);
+ //wordĵ
+ String wordPath=CurConfig.getConfigure("FileSavePath");
+ sTemplateParam=sTemplateParam+",'CONTRACT_ID':'"+contractId+"','PROJ_ID':'"+projectId+"','CONTRACT_NO':'"+contractno+"','fileSavePath':'"+wordPath+"','carcolor':'"+carColor+"','carNumber':'"+carNumber+"','carNo':'"+carNo+"'}";
+ modc.createBqWord(sTemplateParam, tempid, tx);
+ //wordתpdf
+// onetx.commit();
+// JBOTransaction wordtx =JBOFactory.createJBOTransaction();
+ String wordTopdf = modc.wordTopdf(projectId, contractId, tx);
+ //ͬ
+ String compnySignIng = modc.compnySignIng(contractId, tx);
+ //һάӵpdf
+// wordtx.commit();
+// JBOTransaction pdftx =JBOFactory.createJBOTransaction();
+ String outPdfFile = CurConfig.getConfigure("BQcontract");
+ String newPath = modc.pdfAndMark(outPdfFile, path, contractId, tx);
+// pdftx.commit();
+
+ String massage = outputFile(newPath);
+ if("error".equals(massage)){
+ rMage.setContractStatus("error");
+ rMage.setMale("pdfļڣ");
+ tx.rollback();
+ return rMage;
+ }
+ rMage.setContractStatus("success");
+ rMage.setFileName(newPath.substring(newPath.lastIndexOf("/")+1));
+ rMage.setOutputFile(massage);
+// String upload = BASE64.encodeImgageToBase64(file);
+
+// System.out.println(upload);
+// return "{'contractStatus':'success','fileName':'"+newPath.substring(newPath.indexOf("/")+1)+"','outputFile':'"+upload+"','male':'Ϊ"+projectNo+"Ѻͬظ'}";
+ tx.commit();
+ return rMage;
+ } catch (Exception e) {
+ try {
+ tx.rollback();
+ } catch (JBOException e1) {
+ e1.printStackTrace();
+ }
+ e.printStackTrace();
+ System.out.println(e.toString());
+ rMage.setContractStatus("error");
+ rMage.setMale("ͬʧܣ·ͬ");
+// return "{'contractStatus':'error','fileName':'','outputFile':'','male':'"+e.toString()+"'}";
+ return rMage;
+ }
+
+
+ }
+
+ public ReturnMessage changeContract(String projectNo,String carNumber, String carNo){
+ ReturnMessage rMage = new ReturnMessage();
+ String tempid="";//ģid
+ String sTemplateParam="{'CurUserId':'8006U00000003','CurOrgId':'8006003'";//wordҪIJ
+ JBOTransaction tx = null;
+ try {
+ tx =JBOFactory.createJBOTransaction();
+ BizObjectManager lpiManage = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx);
+ BizObjectManager lecManage = JBOFactory.getBizObjectManager(LB_EQUIPMENT_CAR.CLASS_NAME,tx);
+ BizObjectManager lciManage = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx);
+ BizObject lpi = lpiManage.createQuery("PROJECT_NO=:projectNo ").setParameter("projectNo", projectNo).getSingleResult(false);
+ if(lpi==null){
+ rMage.setContractStatus("error");
+ rMage.setMale("ϵͳţͬ");
+ return rMage;
+ }
+ String projectId = lpi.getAttribute("ID").getString();
+ BizObject lci = lciManage.createQuery("PROJECT_ID=:projectId").setParameter("projectId", lpi.getAttribute("ID").getString()).getSingleResult(false);
+ if(lci==null){
+ rMage.setContractStatus("error");
+ rMage.setMale("ûͬȺͬ");
+ return rMage;
+ }else if(!"21".equals(lci.getAttribute("CONTRACT_STATUS").getString())){
+ BizObjectManager lcsManage = JBOFactory.getBizObjectManager(LB_CONTRACT_STATUS.CLASS_NAME,tx);
+ BizObject lcs = lcsManage.createQuery(" STATUS_CODE=:statuscode ").setParameter("statuscode", lci.getAttribute("CONTRACT_STATUS").getString()).getSingleResult(false);
+ if(lcs==null){
+ rMage.setContractStatus("error");
+ rMage.setMale("ͬ״̬ϵԱ");
+ }else{
+ rMage.setContractStatus("error");
+ rMage.setMale("ͬ״̬Ϊ"+lcs.getAttribute("STATUS_NAME").getString()+"ܺͬ");
+ }
+ return rMage;
+ }
+ String contractId = lci.getAttribute("ID").getString();
+ String contractno = lci.getAttribute("contract_no").getString();
+ //УͬǷڸ
+ BizObjectManager fwfManage = JBOFactory.getBizObjectManager(FLOW_WORK_FLAG.CLASS_NAME,tx);
+ BizObject fwf = fwfManage.createQuery(" mutex_key=:cotnractId and flow_name='FundPaymentCarFlow' ").setParameter("cotnractId", contractId).getSingleResult(false);
+ if(fwf!=null){
+ rMage.setContractStatus("error");
+ rMage.setMale("úͬڸУܺͬ");
+ return rMage;
+ }
+ //УͬǷѾͨ
+ BizObjectManager lfiManage = JBOFactory.getBizObjectManager(LC_FUND_INCOME.CLASS_NAME,tx);
+ List lfis = lfiManage.createQuery(" contract_id=:contractid ").setParameter("contractid", contractId).getResultList(false);
+ if(lfis.size()>0){
+ rMage.setContractStatus("error");
+ rMage.setMale("úͬѾͨ룬ܺͬ");
+ return rMage;
+ }
+ //УǷ
+ BizObject lec = lecManage.createQuery(" PROJECT_ID=:projectId and CONTRACT_ID=:contractId").setParameter("projectId", projectId).setParameter("contractId", lci.getAttribute("ID").getString()).getSingleResult(true);
+ if(lec==null){
+ rMage.setContractStatus("error");
+ rMage.setMale("ûв鵽ϢϵԱ!!!");
+ return rMage;
+ }else if(carNumber.equals(lec.getAttribute("FRAME_NUMBER").getString())&&carNo.equals(lec.getAttribute("ENGINE_NUMBER").getString())){
+ rMage.setContractStatus("error");
+ rMage.setMale("ûпɱݣݣ");
+ Map fileBase = modc.fileBase(lci.getAttribute("ID").getString());
+ if(fileBase.size()>0){
+ rMage.setFileName(fileBase.get("fileName"));
+ rMage.setOutputFile(fileBase.get("outputFile"));
+ }
+ return rMage;
+ }
+ lec.setAttributeValue("FRAME_NUMBER", carNumber);
+ lec.setAttributeValue("ENGINE_NUMBER", carNo);
+ lecManage.saveObject(lec);
+ //ȡģ
+ if(lpi.getAttribute("LEAS_FORM").toString().equals("01")){//ֱ
+ tempid="ed20493a9234495f9ba9a88a040e3a26";
+ }else{//
+ tempid="7cd0bccfc26b4a71aeb159cf36d7bc4f";
+ }
+ //ȡģ·
+ String wordPath=CurConfig.getConfigure("FileSavePath");
+ sTemplateParam=sTemplateParam+",'CONTRACT_ID':'"+contractId+"','PROJ_ID':'"+projectId+"','CONTRACT_NO':'"+contractno+"','fileSavePath':'"+wordPath+"','carcolor':'"+lec.getAttribute("CAR_COLOUR").getString()+"','carNumber':'"+carNumber+"','carNo':'"+carNo+"'}";
+ //ɾLB_DOC_CONTRACT_LISTǰ
+ modc.BqChangecontract(contractId, tx);
+ //wordĵ
+ String createBqWord = modc.createBqWord(sTemplateParam, tempid, tx);
+ //wordתpdfɵ·
+ String wordTopdf = modc.wordTopdf(projectId, contractId, tx);
+ //ͬ
+ String compnySignIng = modc.compnySignIng(contractId, tx);
+ //һάӵpdf
+ String outPdfFile = CurConfig.getConfigure("BQcontract");
+ String newPath = modc.pdfAndMark(outPdfFile, "", contractId, tx);
+
+ rMage.setContractStatus("success");
+
+ Map fileBase = modc.fileBase(contractId);
+ if(fileBase.size()>0){
+ rMage.setFileName(fileBase.get("fileName"));
+ rMage.setOutputFile(fileBase.get("outputFile"));
+ rMage.setMale("ͬɹ");
+ }else{
+ rMage.setMale("ͬļûҵϵԱ");
+ }
+ tx.commit();
+ return rMage;
+
+ /*String filePath = filePath(lci.getAttribute("ID").getString());
+ String massage = outputFile(filePath);
+ if("error".equals(massage)){
+ rMage.setContractStatus("success");
+ rMage.setMale("pdfļڣϵԱ");
+ return rMage;
+ }
+ rMage.setContractStatus("error");
+ rMage.setMale("Ѻͬ");
+ rMage.setFileName(filePath.substring(filePath.lastIndexOf("/")+1));
+ rMage.setOutputFile(massage);
+ return rMage;*/
+
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return rMage;
+ }
+
+ public String outputFile(String newPath){
+ //ļתΪString
+ File file = new File(newPath);
+ if (!file.exists()) {
+// throw new RuntimeException("Ҫȡļ");
+ return "error";
+ }
+ return BASE64.encodeImgageToBase64(file);
+ }
+ /*public String filePath(String contractId) throws Exception{
+ BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME);
+ BizObject cont = contBom.createQuery(" contract_id=:contractid").setParameter("contractid", contractId).getSingleResult(false);
+ if(cont==null){
+ return "";
+ }
+ return cont.getAttribute("fullpath").getString();
+ }*/
+ /*public String upload(DataHandler handler, String fileName) {
+ if (fileName != null && !"".equals(fileName)) {
+ File file = new File(fileName);
+ if (handler != null) {
+ InputStream is = null;
+ FileOutputStream fos = null;
+ try {
+ is = handler.getInputStream();
+ fos = new FileOutputStream(file);
+ byte[] buff = new byte[1024 * 8];
+ int len = 0;
+ while ((len = is.read(buff)) > 0) {
+ fos.write(buff, 0, len);
+ }
+ } catch (FileNotFoundException e) {
+ return "fileNotFound";
+ } catch (Exception e) {
+ return "upload File failure";
+ } finally {
+ try {
+ if (fos != null) {
+ fos.flush();
+ fos.close();
+ }
+ if (is != null) {
+ is.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+// return "file absolute path:" + file.getAbsolutePath();
+ return file.getAbsolutePath();
+ } else {
+ return "handler is null";
+ }
+ } else {
+ return "fileName is null";
+ }
+ }*/
+}
diff --git a/src_tenwa/com/tenwa/makeContract/util/BqBaseWordCallBackServiceImpl.java b/src_tenwa/com/tenwa/makeContract/util/BqBaseWordCallBackServiceImpl.java
new file mode 100644
index 000000000..ef121dd5d
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/util/BqBaseWordCallBackServiceImpl.java
@@ -0,0 +1,145 @@
+package com.tenwa.makeContract.util;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import jbo.sys.CODE_LIBRARY;
+
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+
+import com.amarsoft.are.jbo.BizObject;
+import com.amarsoft.are.jbo.JBOFactory;
+import com.amarsoft.are.jbo.JBOTransaction;
+import com.amarsoft.ars.zip.ZipEntry;
+import com.amarsoft.ars.zip.ZipFile;
+import com.tenwa.comm.exception.BusinessException;
+import com.tenwa.officetempalte.service.BaseLableDataService;
+import com.tenwa.officetempalte.serviceImp.BaseWordLableReplaceServiceImp;
+import com.tenwa.officetempalte.util.FileOperatorUtil;
+import com.tenwa.officetempalte.util.WordBookMarkXmlUtil;
+
+public class BqBaseWordCallBackServiceImpl extends BqCreateOfficeCallBackService{
+ @Override
+ public void run(BizObject templateConfig, Map paramMap,
+ JBOTransaction tx) throws Exception {
+
+ BaseLableDataService dataSer=new BaseLableDataService(tx);
+ //ȡģ
+ List exportConfig=dataSer.getTemplateExportConfig(templateConfig.getAttribute("id").getString());
+
+ Map tempModel=new HashMap();
+ tempModel.putAll(paramMap);
+
+ //ȡļʵ·
+ String fileName="";
+ String filePath="";
+ String fullPath="";
+ fileName=FileOperatorUtil.getFileNameByFormual(templateConfig.getAttribute("templateshowname").getString(), tempModel);
+ String uuid=UUID.randomUUID().toString().replaceAll("-", "");
+ fullPath=FileOperatorUtil.getuploadFileDir(paramMap.get("fileSavePath")) +uuid+"_"+fileName;
+ filePath=fullPath.replace(paramMap.get("fileSavePath"), "");
+ //ȡģļ
+ String tempName=templateConfig.getAttribute("templatepath").getString();
+ String rootPath=this.getClass().getResource("/").getPath();
+ rootPath=rootPath.substring(0, rootPath.indexOf("WEB-INF")-1);
+ tempName=rootPath+"/fileTemplate/"+tempName;
+ String suffix = tempName.substring(tempName.lastIndexOf("."));
+ File file = new File(tempName);
+ if (file.isFile()) {
+ if (suffix.indexOf("doc") > 0) {
+ try {
+ //word
+ this.writeDatatoTemplateWordbyBookMark(tempName, paramMap, fullPath,exportConfig,tx);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BusinessException("дwordģʱ"+e.getMessage());
+ }
+ }
+ } else {
+ throw new BusinessException(templateConfig.getAttribute("templateshowname").getString() + "ûģ");
+ }
+ //ɳɹ άϵ
+ this.createRelative(templateConfig, paramMap, fileName, filePath, fullPath, tx);
+ }
+
+ public void runBefore(BizObject templateConfig,
+ Map paramMap, JBOTransaction tx) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void runAllBefore(BizObject templateConfig,
+ Map paramMap, JBOTransaction tx) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+ //wordĵ
+ public void writeDatatoTemplateWordbyBookMark(String tempfile,Map model, String targetFile,List exportConfig,JBOTransaction tx) throws Exception{
+
+ BaseWordLableReplaceServiceImp wordSer=new BaseWordLableReplaceServiceImp();
+ BaseLableDataService lableSer=new BaseLableDataService(tx);
+
+ Document document = null;
+ File file = new File(tempfile);
+ ZipFile docxFile = new ZipFile(file);
+ ZipEntry documentXML = docxFile.getEntry("word/document.xml");
+ InputStream documentXMLIS = docxFile.getInputStream(documentXML);
+ SAXReader saxReader = new SAXReader();
+ document = saxReader.read(documentXMLIS);
+ Map documents=new HashMap();
+ documents.put("miandocument", document);
+
+ Map footmap=WordBookMarkXmlUtil.getfooter(docxFile);
+ documents.putAll(footmap);
+ Map operMap=new HashMap();
+ operMap.put("default", wordSer);
+
+ Map configData=new HashMap();
+
+ for(BizObject config:exportConfig){
+ configData=lableSer.getLableDataByConfig(config, model);
+ Class> oper=null;
+ Method replaceString=null;
+ Method replaceList=null;
+ Method replaceTable=null;
+ String operator_class=config.getAttribute("operatorclass").getString();
+ if(operator_class.length()==0||operator_class.equals("word_default_class")){
+ oper=operMap.get("default").getClass();
+ }else if(operMap.containsKey(operator_class)){
+ oper=(Class>)operMap.get(operator_class);
+ }else{
+ BizObject code=JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("itemno=:itemno and codeno='lable_operator_class'")
+ .setParameter("itemno", operator_class).getSingleResult(false);
+ oper=Class.forName(code.getAttribute("itemattribute").getString());
+ operMap.put(operator_class, oper);
+ }
+ replaceString=oper.getMethod("replaceStringLable",Map.class,BizObject.class,Map.class);
+ replaceList=oper.getMethod("replaceListLable",Map.class,BizObject.class,Map.class);
+ replaceTable=oper.getMethod("replaceTableLable",Map.class,BizObject.class,Map.class);
+ if(config.getAttribute("tagtype").getString().equals("tag_type1")){//ַ
+ replaceString.invoke(oper.newInstance(),documents,config,configData);
+ }else if(config.getAttribute("tagtype").getString().equals("tag_type2")){//
+ replaceList.invoke(oper.newInstance(),documents,config,configData);
+ }else if(config.getAttribute("tagtype").getString().equals("tag_type3")){//
+ replaceTable.invoke(oper.newInstance(),documents,config,configData);
+ }
+ }
+ //ĵ
+ WordBookMarkXmlUtil.saveWordXML(docxFile,document,footmap,targetFile);
+ }
+
+ @Override
+ public void runAfter(BizObject templateConfig,
+ Map paramMap, JBOTransaction tx) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeCallBackService.java b/src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeCallBackService.java
new file mode 100644
index 000000000..c18e65b14
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeCallBackService.java
@@ -0,0 +1,136 @@
+package com.tenwa.makeContract.util;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import jbo.app.tenwa.doc.LB_DOCATTRIBUTE;
+import jbo.app.tenwa.doc.LB_DOCCONFIG;
+import jbo.app.tenwa.doc.LB_DOCLIBRARY;
+import jbo.app.tenwa.doc.LB_DOCRELATIVE;
+import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST;
+
+import com.amarsoft.are.jbo.BizObject;
+import com.amarsoft.are.jbo.BizObjectManager;
+import com.amarsoft.are.jbo.BizObjectQuery;
+import com.amarsoft.are.jbo.JBOFactory;
+import com.amarsoft.are.jbo.JBOTransaction;
+import com.amarsoft.are.util.StringFunction;
+/**
+ * ģ崦ӿ
+ *
+ * */
+public abstract class BqCreateOfficeCallBackService {
+ public abstract void run(BizObject templateConfig,Map paramMap,JBOTransaction tx) throws Exception;
+ public abstract void runBefore(BizObject templateConfig,Map paramMap,JBOTransaction tx) throws Exception;
+ public abstract void runAllBefore(BizObject templateConfig,Map paramMap,JBOTransaction tx) throws Exception;
+ public abstract void runAfter(BizObject templateConfig,Map paramMap,JBOTransaction tx) throws Exception;
+
+ //άϵ
+ public void createRelative(BizObject templateConfig,Map paramMap,String filename,String filepath,String fullpath,JBOTransaction tx) throws Exception{
+ String doctype=templateConfig.getAttribute("DocType").getString();
+ String one_classify= templateConfig.getAttribute("ONECLASSIFY").getString();
+ Map condtionMap=new HashMap();
+ String[] s=new String[]{"OBJECTTYPE","PROJ_ID","CONTRACT_ID","PLAN_NUMBER","PLAN_LIST","CUST_ID","FLOW_UNID","TEMPLATE_ID"};
+ for(int i=0;i entry:condtionMap.entrySet()){
+ sql+=" and rel."+entry.getKey()+"=:"+entry.getKey();
+ }
+ BizObjectQuery query=libBm.createQuery(sql);
+ query.setParameter("oneclassify", one_classify);
+ query.setParameter("doctype", doctype);
+ query.setParameter("docname", templateConfig.getAttribute("TEMPLATENAME").getString());
+ for(Map.Entry entry:condtionMap.entrySet()){
+ query.setParameter(entry.getKey(),entry.getValue());
+ }
+ BizObject lib=query.getSingleResult(false);
+ String libraryId;
+ if(lib==null){
+ //ʼ
+ BizObject rela=relaBm.newObject();
+ for(Map.Entry entry:condtionMap.entrySet()){
+ rela.setAttributeValue(entry.getKey(), entry.getValue());
+ }
+ relaBm.saveObject(rela);
+ String relativeid=rela.getAttribute("id").getString();
+ //ʼ
+ lib=libBm.newObject();
+ lib.setAttributeValue("doc_name", templateConfig.getAttribute("TEMPLATENAME").getString());
+ lib.setAttributeValue("Doc_type", doctype);
+ lib.setAttributeValue("One_Classify", one_classify);
+ lib.setAttributeValue("Relative_id", relativeid);
+ lib.setAttributeValue("Is_File_List","0");
+ libBm.saveObject(lib);
+ libraryId=lib.getAttribute("id").getString();
+ }else{
+ libraryId=lib.getAttribute("id").getString();
+ }
+ File file=new File(fullpath);
+ BizObject attr=attrBm.newObject();
+ attr.setAttributeValue("Library_id", libraryId);
+ attr.setAttributeValue("FileName", filename);
+ attr.setAttributeValue("InputUserId",paramMap.get("CurUserId"));
+ attr.setAttributeValue("InputOrgId", paramMap.get("CurOrgId"));
+ attr.setAttributeValue("InputTime",StringFunction.getTodayNow());
+ attr.setAttributeValue("FilePath",filepath);
+ attr.setAttributeValue("FullPath",fullpath);
+ if(fullpath.endsWith(".docx")){
+ attr.setAttributeValue("Content_Type","application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ }else if(fullpath.endsWith(".xlsx")){
+ attr.setAttributeValue("Content_Type","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ }else if(fullpath.endsWith(".xls")){
+ attr.setAttributeValue("Content_Type","application/vnd.ms-excel");
+ }
+ attr.setAttributeValue("FileSize",file.length());
+ attrBm.saveObject(attr);
+
+ // дLB_DOC_CONTRACT_LIST
+ // ģȡlb_docconfigϢ
+ String attrId = attr.getAttribute("id").getString();
+ BizObjectManager lbcontractBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx);
+ Map contractMap = new HashMap();
+ String[] ss = new String[] {"CUSTOMERNAME", "TELEPHONE", "CONTRACT_NO", "CONTRACT_ID", "PROJECT_ID", "PRODECT_ID", "IDS",
+ "FLOW_UNID"};
+ for (int i = 0; i < ss.length; i++) {
+ if (paramMap.containsKey(ss[i])) {
+ contractMap.put(ss[i], paramMap.get(ss[i]));
+ }
+ }
+ BizObject contract = lbcontractBom.newObject();
+ for (Map.Entry entry : contractMap.entrySet()) {
+ contract.setAttributeValue(entry.getKey(), entry.getValue());
+ }
+ contract.setAttributeValue("InputUserId", paramMap.get("CurUserId"));
+ contract.setAttributeValue("InputOrgId", paramMap.get("CurOrgId"));
+ contract.setAttributeValue("FILENAME", attr.getAttribute("FILENAME").toString());
+ contract.setAttributeValue("ATTRIBUTE_ID", attrId);
+ contract.setAttributeValue("LIBRARY_ID", libraryId);
+ contract.setAttributeValue("FILE_TYPE", "ɨ");
+ contract.setAttributeValue("FILE_FLAG", "yes");
+ contract.setAttributeValue("DOC_NAME", templateConfig.getAttribute("TEMPLATENAME").getString());
+ contract.setAttributeValue("FILEPATH", attr.getAttribute("FILEPATH").toString());
+ contract.setAttributeValue("FULLPATH", attr.getAttribute("FULLPATH").toString());
+ contract.setAttributeValue("InputTime", StringFunction.getTodayNow());
+// contract.setAttributeValue("CONFIG_ID", templateConfig.getAttribute("CONFIG_ID").getString());
+// contract.setAttributeValue("DOC_CLASS_ITEMNO", bo.getAttribute("DOC_CLASS_ITEMNO").getString());
+ if (fullpath.endsWith(".pdf")) {
+ contract.setAttributeValue("PROCESS", "2");
+ } else if (fullpath.endsWith(".docx") || fullpath.endsWith(".doc")) {
+ contract.setAttributeValue("PROCESS", "1");
+ }
+ contract.setAttributeValue("SIGN_TYPE", "DRAFT");// ǩԼ״̬ĬΪݸ
+ contract.setAttributeValue("SENDPROCESS", "0");// ״̬Ĭδ
+ lbcontractBom.saveObject(contract);
+ }
+}
diff --git a/src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeService.java b/src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeService.java
new file mode 100644
index 000000000..27d797cad
--- /dev/null
+++ b/src_tenwa/com/tenwa/makeContract/util/BqCreateOfficeService.java
@@ -0,0 +1,171 @@
+package com.tenwa.makeContract.util;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jbo.com.tenwa.entity.comm.officetempalte.BF_TEMPLATE;
+
+import com.amarsoft.app.util.XMLDataUtil;
+import com.amarsoft.are.ARE;
+import com.amarsoft.are.jbo.BizObject;
+import com.amarsoft.are.jbo.BizObjectManager;
+import com.amarsoft.are.jbo.BizObjectQuery;
+import com.amarsoft.are.jbo.JBOFactory;
+import com.amarsoft.are.jbo.JBOTransaction;
+import com.amarsoft.are.log.Log;
+import com.amarsoft.awe.util.ASResultSet;
+import com.amarsoft.awe.util.SqlObject;
+import com.amarsoft.awe.util.Transaction;
+import com.tenwa.comm.exception.BusinessException;
+import com.tenwa.officetempalte.service.BaseParamService;
+import com.tenwa.officetempalte.service.CreateOfficeCallBackService;
+import com.tenwa.officetempalte.util.FileOperatorUtil;
+/**
+ * ģ崴ļ
+ * ⲿ createOfficeByTemplateNo
+ * */
+public class BqCreateOfficeService {
+ public static Log logger=ARE.getLog();
+ JBOTransaction tx;
+ Transaction Sqlca =null;
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//ڸʽ
+ public BqCreateOfficeService(JBOTransaction tx)throws Exception{
+ this.tx=tx;
+ Sqlca=Transaction.createTransaction(tx);
+ }
+ /**
+ * ģźǰ̨ļ
+ * @param templateNo ģ
+ * @param model ǰ̨
+ *
+ * */
+ @SuppressWarnings("unchecked")
+ public void createOfficeByTemplateNo(String templateNo,Mapmodel) throws Exception{
+ try{
+ //ȡģ
+ BizObject templateConfig=this.getTemplateConfigByNo(templateNo);
+ if(templateConfig==null){
+ throw new BusinessException("ģ"+templateNo+"ûҵģ");
+ }
+ //ģźǰ̨ȡģֵ
+ BaseParamService paramSer=new BaseParamService(tx);
+ //ģ崦
+ Class callback=null;
+ //ȡģ崦
+ if(templateConfig.getAttribute("callback").getString().length()>0){
+ try{
+ callback=(Class) Class.forName(templateConfig.getAttribute("callback").getString());
+ }catch(Exception e){
+ throw new BusinessException(templateConfig.getAttribute("templatename").getString()+"ģ崦δҵ");
+ }
+ }else if(templateConfig.getAttribute("templatetype").getString().equals("word")){//wordĬģ崦
+ callback=(Class) Class.forName("com.tenwa.makeContract.util.BqBaseWordCallBackServiceImpl");
+ }else if(templateConfig.getAttribute("templatetype").getString().equals("excel")){//excel Ĭģ崦
+ callback=(Class) Class.forName("com.tenwa.makeContract.util.BqBaseWordCallBackServiceImpl");
+ }else{
+ throw new BusinessException(templateConfig.getAttribute("templatename").getString()+"ģ崦δҵ");
+ }
+ //ȡģ崦ķ
+ BqCreateOfficeCallBackService ser=callback.newInstance();
+
+ //ǰ
+ ser.runAllBefore(templateConfig, model, tx);
+
+ //ȡģ崴
+ List