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 ruleMsgList = ruleMapper.select(ruleMsgParam); if(ObjectUtil.empty(ruleMsgList)) return; // 提示 Set 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("
"); }); if(msg.length() > 0){ formInfo.getButton().add(new ButtonInfo(false, msg.toString(), SUBMIT_BUTTON)); } } }