From 58b720b18ae2bc6d49ec628cee9224c93c65e990 Mon Sep 17 00:00:00 2001 From: HAHA Date: Tue, 14 Jun 2022 15:55:54 +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=96wgh=5Fjyz=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 + .../opendata/controller/WghJyzController.java | 15 +++- .../com/epmet/opendata/dao/WghJyzDao.java | 1 + .../epmet/opendata/service/WghJyzService.java | 11 +++ .../impl/GuardarDatosTaskServiceImpl.java | 7 ++ .../service/impl/WghJyzServiceImpl.java | 86 +++++++++++++++++++ .../src/main/resources/mapper/WghJyzDao.xml | 3 + 7 files changed, 123 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 54a63dd271..7970dc7226 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 @@ -27,6 +27,7 @@ public interface CaWghDataConstant { String SHARE_WGH_JDB = "wgh_jdb"; String SHARE_WGH_JQZ = "wgh_jqz"; String SHARE_WGH_JXCS = "wgh_jxcs"; + String SHARE_WGH_JYZ = "wgh_jyz"; 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/WghJyzController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghJyzController.java index 38b74659e0..2cb21796ad 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghJyzController.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghJyzController.java @@ -9,6 +9,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.WghJyzDTO; import com.epmet.opendata.excel.WghJyzExcel; import com.epmet.opendata.service.WghJyzService; @@ -77,6 +78,18 @@ public class WghJyzController { ExcelUtils.exportExcelToTarget(response, null, list, WghJyzExcel.class); } - + /** + * 调用ruoyi接口获取wgh_jyz数据 + * + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @author LZN + * @date 2022/6/14 15:52 + */ + @PostMapping("/preserWghJyzVation") + public Result getPreserWghJyzVation(@RequestBody PreserVationFormDTO dto) { + wghJyzService.getPreserWghJyzVation(dto); + return new Result(); + } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghJyzDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghJyzDao.java index 8e1234f7c6..01fcc12a97 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghJyzDao.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghJyzDao.java @@ -13,4 +13,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface WghJyzDao extends BaseDao { + int deleteAll(); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghJyzService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghJyzService.java index 816c3950fe..77778a6262 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghJyzService.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghJyzService.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.WghJyzDTO; import com.epmet.opendata.entity.WghJyzEntity; @@ -75,4 +76,14 @@ public interface WghJyzService extends BaseService { * @date 2022-06-14 */ void delete(String[] ids); + + /** + * 调用ruoyi接口获取wgh_jyz数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 15:53 + */ + void getPreserWghJyzVation(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 6b2fbd9c12..95cc8812d3 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 @@ -47,6 +47,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { @Autowired private WghJxcsService wghJxcsService; + @Autowired + private WghJyzService wghJyzService; + @Override public void guardarDatosTask(PreserVationFormDTO dto) { if (StringUtils.isBlank(dto.getTableName())) { @@ -61,6 +64,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { wghDywgService.getPreserDywgVation(dto); wghJqzService.getPreserWghjqzVation(dto); wghJxcsService.preserWghJxcsVation(dto); + wghJyzService.getPreserWghJyzVation(dto); } else { switch (dto.getTableName()) { @@ -100,6 +104,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { case CaWghDataConstant.SHARE_WGH_JXCS: wghJxcsService.preserWghJxcsVation(dto); break; + case CaWghDataConstant.SHARE_WGH_JYZ: + wghJyzService.getPreserWghJyzVation(dto); + break; } } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghJyzServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghJyzServiceImpl.java index 893d0a3000..9d14a3a6bf 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghJyzServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghJyzServiceImpl.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.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; import com.epmet.opendata.dao.WghJyzDao; +import com.epmet.opendata.dto.constant.CaWghDataConstant; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.WghJyzDTO; +import com.epmet.opendata.entity.CaLoudongEntity; import com.epmet.opendata.entity.WghJyzEntity; import com.epmet.opendata.redis.WghJyzRedis; import com.epmet.opendata.service.WghJyzService; +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,81 @@ public class WghJyzServiceImpl extends BaseServiceImpl baseDao.deleteBatchIds(Arrays.asList(ids)); } + /** + * 调用ruoyi接口获取wgh_jyz数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 15:53 + */ + @Override + public void getPreserWghJyzVation(PreserVationFormDTO dto) { + int i = baseDao.deleteAll(); + if (i >= 0) { + dto.setPageNo(NumConstant.ONE); + dto.setPageSize(NumConstant.FIFTY); + dto.setTableSchema(CaWghDataConstant.TABLESCHEMA_SHARE); + dto.setTableName(CaWghDataConstant.SHARE_WGH_JYZ); + + dto.setWhereCase("1=1"); + dto.setOrderBy("OBJECTID,等级,insert_time"); + + int pageNo = 1; + + int total = 0; + + do { + try { + total = listLouDong(dto); + pageNo++; + dto.setPageNo(pageNo); + } catch (Exception e) { + e.printStackTrace(); + } + } while (total > (pageNo * NumConstant.FIFTY)); + } + + } + + + private int listLouDong(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/WghJyzDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghJyzDao.xml index 4f2e3eddc5..2b97665feb 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghJyzDao.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghJyzDao.xml @@ -26,6 +26,9 @@ + + delete from wgh_jyz +