package com.changhong.epc.count.service.format.impl; import com.changhong.epc.bean.count.format.CpnInfo; import com.changhong.epc.bean.count.format.FormInfo; import com.changhong.epc.bean.count.format.ItemInfo; import com.changhong.epc.bean.tenant.bill.IOCRBill; import com.changhong.epc.constter.count.format.ConstFormatMsg; import com.iemsoft.framework.cloud.core.tools.MsgTool; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.List; import java.util.Objects; /** * 检查表单人员是否和票据一致 */ @Service("formatJourneyErrInfoCount") @Slf4j public class FormatJourneyErrInfoCount extends FormatRuleMsgInfoCount implements ConstFormatMsg { /** * 验证行程错误信息 * @param formInfo * @param itemInfo * @param iocrBills */ protected void forJourney(FormInfo formInfo, ItemInfo itemInfo, List iocrBills) { super.forJourney(formInfo, itemInfo, iocrBills); CpnInfo[] persion = formInfo.getData().stream() .filter(cpnInfo -> Objects.equals(cpnInfo.getFieldKey(), getPersionName())) .toArray(CpnInfo[]::new); if(ObjectUtil.empty(persion)) return; if(ObjectUtil.empty(iocrBills)){ // 无行程票据 itemInfo.addMsgInfo(CpnInfo.CpnMsgCode.header , new CpnInfo.CpnMsgInfo(MsgTool.get(NO_BILL_JOURNEY))); }else { // 票据人员不配置验证 for(IOCRBill iocrBill : iocrBills) { String persionCode = iocrBill.getBillKeyCode(PERSONAL_NAME); if(ObjectUtil.empty(persionCode)) continue; log.debug("票据人员code:{}, 控件人员code:{}", persionCode, persion[0].getValue()); if (!Objects.equals(persionCode, persion[0].getValue())){ itemInfo.addMsgInfo(CpnInfo.CpnMsgCode.header , new CpnInfo.CpnMsgInfo(MsgTool.get(PERSION_NO_EQUALS, iocrBill.getBillKeyName(PERSONAL_NAME)))); } } } } /** * 获得用户名称 * @return */ public String getPersionName(){ return "reimburseMan"; } }