ludc
2024-03-13 30f93a0f5615515df2bfe1fdbbadab0308ca0471
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.vci.ubcs.example.service.impl;
 
import com.vci.ubcs.example.service.ICalledIntegrationService;
import com.vci.ubcs.example.util.HttpUtils;
import com.vci.ubcs.example.util.WsClientUtil;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
 
/**
 * 统一申请接口:UBCS编码资源管理系统,被其他集成的系统的通用接口调用示例
 * @author ludc
 * @date 2024/2/27 20:34
 */
@Service
public class CalledIntegrationServiceImpl implements ICalledIntegrationService {
 
    /**
     * 统一申请接口URL
     */
    private String UNIAPPLYURL = "http://localhost/ubcs-code/applyCode";
 
    /**
     * 标准申请接口URL
     */
    private String UNIAPPLYBZURL = "http://localhost/ubcs-code/applyCodeBZ";
 
    /**
     * 对编码系统的统一申请接口调用,rest方式
     */
    @Override
    public void sendApplyCodeByRest() {
        // 组织数据
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("dataType","json");
        //params.add("dataType","xml");根据需求自行选择
        params.add("dataString","");//根据需求自行组织json格式或者xml格式的数据
        // 是xml时的格式示例:
        /*<?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <data systemId="PDM">
            <user ip="localhost" trueName="pwdfree" userName="pwdfree"/>
            <classifys>
            <classify classCode="1045" fullclsfNamePath="" library="10">
            <sections>
            <section name="分类" value="1045"/>
            </sections>
            <objects>
            <object code="" creator="pwdfree" id="MP.100001" operate="create" status="Released">
            <prop key="partclassification" text="分类" value="1045"/>
            <prop key="c6e_partClass" text="Part分类" value="毛坯"/>
            <prop key="c6e_drawingNo" text="图号" value="1000021"/>
            <prop key="c6e_material" text="材料牌号" value="XXX"/>
            <prop key="c6e_blankStandard" text="毛坯标准" value="G235"/>
            <prop key="c6e_materialStandard" text="技术标准" value="AAAA"/>
            </object>
            </objects>
            </classify>
            </classifys>
            </data>
         */
        // 是json时的格式示例
        params.add(
                "dataString",
                "\"data\": { \"classifys\": { \"classify\": [ { \"classCode\": \"1025\", \"fullclsfNamePath\": \"\", \"library\": \"10\", \"sections\": { \"section\": [ { \"name\": \"分类号\", \"value\": \"1025\" }, { \"name\": \"顺序号\", \"value\": \"\" } ] }, \"obejects\": { \"obeject\": [ { \"code\": \"\", \"id\": \"\", \"status\": \"Released\", \"operate\": \"create\", \"creator\": \"0000\", \"prop\": [ { \"key\": \"name\", \"text\": \"名称\", \"value\": \"\" } ] } ] } } ], \"systemId\": \"ERP\", \"user\": { \"ip\": \"127.0.0.1\", \"trueName\": \"00000\", \"userName\": \"test\" } } } "
        );
        MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
        String res = HttpUtils.post(UNIAPPLYURL,params,headers);
    }
 
    /**
     * 对编码系统统一申请接口调用,WebService方式
     */
    @Override
    public void sendApplyCodeByWebService() {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("dataType","json");
        MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
 
 
 
    }
}