apzl_leasing/src_tenwa/com/tenwa/makeContract/impl/McontractServiceImpl.java

557 lines
24 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tenwa.makeContract.impl;
import java.io.File;
import java.util.List;
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_EQUIPMENT_CAR_TEMP;
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;
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();
public ReturnMessage Mcontract(String projectNo,String carNumber, String carNo,String Mstatus){
JBOTransaction BqLogs = null;
ReturnMessage rMage = new ReturnMessage();
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;
}
public ReturnMessage makeContract(String projectNo,String carNumber, String carNo,String carColor){
McCalcConditionCopyService mcs = new McCalcConditionCopyService();
ReturnMessage rMage = new ReturnMessage();
MakeOneCodeAndContractModel modc = new MakeOneCodeAndContractModel();
String projectId=null;
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);
BizObjectManager lecManage = JBOFactory.getBizObjectManager(LB_EQUIPMENT_CAR.CLASS_NAME,tx);
BizObjectManager lectManage = JBOFactory.getBizObjectManager(LB_EQUIPMENT_CAR_TEMP.CLASS_NAME,tx);
BizObject lpi = lpiManage.createQuery("PROJECT_NO=:projectNo and project_status='13' ").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;
}
//校验项目是否在业务变更和业务撤销流程中
BizObjectManager fwfManage = JBOFactory.getBizObjectManager(FLOW_WORK_FLAG.CLASS_NAME,tx);
BizObject fwf = fwfManage.createQuery("select fc.flowname from O left join jbo.sys.FLOW_CATALOG fc on O.flow_name=fc.flowno where O.mutex_key=:projectId ").setParameter("projectId", lpi.getAttribute("ID").getString()).getSingleResult(false);
if(fwf!=null){
rMage.setContractStatus("error");
rMage.setMale("该申请编号在"+fwf.getAttribute("flowname")+"中,不能合同制作!!!");
bil.setAttributeValue("contractStatus", "error");
bil.setAttributeValue("male", "该申请编号在"+fwf.getAttribute("flowname")+"中,不能合同制作!!!");
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 lec = lecManage.createQuery("FRAME_NUMBER=:frame_number and project_id<>:projectid").setParameter("FRAME_NUMBER", carNumber).setParameter("projectid", lpi.getAttribute("ID").getString()).getSingleResult(false);
BizObject lect = lectManage.createQuery("SELECT * FROM O WHERE O.FRAME_NUMBER=:frame_number and O.flowunid IN (SELECT fo.objectno FROM jbo.sys.FLOW_OBJECT fo WHERE fo.flowno='BContractApproveFlow' AND fo.objectno NOT IN (SELECT ft.objectno FROM jbo.sys.FLOW_TASK ft WHERE ft.flowname='合同制作流程' AND ft.phasename='结束'))").setParameter("FRAME_NUMBER", carNumber).getSingleResult(false);
if(lec != null || lect != null ){
rMage.setContractStatus("error");
rMage.setMale("该车架号已在系统中,请重新填写!!!");
bil.setAttributeValue("contractStatus", "error");
bil.setAttributeValue("male", carNumber+"此车架号已在系统中");
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("该申请号已合同制作,无法重新制作!!!");
Map<String,String> 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;
}
//生成合同编号
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);
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,lpi.getAttribute("LEAS_FORM").toString(), tx);
// pdftx.commit();
String massage = outputFile(newPath);
if("error".equals(massage)){
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);
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) {
try {
tx.rollback();
JBOTransaction back =JBOFactory.createJBOTransaction();
BizObjectManager lcibom = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,back);
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();
}
e.printStackTrace();
System.out.println(e.toString());
rMage.setContractStatus("error");
rMage.setMale("合同制作失败,请重新发起合同制作!!!");
return rMage;
}
}
public ReturnMessage changeContract(String projectNo,String carNumber, String carNo){
MakeOneCodeAndContractModel modc = new MakeOneCodeAndContractModel();
ReturnMessage rMage = new ReturnMessage();
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 lectManage = JBOFactory.getBizObjectManager(LB_EQUIPMENT_CAR_TEMP.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();
BizObject lci = lciManage.createQuery("PROJECT_ID=:projectId").setParameter("projectId", lpi.getAttribute("ID").getString()).getSingleResult(false);
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);
BizObject lcs = lcsManage.createQuery(" STATUS_CODE=:statuscode ").setParameter("statuscode", lci.getAttribute("CONTRACT_STATUS").getString()).getSingleResult(false);
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();
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("该合同在付款申请中,不能合同变更!!!");
bil.setAttributeValue("contractStatus", "error");
bil.setAttributeValue("male", "该合同在付款申请中,不能合同变更");
bilManage.saveObject(bil);
BqLogs.commit();
return rMage;
}
//校验合同是否已经通过付款申请
BizObjectManager lfiManage = JBOFactory.getBizObjectManager(LC_FUND_INCOME.CLASS_NAME,tx);
List<BizObject> lfis = lfiManage.createQuery(" contract_id=:contractid ").setParameter("contractid", contractId).getResultList(false);
if(lfis.size()>0){
rMage.setContractStatus("error");
rMage.setMale("该合同已经通过付款申请,不能合同变更!!!");
bil.setAttributeValue("contractStatus", "error");
bil.setAttributeValue("male", "该合同已经通过付款申请,不能合同变更");
bilManage.saveObject(bil);
BqLogs.commit();
return rMage;
}
//校验车架号是否重复
BizObject lecj = lecManage.createQuery("FRAME_NUMBER=:frame_number and project_id<>:projectid").setParameter("FRAME_NUMBER", carNumber).setParameter("projectid", lpi.getAttribute("ID").getString()).getSingleResult(false);
BizObject lect = lectManage.createQuery("SELECT * FROM O WHERE O.FRAME_NUMBER=:frame_number and O.flowunid IN (SELECT fo.objectno FROM jbo.sys.FLOW_OBJECT fo WHERE fo.flowno='BContractApproveFlow' AND fo.objectno NOT IN (SELECT ft.objectno FROM jbo.sys.FLOW_TASK ft WHERE ft.flowname='合同制作流程' AND ft.phasename='结束'))").setParameter("FRAME_NUMBER", carNumber).getSingleResult(false);
if(lecj != null || lect != null ){
rMage.setContractStatus("error");
rMage.setMale("该车架号已在系统中,请重新填写!!!");
bil.setAttributeValue("contractStatus", "error");
bil.setAttributeValue("male", carNumber+"此车架号已在系统中");
bilManage.saveObject(bil);
BqLogs.commit();
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("没有查到租赁物信息,请联系管理员!!!");
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("success");
rMage.setMale("没有可变的数据!!!");
Map<String,String> 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);
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,lpi.getAttribute("LEAS_FORM").toString(), tx);
rMage.setContractStatus("success");
Map<String,String> fileBase = modc.fileBase(contractId);
if(fileBase.size()>0){
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;
/*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) {
try {
bil.setAttributeValue("contractStatus", "error");
bil.setAttributeValue("male", "合同变更系统异常");
bilManage.saveObject(bil);
BqLogs.commit();
} catch (JBOException e1) {
}
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";
}
}*/
}