材料出库审核后推送艾普MES-v0
This commit is contained in:
		
							parent
							
								
									dbcbb3e1ca
								
							
						
					
					
						commit
						6567a5cc07
					
				| 
						 | 
					@ -1,119 +1,116 @@
 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Source code recreated from a .class file by IntelliJ IDEA
 | 
					 | 
				
			||||||
// (powered by FernFlower decompiler)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
package nc.bs.ic.m4d.sign.rule;
 | 
					package nc.bs.ic.m4d.sign.rule;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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.logging.Logger;
 | 
					import nc.bs.logging.Log;
 | 
				
			||||||
import nc.bs.trade.business.HYPubBO;
 | 
					import nc.bs.trade.business.HYPubBO;
 | 
				
			||||||
 | 
					import nc.bs.uapbd.util.MyHelper;
 | 
				
			||||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
 | 
					import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
 | 
				
			||||||
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.ColumnListProcessor;
 | 
					 | 
				
			||||||
import nc.jdbc.framework.processor.ColumnProcessor;
 | 
					 | 
				
			||||||
import nc.jdbc.framework.processor.MapListProcessor;
 | 
					 | 
				
			||||||
import nc.jdbc.framework.processor.MapProcessor;
 | 
					import nc.jdbc.framework.processor.MapProcessor;
 | 
				
			||||||
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.MaterialOutBodyVO;
 | 
				
			||||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
 | 
					import nc.vo.ic.m4d.entity.MaterialOutVO;
 | 
				
			||||||
import nc.vo.pub.BusinessException;
 | 
					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;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 入库领料
 | 
					 * 入库领料-材料出库审核后推送艾普MES
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author lihao
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class
 | 
					public class PullProcess implements IRule<MaterialOutVO> {
 | 
				
			||||||
PullProcess implements IRule<MaterialOutVO> {
 | 
					 | 
				
			||||||
    public PullProcess() {
 | 
					    public PullProcess() {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String LOG_INFO_NAME = "dldzlog";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
 | 
				
			||||||
 | 
					    private Map<String, String> configParams;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void process(MaterialOutVO[] vos) {
 | 
					    public void process(MaterialOutVO[] vos) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            if (vos != null && vos.length != 0) {
 | 
					            if (vos != null && vos.length != 0) {
 | 
				
			||||||
                JSONArray jsonArray1 = new JSONArray();//领料单据
 | 
					                JSONArray jsonArray1 = new JSONArray();// 领料单据
 | 
				
			||||||
                JSONArray jsonArray2 = new JSONArray();//退库单据
 | 
					                JSONArray jsonArray2 = new JSONArray();// 退库单据
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (MaterialOutVO vo : vos) {
 | 
					                for (MaterialOutVO vo : vos) {
 | 
				
			||||||
                    HYPubBO hybo = new HYPubBO();
 | 
					                    HYPubBO hybo = new HYPubBO();
 | 
				
			||||||
                    Object orgCode = hybo.findColValue("org_purchaseorg", "code", "pk_purchaseorg = '" + vo.getHead().getPk_org() + "' ");
 | 
					                    String orgCode = (String) hybo.findColValue("org_purchaseorg", "code", "pk_purchaseorg = '" + vo.getHead().getPk_org() + "' ");
 | 
				
			||||||
                    //如果不是电力电子集团的取消推送
 | 
					                    configParams = MyHelper.getConfigParams("Dldz-config", null);
 | 
				
			||||||
                    if(!checkIfIncludeOrg((String) orgCode)){
 | 
					                    if (configParams.isEmpty()) {
 | 
				
			||||||
 | 
					                        throw new BusinessException("电力电子的艾普MES接口缺少配置");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 如果不是电力电子集团的取消推送
 | 
				
			||||||
 | 
					                    if (MyHelper.checkIfDldzOrg(orgCode, configParams)) {
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 领料单默认值17 退库单默认值37
 | 
				
			||||||
                    if (vo.getBodys().length > 0 && vo.getBodys()[0].getNshouldassistnum().doubleValue() > 0) {
 | 
					                    if (vo.getBodys().length > 0 && vo.getBodys()[0].getNshouldassistnum().doubleValue() > 0) {
 | 
				
			||||||
                        jsonArray1.add(this.buildSyncData(vo,17));
 | 
					                        jsonArray1.add(this.buildSyncData(vo, 17));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (vo.getBodys().length > 0 && vo.getBodys()[0].getNshouldassistnum().doubleValue() < 0) {
 | 
					                    if (vo.getBodys().length > 0 && vo.getBodys()[0].getNshouldassistnum().doubleValue() < 0) {
 | 
				
			||||||
                        jsonArray2.add(this.buildSyncData(vo,37));
 | 
					                        jsonArray2.add(this.buildSyncData(vo, 37));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if(jsonArray1.size() > 0){
 | 
					
 | 
				
			||||||
 | 
					                if (!jsonArray1.isEmpty()) {
 | 
				
			||||||
                    pushData("/prj-v5-web/ext/api/getMrlReq", jsonArray1);
 | 
					                    pushData("/prj-v5-web/ext/api/getMrlReq", jsonArray1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if(jsonArray2.size() > 0){
 | 
					                if (!jsonArray2.isEmpty()) {
 | 
				
			||||||
                    pushData("/prj-v5-web/ext/api/returnMrl", jsonArray2);
 | 
					                    pushData("/prj-v5-web/ext/api/returnMrl", jsonArray2);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (UifException e) {
 | 
					 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					 | 
				
			||||||
        } catch (BusinessException e) {
 | 
					        } catch (BusinessException e) {
 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					            logDl.error("EpicMes-MaterialOut-req = " + e.getMessage(), e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private JSONObject buildSyncData(MaterialOutVO vo,int businessType ) throws BusinessException {
 | 
					    private JSONObject buildSyncData(MaterialOutVO vo, int businessType) throws BusinessException {
 | 
				
			||||||
        JSONObject obj = new JSONObject();
 | 
					        JSONObject obj = new JSONObject();
 | 
				
			||||||
        obj.put("billCode", vo.getHead().getVbillcode()); // 已存在的billCode字段
 | 
					        obj.put("billCode", vo.getHead().getVbillcode()); // 已存在的billCode字段
 | 
				
			||||||
        obj.put("workOrderCode", null);
 | 
					        obj.put("workOrderCode", null);// 工单号(可为空)
 | 
				
			||||||
        obj.put("businessType", businessType);
 | 
					        obj.put("businessType", businessType); // 业务类型
 | 
				
			||||||
        obj.put("supplierCode", null);
 | 
					        obj.put("supplierCode", null);// 供应商编码(可为空)
 | 
				
			||||||
        obj.put("supplierName", null);
 | 
					        obj.put("supplierName", null);// 供应商名称(可为空)
 | 
				
			||||||
        obj.put("conditionalCode", null);
 | 
					        obj.put("conditionalCode", null);// 状况码(可为空,用于控制业务逻辑)
 | 
				
			||||||
        obj.put("auditCode", null);
 | 
					        obj.put("auditCode", "Y");// 审核码 N:未审核 Y:已审核 X:已作废
 | 
				
			||||||
        obj.put("postingStatus", "Y");
 | 
					        obj.put("postingStatus", "Y");// 过账状态(Y:已过账,N:未过账)
 | 
				
			||||||
        obj.put("confirmationCode", "Y");
 | 
					        obj.put("confirmationCode", "Y"); // 确认码(Y:已确认,N:未确认)
 | 
				
			||||||
        obj.put("changeFlag", null);
 | 
					        obj.put("changeFlag", null); // 变更标识(可为空,Y:已变更,N:未变更)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        BaseDAO dao = new BaseDAO();
 | 
					        BaseDAO dao = new BaseDAO();
 | 
				
			||||||
        String orgsql = "select code,name from org_purchaseorg where pk_purchaseorg = '" + vo.getHead().getPk_org() + "' ";
 | 
					        String orgsql = "select code,name from org_purchaseorg where pk_purchaseorg = '" + vo.getHead().getPk_org() + "' ";
 | 
				
			||||||
        Map<String,Object> tr = (Map<String, Object>) dao.executeQuery( orgsql,  new MapProcessor());
 | 
					        Map<String, Object> tr = (Map<String, Object>) dao.executeQuery(orgsql, new MapProcessor());
 | 
				
			||||||
        obj.put("companyCode", tr.get("code"));
 | 
					        obj.put("companyCode", tr.get("code"));// 公司编码
 | 
				
			||||||
        obj.put("companyName", tr.get("name"));
 | 
					        obj.put("companyName", tr.get("name"));// 公司名称
 | 
				
			||||||
        JSONArray jsonArray = new JSONArray();
 | 
					        JSONArray jsonArray = new JSONArray();
 | 
				
			||||||
        for (MaterialOutBodyVO item: vo.getBodys()){
 | 
					        for (MaterialOutBodyVO item : vo.getBodys()) {
 | 
				
			||||||
            JSONObject detailItem = new JSONObject();
 | 
					            JSONObject detailItem = new JSONObject();
 | 
				
			||||||
            detailItem.put("billCode", vo.getHead().getVbillcode());  // 与主单据号一致
 | 
					            detailItem.put("billCode", vo.getHead().getVbillcode());  // 与主单据号一致
 | 
				
			||||||
            detailItem.put("workOrderCode", null);
 | 
					            detailItem.put("workOrderCode", null);// 工单号(关联工单)
 | 
				
			||||||
            detailItem.put("rowNum",Integer.parseInt(item.getCrowno()) );
 | 
					            detailItem.put("rowNum", Integer.parseInt(item.getCrowno()));// 明细行号(整数)
 | 
				
			||||||
            String mrlsql = "select code,name from bd_material_v where pk_source = '" + item.getCmaterialoid() + "' ";
 | 
					            String mrlsql = "select code,name from bd_material_v where pk_source = '" + item.getCmaterialoid() + "' ";
 | 
				
			||||||
            Map<String,Object> mrl = (Map<String, Object>) dao.executeQuery( mrlsql,  new MapProcessor());
 | 
					            Map<String, Object> mrl = (Map<String, Object>) dao.executeQuery(mrlsql, new MapProcessor());
 | 
				
			||||||
            detailItem.put("mrlCode", mrl.get("code"));
 | 
					            detailItem.put("mrlCode", mrl.get("code"));
 | 
				
			||||||
            detailItem.put("mrlName", mrl.get("name"));
 | 
					            detailItem.put("mrlName", mrl.get("name"));
 | 
				
			||||||
            detailItem.put("planInDate", item.getDbizdate().toStdString());
 | 
					            detailItem.put("planInDate", item.getDbizdate().toStdString()); // 计划入库日期(可为空)
 | 
				
			||||||
            detailItem.put("planInQty", item.getNassistnum().abs().doubleValue());//MES退货单数量为正,需要转换
 | 
					            //  计划入库数量(浮点数)MES退货单数量为正,需要转换
 | 
				
			||||||
 | 
					            detailItem.put("planInQty", item.getNassistnum().abs().doubleValue());
 | 
				
			||||||
            String unitsql = "select code from bd_measdoc where pk_measdoc = '" + item.getCastunitid() + "' ";
 | 
					            String unitsql = "select code from bd_measdoc where pk_measdoc = '" + item.getCastunitid() + "' ";
 | 
				
			||||||
            Map<String,Object> unit = (Map<String, Object>) dao.executeQuery( unitsql,  new MapProcessor());
 | 
					            Map<String, Object> unit = (Map<String, Object>) dao.executeQuery(unitsql, new MapProcessor());
 | 
				
			||||||
            detailItem.put("unit", unit.get("code"));
 | 
					            detailItem.put("unit", unit.get("code"));// 单位
 | 
				
			||||||
            detailItem.put("contractNo", null);
 | 
					            detailItem.put("contractNo", null);// 合同号(可为空)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            String areasql = "select code from bd_stordoc where pk_stordoc = '" + item.getCbodywarehouseid() + "' ";
 | 
					            String areasql = "select code from bd_stordoc where pk_stordoc = '" + item.getCbodywarehouseid() + "' ";
 | 
				
			||||||
            Map<String,Object> area = (Map<String, Object>) dao.executeQuery( areasql,  new MapProcessor());
 | 
					            Map<String, Object> area = (Map<String, Object>) dao.executeQuery(areasql, new MapProcessor());
 | 
				
			||||||
            detailItem.put("area", area.get("code"));
 | 
					            detailItem.put("area", area.get("code"));// 仓库
 | 
				
			||||||
            detailItem.put("subArea", item.getVcontractcode());
 | 
					            detailItem.put("subArea", item.getVcontractcode());// 库位
 | 
				
			||||||
            jsonArray.add(detailItem);
 | 
					            jsonArray.add(detailItem);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        obj.put("details", jsonArray);
 | 
					        obj.put("details", jsonArray);
 | 
				
			||||||
| 
						 | 
					@ -122,37 +119,17 @@ PullProcess implements IRule<MaterialOutVO> {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void pushData(String requestUrl, JSONArray param) throws BusinessException {
 | 
					    private void pushData(String requestUrl, JSONArray param) throws BusinessException {
 | 
				
			||||||
        String baseUrl = SysParaInitQuery.getParaString("GLOBLE00000000000000", "EPICMESURL");
 | 
					        String baseUrl = configParams.get("epicMesUrl");
 | 
				
			||||||
//        baseUrl="http://192.168.55.39:8080";
 | 
					 | 
				
			||||||
        requestUrl = baseUrl + requestUrl;
 | 
					        requestUrl = baseUrl + requestUrl;
 | 
				
			||||||
        String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, param.toJSONString());
 | 
					        String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, param.toJSONString());
 | 
				
			||||||
        JSONObject resultObj = JSONObject.parseObject(result);
 | 
					        JSONObject resultObj = JSONObject.parseObject(result);
 | 
				
			||||||
        Logger.error("EpicMes-Material-req = " + result);
 | 
					        logDl.error("EpicMes-MaterialOut-req = " + result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ("false".equals(resultObj.getString("success"))) {
 | 
					        if (!"1".equals(resultObj.getString("flag"))) {
 | 
				
			||||||
            throw new BusinessException("EpicMes-Material-failerror:" + resultObj.getString("msg"));
 | 
					            throw new BusinessException("EpicMes-MaterialOut-failerror:" + resultObj.getString("msg"));
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Logger.error("EpicMes-Material-suc,result[" + resultObj.toJSONString() + "]");
 | 
					            logDl.error("EpicMes-MaterialOut-suc,result[" + resultObj.toJSONString() + "]");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 检查当前组织是否为电力电子
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public boolean checkIfIncludeOrg(String code) throws BusinessException {
 | 
					 | 
				
			||||||
        // 当当前操作人员是BIP的时候 直接return 不走同步MES的业务逻辑
 | 
					 | 
				
			||||||
        String targetCode = SysParaInitQuery.getParaString("GLOBLE00000000000000", "INCLUDEORG");
 | 
					 | 
				
			||||||
//        targetCode="C013;C014;C015;C017";
 | 
					 | 
				
			||||||
        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