package com.changhong.epc.parsing.service.bill.impl;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.changhong.epc.bean.parsing.BillInfo;
|
import com.changhong.epc.bean.tenant.bill.BillData;
|
import com.changhong.epc.bean.tenant.bill.OCRBillEntity;
|
import com.changhong.epc.bean.tenant.bill.OCRBillHeaderEntity;
|
import com.changhong.epc.bean.tenant.bill.RuleMsg;
|
import com.changhong.epc.parsing.mapper.tenant.BillDataMapper;
|
import com.changhong.epc.parsing.mapper.tenant.RuleMapper;
|
import com.changhong.epc.parsing.service.bill.IAutoAllotJourney;
|
import com.iemsoft.framework.cloud.core.constant.BaseConst;
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 分配行程抽象类
|
*/
|
public abstract class AbstractJourney implements IAutoAllotJourney, BaseConst {
|
|
@Resource
|
protected BillDataMapper billDataMapper;
|
|
//票据规则检查结果相关~
|
@Resource
|
private RuleMapper ruleMapper;
|
|
/**
|
* 添加行程数据
|
* @param billInfo
|
* @param billEntity
|
*/
|
protected void insertBillData(BillInfo billInfo, OCRBillEntity billEntity){
|
// 删除之前的票据
|
BillData deleteBata = new BillData();
|
deleteBata.setOrderCode(billInfo.getOrderCode());
|
billDataMapper.delete(deleteBata);
|
/* 添加 票据头 */
|
for (OCRBillHeaderEntity billHeader : billEntity.getBillDatas()) {
|
|
// 云帐坊订单号
|
//将分配转换后的数据添加到info_last
|
BillData billData = new BillData();
|
billData.setOrderCode(billInfo.getOrderCode());
|
billData.setBillCode(billHeader.getBillCode());
|
billData.setBillInfo(JSONTool.toJson(billHeader, SerializerFeature.DisableCircularReferenceDetect));
|
billData.setJId(billHeader.getBhJouneryId());
|
billData.initParam();
|
billDataMapper.insert(billData);
|
}
|
}
|
|
/**
|
* 1. 检查是否可分配行程(根据规则检查信息)
|
* @param bill
|
*/
|
protected void billInfoCheck(OCRBillEntity bill) {
|
RuleMsg ruleMsgParam = new RuleMsg();
|
ruleMsgParam.setCouldNumber(bill.getOrderCode());
|
ruleMsgParam.setDataStart(VALID_DATA_FLGE.intValue());
|
List<RuleMsg> selectRuleMsg = ruleMapper.select(ruleMsgParam);
|
if(selectRuleMsg != null && !selectRuleMsg.isEmpty())
|
//循环规则检查结果
|
selectRuleMsg.stream().forEach(ruleMsg->{
|
//循环票据信息
|
bill.getBillDatas().stream().forEach(billData ->{
|
//对比~
|
if (Objects.equals(ruleMsg.getBillCode(), billData.getBillCode())) {
|
billData.getRuleMsg().add(ruleMsg);
|
}
|
});
|
});
|
}
|
}
|