package com.tenwa.platform.controller; import com.amarsoft.are.jbo.*; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import jbo.app.tenwa.customer.*; import jbo.com.tenwa.lease.carbrand.BUSINESS_STATUS; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP; import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE; import jbo.sys.*; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class CustomerInfoController { public String serial; public String currUserId; public String channel; public String sourcetype; public String operationType; public String applicationNo; public String customerType; // 自然人类型字典值 private String CUSTOMER_TYPE_PERSON = "03"; // 法人类型字典值 private String CUSTOMER_TYPE_COMPANY = "01"; // 合同起租状态字典值 private String BUSINESS_STATUS_31 = "31"; public String change(JBOTransaction tx) { Map result = new HashMap<>(); try { BizObjectManager pfProjectInfoManager = JBOFactory.getBizObjectManager(PF_PROJECT_INFO.CLASS_NAME, tx); BizObject pfProjectInfo = pfProjectInfoManager.createQuery(" APPLICATION_NO=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); String isNetCar = pfProjectInfo.getAttribute(PF_PROJECT_INFO.IS_NETCAR).getString(); BizObjectManager lbUnionLesseeManager = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME, tx); BizObject lbUnionLessee = lbUnionLesseeManager.createQuery(" CONTRACT_NUMBER=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); String customerId = lbUnionLessee.getAttribute(LB_UNION_LESSEE.CUSTOMER_ID).getString(); if (CUSTOMER_TYPE_PERSON.equals(customerType)) { // 自然人客户 BizObjectManager customerPersonManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME, tx); BizObject customerPerson = customerPersonManager.createQuery(" CUSTOMER_ID=:customerId").setParameter("customerId", customerId).getSingleResult(false); BizObjectManager customerAddressManager = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME, tx); BizObject customerAddress = customerAddressManager.createQuery(" CUSTOMER_ID=:customerId").setParameter("customerId", customerId).getSingleResult(false); BizObjectManager customerFamilyManager = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY.CLASS_NAME, tx); BizObject customerFamily = customerFamilyManager.createQuery(" CUSTOMER_ID=:customerId").setParameter("customerId", customerId).getSingleResult(false); BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME, tx); BizObject contractInfo = contractInfoManager.createQuery(" CONTRACT_NUMBER=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); BizObjectManager pfCustomerPersonManager = JBOFactory.getBizObjectManager(PF_CUSTOMER_PERSON.CLASS_NAME, tx); BizObject pfCustomerPerson = pfCustomerPersonManager.createQuery(" APPLICATION_NO=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); BizObjectManager pfCustomerAddressManager = JBOFactory.getBizObjectManager(PF_CUSTOMER_ADDRESS.CLASS_NAME, tx); BizObject pfCustomerAddress = pfCustomerAddressManager.createQuery(" APPLICATION_NO=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); BizObjectManager pfCustomerFamilyManager = JBOFactory.getBizObjectManager(PF_CUSTOMER_FAMILY.CLASS_NAME, tx); BizObject pfCustomerFamily = pfCustomerFamilyManager.createQuery(" APPLICATION_NO=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); BizObjectManager customerPersonTempManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON_TEMP.CLASS_NAME, tx); BizObject customerPersonTemp = customerPersonTempManager.newObject(); BizObjectManager customerAddressTempManager = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS_TEMP.CLASS_NAME, tx); BizObject customerAddressTemp = customerAddressTempManager.newObject(); BizObjectManager customerFamilyTempManager = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY_TEMP.CLASS_NAME, tx); BizObject customerFamilyTemp = customerFamilyTempManager.newObject(); BizObjectManager contractInfoTempManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO_TEMP.CLASS_NAME, tx); BizObject contractInfoTemp = contractInfoTempManager.newObject(); DataOperatorUtil.coptyJBOPropertyNoKey(pfCustomerPerson, customerPerson); DataOperatorUtil.coptyJBOPropertyNoKey(pfCustomerAddress, customerAddress); DataOperatorUtil.coptyJBOPropertyNoKey(pfCustomerFamily, customerFamily); DataOperatorUtil.coptyJBOPropertyNoKey(customerPerson, customerPersonTemp); DataOperatorUtil.coptyJBOPropertyNoKey(customerAddress, customerAddressTemp); DataOperatorUtil.coptyJBOPropertyNoKey(customerFamily, customerFamilyTemp); DataOperatorUtil.coptyJBOPropertyNoKey(contractInfo, contractInfoTemp); contractInfoTemp.setAttributeValue(LB_CONTRACT_INFO_TEMP.IS_NETCAR, isNetCar); customerPersonTempManager.saveObject(customerPersonTemp); customerAddressTempManager.saveObject(customerAddressTemp); customerFamilyTempManager.saveObject(customerFamilyTemp); contractInfoTempManager.saveObject(contractInfoTemp); } else { // 法人客户 BizObjectManager customerPersonManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME, tx); BizObject customerPerson = customerPersonManager.createQuery(" CUSTOMER_ID=:customerId").setParameter("customerId", customerId).getSingleResult(false); BizObjectManager customerFamilyManager = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY.CLASS_NAME, tx); BizObject customerFamily = customerFamilyManager.createQuery(" CUSTOMER_ID=:customerId").setParameter("customerId", customerId).getSingleResult(false); BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME, tx); BizObject contractInfo = contractInfoManager.createQuery(" CONTRACT_NUMBER=:customerId").setParameter("customerId", customerId).getSingleResult(false); BizObjectManager pfCustomerPersonManager = JBOFactory.getBizObjectManager(PF_CUSTOMER_PERSON.CLASS_NAME, tx); BizObject pfCustomerPerson = pfCustomerPersonManager.createQuery(" APPLICATION_NO=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); BizObjectManager pfCustomerFamilyManager = JBOFactory.getBizObjectManager(PF_CUSTOMER_FAMILY.CLASS_NAME, tx); BizObject pfCustomerFamily = pfCustomerFamilyManager.createQuery(" APPLICATION_NO=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); BizObjectManager customerPersonTempManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON_TEMP.CLASS_NAME, tx); BizObject customerPersonTemp = customerPersonTempManager.newObject(); BizObjectManager customerFamilyTempManager = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY_TEMP.CLASS_NAME, tx); BizObject customerFamilyTemp = customerFamilyTempManager.newObject(); BizObjectManager contractInfoTempManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO_TEMP.CLASS_NAME, tx); BizObject contractInfoTemp = contractInfoTempManager.newObject(); DataOperatorUtil.coptyJBOPropertyNoKey(pfCustomerPerson, customerPerson); DataOperatorUtil.coptyJBOPropertyNoKey(pfCustomerFamily, customerFamily); DataOperatorUtil.coptyJBOPropertyNoKey(customerPerson, customerPersonTemp); DataOperatorUtil.coptyJBOPropertyNoKey(customerFamily, customerFamilyTemp); DataOperatorUtil.coptyJBOPropertyNoKey(contractInfo, contractInfoTemp); contractInfoTemp.setAttributeValue(LB_CONTRACT_INFO_TEMP.IS_NETCAR, isNetCar); customerPersonTempManager.saveObject(customerPersonTemp); customerFamilyTempManager.saveObject(customerFamilyTemp); contractInfoTempManager.saveObject(contractInfoTemp); } // 发起起租后客户信息变更流程 result.put("success", true); result.put("msg", "发起起租后客户信息变更流程成功"); } catch (JBOException e) { result.put("success", false); result.put("msg", "发起起租后客户信息变更出现异常"); e.printStackTrace(); } finally { try { return new ObjectMapper().writeValueAsString(result); } catch (IOException e) { e.printStackTrace(); return "{'success': false, 'msg': '发起起租后客户信息变更出现异常'}"; } } } public String getSerial() { return serial; } public void setSerial(String serial) { this.serial = serial; } public String getCurrUserId() { return currUserId; } public void setCurrUserId(String currUserId) { this.currUserId = currUserId; } public String getChannel() { return channel; } public void setChannel(String channel) { this.channel = channel; } public String getSourcetype() { return sourcetype; } public void setSourcetype(String sourcetype) { this.sourcetype = sourcetype; } public String getOperationType() { return operationType; } public void setOperationType(String operationType) { this.operationType = operationType; } public String getApplicationNo() { return applicationNo; } public void setApplicationNo(String applicationNo) { this.applicationNo = applicationNo; } public String getCustomerType() { return customerType; } public void setCustomerType(String customerType) { this.customerType = customerType; } }