Compare commits
	
		
			No commits in common. "2f935db45f9ffbd076849265fc20b7415394ebe3" and "74eea66f2c43edf1fe9903e9c064ad939d2cc464" have entirely different histories.
		
	
	
		
			2f935db45f
			...
			74eea66f2c
		
	
		| 
						 | 
				
			
			@ -1,101 +0,0 @@
 | 
			
		|||
//
 | 
			
		||||
// Source code recreated from a .class file by IntelliJ IDEA
 | 
			
		||||
// (powered by FernFlower decompiler)
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
package nc.pubimpl.ic.m45.m25;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSON;
 | 
			
		||||
import com.alibaba.fastjson.JSONArray;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import nc.bs.ic.pub.rewrite.RewriteBPTemplate;
 | 
			
		||||
import nc.bs.logging.Log;
 | 
			
		||||
import nc.bs.logging.Logger;
 | 
			
		||||
import nc.bs.uapbd.util.MyHelper;
 | 
			
		||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
 | 
			
		||||
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
 | 
			
		||||
import nc.vo.ic.pub.util.NCBaseTypeUtils;
 | 
			
		||||
import nc.vo.ml.NCLangRes4VoTransl;
 | 
			
		||||
import nc.vo.pub.BusinessException;
 | 
			
		||||
import nc.vo.pub.lang.UFDouble;
 | 
			
		||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class Bill45For25Rewrite extends RewriteBPTemplate<PurchaseInBodyVO> {
 | 
			
		||||
    private static final Log logger = Log.getInstance("qyMesLog");
 | 
			
		||||
    private static final String reqUrl = "/IF_QyErpApi.ashx?action=addRkdFpxx";
 | 
			
		||||
 | 
			
		||||
    public Bill45For25Rewrite() {
 | 
			
		||||
        super(PurchaseInBodyVO.class);
 | 
			
		||||
        this.additionalFields(new String[]{"nnum"});
 | 
			
		||||
        this.addUpdateField("nsignnum");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void reWriteAfterProcess(PurchaseInBodyVO[] vos) throws BusinessException {
 | 
			
		||||
        UFDouble dvalue = null;
 | 
			
		||||
        UFDouble num = null;
 | 
			
		||||
        UFDouble nsignnum = null;
 | 
			
		||||
 | 
			
		||||
        for (PurchaseInBodyVO vo : vos) {
 | 
			
		||||
            num = NCBaseTypeUtils.abs(vo.getNnum());
 | 
			
		||||
            nsignnum = NCBaseTypeUtils.abs(vo.getNsignnum());
 | 
			
		||||
            dvalue = NCBaseTypeUtils.sub(num, new UFDouble[]{nsignnum});
 | 
			
		||||
            if (NCBaseTypeUtils.isLtZero(dvalue)) {
 | 
			
		||||
                throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008002_0", "04008002-0092"));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        super.reWriteAfterProcess(vos);
 | 
			
		||||
        this.syncQyMes(vos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 同步启源的累计开票数量
 | 
			
		||||
     *
 | 
			
		||||
     * @param vos
 | 
			
		||||
     * @throws BusinessException
 | 
			
		||||
     */
 | 
			
		||||
    protected void syncQyMes(PurchaseInBodyVO[] vos) throws BusinessException {
 | 
			
		||||
        JSONArray contentParam = new JSONArray();
 | 
			
		||||
        for (PurchaseInBodyVO vo : vos) {
 | 
			
		||||
            // 启源入库单行主键
 | 
			
		||||
            String vbdef20 = vo.getVbdef20();
 | 
			
		||||
            if (vbdef20 == null || vbdef20.isEmpty() || "~".equals(vbdef20)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            String nsignnum = vo.getNsignnum().toString();
 | 
			
		||||
            JSONObject param = new JSONObject();
 | 
			
		||||
            param.put("rkqdid", vbdef20); // 启源入库单行主键
 | 
			
		||||
            param.put("ydyfpsl", nsignnum);// 累计开票数量
 | 
			
		||||
            contentParam.add(param);
 | 
			
		||||
        }
 | 
			
		||||
        if (!contentParam.isEmpty()) {
 | 
			
		||||
            JSONObject data = new JSONObject();
 | 
			
		||||
            data.put("batchid", System.currentTimeMillis());
 | 
			
		||||
            data.put("Content", contentParam);
 | 
			
		||||
            pushData(data);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 推送同步数据
 | 
			
		||||
     */
 | 
			
		||||
    private void pushData(JSONObject param) throws BusinessException {
 | 
			
		||||
        Map<String, String> configParams = MyHelper.getConfigParams("jm-config", null);
 | 
			
		||||
        String jsonStr = JSON.toJSONString(param);
 | 
			
		||||
        logger.error("qyMes-purchasein-param = " + jsonStr);
 | 
			
		||||
        NCCForUAPLogger.debug("qyMes-purchasein-param = " + jsonStr);
 | 
			
		||||
        String baseUrl = configParams.get("qmsBaseUrl");
 | 
			
		||||
        String requestUrl = baseUrl + reqUrl;
 | 
			
		||||
        logger.error("qyMes-purchasein-url = " + requestUrl);
 | 
			
		||||
        String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
 | 
			
		||||
        NCCForUAPLogger.debug("qyMes-purchasein-result = " + result);
 | 
			
		||||
        JSONObject resultObj = JSONObject.parseObject(result);
 | 
			
		||||
        logger.error("qyMes-purchasein-res = " + result);
 | 
			
		||||
 | 
			
		||||
        if (!"true".equals(resultObj.getString("success"))) {
 | 
			
		||||
            Logger.error("qyMes-purchasein-error,result[" + resultObj.toJSONString() + "]");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +1,10 @@
 | 
			
		|||
package nc.bs.mmpac.pmo.pac0002.bp.rule;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSONArray;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.fasterxml.jackson.databind.ObjectMapper;
 | 
			
		||||
import com.google.gson.Gson;
 | 
			
		||||
import nc.bs.dao.BaseDAO;
 | 
			
		||||
import nc.bs.dao.DAOException;
 | 
			
		||||
import nc.bs.framework.common.InvocationInfoProxy;
 | 
			
		||||
import nc.bs.logging.Log;
 | 
			
		||||
| 
						 | 
				
			
			@ -10,6 +12,8 @@ import nc.bs.trade.business.HYPubBO;
 | 
			
		|||
import nc.bs.trade.business.HYSuperDMO;
 | 
			
		||||
import nc.bs.uapbd.util.MyHelper;
 | 
			
		||||
import nc.impl.pubapp.pattern.rule.IRule;
 | 
			
		||||
import nc.jdbc.framework.processor.MapProcessor;
 | 
			
		||||
import nc.uif.pub.exception.UifException;
 | 
			
		||||
import nc.vo.bd.defdoc.DefdocVO;
 | 
			
		||||
import nc.vo.cmp.util.StringUtils;
 | 
			
		||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
 | 
			
		||||
| 
						 | 
				
			
			@ -38,8 +42,6 @@ import java.util.Map;
 | 
			
		|||
 | 
			
		||||
/**
 | 
			
		||||
 * BIP 系统将生产订单类型为“内配订单 ”的生产订单按照物料编码+项目号向PLM 传递设计任务, PLM 方接收后根据项目号,与成套产品设计任务挂载到相同位置。
 | 
			
		||||
 *
 | 
			
		||||
 * @author lihao
 | 
			
		||||
 */
 | 
			
		||||
public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +58,6 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
    private Map<String, String> configParams;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void process(PMOAggVO[] pmoAggVOS) {
 | 
			
		||||
        if (ArrayUtil.isEmpty(pmoAggVOS)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -71,10 +72,10 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // 推送到思普PLM系统
 | 
			
		||||
            // 推送到锐制系统
 | 
			
		||||
            pushToRZMOM(filteredOrders);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            logDl.error("同步生产订单到SPPLM系统失败: " + e.getMessage());
 | 
			
		||||
            logDl.error("同步生产订单到RZ系统失败: " + e.getMessage());
 | 
			
		||||
            ExceptionUtils.wrappException(e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +99,7 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
               if (itemVO != null) {
 | 
			
		||||
//                   NO	产品品号	 cmaterialvid	物料编码
 | 
			
		||||
//                   NAME	产品名称	name	物料名称
 | 
			
		||||
//                   ASUSER34	项目名称	projectName	项目名称
 | 
			
		||||
//                   ASUSER34	项目名称	project_name	项目名称
 | 
			
		||||
//                   ASUSER28	生产计划号	vsrccode	来源单据号	销售订单号
 | 
			
		||||
//                   AB012	数量	nastnum	数量
 | 
			
		||||
//                   GSDM	公司代码
 | 
			
		||||
| 
						 | 
				
			
			@ -110,16 +111,17 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
                   Object no = hybo.findColValue("bd_material", "code", "pk_material = '"+itemVO.getCmaterialvid()+"' ");
 | 
			
		||||
 | 
			
		||||
                   Object name = hybo.findColValue("bd_material", "name", "pk_material = '"+itemVO.getCmaterialvid()+"' ");
 | 
			
		||||
                    Object projectName = hybo.findColValue("bd_project", "projectName", " pk_project = '" + itemVO.getCprojectid() + "' ");
 | 
			
		||||
                   Object pk_project = hybo.findColValue("bd_project", "project_name", " pk_project = '" + itemVO.getCprojectid() + "' ");
 | 
			
		||||
 | 
			
		||||
                   Object GSDM = hybo.findColValue("org_factory", "code", " pk_factory = '" + parentVO.getPk_org() + "' ");
 | 
			
		||||
 | 
			
		||||
                   request.put("no",no);
 | 
			
		||||
 | 
			
		||||
                   request.put("name",name);
 | 
			
		||||
 | 
			
		||||
                    request.put("ASUSER34", projectName);
 | 
			
		||||
                   request.put("ASUSER34", pk_project);
 | 
			
		||||
 | 
			
		||||
                    request.put("ASUSER28", itemVO.getVfirstcode());
 | 
			
		||||
                   request.put("ASUSER28", itemVO.getVsrccode());
 | 
			
		||||
                   request.put("AB012", itemVO.getNastnum());
 | 
			
		||||
 | 
			
		||||
                   request.put("GSDM", GSDM);
 | 
			
		||||
| 
						 | 
				
			
			@ -146,12 +148,12 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
            plmBaseUrl = configParams.get("plmBaseUrl");
 | 
			
		||||
            plmUser = configParams.get("plmUser");
 | 
			
		||||
            token = getToken();
 | 
			
		||||
            logDl.error("AfterApproveSyncPLMRule-param = " + jsonArrayStr);
 | 
			
		||||
            logDl.info("请求参数 :"+jsonArrayStr);
 | 
			
		||||
            String responseString= this.doPost(plmBaseUrl+pmourl,jsonArrayStr);
 | 
			
		||||
            logDl.error("AfterApproveSyncPLMRule-res = " + responseString);
 | 
			
		||||
            logDl.info("返回结果 :"+responseString);
 | 
			
		||||
            Gson gson = new Gson();
 | 
			
		||||
            Map result = gson.fromJson(responseString, Map.class);
 | 
			
		||||
            if (!"true".equals(result.get("success").toString())) {
 | 
			
		||||
            if (!result.get("success").toString().equals("true")) {
 | 
			
		||||
                throw new BusinessException(result.get("msg").toString());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +183,6 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
 | 
			
		||||
        return filteredOrders;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Map<String, String> getConfigParams(String code) {
 | 
			
		||||
        Map<String, String> map = new HashMap<>();
 | 
			
		||||
        String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='[code]' and dr=0 ) and dr=0";
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +200,6 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
        }
 | 
			
		||||
        return map;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String doPost(String requestUrl, String param) throws IOException {
 | 
			
		||||
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
 | 
			
		||||
        cm.setMaxTotal(500);
 | 
			
		||||
| 
						 | 
				
			
			@ -221,6 +221,8 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取token
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -237,7 +239,6 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
        }
 | 
			
		||||
        return token;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String doGet(String requestUrl, Map<String, String> paramMap) throws IOException {
 | 
			
		||||
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
 | 
			
		||||
        cm.setMaxTotal(5000);
 | 
			
		||||
| 
						 | 
				
			
			@ -266,5 +267,4 @@ public class AfterApproveSyncPLMRule implements IRule<PMOAggVO> {
 | 
			
		|||
        get.releaseConnection();
 | 
			
		||||
        return responseString;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue