From 03d66d37749b2f9659705eb920b107354daf4033 Mon Sep 17 00:00:00 2001 From: HAHA Date: Tue, 14 Jun 2022 16:47:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8ruoyi=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=8E=B7=E5=8F=96wgh=5Fyqhjz=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/WghYqhjzController.java | 15 +++- .../com/epmet/opendata/dao/WghYqhjzDao.java | 1 + .../opendata/service/WghYqhjzService.java | 11 +++ .../impl/GuardarDatosTaskServiceImpl.java | 7 ++ .../service/impl/WghYqhjzServiceImpl.java | 86 +++++++++++++++++++ .../src/main/resources/mapper/WghYqhjzDao.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 c094b6aaa5..9af21b42a9 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 @@ -34,6 +34,7 @@ public interface CaWghDataConstant { String SHARE_WGH_SZZRWG = "wgh_szzrwg"; String SHARE_WGH_WHPDW = "wgh_whpdw"; String SHARE_WGH_YJBMCS = "wgh_yjbmcs"; + String SHARE_WGH_YQHJZ = "wgh_yqhjz"; 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/WghYqhjzController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghYqhjzController.java index 9b91f4bc11..972710d611 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghYqhjzController.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghYqhjzController.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.service.WghYqhjzService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -76,6 +77,18 @@ public class WghYqhjzController { ExcelUtils.exportExcelToTarget(response, null, list, WghYqhjzExcel.class); } - + /** + * 调用ruoyi系统获取wgh_yqhjz数据 + * + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @author LZN + * @date 2022/6/14 16:46 + */ + @PostMapping("/preserWghYqhjzVation") + public Result getPreserWghYqhjzVation(@RequestBody PreserVationFormDTO dto) { + wghYqhjzService.getPreserWghYqhjzVation(dto); + return new Result(); + } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYqhjzDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYqhjzDao.java index 661c60f9a4..a8984a2aa7 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYqhjzDao.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYqhjzDao.java @@ -13,4 +13,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface WghYqhjzDao extends BaseDao { + int deleteAll(); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYqhjzService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYqhjzService.java index 7aff21c044..129c917617 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYqhjzService.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYqhjzService.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.entity.WghYqhjzEntity; import com.epmet.opendata.dto.wgh.WghYqhjzDTO; @@ -75,4 +76,14 @@ public interface WghYqhjzService extends BaseService { * @date 2022-06-14 */ void delete(String[] ids); + + /** + * 调用ruoyi系统获取wgh_yqhjz数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 16:46 + */ + void getPreserWghYqhjzVation(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 fbe4b53085..9957afe1e4 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 @@ -68,6 +68,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { @Autowired private WghYjbmcsService wghYjbmcsService; + @Autowired + private WghYqhjzService wghYqhjzService; + @Override public void guardarDatosTask(PreserVationFormDTO dto) { if (StringUtils.isBlank(dto.getTableName())) { @@ -89,6 +92,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { wghSzzrwgService.getPreserWghSzzrwgVation(dto); wghWhpdwService.getPreserWhpdwVation(dto); wghYjbmcsService.getPreserWghYjbmcsVation(dto); + wghYqhjzService.getPreserWghYqhjzVation(dto); } else { switch (dto.getTableName()) { @@ -149,6 +153,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { case CaWghDataConstant.SHARE_WGH_YJBMCS: wghYjbmcsService.getPreserWghYjbmcsVation(dto); break; + case CaWghDataConstant.SHARE_WGH_YQHJZ: + wghYqhjzService.getPreserWghYqhjzVation(dto); + break; } } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYqhjzServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYqhjzServiceImpl.java index aa8b06d753..f7ee3830b4 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYqhjzServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYqhjzServiceImpl.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.WghYqhjzDao; +import com.epmet.opendata.dto.constant.CaWghDataConstant; +import com.epmet.opendata.dto.form.PreserVationFormDTO; +import com.epmet.opendata.entity.CaLoudongEntity; import com.epmet.opendata.entity.WghYqhjzEntity; import com.epmet.opendata.redis.WghYqhjzRedis; import com.epmet.opendata.service.WghYqhjzService; +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 WghYqhjzServiceImpl extends BaseServiceImpl= 0) { + dto.setPageNo(NumConstant.ONE); + dto.setPageSize(NumConstant.FIFTY); + dto.setTableSchema(CaWghDataConstant.TABLESCHEMA_SHARE); + dto.setTableName(CaWghDataConstant.SHARE_WGH_YQHJZ); + + dto.setWhereCase("1=1"); + dto.setOrderBy("OBJECTID,XH,insert_time"); + + int pageNo = 1; + + int total = 0; + + do { + try { + total = listWghYqhjz(dto); + pageNo++; + dto.setPageNo(pageNo); + } catch (Exception e) { + e.printStackTrace(); + } + } while (total > (pageNo * NumConstant.FIFTY)); + } + + } + + + private int listWghYqhjz(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/WghYqhjzDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghYqhjzDao.xml index 1ec98d4387..c9b26071ee 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghYqhjzDao.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghYqhjzDao.xml @@ -26,6 +26,9 @@ + + delete from wgh_yqhjz +