高压IMS-材料出库和生产报告优化

This commit is contained in:
mzr 2025-10-22 09:04:23 +08:00
parent fa60206ce2
commit bc0a0628e0
2 changed files with 35 additions and 24 deletions

View File

@ -3,7 +3,6 @@ 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.logging.Logger;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
@ -11,11 +10,11 @@ import nc.bs.uapbd.util.ImsDaoUtil;
import nc.bs.uapbd.util.MyHelper;
import nc.itf.mmpac.pickm.IPickmQueryService;
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.material.MaterialVO;
import nc.vo.bd.stordoc.StordocVO;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.ic.m4d.entity.MaterialOutBodyVO;
@ -67,7 +66,7 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
@Override
public PreAlertObject executeTask(BgWorkingContext arg0) {
Logger.error("---start----任务开始运行--");
logger.error("---start----任务开始运行--");
try {
IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class);
// IMS 同步状态BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
@ -139,9 +138,14 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
// 如果物料不相等则BIP物料替换为IMS物料
String cmaterialvid = bvo.getCmaterialvid();
String goodsCode = detailMap.get("cmaterialvid") + "";
String whereSql = MaterialVO.CODE + " = '" + goodsCode + "'" + " and pk_org = '" + hvo.getPk_org() + "'";
String goodsId = MyHelper.getStrValByCondition(MaterialVO.getDefaultTableName(), MaterialVO.PK_MATERIAL,
whereSql);
String pkOrg = hvo.getPk_org();
String goodsSql = " SELECT b.pk_material" +
" FROM bd_materialstock a" +
" LEFT JOIN bd_material b ON a.pk_material = b.pk_material" +
" WHERE b.code = '[code]' AND a.pk_org = '[pk_org]'";
goodsSql = goodsSql.replace("[code]", goodsCode);
goodsSql = goodsSql.replace("[pk_org]", pkOrg);
String goodsId = (String) baseDAO.executeQuery(goodsSql, new ColumnProcessor());
if (!cmaterialvid.equals(goodsId)) {
bvo.setCmaterialvid(goodsId);
}
@ -156,7 +160,7 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
// NCCForUAPLogger.debug("code = " + resultvos[0].getHead().getVbillcode());
imsIdSet.add(cgeneralhid);
} catch (BusinessException e) {
Logger.error("MaterialOutGyImsPlugin Error: ", 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());
@ -172,9 +176,9 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
String updateSql = "update BIPOutMainTab set status = '2',err_msg = null where " + inSql;
ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
}
Logger.error("---end----任务结束运行--");
logger.error("---end----任务结束运行--");
} catch (Exception e) {
Logger.error("MaterialOutGyImsPlugin Error: ", e);
logger.error("MaterialOutGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("MaterialOutGyImsPlugin Error: " + e.getMessage());
}
return null;

View File

@ -2,18 +2,17 @@ package nc.bs.uapbd.task.ims;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
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.MyHelper;
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
import nc.itf.mmpac.wr.IWrMaintainService;
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.util.mmf.busi.service.PFPubService;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.material.MaterialVO;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
import nc.vo.mmpac.wr.entity.AggWrVO;
@ -24,7 +23,6 @@ import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.scmpub.res.billtype.MMBillType;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import uap.mw.trans.TransactionFactory;
import java.math.BigDecimal;
@ -39,6 +37,8 @@ import java.util.*;
* @date 20250929
*/
public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
private static final String LOG_INFO_NAME = "gymeslog";
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
private SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
private SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// BIP数据源
@ -60,13 +60,13 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
@Override
public PreAlertObject executeTask(BgWorkingContext arg0) {
Logger.error("---start----任务开始运行--");
logger.error("---start----任务开始运行--");
try {
IPMOQueryService pmoQueryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
IWrMaintainService wrService = NCLocator.getInstance().lookup(IWrMaintainService.class);
// 手动开启事务
TransactionFactory.getTMProxy().begin(3, 0);
String selSql = "select * from BIPReportMainTab where status != '2'";
String selSql = "select * from BIPReportMainTab where status = 'C'";
List<Map<String, Object>> mainList = (List<Map<String, Object>>) getImsDao().executeQuery(selSql, new MapListProcessor());
Set<String> pkWrSet = new HashSet<>();
for (Map<String, Object> mainMap : mainList) {
@ -99,6 +99,8 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
hvo.setVbillcode(mainMap.get("vbillcode") + "");
hvo.setCreator("BIP");
hvo.setBillmaker("BIP");
// 1=自由;2=审批通过;
hvo.setFbillstatus(2);
String dmakedateStr = "";
if (mainMap.get("dmakedate") != null && mainMap.get("dmakedate") instanceof Timestamp dmakedate1) {
dmakedateStr = DATE_FORMATTER.format(dmakedate1);
@ -124,10 +126,15 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
bvo.setNbwrastnum(new UFDouble((BigDecimal) detailMap.get("nbwrastnum")));// 完工数量
// 如果物料不相等则BIP物料替换为IMS物料
String cbmaterialvid = bvo.getCbmaterialvid();
String pkOrg = hvo.getPk_org();
String goodsCode = detailMap.get("cbmaterialvid") + "";
String whereSql = MaterialVO.CODE + " = '" + goodsCode + "'" + " and pk_org = '" + hvo.getPk_org() + "'";
String goodsId = MyHelper.getStrValByCondition(MaterialVO.getDefaultTableName(), MaterialVO.PK_MATERIAL,
whereSql);
String goodsSql = " SELECT b.pk_material" +
" FROM bd_materialstock a" +
" LEFT JOIN bd_material b ON a.pk_material = b.pk_material" +
" WHERE b.code = '[code]' AND a.pk_org = '[pk_org]'";
goodsSql = goodsSql.replace("[code]", goodsCode);
goodsSql = goodsSql.replace("[pk_org]", pkOrg);
String goodsId = (String) baseDAO.executeQuery(goodsSql, new ColumnProcessor());
if (!cbmaterialvid.equals(goodsId)) {
bvo.setCbmaterialvid(goodsId);
}
@ -140,12 +147,12 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
resultvos = wrService.insert(vos);
}
} catch (BusinessException e) {
Logger.error("ProductReportGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("ProductReportGyImsPlugin Error: " + e.getMessage());
logger.error("ProductReportGyImsPlugin Error: ", e);
// NCCForUAPLogger.debug("ProductReportGyImsPlugin Error: " + e.getMessage());
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);
NCCForUAPLogger.debug("ProductReportGyImsPlugin-updateSql = " + updateSql);
// NCCForUAPLogger.debug("ProductReportGyImsPlugin-updateSql = " + updateSql);
getImsDao().executeUpdate(updateSql);
}
if (MMValueCheck.isEmpty(resultvos)) {
@ -161,12 +168,12 @@ public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
}
// 正常结束
TransactionFactory.getTMProxy().end(null);
Logger.error("---end----任务结束运行--");
logger.error("---end----任务结束运行--");
} catch (Exception e) {
// 异常回滚
TransactionFactory.getTMProxy().end(e);
Logger.error("ProductReportGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("ProductReportGyImsPlugin Error: " + e.getMessage());
logger.error("ProductReportGyImsPlugin Error: ", e);
// NCCForUAPLogger.debug("ProductReportGyImsPlugin Error: " + e.getMessage());
}
return null;
}