负计划校验优化
This commit is contained in:
parent
646c0d842f
commit
fb999d54b5
|
|
@ -6,8 +6,14 @@
|
|||
package nc.bs.pu.m20.rewrite.pu.rule;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.vo.am.common.util.StringUtils;
|
||||
import nc.vo.ml.NCLangRes4VoTransl;
|
||||
import nc.vo.org.StockOrgVO;
|
||||
import nc.vo.pu.m20.entity.PraybillItemVO;
|
||||
import nc.vo.pu.m20.entity.PraybillViewVO;
|
||||
import nc.vo.pu.m20.entity.writeback.OrderWriteBackVO;
|
||||
|
|
@ -16,6 +22,7 @@ import nc.vo.pub.BusinessException;
|
|||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.pubapp.pattern.pub.MathTool;
|
||||
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||
|
||||
public class CheckOrderNumCalcRule implements IRule<PraybillViewVO> {
|
||||
|
||||
|
|
@ -25,6 +32,22 @@ public class CheckOrderNumCalcRule implements IRule<PraybillViewVO> {
|
|||
public void process(PraybillViewVO[] views) {
|
||||
for(PraybillViewVO vo : views) {
|
||||
PraybillItemVO itemVO=vo.getItem();
|
||||
Map<String, String> configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String pkOrg = vo.getHead().getPk_org();
|
||||
String orgCode = null;
|
||||
try {
|
||||
orgCode = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, pkOrg);
|
||||
|
||||
// 只有箱变公司才赋值生产BOM字段
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(null != itemVO.getAttributeValue("vbdef33") && null!=itemVO.getNaccumulatenum()&& itemVO.getNaccumulatenum().compareTo(new UFDouble(String.valueOf(itemVO.getAttributeValue("vbdef33"))))>0){
|
||||
try {
|
||||
throw new BusinessException("请购单累计订货数量大于最终需求数量不能生成采购订单!");
|
||||
|
|
@ -34,4 +57,35 @@ public class CheckOrderNumCalcRule implements IRule<PraybillViewVO> {
|
|||
}
|
||||
}
|
||||
}
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("xbOrg");
|
||||
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(",");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 根据主键查询编码
|
||||
*/
|
||||
private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException {
|
||||
if (nc.vo.cmp.util.StringUtils.isEmpty(pk)) {
|
||||
return null;
|
||||
}
|
||||
SqlBuilder sqlBuilder = new SqlBuilder();
|
||||
sqlBuilder.append(" select " + selectField);
|
||||
sqlBuilder.append(" from " + tableName);
|
||||
sqlBuilder.append(" where ");
|
||||
sqlBuilder.append(pkField, pk);
|
||||
Object o = new BaseDAO().executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
||||
if (o == null) {
|
||||
throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】");
|
||||
}
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ public class CheckOrderFinalNumRule implements IRule<OrderVO> {
|
|||
public void process(OrderVO[] orderVOS) {
|
||||
if (!ArrayUtil.isEmpty(orderVOS)) {
|
||||
for (OrderVO vo : orderVOS) {
|
||||
if(vo.getPrimaryKey()!=null){
|
||||
continue;
|
||||
}
|
||||
// if(vo.getPrimaryKey()!=null){
|
||||
// continue;
|
||||
// }
|
||||
for (OrderItemVO itemVO:vo.getBVO()){
|
||||
if(null != itemVO.getAttributeValue("vbdef33") && itemVO.getNastnum().compareTo(new UFDouble(String.valueOf(itemVO.getAttributeValue("vbdef33"))))>0){
|
||||
if(null != itemVO.getAttributeValue("vbdef33") && null!=itemVO.getNaccumarrvnum() && itemVO.getNaccumarrvnum().compareTo(new UFDouble(String.valueOf(itemVO.getAttributeValue("vbdef33"))))>0){
|
||||
try {
|
||||
throw new BusinessException("采购数量大于最终需求数量不能生成采购订单!");
|
||||
throw new BusinessException("累计到货主数量大于最终需求数量不能生成到货单!");
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,21 @@ package nc.bs.pu.m23.writeback.ic.rule;
|
|||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.vo.am.common.util.StringUtils;
|
||||
import nc.vo.ml.NCLangRes4VoTransl;
|
||||
import nc.vo.org.FactoryVO;
|
||||
import nc.vo.org.StockOrgVO;
|
||||
import nc.vo.pu.m23.entity.ArriveItemVO;
|
||||
import nc.vo.pu.m23.entity.ArriveViewVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.pubapp.pattern.data.ValueUtils;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -26,12 +31,24 @@ public class ChknaccumstorenumRule implements IRule<ArriveViewVO> {
|
|||
|
||||
public void process(ArriveViewVO[] vos) {
|
||||
if (vos != null && vos.length != 0) {
|
||||
Map<String, String> configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for(ArriveViewVO view : vos) {
|
||||
try {
|
||||
UFDouble naccumstorenum1= getNaccumstorenum(view.getBVO().getPk_arriveorder_b());
|
||||
} catch (DAOException e) {
|
||||
String pkOrg = view.getHVO().getPk_org();
|
||||
String orgCode = null;
|
||||
orgCode = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, pkOrg);
|
||||
// 只有箱变公司才赋值生产BOM字段
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
UFDouble naccumstorenum = view.getBVO().getNaccumstorenum();
|
||||
Object vbdef33 = view.getBVO().getVbdef33();
|
||||
if(null != vbdef33 && null!=naccumstorenum && naccumstorenum.compareTo(new UFDouble(String.valueOf(vbdef33)))>0) {
|
||||
|
|
@ -45,6 +62,37 @@ public class ChknaccumstorenumRule implements IRule<ArriveViewVO> {
|
|||
|
||||
}
|
||||
}
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("xbOrg");
|
||||
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(",");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 根据主键查询编码
|
||||
*/
|
||||
private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException {
|
||||
if (nc.vo.cmp.util.StringUtils.isEmpty(pk)) {
|
||||
return null;
|
||||
}
|
||||
SqlBuilder sqlBuilder = new SqlBuilder();
|
||||
sqlBuilder.append(" select " + selectField);
|
||||
sqlBuilder.append(" from " + tableName);
|
||||
sqlBuilder.append(" where ");
|
||||
sqlBuilder.append(pkField, pk);
|
||||
Object o = new BaseDAO().executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
||||
if (o == null) {
|
||||
throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】");
|
||||
}
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
private UFDouble getNaccumstorenum(String pkArriveorderB) throws DAOException {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ public class CheckFinalNumRule implements IRule<ArriveVO> {
|
|||
|
||||
public void process(ArriveVO[] arriveVOS) {
|
||||
for (ArriveVO vo : arriveVOS) {
|
||||
if (vo.getPrimaryKey() != null) {
|
||||
continue;
|
||||
}
|
||||
// if (vo.getPrimaryKey() != null) {
|
||||
// continue;
|
||||
// }
|
||||
if (vo == null || vo.getHVO() == null) {
|
||||
try {
|
||||
throw new BusinessException("到货单主信息不能为空");
|
||||
|
|
@ -29,9 +29,9 @@ public class CheckFinalNumRule implements IRule<ArriveVO> {
|
|||
}
|
||||
ArriveItemVO[] bodys=vo.getBVO();
|
||||
for(ArriveItemVO body : bodys) {
|
||||
if(null!=body.getAttributeValue("vbdef33") && body.getNastnum().compareTo(new UFDouble(String.valueOf(body.getAttributeValue("vbdef33"))))>0){
|
||||
if(null!=body.getAttributeValue("vbdef33") && null !=body.getNaccumstorenum() && body.getNaccumstorenum().compareTo(new UFDouble(String.valueOf(body.getAttributeValue("vbdef33"))))>0){
|
||||
try {
|
||||
throw new BusinessException("数量大于最终需求数量不能生成到货单!");
|
||||
throw new BusinessException("累计入库主数量大于最终需求数量不能生成入库单!");
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue