feat(ic): 费用领料增加仓库和物料的校验
This commit is contained in:
parent
eb2df75640
commit
627619119f
|
|
@ -3,6 +3,7 @@ package nc.bs.ic.m45.insert.rule;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.InvocationInfoProxy;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
|
|
@ -11,9 +12,11 @@ import nc.bs.uapbd.util.MyHelper;
|
|||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
|
||||
import nc.itf.uap.IUAPQueryBS;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.bd.stordoc.StordocVO;
|
||||
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
|
||||
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
|
||||
import nc.vo.ic.m45.entity.PurchaseInVO;
|
||||
|
|
@ -86,6 +89,7 @@ public class ManualMaterialPickupRule implements IRule<PurchaseInVO> {
|
|||
PurchaseInBodyVO[] bodys = inVO.getBodys();
|
||||
String pkOrg = head.getPk_org();
|
||||
String vbillcode = head.getVbillcode();
|
||||
String cwarehouseid = head.getCwarehouseid();
|
||||
UFDate dbilldate = head.getDbilldate();
|
||||
// 判断是否是精密铸造(C038)
|
||||
if (!"null".equals(orgId) && orgId.equals(pkOrg)) {
|
||||
|
|
@ -97,10 +101,24 @@ public class ManualMaterialPickupRule implements IRule<PurchaseInVO> {
|
|||
if (MMValueCheck.isEmpty(warehouseCode) || "~".equals(warehouseCode)) {
|
||||
ExceptionUtils.wrappBusinessException("请检查仓库编码是否配置正确");
|
||||
}
|
||||
// 判断仓库是否正确
|
||||
String warehouseId = getWarehouseInfo(pkOrg, warehouseCode);
|
||||
if (MMValueCheck.isNotEmpty(warehouseId)
|
||||
&& !"~".equals(warehouseId)
|
||||
&& !warehouseId.equals(cwarehouseid)) {
|
||||
continue;
|
||||
}
|
||||
// 费用领料的物料编码
|
||||
String configMaterialCode = configParams.get("noItemCode");
|
||||
if (configMaterialCode == null || configMaterialCode.isEmpty()) {
|
||||
ExceptionUtils.wrappBusinessException("自定义档案中的物料参数未配置");
|
||||
}
|
||||
// 判断采购入库是否存在费用物料,如果不存在则跳过领料逻辑
|
||||
boolean hasExpenseMaterial = checkIfHasExpenseMaterial(bodys, configMaterialCode);
|
||||
if (!hasExpenseMaterial) {
|
||||
// 如果不存在费用物料,则跳过后续领料逻辑
|
||||
continue;
|
||||
}
|
||||
String trantypecode = configParams.get("in-trantypecode");
|
||||
if (trantypecode == null || trantypecode.isEmpty()) {
|
||||
ExceptionUtils.wrappBusinessException("自定义档案中的单据类型参数未配置");
|
||||
|
|
@ -245,4 +263,42 @@ public class ManualMaterialPickupRule implements IRule<PurchaseInVO> {
|
|||
return resMap;
|
||||
}
|
||||
|
||||
private String getWarehouseInfo(String pk_org, String warehouseCode) throws DAOException {
|
||||
SqlBuilder sqlBuilder = new SqlBuilder();
|
||||
sqlBuilder.append(" select " + StordocVO.PK_STORDOC);
|
||||
sqlBuilder.append(" from " + StordocVO.getDefaultTableName());
|
||||
sqlBuilder.append(" where dr = 0");
|
||||
sqlBuilder.append(" and ");
|
||||
sqlBuilder.append(StordocVO.CODE, warehouseCode);
|
||||
sqlBuilder.append(" and ");
|
||||
sqlBuilder.append(StordocVO.PK_ORG, pk_org);
|
||||
String warehouseId = (String) getDao().executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
||||
return warehouseId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查采购入库单中是否存在费用物料
|
||||
*
|
||||
* @param bodys 采购入库单表体
|
||||
* @param configMaterialCode 费用物料编码配置
|
||||
* @return 是否存在费用物料
|
||||
* @throws BusinessException 业务异常
|
||||
*/
|
||||
private boolean checkIfHasExpenseMaterial(PurchaseInBodyVO[] bodys, String configMaterialCode) throws BusinessException {
|
||||
if (ArrayUtils.isEmpty(bodys)) {
|
||||
return false;
|
||||
}
|
||||
HYPubBO hyPub = new HYPubBO();
|
||||
for (PurchaseInBodyVO body : bodys) {
|
||||
String cmaterialvid = body.getCmaterialvid();
|
||||
String condition = "pk_material = '" + cmaterialvid + "'";
|
||||
String materialCode = hyPub.findColValue(MaterialVO.getDefaultTableName(), MaterialVO.CODE, condition) + "";
|
||||
if (configMaterialCode.equals(materialCode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue