高压IMS同步优化

This commit is contained in:
mzr 2025-11-05 19:27:02 +08:00
parent 596e3d74bf
commit 7b681a606e
2 changed files with 107 additions and 99 deletions

View File

@ -10,6 +10,7 @@ import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.bs.uapbd.util.ImsDaoUtil;
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;
@ -102,9 +103,13 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
JSONArray bodyJsonArr = new JSONArray();
for (Map<String, Object> body : bodyList) {
JSONObject bodyJson = new JSONObject();
bodyJson.put("cmaterialvid", body.get("cmaterialvid"));// 膠죕긍쯤
// bodyJson.put("castunitid", body.get("castunitid"));// 데貫
// bodyJson.put("cunitid", body.get("cunitid"));// 寮데貫
Object cmaterialvid = body.get("cmaterialvid");
Map goodsMap = getGoodsInfo(cmaterialvid + "");
bodyJson.put("cmaterialvid", cmaterialvid);// 膠죕긍쯤
if (goodsMap != null) {
bodyJson.put("castunitid", goodsMap.get("unitcode"));// 데貫
bodyJson.put("cunitid", goodsMap.get("unitcode"));// 寮데貫
}
bodyJson.put("nshouldnum", body.get("nshouldnum"));// 应收主数量
bodyJson.put("nshouldassistnum", body.get("nshouldassistnum"));// 应收数量
bodyJson.put("nnum", body.get("nnum"));// 实收主数量
@ -130,7 +135,7 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
bodyJson.put("norigtaxmny", body.get("norigtaxmny"));// 价税合计
bodyJson.put("nmny", body.get("norigmny"));// 本币无税金额
bodyJson.put("ntaxmny", body.get("norigtaxmny"));// 本币价税合计
bodyJson.put("ntaxrate", body.get("ntaxrate"));// 江쪽
// bodyJson.put("ntaxrate", body.get("ntaxrate"));// 江쪽
bodyJson.put("vnotebody", body.get("vnotebody"));// 行备注
bodyJsonArr.add(bodyJson);
@ -142,13 +147,15 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
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()) {
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;
ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
getImsDao().executeUpdate(updateSql);
}
} catch (Exception e) {
Logger.error("ErpIaI2billFromGyImsPlugin Error: ", e);
@ -162,4 +169,15 @@ public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
}
return null;
}
private Map getGoodsInfo(String materialCode) throws BusinessException {
String sql = " select a.pk_measdoc, c.code unitcode, b.pk_measdoc deputyunit " +
"from bd_material a " +
"left join bd_materialconvert b on a.pk_material = b.pk_material " +
"left join bd_measdoc c on a.pk_measdoc = c.pk_measdoc " +
"where a.code = '" + materialCode + "' ";
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
return map;
}
}

View File

@ -27,7 +27,6 @@ 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 nccloud.baseapp.core.log.NCCForUAPLogger;
import java.math.BigDecimal;
import java.sql.Timestamp;
@ -79,7 +78,7 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
imsIdFailSet.add(cgeneralhid);
// 同步状态IMS:C-创建;U-修改; 4-BIP审核出库MES接收确认 BIP:2-BIP审核出库
String status = mainMap.get("status") + "";
try {
String pkSql = "select * from BIPOutDetailTab where cgeneralhid = '" + cgeneralhid + "'";
List<Map<String, Object>> detailList = (List<Map<String, Object>>) getImsDao().executeQuery(pkSql, new MapListProcessor());
Map<String, Map<String, Object>> detailIdMap = new HashMap<>();
@ -166,24 +165,14 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
if (MMValueCheck.isEmpty(resultvos)) {
continue;
}
// NCCForUAPLogger.debug("code = " + resultvos[0].getHead().getVbillcode());
imsIdSet.add(cgeneralhid);
} catch (BusinessException e) {
logger.error("MaterialOutGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("MaterialOutGyImsPlugin Error: " + e.getMessage());
String updateSql = "update BIPOutMainTab set err_msg = '[err_msg]' where cgeneralhid = '[cgeneralhid]'";
updateSql = updateSql.replace("[err_msg]", e.getMessage());
updateSql = updateSql.replace("[cgeneralhid]", cgeneralhid);
NCCForUAPLogger.debug("MaterialOutGyImsPlugin-updateSql = " + updateSql);
int rows = ImsDaoUtil.executeUpdate(updateSql, cgeneralhid);
NCCForUAPLogger.debug("MaterialOutGyImsPlugin-rows = " + rows);
}
}
if (!imsIdSet.isEmpty()) {
// 修改状态为 完成
String inSql = SqlUtils.getInStr("cgeneralhid", imsIdSet.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update BIPOutMainTab set status = '2',err_msg = null where " + inSql;
ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
// NCCForUAPLogger.debug("updateSql-suc = " + updateSql);
int rows = ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
}
logger.error("---end----任务结束运行--");
} catch (Exception e) {
@ -191,6 +180,7 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
String inSql = SqlUtils.getInStr("cgeneralhid", imsIdFailSet.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update BIPOutMainTab set err_msg = '[err_msg]' where " + inSql;
updateSql = updateSql.replace("[err_msg]", e.getMessage());
// NCCForUAPLogger.debug("updateSql-fail = " + updateSql);
int rows = ImsDaoUtil.executeUpdate(updateSql, imsIdFailSet.toString());
}
return null;