mmpac流程生产订单: 增加生产订单同步到MES系统的判断逻辑
- 新增 shouldSyncToMes 方法判断是否需要同步到MES系统 - 根据源头单据类型判断是否为销售订单 - 如果是销售订单,联查销售订单子实体 - 判断销售订单是否有定制标识 - 如果有定制标识,检查工艺配置完成时间是否有值 - 如果无定制标识,允许同步到MES - 如果有定制标识且工艺配置完成时间有值,允许同步到MES- 如果有定制标识且工艺配置完成时间为空,不允许同步到MES
This commit is contained in:
		
							parent
							
								
									e336bcb528
								
							
						
					
					
						commit
						d08a4b955f
					
				|  | @ -7,6 +7,7 @@ import nc.bs.dao.BaseDAO; | |||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.logging.Log; | ||||
| import nc.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.jdbc.framework.SQLParameter; | ||||
| import nc.jdbc.framework.processor.ColumnProcessor; | ||||
| import nc.vo.bc.pmpub.project.ProjectHeadVO; | ||||
| import nc.vo.bd.bom.bom0202.entity.BomVO; | ||||
|  | @ -21,6 +22,7 @@ import nc.vo.pub.BusinessException; | |||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.pubapp.pattern.pub.SqlBuilder; | ||||
| import nc.vo.scmpub.util.ArrayUtil; | ||||
| import nc.vo.so.m30.entity.SaleOrderBVO; | ||||
| import nc.vo.vorg.DeptVersionVO; | ||||
| import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; | ||||
| 
 | ||||
|  | @ -202,6 +204,12 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> { | |||
|         String vbillcode = head.getVbillcode(); // 单据号 | ||||
|         String itemRow = item.getVrowno(); // 行号        obmlog.info("开始为生产订单 " + vbillcode + " 行 " + itemRow + " 构建同步MES数据。"); | ||||
| 
 | ||||
|         // 检查是否需要同步到MES系统 | ||||
|         if (!shouldSyncToMes(item)) { | ||||
|             obmlog.info("生产订单 " + vbillcode + " 行 " + itemRow + " 不满足同步条件,跳过同步到MES系统。"); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         // orderNo String 是 生产订单号+行号 vbillcode+itemRow | ||||
|         String orderNoWithRow = vbillcode + itemRow; | ||||
|         if (orderNoWithRow.length() > 18) { | ||||
|  | @ -425,4 +433,80 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> { | |||
|         return field; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 判断是否需要同步到MES系统 | ||||
|      * 业务逻辑: | ||||
|      * 1. 通过源头单据类型判断是否为销售订单(源头单据类型为30) | ||||
|      * 2. 如果是销售订单,需要联查销售订单子实体 | ||||
|      * 3. 判断销售订单是否有定制标识(vbdef18) | ||||
|      * 4. 如果有定制标识,需要检查工艺配置完成时间(vbdef17)是否有值 | ||||
|      *    - 有值:传递给MES | ||||
|      *    - 无值:不传递给MES | ||||
|      * 5. 如果无定制标识:传递给MES | ||||
|      *  | ||||
|      * @param item 生产订单明细 | ||||
|      * @return true-需要同步,false-不需要同步 | ||||
|      * @throws BusinessException | ||||
|      */ | ||||
|     private boolean shouldSyncToMes(PMOItemVO item) throws BusinessException { | ||||
|         // 检查源头单据类型是否为销售订单(30) | ||||
|         if (!"30".equals(item.getVfirsttype())) { | ||||
|             // 非销售订单来源,直接同步 | ||||
|             obmlog.debug("生产订单明细行来源不是销售订单(源头单据类型:" + item.getVfirsttype() + "),允许同步。"); | ||||
|             return true; | ||||
|         } | ||||
|          | ||||
|         // 是销售订单来源,需要进一步检查 | ||||
|         String vfirstbid = item.getVfirstbid(); // 源头单据子表ID | ||||
|         if (StringUtils.isEmpty(vfirstbid)) { | ||||
|             obmlog.warn("生产订单明细行来源为销售订单,但源头单据子表ID为空,默认允许同步。"); | ||||
|             return true; | ||||
|         } | ||||
|          | ||||
|         try { | ||||
|             // 查询销售订单子实体的定制标识和工艺配置完成时间 | ||||
|             SqlBuilder sqlBuilder = new SqlBuilder(); | ||||
|             sqlBuilder.append(" SELECT vbdef18, vbdef17 "); | ||||
|             sqlBuilder.append(" FROM so_saleorder_b ");            sqlBuilder.append(" WHERE csaleorderbid = ? "); | ||||
|             sqlBuilder.append(" AND dr = 0 "); | ||||
|             SQLParameter sqlParam = new SQLParameter(); | ||||
|             sqlParam.addParam(vfirstbid); | ||||
|             SaleOrderBVO saleOrderBVO = (SaleOrderBVO) dao.retrieveByPK(SaleOrderBVO.class, vfirstbid); | ||||
|             if (Objects.isNull(saleOrderBVO)) { | ||||
|                 obmlog.warn("未查询到销售订单子实体信息(ID:" + vfirstbid + "),默认允许同步。"); | ||||
|                 return true; | ||||
|             } | ||||
|              | ||||
|             String vbdef18 = saleOrderBVO.getVbdef18(); | ||||
|             String vbdef17 = saleOrderBVO.getVbdef17(); | ||||
| 
 | ||||
|             obmlog.debug("销售订单定制标识:" + vbdef18 + ",工艺配置完成时间:" + vbdef17); | ||||
|              | ||||
|             // 如果无定制标识,允许同步 | ||||
|             if (StringUtils.isEmpty(vbdef18)) { | ||||
|                 obmlog.debug("销售订单无定制标识,允许同步。"); | ||||
|                 return true; | ||||
|             } | ||||
| 
 | ||||
|             if ("N".equals(vbdef18)) { | ||||
|                 obmlog.debug("销售订单定制标识为N,允许同步。"); | ||||
|                 return true; | ||||
|             } | ||||
| 
 | ||||
|             // 有定制标识,检查工艺配置完成时间 | ||||
|             if (StringUtils.isEmpty(vbdef17)) { | ||||
|                 obmlog.info("销售订单有定制标识但工艺配置完成时间为空,不允许同步。"); | ||||
|                 return false; | ||||
|             } else { | ||||
|                 obmlog.debug("销售订单有定制标识且工艺配置完成时间有值,允许同步。"); | ||||
|                 return true; | ||||
|             } | ||||
|              | ||||
|         } catch (Exception e) { | ||||
|             obmlog.error("查询销售订单信息失败:" + e.getMessage(), e); | ||||
|             // 查询失败时,为了避免影响正常业务,默认允许同步 | ||||
|             throw new BusinessException("查询销售订单信息失败:" + e.getMessage()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue