流程生产订单审批后推送高压IMS
This commit is contained in:
parent
710447bad3
commit
5570e015b4
|
|
@ -9,15 +9,13 @@ import nc.jdbc.framework.SQLParameter;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||||
|
import nc.vo.org.OrgVO;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
import nc.vo.scmpub.util.ArrayUtil;
|
import nc.vo.scmpub.util.ArrayUtil;
|
||||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程生产订单审批后推送高压IMS
|
* 流程生产订单审批后推送高压IMS
|
||||||
|
|
@ -47,6 +45,31 @@ public class AfterApproveSyncImsRule implements IRule<PMOAggVO> {
|
||||||
return imsDao;
|
return imsDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String HEAD_TABLE = "BIPOrderMainTab";
|
||||||
|
private static final String BODY_TABLE = "BIPOrderDetailTab";
|
||||||
|
private static final String[] HEAD_COLUMNS = {"cpmohid", "pk_org", "cplanfactoryid", "dbilldate", "vbillcode", "ctrantypeid", "vtrantypecode", "fbillstatus",
|
||||||
|
"approver", "approvertime", "billmaker", "dmakedate", "vnote", "creator", "creationtime", "status"};
|
||||||
|
private static final String[] BODY_COLUMNS = {
|
||||||
|
"cmoid", "cpmohid", "vbillcode", "vrowno", "pk_group", "pk_org", "fitemstatus", "cmaterialvid", "cunitid", "castunitid", "nnum", "nastnum", "vchangerate", "nplanputastnum",
|
||||||
|
"nplanputnum", "nmmastnum", "nmmnum", "cdeptid", "temp_mainmaterialid", "temp_mainmaterialvid", "temp_mainbid", "cemployeeid", "cbomversionid", "vbomversion", "cpackbomid",
|
||||||
|
"vpackbomversion", "crtversionid", "vrtversion", "tplanstarttime", "tplanendtime", "twillendtime", "tactstarttime", "tactendtime", "mocloser", "tmoclosedtime", "vsalebillcode",
|
||||||
|
"cbatchid", "vbatchcode", "vnote", "cproductorid", "cprojectid", "vsrctrantypeid", "vsrctrantype", "vsrctype", "vsrcid", "vsrccode", "vsrcbid", "vsrcrowno", "crequireorg",
|
||||||
|
"crequireorgvid", "trequiredate", "tsupplytime", "vfirsttrantypeid", "vfirsttrantype", "vfirsttype", "vfirstid", "vfirstcode", "vfirstbid", "vfirstrowno", "ninastnum", "ninnum",
|
||||||
|
"vfirstmotype", "cfirstmoid", "vfirstmocode", "cfirstmobid", "vfirstmorowno", "cinwarehouseid", "vbdef31"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 表头-定义数值类型字段列表
|
||||||
|
private Set<String> headNumFields = new HashSet<>(Arrays.asList(
|
||||||
|
"nnum", "nastnum", "nplanputastnum", "nplanputnum", "nmmastnum", "nmmnum",
|
||||||
|
"ninastnum", "ninnum"
|
||||||
|
));
|
||||||
|
// 表体-定义数值类型字段列表
|
||||||
|
Set<String> bodyNumFields = new HashSet<>(Arrays.asList(
|
||||||
|
"nnum", "nastnum", "nplanputastnum", "nplanputnum", "nmmastnum", "nmmnum",
|
||||||
|
"ninastnum", "ninnum"
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(PMOAggVO[] pmoAggVOS) {
|
public void process(PMOAggVO[] pmoAggVOS) {
|
||||||
if (ArrayUtil.isEmpty(pmoAggVOS)) {
|
if (ArrayUtil.isEmpty(pmoAggVOS)) {
|
||||||
|
|
@ -68,273 +91,28 @@ public class AfterApproveSyncImsRule implements IRule<PMOAggVO> {
|
||||||
for (PMOAggVO vo : useVOs) {
|
for (PMOAggVO vo : useVOs) {
|
||||||
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
||||||
PMOItemVO[] itemVOS = vo.getChildrenVO();
|
PMOItemVO[] itemVOS = vo.getChildrenVO();
|
||||||
// 判断物料的业务单元是否是高压加工车间W,不是则跳过
|
// 判断物料的业务单元是否是高压加工车间,不是则跳过
|
||||||
String pkOrg = pmoHeadVO.getPk_org();
|
String pkOrg = pmoHeadVO.getPk_org();
|
||||||
/*String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||||
if (checkIfOrg(orgCode, configParams)) {
|
if (checkIfOrg(orgCode, configParams)) {
|
||||||
continue;
|
continue;
|
||||||
}*/
|
}
|
||||||
// 表头
|
// 表头
|
||||||
// cpmohid 流程生产订单
|
|
||||||
// pk_org 工厂最新版本
|
|
||||||
// cplanfactoryid 计划组织最新版本
|
|
||||||
// dbilldate 单据日期
|
|
||||||
// vbillcode 流程生产订单号
|
|
||||||
// ctrantypeid 订单交易类型
|
|
||||||
// vtrantypecode 订单交易类型编码
|
|
||||||
// fbillstatus 订单状态
|
|
||||||
// approver 审批人
|
|
||||||
// approvertime 审批日期
|
|
||||||
// billmaker 制单人
|
|
||||||
// dmakedate 制单日期
|
|
||||||
// vnote 备注
|
|
||||||
// creator 创建人
|
|
||||||
// creationtime 创建时间
|
|
||||||
// status C=创建U=修改2=处理完成
|
|
||||||
// 构建插入表头数据的SQL
|
// 构建插入表头数据的SQL
|
||||||
StringBuilder headSqlBuilder = new StringBuilder();
|
String headSql = buildInsertSQL(HEAD_TABLE, HEAD_COLUMNS);
|
||||||
headSqlBuilder.append("INSERT INTO BIPOrderMainTab (");
|
|
||||||
headSqlBuilder.append("cpmohid, pk_org, cplanfactoryid, dbilldate, vbillcode, ");
|
SQLParameter headParams = buildHeadParameters(pmoHeadVO);
|
||||||
headSqlBuilder.append("ctrantypeid, vtrantypecode, fbillstatus, approver, ");
|
|
||||||
headSqlBuilder.append("approvertime, billmaker, dmakedate, vnote, creator, ");
|
|
||||||
headSqlBuilder.append("creationtime, status");
|
|
||||||
headSqlBuilder.append(") VALUES (");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?").append(", ");
|
|
||||||
headSqlBuilder.append("?");
|
|
||||||
headSqlBuilder.append(")");
|
|
||||||
SQLParameter headParams = new SQLParameter();
|
|
||||||
headParams.addParam(pmoHeadVO.getCpmohid());
|
|
||||||
headParams.addParam(pmoHeadVO.getPk_org());
|
|
||||||
headParams.addParam(pmoHeadVO.getCplanfactoryid());
|
|
||||||
headParams.addParam(skipNull(pmoHeadVO.getDbilldate()));
|
|
||||||
headParams.addParam(pmoHeadVO.getVbillcode());
|
|
||||||
headParams.addParam(pmoHeadVO.getCtrantypeid());
|
|
||||||
headParams.addParam(pmoHeadVO.getVtrantypecode());
|
|
||||||
headParams.addParam(pmoHeadVO.getFbillstatus());
|
|
||||||
headParams.addParam(pmoHeadVO.getApprover());
|
|
||||||
headParams.addParam(skipNull(pmoHeadVO.getApprovertime()));
|
|
||||||
headParams.addParam(pmoHeadVO.getBillmaker());
|
|
||||||
headParams.addParam(skipNull(pmoHeadVO.getDmakedate()));
|
|
||||||
headParams.addParam(pmoHeadVO.getVnote());
|
|
||||||
headParams.addParam(pmoHeadVO.getCreator());
|
|
||||||
headParams.addParam(skipNull(pmoHeadVO.getCreationtime()));
|
|
||||||
headParams.addParam("C");// 默认状态为C(新增)
|
|
||||||
List<Map<String, SQLParameter>> bodyParameterList = new ArrayList<>();
|
List<Map<String, SQLParameter>> bodyParameterList = new ArrayList<>();
|
||||||
for (PMOItemVO item : itemVOS) {
|
for (PMOItemVO item : itemVOS) {
|
||||||
// cmoid 流程生产订单明细
|
|
||||||
// vrowno 行号
|
|
||||||
// pk_group 集团
|
|
||||||
// pk_org 工厂最新版本
|
|
||||||
// fitemstatus 行状态
|
|
||||||
// cmaterialvid 产品
|
|
||||||
// cunitid 主单位
|
|
||||||
// castunitid 单位
|
|
||||||
// nnum 主数量
|
|
||||||
// nastnum 数量
|
|
||||||
// vchangerate 换算率
|
|
||||||
// nplanputastnum 计划投入数量
|
|
||||||
// nplanputnum 计划投入主数量
|
|
||||||
// nmmastnum 计划产出数量
|
|
||||||
// nmmnum 计划产出主数量
|
|
||||||
// cdeptid 生产部门
|
|
||||||
// cdeptvid 生产部门版本
|
|
||||||
// cemployeeid 业务员
|
|
||||||
// tplanstarttime 计划开工时间
|
|
||||||
// tplanendtime 计划完工时间
|
|
||||||
// twillendtime 预计完工时间
|
|
||||||
// tactstarttime 实际开工时间
|
|
||||||
// tactendtime 实际完工时间
|
|
||||||
// mocloser 关闭人
|
|
||||||
// tmoclosedtime 关闭时间
|
|
||||||
// cbatchid 生产批次
|
|
||||||
// vbatchcode 生产批次号
|
|
||||||
// vnote 备注
|
|
||||||
// cproductorid 生产厂商
|
|
||||||
// cprojectid 项目
|
|
||||||
// vsrctrantypeid 来源交易类型
|
|
||||||
// vsrctrantype 来源交易类型编码
|
|
||||||
// vsrctype 来源单据类型
|
|
||||||
// vsrcid 来源单据
|
|
||||||
// vsrccode 来源单据号
|
|
||||||
// vsrcbid 来源单据明细
|
|
||||||
// vsrcrowno 来源单据行号
|
|
||||||
// crequireorg 需求库存组织最新版本
|
|
||||||
// crequireorgvid 需求库存组织
|
|
||||||
// vfirsttrantypeid 源头交易类型
|
|
||||||
// vfirsttrantype 源头交易类型编码
|
|
||||||
// vfirsttype 源头单据类型
|
|
||||||
// vfirstid 源头单据
|
|
||||||
// vfirstcode 源头单据号
|
|
||||||
// vfirstbid 源头单据明细
|
|
||||||
// vfirstrowno 源头单据行号
|
|
||||||
// vfirstmotype 源头生产订单类型
|
|
||||||
// cfirstmoid 源头生产订单
|
|
||||||
// vfirstmocode 源头生产订单号
|
|
||||||
// cfirstmobid 源头生产订单行
|
|
||||||
// vfirstmorowno 源头生产订单行号
|
|
||||||
// cinwarehouseid 入库仓库
|
|
||||||
// vbillcode 流程生产订单号
|
|
||||||
// cpmohid 流程生产订单表头主键
|
|
||||||
// vsalebillcode 销售订单号
|
|
||||||
// temp_mainmaterialid 主产品最新版本
|
|
||||||
// temp_mainmaterialvid 主产品
|
|
||||||
// temp_mainbid 主产品行
|
|
||||||
// ninnum 合格入库主数量
|
|
||||||
Map<String, SQLParameter> itemMap = new HashMap<>();
|
Map<String, SQLParameter> itemMap = new HashMap<>();
|
||||||
StringBuilder bodySqlBuilder = new StringBuilder();
|
// 构建明细表SQL
|
||||||
bodySqlBuilder.append("INSERT INTO BIPOrderDetailTab (");
|
String bodySql = buildInsertSQL(BODY_TABLE, BODY_COLUMNS);
|
||||||
bodySqlBuilder.append("cmoid, vrowno, pk_group, pk_org, fitemstatus, ");
|
|
||||||
bodySqlBuilder.append("cmaterialvid, cunitid, castunitid, nnum, nastnum, ");
|
|
||||||
bodySqlBuilder.append("vchangerate, nplanputastnum, nplanputnum, nmmastnum, nmmnum, ");
|
|
||||||
bodySqlBuilder.append("cdeptid, cdeptvid, cemployeeid, tplanstarttime, tplanendtime, ");
|
|
||||||
bodySqlBuilder.append("twillendtime, tactstarttime, tactendtime, mocloser, tmoclosedtime, ");
|
|
||||||
bodySqlBuilder.append("cbatchid, vbatchcode, vnote, cproductorid, cprojectid, ");
|
|
||||||
bodySqlBuilder.append("vsrctrantypeid, vsrctrantype, vsrctype, vsrcid, vsrccode, ");
|
|
||||||
bodySqlBuilder.append("vsrcbid, vsrcrowno, crequireorg, crequireorgvid, vfirsttrantypeid, ");
|
|
||||||
bodySqlBuilder.append("vfirsttrantype, vfirsttype, vfirstid, vfirstcode, vfirstbid, ");
|
|
||||||
bodySqlBuilder.append("vfirstrowno, vfirstmotype, cfirstmoid, vfirstmocode, cfirstmobid, ");
|
|
||||||
bodySqlBuilder.append("vfirstmorowno, cinwarehouseid, vbillcode, cpmohid, vsalebillcode, ");
|
|
||||||
bodySqlBuilder.append("temp_mainmaterialid, temp_mainmaterialvid, temp_mainbid, ninnum");
|
|
||||||
bodySqlBuilder.append(") VALUES (");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?").append(", ");
|
|
||||||
bodySqlBuilder.append("?");
|
|
||||||
bodySqlBuilder.append(")");
|
|
||||||
// 添加表体参数
|
// 添加表体参数
|
||||||
SQLParameter bodyParams = new SQLParameter();
|
SQLParameter bodyParams = buildBodyParameters(item, pmoHeadVO);
|
||||||
bodyParams.addParam(item.getCmoid());
|
itemMap.put(bodySql, bodyParams);
|
||||||
bodyParams.addParam(item.getVrowno());
|
|
||||||
bodyParams.addParam(item.getPk_group());
|
|
||||||
bodyParams.addParam(item.getPk_org());
|
|
||||||
bodyParams.addParam(item.getFitemstatus());
|
|
||||||
bodyParams.addParam(item.getCmaterialvid());
|
|
||||||
bodyParams.addParam(item.getCunitid());
|
|
||||||
bodyParams.addParam(item.getCastunitid());
|
|
||||||
bodyParams.addParam(skipNull(item.getNnum()));
|
|
||||||
bodyParams.addParam(skipNull(item.getNastnum()));
|
|
||||||
bodyParams.addParam(item.getVchangerate());
|
|
||||||
bodyParams.addParam(skipNull(item.getNplanputastnum()));
|
|
||||||
bodyParams.addParam(skipNull(item.getNplanputnum()));
|
|
||||||
bodyParams.addParam(skipNull(item.getNmmastnum()));
|
|
||||||
bodyParams.addParam(skipNull(item.getNmmnum()));
|
|
||||||
bodyParams.addParam(item.getCdeptid());
|
|
||||||
bodyParams.addParam(item.getCdeptvid());
|
|
||||||
bodyParams.addParam(item.getCemployeeid());
|
|
||||||
bodyParams.addParam(skipNull(item.getTplanstarttime()));
|
|
||||||
bodyParams.addParam(skipNull(item.getTplanendtime()));
|
|
||||||
bodyParams.addParam(skipNull(item.getTwillendtime()));
|
|
||||||
bodyParams.addParam(skipNull(item.getTactstarttime()));
|
|
||||||
bodyParams.addParam(skipNull(item.getTactendtime()));
|
|
||||||
bodyParams.addParam(item.getMocloser());
|
|
||||||
bodyParams.addParam(item.getTmoclosedtime());
|
|
||||||
bodyParams.addParam(item.getCbatchid());
|
|
||||||
bodyParams.addParam(item.getVbatchcode());
|
|
||||||
bodyParams.addParam(item.getVnote());
|
|
||||||
bodyParams.addParam(item.getCproductorid());
|
|
||||||
bodyParams.addParam(item.getCprojectid());
|
|
||||||
bodyParams.addParam(item.getVsrctrantypeid());
|
|
||||||
bodyParams.addParam(item.getVsrctrantype());
|
|
||||||
bodyParams.addParam(item.getVsrctype());
|
|
||||||
bodyParams.addParam(item.getVsrcid());
|
|
||||||
bodyParams.addParam(item.getVsrccode());
|
|
||||||
bodyParams.addParam(item.getVsrcbid());
|
|
||||||
bodyParams.addParam(item.getVsrcrowno());
|
|
||||||
bodyParams.addParam(item.getCrequireorg());
|
|
||||||
bodyParams.addParam(item.getCrequireorgvid());
|
|
||||||
bodyParams.addParam(item.getVfirsttrantypeid());
|
|
||||||
bodyParams.addParam(item.getVfirsttrantype());
|
|
||||||
bodyParams.addParam(item.getVfirsttype());
|
|
||||||
bodyParams.addParam(item.getVfirstid());
|
|
||||||
bodyParams.addParam(item.getVfirstcode());
|
|
||||||
bodyParams.addParam(item.getVfirstbid());
|
|
||||||
bodyParams.addParam(item.getVfirstrowno());
|
|
||||||
bodyParams.addParam(item.getVfirstmotype());
|
|
||||||
bodyParams.addParam(item.getCfirstmoid());
|
|
||||||
bodyParams.addParam(item.getVfirstmocode());
|
|
||||||
bodyParams.addParam(item.getCfirstmobid());
|
|
||||||
bodyParams.addParam(item.getVfirstmorowno());
|
|
||||||
bodyParams.addParam(item.getCinwarehouseid());
|
|
||||||
bodyParams.addParam(pmoHeadVO.getVbillcode());
|
|
||||||
bodyParams.addParam(item.getCpmohid());
|
|
||||||
bodyParams.addParam(item.getVsalebillcode());
|
|
||||||
bodyParams.addParam(item.getTemp_mainmaterialid());
|
|
||||||
bodyParams.addParam(item.getTemp_mainmaterialvid());
|
|
||||||
bodyParams.addParam(item.getTemp_mainbid());
|
|
||||||
bodyParams.addParam(skipNull(item.getNinnum()));
|
|
||||||
itemMap.put(bodySqlBuilder.toString(), bodyParams);
|
|
||||||
bodyParameterList.add(itemMap);
|
bodyParameterList.add(itemMap);
|
||||||
}
|
}
|
||||||
pushData(headSqlBuilder.toString(), headParams, bodyParameterList);
|
pushData(headSql, headParams, bodyParameterList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,15 +121,15 @@ public class AfterApproveSyncImsRule implements IRule<PMOAggVO> {
|
||||||
*/
|
*/
|
||||||
private void pushData(String headSql, SQLParameter headParams, List<Map<String, SQLParameter>> bodyParameterList) throws BusinessException {
|
private void pushData(String headSql, SQLParameter headParams, List<Map<String, SQLParameter>> bodyParameterList) throws BusinessException {
|
||||||
logger.error("gyIms-PMO-headSql = " + headSql);
|
logger.error("gyIms-PMO-headSql = " + headSql);
|
||||||
int i = getImsDao().executeUpdate(headSql, headParams);
|
int HeadRowsAffected = getImsDao().executeUpdate(headSql, headParams);
|
||||||
if (i != 1) {
|
if (HeadRowsAffected != 1) {
|
||||||
NCCForUAPLogger.error("gyIms-PMO-headSql = " + headSql);
|
NCCForUAPLogger.debug("gyIms-PMO-headSql = " + headSql);
|
||||||
}
|
}
|
||||||
for (Map<String, SQLParameter> map : bodyParameterList) {
|
for (Map<String, SQLParameter> map : bodyParameterList) {
|
||||||
String bodySql = map.keySet().iterator().next();
|
String bodySql = map.keySet().iterator().next();
|
||||||
int j = getImsDao().executeUpdate(bodySql, map.get(bodySql));
|
int bodyRowsAffected = getImsDao().executeUpdate(bodySql, map.get(bodySql));
|
||||||
if (j != 1) {
|
if (bodyRowsAffected != 1) {
|
||||||
NCCForUAPLogger.error("gyIms-PMO-bodySql = " + bodySql);
|
NCCForUAPLogger.debug("gyIms-PMO-bodySql = " + bodySql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// logger.error("gyIms-PMO-res = " + result);
|
// logger.error("gyIms-PMO-res = " + result);
|
||||||
|
|
@ -371,6 +149,71 @@ public class AfterApproveSyncImsRule implements IRule<PMOAggVO> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildInsertSQL(String tableName, String[] columns) {
|
||||||
|
int columnCount = columns.length;
|
||||||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||||||
|
sqlBuilder.append("INSERT INTO ").append(tableName).append(" (");
|
||||||
|
|
||||||
|
for (int i = 0; i < columnCount; i++) {
|
||||||
|
String column = columns[i];
|
||||||
|
sqlBuilder.append(column);
|
||||||
|
if (i < columnCount - 1) {
|
||||||
|
sqlBuilder.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlBuilder.append(") VALUES (");
|
||||||
|
for (int i = 0; i < columnCount; i++) {
|
||||||
|
sqlBuilder.append("?");
|
||||||
|
if (i < columnCount - 1) {
|
||||||
|
sqlBuilder.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sqlBuilder.append(")");
|
||||||
|
return sqlBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private SQLParameter buildHeadParameters(PMOHeadVO pmoHeadVO) {
|
||||||
|
SQLParameter headParams = new SQLParameter();
|
||||||
|
for (String column : HEAD_COLUMNS) {
|
||||||
|
if ("status".equals(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Object value = pmoHeadVO.getAttributeValue(column);
|
||||||
|
if (headNumFields.contains(column)) {
|
||||||
|
value = skipNullForNumber(value);
|
||||||
|
} else {
|
||||||
|
value = skipNull(value);
|
||||||
|
}
|
||||||
|
headParams.addParam(value);
|
||||||
|
}
|
||||||
|
// status C=创建U=修改2=处理完成
|
||||||
|
headParams.addParam("C");// 默认状态为C(新增)
|
||||||
|
return headParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SQLParameter buildBodyParameters(PMOItemVO item, PMOHeadVO pmoHeadVO) {
|
||||||
|
SQLParameter bodyParams = new SQLParameter();
|
||||||
|
for (String column : BODY_COLUMNS) {
|
||||||
|
Object value;
|
||||||
|
if ("vbillcode".equals(column)) {
|
||||||
|
value = pmoHeadVO.getAttributeValue(column);
|
||||||
|
} else {
|
||||||
|
value = item.getAttributeValue(column);
|
||||||
|
}
|
||||||
|
// 根据字段类型选择不同的空值处理方式
|
||||||
|
if (bodyNumFields.contains(column)) {
|
||||||
|
value = skipNullForNumber(value);
|
||||||
|
} else {
|
||||||
|
value = skipNull(value);
|
||||||
|
}
|
||||||
|
bodyParams.addParam(value);
|
||||||
|
}
|
||||||
|
return bodyParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空值安全处理方法
|
* 空值安全处理方法
|
||||||
*
|
*
|
||||||
|
|
@ -393,5 +236,29 @@ public class AfterApproveSyncImsRule implements IRule<PMOAggVO> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专门处理数值类型的空值
|
||||||
|
*
|
||||||
|
* @param value 需要处理的值
|
||||||
|
* @return 如果为null则返回0,否则返回转换后的数值
|
||||||
|
*/
|
||||||
|
private Object skipNullForNumber(Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// 数值类型转换
|
||||||
|
if (value instanceof nc.vo.pub.lang.UFDouble) {
|
||||||
|
return ((nc.vo.pub.lang.UFDouble) value).toDouble();
|
||||||
|
} else if (value instanceof Number) {
|
||||||
|
return ((Number) value).doubleValue();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(value.toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue