package com.changhong.epc.parsing.service.loop.impl;
|
|
import com.changhong.epc.bean.parsing.BillInfo;
|
import com.changhong.epc.bean.parsing.RuleMsgColumn;
|
import com.changhong.epc.bean.tenant.bill.RuleCheckMsg;
|
import com.changhong.epc.bean.tenant.bill.RuleMsg;
|
import com.changhong.epc.bean.tenant.bill.RuleMsgExtend;
|
import com.changhong.epc.bean.tenant.master.MasterValue;
|
import com.changhong.epc.constter.parsing.ConstRuleMsg;
|
import com.changhong.epc.constter.system.SystemClients;
|
import com.changhong.epc.parsing.mapper.tenant.BillInfoMapper;
|
import com.changhong.epc.parsing.mapper.tenant.RuleCheckMsgMapper;
|
import com.changhong.epc.parsing.mapper.tenant.RuleMapper;
|
import com.changhong.epc.parsing.mapper.tenant.RuleMsgMapper;
|
import com.changhong.epc.parsing.service.loop.IRuleMsgHandService;
|
import com.changhong.epc.rely.api.epc.admin.CorresElFieldApi;
|
import com.changhong.epc.rely.api.epc.tenant.MasterApi;
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.math.NumberUtils;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Objects;
|
import java.util.Optional;
|
|
/**
|
*
|
* @ClassName: RuleMsgHandServiceImpl
|
* @author [九鼎联合科技]
|
* @date 2017年6月19日 下午6:36:15
|
*/
|
@Component("ruleMsgHandService")
|
@Slf4j
|
public class RuleMsgHandServiceImpl extends LoopSuper implements SystemClients, IRuleMsgHandService, ConstRuleMsg {
|
|
@Resource
|
private RuleMsgMapper ruleMsgMapper;
|
|
@Resource
|
private RuleMapper ruleMapper;
|
|
@Resource
|
private BillInfoMapper billInfoMapper;
|
|
@Resource
|
private RuleCheckMsgMapper ruleCheckMsgMapper;
|
|
@Override
|
public String getThreadName() {
|
return "解析规则检查服务";
|
}
|
|
@Override
|
public void businessHandle() {
|
Manager();
|
}
|
|
/**
|
* 取出te_bill_check_msg表规则信息的json字符串数据 解析
|
* void 返回类型 @throws
|
*/
|
private void Manager() {
|
insertRuleMsg(ruleCheckMsgMapper.selectUntreatedRuleCheckMsg());
|
}
|
|
/**
|
* 传入json字符串集合解析存入rule_msg数据表 @Title: insertRuleMsg @param @param rcmList
|
* 设定文件 @return void 返回类型 @throws
|
*/
|
public void insertRuleMsg(List<RuleCheckMsg> rcmList) {
|
if(ObjectUtil.empty(rcmList)){
|
return;
|
}
|
for (RuleCheckMsg rcm : rcmList) {
|
log.debug("----------------开始解析规则检查结果--------------");
|
BillInfo billInfo = billInfoMapper.selectByOrderCode(rcm.getOrderCode());
|
if(billInfo == null ||billInfo.getInfo() == null || Objects.equals("",billInfo.getInfo())){
|
log.debug("当前订单号:-->"+rcm.getOrderCode());
|
log.debug("当前不可规则检查-->"+ JSONTool.toJson(billInfo));
|
continue;
|
}
|
RuleMsg t = new RuleMsg();
|
t.setCouldNumber(rcm.getOrderCode());
|
ruleMapper.delete(t);
|
/*将解析后的数据添加到rule_msg表中*/
|
RuleMsgExtend rList = JSONTool.toObj(rcm.getMsg(), RuleMsgExtend.class);
|
Optional.ofNullable(rList)
|
.map(RuleMsgExtend::getCheckResultList)
|
.orElse(new ArrayList<>())
|
.stream().forEach(rl ->{
|
RuleMsg ruleMsg = new RuleMsg();
|
ruleMsg.setResult(rl.getResult());
|
ruleMsg.setBillCode(rl.getBillCode());
|
ruleMsg.setCouldNumber(rList.getOrderCode());
|
ruleMsg.setRulecode(rl.getRulecode());
|
ruleMsg.setRulename(rl.getRulename());
|
ruleMsg.setLevel(getLevel(rl.getRulecode()));
|
ruleMsg.setType(RU_TYPE3);
|
ruleMsg.setStatus(RU_STATUS1);
|
ruleMsg.initParam();
|
ruleMapper.insert(ruleMsg);
|
|
});
|
/*将原始检查票据表状态更新*/
|
rcm.setDataStart(99);
|
ruleCheckMsgMapper.updateByPrimaryKey(rcm);
|
log.debug("修改订单标号为" + rList.getOrderCode() + "的状态为可分配行程状态");
|
//修改票据状态
|
billInfoMapper.updateBillState(rList.getOrderCode());
|
}
|
}
|
|
/**
|
* 获取错误级别level,code错误则默认level等级为10 @Title: getLevel @param @param
|
* code @param @return 设定文件 @return int 返回类型 @throws
|
*/
|
@SuppressWarnings("unchecked")
|
public int getLevel(String code) {
|
String mdCode = SpringUtil.getBean(CorresElFieldApi.class).getCorresElField(RULE_MSG_MDCODE).getMdCode();
|
|
MasterValue masterValue = SpringUtil.getBean(MasterApi.class).getMasterVal(mdCode, code);
|
if(!ObjectUtil.notEmpty(masterValue) && !ObjectUtil.notEmpty(masterValue.getEleValue())){
|
return NumberUtils.createInteger(masterValue.getEleValue());
|
}else{
|
return LEVEL_10;
|
}
|
}
|
|
@Override
|
public void insertRuleMsg(RuleMsgColumn ruleMsg) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void Manager(RuleCheckMsg ruleCheckMsg) {
|
// TODO Auto-generated method stub
|
|
}
|
|
|
}
|