package com.vci.ubcs.example.controller; import com.alibaba.fastjson.JSONObject; import com.vci.ubcs.example.util.HttpUtils; import lombok.AllArgsConstructor; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; /** * @author ludc * @date 2024/2/20 22:04 */ @RestController @AllArgsConstructor @RequestMapping("/erpTest") public class MyServiceTest { @GetMapping("/test1") public void testMyService() { /*MultiValueMap params = new LinkedMultiValueMap<>(); params.add("dataType","json"); // params.add("dataString","data:{object:[{\"classCodde\":\"RENYUAN\",\"itemid\":\"19986015\",\"code\":\"698021151\",\"library\":\"RENYUAN\",\"pro\":[{\"filedName\":\"sfz\",\"outName\":\"身份证\",\"filedValue\":\"\"}]}]}"); NodeJosnDTO nodeJosnDTO = new NodeJosnDTO(); NodedataDTO nodeDataDTO = new NodedataDTO(); NodeObjectDTO nodeObjectDTO = new NodeObjectDTO(); nodeObjectDTO.setCode("698021151");//设置编码 nodeObjectDTO.setClassCode("RENYUAN"); nodeObjectDTO.setStatus("Released"); nodeObjectDTO.setItemid("19986015"); nodeObjectDTO.setLibrary("RENYUAN"); List nodeObjectDTOS = new ArrayList<>(); nodeObjectDTOS.add(nodeObjectDTO); nodeDataDTO.setObject(nodeObjectDTOS); nodeJosnDTO.setData(nodeDataDTO); List nodeProDTOS = new ArrayList<>(); NodeProDTO nodeProDTO = new NodeProDTO(); nodeProDTO.setFiledName("sfz"); nodeProDTO.setOutname("身份证"); nodeProDTO.setFiledValue(""); nodeProDTOS.add(nodeProDTO); nodeObjectDTO.setPro(nodeProDTOS); Object object = JSONObject.toJSON(nodeJosnDTO); String sendString = object.toString(); XStream xStream = new XStream(new DomDriver()); xStream.processAnnotations(NodedataDTO.class); xStream.autodetectAnnotations(true); // sendString = "\n" + xStream.toXML(nodeDataDTO); params.add("dataString",sendString); MultiValueMap headers = new LinkedMultiValueMap<>(); String backString = HttpUtils.post("http://localhost:8118/test/test", params, headers);*/ } }