zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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);
                    }
                });
            });
    }
}