diff --git a/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java b/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java index 839af3828..057eff771 100644 --- a/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java +++ b/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java @@ -10,11 +10,13 @@ import java.util.Map; import jbo.app.tenwa.calc.LC_FUND_INCOME; import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; import jbo.com.tenwa.entity.comm.flow.FLOW_WORK_FLAG; +import jbo.com.tenwa.lease.comm.BC_INTERFACE_LOGS; 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.util.StringFunction; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectKey; import com.amarsoft.are.jbo.BizObjectManager; @@ -37,27 +39,53 @@ public class McontractServiceImpl implements McontractService{ // MakeOneCodeAndContractModel modc = new MakeOneCodeAndContractModel(); Configure CurConfig = Configure.getInstance(); public ReturnMessage Mcontract(String projectNo,String carNumber, String carNo,String Mstatus){ + JBOTransaction BqLogs = null; 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("参数错误:制作标识参数有误!!"); + try { + BqLogs =JBOFactory.createJBOTransaction(); + BizObjectManager bilManage = JBOFactory.getBizObjectManager(BC_INTERFACE_LOGS.CLASS_NAME,BqLogs); + BizObject bil = bilManage.newObject(); + if(projectNo==null||projectNo==""||projectNo.length()<=0){ + rMage.setContractStatus("error"); + rMage.setMale("参数错误:申请编号不能为空"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "申请号为空"); + }else if (carNumber==null||carNumber==""||carNumber.length()<=0){ + rMage.setContractStatus("error"); + rMage.setMale("参数错误:车架号不能为空"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "车架号为空"); + }else if(carNo==null||carNo==""||carNo.length()<=0){ + rMage.setContractStatus("error"); + rMage.setMale("参数错误:发动机号不能为空"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "发动机号为空"); + }else if(Mstatus==null||Mstatus==""||Mstatus.length()<=0){ + rMage.setContractStatus("error"); + rMage.setMale("参数错误:制作标识不能为空"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "制作标识为空"); + }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("参数错误:制作标识参数有误!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "制作参数错误"); + } + bil.setAttributeValue("projectNo", projectNo); + bil.setAttributeValue("carNumber", carNumber); + bil.setAttributeValue("carNo", carNo); + bil.setAttributeValue("Mstatus", Mstatus); + bil.setAttributeValue("INPUTUSERID", "bcinterface"); + bil.setAttributeValue("INPUTTIME", StringFunction.getTodayNow()); + bilManage.saveObject(bil); + BqLogs.commit(); + }catch (Exception e) { + } return rMage; } @@ -71,38 +99,70 @@ public class McontractServiceImpl implements McontractService{ String tempid="";//模板id String sTemplateParam="{'CurUserId':'8006U00000003','CurOrgId':'8006003'";//生成word需要的参数 JBOTransaction tx = null; + JBOTransaction BqLogs = null; + BizObjectManager bilManage=null; + BizObject bil = null; try { tx =JBOFactory.createJBOTransaction(); + BqLogs =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); + //保存日志信息 + bilManage = JBOFactory.getBizObjectManager(BC_INTERFACE_LOGS.CLASS_NAME,BqLogs); + bil = bilManage.newObject(); + bil.setAttributeValue("projectNo", projectNo); + bil.setAttributeValue("carNumber", carNumber); + bil.setAttributeValue("carNo", carNo); + bil.setAttributeValue("Mstatus", "NEW"); + bil.setAttributeValue("INPUTUSERID", "bcinterface"); + bil.setAttributeValue("INPUTTIME", StringFunction.getTodayNow()); if(lpi==null){ rMage.setContractStatus("error"); rMage.setMale("系统中无此申请编号,无法合同制作!!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "系统中无此申请编号"); + bilManage.saveObject(bil); + BqLogs.commit(); 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("该申请编号在系统中没有查到对应扣款卡信息。请联系管理员!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "申请编号在系统中没有查到对应扣款卡信息"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; }else if(!"Y".equals(ca.getAttribute("SIGN_STATUS").getString())){ rMage.setContractStatus("error"); rMage.setMale("该申请号没有完成签约验证。请提醒客户查看手机短信,首先完成扣款卡的签约验证!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "申请号没有完成签约验证"); + bilManage.saveObject(bil); + BqLogs.commit(); 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("该申请已合同制作,无法重新制作!!!"); + rMage.setMale("该申请号已合同制作,无法重新制作!!!"); Map fileBase = modc.fileBase(lci.getAttribute("ID").getString()); if(fileBase.size()>0){ rMage.setFileName(fileBase.get("fileName")); rMage.setOutputFile(fileBase.get("outputFile")); + bil.setAttributeValue("fileName", fileBase.get("fileName").toString()); + bil.setAttributeValue("isfile", "Y"); }else{ rMage.setMale("没有找到文件,请联系管理员!!!"); + bil.setAttributeValue("isfile", "N"); } + bil.setAttributeValue("contractStatus", "success"); + bil.setAttributeValue("male", "申请号已合同制作"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; } //生成合同编号 @@ -149,7 +209,7 @@ public class McontractServiceImpl implements McontractService{ // JBOTransaction wordtx =JBOFactory.createJBOTransaction(); String wordTopdf = modc.wordTopdf(projectId, contractId, tx); //合同盖章 -// String compnySignIng = modc.compnySignIng(contractId, tx); + String compnySignIng = modc.compnySignIng(contractId, tx); //将一维码添加到pdf中 // wordtx.commit(); // JBOTransaction pdftx =JBOFactory.createJBOTransaction(); @@ -162,15 +222,22 @@ public class McontractServiceImpl implements McontractService{ rMage.setContractStatus("error"); rMage.setMale("pdf文件不存在!!!"); tx.rollback(); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "pdf文件不存在"); + bilManage.saveObject(bil); + BqLogs.commit(); 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+"已合同制作,请勿重复制作'}"; + bil.setAttributeValue("contractStatus", "success"); + bil.setAttributeValue("fileName", newPath.substring(newPath.lastIndexOf("/")+1)); + bil.setAttributeValue("male", "合同制作完成"); + bil.setAttributeValue("isfile", "Y"); + bilManage.saveObject(bil); + BqLogs.commit(); tx.commit(); return rMage; } catch (Exception e) { @@ -181,6 +248,11 @@ public class McontractServiceImpl implements McontractService{ BizObject lci = lcibom.createQuery("project_id=:projectid").setParameter("projectid", projectId).getSingleResult(true); lcibom.deleteObject(lci); back.commit(); + + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "系统异常"); + bilManage.saveObject(bil); + BqLogs.commit(); } catch (JBOException e1) { e1.printStackTrace(); } @@ -188,7 +260,6 @@ public class McontractServiceImpl implements McontractService{ System.out.println(e.toString()); rMage.setContractStatus("error"); rMage.setMale("合同制作失败,请重新发起合同制作!!!"); -// return "{'contractStatus':'error','fileName':'','outputFile':'','male':'"+e.toString()+"'}"; return rMage; } @@ -201,15 +272,33 @@ public class McontractServiceImpl implements McontractService{ String tempid="";//模板id String sTemplateParam="{'CurUserId':'8006U00000003','CurOrgId':'8006003'";//生成word需要的参数 JBOTransaction tx = null; + JBOTransaction BqLogs = null; + BizObjectManager bilManage=null; + BizObject bil = null; try { tx =JBOFactory.createJBOTransaction(); + BqLogs =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); + + //保存日志信息 + bilManage = JBOFactory.getBizObjectManager(BC_INTERFACE_LOGS.CLASS_NAME,BqLogs); + bil = bilManage.newObject(); + bil.setAttributeValue("projectNo", projectNo); + bil.setAttributeValue("carNumber", carNumber); + bil.setAttributeValue("carNo", carNo); + bil.setAttributeValue("Mstatus", "UPDATE"); + bil.setAttributeValue("INPUTUSERID", "bcinterface"); + bil.setAttributeValue("INPUTTIME", StringFunction.getTodayNow()); if(lpi==null){ rMage.setContractStatus("error"); rMage.setMale("系统中无此申请编号,无法合同变更!!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "系统中无此申请编号,无法合同变更"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; } String projectId = lpi.getAttribute("ID").getString(); @@ -217,6 +306,10 @@ public class McontractServiceImpl implements McontractService{ if(lci==null){ rMage.setContractStatus("error"); rMage.setMale("该申请号没有生产合同,请先合同制作!!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "申请号没有生产合同,请先合同制作"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; }else if(!"21".equals(lci.getAttribute("CONTRACT_STATUS").getString())){ BizObjectManager lcsManage = JBOFactory.getBizObjectManager(LB_CONTRACT_STATUS.CLASS_NAME,tx); @@ -224,10 +317,15 @@ public class McontractServiceImpl implements McontractService{ if(lcs==null){ rMage.setContractStatus("error"); rMage.setMale("合同状态有误,请联系管理员!!!"); + bil.setAttributeValue("male", "合同状态有误,请联系管理员"); }else{ rMage.setContractStatus("error"); rMage.setMale("合同状态为:"+lcs.getAttribute("STATUS_NAME").getString()+",不能合同变更"); + bil.setAttributeValue("male", "合同状态为:"+lcs.getAttribute("STATUS_NAME").getString()+",不能合同变更"); } + bil.setAttributeValue("contractStatus", "error"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; } String contractId = lci.getAttribute("ID").getString(); @@ -238,6 +336,10 @@ public class McontractServiceImpl implements McontractService{ if(fwf!=null){ rMage.setContractStatus("error"); rMage.setMale("该合同在付款申请中,不能合同变更!!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "该合同在付款申请中,不能合同变更"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; } //校验合同是否已经通过付款申请 @@ -246,6 +348,10 @@ public class McontractServiceImpl implements McontractService{ if(lfis.size()>0){ rMage.setContractStatus("error"); rMage.setMale("该合同已经通过付款申请,不能合同变更!!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "该合同已经通过付款申请,不能合同变更"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; } //校验参数数据是否变更 @@ -253,15 +359,25 @@ public class McontractServiceImpl implements McontractService{ if(lec==null){ rMage.setContractStatus("error"); rMage.setMale("没有查到租赁物信息,请联系管理员!!!"); + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "没有查到租赁物信息,请联系管理员"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; }else if(carNumber.equals(lec.getAttribute("FRAME_NUMBER").getString())&&carNo.equals(lec.getAttribute("ENGINE_NUMBER").getString())){ - rMage.setContractStatus("error"); - rMage.setMale("没有可变的数据,请检查数据!!!"); + 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")); + bil.setAttributeValue("fileName", fileBase.get("fileName")); + bil.setAttributeValue("isfile", "Y"); } + bil.setAttributeValue("contractStatus", "success"); + bil.setAttributeValue("male", "没有可变的数据"); + bilManage.saveObject(bil); + BqLogs.commit(); return rMage; } lec.setAttributeValue("FRAME_NUMBER", carNumber); @@ -283,7 +399,7 @@ public class McontractServiceImpl implements McontractService{ //将word转pdf,并返回生成的路径 String wordTopdf = modc.wordTopdf(projectId, contractId, tx); //合同盖章 -// String compnySignIng = modc.compnySignIng(contractId, tx); + String compnySignIng = modc.compnySignIng(contractId, tx); //将一维码添加到pdf中 String outPdfFile = CurConfig.getConfigure("BQcontract"); String newPath = modc.pdfAndMark(outPdfFile, "", contractId, tx); @@ -295,9 +411,19 @@ public class McontractServiceImpl implements McontractService{ rMage.setFileName(fileBase.get("fileName")); rMage.setOutputFile(fileBase.get("outputFile")); rMage.setMale("合同变更成功"); + bil.setAttributeValue("fileName", fileBase.get("fileName")); + bil.setAttributeValue("isfile", "Y"); + bil.setAttributeValue("male", "合同变更成功"); }else{ rMage.setMale("合同文件没有找到,请联系管理员!!!"); + bil.setAttributeValue("isfile", "N"); + bil.setAttributeValue("male", "合同变更成功,没有返回文件"); } + bil.setAttributeValue("contractStatus", "success"); + + bilManage.saveObject(bil); + BqLogs.commit(); + tx.commit(); return rMage; @@ -316,7 +442,13 @@ public class McontractServiceImpl implements McontractService{ } catch (Exception e) { - // TODO Auto-generated catch block + try { + bil.setAttributeValue("contractStatus", "error"); + bil.setAttributeValue("male", "合同变更系统异常"); + bilManage.saveObject(bil); + BqLogs.commit(); + } catch (JBOException e1) { + } e.printStackTrace(); } return rMage;