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 208790880a..95773cb324 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 @@ -21,6 +21,7 @@ public interface CaWghDataConstant { String UNICOM_RENTAL = "ca_rental"; String SHARE_BASE_GRID = "BaseGrid"; + String SHARE_BM_GRID = "bm_grid"; 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/BmGridController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BmGridController.java index c89a16bce1..4c87101c5b 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BmGridController.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BmGridController.java @@ -78,6 +78,17 @@ public class BmGridController { ExcelUtils.exportExcelToTarget(response, null, list, BmGridExcel.class); } - - + /** + * 调用ruoyi存储bm_grid数据 + * + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @author LZN + * @date 2022/6/14 14:16 + */ + @PostMapping("preserBmGridVation") + public Result getpreserBmGridVation(@RequestBody PreserVationFormDTO dto) { + bmGridService.getPreserBmGridVation(dto); + return new Result(); + } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BmGridDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BmGridDao.java index 257761fae9..b4988f03c6 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BmGridDao.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BmGridDao.java @@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface BmGridDao extends BaseDao { + int deleteAll(); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BmGridService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BmGridService.java index c61414ab19..d2f79c35fe 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BmGridService.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BmGridService.java @@ -78,5 +78,13 @@ public interface BmGridService extends BaseService { */ void delete(String[] ids); - + /** + * 调用ruoyi存储bm_grid数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 14:17 + */ + void getPreserBmGridVation(PreserVationFormDTO dto); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BmGridServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BmGridServiceImpl.java index 349e77f2cf..d3cf864f00 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BmGridServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BmGridServiceImpl.java @@ -1,18 +1,26 @@ 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.BmGridDao; +import com.epmet.opendata.dto.constant.CaWghDataConstant; import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.BmGridDTO; +import com.epmet.opendata.entity.BasegridEntity; import com.epmet.opendata.entity.BmGridEntity; import com.epmet.opendata.redis.BmGridRedis; import com.epmet.opendata.service.BmGridService; +import com.epmet.opendata.util.AesUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -86,6 +94,78 @@ public class BmGridServiceImpl extends BaseServiceImpl baseDao.deleteBatchIds(Arrays.asList(ids)); } + /** + * 调用ruoyi存储bm_grid数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 14:17 + */ + @Override + public void getPreserBmGridVation(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_BM_GRID); + + dto.setWhereCase("delete_flag = 'normal'"); + dto.setOrderBy("grid_id,parent_id,create_date"); + + int pageNo = 1; + + int total = 0; + + do { + try { + total = listBmGrid(dto); + pageNo++; + dto.setPageNo(pageNo); + } catch (Exception e) { + e.printStackTrace(); + } + } while (total > (pageNo * NumConstant.FIFTY)); + } + } + + private int listBmGrid(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/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 9a790ccd56..f7f955d333 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 @@ -3,6 +3,7 @@ package com.epmet.opendata.service.impl; import com.epmet.opendata.dto.constant.CaWghDataConstant; import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.service.*; +import net.bytebuddy.asm.Advice; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,6 +29,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { @Autowired private BasegridService basegridService; + @Autowired + private BmGridService bmGridService; + @Override public void guardarDatosTask(PreserVationFormDTO dto) { if (StringUtils.isBlank(dto.getTableName())) { @@ -37,6 +41,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { residentService.preserResidentVation(dto); rotatorsService.preserRotatorsVation(dto); basegridService.preserBaseGridVation(dto); + bmGridService.getPreserBmGridVation(dto); } switch (dto.getTableName()) { @@ -58,6 +63,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { case CaWghDataConstant.SHARE_BASE_GRID: basegridService.preserBaseGridVation(dto); break; + case CaWghDataConstant.SHARE_BM_GRID: + bmGridService.getPreserBmGridVation(dto); + break; } } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BmGridDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BmGridDao.xml index 5afad7c849..230d6fee17 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BmGridDao.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BmGridDao.xml @@ -42,6 +42,9 @@ + + delete from bm_grid +