refactor(ims): 优化IMS生产订单状态同步-调整数据源获取方式

This commit is contained in:
mzr 2025-11-21 11:03:47 +08:00
parent 70f72c23a8
commit d9bf9c2cda
1 changed files with 15 additions and 51 deletions

View File

@ -6,39 +6,18 @@ import nc.bs.logging.Log;
import nc.bs.pub.pa.PreAlertObject; import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.taskcenter.BgWorkingContext; import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin; import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.bs.uapbd.util.ImsDaoUtil; import nc.bs.uapbd.util.GyImsDbUtil;
import nc.bs.uapbd.util.MyHelper;
import nc.itf.mmpac.pickm.IPickmQueryService;
import nc.itf.mmpac.pmo.pac0002.IPMOBusinessService; import nc.itf.mmpac.pmo.pac0002.IPMOBusinessService;
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService; import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.pubitf.ic.m4d.api.IMaterialOutMaintainAPI;
import nc.util.mmf.busi.service.PFPubService;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.stordoc.StordocVO;
import nc.vo.fi.pub.SqlUtils; import nc.vo.fi.pub.SqlUtils;
import nc.vo.ic.m4d.entity.MaterialOutBodyVO;
import nc.vo.ic.m4d.entity.MaterialOutHeadVO;
import nc.vo.ic.m4d.entity.MaterialOutVO;
import nc.vo.mmpac.pickm.entity.AggPickmVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
import nc.vo.pub.BusinessException; import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.scmpub.res.billtype.ICBillType;
import nc.vo.scmpub.res.billtype.MMBillType;
import nc.ws.opm.pub.utils.result.APIErrCodeEnum;
import nccloud.api.rest.utils.ResultMessageUtil;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import java.math.BigDecimal; import java.util.HashSet;
import java.sql.Timestamp; import java.util.List;
import java.text.SimpleDateFormat; import java.util.Map;
import java.util.*; import java.util.Set;
/** /**
* ims生产订单状态同步 * ims生产订单状态同步
@ -47,33 +26,18 @@ public class PmoStatusFromGyImsPlugin implements IBackgroundWorkPlugin {
private static final String LOG_INFO_NAME = "gyimslog"; private static final String LOG_INFO_NAME = "gyimslog";
private static final Log logger = Log.getInstance(LOG_INFO_NAME); private static final Log logger = Log.getInstance(LOG_INFO_NAME);
// BIP数据源
// BIP数据源
public static final BaseDAO baseDAO = new BaseDAO(); public static final BaseDAO baseDAO = new BaseDAO();
// IMS数据源
public BaseDAO imsDao;
/**
* 获取IMS数据源
*/
public BaseDAO getImsDao() {
if (imsDao == null) {
imsDao = new BaseDAO("gyims");
// 禁用时间戳ts
imsDao.setAddTimeStamp(false);
}
return imsDao;
}
@Override @Override
public PreAlertObject executeTask(BgWorkingContext arg0) { public PreAlertObject executeTask(BgWorkingContext arg0) {
logger.error("---start----ims生产订单状态同步任务开始运行--"); logger.error("---start----ims生产订单状态同步任务-开始运行--");
try { try {
// IMS 同步状态BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成 // IMS 同步状态BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
String selSql = "select * from BIPOrderStatus where status = 'C' or status = 'U'"; String selSql = "select * from BIPOrderStatus where status = 'C' or status = 'U'";
List<Map<String, Object>> mainList = (List<Map<String, Object>>) getImsDao().executeQuery(selSql, new MapListProcessor()); List<Map<String, Object>> mainList = GyImsDbUtil.query(selSql);
Set<String> imsIdSet = new HashSet<>(); Set<String> imsIdSet = new HashSet<>();
if(mainList.isEmpty()){ if (mainList.isEmpty()) {
logger.error("---end---没有需要同步数据--"); logger.error("---end---没有需要同步数据--");
return null; return null;
} }
@ -98,7 +62,7 @@ public class PmoStatusFromGyImsPlugin implements IBackgroundWorkPlugin {
throw new BusinessException("未找到订单: " + cmoid); throw new BusinessException("未找到订单: " + cmoid);
} }
for (PMOAggVO vo : currentVOs) { for (PMOAggVO vo : currentVOs) {
for(PMOItemVO itemVOS:vo.getChildrenVO()){ for (PMOItemVO itemVOS : vo.getChildrenVO()) {
// 获取当前行状态 // 获取当前行状态
int currentStatus = vo.getParentVO().getFbillstatus(); // 假设存在此方法获取当前状态 int currentStatus = vo.getParentVO().getFbillstatus(); // 假设存在此方法获取当前状态
// 只有审核通过(4)的订单才能修改为其他状态 // 只有审核通过(4)的订单才能修改为其他状态
@ -107,7 +71,7 @@ public class PmoStatusFromGyImsPlugin implements IBackgroundWorkPlugin {
continue; continue;
// throw new BusinessException("订单" + cmoid + "当前状态为" + currentStatus + ",只有审核通过的订单才能修改行状态"); // throw new BusinessException("订单" + cmoid + "当前状态为" + currentStatus + ",只有审核通过的订单才能修改行状态");
} }
// 目标状态是1-3从审核通过状态变更调用对应的方法 // 目标状态是1-3从审核通过状态变更调用对应的方法
switch (targetStatus) { switch (targetStatus) {
case 1: // 投放 case 1: // 投放
updateBills = businessService.rowput(currentVOs); updateBills = businessService.rowput(currentVOs);
@ -124,12 +88,12 @@ public class PmoStatusFromGyImsPlugin implements IBackgroundWorkPlugin {
// 修改状态为 完成 // 修改状态为 完成
String inSql = SqlUtils.getInStr("cmoid", imsIdSet.toArray(new String[0]), Boolean.TRUE); String inSql = SqlUtils.getInStr("cmoid", imsIdSet.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update BIPOrderStatus set status = '2' where " + inSql; String updateSql = "update BIPOrderStatus set status = '2' where " + inSql;
ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString()); GyImsDbUtil.update(updateSql);
} }
logger.error("---end----任务结束运行--"); logger.error("---end---ims生产订单状态同步任务-任务结束运行--");
} catch (Exception e) { } catch (Exception e) {
logger.error("MaterialOutGyImsPlugin Error: ", e); logger.error("PmoStatusFromGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("MaterialOutGyImsPlugin Error: " + e.getMessage()); // NCCForUAPLogger.debug("PmoStatusFromGyImsPlugin Error: " + e.getMessage());
} }
return null; return null;
} }