Merge remote-tracking branch 'origin/main' into main

# Conflicts:
#	mmpac/src/private/nc/bs/mmpac/pickm/bp/PickmApproveBP.java
This commit is contained in:
jiashuai 2025-10-09 15:52:30 +08:00
commit 1ebb7a997b
26 changed files with 1621 additions and 107 deletions

View File

@ -1,6 +1,7 @@
package nccloud.api.impl.ic.onhand;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.itf.ic.onhand.OnhandResService;
import nc.vo.ic.onhand.entity.OnhandDimVO;
import nc.vo.ic.onhand.entity.OnhandVO;
@ -14,6 +15,7 @@ import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
import nccloud.openapi.scmpub.pubitf.IJsonParamMapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -59,7 +61,7 @@ public class APIOnhandQueryIpml implements IAPIOnhandQuery {
public OnhandVO[] queryOnhandVOByDimsNoTrans(List<Map<String, Object>> paramMapList) throws BusinessException {
//±<EFBFBD><EFBFBD>ה<EFBFBD>מ¼ל²י
// 必输项检查
try {
List<OnhandDimVO> onhandDimVOS = new ArrayList<>();
for (Map<String, Object> paramMap : paramMapList) {
@ -79,6 +81,7 @@ public class APIOnhandQueryIpml implements IAPIOnhandQuery {
return null;
}
}
@Override
public OnhandVO[] queryOnhandVOByDims(List<Map<String, Object>> paramMapList) throws Exception {
// ±ØÊäÏî¼ì²é
@ -120,6 +123,52 @@ public class APIOnhandQueryIpml implements IAPIOnhandQuery {
return onhandVOs;
}
@Override
public OnhandVO[] onhandQueryBatch(Map<String, Object> paramMap) throws Exception {
try {
List<OnhandDimVO> onhandDimVOS = new ArrayList<>();
String pk_org = paramMap.get("pk_org").toString();
if (paramMap.get("cmaterialoid") != null && paramMap.get("cmaterialoid") instanceof List) {
List<String> cmaterialoids = (List<String>) paramMap.get("cmaterialoid");
for (String cmaterialoid : cmaterialoids) {
Map<String, Object> selMap = new HashMap<>();
selMap.put("pk_org", pk_org);
selMap.put("cmaterialoid", cmaterialoid);
// 翻译
selMap = TransferCodeToPKTool.doTranslateFields(jsonParamMapping, selMap);
OnhandDataSupplement dataSupplement = new OnhandDataSupplement();
OnhandDimVO onhandDimVO = new OnhandDimVO();
try {
onhandDimVO = dataSupplement.process(selMap);
} catch (Exception e) {
Logger.error(e);
}
// 跳过查不出数据的物料
if (onhandDimVO == null || onhandDimVO.getCmaterialoid() == null) {
continue;
}
onhandDimVOS.add(onhandDimVO);
}
} else {
Map<String, Object> selMap = new HashMap<>();
selMap.put("pk_org", pk_org);
// 翻译
selMap = TransferCodeToPKTool.doTranslateFields(jsonParamMapping, selMap);
OnhandDataSupplement dataSupplement = new OnhandDataSupplement();
OnhandDimVO onhandDimVO = new OnhandDimVO();
onhandDimVO = dataSupplement.process(selMap);
onhandDimVOS.add(onhandDimVO);
}
OnhandVO[] onhandVOs = NCLocator.getInstance().lookup(OnhandResService.class)
.queryOnhandVOByDims(onhandDimVOS.toArray(new OnhandDimVO[0]));
return onhandVOs;
} catch (Exception e) {
ExceptionUtils.marsh(e);
return null;
}
}
// ±ØÊäÏîУÑé
private void requiredFieldCheck(String[] requiredField, Map<String, Object> paramMap) {

View File

@ -46,4 +46,13 @@ public interface IAPIOnhandQuery {
* @throws Exception 当查询操作失败时抛出的异常
*/
OnhandVO[] queryOnhandVOByCondition(Map<String, Object> paramMap) throws Exception;
/**
* 根据查询条件查询多个物料的现存量信息
*
* @param paramMap 参数映射列表每个映射包含一组查询条件
* @return OnhandVO[] 查询到的现存量信息数组
* @throws Exception 当查询操作失败时抛出的异常
*/
OnhandVO[] onhandQueryBatch(Map<String, Object> paramMap) throws Exception;
}

View File

@ -773,7 +773,7 @@ public class OnhandResource {
}
try {
OnhandVO[] onhandVOs = NCLocator.getInstance().lookup(IAPIOnhandQuery.class)
.queryOnhandVOByDims(paramMap);
.onhandQueryBatch(paramMap);
// 对数据进行整合组装,返回物料+仓库+数量
if (null != onhandVOs && onhandVOs.length > 0) {
// 收集所有物料和仓库ID

View File

@ -1,7 +1,6 @@
package nc.bs.mmpac.pickm.bp;
import nc.bs.mmpac.pickm.bp.rule.AfterApproveRuleHighpressureIms;
import nc.bs.mmpac.pickm.bp.rule.AfterApproveRuleHighpressureMes;
import nc.bs.mmpac.pickm.bp.rule.AfterApproveRuleSyncRZWMS;
import nc.bs.mmpac.pickm.plugin.PickmPluginPoint;
@ -29,8 +28,6 @@ public class PickmApproveBP {
processer.addAfterRule(pickmstatusFilterRule);
//备料计划审批后推送高压MES
processer.addAfterRule(new AfterApproveRuleHighpressureMes());
//备料计划审批后推送高压IMS
processer.addAfterRule(new AfterApproveRuleHighpressureIms());
}
private void addBeforeRule(CompareAroundProcesser<AggPickmVO> processer) {

View File

@ -62,7 +62,7 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
HYPubBO hybo = new HYPubBO();
JSONObject list = new JSONObject();
JSONArray jsonArray = new JSONArray();
String flags = "";//判断是否新增或修改
String flags = "";// 判断是否新增或修改
for (AggPickmVO vo : useVOs) {
PickmHeadVO pickmHeadVO = vo.getParentVO();
PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildrenVO();
@ -75,7 +75,7 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
JSONObject singleObj = new JSONObject();
// 创建子项数组
JSONArray contentArray = new JSONArray();
//自定义项19是Y时调用修改口若不是则调用新增口
// 自定义项19是Y时调用修改口若不是则调用新增口
String saleDef = pickmHeadVO.getVdef19() == null ? "" : pickmHeadVO.getVdef19();
if (!saleDef.equals("Y")) {
// 更新自定义项19为Y
@ -222,7 +222,10 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
jsonArray.add(singleObj);
list.put("list", jsonArray);
}
pushData(list, flags);
if (list != null && !list.isEmpty()) {
pushData(list, flags);
}
}
/**
@ -254,10 +257,8 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
);
logger.error("gyMes-Pickm-param = " + jsonStr);
String baseUrl = configParams.get("mesBaseUrl");
String requestUrl = "";
if (flags.equals("addOrder")) {
requestUrl = baseUrl + configParams.get("materialRequirementsAdd");
} else if (flags.equals("updateOrder")) {//调用修改口
String requestUrl = baseUrl + configParams.get("materialRequirementsAdd");
if (flags.equals("updateOrder")) {// 调用修改口
requestUrl = baseUrl + configParams.get("materialRequirementsUpdate");
}
logger.error("gyMes-Pickm-url = " + requestUrl);

View File

@ -56,15 +56,11 @@ public class PMOApproveBP {
// 审批后推送流程生产订单到艾普MES
processer.addAfterRule(new AfterApproveSyncEpicMesRule());
// 审批后推送流程生产订单到启源qms
// processer.addAfterRule(new AfterApproveSyncQMSRule());
// 流程生产订单审批后推送高压MES
processer.addAfterRule(new AfterApproveSyncHighpressureMesRule());
// processer.addAfterRule(new AfterApproveSyncQMSRule());
// 流程生产订单审批后推送高压MES
// processer.addAfterRule(new AfterApproveSyncHighpressureMesRule());
processer.addAfterRule(new AfterApproveSyncQMSRule());
// 流程生产订单审批后推送高压MES
processer.addAfterRule(new AfterApproveSyncHighpressureMesRule());
// processer.addAfterRule(new AfterApproveSyncEpicQMSRule());
// processer.addAfterRule(new AfterApproveSyncImsRule("Y"));
}
@ -95,5 +91,6 @@ public class PMOApproveBP {
processer.addAfterRule(new AfterUnApproveSyncEpicMesRule());
// 生产订单取消审批后推送高压MES
processer.addAfterRule(new AfterApproveCancelSyncHighpressureMesRule());
// processer.addAfterRule(new AfterApproveSyncImsRule("N"));
}
}

View File

@ -101,7 +101,9 @@ public class AfterApproveCancelSyncHighpressureMesRule implements IRule<PMOAggVO
list.put("bipChildId", result); // ×ÓÏîÖ÷¼üID
}
pushData(list);
if (list != null && !list.isEmpty()) {
pushData(list);
}
}
/**

View File

@ -221,7 +221,9 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
jsonArray.add(singleObj);
list.put("list", jsonArray);
}
pushData(list, flags);
if (list != null && !list.isEmpty()) {
pushData(list, flags);
}
}
/**
@ -235,10 +237,8 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
);
logger.error("gyMes-PMO-param = " + jsonStr);
String baseUrl = configParams.get("mesBaseUrl");
String requestUrl = "";
if (flags.equals("addOrder")) {
requestUrl = baseUrl + configParams.get("productionOrderAdd");
} else if (flags.equals("updateOrder")) {//调用修改口
String requestUrl = baseUrl + configParams.get("productionOrderAdd");
if (flags.equals("updateOrder")) {//调用修改口
requestUrl = baseUrl + configParams.get("productionOrderUpdate");
}
logger.error("gyMes-PMO-url = " + requestUrl);

View File

@ -87,10 +87,10 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
itemObj.put("sgdh", pmoHeadVO.getVbillcode());
itemObj.put("xshth", projectCode);
itemObj.put("htqdxh", item.getVfirstrowno());
itemObj.put("wlbh", mrlmap.get("code"));
itemObj.put("wlmc", mrlmap.get("name"));
itemObj.put("wlbh", mrlmap.get("code"));// ²úÆ·±àºÅ
itemObj.put("wlmc", mrlmap.get("name"));// ²úÆ·Ãû³Æ
String wlxhgg = MyHelper.skipNull(mrlmap.get("materialspec")) + MyHelper.skipNull(mrlmap.get("materialtype"));
itemObj.put("wlxhgg", wlxhgg);
itemObj.put("wlxhgg", wlxhgg);// ²úÆ·ÐͺŹæ¸ñ
itemObj.put("jhsl", item.getNastnum().toString());
UFDateTime tplanendtime = item.getTplanendtime();
String tplanendtimeStr = "";
@ -126,8 +126,8 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
logger.error("QMS-PMO-XB-res = " + result);
if (!"true".equals(resultObj.getString("success"))) {
// throw new BusinessException("QMS-PMO-XB-error:" + resultObj.getString("msg"));
logger.error("QMS-PMO-XB-error,result[" + resultObj.toJSONString() + "]");
throw new BusinessException("QMS-PMO-XB-error:" + resultObj.getString("message"));
}
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding='gb2312'?>
<module>
<rest>
<resource classname="nc.api.qc.resource.QcconclusionRestResource" exinfo="澗운데" />
<resource classname="nc.api.qc.resource.QcconclusionRestResource" exinfo="质检报告" />
</rest>
</module>

View File

@ -48,7 +48,7 @@ public class ReportInsertBP {
this.addAfterFinalRule(processer);
processer.before(aggVO);
BillInsert<ReportVO> bo = new BillInsert();
ReportVO[] vos = (ReportVO[])bo.insert(aggVO);
ReportVO[] vos = (ReportVO[]) bo.insert(aggVO);
processer.after(aggVO);
return vos;
}

View File

@ -73,9 +73,8 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
ArriveVO[] arriveVOS = billquery.query(firstIds.toArray(new String[0]));
buildSyncData(arriveVOS);
}
// ×éÖ¯Êý¾Ý
// buildSyncData(reportVOS);
} catch (Exception e) {
logger.error("SyncQcQmsRule-exp:" + e.getMessage(), e);
ExceptionUtils.wrappException(e);
}
}
@ -107,10 +106,8 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
String creatorName = MyHelper.getStrValByCondition("sm_user", UserVO.USER_NAME,
UserVO.CUSERID + " = '" + hvo.getBillmaker() + "'");
JSONObject singleObj = new JSONObject();
String cghth = "";
if (bvo != null && bvo.length > 0) {
cghth = bvo[0].getVsourcecode();
}
// 采购合同号
String cghth = getCghthVal(hvo, bvo);
// 启源送检单主表
long cts = System.currentTimeMillis();
singleObj.put("batchid", cts);
@ -123,7 +120,7 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
singleObj.put("bz", hvo.getVmemo());// 摘要备注用于填写送检单的补充说明信息
// 查询关联的质检报告-传入启源送检单的明细
HYPubBO hybo = new HYPubBO();
ReportItemVO[] reportItemVOS = (ReportItemVO[]) hybo.queryByCondition(ReportItemVO.class, " and cfirstid = '" + pk_arriveorder + "'");
ReportItemVO[] reportItemVOS = (ReportItemVO[]) hybo.queryByCondition(ReportItemVO.class, " cfirstid = '" + pk_arriveorder + "'");
JSONArray contentArray = new JSONArray();
for (ReportItemVO reportItemVO : reportItemVOS) {
String pkReportbill = reportItemVO.getPk_reportbill();
@ -143,6 +140,8 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
itemObj.put("sjsl", reportHeaderVO.getNapplynum().toString()); // 送检数量设计单位按设计计量单位统计的送检数量
itemObj.put("jldw", cunitname); // 计量单位
itemObj.put("bz", reportItemVO.getVbdef1()); // 明细备注用于填写该送检物料的补充说明
itemObj.put("bipzyid", pkReportbill); // 质检报告ID
itemObj.put("bipqdid", reportItemVO.getPk_reportbill_b()); // 质检报告明细ID
contentArray.add(itemObj);
}
singleObj.put("Content", contentArray);
@ -150,6 +149,35 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
}
}
private String getCghthVal(ArriveHeaderVO hvo, ArriveItemVO[] bvo) throws BusinessException {
String cghth = "";
String pkPupsndoc = hvo.getPk_pupsndoc();
// 查询采购员名称
String name = "";
if (pkPupsndoc != null && !pkPupsndoc.isEmpty() && !"~".equals(pkPupsndoc)) {
name = MyHelper.getStrValByCondition(PsndocVO.getDefaultTableName(), PsndocVO.NAME,
PsndocVO.PK_PSNDOC + " = '" + pkPupsndoc + "'");
}
if (bvo != null && bvo.length > 0) {
StringBuilder cghthBuilder = new StringBuilder();
for (int i = 0; i < bvo.length; i++) {
String vsourcecode = bvo[i].getVsourcecode();
if (vsourcecode == null || vsourcecode.isEmpty() || "~".equals(vsourcecode)) {
continue;
}
if (i > 0) {
cghthBuilder.append(",");
}
cghthBuilder.append(vsourcecode);
if (!name.isEmpty()) {
cghthBuilder.append(name);
}
}
cghth = cghthBuilder.toString();
}
return cghth;
}
private void buildSyncData1(ReportVO[] useVOs) throws BusinessException {
for (ReportVO vo : useVOs) {
ReportHeaderVO hvo = vo.getHVO();
@ -253,8 +281,8 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
logger.error("QMS-QC-res = " + result);
if (!"true".equals(resultObj.getString("success"))) {
// throw new BusinessException("QMS-QC-error:" + resultObj.getString("msg"));
logger.error("QMS-QC-error,result[" + resultObj.toJSONString() + "]");
throw new BusinessException("QMS-QC-error:" + resultObj.getString("message"));
}
}

View File

@ -115,14 +115,19 @@ public class AfterApprovingSynchronizeRuleQMS implements IRule<SaleOrderVO> {
itemObj.put("wlbh", mrlmap.get("code"));
itemObj.put("wlmc", mrlmap.get("name"));
itemObj.put("wlxhgg", ((String) mrlmap.get("materialspec") != null ? mrlmap.get("materialspec").toString() : "") + ((String) mrlmap.get("materialtype") != null ? mrlmap.get("materialtype").toString() : ""));
String wlxhgg = (mrlmap.get("materialspec") != null ? mrlmap.get("materialspec").toString() : "") + (mrlmap.get("materialtype") != null ? mrlmap.get("materialtype").toString() : "");
itemObj.put("wlxhgg", wlxhgg);
itemObj.put("dhsl", item.getNastnum().doubleValue());
itemObj.put("xsj", item.getNqtorigtaxprice().doubleValue());
itemObj.put("bxzje", item.getNqtorigtaxprice().doubleValue());
itemObj.put("jhrq", item.getDsenddate().toString().substring(0, 10));
if (item.getDsenddate() != null) {
itemObj.put("jhrq", item.getDsenddate().toString().substring(0, 10));
} else {
itemObj.put("jhrq", "");
}
itemObj.put("bz", item.getVrownote());
Object pk_project = hybo.findColValue("bd_project", "project_name", " pk_project = '" + item.getCprojectid() + "' ");
itemObj.put("xmmc", pk_project);
Object project_name = hybo.findColValue("bd_project", "project_name", " project_name = '" + item.getCprojectid() + "' ");
itemObj.put("xmmc", project_name);
contentArray.add(itemObj);
}
@ -176,8 +181,8 @@ public class AfterApprovingSynchronizeRuleQMS implements IRule<SaleOrderVO> {
String requestUrl = baseUrl + reqUrl;
logger.error("QMS-SaleOrder-url = " + requestUrl);
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
JSONObject resultObj = JSONObject.parseObject(result);
logger.error("QMS-SaleOrder-res = " + result);
JSONObject resultObj = JSONObject.parseObject(result);
if (!"true".equals(resultObj.getString("success"))) {
logger.error("QMS-SaleOrder-error,result[" + resultObj.toJSONString() + "]");

View File

@ -100,7 +100,10 @@ public class AfterSoCancelSyncRuleGyMes implements IRule<SaleOrderVO> {
list.put("bipOrderId", result); // 主键ID
list.put("bipUpdateBy", bipUpdateBy);// 取消审批人
pushData(list);
if (list != null && !list.isEmpty()) {
pushData(list);
}
}
}

View File

@ -110,7 +110,9 @@ public class AfterSoSyncRuleGyMes implements IRule<SaleOrderVO> {
itemObj.put("remark", item.getVrownote());// 备注
itemObj.put("bipCreateBy", createName);// 创建人
itemObj.put("customers", customerName);// 客户
pushData(itemObj);
if (itemObj != null && !itemObj.isEmpty()) {
pushData(itemObj);
}
}
} else {
@ -131,7 +133,9 @@ public class AfterSoSyncRuleGyMes implements IRule<SaleOrderVO> {
itemObj.put("remark", item.getVrownote());// 备注
itemObj.put("bipUpdateBy", createName);// 修改人
itemObj.put("customers", customerName);// 客户
pushData_Update(itemObj);
if (itemObj != null && !itemObj.isEmpty()) {
pushData_Update(itemObj);
}
}
}

View File

@ -170,7 +170,7 @@ public class ApproveSaleOrderAction {
// 在审批后推送到QMS系统
processer.addAfterRule(new AfterApprovingSynchronizeRuleQMS());
// 在审批后推送到高压MES
processer.addAfterRule(new AfterSoSyncRuleGyMes());
processer.addAfterRule(new AfterSoSyncRuleGyMes());
}
private boolean isExistDelivery(String ctranstype) {

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import nc.bs.dao.BaseDAO;
import nc.bs.logging.Log;
import nc.bs.uapbd.util.MyHelper;
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
@ -13,11 +14,14 @@ import nc.vo.bd.bom.bom0202.entity.AggBomVO;
import nc.vo.bd.bom.bom0202.entity.BomItemVO;
import nc.vo.bd.bom.bom0202.entity.BomVO;
import nc.vo.bd.material.MaterialVO;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* BOM修改后同步艾普MES的BOM
@ -30,6 +34,14 @@ public class BomSaveAfterEpicMesRule implements IRule<AggBomVO> {
private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
private static final String reqUrl = "/prj-v5-web/ext/api/bom";
private Map<String, String> configParams;
private BaseDAO dao;
public BaseDAO getDao() {
if (dao == null) {
dao = new BaseDAO();
}
return dao;
}
@Override
public void process(AggBomVO[] vos) {
@ -38,10 +50,16 @@ public class BomSaveAfterEpicMesRule implements IRule<AggBomVO> {
configParams = MyHelper.getConfigParams("Dldz-config", null);
JSONArray data = buildSyncData(vos);
if (!data.isEmpty()) {
pushData(data);
pushData(data, vos);
}
} catch (BusinessException e) {
ExceptionUtils.wrappException(e);
String message = e.getMessage();
logDl.error("EpicMes-BOM-exp:" + message, e);
if (message != null && message.contains("Connection timed out")) {
handleSyncBomExp(vos, "N", message);
} else {
ExceptionUtils.wrappException(e);
}
}
}
}
@ -112,7 +130,7 @@ public class BomSaveAfterEpicMesRule implements IRule<AggBomVO> {
/**
* 推送同步数据
*/
private void pushData(JSONArray param) throws BusinessException {
private void pushData(JSONArray param, AggBomVO[] vos) throws BusinessException {
// 转json字符串的时候保留null值
String jsonStr = JSON.toJSONString(param,
SerializerFeature.WriteMapNullValue,
@ -130,6 +148,34 @@ public class BomSaveAfterEpicMesRule implements IRule<AggBomVO> {
if (!"1".equals(resultObj.getString("flag"))) {
// throw new BusinessException("EpicMes-BOM-error:" + resultObj.getString("msg"));
logDl.error("EpicMes-BOM-error,result[" + resultObj.toJSONString() + "]");
// 保存BOM推送的错误信息
handleSyncBomExp(vos, "N", resultObj.getString("msg"));
} else {
handleSyncBomExp(vos, "Y", "");
}
}
/**
* 更新错误信息
*/
private void handleSyncBomExp(AggBomVO[] vos, String errorCode, String errorMsg) {
if (MMValueCheck.isEmpty(vos)) {
return;
}
Set<String> ids = new HashSet<>();
for (AggBomVO vo : vos) {
BomVO hvo = (BomVO) vo.getParentVO();
String cbomid = hvo.getCbomid();
ids.add(cbomid);
}
try {
String inSql = SqlUtils.getInStr("cbomid", ids.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update bd_bom set hvdef19 = '[errorCode]' where " + inSql;
updateSql = updateSql.replace("[errorCode]", errorCode);
int updatedRows = getDao().executeUpdate(updateSql);
} catch (BusinessException e) {
logDl.error("EpicMes-BOM-handleSyncBomExp = " + e.getMessage(), e);
}
}
}

View File

@ -0,0 +1,467 @@
package nc.bs.uapbd.bip.workplugin;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.ic.m45.insert.InsertBP;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.bs.trade.business.HYPubBO;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.pubimpl.ic.api.maintain.BillMaintainTool;
import nc.vo.ia.mi2.entity.I2BillVO;
import nc.vo.ia.mi2.entity.I2HeadVO;
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
import nc.vo.ic.m45.entity.PurchaseInVO;
import nc.vo.ic.org.OrgInfoQuery;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
import nc.vo.scmpub.res.billtype.ICBillType;
import nccloud.api.impl.ic.m45.check.CheckPurchaseInSaveValidator;
import nccloud.api.impl.ic.m45.fill.PurchaseInSaveFillValue;
import nccloud.openapi.ic.util.ICAPILocationVOUtils;
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
import org.eclipse.swt.internal.C;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ErpIaI2billFromGyImsPlugin implements IBackgroundWorkPlugin {
@Override
public PreAlertObject executeTask(BgWorkingContext bgWorkingContext) throws BusinessException {
BaseDAO imsDao= new BaseDAO("gyims");
// 禁用时间戳ts
imsDao.setAddTimeStamp(false);
// 查询高压ims中间表需要同步的数据
String sql = " \t\tSELECT\n" +
"\t* \n" +
"from BIPInputMainTab a " +
"where a.status !='2'";
List<Map<String,Object>> remain = (List<Map<String, Object>>) imsDao.executeQuery(sql, new MapListProcessor());
if (remain != null && remain.size() > 0) {
try{
List<PurchaseInVO> list = new ArrayList<PurchaseInVO>();
for (Map<String, Object> map : remain) {
HYPubBO hy = new HYPubBO();
PurchaseInVO vo = new PurchaseInVO();
PurchaseInHeadVO head = new PurchaseInHeadVO();
// 按数据库字段名直接调用对应setter方法set+字段名
head.setCgeneralhid((String) map.get("cgeneralhid"));
head.setPk_group(InvocationInfoProxy.getInstance().getGroupId());
map.put("pk_org","C047");
map.put("pk_org_v","C047");
// OrgVO orgvo = (OrgVO)hy.queryByPrimaryKey(OrgVO.class, );
Object pk_org = hy.findColValue("org_stockorg", "pk_org", "code = '"+map.get("pk_org")+"' and nvl(dr,0)=0 and islastversion='Y' ");
head.setPk_org((String) pk_org); // 对应字段pk_org
// Object pk_org_v = hy.findColValue("org_stockorg_v", "pk_vid", "pk_stockorg = '"+pk_org+"' ");
Object pk_org_v = hy.findColValue("org_stockorg_v", "pk_vid", "code = '"+map.get("pk_org")+"' ");
head.setPk_org_v((String) pk_org_v); // 对应字段pk_org_v
Object busicode = hy.findColValue("bd_busitype", "pk_busitype", "busicode = '"+map.get("busicode")+"' ");
head.setCbiztype((String) busicode);
head.setVbillcode((String) map.get("vbillcode"));
// Object cwarehouseid = hy.findColValue("bd_stordoc", "pk_stordoc", " code = '"+map.get("cwarehouseid")+"' ");
Object cwarehouseid = hy.findColValue("bd_stordoc", "pk_stordoc", " code = '"+"C047002"+"' ");
head.setCwarehouseid((String) cwarehouseid);
head.setDbilldate(new UFDate(String.valueOf(map.get("dbilldate"))) ); // 日期类型
map.put("vtrantypecode","45-Cxx-CI02");
head.setVtrantypecode((String) map.get("vtrantypecode"));
Object ctrantypeid = hy.findColValue("bd_billtype", "pk_billtypeid", " pk_billtypecode = '"+map.get("vtrantypecode")+"' and dr='0' ");
head.setCtrantypeid((String) ctrantypeid);
Object cwhsmanagerid = hy.findColValue("bd_psndoc", "pk_psndoc", " code = '"+map.get("cwhsmanagerid")+"' and dr='0' ");
head.setCwhsmanagerid((String)cwhsmanagerid);
Object cdptid = hy.findColValue("org_dept", "pk_dept", " code = '"+map.get("cdptid")+"' and dr='0' ");
head.setCdptid((String) cdptid);
Object cbizid = hy.findColValue("bd_psndoc", "pk_psndoc", " code = '"+map.get("cbizid")+"' and dr='0' ");
head.setCbizid((String) cbizid);
head.setNtotalnum(new UFDouble(String.valueOf(map.get("ntotalnum")))); // 数字类型
head.setVnote((String) map.get("vnote"));
// head.setStatus((Integer) map.get("status"));
head.setFbillflag(2);
Object billmaker = hy.findColValue("sm_user", "cuserid", " user_code = '"+map.get("billmaker")+"' and dr='0' ");
head.setBillmaker((String) billmaker);
Object approver = hy.findColValue("sm_user", "cuserid", " user_code = '"+map.get("approver")+"' and dr='0' ");
head.setApprover((String)approver);
if(map.get("taudittime") !=null){
head.setTaudittime(new UFDate(String.valueOf(map.get("taudittime"))) ); // 日期类型
}
map.put("cpayfinorgoid","C003");
Object cpayfinorgoid = hy.findColValue("org_financeorg", "pk_financeorg", " code = '"+map.get("cpayfinorgoid")+"' and dr='0' ");
if(cpayfinorgoid !=null){
head.setCpayfinorgoid((String) cpayfinorgoid);
}
Object cfanaceorgoid = hy.findColValue("org_financeorg", "pk_financeorg", " code = '"+map.get("cfanaceorgoid")+"' and dr='0' ");
head.setCfanaceorgoid((String) cfanaceorgoid); // 注意原字段名是否正确org_financeorg
Object cpurorgoid = hy.findColValue("org_purchaseorg", "pk_purchaseorg", " code = '"+map.get("cpurorgoid")+"' and dr='0' ");
head.setCpurorgoid((String) cpurorgoid);
Object cvendorid = hy.findColValue("bd_supplier", "pk_supplier", " code = '"+map.get("cvendorvid")+"' and dr='0' ");
head.setCvendorid((String)cvendorid);
Object cvendorvid = hy.findColValue("bd_supplier_v", "pk_supplier_v", " pk_supplier = '"+cvendorid+"' and dr='0' ");
head.setCvendorvid((String)cvendorvid);
head.setDmakedate(new UFDate(String.valueOf(map.get("dmakedate")))); // 日期类型
Object csendcountryid = hy.findColValue("bd_countryzone", "pk_country", " code = '"+"CN"+"' and dr='0' ");
head.setCsendcountryid((String) csendcountryid);
Object crececountryid = hy.findColValue("bd_countryzone", "pk_country", " code = '"+"CN"+"' and dr='0' ");
head.setCrececountryid((String) crececountryid);
Object ctaxcountryid = hy.findColValue("bd_countryzone", "pk_country", " code = '"+"CN"+"' and dr='0' ");
head.setCtaxcountryid((String) ctaxcountryid);
head.setFbuysellflag(2 ); // 数值类型按需调整
// 将head设置到vo中
vo.setParent(head);
String bodysql = " \t\tSELECT\n" +
"\t* \n" +
"from BIPInputDetailTab a " +
"where a.cgeneralhid ='"+map.get("cgeneralhid")+"'";
List<Map<String,Object>> bodys = (List<Map<String, Object>>) imsDao.executeQuery(bodysql, new MapListProcessor());
List<PurchaseInBodyVO> list1 = new ArrayList<>();
for(Map<String,Object> body : bodys) {
HYPubBO hy1 = new HYPubBO();
PurchaseInBodyVO bodyVO = new PurchaseInBodyVO();
// 主键及关联字段
bodyVO.setCgeneralbid((String) body.get("cgeneralbid")); // 主键(UFID)org_corp
bodyVO.setCgeneralhid((String) body.get("cgeneralhid")); // 关联主表ID
body.put("corpoid","C003");
Object corpoid = hy1.findColValue("org_corp", "pk_corp", " code = '"+body.get("corpoid")+"' and dr='0' ");
bodyVO.setCorpoid((String)corpoid); // 组织_业务单元_公司
Object cfanaceorgoid1 = hy1.findColValue("org_financeorg", "pk_financeorg", " code = '"+"C003"+"' and dr='0' ");
bodyVO.setCfanaceorgoid((String) cfanaceorgoid1); // 组织_业务单元_财务组织org_financeorg
// bodyVO.setVbillcode((String) body.get("vbillcode")); // 字符串
bodyVO.setCrowno((String) body.get("crowno")); // 字符串
Object cmaterialvid = hy1.findColValue("bd_material", "pk_material", " code = '"+body.get("cmaterialvid")+"' and dr='0' ");
bodyVO.setCmaterialvid((String)cmaterialvid); // 物料基本信息
Object cunitid = hy1.findColValue("bd_material", "pk_measdoc", " code = '"+body.get("cmaterialvid")+"' and dr='0' ");
bodyVO.setCunitid((String)cunitid); // 计量单位bd_measdoc
// Object castunitid = hy1.findColValue("bd_measdoc", "pk_measdoc", " code = '"+body.get("castunitid")+"' and dr='0' ");
bodyVO.setCastunitid((String)cunitid); // 计量单位
bodyVO.setVchangerate((String) body.get("vchangerate")); // 字符串
bodyVO.setVbatchcode((String) body.get("vbatchcode")); // 字符串
// 数值类型UFDouble
bodyVO.setNshouldassistnum(new UFDouble(String.valueOf(body.get("nshouldassistnum")))); // 数值
bodyVO.setNshouldnum(new UFDouble(String.valueOf(body.get("nshouldnum")))); // 数值
bodyVO.setNassistnum(new UFDouble(String.valueOf(body.get("nassistnum")))); // 数值
bodyVO.setNnum(new UFDouble(String.valueOf(body.get("nnum")))); // 数值
if(body.get("cprojectid")!=null){
Object cprojectid = hy1.findColValue("bd_project", "pk_project", " code = '"+body.get("cprojectid")+"' and dr='0' ");
bodyVO.setCprojectid((String) cprojectid); // 项目
}
bodyVO.setVnotebody((String) body.get("vnotebody")); // 字符串
Object cbodytranstypecode = hy1.findColValue("bd_billtype", "pk_billtypeid", " pk_billtypecode = '"+body.get("cbodytranstypecode")+"' and dr='0' ");
bodyVO.setCbodytranstypecode((String)cbodytranstypecode); // 单据类型
// Object cbodywarehouseid = hy1.findColValue("bd_stordoc", "pk_stordoc", " code = '"+body.get("cbodywarehouseid")+"' and dr='0' ");
bodyVO.setCbodywarehouseid(head.getCwarehouseid()); // 仓库
Object cproductorid = hy1.findColValue("bd_defdoc", "pk_defdoc", " code = '" + body.get("cproductorid") + "' and dr='0' ");
bodyVO.setCproductorid((String) cproductorid); // 生产厂商
// Object pk_creqwareid = hy1.findColValue("bd_stordoc", "pk_stordoc", " code = '"+body.get("pk_creqwareid")+"' and dr='0' ");
bodyVO.setPk_creqwareid(head.getCwarehouseid()); // 仓库
Object creqstoorgoid = hy1.findColValue("org_stockorg", "pk_org", "code = '"+"C047"+"' and nvl(dr,0)=0 and islastversion='Y' ");
bodyVO.setCreqstoorgoid((String) creqstoorgoid); // 组织_业务单元_库存组织
Object corigcurrencyid = hy1.findColValue("bd_currtype", "pk_currtype", "code = '"+"CNY"+"' and nvl(dr,0)=0 ");
bodyVO.setCorigcurrencyid((String) corigcurrencyid); // 币种
bodyVO.setNchangestdrate(new UFDouble(1)); // 数值
Object ccurrencyid = hy1.findColValue("bd_currtype", "pk_currtype", "code = '"+"CNY"+"' and nvl(dr,0)=0 ");
bodyVO.setCcurrencyid((String) ccurrencyid); // 币种
// 价格相关数值UFDouble
// 处理UFDouble类型属性值非null时才赋值
Object norignetpriceVal = body.get("norignetprice");
if (norignetpriceVal != null) {
bodyVO.setNorignetprice(new UFDouble(String.valueOf(norignetpriceVal)));
}
Object norigtaxnetpriceVal = body.get("norigtaxnetprice");
if (norigtaxnetpriceVal != null) {
bodyVO.setNorigtaxnetprice(new UFDouble(String.valueOf(norigtaxnetpriceVal)));
}
Object nnetpriceVal = body.get("nnetprice");
if (nnetpriceVal != null) {
bodyVO.setNnetprice(new UFDouble(String.valueOf(nnetpriceVal)));
}
Object ntaxnetpriceVal = body.get("ntaxnetprice");
if (ntaxnetpriceVal != null) {
bodyVO.setNtaxnetprice(new UFDouble(String.valueOf(ntaxnetpriceVal)));
}
// 计量单位非null时赋值
Object cqtunitidVal = body.get("cqtunitid");
if (cqtunitidVal != null) {
bodyVO.setCqtunitid((String) cqtunitidVal);
}
// 数值UFDouble类型非null时赋值
Object nqtunitnumVal = body.get("nqtunitnum");
if (nqtunitnumVal != null) {
bodyVO.setNqtunitnum(new UFDouble(String.valueOf(nqtunitnumVal)));
}
// 字符串非null时赋值
Object vqtunitrateVal = body.get("vqtunitrate");
if (vqtunitrateVal != null) {
bodyVO.setVqtunitrate((String) vqtunitrateVal);
}
// 继续处理其他UFDouble类型属性
Object nqtorignetpriceVal = body.get("nqtorignetprice");
if (nqtorignetpriceVal != null) {
bodyVO.setNqtorignetprice(new UFDouble(String.valueOf(nqtorignetpriceVal)));
}
Object nqtorigtaxnetpriceVal = body.get("nqtorigtaxnetprice");
if (nqtorigtaxnetpriceVal != null) {
bodyVO.setNqtorigtaxnetprice(new UFDouble(String.valueOf(nqtorigtaxnetpriceVal)));
}
Object nqtnetpriceVal = body.get("nqtnetprice");
if (nqtnetpriceVal != null) {
bodyVO.setNqtnetprice(new UFDouble(String.valueOf(nqtnetpriceVal)));
}
Object nqttaxnetpriceVal = body.get("nqttaxnetprice");
if (nqttaxnetpriceVal != null) {
bodyVO.setNqttaxnetprice(new UFDouble(String.valueOf(nqttaxnetpriceVal)));
}
Object norigpriceVal = body.get("norigprice");
if (norigpriceVal != null) {
bodyVO.setNorigprice(new UFDouble(String.valueOf(norigpriceVal)));
}
Object norigtaxpriceVal = body.get("norigtaxprice");
if (norigtaxpriceVal != null) {
bodyVO.setNorigtaxprice(new UFDouble(String.valueOf(norigtaxpriceVal)));
}
Object npriceVal = body.get("nprice");
if (npriceVal != null) {
bodyVO.setNprice(new UFDouble(String.valueOf(npriceVal)));
}
Object ntaxpriceVal = body.get("ntaxprice");
if (ntaxpriceVal != null) {
bodyVO.setNtaxprice(new UFDouble(String.valueOf(ntaxpriceVal)));
}
Object nqtorigpriceVal = body.get("nqtorigprice");
if (nqtorigpriceVal != null) {
bodyVO.setNqtorigprice(new UFDouble(String.valueOf(nqtorigpriceVal)));
}
Object nqtorigtaxpriceVal = body.get("nqtorigtaxprice");
if (nqtorigtaxpriceVal != null) {
bodyVO.setNqtorigtaxprice(new UFDouble(String.valueOf(nqtorigtaxpriceVal)));
}
Object nqtpriceVal = body.get("nqtprice");
if (nqtpriceVal != null) {
bodyVO.setNqtprice(new UFDouble(String.valueOf(nqtpriceVal)));
}
Object nqttaxpriceVal = body.get("nqttaxprice");
if (nqttaxpriceVal != null) {
bodyVO.setNqttaxprice(new UFDouble(String.valueOf(nqttaxpriceVal)));
}
Object nitemdiscountrateVal = body.get("nitemdiscountrate");
if (nitemdiscountrateVal != null) {
bodyVO.setNitemdiscountrate(new UFDouble(String.valueOf(nitemdiscountrateVal)));
}
// 金额及税额相关UFDouble类型非null时赋值
Object norigmnyVal = body.get("norigmny");
if (norigmnyVal != null) {
bodyVO.setNorigmny(new UFDouble(String.valueOf(norigmnyVal)));
}
Object norigtaxmnyVal = body.get("norigtaxmny");
if (norigtaxmnyVal != null) {
bodyVO.setNorigtaxmny(new UFDouble(String.valueOf(norigtaxmnyVal)));
}
Object nmnyVal = body.get("nmny");
if (nmnyVal != null) {
bodyVO.setNmny(new UFDouble(String.valueOf(nmnyVal)));
}
Object ntaxmnyVal = body.get("ntaxmny");
if (ntaxmnyVal != null) {
bodyVO.setNtaxmny(new UFDouble(String.valueOf(ntaxmnyVal)));
}
Object ntaxVal = body.get("ntax");
if (ntaxVal != null) {
bodyVO.setNtax(new UFDouble(String.valueOf(ntaxVal)));
}
// 增值税税码税率查询结果非null时赋值
Object ctaxcodeid = hy1.findColValue("bd_taxcode", "pk_taxcode",
"code = '" + "CN13" + "' and dr=0 ");
if (ctaxcodeid != null) {
bodyVO.setCtaxcodeid((String) ctaxcodeid);
}
String sql1 ="select taxrate from bd_taxrate where pk_taxcode = '1002Z01000000001CNE2' and dr=0 ";
Object ntaxrateVal =new BaseDAO().executeQuery(sql1, new ColumnProcessor());
// Object ntaxrateVal = hy1.findColValue("bd_taxrate", "taxrate",
// " pk_taxcode = '" + ctaxcodeid+ "' and dr=0 ");
if (ntaxrateVal != null) {
bodyVO.setNtaxrate(new UFDouble(String.valueOf(ntaxrateVal)));
}
// 继续处理其他UFDouble类型
Object ncaltaxmnyVal = body.get("ncaltaxmny");
if (ncaltaxmnyVal != null) {
bodyVO.setNcaltaxmny(new UFDouble(String.valueOf(ncaltaxmnyVal)));
}
// 扣税类别非null时转换并赋值
Object ftaxtypeflagVal = body.get("ftaxtypeflag");
if (ftaxtypeflagVal != null) {
bodyVO.setFtaxtypeflag(Integer.valueOf((String) ftaxtypeflagVal));
}
Object ncalcostmnyVal = body.get("ncalcostmny");
if (ncalcostmnyVal != null) {
bodyVO.setNcalcostmny(new UFDouble(String.valueOf(ncalcostmnyVal)));
}
// 供应商基本信息查询结果非null时赋值
String cvendorid1 = (String) hy1.findColValue("bd_supplier", "pk_supplier",
" code = '" + body.get("cvendorid") + "' and dr=0 ");
if (cvendorid1 != null) {
bodyVO.setCvendorid(cvendorid1);
}
list1.add(bodyVO);
}
vo.setChildrenVO(list1.toArray(new PurchaseInBodyVO[list1.size()]));
// 添加到集合
list.add(vo);
}
PurchaseInVO[] vos =list.toArray(new PurchaseInVO[list.size()]) ;
// InsertBP insertBP=new InsertBP();
// insertBP.insert(list.toArray(new PurchaseInVO[list.size()]));
ICAPILocationVOUtils.setLocationVO(ICBillType.PurchaseIn.getCode(), vos);
// 1传入数据基本非空校验
BillVOsCheckRule checker =
new BillVOsCheckRule(new CheckPurchaseInSaveValidator());
//2025年4月23日15点10分 采购入库单接口项目字段为波浪则清空 sdlizheng --start
for (PurchaseInVO vo : vos) {
PurchaseInBodyVO[] bodys = vo.getBodys();
if (bodys != null && bodys.length > 0) {
String[] attributeNames = bodys[0].getAttributeNames();
for (PurchaseInBodyVO body : bodys) {
for (String fildName : attributeNames) {
if (body.getAttributeValue(fildName) != null && "~".equals(body.getAttributeValue(fildName))) {
body.setAttributeValue(fildName, null);
}
}
}
}
}
//2025年4月23日15点10分 采购入库单接口项目字段为波浪则清空 sdlizheng --end
//添加供应商和交易类型为空赋值
checker.check(vos);
// 翻译货位
ICAPILocationVOUtils.translate(vos);
//begin没取到财务组织导致的报错在这里给财务组织赋值为库存组织
// for (PurchaseInVO vo : vos) {
// if (vo.getHead().getCfanaceorgoid() != null) {
// continue;
// }
// String cfinanceoid = (new OrgInfoQuery()).getFinanceOrgIDByCalBodyID(vo.getHead().getPk_org());
// String cfinancevid = (new OrgInfoQuery()).getFinanceOrgVIDByCalBodyID(vo.getHead().getPk_org());
// vo.getHead().setCfanaceorgoid(cfinanceoid);
// vo.getHead().setCfanaceorgvid(cfinancevid);
// }
//end
// 3其他数据填充
// new PurchaseInSaveFillValue().setDefaultValue(vos);
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>(
PurchaseInVO.class, ICBillType.PurchaseIn.getCode());
tool.insert(list.toArray(new PurchaseInVO[list.size()]));
} catch (Exception e) {
throw new BusinessException("同步失败:" + e.getMessage(), e);
}
}
return null;
}
}

View File

@ -0,0 +1,193 @@
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;
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.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.fi.pub.SqlUtils;
import nc.vo.ic.m4d.entity.MaterialOutBodyVO;
import nc.vo.ic.m4d.entity.MaterialOutHeadVO;
import nc.vo.ic.m4d.entity.MaterialOutVO;
import nc.vo.mmpac.pickm.entity.AggPickmVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
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;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 定时同步高压加工车间IMS的材料出库
*
* @author mzr
* @date 20250930
*/
public class MaterialOutGyImsPlugin 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数据源
public static final BaseDAO baseDAO = new BaseDAO();
// IMS数据源
public BaseDAO imsDao;
/**
* 获取IMS数据源
*/
public BaseDAO getImsDao() {
if (imsDao == null) {
imsDao = new BaseDAO("gyims");
// 禁用时间戳ts
imsDao.setAddTimeStamp(false);
}
return imsDao;
}
@Override
public PreAlertObject executeTask(BgWorkingContext arg0) {
Logger.error("---start----任务开始运行--");
try {
IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class);
// IMS 同步状态BIP:C-创建;U-修改D-删除 IMS:2-MES单据接收完成
String selSql = "select * from BIPOutMainTab where status != '2'";
List<Map<String, Object>> mainList = (List<Map<String, Object>>) getImsDao().executeQuery(selSql, new MapListProcessor());
Set<String> imsIdSet = new HashSet<>();
for (Map<String, Object> mainMap : mainList) {
String cgeneralhid = mainMap.get("cgeneralhid") + "";
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<>();
for (Map<String, Object> detailMap : detailList) {
detailIdMap.put(detailMap.get("vbdef17") + "", detailMap);
}
if (detailList.isEmpty()) {
continue;
}
String csourcebillhid = detailList.get(0).get("vbdef16") + "";// 备料计划主键
// 查询备料计划的VO
AggPickmVO[] pickmVOS = queryService.queryBillsByPks(new String[]{csourcebillhid});
// 调用单据转换规则转换出流程材料出库的VO
MaterialOutVO[] vos = (MaterialOutVO[]) PFPubService.runChangeData(MMBillType.PickMo.getCode(), ICBillType.MaterialOut.getCode(),
pickmVOS, null, PfButtonClickContext.ClassifyByItfdef);
if (MMValueCheck.isEmpty(vos)) {
continue;
}
// 设置行号
setMaterialOutRowNum(vos);
// 根据IMS字段赋值
for (MaterialOutVO vo : vos) {
MaterialOutHeadVO hvo = vo.getHead();
MaterialOutBodyVO[] bodys = vo.getBodys();
hvo.setVbillcode(mainMap.get("vbillcode") + "");
hvo.setCreator("BIP");
hvo.setBillmaker("BIP");
hvo.setVtrantypecode("4D-01");
if (mainMap.get("dmakedate") != null && mainMap.get("dmakedate") instanceof Timestamp dmakedate1) {
String dmakedateStr = DATE_FORMATTER.format(dmakedate1);
UFDate dmakedate = new UFDate(dmakedateStr);
hvo.setDmakedate(dmakedate);
}
if (mainMap.get("creationtime") != null && mainMap.get("creationtime") instanceof Timestamp creationtime1) {
String creationtimeStr = DATETIME_FORMATTER.format(creationtime1);
UFDateTime creationtime = new UFDateTime(creationtimeStr);
hvo.setCreationtime(creationtime);
}
for (MaterialOutBodyVO bvo : bodys) {
String getCsourcebillbid = bvo.getCsourcebillbid();// 备料计划明细id
Map<String, Object> detailMap = detailIdMap.get(getCsourcebillbid);
if (detailMap != null) {
// 物料或数量替换
bvo.setNshouldnum(skipNullNum(detailMap.get("nshouldnum"), bvo.getNshouldnum()));// 应发主数量
bvo.setNshouldassistnum(skipNullNum(detailMap.get("nshouldassistnum"), bvo.getNshouldassistnum()));// 应发数量
bvo.setNnum(skipNullNum(detailMap.get("nnum"), bvo.getNnum()));// 实发主数量
bvo.setNassistnum(skipNullNum(detailMap.get("nassistnum"), bvo.getNassistnum()));// 实发数量
// 如果物料不相等则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);
if (!cmaterialvid.equals(goodsId)) {
bvo.setCmaterialvid(goodsId);
}
}
}
}
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
MaterialOutVO[] resultvos = materialOut.insertBills(vos);
if (MMValueCheck.isEmpty(resultvos)) {
continue;
}
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());
}
Logger.error("---end----任务结束运行--");
} catch (Exception e) {
Logger.error("MaterialOutGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("MaterialOutGyImsPlugin Error: " + e.getMessage());
}
return null;
}
private UFDouble skipNullNum(Object value, UFDouble num) {
if (value instanceof BigDecimal) {
return new UFDouble((BigDecimal) value);
}
if (num != null) {
return num;
}
return UFDouble.ZERO_DBL;
}
private void setMaterialOutRowNum(MaterialOutVO[] vos) {
for (int i = 0; i < vos.length; i++) {
MaterialOutVO vo = vos[i];
MaterialOutBodyVO[] bodys = vo.getBodys();
if (bodys != null && bodys.length > 0) {
for (int j = 0; j < bodys.length; j++) {
MaterialOutBodyVO body = bodys[j];
body.setCrowno(String.valueOf((j + 1) * 10));
}
}
}
}
}

View File

@ -0,0 +1,170 @@
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.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.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;
import nc.vo.mmpac.wr.entity.WrItemVO;
import nc.vo.mmpac.wr.entity.WrVO;
import nc.vo.pub.BusinessException;
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;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 定时同步高压加工车间IMS的生产报告
*
* @author mzr
* @date 20250929
*/
public class ProductReportGyImsPlugin implements IBackgroundWorkPlugin {
private SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
private SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// BIP数据源
public static final BaseDAO baseDAO = new BaseDAO();
// IMS数据源
public BaseDAO imsDao;
/**
* 获取IMS数据源
*/
public BaseDAO getImsDao() {
if (imsDao == null) {
imsDao = new BaseDAO("gyims");
// 禁用时间戳ts
imsDao.setAddTimeStamp(false);
}
return imsDao;
}
@Override
public PreAlertObject executeTask(BgWorkingContext arg0) {
Logger.error("---start----任务开始运行--");
try {
IPMOQueryService pmoQueryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
IWrMaintainService wrService = NCLocator.getInstance().lookup(IWrMaintainService.class);
// 手动开启事务
TransactionFactory.getTMProxy().begin(3, 0);
// IMS:C-创建;U-修改 BIP:2-BIP单据接收完成
String selSql = "select * from BIPReportMainTab where status != '2'";
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) {
String pkWr = mainMap.get("pk_wr").toString();
String pkWrSql = "select * from BIPReportDetailTab where pk_wr = '" + pkWr + "'";
List<Map<String, Object>> detailList = (List<Map<String, Object>>) getImsDao().executeQuery(pkWrSql, new MapListProcessor());
Map<String, Map<String, Object>> detailIdMap = new HashMap<>();
for (Map<String, Object> detailMap : detailList) {
detailIdMap.put(detailMap.get("vbdef23").toString(), detailMap);
}
if (detailList.isEmpty()) {
continue;
}
String vbdef22 = detailList.get(0).get("vbdef22") + "";// 流程生产订单主键
// 查询流程生产订单的VO
PMOAggVO[] pmoAggVOS = pmoQueryService.queryByPks(new String[]{vbdef22});
// 调用单据转换规则转换出流程生产报告的VO
AggWrVO[] vos = (AggWrVO[]) PFPubService.runChangeData(MMBillType.ProduceOrder.getCode(), MMBillType.ProduceReport.getCode(),
pmoAggVOS, null, PfButtonClickContext.ClassifyByItfdef);
if (MMValueCheck.isEmpty(vos)) {
continue;
}
// 根据IMS字段赋值
for (AggWrVO vo : vos) {
WrVO hvo = vo.getParentVO();
WrItemVO[] bvos = vo.getChildrenVO();
hvo.setVbillcode(mainMap.get("vbillcode") + "");
hvo.setCreator("BIP");
hvo.setBillmaker("BIP");
String dmakedateStr = "";
if (mainMap.get("dmakedate") != null && mainMap.get("dmakedate") instanceof Timestamp dmakedate1) {
dmakedateStr = DATE_FORMATTER.format(dmakedate1);
UFDate dmakedate = new UFDate(dmakedateStr);
hvo.setDmakedate(dmakedate);
}
if (mainMap.get("creationtime") != null && mainMap.get("creationtime") instanceof Timestamp creationtime1) {
String creationtimeStr = DATETIME_FORMATTER.format(creationtime1);
UFDateTime creationtime = new UFDateTime(creationtimeStr);
hvo.setCreationtime(creationtime);
}
for (WrItemVO bvo : bvos) {
bvo.setFbproducttype(1);// 产品类型 1.主产品
bvo.setTbstarttime(new UFDateTime(dmakedateStr + " 00:00:00"));// 开始时间
bvo.setTbendtime(new UFDateTime(dmakedateStr + " 23:59:59"));// 结束时间
String cbmobid = bvo.getCbmobid();// 流程生产订单明细id
Map<String, Object> detailMap = detailIdMap.get(cbmobid);
if (detailMap != null) {
// 物料或数量替换
bvo.setNbplanwrnum(new UFDouble((BigDecimal) detailMap.get("nbplanwrnum")));// 计划完工主数量
bvo.setNbplanwrastnum(new UFDouble((BigDecimal) detailMap.get("nbplanwrastnum")));// 计划完工数量
bvo.setNbwrnum(new UFDouble((BigDecimal) detailMap.get("nbwrnum")));// 完工主数量
bvo.setNbwrastnum(new UFDouble((BigDecimal) detailMap.get("nbwrastnum")));// 完工数量
// 如果物料不相等则BIP物料替换为IMS物料
String cbmaterialvid = bvo.getCbmaterialvid();
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);
if (!cbmaterialvid.equals(goodsId)) {
bvo.setCbmaterialvid(goodsId);
}
}
}
}
AggWrVO[] resultvos = null;
try {
resultvos = wrService.insert(vos);
} catch (BusinessException e) {
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);
getImsDao().executeUpdate(updateSql);
}
if (MMValueCheck.isEmpty(resultvos)) {
continue;
}
pkWrSet.add(pkWr);
}
if (!pkWrSet.isEmpty()) {
// 修改状态为 完成
String inSql = SqlUtils.getInStr("pk_wr", pkWrSet.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update BIPReportMainTab set status = '2' where " + inSql;
getImsDao().executeUpdate(updateSql);
}
// 正常结束
TransactionFactory.getTMProxy().end(null);
Logger.error("---end----任务结束运行--");
} catch (Exception e) {
// 异常回滚
TransactionFactory.getTMProxy().end(e);
Logger.error("ProductReportGyImsPlugin Error: ", e);
NCCForUAPLogger.debug("ProductReportGyImsPlugin Error: " + e.getMessage());
}
return null;
}
}

View File

@ -0,0 +1,193 @@
package nc.bs.uapbd.task.mes.epic;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
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.bs.uapbd.util.ThirdPartyPostRequestUtil;
import nc.itf.bd.bom.bom0202.IBomBillQueryService;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.bom.bom0202.entity.AggBomVO;
import nc.vo.bd.bom.bom0202.entity.BomItemVO;
import nc.vo.bd.bom.bom0202.entity.BomVO;
import nc.vo.bd.material.MaterialVO;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* BOM-艾普MES-定时重推失败的数据
*
* @author mzr
* @date 20251006
*/
public class BomToEpicMesPlugin implements IBackgroundWorkPlugin {
private static final String LOG_INFO_NAME = "syscron";
private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
private static final String reqUrl = "/prj-v5-web/ext/api/bom";
private Map<String, String> configParams;
private BaseDAO dao;
public BaseDAO getDao() {
if (dao == null) {
dao = new BaseDAO();
}
return dao;
}
@Override
public PreAlertObject executeTask(BgWorkingContext bgWorkingContext) throws BusinessException {
try {
String sql = " select * from v_mes_bom_cron";
List<Map<String, String>> pkList = (List<Map<String, String>>) getDao().executeQuery(sql.toString(), new MapListProcessor());
if (pkList.isEmpty()) {
return null;
}
configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) {
return null;
}
IBomBillQueryService qry = NCLocator.getInstance().lookup(IBomBillQueryService.class);
for (Map<String, String> map : pkList) {
String cbomid = map.get("cbomid");
AggBomVO[] vos = qry.queryAggBomByBomID(new String[]{cbomid});
JSONArray data = buildSyncData(vos);
if (!data.isEmpty()) {
pushData(data, vos);
}
} // MATERIAL
} catch (Exception e) {
logDl.error("BomToEpicMesPlugin-exp:" + e.getMessage(), e);
}
return null;
}
/**
* 构建同步数据
*/
private JSONArray buildSyncData(AggBomVO[] useVOs) throws BusinessException {
JSONArray data = new JSONArray();
for (AggBomVO vo : useVOs) {
// 判断物料的业务单元是否是电力电子公司不是则跳过
BomVO hvo = (BomVO) vo.getParentVO();
String hvnote = hvo.getHvnote();
// 跳过期初的BOM
if ("202509QC".equals(hvnote)) {
continue;
}
String pkOrg = (String) hvo.getAttributeValue("pk_org");
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
if (MyHelper.checkIfDldzOrg(orgCode, configParams)) {
continue;
}
BomItemVO[] childrenVOs = vo.getChildrenVO();
if (MMValueCheck.isEmpty(childrenVOs)) {
continue;
}
// 只推送生产BOM 1=生产BOM;2=包装BOM;3=配置BOM;
Integer fbomtype = hvo.getFbomtype();
if (fbomtype != 1) {
continue;
}
String hcmaterialid = hvo.getHcmaterialid();// 父项物料编码
String hversion = hvo.getHversion();// BOM版本号
String mitm = MyHelper.getStrValByCondition(MaterialVO.getDefaultTableName(), MaterialVO.CODE,
MaterialVO.PK_MATERIAL + " = '" + hcmaterialid + "'");
for (BomItemVO childrenVO : childrenVOs) {
String cmaterialid = childrenVO.getCmaterialid();
String sitm = MyHelper.getStrValByCondition(MaterialVO.getDefaultTableName(), MaterialVO.CODE,
MaterialVO.PK_MATERIAL + " = '" + cmaterialid + "'");
// 组装数据
JSONObject singleObj = new JSONObject();
singleObj.put("mitm", mitm); // 制造物料编码(ERP父项物料编码)
singleObj.put("sitm", sitm); // 子物料编码
singleObj.put("orderNum", hversion); // 合同号(ERP中电力电子项目号=BOM版本号)
singleObj.put("qana", childrenVO.getNassitemnum().toString()); // 数量(ERP子项数量)
singleObj.put("ver", hversion); // BOM版本号
singleObj.put("remark", childrenVO.getVnote()); // 备注
data.add(singleObj);
}
/**
* [
* {
* "mitm": "DSF01-2501230028",
* "sitm": "2305050447",
* "orderNum": "111",
* "qana": 1,
* "ver": "1",
* "remark": ""
* }
* ]
*/
}
return data;
}
/**
* 推送同步数据
*/
private void pushData(JSONArray param, AggBomVO[] vos) throws BusinessException {
// 转json字符串的时候保留null值
String jsonStr = JSON.toJSONString(param,
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullStringAsEmpty
);
logDl.error("EpicMes-BOM-param = " + jsonStr);
// NCCForUAPLogger.debug("EpicMes-BOM-param = " + jsonStr);
String baseUrl = configParams.get("epicMesUrl");
String requestUrl = baseUrl + reqUrl;
logDl.error("EpicMes-BOM-url = " + requestUrl);
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
JSONObject resultObj = JSONObject.parseObject(result);
logDl.error("EpicMes-BOM-res = " + result);
// NCCForUAPLogger.debug("EpicMes-BOM-result = " + result);
if (!"1".equals(resultObj.getString("flag"))) {
// throw new BusinessException("EpicMes-BOM-error:" + resultObj.getString("msg"));
logDl.error("EpicMes-BOM-error,result[" + resultObj.toJSONString() + "]");
// 保存BOM推送的错误信息
// handleSyncBomExp(vos, "N", resultObj.getString("msg"));
} else {
handleSyncBomExp(vos, "Y", "");
}
}
/**
* 更新错误信息
*/
private void handleSyncBomExp(AggBomVO[] vos, String errorCode, String errorMsg) {
if (MMValueCheck.isEmpty(vos)) {
return;
}
Set<String> ids = new HashSet<>();
for (AggBomVO vo : vos) {
BomVO hvo = (BomVO) vo.getParentVO();
String cbomid = hvo.getCbomid();
ids.add(cbomid);
}
try {
String inSql = SqlUtils.getInStr("cbomid", ids.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update bd_bom set hvdef19 = '[errorCode]' where " + inSql;
updateSql = updateSql.replace("[errorCode]", errorCode);
int updatedRows = getDao().executeUpdate(updateSql);
} catch (BusinessException e) {
logDl.error("EpicMes-BOM-updateErrorInfo = " + e.getMessage(), e);
}
}
}

View File

@ -0,0 +1,210 @@
package nc.bs.uapbd.task.mes.epic;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import nc.bs.dao.BaseDAO;
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.trade.business.HYPubBO;
import nc.bs.uapbd.util.MyHelper;
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.material.MaterialVO;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import java.util.*;
/**
* 物料-艾普MES-定时重推失败的数据
*
* @author mzr
* @date 20251006
*/
public class MaterialToEpicMesPlugin implements IBackgroundWorkPlugin {
private static final String LOG_INFO_NAME = "syscron";
private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
private static final String reqUrl = "/prj-v5-web/ext/api/mrl";
private Map<String, String> configParams;
private BaseDAO dao;
public BaseDAO getDao() {
if (dao == null) {
dao = new BaseDAO();
}
return dao;
}
@Override
public PreAlertObject executeTask(BgWorkingContext bgWorkingContext) throws BusinessException {
try {
String sql = " select * from v_mes_material_cron";
List<Map<String, String>> pkList = (List<Map<String, String>>) getDao().executeQuery(sql.toString(), new MapListProcessor());
if (pkList.isEmpty()) {
return null;
}
configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) {
return null;
}
HYPubBO hyPub = new HYPubBO();
List<MaterialVO> voList = new ArrayList<>();
for (Map<String, String> map : pkList) {
String pkMaterial = map.get("pk_material");
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
voList.add(materialVO);
}
if (!voList.isEmpty()) {
MaterialVO[] useVOs = voList.toArray(new MaterialVO[0]);
buildSyncData(useVOs);
}
} catch (Exception e) {
logDl.error("BomToEpicMesPlugin-exp:" + e.getMessage(), e);
}
return null;
}
/**
* 构建同步数据
*/
private void buildSyncData(MaterialVO[] useVOs) throws BusinessException {
for (MaterialVO vo : useVOs) {
String pkMaterial = vo.getPk_material();
// 判断物料的业务单元是否是电力电子公司不是则跳过
String pkOrg = vo.getPk_org();
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
// 字段值翻译
// String pk_marbasclass = vo.getPk_marbasclass();
// String mrlTypeCOde = MyHelper.transferField(MarBasClassVO.getDefaultTableName(), MarBasClassVO.CODE, MarBasClassVO.PK_MARBASCLASS, pk_marbasclass);
// 计量单位
Map unitMap = getGoodsInfo(pkMaterial);
// 1=未启用;2=已启用;3=已停用;
Integer enablestate = vo.getEnablestate();
String statusCode = (3 == enablestate) ? "N" : "Y";
// 组装数据
JSONObject singleObj = new JSONObject();
singleObj.put("id", null);// 唯一标识主键
singleObj.put("siteCode", orgCode);// 工厂编码
singleObj.put("mrlCode", vo.getCode());// 物料编码
singleObj.put("mrlName", vo.getName());// 物料名称
singleObj.put("unit", unitMap.get("unitname"));// 单位
singleObj.put("model", vo.getMaterialtype());// 型号
singleObj.put("specification", vo.getMaterialspec());// 规格
singleObj.put("type", getType(""));// 类型I:新增 U:修改 D:删除
singleObj.put("deputyUnit", unitMap.get("deputy_unitname"));// 副单位
singleObj.put("auditCode", "1");// 审核码
singleObj.put("statusCode", statusCode);// 状态码Y表示启用N表示停用
// singleObj.put("mrlTypeErp", getGoodsProject(pkMaterial));// 物料类型ERP1:专用件3:通用件
singleObj.put("mrlType", getGoodsType(pkMaterial));// 物料分类 制造1 其它0
singleObj.put("convertRate", unitMap.getOrDefault("convertRate", "1"));// 单位换算率
// singleObj.put("isCheck", "1");// 是否选中1:0:
pushData(singleObj, useVOs);
}
}
/**
* 推送同步数据
*/
private void pushData(JSONObject param, MaterialVO[] useVOs) throws BusinessException {
// String jsonString = param.toJSONString();
// 转json字符串的时候保留null值
String jsonStr = JSON.toJSONString(param,
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullStringAsEmpty
);
logDl.error("EpicMes-Material-param = " + jsonStr);
// NCCForUAPLogger.debug("EpicMes-Material-param = " + jsonStr);
String baseUrl = configParams.get("epicMesUrl");
String requestUrl = baseUrl + reqUrl;
logDl.error("EpicMes-Material-url = " + requestUrl);
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
JSONObject resultObj = JSONObject.parseObject(result);
logDl.error("EpicMes-Material-res = " + result);
if (!"1".equals(resultObj.getString("flag"))) {
// throw new BusinessException("EpicMes-Material-error:" + resultObj.getString("msg"));
logDl.error("EpicMes-Material-error,result[" + resultObj.toJSONString() + "]");
handleSyncMaterialExp(useVOs, "N", resultObj.getString("msg"));
} else {
handleSyncMaterialExp(useVOs, "Y", "");
}
}
private String getType(String eventType) {
// 类型I:新增 U:修改 D:删除
Map<String, String> map = new HashMap<>();
map.put("1002", "I");
map.put("1009", "I");
map.put("1004", "U");
map.put("1069", "U");
map.put("1071", "U");
return map.getOrDefault(eventType, "I");
}
private Map getGoodsInfo(String pkMaterial) throws BusinessException {
String sql = " select a.pk_measdoc, c.name unitname, b.pk_measdoc deputyUnit, d.name deputy_unitname, nvl(b.measrate, '1/1') measrate " +
"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 " +
"left join bd_measdoc d on b.pk_measdoc = d.pk_measdoc " +
"where a.pk_material = '" + pkMaterial + "' ";
// logDl.error("EpicMes-Material-getUnitInfo-sql = " + sql);
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
map.put("convertRate", MyHelper.transferSpecialField(map.get("measrate") + ""));
return map;
}
private String getGoodsType(String pkMaterial) throws BusinessException {
String targetCode = configParams.get("dldzOrg");
String[] orgItem = targetCode.split(",");
String inStr = SqlUtils.getInStr("b.code", orgItem, Boolean.TRUE);
// 物料-库存信息-物料类型 DR=分销补货;FR=工厂补货;MR=制造件;PR=采购件;OT=委外件;ET=其他
// mes物料类型 制造1 其它0(ERP多个组织中如果有一个是制造件或虚拟件(其他)就传1)
String mesType = "0";
// String martype = MyHelper.transferField(MaterialStockVO.getDefaultTableName(), MaterialStockVO.MARTYPE, MaterialStockVO.PK_MATERIAL, pkMaterial);
String countSql = "SELECT count(1)" +
" FROM bd_materialstock a" +
" LEFT JOIN org_stockorg b ON a.pk_org = b.pk_stockorg" +
" WHERE a.dr = 0 AND a.martype IN ('MR','ET') " +
" AND a.pk_material = '[pkMaterial]'" +
" AND " + inStr;
countSql = countSql.replace("[pkMaterial]", pkMaterial);
Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
if (num > 0) {
mesType = "1";
}
return mesType;
}
/**
* 更新错误信息
*/
private void handleSyncMaterialExp(MaterialVO[] vos, String errorCode, String errorMsg) {
if (MMValueCheck.isEmpty(vos)) {
return;
}
Set<String> ids = new HashSet<>();
for (MaterialVO vo : vos) {
String pkMaterial = vo.getPk_material();
ids.add(pkMaterial);
}
try {
String inSql = SqlUtils.getInStr("pk_material", ids.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update bd_material set def30 = '[errorCode]' where " + inSql;
updateSql = updateSql.replace("[errorCode]", errorCode);
int updatedRows = getDao().executeUpdate(updateSql);
} catch (BusinessException e) {
logDl.error("EpicMes-Material-handleSyncMaterialExp = " + e.getMessage(), e);
}
}
}

View File

@ -15,17 +15,14 @@ import nc.bs.uapbd.util.MyHelper;
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.material.MaterialVO;
import nc.vo.bd.material.marbasclass.MarBasClassVO;
import nc.vo.bd.material.stock.MaterialStockVO;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 物料新增修改后同步艾普MES的物料
@ -38,6 +35,14 @@ public class MaterialToEpicMesListener implements IBusinessListener {
private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
private static final String reqUrl = "/prj-v5-web/ext/api/mrl";
private Map<String, String> configParams;
private BaseDAO dao;
public BaseDAO getDao() {
if (dao == null) {
dao = new BaseDAO();
}
return dao;
}
@Override
public void doAction(IBusinessEvent event) throws BusinessException {
@ -46,39 +51,45 @@ public class MaterialToEpicMesListener implements IBusinessListener {
Object[] objs = e.getObjs();
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后 1061批改后
if ("1002".equals(eventType) || "1004".equals(eventType) || "1061".equals(eventType) ||
"1071".equals(eventType) || "1069".equals(eventType)) {
MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) {
throw new BusinessException("电力电子的艾普MES接口缺少配置");
}
buildSyncData(useVOs, eventType);
} else if ("1009".equals(eventType)) {
// 物料可见性范围-分配后 1009
configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) {
throw new BusinessException("电力电子的艾普MES接口缺少配置");
}
HYPubBO hyPub = new HYPubBO();
List<MaterialVO> voList = new ArrayList<>();
for (Object obj : objs) {
MultiOrgAssignVO vo = (MultiOrgAssignVO) obj;
String pkMaterial = vo.getPk_doc();
String pkOrg = vo.getPk_org();
String orgCode = (String) hyPub.findColValue(OrgVO.getDefaultTableName(), OrgVO.CODE, "dr =0 and pk_org = '" + pkOrg + "' ");
// 检查当前组织是否为电力电子
if (MyHelper.checkIfDldzOrg(orgCode, configParams)) {
continue;
MaterialVO[] useVOs = null;
try {
if ("1002".equals(eventType) || "1004".equals(eventType) || "1061".equals(eventType) ||
"1071".equals(eventType) || "1069".equals(eventType)) {
useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) {
throw new BusinessException("电力电子的艾普MES接口缺少配置");
}
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
voList.add(materialVO);
}
if (!voList.isEmpty()) {
MaterialVO[] useVOs = voList.toArray(new MaterialVO[0]);
buildSyncData(useVOs, eventType);
}
} else if ("1009".equals(eventType)) {
// 物料可见性范围-分配后 1009
configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) {
throw new BusinessException("电力电子的艾普MES接口缺少配置");
}
HYPubBO hyPub = new HYPubBO();
List<MaterialVO> voList = new ArrayList<>();
for (Object obj : objs) {
MultiOrgAssignVO vo = (MultiOrgAssignVO) obj;
String pkMaterial = vo.getPk_doc();
String pkOrg = vo.getPk_org();
String orgCode = (String) hyPub.findColValue(OrgVO.getDefaultTableName(), OrgVO.CODE, "dr =0 and pk_org = '" + pkOrg + "' ");
// 检查当前组织是否为电力电子
if (MyHelper.checkIfDldzOrg(orgCode, configParams)) {
continue;
}
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
voList.add(materialVO);
}
if (!voList.isEmpty()) {
useVOs = voList.toArray(new MaterialVO[0]);
buildSyncData(useVOs, eventType);
}
}
} catch (BusinessException ex) {
logDl.error("EpicMes-Material-exp:" + ex.getMessage(), ex);
handleSyncMaterialExp(useVOs, "N", ex.getMessage());
}
}
@ -96,8 +107,8 @@ public class MaterialToEpicMesListener implements IBusinessListener {
continue;
}
// 字段值翻译
String pk_marbasclass = vo.getPk_marbasclass();
String mrlTypeCOde = MyHelper.transferField(MarBasClassVO.getDefaultTableName(), MarBasClassVO.CODE, MarBasClassVO.PK_MARBASCLASS, pk_marbasclass);
// String pk_marbasclass = vo.getPk_marbasclass();
// String mrlTypeCOde = MyHelper.transferField(MarBasClassVO.getDefaultTableName(), MarBasClassVO.CODE, MarBasClassVO.PK_MARBASCLASS, pk_marbasclass);
// 计量单位
Map unitMap = getGoodsInfo(pkMaterial);
@ -206,4 +217,26 @@ public class MaterialToEpicMesListener implements IBusinessListener {
return mesType;
}
/**
* 更新错误信息
*/
private void handleSyncMaterialExp(MaterialVO[] vos, String errorCode, String errorMsg) {
if (MMValueCheck.isEmpty(vos)) {
return;
}
Set<String> ids = new HashSet<>();
for (MaterialVO vo : vos) {
String pkMaterial = vo.getPk_material();
ids.add(pkMaterial);
}
try {
String inSql = SqlUtils.getInStr("pk_material", ids.toArray(new String[0]), Boolean.TRUE);
String updateSql = "update bd_material set def30 = '[errorCode]' where " + inSql;
updateSql = updateSql.replace("[errorCode]", errorCode);
int updatedRows = getDao().executeUpdate(updateSql);
} catch (BusinessException e) {
logDl.error("EpicMes-Material-handleSyncMaterialExp = " + e.getMessage(), e);
}
}
}

View File

@ -42,15 +42,9 @@ public class MaterialToQmsListener implements IBusinessListener {
String eventType = event.getEventType();
Object[] objs = e.getObjs();
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后
if ("1004".equals(eventType)) {
MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
configParams = MyHelper.getConfigParams("xb-config", null);
if (configParams.isEmpty()) {
throw new BusinessException("箱变的QMS接口缺少配置");
}
buildSyncData(useVOs, eventType);
} else if ("1071".equals(eventType) || "1069".equals(eventType)) {
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后 1061批改后
if ("1002".equals(eventType) || "1004".equals(eventType) || "1061".equals(eventType)
|| "1071".equals(eventType) || "1069".equals(eventType)) {
MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
configParams = MyHelper.getConfigParams("xb-config", null);
if (configParams.isEmpty()) {
@ -118,7 +112,8 @@ public class MaterialToQmsListener implements IBusinessListener {
contentObj.put("meswlbh", vo.getCode()); // 启源物料编码
contentObj.put("bipwlbh", vo.getCode()); // BIP物料编码
contentObj.put("wlmc", vo.getName()); // 物料名称
contentObj.put("wlxhgg", vo.getMaterialtype() + vo.getMaterialspec()); // 物料型号规格
String wlxhgg = MyHelper.skipNull(vo.getMaterialtype()) + MyHelper.skipNull(vo.getMaterialspec());
contentObj.put("wlxhgg", wlxhgg); // 物料型号规格
contentObj.put("wlfl", mrlTypeName); // 物料分类
contentObj.put("wlbz", "产品"); // 物料标志
contentObj.put("sjjldw", unitMap.get("unitname")); // 设计计量单位

View File

@ -0,0 +1,84 @@
package nc.bs.uapbd.util;
import nc.bs.logging.Log;
import nc.jdbc.framework.JdbcSession;
import nc.jdbc.framework.PersistenceManager;
import nc.jdbc.framework.exception.DbException;
import nc.vo.pub.BusinessException;
import java.sql.Connection;
import java.sql.SQLException;
/**
* 高压加工车间-IMS-DAO 工具类
*
* @author mzr
* @date 2025/10/08
*/
public class ImsDaoUtil {
private static final String LOG_INFO_NAME = "gymeslog";
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
public static int executeUpdate(String sql, String targetId) throws BusinessException {
// 2. 直接通过静态工厂方法获取 PersistenceManager
PersistenceManager pm = null;
JdbcSession jdbcSession = null;
Connection conn = null;
int rows = 0;
try {
// 直接调用 PersistenceManager 的静态方法 getInstance()
pm = PersistenceManager.getInstance("gyims");
pm.setAddTimeStamp(false);// 不添加时间戳ts
// 2.1 获取 JdbcSession Connection
jdbcSession = pm.getJdbcSession();
jdbcSession.setSQLTranslator(true); // 保持 SQL 转换
conn = jdbcSession.getConnection();
conn.setAutoCommit(false);
logger.info("直接获取PersistenceManager手动事务开启targetId" + targetId);
// 4. 执行主表+子表操作 (传入共享的 pm)
logger.info("事务内执行更新targetId" + targetId);
rows = pm.getJdbcSession().executeUpdate(sql);
logger.info("事务内执行更新rows" + rows);
logger.info("事务内操作全部成功准备提交targetId" + targetId);
} catch (DbException | SQLException e) { // 捕获 DbException SQLException
logger.error("事务执行失败触发回滚targetId" + targetId);
if (conn != null) {
try {
conn.rollback();
logger.info("事务回滚完成targetId" + targetId);
} catch (SQLException rollbackE) {
logger.error("事务回滚异常targetId" + targetId);
}
}
throw new BusinessException("备料计划同步事务失败:" + e.getMessage(), e);
} finally {
if (conn != null) {
try {
conn.commit();
logger.info("事务提交成功targetId" + targetId);
// 恢复自动提交模式确保不会影响其他操作
conn.setAutoCommit(true);
} catch (SQLException commitE) {
logger.error("事务提交异常targetId" + targetId);
}
}
// 5. 释放 PersistenceManager (至关重要)
if (pm != null) {
try {
pm.release(); // 必须调用 release() 将连接归还给连接池
logger.info("PersistenceManager 释放完成targetId" + targetId);
} catch (Exception releaseE) {
logger.error("PersistenceManager 释放异常", releaseE);
}
}
}
return rows;
}
}

View File

@ -1,10 +1,12 @@
package nccloud.api.uapbd.msg;
import com.alibaba.fastjson.JSONObject;
import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.logging.Logger;
import nc.bs.trade.business.HYSuperDMO;
import nc.bs.uapbd.util.MyHelper;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.vo.fi.pub.SqlUtils;
import nc.vo.org.FactoryVO;
import nc.vo.pub.BusinessException;
@ -15,7 +17,6 @@ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.sm.UserVO;
import nc.vo.uap.rbac.role.RoleVO;
import nccloud.api.rest.utils.ResultMessageUtil;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import nccloud.bs.pub.pf.PfMessageUtil;
import nccloud.commons.lang.StringUtils;
import nccloud.ws.rest.resource.AbstractNCCRestResource;
@ -60,6 +61,14 @@ public class MsgResource extends AbstractNCCRestResource {
String content = (String) jsonObject.get("content");
String orgCode = (String) jsonObject.get("orgCode");
try {
String pkOrg = MyHelper.transferField(FactoryVO.getDefaultTableName(), FactoryVO.PK_FACTORY, FactoryVO.CODE, orgCode);
if (pkOrg != null) {
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
}
String materialCode = (String) jsonObject.get("materialCode");
if (materialCode == null || materialCode.isEmpty()) {
return ResultMessageUtil.toJSON(false, "传参中缺少物料编码");
}
// 通知消息字段最大为4000位
if (content != null && content.length() > 1500) {
content = content.substring(0, 1500);
@ -69,7 +78,7 @@ public class MsgResource extends AbstractNCCRestResource {
ArrayList<UserNameObject> userList = new ArrayList<>();
// 根据传递的角色查询要发送消息的用户信息
String roleId = getMsgRole(orgCode);
String roleId = getMsgRole(pkOrg, materialCode);
UserVO[] userVOS = getUserByRole(roleId);
if (userVOS == null || userVOS.length == 0) {
return ResultMessageUtil.toJSON(false, "未查询到用户");
@ -129,7 +138,7 @@ public class MsgResource extends AbstractNCCRestResource {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = sdf.format(new Date());
strWhere = strWhere.replace("[now]", time);
NCCForUAPLogger.debug("getUserByRole-strWhere = " + strWhere);
// NCCForUAPLogger.debug("getUserByRole-strWhere = " + strWhere);
try {
vos = (UserVO[]) getSuperDMO().queryByWhereClause(UserVO.class, strWhere);
} catch (DAOException e) {
@ -142,9 +151,13 @@ public class MsgResource extends AbstractNCCRestResource {
/**
* 查询要发消息的角色id
*/
private String getMsgRole(String orgCode) throws BusinessException {
private String getMsgRole(String pkOrg, String materialCode) throws BusinessException {
String pkRole = "";
String pkOrg = MyHelper.transferField(FactoryVO.getDefaultTableName(), FactoryVO.PK_FACTORY, FactoryVO.CODE, orgCode);
// 先查询物料分类上配置的角色如果有则返回否则查询自定义档案中配置的角色
pkRole = getGoodsTypeRole(pkOrg, materialCode);
if (pkRole != null && !"~".equals(pkRole) && !pkRole.isEmpty()) {
return pkRole;
}
Map<String, String> configParams = MyHelper.getConfigParams("Dldz-config", null);
String strWhere = " dr = 0 ";
String msgRoleCode = configParams.getOrDefault("msgRoleCode", "");
@ -154,12 +167,11 @@ public class MsgResource extends AbstractNCCRestResource {
if (msgRoleCode.contains(",")) {
String inSql = SqlUtils.getInStr("role_code", msgRoleCode.split(",", -1), Boolean.TRUE);
strWhere += " AND " + inSql;
NCCForUAPLogger.debug("¶à½ÇÉ«-strWhere = " + strWhere);
// NCCForUAPLogger.debug("多角色-strWhere = " + strWhere);
} else {
strWhere += " AND role_code = '" + msgRoleCode + "'";
}
if (StringUtils.isNotEmpty(orgCode) && !"~".equals(orgCode) &&
StringUtils.isNotEmpty(pkOrg) && !"~".equals(pkOrg)) {
if (StringUtils.isNotEmpty(pkOrg) && !"~".equals(pkOrg)) {
strWhere += " AND pk_org = '" + pkOrg + "'";
}
Set<String> pkRoleSet = new HashSet<>();
@ -181,4 +193,20 @@ public class MsgResource extends AbstractNCCRestResource {
return pkRole;
}
private String getGoodsTypeRole(String pkOrg, String materialCode) throws BusinessException {
String pkRole = "";
String sql = "SELECT marclass.def1" +
" FROM bd_marbasclass marclass" +
" LEFT JOIN bd_material mar ON marclass.pk_marbasclass = mar.pk_marbasclass" +
" LEFT JOIN bd_materialstock marstock ON mar.pk_material = marstock.pk_material" +
" WHERE " +
" marclass.DR = 0" +
" AND marstock.pk_org = '[pkOrg]'" +
" AND mar.CODE = '[materialCode]'";
sql = sql.replace("[pkOrg]", pkOrg);
sql = sql.replace("[materialCode]", materialCode);
pkRole = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor());
return pkRole;
}
}