高压IMS-定时同步数据调整

This commit is contained in:
mzr 2025-11-20 14:48:30 +08:00
parent 120c0b4929
commit 9c725d2c9a
3 changed files with 33 additions and 37 deletions

View File

@ -5,23 +5,22 @@ import com.alibaba.fastjson.JSONObject;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Log;
import nc.bs.logging.Logger;
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.jdbc.framework.processor.MapListProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.ic.m45.entity.PurchaseInVO;
import nc.vo.pub.BusinessException;
import nccloud.api.ic.m45.IAPIPurchaseInMaitain;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 高压加工车间-IMS-定时获取采购入库数据
@ -57,13 +56,12 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
if (remain == null || remain.isEmpty()) {
return null;
}
Set<String> imsIdSet = new HashSet<>();
try {
for (Map<String, Object> map : remain) {
List<Map<String, Object>> paramList = new ArrayList<>();
for (Map<String, Object> map : remain) {
String cgeneralhid = (String) map.get("cgeneralhid");
// 状态标识 IMS:C-创建;U-修改 BIP:2-BIP单据接收完成
String status = map.get("status") + "";
String cgeneralhid = (String) map.get("cgeneralhid");
// 状态标识 IMS:C-创建;U-修改 BIP:2-BIP单据接收完成
String status = map.get("status") + "";
try {
String bodySql = " SELECT *" + " from BIPInputDetailTab a " + " where a.cgeneralhid ='" + cgeneralhid + "'";
List<Map<String, Object>> bodyList = (List<Map<String, Object>>) getImsDao().executeQuery(bodySql, new MapListProcessor());
if (bodyList == null || bodyList.isEmpty()) {
@ -91,7 +89,7 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
headJson.put("cpayfinorgvid", "C003");// 应付财务组织最新版本
headJson.put("cpayfinorgoid", "C003");// 应付财务组织
headJson.put("creator", "BIP");
headJson.put("billmaker", MyHelper.getUserId((String) map.get("billmaker")) );
headJson.put("billmaker", MyHelper.getUserId((String) map.get("billmaker")));
if (map.get("dbilldate") != null && map.get("dbilldate") instanceof Timestamp dbilldate) {
String dbilldateStr = DATETIME_FORMATTER.format(dbilldate);
headJson.put("dbilldate", dbilldateStr); // 单据日期
@ -149,27 +147,26 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
param.put("ic_purchasein_b", bodyJsonArr);
// 添加到集合
paramList.add(param);
imsIdSet.add(cgeneralhid);
}
// String jsonString = JSONArray.toJSONString(paramList);
// NCCForUAPLogger.debug("jsonString = " + jsonString);
IAPIPurchaseInMaitain purchaseInMaitain = NCLocator.getInstance().lookup(IAPIPurchaseInMaitain.class);
PurchaseInVO[] resultvos = purchaseInMaitain.save(paramList);
if (!imsIdSet.isEmpty() && resultvos != null) {
// 修改状态为 完成
String inSql = SqlUtils.getInStr("cgeneralhid", imsIdSet.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update BIPInputMainTab set status = '2',err_msg = null where " + inSql;
// String jsonString = JSONArray.toJSONString(paramList);
// NCCForUAPLogger.debug("jsonString = " + jsonString);
IAPIPurchaseInMaitain purchaseInMaitain = NCLocator.getInstance().lookup(IAPIPurchaseInMaitain.class);
PurchaseInVO[] resultvos = purchaseInMaitain.save_RequiresNew(paramList);
String updateSql;
if (resultvos != null && resultvos.length > 0) {
updateSql = "update BIPInputMainTab set status = '2',err_msg = null where cgeneralhid = '[cgeneralhid]'";
} else {
updateSql = "update BIPInputMainTab set err_msg = '[err_msg]' where cgeneralhid = '[cgeneralhid]'";
updateSql = updateSql.replace("[err_msg]", "新增返回空");
}
updateSql = updateSql.replace("[cgeneralhid]", cgeneralhid);
getImsDao().executeUpdate(updateSql);
} catch (BusinessException e) {
logger.error("ErpIaI2billFromGyImsPlugin Error: " + e.getMessage(), e);
String updateSql = "update BIPInputMainTab set err_msg = '[err_msg]' where cgeneralhid = '[cgeneralhid]'";
updateSql = updateSql.replace("[err_msg]", e.getMessage());
updateSql = updateSql.replace("[cgeneralhid]", cgeneralhid);
int rows = getImsDao().executeUpdate(updateSql);
}
} catch (Exception e) {
logger.error("ErpIaI2billFromGyImsPlugin Error: ", e);
// NCCForUAPLogger.debug("ErpIaI2billFromGyImsPlugin Error: " + e.getMessage());
String inSql = SqlUtils.getInStr("cgeneralhid", imsIdSet.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update BIPInputMainTab set err_msg = '[err_msg]' where " + inSql;
updateSql = updateSql.replace("[err_msg]", e.getMessage());
// NCCForUAPLogger.debug("ErpIaI2billFromGyImsPlugin-updateSql = " + updateSql);
int rows = ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
// NCCForUAPLogger.debug("ErpIaI2billFromGyImsPlugin-rows = " + rows);
}
return null;
}

View File

@ -63,12 +63,11 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
@Override
public PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {
logger.error("---start----任务开始运行--");
logger.error("---start----高压IMS-材料出库-任务开始运行--");
IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class);
// IMS 同步状态BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
String selSql = "select * from BIPOutMainTab where status = 'C'";
List<Map<String, Object>> mainList = (List<Map<String, Object>>) getImsDao().executeQuery(selSql, new MapListProcessor());
Set<String> imsIdSet = new HashSet<>();
for (Map<String, Object> mainMap : mainList) {
String cgeneralhid = mainMap.get("cgeneralhid") + "";
// 同步状态IMS:C-创建;U-修改; 4-BIP审核出库MES接收确认 BIP:2-BIP审核出库
@ -174,7 +173,7 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
getImsDao().executeUpdate(updateSql);
}
}
logger.error("---end----任务结束运行--");
logger.error("---end----高压IMS-材料出库-任务结束运行--");
return null;
}

View File

@ -66,7 +66,7 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
@Override
public PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {
logger.error("---start----任务开始运行--");
logger.error("---start----高压IMS-生产报告-任务开始运行--");
IPMOQueryService pmoQueryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
IWrMaintainService wrService = NCLocator.getInstance().lookup(IWrMaintainService.class);
String selSql = "select * from BIPReportMainTab where status = 'C'";
@ -169,14 +169,14 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
updateSql = updateSql.replace("[pkWr]", pkWr);
getImsDao().executeUpdate(updateSql);
} catch (BusinessException e) {
logger.error("ProductReportGyImsPlugin Error: ", e);
logger.error("ProductReportGyImsPlugin Error: " + e.getMessage(), e);
String updateSql = "update BIPReportMainTab set err_msg = '[err_msg]' where pk_wr = '[pkWr]'";
updateSql = updateSql.replace("[err_msg]", e.getMessage());
updateSql = updateSql.replace("[pkWr]", pkWr);
getImsDao().executeUpdate(updateSql);
}
}
logger.error("---end----任务结束运行--");
logger.error("---end----高压IMS-生产报告-任务结束运行--");
return null;
}