From 33b73c63121acd17fff0b978f940dfb8a2bcf998 Mon Sep 17 00:00:00 2001 From: HAHA Date: Tue, 14 Jun 2022 15:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8ruoyi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=8E=B7=E5=8F=96dywg=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/constant/CaWghDataConstant.java | 1 + .../controller/WghDywgController.java | 15 +++- .../com/epmet/opendata/dao/WghDywgDao.java | 1 + .../opendata/service/WghDywgService.java | 11 +++ .../impl/GuardarDatosTaskServiceImpl.java | 7 ++ .../service/impl/WghDywgServiceImpl.java | 84 +++++++++++++++++++ .../src/main/resources/mapper/WghDywgDao.xml | 3 + 7 files changed, 121 insertions(+), 1 deletion(-) diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/constant/CaWghDataConstant.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/constant/CaWghDataConstant.java index 0419eb859f..f34ceda2ff 100644 --- a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/constant/CaWghDataConstant.java +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/constant/CaWghDataConstant.java @@ -23,6 +23,7 @@ public interface CaWghDataConstant { String SHARE_BASE_GRID = "BaseGrid"; String SHARE_BM_GRID = "bm_grid"; String SHARE_COMMUNITY = "community"; + String SHARE_WGH_DYWG = "wgh_dywg"; String DATA_URL_UNICON = "http://120.221.72.83:9090/bridge/unicom/page"; String DATA_URL_SHARE = "http://120.221.72.83:9090/bridge/share/sharePage"; diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghDywgController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghDywgController.java index d7e2123e75..90f910d9c2 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghDywgController.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghDywgController.java @@ -10,6 +10,7 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.WghDywgDTO; import com.epmet.opendata.excel.WghDywgExcel; import com.epmet.opendata.service.WghDywgService; @@ -78,6 +79,18 @@ public class WghDywgController { ExcelUtils.exportExcelToTarget(response, null, list, WghDywgExcel.class); } - + /** + * 调用ruoyi接口获取dywg数据 + * + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @author LZN + * @date 2022/6/14 15:11 + */ + @PostMapping("preserDywgVation") + public Result getPreserDywgVation(@RequestBody PreserVationFormDTO dto) { + wghDywgService.getPreserDywgVation(dto); + return new Result(); + } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghDywgDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghDywgDao.java index 488784b3d2..341db87c61 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghDywgDao.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghDywgDao.java @@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface WghDywgDao extends BaseDao { + int deleteAll(); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghDywgService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghDywgService.java index e078faba79..8f13184379 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghDywgService.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghDywgService.java @@ -2,6 +2,7 @@ package com.epmet.opendata.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.WghDywgDTO; import com.epmet.opendata.entity.WghDywgEntity; @@ -75,4 +76,14 @@ public interface WghDywgService extends BaseService { * @date 2022-06-14 */ void delete(String[] ids); + + /** + * 调用ruoyi接口获取dywg数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 15:11 + */ + void getPreserDywgVation(PreserVationFormDTO dto); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GuardarDatosTaskServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GuardarDatosTaskServiceImpl.java index a4c42f7b09..3fcb79ec23 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GuardarDatosTaskServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GuardarDatosTaskServiceImpl.java @@ -35,6 +35,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { @Autowired private CommunityService communityService; + @Autowired + private WghDywgService wghDywgService; + @Override public void guardarDatosTask(PreserVationFormDTO dto) { if (StringUtils.isBlank(dto.getTableName())) { @@ -46,6 +49,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { basegridService.preserBaseGridVation(dto); bmGridService.getPreserBmGridVation(dto); communityService.getPreserCommunityVation(dto); + wghDywgService.getPreserDywgVation(dto); } switch (dto.getTableName()) { @@ -73,6 +77,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { case CaWghDataConstant.SHARE_COMMUNITY: communityService.getPreserCommunityVation(dto); break; + case CaWghDataConstant.SHARE_WGH_DYWG: + wghDywgService.getPreserDywgVation(dto); + break; } } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghDywgServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghDywgServiceImpl.java index ed55100449..b3c29d6f40 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghDywgServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghDywgServiceImpl.java @@ -1,16 +1,25 @@ package com.epmet.opendata.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; import com.epmet.opendata.dao.WghDywgDao; +import com.epmet.opendata.dto.constant.CaWghDataConstant; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.WghDywgDTO; +import com.epmet.opendata.entity.CaLoudongEntity; import com.epmet.opendata.entity.WghDywgEntity; import com.epmet.opendata.redis.WghDywgRedis; import com.epmet.opendata.service.WghDywgService; +import com.epmet.opendata.util.AesUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -84,4 +93,79 @@ public class WghDywgServiceImpl extends BaseServiceImpl= 0) { + dto.setPageNo(NumConstant.ONE); + dto.setPageSize(NumConstant.FIFTY); + dto.setTableSchema(CaWghDataConstant.TABLESCHEMA_SHARE); + dto.setTableName(CaWghDataConstant.SHARE_WGH_DYWG); + + dto.setWhereCase("1=1"); + dto.setOrderBy("ORDATE"); + + int pageNo = 1; + + int total = 0; + + do { + try { + total = listDywg(dto); + pageNo++; + dto.setPageNo(pageNo); + } catch (Exception e) { + e.printStackTrace(); + } + } while (total > (pageNo * NumConstant.FIFTY)); + } + } + + private int listDywg(PreserVationFormDTO dto) throws Exception { + String aes = AesUtils.encryptByAES(JSONObject.toJSONString(dto), CaWghDataConstant.AESKEY); + JSONObject obj = new JSONObject(); + obj.put(CaWghDataConstant.SHARE_CONDITION, aes); + String data = HttpClientManager.getInstance().sendPostByJSON(CaWghDataConstant.DATA_URL_SHARE, obj.toJSONString()).getData(); + JSONObject toResult = JSON.parseObject(data); + Result result = ConvertUtils.mapToEntity(toResult, Result.class); + if (!result.success()) { + return dto.getPageNo() + 1; + } + + ReturnDate returnDate = JSONObject.parseObject(JSONObject.toJSONString(result.getData()), ReturnDate.class); + this.insertBatch(returnDate.getList()); + return returnDate.getTotal(); + } + + static class ReturnDate { + + private int total; + private List list; + + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + } + } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghDywgDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghDywgDao.xml index 08611dc01e..d5334a8e8a 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghDywgDao.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghDywgDao.xml @@ -16,6 +16,9 @@ + + delete from wgh_dywg +