docus_webservice_1.1
lzy 4 years ago
parent 846e692614
commit 98a8b2019d

@ -3,6 +3,7 @@ package com.docus.webservice.config;
import com.docus.webservice.enums.Codes;
import com.docus.webservice.handler.ITBasicWebService;
import com.docus.webservice.handler.TBasicWebService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -10,7 +11,6 @@ import javax.xml.ws.Endpoint;
@Configuration
public class WebServiceConfig {
//把实现类交给spring管理
@Bean
public ITBasicWebService tBasicWebService() {
@ -20,7 +20,7 @@ public class WebServiceConfig {
@Bean
public Endpoint endpoint() {
System.out.println("-----------------------web service服务已发布-------------------------");
String address = "http://localhost:" + Codes.EXTERNAL.getCode()+"/" + Codes.EXTERNAL.getMessage();
String address = "http://"+"0.0.0.0"+":" + Codes.EXTERNAL.getCode()+"/" + Codes.EXTERNAL.getMessage();
Endpoint publish = Endpoint.publish(address, tBasicWebService());
System.out.println(" "+address);
return publish;

@ -19,7 +19,7 @@ public enum Codes {
//web service 服务名
EXTERNAL("9201","docus_tBasic_data"),
//静态文件存放位置
JSON_ADDRESS("999",System.getProperty("user.dir")+"\\docus-webservice\\dataConfig\\homeQualitySet.json"),
JSON_ADDRESS("999","\\dataConfig\\homeQualitySet.json"),
//接收二级节点
MSG("201","Msg"),
//接收三级节点

@ -16,6 +16,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.jws.WebService;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -29,6 +31,16 @@ public class TBasicWebService implements ITBasicWebService {
@Autowired
private TBasicSubMapper tBasicSubMapper;
private String CurrentPath(){
File dir = new File(".");
String currentpath ="";
try {
currentpath = dir.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
return currentpath;
}
@Override
public String savaAndSub(String tbasic) {
@ -37,7 +49,7 @@ public class TBasicWebService implements ITBasicWebService {
//解析xml
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
//解析json映射文件
String json = JsonUtils.readJsonFile(Codes.JSON_ADDRESS.getMessage());
String json = JsonUtils.readJsonFile(CurrentPath()+Codes.JSON_ADDRESS.getMessage());
Map jsonMap = JSON.parseObject(json, Map.class);
HashMap<String, Object> tBasicMap = new HashMap<>();
HashMap<String, Object> tBasicSubMap = new HashMap<>();
@ -104,7 +116,9 @@ public class TBasicWebService implements ITBasicWebService {
//解析xml
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
//解析json映射文件
String json = JsonUtils.readJsonFile(Codes.JSON_ADDRESS.getMessage());
String path=CurrentPath()+Codes.JSON_ADDRESS.getMessage();
System.out.println(path);
String json = JsonUtils.readJsonFile(path);
Map jsonMap = JSON.parseObject(json, Map.class);
HashMap<String, Object> tBasicMap = new HashMap<>();
HashMap<String, Object> tBasicSubMap = new HashMap<>();
@ -138,7 +152,7 @@ public class TBasicWebService implements ITBasicWebService {
int insert;
if (tBasicMap != null && tBasicMap.size() > 0) {
tBasic = JSON.parseObject(JSON.toJSONString(tBasicMap), TBasic.class);
if(StringUtils.isNotBlank(tBasic.getEmpId())){
if(StringUtils.isBlank(tBasic.getEmpId())){
return ResultUtils.fail("emp_id字段不能为空值");
}
TBasic selectTBasic = tBasicMapper.selectOne(new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
@ -166,6 +180,6 @@ public class TBasicWebService implements ITBasicWebService {
e.printStackTrace();
return ResultUtils.fail();
}
return null;
return ResultUtils.success().asXML();
}
}

@ -1,13 +0,0 @@
package com.docus.webservice;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DocusWebserviceApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save