This commit is contained in:
parent
92a6d168b0
commit
99ac71285e
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.bs.ic.m4d.sign;
|
||||
|
||||
import com.yonyou.cloud.ncc.plugin.entity.OperationInfo;
|
||||
import nc.bs.ic.general.sign.ISignBP;
|
||||
import nc.bs.ic.general.sign.ISignRuleProvider;
|
||||
import nc.bs.ic.general.sign.SignBPTemplate;
|
||||
import nc.bs.ic.m4d.base.BPPlugInPoint;
|
||||
import nc.bs.ic.m4d.base.UpdateSCOnhandRule;
|
||||
import nc.bs.ic.m4d.sign.rule.AfterSignRuleForLiabilityProcess;
|
||||
import nc.bs.ic.m4d.sign.rule.PullProcess;
|
||||
import nc.bs.ic.m4d.sign.rule.PushSaveIAandTOBill;
|
||||
import nc.bs.ic.pub.util.SagasUtils;
|
||||
import nc.bs.scmpub.rule.VOSagaFrozenValidateRule;
|
||||
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
|
||||
import nc.itf.ic.m4d.compensate.IMaterialOutSagasCompensate;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||
import nc.vo.ic.pub.util.VOEntityUtil;
|
||||
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SignBP implements ISignBP<MaterialOutVO>, ISignRuleProvider<MaterialOutVO> {
|
||||
public SignBP() {
|
||||
}
|
||||
|
||||
public void addAfterRule(MaterialOutVO[] vos, AroundProcesser<MaterialOutVO> processor) {
|
||||
processor.addAfterRule(new UpdateSCOnhandRule(false));
|
||||
processor.addAfterRule(new PushSaveIAandTOBill());
|
||||
processor.addAfterRule(new AfterSignRuleForLiabilityProcess());
|
||||
// 导入领料需求
|
||||
processor.addAfterRule(new PullProcess());
|
||||
}
|
||||
|
||||
public void addBeforeRule(MaterialOutVO[] vos, AroundProcesser<MaterialOutVO> processor) {
|
||||
processor.addBeforeRule(new VOSagaFrozenValidateRule(true));
|
||||
}
|
||||
|
||||
public MaterialOutVO[] sign(MaterialOutVO[] vos) {
|
||||
SignBPTemplate<MaterialOutVO> signBP = new SignBPTemplate(BPPlugInPoint.SignBP, this);
|
||||
SagasUtils.frozenAndAddSaga(vos, ICBillType.MaterialOut.getCode(), "1", (OperationInfo)null);
|
||||
Map<String, Serializable> paramMap = new HashMap();
|
||||
paramMap.put("actionname", "sign_4D");
|
||||
paramMap.put("hid", VOEntityUtil.getPksFromAggVO(vos));
|
||||
SagasUtils.compensate(paramMap, IMaterialOutSagasCompensate.class);
|
||||
return (MaterialOutVO[])signBP.sign(vos);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.bs.ic.m4d.sign.rule;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.bs.logging.Logger;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.uif.pub.exception.UifException;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutBodyVO;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.scmpub.res.billtype.IABillType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class
|
||||
PullProcess implements IRule<MaterialOutVO> {
|
||||
public PullProcess() {
|
||||
}
|
||||
|
||||
public void process(MaterialOutVO[] vos) {
|
||||
try {
|
||||
if (vos != null && vos.length != 0) {
|
||||
JSONArray jsonArray1 = new JSONArray();//领料单据
|
||||
JSONArray jsonArray2 = new JSONArray();//退库单据
|
||||
|
||||
for (MaterialOutVO vo : vos) {
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
Object orgCode = hybo.findColValue("org_purchaseorg", "code", "pk_purchaseorg = '" + vo.getHead().getPk_org() + "' ");
|
||||
//如果不是电力电子集团的取消推送
|
||||
if(!checkIfIncludeOrg((String) orgCode)){
|
||||
continue;
|
||||
}
|
||||
if (vo.getBodys().length > 0 && vo.getBodys()[0].getNshouldassistnum().doubleValue() > 0) {
|
||||
jsonArray1.add(this.buildSyncData(vo));
|
||||
}
|
||||
if (vo.getBodys().length > 0 && vo.getBodys()[0].getNshouldassistnum().doubleValue() < 0) {
|
||||
jsonArray2.add(this.buildSyncData(vo));
|
||||
}
|
||||
|
||||
}
|
||||
pushData("/prj-v5-web/ext/api/mrl", jsonArray1);
|
||||
pushData("/prj-v5-web/ext/api/mrl", jsonArray2);
|
||||
|
||||
|
||||
}
|
||||
} catch (UifException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject buildSyncData(MaterialOutVO vo) throws BusinessException {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("billCode", vo.getHead().getVbillcode()); // 已存在的billCode字段
|
||||
obj.put("workOrderCode", null);
|
||||
obj.put("businessType", 17);
|
||||
obj.put("supplierCode", null);
|
||||
obj.put("supplierName", null);
|
||||
obj.put("conditionalCode", null);
|
||||
obj.put("auditCode", null);
|
||||
obj.put("postingStatus", "Y");
|
||||
obj.put("confirmationCode", "Y");
|
||||
obj.put("changeFlag", null);
|
||||
obj.put("companyCode", "DLDZ");
|
||||
obj.put("companyName", "泰开电力电子");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (MaterialOutBodyVO item: vo.getBodys()){
|
||||
JSONObject detailItem = new JSONObject();
|
||||
detailItem.put("billCode", "DSF04-2507010196"); // 与主单据号一致
|
||||
detailItem.put("workOrderCode", "DSF01-2504030005");
|
||||
detailItem.put("rowNum", 1);
|
||||
detailItem.put("mrlCode", "506020103606");
|
||||
detailItem.put("mrlName", null);
|
||||
detailItem.put("planInDate", null);
|
||||
detailItem.put("planInQty", 49.236);
|
||||
detailItem.put("unit", "M2");
|
||||
detailItem.put("contractNo", null);
|
||||
detailItem.put("area", "S003");
|
||||
detailItem.put("subArea", null);
|
||||
jsonArray.add(detailItem);
|
||||
}
|
||||
obj.put("details", jsonArray);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
private void pushData(String requestUrl, JSONArray param) throws BusinessException {
|
||||
String baseUrl = SysParaInitQuery.getParaString("GLOBLE00000000000000", "EPICMESURL");
|
||||
requestUrl = baseUrl + requestUrl;
|
||||
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, param.toJSONString());
|
||||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
Logger.error("EpicMes-Material-req = " + result);
|
||||
|
||||
if ("false".equals(resultObj.getString("success"))) {
|
||||
throw new BusinessException("EpicMes-Material-failerror:" + resultObj.getString("msg"));
|
||||
} else {
|
||||
Logger.error("EpicMes-Material-suc,result[" + resultObj.toJSONString() + "]");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 检查当前组织是否为电力电子
|
||||
*/
|
||||
public boolean checkIfIncludeOrg(String code) throws BusinessException {
|
||||
// 当当前操作人员是BIP的时候 直接return 不走同步MES的业务逻辑
|
||||
String targetCode = SysParaInitQuery.getParaString("GLOBLE00000000000000", "INCLUDEORG");
|
||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数,请前往 [业务参数设置-全局] 配置INCLUDEORG参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(";");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
Logger.debug("当前处理组织校验为电力电子:" + code);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue