ludc
2024-03-13 30f93a0f5615515df2bfe1fdbbadab0308ca0471
Source/ExampleIntegratedPushCalled/src/main/java/com/vci/ubcs/example/service/impl/CalledIntegrationServiceImpl.java
@@ -1,7 +1,12 @@
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编码资源管理系统,被其他集成的系统的通用接口调用示例
@@ -12,19 +17,67 @@
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方式调用
     * 对编码系统统一申请接口调用,WebService方式
     */
    @Override
    public void sendApplyCodeByWebService() {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("dataType","json");
        MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    }
}