From 3358a90e80557eeb54c14e95a9b94e7d2b57f0ef Mon Sep 17 00:00:00 2001 From: tangfutang Date: Mon, 8 Jun 2020 20:06:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91app=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E7=94=B5=E5=AD=90=E7=AD=BE=E7=BA=A6=E3=80=81=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E9=87=8D=E5=8F=91=E3=80=81=E6=9F=A5=E8=AF=A2=E7=AD=BE=E7=BA=A6?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ContractMakeController.java | 60 ++++++ .../make/service/ContractMakeService.java | 15 ++ .../service/impl/ContractMakeServiceImpl.java | 185 +++++++++++++++++- 3 files changed, 251 insertions(+), 9 deletions(-) diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/controller/ContractMakeController.java b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/controller/ContractMakeController.java index 3fa9821d5..0ddb31622 100644 --- a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/controller/ContractMakeController.java +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/controller/ContractMakeController.java @@ -85,4 +85,64 @@ public class ContractMakeController { return ReturnMapUtil.rollback(e); } } + + /** + * 发起签约验证 + */ + @Path("/initiate/sign") + @POST + public Map initiateSign(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca) throws Exception { + ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca); + ARE.getLog() + .info("[CONTROLLER] BusinessDataController run ................."); + ARE.getLog().info( + "[Path] /contract/make/initiate/sign" + " run ................."); + try { + return service.initiateSign(request, response, tx, sqlca, ReturnMapUtil); + } catch (Exception e) { + return ReturnMapUtil.rollback(e); + } + } + + /** + * 电子签约短信重发 + */ + @Path("/sendMessage/again") + @POST + public Map sendMessageAgain(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca) throws Exception { + ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca); + ARE.getLog() + .info("[CONTROLLER] BusinessDataController run ................."); + ARE.getLog().info( + "[Path] /contract/make/sendMessage/again" + " run ................."); + try { + return service.sendMessageAgain(request, response, tx, sqlca, ReturnMapUtil); + } catch (Exception e) { + return ReturnMapUtil.rollback(e); + } + } + + /** + * 签约结果查询 + */ + @Path("/query/again") + @POST + public Map queryAgain(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca) throws Exception { + ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca); + ARE.getLog() + .info("[CONTROLLER] BusinessDataController run ................."); + ARE.getLog().info( + "[Path] /contract/make/query/again" + " run ................."); + try { + return service.queryAgain(request, response, tx, sqlca, ReturnMapUtil); + } catch (Exception e) { + return ReturnMapUtil.rollback(e); + } + } } diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/ContractMakeService.java b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/ContractMakeService.java index 6e5efd872..d8c9a2999 100644 --- a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/ContractMakeService.java +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/ContractMakeService.java @@ -24,6 +24,21 @@ public interface ContractMakeService { @Context Transaction sqlca, ReturnMapUtil ReturnMapUtil) throws Exception; + Map initiateSign(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca, ReturnMapUtil ReturnMapUtil) + throws Exception; + + Map sendMessageAgain(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca, ReturnMapUtil ReturnMapUtil) + throws Exception; + + Map queryAgain(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca, ReturnMapUtil ReturnMapUtil) + throws Exception; + } diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/impl/ContractMakeServiceImpl.java b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/impl/ContractMakeServiceImpl.java index 1ffed7934..f5d26eb81 100644 --- a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/impl/ContractMakeServiceImpl.java +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/contract/make/service/impl/ContractMakeServiceImpl.java @@ -15,6 +15,7 @@ import net.sf.json.JSONObject; 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; @@ -23,7 +24,9 @@ import com.amarsoft.context.ASUser; import com.base.constant.RestfullConstant; import com.base.util.MultipartDataUtil; import com.base.util.ReturnMapUtil; +import com.tenwa.action.channelportal.businesshanding.contractaward.ContractAward; import com.tenwa.app.baseFileTemplate.handle.FileTemplateUtil; +import com.tenwa.channelportal.action.ContractSignAction; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.makeContract.util.MakeOneCodeAndContractModel; import com.tenwa.officetempalte.action.CreateContractOfficeAction; @@ -116,33 +119,34 @@ public class ContractMakeServiceImpl implements ContractMakeService{ Configure CurConfig = Configure.getInstance(); String wordPath=CurConfig.getConfigure("FileSavePath"); if(templateId == null || templateId.length() == 0){ - body.put("status", "faile"); + body.put("status", "01"); body.put("message", "模板编号不能为空!"); }else if(message == null && !"success".equals(message)){ - body.put("status", "faile"); + body.put("status", "01"); body.put("message", message); }else if("error".equals(projectSignStatus)){ - body.put("status", "faile"); + body.put("status", "01"); body.put("message", "请提醒客户查看手机短信,首先完成扣款卡的签约验证!"); }else{ flowParms.put("templateId", templateId); flowParms.put("wordPath", wordPath); String makeContract = ContractMakeControllerUtil.makeContract(flowParms, sqlca); if(!"success".equals(makeContract)){ - body.put("status", "faile"); + body.put("status", "01"); body.put("message", makeContract); }else{ MakeOneCodeAndContractModel modc = new MakeOneCodeAndContractModel(); String diskPath=CurConfig.getConfigure("OneDimensionalCode"); //根据合同编号生成一维码图片 - String path = modc.MOneDimensionalCode(contractNo, contractId, projectId,diskPath,tx); - String outPdfFile = CurConfig.getConfigure("BQcontract"); - modc.pdfAndMark(outPdfFile, path, contractId,flowParms.get("leasform"), tx); + String path = modc.MOneDimensionalCode(contractNo, contractId, projectId,diskPath,sqlca); + String outPdfFile=CurConfig.getConfigure("BQcontract"); + modc.pdfAndMark(outPdfFile, path, contractId,flowParms.get("leasform"), sqlca); // //判断是否自动盖章sealType signType if(("01".equals(flowParms.get("customertype"))&&"Auto".equals(flowParms.get("sealType")) )||("Auto".equals(flowParms.get("sealType")) && "Hand".equals(flowParms.get("signType")) )){ - modc.compnySignIng(contractId, tx); + modc.compnySignIng(contractId, sqlca); } - body.put("status", "success"); + body.put("status", "00"); + body.put("message", ""); } } ReturnMapUtil.setReturnMap(body, @@ -201,4 +205,167 @@ public class ContractMakeServiceImpl implements ContractMakeService{ } return falg; } + @Override + public Map initiateSign(HttpServletRequest request, + HttpServletResponse response, JBOTransaction tx, Transaction sqlca, + ReturnMapUtil ReturnMapUtil) throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + fieldMap = (Map) testMap.get("fieldMap"); // 参数 + Map body = new HashMap(); + + String userid = fieldMap.get("userid") == null ? "" : fieldMap.get("userid").toString(); + String flowUnid = fieldMap.get("FlowUnid") == null ? "" : fieldMap.get("FlowUnid").toString(); + Map flowParms = ContractMakeControllerUtil.getFlowParms(flowUnid); + String checkSign = this.checkSign(flowParms,"initiateSign", tx); + + ContractSignAction csa = new ContractSignAction(); + csa.setProjectId(flowParms.get("ProjectId")); + String checkFile = this.checkFile(csa, tx); + if(!"success".equals(checkSign)){ + body.put("status", "01"); + body.put("message", checkSign); + }else if(!"success".equals(checkFile)){ + body.put("status", "01"); + body.put("message", checkFile); + }else{ + csa.setCurUserID(userid); + csa.setFlowUnid(flowParms.get("FlowUnid")); + csa.setSubjectId(flowParms.get("SubjectId")); + String signIng = csa.signIng(tx); + String[] signStatus = signIng.split("@"); + if("success".equals(signStatus[0])){ + body.put("status", "00"); + body.put("message", "电子签约发起成功!"); + }else{ + body.put("status", "01"); + body.put("message", signStatus[1]); + } + } + body.put("FlowUnid", flowUnid); + ReturnMapUtil.setReturnMap(body, + RestfullConstant.baseProperty.get("success").toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + + //校验发起电子签约条件 + public String checkFile(ContractSignAction csa ,JBOTransaction tx) throws Exception{ + String message = "success"; + String resultMessge = csa.getMakeContractProcess(tx); + if( ! "error".equals(resultMessge)){ + Integer fileStatus = new Integer(resultMessge); + if(fileStatus==1){ + message = "word转换PDF格式部分失败,"; + }else if(fileStatus==2){ + message = "word转换PDF格式失败"; + }else if(fileStatus==3){ + message = "word转换PDF格式部分失败"; + }else if(fileStatus==4){ + message = "word文件正在转换PDF文件格式"; + }else if(fileStatus==5){ + message = "word文件没有转换PDF文件格式"; + } + } + return message; + } + @Override + public Map sendMessageAgain(HttpServletRequest request, + HttpServletResponse response, JBOTransaction tx, Transaction sqlca, + ReturnMapUtil ReturnMapUtil) throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + fieldMap = (Map) testMap.get("fieldMap"); // 参数 + Map body = new HashMap(); + String userid = fieldMap.get("userid") == null ? "" : fieldMap.get("userid").toString(); + String flowUnid = fieldMap.get("FlowUnid") == null ? "" : fieldMap.get("FlowUnid").toString(); + + Map flowParms = ContractMakeControllerUtil.getFlowParms(flowUnid); + + String checkSign = this.checkSign(flowParms,"sendMessageAgain", tx); + if(!"success".equals(checkSign)){ + body.put("status", "01"); + body.put("message", checkSign); + }else{ + ContractSignAction csa = new ContractSignAction(); + csa.setProjectId(flowParms.get("ProjectId")); + csa.setSubjectId(flowParms.get("SubjectId")); + String sendMessageAgain = csa.sendMessageAgain(tx); + if("success".equals(sendMessageAgain)){ + body.put("status", "00"); + body.put("message", "短信发送成功!"); + }else{ + body.put("status", "01"); + body.put("message", "短信发送失败!["+sendMessageAgain+"]"); + } + } + body.put("FlowUnid", flowUnid); + ReturnMapUtil.setReturnMap(body, + RestfullConstant.baseProperty.get("success").toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + @Override + public Map queryAgain(HttpServletRequest request, + HttpServletResponse response, JBOTransaction tx, Transaction sqlca, + ReturnMapUtil ReturnMapUtil) throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + fieldMap = (Map) testMap.get("fieldMap"); // 参数 + Map body = new HashMap(); + String userid = fieldMap.get("userid") == null ? "" : fieldMap.get("userid").toString(); + String flowUnid = fieldMap.get("FlowUnid") == null ? "" : fieldMap.get("FlowUnid").toString(); + Map flowParms = ContractMakeControllerUtil.getFlowParms(flowUnid); + + String checkSign = this.checkSign(flowParms,"queryAgain", tx); + if(!"success".equals(checkSign)){ + body.put("status", "01"); + body.put("message", checkSign); + }else{ + ContractSignAction csa = new ContractSignAction(); + csa.setProjectId(flowParms.get("ProjectId")); + csa.setCustomerType(flowParms.get("customertype")); + csa.setFlowUnid(flowUnid); + csa.setCurUserID(userid); + csa.setSubjectId(flowParms.get("SubjectId")); + String contractSignStatus = csa.contractSignStatus(tx); + if("已经完成电子签约".equals(contractSignStatus)){ + body.put("status", "00"); + body.put("message",contractSignStatus); + }else{ + body.put("status", "01"); + body.put("message", contractSignStatus); + } + } + body.put("FlowUnid", flowUnid); + ReturnMapUtil.setReturnMap(body, + RestfullConstant.baseProperty.get("success").toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + + + //校验发起电子签约条件 + public String checkSign(Map flowParms,String signType,JBOTransaction tx) throws Exception{ + String message = "success"; + ContractAward ca = new ContractAward(); + ca.setProject_id(flowParms.get("ProjectId")); + ca.setFlowUnid(flowParms.get("FlowUnid")); + String projectStatus = ca.projectStatus(tx); + String[] result = projectStatus.split("@"); + String status = result[0]; + if("true".equals(result[3])){ + message = "请先生成pdf版的合同!!!"; + }; + if( status!=null && !status.equals("null") && status.length()>0 && new Integer(status) < 3 ){ + message = "请生成合同,在电子签约"; + }; + if(status!=null && !status.equals("null") && status.length()>0 && new Integer(status) > 4 &&new Integer(status) < 7 ){ + message = "合同状态为:"+result[1]+"不可以电子签章"; + } + if("4".equals(status)){ + message = "电子签约已完成,无需重复发起!"; + }; + if("8".equals(status) && "initiateSign".equals(signType)){ + message = "电子签约已发起,请签署电子合同!"; + }; + return message; + } }