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 362d920dbf..c094b6aaa5 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 @@ -33,6 +33,7 @@ public interface CaWghDataConstant { String SHARE_WGH_SZCGWGH = "wgh_szcgwgh"; String SHARE_WGH_SZZRWG = "wgh_szzrwg"; String SHARE_WGH_WHPDW = "wgh_whpdw"; + String SHARE_WGH_YJBMCS = "wgh_yjbmcs"; 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/WghYjbmcsController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghYjbmcsController.java index a76832bba8..3a6764c36c 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghYjbmcsController.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/WghYjbmcsController.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.WghYjbmcsDTO; import com.epmet.opendata.excel.WghYjbmcsExcel; import com.epmet.opendata.service.WghYjbmcsService; @@ -34,20 +35,20 @@ public class WghYjbmcsController { private WghYjbmcsService wghYjbmcsService; @RequestMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = wghYjbmcsService.page(params); return new Result>().ok(page); } - @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) - public Result get(@PathVariable("id") String id){ + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id) { WghYjbmcsDTO data = wghYjbmcsService.get(id); return new Result().ok(data); } @NoRepeatSubmit @PostMapping("save") - public Result save(@RequestBody WghYjbmcsDTO dto){ + public Result save(@RequestBody WghYjbmcsDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); wghYjbmcsService.save(dto); @@ -56,7 +57,7 @@ public class WghYjbmcsController { @NoRepeatSubmit @PostMapping("update") - public Result update(@RequestBody WghYjbmcsDTO dto){ + public Result update(@RequestBody WghYjbmcsDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); wghYjbmcsService.update(dto); @@ -64,7 +65,7 @@ public class WghYjbmcsController { } @PostMapping("delete") - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); wghYjbmcsService.delete(ids); @@ -77,6 +78,18 @@ public class WghYjbmcsController { ExcelUtils.exportExcelToTarget(response, null, list, WghYjbmcsExcel.class); } - + /** + * 调用ruoyi系统获取wgh_yjbmcs数据 + * + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @author LZN + * @date 2022/6/14 16:39 + */ + @PostMapping("/preserWghYjbmcsVation") + public Result getPreserWghYjbmcsVation(@RequestBody PreserVationFormDTO dto) { + wghYjbmcsService.getPreserWghYjbmcsVation(dto); + return new Result(); + } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYjbmcsDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYjbmcsDao.java index effb876078..1bc32540b1 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYjbmcsDao.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/WghYjbmcsDao.java @@ -13,4 +13,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface WghYjbmcsDao extends BaseDao { + int deleteAll(); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYjbmcsService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYjbmcsService.java index d73715139d..03cbb10b49 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYjbmcsService.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/WghYjbmcsService.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.WghYjbmcsDTO; import com.epmet.opendata.entity.WghYjbmcsEntity; @@ -76,4 +77,14 @@ public interface WghYjbmcsService extends BaseService { * @date 2022-06-14 */ void delete(String[] ids); + + /** + * 调用ruoyi系统获取wgh_yjbmcs数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 16:39 + */ + void getPreserWghYjbmcsVation(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 3c6c61cab6..fbe4b53085 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 @@ -65,6 +65,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { @Autowired private WghWhpdwService wghWhpdwService; + @Autowired + private WghYjbmcsService wghYjbmcsService; + @Override public void guardarDatosTask(PreserVationFormDTO dto) { if (StringUtils.isBlank(dto.getTableName())) { @@ -85,6 +88,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { wghSzcgwghService.getPreserWghSzcgwghVation(dto); wghSzzrwgService.getPreserWghSzzrwgVation(dto); wghWhpdwService.getPreserWhpdwVation(dto); + wghYjbmcsService.getPreserWghYjbmcsVation(dto); } else { switch (dto.getTableName()) { @@ -142,6 +146,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { case CaWghDataConstant.SHARE_WGH_WHPDW: wghWhpdwService.getPreserWhpdwVation(dto); break; + case CaWghDataConstant.SHARE_WGH_YJBMCS: + wghYjbmcsService.getPreserWghYjbmcsVation(dto); + break; } } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYjbmcsServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYjbmcsServiceImpl.java index 367d539a63..4652ee8906 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYjbmcsServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/WghYjbmcsServiceImpl.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.WghYjbmcsDao; +import com.epmet.opendata.dto.constant.CaWghDataConstant; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.WghYjbmcsDTO; +import com.epmet.opendata.entity.CaLoudongEntity; import com.epmet.opendata.entity.WghYjbmcsEntity; import com.epmet.opendata.redis.WghYjbmcsRedis; import com.epmet.opendata.service.WghYjbmcsService; +import com.epmet.opendata.util.AesUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -48,8 +57,8 @@ public class WghYjbmcsServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -84,4 +93,81 @@ public class WghYjbmcsServiceImpl extends BaseServiceImpl= 0) { + dto.setPageNo(NumConstant.ONE); + dto.setPageSize(NumConstant.FIFTY); + dto.setTableSchema(CaWghDataConstant.TABLESCHEMA_SHARE); + dto.setTableName(CaWghDataConstant.SHARE_WGH_YJBMCS); + + 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/WghYjbmcsDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghYjbmcsDao.xml index 536ca04ca0..2f23df803e 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghYjbmcsDao.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/WghYjbmcsDao.xml @@ -18,6 +18,9 @@ + + delete from wgh_yjbmcs +