材料出库签字后推送高压ims中间表
This commit is contained in:
parent
ab0a8975be
commit
d1385afbe4
|
|
@ -13,6 +13,8 @@ import nc.bs.ic.m4d.base.BPPlugInPoint;
|
|||
import nc.bs.ic.m4d.base.UpdateSCOnhandRule;
|
||||
import nc.bs.ic.m4d.sign.rule.AfterSignRuleForLiabilityProcess;
|
||||
import nc.bs.ic.m4d.sign.rule.PullProcessEpicMesRule;
|
||||
|
||||
import nc.bs.ic.m4d.sign.rule.UpdateGyimsRule;
|
||||
import nc.bs.ic.m4d.sign.rule.PushSaveIAandTOBill;
|
||||
import nc.bs.ic.pub.util.SagasUtils;
|
||||
import nc.bs.scmpub.rule.VOSagaFrozenValidateRule;
|
||||
|
|
@ -37,6 +39,8 @@ public class SignBP implements ISignBP<MaterialOutVO>, ISignRuleProvider<Materia
|
|||
// processor.addAfterRule(new CheckDbizdateProcess());
|
||||
// 推送艾普MES-领料需求/退库单
|
||||
processor.addAfterRule(new PullProcessEpicMesRule("Y"));
|
||||
|
||||
processor.addAfterRule(new UpdateGyimsRule());
|
||||
}
|
||||
|
||||
public void addBeforeRule(MaterialOutVO[] vos, AroundProcesser<MaterialOutVO> processor) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
package nc.bs.ic.m4d.sign.rule;
|
||||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.uapbd.util.ImsDaoUtil;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.vo.fi.pub.SqlUtils;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 材料出库签字后修改高压ims
|
||||
* 上月(2025-10-01)
|
||||
* 本月(2025-11-30)
|
||||
*/
|
||||
public class UpdateGyimsRule implements IRule<MaterialOutVO> {
|
||||
// IMS数据源
|
||||
public BaseDAO imsDao;
|
||||
private Map<String, String> configParams;
|
||||
|
||||
public UpdateGyimsRule() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IMS数据源
|
||||
*/
|
||||
public BaseDAO getImsDao() {
|
||||
if (imsDao == null) {
|
||||
imsDao = new BaseDAO("gyims");
|
||||
// 禁用时间戳ts
|
||||
imsDao.setAddTimeStamp(false);
|
||||
}
|
||||
return imsDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(MaterialOutVO[] materialOutVOS) {
|
||||
Set<String> imsIdSet = new HashSet<>();
|
||||
try {
|
||||
configParams = MyHelper.getConfigParams("gy-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
throw new BusinessException("高压的gyims接口缺少配置");
|
||||
}
|
||||
for (MaterialOutVO materialOutVO : materialOutVOS) {
|
||||
|
||||
// 判断物料的业务单元是否是高压公司,不是则跳过
|
||||
String pkOrg = materialOutVO.getHead().getPk_org();
|
||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
imsIdSet.add(materialOutVO.getHead().getVbillcode());
|
||||
}
|
||||
if (!imsIdSet.isEmpty()) {
|
||||
// 修改状态为 完成:优化SQL条件拼接,避免语法错误和SQL注入风险
|
||||
// 1. 生成带引号的ID字符串(如 'id1','id2','id3')
|
||||
String ids = imsIdSet.stream()
|
||||
.map(id -> "'" + id.replace("'", "''") + "'") // 处理单引号转义,防止SQL注入
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
// 2. 构建更新SQL(假设vbillcode是字符串类型字段)
|
||||
String updateSql = "update BIPOutMainTab set status = '2' where vbillcode in (" + ids + ")";
|
||||
|
||||
// 3. 执行更新(注意:这里不需要再传递参数,SQL已拼接完成)
|
||||
int rows = ImsDaoUtil.executeUpdate(updateSql,ids);
|
||||
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("imsOrg");
|
||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(",");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ public class MaterialOutGyImsPlugin implements IBackgroundWorkPlugin {
|
|||
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;
|
||||
String updateSql = "update BIPOutMainTab set status = '1',err_msg = null where " + inSql;
|
||||
// NCCForUAPLogger.debug("updateSql-suc = " + updateSql);
|
||||
int rows = ImsDaoUtil.executeUpdate(updateSql, imsIdSet.toString());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue