Browse Source

调用ruoyi接口存储社区数据

master
HAHA 3 years ago
parent
commit
ff2e388156
  1. 1
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/constant/CaWghDataConstant.java
  2. 29
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CommunityController.java
  3. 1
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CommunityDao.java
  4. 13
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CommunityService.java
  5. 90
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CommunityServiceImpl.java
  6. 7
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GuardarDatosTaskServiceImpl.java
  7. 3
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CommunityDao.xml

1
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_BASE_GRID = "BaseGrid";
String SHARE_BM_GRID = "bm_grid"; 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_UNICON = "http://120.221.72.83:9090/bridge/unicom/page";
String DATA_URL_SHARE = "http://120.221.72.83:9090/bridge/share/sharePage"; String DATA_URL_SHARE = "http://120.221.72.83:9090/bridge/share/sharePage";

29
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.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; 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.dto.wgh.CommunityDTO;
import com.epmet.opendata.excel.CommunityExcel; import com.epmet.opendata.excel.CommunityExcel;
import com.epmet.opendata.service.CommunityService; import com.epmet.opendata.service.CommunityService;
@ -22,8 +23,6 @@ import java.util.Map;
/** /**
*
*
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-14 * @since v1.0.0 2022-06-14
*/ */
@ -35,20 +34,20 @@ public class CommunityController {
private CommunityService communityService; private CommunityService communityService;
@RequestMapping("page") @RequestMapping("page")
public Result<PageData<CommunityDTO>> page(@RequestParam Map<String, Object> params){ public Result<PageData<CommunityDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CommunityDTO> page = communityService.page(params); PageData<CommunityDTO> page = communityService.page(params);
return new Result<PageData<CommunityDTO>>().ok(page); return new Result<PageData<CommunityDTO>>().ok(page);
} }
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET})
public Result<CommunityDTO> get(@PathVariable("id") String id){ public Result<CommunityDTO> get(@PathVariable("id") String id) {
CommunityDTO data = communityService.get(id); CommunityDTO data = communityService.get(id);
return new Result<CommunityDTO>().ok(data); return new Result<CommunityDTO>().ok(data);
} }
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("save") @PostMapping("save")
public Result save(@RequestBody CommunityDTO dto){ public Result save(@RequestBody CommunityDTO dto) {
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
communityService.save(dto); communityService.save(dto);
@ -57,7 +56,7 @@ public class CommunityController {
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("update") @PostMapping("update")
public Result update(@RequestBody CommunityDTO dto){ public Result update(@RequestBody CommunityDTO dto) {
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
communityService.update(dto); communityService.update(dto);
@ -65,7 +64,7 @@ public class CommunityController {
} }
@PostMapping("delete") @PostMapping("delete")
public Result delete(@RequestBody String[] ids){ public Result delete(@RequestBody String[] ids) {
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
communityService.delete(ids); communityService.delete(ids);
@ -78,6 +77,18 @@ public class CommunityController {
ExcelUtils.exportExcelToTarget(response, null, list, CommunityExcel.class); 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();
}
} }

1
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 @Mapper
public interface CommunityDao extends BaseDao<CommunityEntity> { public interface CommunityDao extends BaseDao<CommunityEntity> {
int deleteAll();
} }

13
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.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; 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.dto.wgh.CommunityDTO;
import com.epmet.opendata.entity.CommunityEntity; import com.epmet.opendata.entity.CommunityEntity;
@ -10,8 +11,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
*
*
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-14 * @since v1.0.0 2022-06-14
*/ */
@ -76,4 +75,14 @@ public interface CommunityService extends BaseService<CommunityEntity> {
* @date 2022-06-14 * @date 2022-06-14
*/ */
void delete(String[] ids); void delete(String[] ids);
/**
* 调用ruoyi接口存储社区数据
*
* @param dto
* @return void
* @author LZN
* @date 2022/6/14 15:03
*/
void getPreserCommunityVation(PreserVationFormDTO dto);
} }

90
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; 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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant; 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.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; 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.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.dto.wgh.CommunityDTO;
import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CommunityEntity; import com.epmet.opendata.entity.CommunityEntity;
import com.epmet.opendata.redis.CommunityRedis; import com.epmet.opendata.redis.CommunityRedis;
import com.epmet.opendata.service.CommunityService; import com.epmet.opendata.service.CommunityService;
import com.epmet.opendata.util.AesUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -21,8 +30,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
*
*
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-14 * @since v1.0.0 2022-06-14
*/ */
@ -48,8 +55,8 @@ public class CommunityServiceImpl extends BaseServiceImpl<CommunityDao, Communit
return ConvertUtils.sourceToTarget(entityList, CommunityDTO.class); return ConvertUtils.sourceToTarget(entityList, CommunityDTO.class);
} }
private QueryWrapper<CommunityEntity> getWrapper(Map<String, Object> params){ private QueryWrapper<CommunityEntity> getWrapper(Map<String, Object> params) {
String id = (String)params.get(FieldConstant.ID_HUMP); String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>(); QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -84,4 +91,79 @@ public class CommunityServiceImpl extends BaseServiceImpl<CommunityDao, Communit
baseDao.deleteBatchIds(Arrays.asList(ids)); baseDao.deleteBatchIds(Arrays.asList(ids));
} }
/**
* 调用ruoyi接口存储社区数据
*
* @param dto
* @return void
* @author LZN
* @date 2022/6/14 15:03
*/
@Override
public void getPreserCommunityVation(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_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<CommunityEntity> list;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<CommunityEntity> getList() {
return list;
}
public void setList(List<CommunityEntity> list) {
this.list = list;
}
}
} }

7
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 @Autowired
private BmGridService bmGridService; private BmGridService bmGridService;
@Autowired
private CommunityService communityService;
@Override @Override
public void guardarDatosTask(PreserVationFormDTO dto) { public void guardarDatosTask(PreserVationFormDTO dto) {
if (StringUtils.isBlank(dto.getTableName())) { if (StringUtils.isBlank(dto.getTableName())) {
@ -42,6 +45,7 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService {
rotatorsService.preserRotatorsVation(dto); rotatorsService.preserRotatorsVation(dto);
basegridService.preserBaseGridVation(dto); basegridService.preserBaseGridVation(dto);
bmGridService.getPreserBmGridVation(dto); bmGridService.getPreserBmGridVation(dto);
communityService.getPreserCommunityVation(dto);
} }
switch (dto.getTableName()) { switch (dto.getTableName()) {
@ -66,6 +70,9 @@ public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService {
case CaWghDataConstant.SHARE_BM_GRID: case CaWghDataConstant.SHARE_BM_GRID:
bmGridService.getPreserBmGridVation(dto); bmGridService.getPreserBmGridVation(dto);
break; break;
case CaWghDataConstant.SHARE_COMMUNITY:
communityService.getPreserCommunityVation(dto);
break;
} }
} }
} }

3
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CommunityDao.xml

@ -12,6 +12,9 @@
<result property="longitude" column="longitude"/> <result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/> <result property="latitude" column="latitude"/>
</resultMap> </resultMap>
<delete id="deleteAll">
delete from community
</delete>
</mapper> </mapper>

Loading…
Cancel
Save