到货单制单日期校验
This commit is contained in:
parent
509fab347d
commit
6dbe4d310f
|
|
@ -6,6 +6,7 @@
|
||||||
package nc.impl.pu.m23.maintain.rule;
|
package nc.impl.pu.m23.maintain.rule;
|
||||||
|
|
||||||
import nc.bs.framework.common.NCLocator;
|
import nc.bs.framework.common.NCLocator;
|
||||||
|
import nc.bs.trade.business.HYPubBO;
|
||||||
import nc.impl.pubapp.pattern.rule.IRule;
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
import nc.pubitf.so.m30.api.ISaleOrderQueryAPI;
|
import nc.pubitf.so.m30.api.ISaleOrderQueryAPI;
|
||||||
import nc.vo.pu.m21.entity.OrderItemVO;
|
import nc.vo.pu.m21.entity.OrderItemVO;
|
||||||
|
|
@ -18,6 +19,7 @@ import nc.vo.so.m30.entity.SaleOrderBVO;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class CheckBillDateRule implements IRule<ArriveVO> {
|
public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||||
|
|
@ -35,8 +37,13 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||||
if (vo == null || vo.getHVO() == null) {
|
if (vo == null || vo.getHVO() == null) {
|
||||||
throw new BusinessException("到货单主信息不能为空");
|
throw new BusinessException("到货单主信息不能为空");
|
||||||
}
|
}
|
||||||
|
// 只校验箱变
|
||||||
Date arriveMakeDate = null != vo.getHVO().getDmakedate() ? vo.getHVO().getDmakedate().toDate(): new Date() ;
|
HYPubBO hybo = new HYPubBO();
|
||||||
|
String org = hybo.findColValue("org_adminorg", "pk_adminorg", " code = 'C030' ") + "";
|
||||||
|
if(!vo.getHVO().getPk_org().equals(org)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Date arriveMakeDate = null != vo.getHVO().getDbilldate() ? vo.getHVO().getDbilldate().toDate(): new Date() ;
|
||||||
// 校验制单日期是否存在
|
// 校验制单日期是否存在
|
||||||
if (arriveMakeDate == null) {
|
if (arriveMakeDate == null) {
|
||||||
throw new BusinessException("到货单制单日期不能为空");
|
throw new BusinessException("到货单制单日期不能为空");
|
||||||
|
|
@ -90,10 +97,10 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||||
Date earliestAllowedDate = addDays(expectArriveDate, -3);
|
Date earliestAllowedDate = addDays(expectArriveDate, -3);
|
||||||
|
|
||||||
// 2. 判断规则
|
// 2. 判断规则
|
||||||
boolean isTooEarly = arriveMakeDate.before(earliestAllowedDate);
|
boolean isTooEarly =clearTime(arriveMakeDate).before(clearTime(earliestAllowedDate));
|
||||||
boolean isTooLate = arriveMakeDate.after(expectArriveDate);
|
// boolean isTooLate = arriveMakeDate.after(expectArriveDate);
|
||||||
|
|
||||||
if (isTooEarly || isTooLate) {
|
// if (isTooEarly || isTooLate) {
|
||||||
String errorMsg;
|
String errorMsg;
|
||||||
if (isTooEarly) {
|
if (isTooEarly) {
|
||||||
errorMsg = String.format(
|
errorMsg = String.format(
|
||||||
|
|
@ -104,15 +111,15 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||||
o.getHVO().getVbillcode(),
|
o.getHVO().getVbillcode(),
|
||||||
orderItem.getCrowno()
|
orderItem.getCrowno()
|
||||||
);
|
);
|
||||||
} else { // isTooLate
|
// } else { // isTooLate
|
||||||
errorMsg = String.format(
|
// errorMsg = String.format(
|
||||||
"到货单制单日期(%s)晚于采购订单预计到货时间(%s),不符合提前到货规则,不允许保存。订单编号:%s,明细行号:%s",
|
// "到货单制单日期(%s)晚于采购订单预计到货时间(%s),不符合提前到货规则,不允许保存。订单编号:%s,明细行号:%s",
|
||||||
formatDate(arriveMakeDate),
|
// formatDate(arriveMakeDate),
|
||||||
formatDate(expectArriveDate),
|
// formatDate(expectArriveDate),
|
||||||
o.getHVO().getVbillcode(),
|
// o.getHVO().getVbillcode(),
|
||||||
orderItem.getCrowno()
|
// orderItem.getCrowno()
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
throw new BusinessException(errorMsg);
|
throw new BusinessException(errorMsg);
|
||||||
}
|
}
|
||||||
break; // 找到匹配明细后退出循环
|
break; // 找到匹配明细后退出循环
|
||||||
|
|
@ -160,6 +167,22 @@ public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||||
return DATE_FORMATTER.format(date);
|
return DATE_FORMATTER.format(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 清除日期中的时间部分,只保留年月日
|
||||||
|
*/
|
||||||
|
private static Date clearTime(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
// 将时间部分设置为0
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue