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
package com.changhong.epc.count.service.format.impl;
 
import com.changhong.epc.bean.count.format.ButtonInfo;
import com.changhong.epc.bean.count.format.FormInfo;
import com.changhong.epc.bean.count.format.FormMsgInfo;
import com.changhong.epc.bean.tenant.bill.RuleMsg;
import com.changhong.epc.constter.parsing.ConstRuleMsg;
import com.changhong.epc.count.mapper.tenant.ruleMsg.RuleMapper;
import com.changhong.epc.count.service.count.model.CountResultLast;
import com.iemsoft.framework.cloud.core.tools.MsgTool;
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
/**
 * 计算费用返回规则检查信息
 */
@Service("formatRuleMsgInfoCount")
public class FormatRuleMsgInfoCount extends FormatBillInfoCount implements ConstRuleMsg {
 
    @Resource
    private RuleMapper ruleMapper;
 
    @Override
    public void formatResult(FormInfo formInfo, CountResultLast countResultLast) {
        super.formatResult(formInfo, countResultLast);
 
        if(ObjectUtil.empty(formInfo.getOrderCode()))
            return;
 
        RuleMsg ruleMsgParam = new RuleMsg();
        ruleMsgParam.setCouldNumber(formInfo.getOrderCode());
        ruleMsgParam.setDataStart(0);
        List<RuleMsg> ruleMsgList = ruleMapper.select(ruleMsgParam);
 
        if(ObjectUtil.empty(ruleMsgList))
            return;
        // 提示
        Set<FormMsgInfo.GroupData> msgData = new HashSet<>();
        ruleMsgList.stream()
                .filter(ruleMsg -> ruleMsg.getResult() == ERROR && ruleMsg.getLevel() == LEVEL_10)
                .forEach(ruleMsg -> {
                    msgData.add(new FormMsgInfo.GroupData(ruleMsg.getRulename()));
        });
        if(ObjectUtil.notEmpty(msgData)){
            setFormMsgInfo(formInfo, MsgTool.get(BILL_RULE_MSG), msgData);
        }
 
        // 不可提交
        StringBuilder msg = new StringBuilder();
        ruleMsgList.stream()
                .filter(ruleMsg -> ruleMsg.getResult() == ERROR && ruleMsg.getLevel() == LEVEL_30)
                .forEach(ruleMsg -> {
            msg.append(ruleMsg.getRulename()).append("</br>");
        });
        if(msg.length() > 0){
            formInfo.getButton().add(new ButtonInfo(false, msg.toString(), SUBMIT_BUTTON));
        }
 
    }
}