From cd9816e28028befbbe6230e58bfb5ce47611df31 Mon Sep 17 00:00:00 2001 From: mzr Date: Thu, 30 Oct 2025 16:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E5=AF=86-=E7=89=A9=E6=96=99=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E4=BF=A1=E6=81=AF=E4=BF=9D=E5=AD=98=E5=89=8D=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialSaveBeforeCheckJMListener.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 uapbd/src/private/nc/impl/bd/material/plan/MaterialSaveBeforeCheckJMListener.java diff --git a/uapbd/src/private/nc/impl/bd/material/plan/MaterialSaveBeforeCheckJMListener.java b/uapbd/src/private/nc/impl/bd/material/plan/MaterialSaveBeforeCheckJMListener.java new file mode 100644 index 00000000..edf0e69f --- /dev/null +++ b/uapbd/src/private/nc/impl/bd/material/plan/MaterialSaveBeforeCheckJMListener.java @@ -0,0 +1,57 @@ +package nc.impl.bd.material.plan; + +import nc.bs.businessevent.IBusinessEvent; +import nc.bs.businessevent.IBusinessListener; +import nc.bs.businessevent.bd.BDCommonEvent; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +import nc.bs.uapbd.util.MyHelper; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.util.mmf.framework.base.MMValueCheck; +import nc.vo.bd.material.plan.MaterialPlanVO; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; + +import java.util.Map; + +/** + * 精密-物料计划信息保存前校验 + * + * @author mzr + * @date 2025/10/30 + */ +public class MaterialSaveBeforeCheckJMListener implements IBusinessListener { + private static final String LOG_INFO_NAME = "jmqylog"; + private static final Log logger = Log.getInstance(LOG_INFO_NAME); + private BaseDAO baseDAO = new BaseDAO(); + + public void doAction(IBusinessEvent event) throws BusinessException { + BDCommonEvent e = (BDCommonEvent) event; + String eventType = event.getEventType(); + Object[] objs = e.getObjs(); + // 1003 修改前校验 + if ("1003".equals(eventType)) { + String orgId = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = 'C038' and ISBUSINESSUNIT = 'Y'"); + for (Object obj : objs) { + if (obj instanceof MaterialPlanVO planVO) { + String pkOrg = planVO.getPk_org(); + // 组织判断,精密的才需校验 + if (MMValueCheck.isNotEmpty(orgId) && orgId.equals(pkOrg)) { + String def2 = planVO.getDef2();// 启源物料编码/原系统物料编码 + if (MMValueCheck.isNotEmpty(def2)) { + String countSql = "select count(1) from bd_materialplan where pk_org = '[pk_org]' and def2 = '[def2]'"; + countSql = countSql.replace("[pk_org]", pkOrg).replace("[def2]", def2); + Integer num = (Integer) baseDAO.executeQuery(countSql, new ColumnProcessor()); + if (num > 0) { + throw new BusinessException("原系统物料编码重复,请检查!"); + } + } + } + } + } + } + + } + + +}