ims生产订单状态同步任务
This commit is contained in:
parent
9a838e0f7d
commit
ef6ca42c78
|
|
@ -0,0 +1,136 @@
|
||||||
|
package nc.bs.uapbd.task.ims;
|
||||||
|
|
||||||
|
import nc.bs.dao.BaseDAO;
|
||||||
|
import nc.bs.framework.common.NCLocator;
|
||||||
|
import nc.bs.logging.Log;
|
||||||
|
import nc.bs.pub.pa.PreAlertObject;
|
||||||
|
import nc.bs.pub.taskcenter.BgWorkingContext;
|
||||||
|
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
|
||||||
|
import nc.bs.uapbd.util.ImsDaoUtil;
|
||||||
|
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.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.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.PMOItemVO;
|
||||||
|
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.sql.Timestamp;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ims生产订单状态同步
|
||||||
|
*/
|
||||||
|
public class PmoStatusFromGyImsPlugin implements IBackgroundWorkPlugin {
|
||||||
|
|
||||||
|
private static final String LOG_INFO_NAME = "gymeslog";
|
||||||
|
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
||||||
|
|
||||||
|
// BIP数据源
|
||||||
|
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
|
||||||
|
public PreAlertObject executeTask(BgWorkingContext arg0) {
|
||||||
|
logger.error("---start----ims生产订单状态同步任务开始运行--");
|
||||||
|
try {
|
||||||
|
// IMS 同步状态:BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
|
||||||
|
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());
|
||||||
|
Set<String> imsIdSet = new HashSet<>();
|
||||||
|
if(mainList.isEmpty()){
|
||||||
|
logger.error("---end---没有需要同步数据--");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PMOAggVO[] updateBills = null;
|
||||||
|
IPMOQueryService queryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||||
|
IPMOBusinessService businessService = NCLocator.getInstance().lookup(IPMOBusinessService.class);
|
||||||
|
for (Map<String, Object> mainMap : mainList) {
|
||||||
|
String cmoid = (String) mainMap.get("cmoid");
|
||||||
|
int targetStatus;
|
||||||
|
try {
|
||||||
|
targetStatus = Integer.parseInt(mainMap.get("fitemstatus").toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new BusinessException("行状态格式错误,必须为整数");
|
||||||
|
}
|
||||||
|
// 验证状态值是否合法
|
||||||
|
if (targetStatus < 1 || targetStatus > 2) {
|
||||||
|
throw new BusinessException("行状态值无效,必须是1-2之间的整数");
|
||||||
|
}
|
||||||
|
// 查询当前订单信息
|
||||||
|
PMOAggVO[] currentVOs = queryService.queryPMOAggVOByBid(new String[]{cmoid});
|
||||||
|
if (currentVOs == null || currentVOs.length == 0) {
|
||||||
|
throw new BusinessException("未找到订单: " + cmoid);
|
||||||
|
}
|
||||||
|
for (PMOAggVO vo : currentVOs) {
|
||||||
|
for(PMOItemVO itemVOS:vo.getChildrenVO()){
|
||||||
|
// 获取当前行状态
|
||||||
|
int currentStatus = vo.getParentVO().getFbillstatus(); // 假设存在此方法获取当前状态
|
||||||
|
// 只有审核通过(4)的订单才能修改为其他状态
|
||||||
|
if (currentStatus != 4) {
|
||||||
|
logger.error("订单" + cmoid + "当前状态为" + currentStatus + ",只有审核通过的订单才能修改行状态");
|
||||||
|
continue;
|
||||||
|
// throw new BusinessException("订单" + cmoid + "当前状态为" + currentStatus + ",只有审核通过的订单才能修改行状态");
|
||||||
|
}
|
||||||
|
// 目标状态是1-3,从审核通过状态变更,调用对应的方法
|
||||||
|
switch (targetStatus) {
|
||||||
|
case 1: // 投放
|
||||||
|
updateBills = businessService.rowput(currentVOs);
|
||||||
|
break;
|
||||||
|
case 2: // 完工
|
||||||
|
updateBills = businessService.rowfinish(currentVOs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
imsIdSet.add(cmoid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!imsIdSet.isEmpty()) {
|
||||||
|
// 修改状态为 完成
|
||||||
|
String inSql = SqlUtils.getInStr("cmoid", imsIdSet.toArray(new String[0]), Boolean.TRUE);
|
||||||
|
String updateSql = "update BIPOrderStatus set status = '2' where " + inSql;
|
||||||
|
ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
|
||||||
|
}
|
||||||
|
logger.error("---end----任务结束运行--");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("MaterialOutGyImsPlugin Error: ", e);
|
||||||
|
NCCForUAPLogger.debug("MaterialOutGyImsPlugin Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue