优化 MES 同步逻辑并添加用户排除功能
- 移除了 AfterApprovingSynchronizeRuleMES 类中的冗余代码 - 在 BatchTransferToPurchaseOrder 类中实现了批量转换采购订单的新逻辑 - 在 HttpPostOtherSysImpl 类中添加了用户排除检查功能 - 优化了 IHttpPostOtherSys 接口,新增 checkIfExcludeUser 方法
This commit is contained in:
parent
789d944833
commit
bf345f6b8f
|
@ -2,9 +2,11 @@ package nccloud.pubift.commen.impl.utils;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import nc.bs.framework.common.InvocationInfoProxy;
|
||||||
import nc.bs.logging.Log;
|
import nc.bs.logging.Log;
|
||||||
import nc.hr.utils.PubEnv;
|
import nc.hr.utils.PubEnv;
|
||||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||||
|
import nc.vo.am.common.util.StringUtils;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
|
import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
|
||||||
import org.apache.http.Header;
|
import org.apache.http.Header;
|
||||||
|
@ -57,9 +59,12 @@ public class HttpPostOtherSysImpl implements IHttpPostOtherSys {
|
||||||
try {
|
try {
|
||||||
obmlog.debug("HttpPostOtherSys 请求数据 :" + JSONObject.toJSONString(requestData)); // 记录请求数据
|
obmlog.debug("HttpPostOtherSys 请求数据 :" + JSONObject.toJSONString(requestData)); // 记录请求数据
|
||||||
JSONObject jsonRequest = new JSONObject(requestData); // 将Map转换为JSONObject
|
JSONObject jsonRequest = new JSONObject(requestData); // 将Map转换为JSONObject
|
||||||
|
if (checkIfExcludeUser()) {
|
||||||
|
obmlog.debug("当前用户为测试用户被配置为不同步,跳过同步MES系统");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String response = callMes(apiPath, jsonRequest); // 调用MES接口
|
String response = callMes(apiPath, jsonRequest); // 调用MES接口
|
||||||
JSONObject jsonResponse = JSONObject.parseObject(response); // 解析返回的JSON字符串
|
JSONObject jsonResponse = JSONObject.parseObject(response); // 解析返回的JSON字符串
|
||||||
|
|
||||||
obmlog.debug("三方接口返回::" + jsonResponse.toJSONString()); // 记录三方接口返回的数据
|
obmlog.debug("三方接口返回::" + jsonResponse.toJSONString()); // 记录三方接口返回的数据
|
||||||
|
|
||||||
// 检查是否存在 "Data" 数组
|
// 检查是否存在 "Data" 数组
|
||||||
|
@ -103,6 +108,26 @@ public class HttpPostOtherSysImpl implements IHttpPostOtherSys {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查当前用户是否需要跳过同步
|
||||||
|
*/
|
||||||
|
public boolean checkIfExcludeUser() {
|
||||||
|
String code = InvocationInfoProxy.getInstance().getUserCode();
|
||||||
|
//当当前操作人员是BIP的时候 直接return 不走同步MES的业务逻辑
|
||||||
|
String excludeUsers = SysParaInitQuery.getParaString("GLOBLE00000000000000", "JINSIWEINOSYNCUESR");
|
||||||
|
if (StringUtils.isNotEmpty(excludeUsers)) {
|
||||||
|
String[] userItem = excludeUsers.split(";");
|
||||||
|
for (String userCode : userItem) {
|
||||||
|
if (userCode.isEmpty()) continue;
|
||||||
|
if (code != null && code.equals(userCode)) {
|
||||||
|
obmlog.debug("AfterApprovingSynchronizeRuleMES-当前人员是测试人员,不处理,当前用户为:" + code);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务请求post方法
|
* 业务请求post方法
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,4 +24,6 @@ public interface IHttpPostOtherSys {
|
||||||
* 发送数据到外部系统
|
* 发送数据到外部系统
|
||||||
*/
|
*/
|
||||||
public void sendToExternalSystem(String apiPaht, Map<String, Object> requestData) throws BusinessException;
|
public void sendToExternalSystem(String apiPaht, Map<String, Object> requestData) throws BusinessException;
|
||||||
|
|
||||||
|
public boolean checkIfExcludeUser();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,12 @@ import nc.vo.pu.m21.entity.OrderVO;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
import nc.vo.pub.compiler.PfParameterVO;
|
import nc.vo.pub.compiler.PfParameterVO;
|
||||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
|
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
|
||||||
import nc.vo.scmpub.res.billtype.POBillType;
|
import nc.vo.scmpub.res.billtype.POBillType;
|
||||||
|
import nc.vo.scmpub.util.AppInfoContext;
|
||||||
|
import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO;
|
||||||
|
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
|
||||||
|
import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService;
|
||||||
|
|
||||||
public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
||||||
private static final Log logger = Log.getInstance("devpoordertask");
|
private static final Log logger = Log.getInstance("devpoordertask");
|
||||||
|
@ -204,7 +209,11 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IPfExchangeService service = NCLocator.getInstance().lookup(IPfExchangeService.class);
|
IPfExchangeService service = NCLocator.getInstance().lookup(IPfExchangeService.class);
|
||||||
OrderVO[] transVos = (OrderVO[]) service.runChangeDataAry("20", "21", orderVOs, null);
|
OrderVO[] transVos = (OrderVO[]) service.runChangeDataAryNeedClassify("20", "21", orderVOs, null, 1);
|
||||||
|
CloudPFlowContext cloudContext = this.getCloudPFlowContext(transVos);
|
||||||
|
AppInfoContext.setBtnCode("Save");
|
||||||
|
SCMScriptResultDTO scriptResult = ((IBatchRunScriptService) NCLocator.getInstance().lookup(IBatchRunScriptService.class)).runBacth(cloudContext, OrderVO.class);
|
||||||
|
AbstractBill[] sucessVOs = scriptResult.getSucessVOs();
|
||||||
if (transVos == null || transVos.length <= 0) {
|
if (transVos == null || transVos.length <= 0) {
|
||||||
logger.info("转换时出现问题,传唤后VO对象数组为空", this.getClass(), "processBatchTransfer");
|
logger.info("转换时出现问题,传唤后VO对象数组为空", this.getClass(), "processBatchTransfer");
|
||||||
}
|
}
|
||||||
|
@ -219,4 +228,14 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
||||||
throw new BusinessException("批量转换请购单到采购订单失败: " + e.getMessage(), e);
|
throw new BusinessException("批量转换请购单到采购订单失败: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CloudPFlowContext getCloudPFlowContext(OrderVO[] vos) {
|
||||||
|
CloudPFlowContext context = new CloudPFlowContext();
|
||||||
|
context.setActionName("SAVEBASE");
|
||||||
|
context.setBillType(POBillType.Order.getCode());
|
||||||
|
context.setBillVos(vos);
|
||||||
|
context.setUserObj(null);
|
||||||
|
AppInfoContext.setBtnCode("Save");
|
||||||
|
return context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package nc.bs.so.m30.rule.approve;
|
package nc.bs.so.m30.rule.approve;
|
||||||
|
|
||||||
|
import bsh.StringUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import nc.bs.dao.BaseDAO;
|
import nc.bs.dao.BaseDAO;
|
||||||
import nc.bs.framework.common.InvocationInfoProxy;
|
import nc.bs.framework.common.InvocationInfoProxy;
|
||||||
import nc.bs.framework.common.NCLocator;
|
import nc.bs.framework.common.NCLocator;
|
||||||
import nc.bs.logging.Log;
|
import nc.bs.logging.Log;
|
||||||
|
import nc.hr.utils.PubEnv;
|
||||||
import nc.impl.pubapp.pattern.rule.IRule;
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
|
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||||
|
import nc.vo.am.common.util.StringUtils;
|
||||||
import nc.vo.bd.balatype.BalaTypeVO;
|
import nc.vo.bd.balatype.BalaTypeVO;
|
||||||
import nc.vo.bd.currtype.CurrtypeVO;
|
import nc.vo.bd.currtype.CurrtypeVO;
|
||||||
import nc.vo.bd.cust.CustomerVO;
|
import nc.vo.bd.cust.CustomerVO;
|
||||||
|
@ -49,13 +53,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> {
|
||||||
// 初始化HTTP请求工具类
|
// 初始化HTTP请求工具类
|
||||||
IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
|
IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
|
||||||
try {
|
try {
|
||||||
// String code = InvocationInfoProxy.getInstance().getUserCode();
|
|
||||||
// 当当前操作人员是BIP的时候 直接return 不走同步MES的业务逻辑
|
|
||||||
// if (code != null && code.equals("BIP")) {
|
|
||||||
// obmlog.debug("AfterApprovingSynchronizeRuleMES-当前人员是BIP,不处理");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (saleOrderVOs == null || saleOrderVOs.length == 0) {
|
if (saleOrderVOs == null || saleOrderVOs.length == 0) {
|
||||||
obmlog.debug("AfterApprovingSynchronizeRuleMES-没有需要处理的销售订单");
|
obmlog.debug("AfterApprovingSynchronizeRuleMES-没有需要处理的销售订单");
|
||||||
return;
|
return;
|
||||||
|
@ -81,6 +78,7 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建符合金思维系统接口规范的请求数据
|
* 构建符合金思维系统接口规范的请求数据
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue