refactor(task):优化材料出库-高压IMS获取逻辑-启用独立事务
This commit is contained in:
parent
af944a833c
commit
6959f0e1cb
|
|
@ -6,7 +6,6 @@ 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.MyHelper;
|
import nc.bs.uapbd.util.MyHelper;
|
||||||
import nc.itf.mmpac.pickm.IPickmQueryService;
|
import nc.itf.mmpac.pickm.IPickmQueryService;
|
||||||
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
|
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
|
||||||
|
|
@ -16,7 +15,6 @@ import nc.pubitf.ic.m4d.api.IMaterialOutMaintainAPI;
|
||||||
import nc.util.mmf.busi.service.PFPubService;
|
import nc.util.mmf.busi.service.PFPubService;
|
||||||
import nc.util.mmf.framework.base.MMValueCheck;
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
import nc.vo.bd.stordoc.StordocVO;
|
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.MaterialOutBodyVO;
|
||||||
import nc.vo.ic.m4d.entity.MaterialOutHeadVO;
|
import nc.vo.ic.m4d.entity.MaterialOutHeadVO;
|
||||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||||
|
|
@ -66,19 +64,16 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
|
||||||
@Override
|
@Override
|
||||||
public PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {
|
public PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {
|
||||||
logger.error("---start----任务开始运行--");
|
logger.error("---start----任务开始运行--");
|
||||||
Set<String> imsIdFailSet = new HashSet<>();
|
IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class);
|
||||||
try {
|
// IMS 同步状态:BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
|
||||||
IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class);
|
String selSql = "select * from BIPOutMainTab where status = 'C'";
|
||||||
// IMS 同步状态:BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
|
List<Map<String, Object>> mainList = (List<Map<String, Object>>) getImsDao().executeQuery(selSql, new MapListProcessor());
|
||||||
String selSql = "select * from BIPOutMainTab where status = 'C'";
|
Set<String> imsIdSet = new HashSet<>();
|
||||||
List<Map<String, Object>> mainList = (List<Map<String, Object>>) getImsDao().executeQuery(selSql, new MapListProcessor());
|
for (Map<String, Object> mainMap : mainList) {
|
||||||
Set<String> imsIdSet = new HashSet<>();
|
String cgeneralhid = mainMap.get("cgeneralhid") + "";
|
||||||
for (Map<String, Object> mainMap : mainList) {
|
// 同步状态:IMS:C-创建;U-修改; 4-BIP审核出库MES接收确认 BIP:2-BIP审核出库
|
||||||
String cgeneralhid = mainMap.get("cgeneralhid") + "";
|
String status = mainMap.get("status") + "";
|
||||||
imsIdFailSet.add(cgeneralhid);
|
try {
|
||||||
// 同步状态:IMS:C-创建;U-修改; 4-BIP审核出库MES接收确认 BIP:2-BIP审核出库
|
|
||||||
String status = mainMap.get("status") + "";
|
|
||||||
|
|
||||||
String pkSql = "select * from BIPOutDetailTab where cgeneralhid = '" + cgeneralhid + "'";
|
String pkSql = "select * from BIPOutDetailTab where cgeneralhid = '" + cgeneralhid + "'";
|
||||||
List<Map<String, Object>> detailList = (List<Map<String, Object>>) getImsDao().executeQuery(pkSql, new MapListProcessor());
|
List<Map<String, Object>> detailList = (List<Map<String, Object>>) getImsDao().executeQuery(pkSql, new MapListProcessor());
|
||||||
Map<String, Map<String, Object>> detailIdMap = new HashMap<>();
|
Map<String, Map<String, Object>> detailIdMap = new HashMap<>();
|
||||||
|
|
@ -141,8 +136,6 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
|
||||||
bvo.setNshouldassistnum(skipNullNum(detailMap.get("nshouldassistnum"), bvo.getNshouldassistnum()));// 应发数量
|
bvo.setNshouldassistnum(skipNullNum(detailMap.get("nshouldassistnum"), bvo.getNshouldassistnum()));// 应发数量
|
||||||
bvo.setNnum(skipNullNum(detailMap.get("nnum"), bvo.getNshouldnum()));// 实发主数量
|
bvo.setNnum(skipNullNum(detailMap.get("nnum"), bvo.getNshouldnum()));// 实发主数量
|
||||||
bvo.setNassistnum(skipNullNum(detailMap.get("nassistnum"), bvo.getNshouldassistnum()));// 实发数量
|
bvo.setNassistnum(skipNullNum(detailMap.get("nassistnum"), bvo.getNshouldassistnum()));// 实发数量
|
||||||
// bvo.setNnum(skipNullNum(detailMap.get("nnum"), bvo.getNnum()));// 实发主数量
|
|
||||||
// bvo.setNassistnum(skipNullNum(detailMap.get("nassistnum"), bvo.getNassistnum()));// 实发数量
|
|
||||||
// 如果物料不相等,则BIP物料替换为IMS物料
|
// 如果物料不相等,则BIP物料替换为IMS物料
|
||||||
String cmaterialvid = bvo.getCmaterialvid();
|
String cmaterialvid = bvo.getCmaterialvid();
|
||||||
String goodsCode = detailMap.get("cmaterialvid") + "";
|
String goodsCode = detailMap.get("cmaterialvid") + "";
|
||||||
|
|
@ -160,29 +153,28 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 用_RequiresNew方法单独启事务
|
||||||
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
||||||
MaterialOutVO[] resultvos = materialOut.insertBills(vos);
|
MaterialOutVO[] resultvos = materialOut.batchInsertBills_RequiresNew(vos);
|
||||||
if (MMValueCheck.isEmpty(resultvos)) {
|
String updateSql;
|
||||||
continue;
|
if (MMValueCheck.isNotEmpty(resultvos)) {
|
||||||
|
updateSql = "update BIPOutMainTab set status = '1',err_msg = null where cgeneralhid = '[cgeneralhid]'";
|
||||||
|
} else {
|
||||||
|
updateSql = "update BIPOutMainTab set err_msg = '[err_msg]' where cgeneralhid = '[cgeneralhid]'";
|
||||||
|
updateSql = updateSql.replace("[err_msg]", "新增返回空");
|
||||||
}
|
}
|
||||||
imsIdSet.add(cgeneralhid);
|
updateSql = updateSql.replace("[cgeneralhid]", cgeneralhid);
|
||||||
|
getImsDao().executeUpdate(updateSql);
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
logger.error("MaterialOutGyImsPlugin Error: ", e);
|
||||||
|
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("updateSql-fail = " + updateSql);
|
||||||
|
getImsDao().executeUpdate(updateSql);
|
||||||
}
|
}
|
||||||
if (!imsIdSet.isEmpty()) {
|
|
||||||
// 修改状态为 完成
|
|
||||||
String inSql = SqlUtils.getInStr("cgeneralhid", imsIdSet.toArray(new String[0]), Boolean.TRUE);
|
|
||||||
String updateSql = "update BIPOutMainTab set status = '1',err_msg = null where " + inSql;
|
|
||||||
// NCCForUAPLogger.debug("updateSql-suc = " + updateSql);
|
|
||||||
int rows = ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
|
|
||||||
}
|
|
||||||
logger.error("---end----任务结束运行--");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("MaterialOutGyImsPlugin Error: ", e);
|
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
logger.error("---end----任务结束运行--");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue