From 2a5334dc810d6445137d76897df513cdf48742e1 Mon Sep 17 00:00:00 2001 From: huangweixiong Date: Tue, 21 Jun 2022 20:47:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=88=86=E9=A1=B5=EF=BC=8C=E6=8E=92=E5=BA=8F=EF=BC=8C=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ResourceController.java | 36 +++++++++++++------ .../src/main/resources/application-hwx.yml | 2 ++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index aefcdf6c..dbd8f1ff 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -13,10 +13,7 @@ import io.renren.common.validator.group.DefaultGroup; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.excel.ResourceExcelImportListener; import io.renren.modules.resource.service.ResourceService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +32,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.*; @@ -297,19 +295,35 @@ public class ResourceController { @GetMapping("ZywMessage/list") @ApiOperation("资源列表转发") - public Result ZywMessageList(Integer page, Integer size) { + public Result ZywMessageList(@ApiParam("页数") Integer page, + @ApiParam("页大小") Integer size, + @ApiParam("排序字段;fbrq(发布日期),syqk(申请数量)") String pxcol, + @ApiParam("排序方式,取值asc/desc") String order, + @ApiParam("部门") String bmname, + @ApiParam("资源模糊搜索") String zyname) { + + 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 = "\n" + "\n" + - " \n" + - " \n" + + " \n" + String.format("%d\n %d\n",page, size) + - " \n" + - " \n" + - ""; + String.format("%s\n %s\n",pxcol, order); + if (bmname != null){ + parame = parame + String.format("%s",bmname); + } + if (zyname != null) { + parame = parame + String.format("%s",zyname); + } + parame = parame + ""; + HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort"); - requestHeaders.setContentType(MediaType.TEXT_XML); + requestHeaders.setContentType(new MediaType("text","xml", Charset.forName("utf-8"))); HttpEntity requestEntity = new HttpEntity(parame, requestHeaders); try { String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody(); diff --git a/renren-admin/src/main/resources/application-hwx.yml b/renren-admin/src/main/resources/application-hwx.yml index f34f8d8a..b5bc677a 100644 --- a/renren-admin/src/main/resources/application-hwx.yml +++ b/renren-admin/src/main/resources/application-hwx.yml @@ -34,6 +34,8 @@ spring: wall: config: multi-statement-allow: true + flyway: + enabled: false #上传的静态资源配置 resource: root_url: 15.2.21.238 From b531192f91a4bf1406aae82fa84903f69e901b18 Mon Sep 17 00:00:00 2001 From: huangweixiong Date: Tue, 21 Jun 2022 21:31:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B8=82=E5=B1=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataResource/DataResourceFactory.java | 2 + .../domain/TsingtaoDataResourceService.java | 73 ++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java index 3f39b02c..c011cc35 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java @@ -5,6 +5,7 @@ import io.renren.common.domain.BaoTouProperties; import io.renren.common.domain.TsingtaoProperties; import io.renren.common.domain.Tsingtao_xhaProperties; 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.service.ResourceService; import org.slf4j.Logger; @@ -43,6 +44,7 @@ public final class DataResourceFactory { AbstractDataResourceService abstractDataResourceService = null; switch (Constant.ProjectPlace.getByFlag(projectPlace)) { case TSINGTAO: { // 青岛市局 + abstractDataResourceService = new TsingtaoDataResourceService(); } break; case TSINGTAO_XHA: { // 青岛西海岸 diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java index e265c351..4d1b85bf 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java @@ -1,9 +1,24 @@ 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.dto.GetDataResourceListDto; +import io.swagger.annotations.ApiParam; import org.slf4j.Logger; 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 { private static final Logger logger = LoggerFactory.getLogger(TsingtaoDataResourceService.class); + + private static RestTemplate restTemplate; + + { + TsingtaoDataResourceService.restTemplate = SpringContextUtils.getBean(RestTemplate.class); + } + + @Override 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 = "\n" + + "\n" + + " \n" + + String.format("%d\n %d\n",page, size) + + String.format("%s\n %s\n",pxcol, order); + if (bmname != null){ + parame = parame + String.format("%s",bmname); + } + if (zyname != null) { + parame = parame + String.format("%s",zyname); + } + parame = parame + ""; + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort"); + requestHeaders.setContentType(new MediaType("text","xml", Charset.forName("utf-8"))); + HttpEntity requestEntity = new HttpEntity(parame, requestHeaders); + try { + String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody(); + String startTag = ""; + String endTag = ""; + String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag)); + HashMap result = JSONObject.parseObject(json, HashMap.class); + + List rows = (List) result.get("data"); + List 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; + } } }