修改产品贴息占用逻辑

This commit is contained in:
zhulianghua 2018-07-24 14:50:43 +08:00
parent f76684d673
commit 3e773f8228
4 changed files with 128 additions and 17 deletions

View File

@ -3980,6 +3980,24 @@
</managerProperties>
</manager>
</class>
<class name="LB_DISCOUNT_OCCUPY" label="" keyAttributes="id">
<attributes>
<attribute name="id" label="id" type="STRING" length="32"/>
<attribute name="product_id" label="product_id" type="STRING" length="32"/>
<attribute name="flowunid" label="flowunid" type="STRING" length="32"/>
<attribute name="project_id" label="project_id" type="STRING" length="32"/>
<attribute name="discount" label="discount" type="DOUBLE" length="22" scale="2"/>
<attribute name="inputuserid" label="inputuserid" type="STRING" length="32"/>
<attribute name="inputorgid" label="inputorgid" type="STRING" length="32"/>
<attribute name="inputtime" label="inputtime" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lb_discount_occupy" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
</package>
<package name="jbo.com.tenwa.lease.carbrand" >
<class name="LB_CLAIMS_BOOK_DETAIL" label="索赔申请书详情表" keyAttributes="ID">

View File

@ -489,6 +489,86 @@ public class ProductParamUtil {
}
return parameterValue;
}
/**
* 传入产品编号组件类型编号和组件ID,返回单个组件所有参数
* @param productId 产品编号
* @param componentType 组件类型编号
* @param id 对应组件的ID
* @return 参数对应的值
* @throws Exception
* @author zhulh
*/
public static Map<String,String> getProductComponentAllParameters(String productId,String componentType,String id) throws Exception{
Map<String,String> parameValue = new HashMap<String,String>();
String realXmlPath = getProductValueXmlBySql(productId);
//List<BusinessObject> componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID");
/*List<BusinessObject> exists = new ArrayList<BusinessObject>();
BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME);
BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true);
String pData = boLPI.getAttribute("PRODUCT_DATA").getString();
String type = componentType;
if("".equals(pData)){
}else{
JSONArray jsonArray = JSONArray.fromObject(pData);
Iterator<JSONObject> it = jsonArray.iterator();
while(it.hasNext()){
JSONObject jo = (JSONObject)it.next().get("jbo.sample.Component");
if(type.equals(jo.get("TYPE"))){
JSONArray ja = JSONArray.fromObject(jo.get("Parameter"));
BusinessObject b = BusinessObject.createBusinessObject("Component");
b.setAttributes(jo);
BusinessObject[] bos = new BusinessObject[ja.size()];
for(int i=0;i<bos.length;i++){
BusinessObject bValue = BusinessObject.createBusinessObject("Parameter");
bValue.setAttributes(ja.getJSONObject(i).getJSONObject("jbo.sample.Parameter"));
bos[i] = bValue;
}
b.setAttributeValue("Parameter", bos);
exists.add(b);
break;
}
}
}*/
//List<BusinessObject> exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType);
List<BusinessObject> exists = getBusinessObject(realXmlPath, componentType);
for(BusinessObject bo:exists){
List<BusinessObject> parameters = bo.getBusinessObjects("Parameter");
if(!id.equals(bo.getString("ID"))){
continue;
}
for(BusinessObject boP:parameters){
String parameterValue = "";
String parameterValueMax = "";
String parameterValueMin = "";
if(boP.containsAttribute("OPTIONALVALUE")){
parameterValue = boP.getString("OPTIONALVALUE");
}else if(boP.containsAttribute("MANDATORYVALUE")){
parameterValue = boP.getString("MANDATORYVALUE");
}else if(boP.containsAttribute("VALUE")){
parameterValue = boP.getString("VALUE");
}
if(boP.containsAttribute("MAXIMUMVALUE")){
parameterValueMax = boP.getString("MAXIMUMVALUE");
}
if(boP.containsAttribute("MINIMUMVALUE")){
parameterValueMin = boP.getString("MINIMUMVALUE");
}
parameValue.put(boP.getString("PARAMETERID"), parameterValue);
if(!"".equals(parameterValueMax)){
parameValue.put(boP.getString("PARAMETERID")+"-MAX", parameterValueMax);
}
if(!"".equals(parameterValueMin)){
parameValue.put(boP.getString("PARAMETERID")+"-MIN", parameterValueMin);
}
}
if(!parameValue.isEmpty()) {
break;
}
}
return parameValue;
}
/**
* 获取五级分类结果
* @param productId

View File

@ -16,7 +16,14 @@ import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
public class BaseFlowStartAction extends FlowBussionAction {
private String error_message = "failed@发起流程出错";
public String getError_message() {
return error_message;
}
public void setError_message(String error_message) {
this.error_message = error_message;
}
@Override
public String initFLow(JBOTransaction tx) throws Exception {
try {
@ -44,7 +51,7 @@ public class BaseFlowStartAction extends FlowBussionAction {
// TODO Auto-generated catch block
e.printStackTrace();
tx.rollback();
return "failed@发起流程出错";
return error_message;
}
}
/**

View File

@ -1,27 +1,16 @@
package com.tenwa.lease.flow.project.projectapproval;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import jbo.app.tenwa.customer.CUSTOMER_CERT;
import jbo.app.tenwa.customer.CUSTOMER_COMPANY;
import jbo.app.tenwa.customer.CUSTOMER_INFO;
import jbo.app.tenwa.customer.CUSTOMER_PERSON;
import jbo.app.tenwa.customer.CUSTOMER_TEL;
import jbo.com.tenwa.lease.comm.LB_GUARANTEE_UNIT;
import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO;
import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE;
import com.amarsoft.app.util.ProductParamUtil;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.are.util.StringFunction;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.amarsoft.context.ASUser;
import com.tenwa.comm.exception.BusinessException;
import com.tenwa.flow.action.comm.BaseFlowStartAction;
import com.tenwa.util.SerialNumberUtil;
@ -58,6 +47,24 @@ public class BusinessApprovalStartAction extends BaseFlowStartAction{
String projectNO = "";
//根据业务类型生成不同的项目编号
if(businessType.equals("1")){//1是汽车业务
//补充业务逻辑如果贴息余额不够的情况就不给通过
Map<String, String> discount = ProductParamUtil.getProductComponentAllParameters(this.getProductId(), "PRD0315", "DISCOUNT");
if(!discount.isEmpty() && null != discount.get("DISCOUNT_ALL") && null != discount.get("CostType08")) {
synchronized (this) {
String discountAll = discount.get("DISCOUNT_ALL");
String discountValue = discount.get("CostType08");
Transaction tran = Transaction.createTransaction(tx);
String result = tran.getString(new SqlObject("select case when " + discountAll + "-ifnull(sum(discount), 0) >= " + discountValue + " then '0' else '1' end from lb_discount_occupy where product_id = '" + this.getProductId() + "'"));
if("0".equals(result)) {
ASUser user = ASUser.getUser(this.CurUserID, tran);
tran.executeSQL(new SqlObject("insert into lb_discount_occupy(id, product_id, flowunid, project_id, discount, inputuserid, inputorgid, inputtime) "
+ " values (replace(uuid(),'-',''), '" + this.getProductId() + "', '" + flowBussiness.getAttribute("flow_unid").toString() + "', '" + uuid.replaceAll("-", "") + "',"
+ " " + discountValue + ", '" + this.CurUserID + "', '" + user.getOrgID() + "', replace(now(),'-','/'))"));
} else {
throw new BusinessException("failed@产品贴息额已用完");
}
}
}
projectNO=SerialNumberUtil.getProjectSerialNumber1(this.getAsUser().getOrgID(), tx);//生成A开头编号
}else if(businessType.equals("2")){//2是传统业务
projectNO=SerialNumberUtil.getProjectSerialNumber2(this.getAsUser().getOrgID(), tx);//生成T开头编号
@ -250,5 +257,4 @@ public class BusinessApprovalStartAction extends BaseFlowStartAction{
public void setCerttype(String certtype) {
this.certtype = certtype;
}
}