Browse Source

人口基本信息调用ruoyi接口存储数据

master
HAHA 3 years ago
parent
commit
7137426cfa
  1. 15
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaResidentController.java
  2. 2
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaResidentDao.java
  3. 8
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaResidentService.java
  4. 108
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaResidentServiceImpl.java
  5. 3
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CaResidentDao.xml

15
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaResidentController.java

@ -14,6 +14,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.opendata.dto.CaResidentDTO;
import com.epmet.opendata.dto.form.CaLoudongFormDTO;
import com.epmet.opendata.dto.form.CaResidentFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.dto.result.CaResidentResultDTO;
import com.epmet.opendata.excel.CaResidentExcel;
@ -97,4 +98,18 @@ public class CaResidentController {
PageData<CaResidentResultDTO> data = caResidentService.getPage(dto);
return new Result<PageData<CaResidentResultDTO>>().ok(data);
}
/**
* 人口基本信息调用ruoyi接口存储数据
*
* @param dto
* @return com.epmet.commons.tools.utils.Result
* @author LZN
* @date 2022/6/2 10:47
*/
@PostMapping("/preserResidentVation")
public Result getPreserResidentVation(@RequestBody PreserVationFormDTO dto) {
caResidentService.preserResidentVation(dto);
return new Result();
}
}

2
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaResidentDao.java

@ -25,4 +25,6 @@ public interface CaResidentDao extends BaseDao<CaResidentEntity> {
* @return
*/
List<CaResidentResultDTO> getPage(@Param("residentName") String residentName);
void deleteAll();
}

8
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaResidentService.java

@ -4,6 +4,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.opendata.dto.CaResidentDTO;
import com.epmet.opendata.dto.form.CaResidentFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaResidentResultDTO;
import com.epmet.opendata.entity.CaResidentEntity;
@ -86,4 +87,11 @@ public interface CaResidentService extends BaseService<CaResidentEntity> {
* @return
*/
PageData<CaResidentResultDTO> getPage(CaResidentFormDTO dto);
/**
* 人口基本信息调用ruoyi接口存储数据
*
* @param dto
*/
void preserResidentVation(PreserVationFormDTO dto);
}

108
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaResidentServiceImpl.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.dto.IcResiUserDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.opendata.dao.CaResidentDao;
import com.epmet.opendata.dto.CaResidentDTO;
import com.epmet.opendata.dto.form.CaResidentFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.dto.result.CaResidentResultDTO;
import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CaResidentEntity;
import com.epmet.opendata.redis.CaResidentRedis;
import com.epmet.opendata.service.CaResidentService;
@ -37,6 +46,9 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
@Autowired
private CaResidentRedis caResidentRedis;
@Autowired
private EpmetUserOpenFeignClient openFeignClient;
@Override
public PageData<CaResidentDTO> page(Map<String, Object> params) {
IPage<CaResidentEntity> page = baseDao.selectPage(
@ -53,8 +65,8 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
return ConvertUtils.sourceToTarget(entityList, CaResidentDTO.class);
}
private QueryWrapper<CaResidentEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<CaResidentEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<CaResidentEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -97,4 +109,96 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
return new PageData<>(result, info.getTotal());
}
/**
* 人口基本信息调用ruoyi接口存储数据
*
* @param dto
* @return void
* @author LZN
* @date 2022/6/2 10:47
*/
@Override
public void preserResidentVation(PreserVationFormDTO dto) {
baseDao.deleteAll();
dto.setPageNo(NumConstant.ONE);
dto.setPageSize(NumConstant.FIFTY);
dto.setTableSchema(residentEnum.RK.name);
dto.setTableName(residentEnum.RK.code);
dto.setWhereCase("delete_flag = 'normal'");
dto.setOrderBy("grid_id,update_date desc");
int pageNo = 1;
int total = 0;
do {
total = listResident(dto);
pageNo++;
dto.setPageNo(pageNo);
} while (total > (pageNo * NumConstant.FIFTY));
}
enum residentEnum {
RK("unicom", "ca_resident"),
;
private String name;
private String code;
residentEnum(String name, String code) {
this.name = name;
this.code = code;
}
}
private int listResident(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).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);
returnDate.getList().forEach(item -> {
if(StringUtils.isNotBlank(item.getIdCard())) {
Result<IcResiUserDTO> client = openFeignClient.getByResiIdCard(item.getIdCard());
IcResiUserDTO clientData = client.getData();
item.setIcResiUser(clientData.getId());
item.setHomeId(clientData.getHomeId());
}
});
this.insertBatch(returnDate.getList());
return returnDate.getTotal();
}
class ReturnDate {
private int total;
private List<CaResidentEntity> list;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<CaResidentEntity> getList() {
return list;
}
public void setList(List<CaResidentEntity> list) {
this.list = list;
}
}
}

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

@ -58,6 +58,9 @@
<result property="attribute9" column="attribute9"/>
<result property="attribute10" column="attribute10"/>
</resultMap>
<delete id="deleteAll">
delete from ca_resident
</delete>
<select id="getPage" resultType="com.epmet.opendata.dto.result.CaResidentResultDTO">
SELECT
resident_id,

Loading…
Cancel
Save