niying
2024-01-24 3c49f1e5c375801f546eb7e0736280693f7187cf
src/main/java/com/itstyle/mdm/utils/MdmUtils.java
@@ -23,7 +23,7 @@
public class MdmUtils {
    @Value("${MDM_ADRESS}")
    private static String MDM_ADRESS;
    private String MDM_ADRESS;
    @Autowired
    private MdmService mdmService;
@@ -48,56 +48,6 @@
            if(200 == code){
                //成功
                String records = httpClientResult.getContent();
                /*String records = "{\n" +
                        "    \"current\": 1,\n" +
                        "    \"orders\": [],\n" +
                        "    \"pages\": 303,\n" +
                        "    \"records\": [\n" +
                        "        {\n" +
                        "            \"aliascode\": \"000\",\n" +
                        "            \"appfrom\": \"1\",\n" +
                        "            \"applicationaccountid\": \"D15600005811650001\",\n" +
                        "            \"applicationname\": \"审核管理员\",\n" +
                        "            \"attri1\": \"\",\n" +
                        "            \"attri10\": \"\",\n" +
                        "            \"attri11\": \"\",\n" +
                        "            \"attri12\": \"产品\",\n" +
                        "            \"attri13\": \"1667957805944\",\n" +
                        "            \"attri14\": \"\",\n" +
                        "            \"attri15\": \"0003.000\",\n" +
                        "            \"attri2\": \"\",\n" +
                        "            \"attri3\": \"\",\n" +
                        "            \"attri4\": \"\",\n" +
                        "            \"attri5\": \"\",\n" +
                        "            \"attri6\": \"\",\n" +
                        "            \"attri7\": \"\",\n" +
                        "            \"attri8\": \"\",\n" +
                        "            \"attri9\": \"\",\n" +
                        "            \"companyid\": \"1560000581165\",\n" +
                        "            \"employeeid\": \"\",\n" +
                        "            \"globtgccode\": \"\",\n" +
                        "            \"id\": 1668994782539,\n" +
                        "            \"industrycode\": \"517\",\n" +
                        "            \"industryname\": \"医药卫生保健化妆品业\",\n" +
                        "            \"name\": \"感冒药\",\n" +
                        "            \"nameen\": \"abc\",\n" +
                        "            \"note\": \"\",\n" +
                        "            \"ontologynamecode\": \"9000000003\",\n" +
                        "            \"pym\": \"gmy\",\n" +
                        "            \"rebacklockflag\": \"\",\n" +
                        "            \"regioncode\": \"\",\n" +
                        "            \"regionlevel\": \"\",\n" +
                        "            \"repeatflag\": \"\",\n" +
                        "            \"status\": \"200\",\n" +
                        "            \"tgcoriginalcode\": \"9000000003.000\",\n" +
                        "            \"updatedat\": 1668995367562,\n" +
                        "            \"updatetime\": 1668995367562\n" +
                        "        }\n" +
                        "    ],\n" +
                        "    \"searchCount\": true,\n" +
                        "    \"size\": 1,\n" +
                        "    \"total\": 303\n" +
                        "}";*/
                records = records.replaceAll("\\p{Z}", "");
                JSONObject jsonObj = JSON.parseObject(records);
                records = jsonObj.getString("records");
@@ -130,6 +80,51 @@
    }
    /**
     * MDM计量单位数据获取
     * @return
     */
    public String queryUnit(){
        MdmEnum anEnum = MdmEnum.getMdmEnumByAddress("计量单位业务基础数据编码获取");
        StringBuffer returnJson = new StringBuffer();
        Map<String,String> params = new HashMap<>();
        params.put("code","1560000581165.1560000576507.a94a779e9e6d3ecbb646e39477dad6ec");//授权码
        params.put("type",anEnum.getType());//类型
        String address = anEnum.getAddress();
        try {
            HttpClientResult httpClientResult = MdmApiUtils.doPost(MDM_ADRESS+address, null, params);
            int code = httpClientResult.getCode();
            if(200 == code){
                //成功
                String records = httpClientResult.getContent();
                records = records.replaceAll("\\p{Z}", "");
                JSONObject jsonObj = JSON.parseObject(records);
                records = jsonObj.getString("records");
                JSONArray recordArray = JSON.parseArray(records);//物料数据信息
                //将数据保存至数据库
                JSONArray newJson = mdmService.saveMdmData(recordArray);
                if(newJson.size()!=0){
                    //定义返回json格式
                    returnJson.append("{\n" +
                            "  \"code\": 200,\n" +
                            "  \"data\":"+newJson.toJSONString());
                    returnJson.append(",\n" +
                            "  \"message\": \"请求成功\",\n" +
                            "  \"success\": true\n" +
                            "}");
                    //返回json格式参数
                    String toString = returnJson.toString();
                    System.out.println(toString);
                    //分发增量数据至异构系统
                    distributeDataToSys(toString,"计量单位业务基础数据编码获取");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
    /**
     * 分发主数据数据至异构系统
     * @param jsonParam
     */