From 627619119fefaa0a20ba918458fe555c53bb42ec Mon Sep 17 00:00:00 2001 From: mzr Date: Sat, 1 Nov 2025 17:08:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(ic):=20=E8=B4=B9=E7=94=A8=E9=A2=86?= =?UTF-8?q?=E6=96=99=E5=A2=9E=E5=8A=A0=E4=BB=93=E5=BA=93=E5=92=8C=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=9A=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../insert/rule/ManualMaterialPickupRule.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/ic/src/private/nc/bs/ic/m45/insert/rule/ManualMaterialPickupRule.java b/ic/src/private/nc/bs/ic/m45/insert/rule/ManualMaterialPickupRule.java index e7bd8179..8e637d55 100644 --- a/ic/src/private/nc/bs/ic/m45/insert/rule/ManualMaterialPickupRule.java +++ b/ic/src/private/nc/bs/ic/m45/insert/rule/ManualMaterialPickupRule.java @@ -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 { 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 { 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 { 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; + } + }