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 95773cb324..0419eb859f 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 @@ -22,6 +22,7 @@ public interface CaWghDataConstant { String SHARE_BASE_GRID = "BaseGrid"; String SHARE_BM_GRID = "bm_grid"; + String SHARE_COMMUNITY = "community"; 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/CommunityController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CommunityController.java index 8e7b7f9528..a7f54e01e4 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CommunityController.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CommunityController.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.CommunityDTO; import com.epmet.opendata.excel.CommunityExcel; import com.epmet.opendata.service.CommunityService; @@ -22,8 +23,6 @@ import java.util.Map; /** - * - * * @author generator generator@elink-cn.com * @since v1.0.0 2022-06-14 */ @@ -35,20 +34,20 @@ public class CommunityController { private CommunityService communityService; @RequestMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = communityService.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) { CommunityDTO data = communityService.get(id); return new Result().ok(data); } @NoRepeatSubmit @PostMapping("save") - public Result save(@RequestBody CommunityDTO dto){ + public Result save(@RequestBody CommunityDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); communityService.save(dto); @@ -57,7 +56,7 @@ public class CommunityController { @NoRepeatSubmit @PostMapping("update") - public Result update(@RequestBody CommunityDTO dto){ + public Result update(@RequestBody CommunityDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); communityService.update(dto); @@ -65,7 +64,7 @@ public class CommunityController { } @PostMapping("delete") - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); communityService.delete(ids); @@ -78,6 +77,18 @@ public class CommunityController { ExcelUtils.exportExcelToTarget(response, null, list, CommunityExcel.class); } - + /** + * 调用ruoyi接口存储社区数据 + * + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @author LZN + * @date 2022/6/14 15:02 + */ + @PostMapping("preserCommunityVation") + public Result getPreserCommunityVation(@RequestBody PreserVationFormDTO dto) { + communityService.getPreserCommunityVation(dto); + return new Result(); + } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CommunityDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CommunityDao.java index 9dd874ef17..8457a499f4 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CommunityDao.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CommunityDao.java @@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface CommunityDao extends BaseDao { + int deleteAll(); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CommunityService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CommunityService.java index 002c3f0fd6..1c22cad274 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CommunityService.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CommunityService.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.CommunityDTO; import com.epmet.opendata.entity.CommunityEntity; @@ -10,8 +11,6 @@ import java.util.List; import java.util.Map; /** - * - * * @author generator generator@elink-cn.com * @since v1.0.0 2022-06-14 */ @@ -76,4 +75,14 @@ public interface CommunityService extends BaseService { * @date 2022-06-14 */ void delete(String[] ids); + + /** + * 调用ruoyi接口存储社区数据 + * + * @param dto + * @return void + * @author LZN + * @date 2022/6/14 15:03 + */ + void getPreserCommunityVation(PreserVationFormDTO dto); } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CommunityServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CommunityServiceImpl.java index d1143a6ac9..0846ff4a95 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CommunityServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CommunityServiceImpl.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.CommunityDao; +import com.epmet.opendata.dto.constant.CaWghDataConstant; +import com.epmet.opendata.dto.form.PreserVationFormDTO; import com.epmet.opendata.dto.wgh.CommunityDTO; +import com.epmet.opendata.entity.CaLoudongEntity; import com.epmet.opendata.entity.CommunityEntity; import com.epmet.opendata.redis.CommunityRedis; import com.epmet.opendata.service.CommunityService; +import com.epmet.opendata.util.AesUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,8 +30,6 @@ import java.util.List; import java.util.Map; /** - * - * * @author generator generator@elink-cn.com * @since v1.0.0 2022-06-14 */ @@ -48,8 +55,8 @@ public class CommunityServiceImpl 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 +91,79 @@ public class CommunityServiceImpl extends BaseServiceImpl= 0) { + dto.setPageNo(NumConstant.ONE); + dto.setPageSize(NumConstant.FIFTY); + dto.setTableSchema(CaWghDataConstant.TABLESCHEMA_SHARE); + dto.setTableName(CaWghDataConstant.SHARE_COMMUNITY); + + dto.setWhereCase("1=1"); + dto.setOrderBy(""); + + int pageNo = 1; + + int total = 0; + + do { + try { + total = listCommunity(dto); + pageNo++; + dto.setPageNo(pageNo); + } catch (Exception e) { + e.printStackTrace(); + } + } while (total > (pageNo * NumConstant.FIFTY)); + } + } + + private int listCommunity(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 f7f955d333..a4c42f7b09 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 @@ -32,6 +32,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { @Autowired private BmGridService bmGridService; + @Autowired + private CommunityService communityService; + @Override public void guardarDatosTask(PreserVationFormDTO dto) { if (StringUtils.isBlank(dto.getTableName())) { @@ -42,6 +45,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { rotatorsService.preserRotatorsVation(dto); basegridService.preserBaseGridVation(dto); bmGridService.getPreserBmGridVation(dto); + communityService.getPreserCommunityVation(dto); } switch (dto.getTableName()) { @@ -66,6 +70,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { case CaWghDataConstant.SHARE_BM_GRID: bmGridService.getPreserBmGridVation(dto); break; + case CaWghDataConstant.SHARE_COMMUNITY: + communityService.getPreserCommunityVation(dto); + break; } } } diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CommunityDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CommunityDao.xml index dd20682a82..03d2f5d563 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CommunityDao.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CommunityDao.xml @@ -12,6 +12,9 @@ + + delete from community +