箱变到货单制单日期校验天数改成按照系统配置
This commit is contained in:
parent
13a9f6c5e3
commit
64838baeb1
|
|
@ -7,6 +7,7 @@ package nc.impl.pu.m23.maintain.rule;
|
|||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.pubitf.so.m30.api.ISaleOrderQueryAPI;
|
||||
import nc.vo.pu.m21.entity.OrderItemVO;
|
||||
|
|
@ -15,12 +16,14 @@ import nc.vo.pu.m23.entity.ArriveItemVO;
|
|||
import nc.vo.pu.m23.entity.ArriveVO;
|
||||
import nc.vo.pu.pub.util.BillQuery;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.so.m30.entity.SaleOrderBVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||
public CheckBillDateRule() {
|
||||
|
|
@ -37,6 +40,17 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
|||
if (vo == null || vo.getHVO() == null) {
|
||||
throw new BusinessException("到货单主信息不能为空");
|
||||
}
|
||||
Map<String, String> configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if(null==configParams.get("days")){
|
||||
throw new BusinessException("到货单制单日期校验信息未配置");
|
||||
}
|
||||
UFDouble days=configParams.get("days")==null?null:new UFDouble(configParams.get("days"));
|
||||
if (days == null || days.doubleValue() <= 0) {
|
||||
throw new BusinessException("到货单制单日期校验天数配置无效");
|
||||
}
|
||||
// 只校验箱变
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
String org = hybo.findColValue("org_adminorg", "pk_adminorg", " code = 'C030' ") + "";
|
||||
|
|
@ -92,9 +106,9 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
|||
throw new BusinessException("采购订单明细" + pkOrderB + "的计划到货时间不能为空");
|
||||
}
|
||||
|
||||
// 核心逻辑:只允许提前3天到货
|
||||
// 1. 计算预计到货时间前3天的日期(最早允许的制单日期)
|
||||
Date earliestAllowedDate = addDays(expectArriveDate, -3);
|
||||
// 核心逻辑:根据配置的天数校验提前到货
|
||||
// 1. 计算预计到货时间前N天的日期(最早允许的制单日期)
|
||||
Date earliestAllowedDate = addDays(expectArriveDate, -days.intValue());
|
||||
|
||||
// 2. 判断规则
|
||||
boolean isTooEarly =clearTime(arriveMakeDate).before(clearTime(earliestAllowedDate));
|
||||
|
|
@ -104,9 +118,10 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
|||
String errorMsg;
|
||||
if (isTooEarly) {
|
||||
errorMsg = String.format(
|
||||
"到货单制单日期(%s)早于采购订单预计到货时间(%s)超过3天,不允许保存。最早允许制单日期为%s。订单编号:%s,明细行号:%s",
|
||||
"到货单制单日期(%s)早于采购订单预计到货时间(%s)超过%s天,不允许保存。最早允许制单日期为%s。订单编号:%s,明细行号:%s",
|
||||
formatDate(arriveMakeDate),
|
||||
formatDate(expectArriveDate),
|
||||
days,
|
||||
formatDate(earliestAllowedDate),
|
||||
o.getHVO().getVbillcode(),
|
||||
orderItem.getCrowno()
|
||||
|
|
|
|||
Loading…
Reference in New Issue