package com.changhong.epc.count.controller;
|
|
import com.changhong.epc.bean.count.format.FormInfo;
|
import com.changhong.epc.bean.count.format.SystemFunFormInfo;
|
import com.changhong.epc.constter.base.BaseConst;
|
import com.changhong.epc.constter.count.nomr.CountUrlConst;
|
import com.changhong.epc.count.service.count.IExpendCostCount;
|
import com.changhong.epc.count.service.count.model.CountParamMax;
|
import com.changhong.epc.count.service.count.model.CountResultLast;
|
import com.changhong.epc.count.service.format.FormatFormInfo;
|
import com.changhong.epc.count.service.system.IExpendSystemCount;
|
import com.iemsoft.framework.cloud.core.thread.ThreadData;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import java.util.Objects;
|
|
/**
|
* 计算费用
|
* @author wangZhenXin
|
*
|
*/
|
@RestController
|
@Slf4j
|
public class CountController implements CountUrlConst{
|
|
@Resource
|
private IExpendCostCount expendCostCount;
|
|
@Resource(name="formatXECount")
|
private FormatFormInfo<CountParamMax, CountResultLast> formatFormInfoCount;
|
|
@Resource
|
private IExpendSystemCount iExpendSystemCount;
|
|
/**
|
* 系统变量
|
* @param systemFunFormInfo
|
* @return
|
*/
|
@RequestMapping(value=COUNT_SYSTEM_URL, method={RequestMethod.OPTIONS, RequestMethod.POST})
|
public FormInfo systemCount(@RequestBody SystemFunFormInfo systemFunFormInfo){
|
ThreadData.set(BaseConst.FORMID,systemFunFormInfo.getFormInfo().getFormId());
|
ThreadData.set(BaseConst.ORDER_CODE,systemFunFormInfo.getFormInfo().getOrderCode());
|
ThreadData.set(BaseConst.DATA_ROW_NUM,systemFunFormInfo.getFormInfo().getId());
|
return iExpendSystemCount.systemCount(systemFunFormInfo);
|
}
|
|
/**
|
* 计算费用
|
* @param formInfo
|
* @return
|
*/
|
@RequestMapping(value=COUNT_COST_URL, method={RequestMethod.OPTIONS, RequestMethod.POST})
|
public FormInfo costCount(@RequestBody FormInfo formInfo){
|
try {
|
ThreadData.set(BaseConst.FORMID, formInfo.getFormId());
|
ThreadData.set(BaseConst.ORDER_CODE, formInfo.getOrderCode());
|
ThreadData.set(BaseConst.DATA_ROW_NUM, Objects.toString(formInfo.getId()));
|
//格式化参数
|
CountParamMax p = formatFormInfoCount.formatParam(formInfo);
|
//计算费用
|
CountResultLast sun = expendCostCount.costCount(p);
|
//格式化返回结果
|
formatFormInfoCount.formatResult(formInfo, sun);
|
|
return formInfo;
|
}catch (Exception e){
|
log.error(e.getMessage(), e);
|
return formInfo;
|
}
|
}
|
|
/**
|
* 计算费用和系统变量
|
* @param systemFunFormInfo
|
* @return
|
*/
|
@RequestMapping(value=COUNT_AND_SYSTEM_COST_URL, method={RequestMethod.OPTIONS, RequestMethod.POST})
|
public FormInfo countAndSystem(@RequestBody SystemFunFormInfo systemFunFormInfo){
|
ThreadData.set(BaseConst.FORMID,systemFunFormInfo.getFormInfo().getFormId());
|
ThreadData.set(BaseConst.ORDER_CODE,systemFunFormInfo.getFormInfo().getOrderCode());
|
ThreadData.set(BaseConst.DATA_ROW_NUM,systemFunFormInfo.getFormInfo().getId());
|
// 计算系统变量
|
iExpendSystemCount.systemCount(systemFunFormInfo);
|
// 计算费用
|
formatFormInfoCount.formatResult(systemFunFormInfo.getFormInfo(), expendCostCount.costCount(formatFormInfoCount.formatParam(systemFunFormInfo.getFormInfo())));
|
// 计算系统变量
|
iExpendSystemCount.systemCount(systemFunFormInfo);
|
return systemFunFormInfo.getFormInfo();
|
}
|
|
}
|