市局数据资源实现
This commit is contained in:
parent
8e87eb848f
commit
b531192f91
|
@ -5,6 +5,7 @@ import io.renren.common.domain.BaoTouProperties;
|
||||||
import io.renren.common.domain.TsingtaoProperties;
|
import io.renren.common.domain.TsingtaoProperties;
|
||||||
import io.renren.common.domain.Tsingtao_xhaProperties;
|
import io.renren.common.domain.Tsingtao_xhaProperties;
|
||||||
import io.renren.common.utils.SpringContextUtils;
|
import io.renren.common.utils.SpringContextUtils;
|
||||||
|
import io.renren.modules.resource.dataResource.domain.TsingtaoDataResourceService;
|
||||||
import io.renren.modules.resource.dataResource.domain.TsingtaoXHADataResourceService;
|
import io.renren.modules.resource.dataResource.domain.TsingtaoXHADataResourceService;
|
||||||
import io.renren.modules.resource.service.ResourceService;
|
import io.renren.modules.resource.service.ResourceService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -43,6 +44,7 @@ public final class DataResourceFactory {
|
||||||
AbstractDataResourceService abstractDataResourceService = null;
|
AbstractDataResourceService abstractDataResourceService = null;
|
||||||
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
|
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
|
||||||
case TSINGTAO: { // 青岛市局
|
case TSINGTAO: { // 青岛市局
|
||||||
|
abstractDataResourceService = new TsingtaoDataResourceService();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSINGTAO_XHA: { // 青岛西海岸
|
case TSINGTAO_XHA: { // 青岛西海岸
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
package io.renren.modules.resource.dataResource.domain;
|
package io.renren.modules.resource.dataResource.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.renren.common.utils.Result;
|
||||||
|
import io.renren.common.utils.SpringContextUtils;
|
||||||
import io.renren.modules.resource.dataResource.AbstractDataResourceService;
|
import io.renren.modules.resource.dataResource.AbstractDataResourceService;
|
||||||
import io.renren.modules.resource.dto.GetDataResourceListDto;
|
import io.renren.modules.resource.dto.GetDataResourceListDto;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 青岛市局数据资源
|
* 青岛市局数据资源
|
||||||
|
@ -11,8 +26,64 @@ import org.slf4j.LoggerFactory;
|
||||||
public class TsingtaoDataResourceService extends AbstractDataResourceService {
|
public class TsingtaoDataResourceService extends AbstractDataResourceService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TsingtaoDataResourceService.class);
|
private static final Logger logger = LoggerFactory.getLogger(TsingtaoDataResourceService.class);
|
||||||
|
|
||||||
|
private static RestTemplate restTemplate;
|
||||||
|
|
||||||
|
{
|
||||||
|
TsingtaoDataResourceService.restTemplate = SpringContextUtils.getBean(RestTemplate.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getDataResource(GetDataResourceListDto dto) {
|
public Object getDataResource(GetDataResourceListDto dto) {
|
||||||
return null;
|
|
||||||
|
Integer page = dto.getPageNum();
|
||||||
|
Integer size = dto.getPageSize();
|
||||||
|
String pxcol = dto.getOrderField();
|
||||||
|
String order = dto.getOrderType();
|
||||||
|
String bmname = dto.getServiceName();
|
||||||
|
String zyname = dto.getServiceName();
|
||||||
|
|
||||||
|
if (page == null) page = 1;
|
||||||
|
if (size == null) size = 10;
|
||||||
|
if (pxcol == null) pxcol = "fbrq";
|
||||||
|
if (order == null) order = "desc";
|
||||||
|
|
||||||
|
String url = "http://15.72.158.81/zyjk/ZywMessage.asmx";
|
||||||
|
String parame = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||||
|
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
||||||
|
" <soap:Body><ZWCJ_mainPort xmlns=\"http://tempuri.org/\">\n" +
|
||||||
|
String.format("<pagenum>%d</pagenum>\n <pagesize>%d</pagesize>\n",page, size) +
|
||||||
|
String.format("<pxcol>%s</pxcol>\n <order>%s</order>\n",pxcol, order);
|
||||||
|
if (bmname != null){
|
||||||
|
parame = parame + String.format("<bmname>%s</bmname>",bmname);
|
||||||
|
}
|
||||||
|
if (zyname != null) {
|
||||||
|
parame = parame + String.format("<zyname>%s</zyname>",zyname);
|
||||||
|
}
|
||||||
|
parame = parame + "</ZWCJ_mainPort></soap:Body></soap:Envelope>";
|
||||||
|
HttpHeaders requestHeaders = new HttpHeaders();
|
||||||
|
requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort");
|
||||||
|
requestHeaders.setContentType(new MediaType("text","xml", Charset.forName("utf-8")));
|
||||||
|
HttpEntity<String> requestEntity = new HttpEntity(parame, requestHeaders);
|
||||||
|
try {
|
||||||
|
String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody();
|
||||||
|
String startTag = "<ZWCJ_mainPortResult>";
|
||||||
|
String endTag = "</ZWCJ_mainPortResult>";
|
||||||
|
String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag));
|
||||||
|
HashMap result = JSONObject.parseObject(json, HashMap.class);
|
||||||
|
|
||||||
|
List<Map> rows = (List<Map>) result.get("data");
|
||||||
|
List<Object> objects = rows.stream()
|
||||||
|
.filter(item -> item.get("main") != null)
|
||||||
|
.map(item -> item.get("main"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
result.put("data", objects);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue