Browse Source

代码生成,编写存储caResidentUser表数据的接口,编写feignClient,完善绑定网格接口

dev
HAHA 3 years ago
parent
commit
f3c2d24a4e
  1. 64
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/ca/CaResidentUserDTO.java
  2. 57
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/SaveCaResidentUserFormDTO.java
  3. 5
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/feign/GuardarDatosFeignClient.java
  4. 6
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/feign/impl/GuardarDatosFeignClientFallBack.java
  5. 88
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaResidentUserController.java
  6. 21
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaResidentUserDao.java
  7. 42
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/CaResidentUserEntity.java
  8. 45
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/excel/CaResidentUserExcel.java
  9. 30
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/redis/CaResidentUserRedis.java
  10. 82
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaResidentUserService.java
  11. 99
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaResidentUserServiceImpl.java
  12. 8
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CaResidentUserDao.xml
  13. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  14. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

64
epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/ca/CaResidentUserDTO.java

@ -0,0 +1,64 @@
package com.epmet.opendata.dto.ca;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@Data
public class CaResidentUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 身份证号
*/
private String idCard;
/**
* ic_resi_user表id
*/
private String icResiUserId;
/**
* 绑定的房屋id
*/
private String homeId;
/**
* 创建人
*/
private Long createBy;
/**
* 创建时间
*/
private Date createDate;
/**
* 最后修改人
*/
private Long updateBy;
/**
* 最后修改时间
*/
private Date updateDate;
/**
* 删除标记normal
*/
private String deleteFlag;
/**
* 乐观锁
*/
private Integer versions;
}

57
epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/SaveCaResidentUserFormDTO.java

@ -0,0 +1,57 @@
package com.epmet.opendata.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class SaveCaResidentUserFormDTO implements Serializable {
private static final long serialVersionUID = -182571137927356144L;
/**
* 身份证号
*/
private String idCard;
/**
* ic_resi_user表id
*/
private String icResiUserId;
/**
* 房屋id
*/
private String homeId;
/**
* 创建人
*/
private Long createdBy;
/**
* 创建时间
*/
private Date createdDate;
/**
* 最后修改人
*/
private Long updatedBy;
/**
* 最后修改时间
*/
private Date updatedDate;
/**
* 删除标记
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer versions;
}

5
epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/feign/GuardarDatosFeignClient.java

@ -3,10 +3,12 @@ package com.epmet.opendata.feign;
import com.epmet.commons.tools.utils.Result;
import com.epmet.opendata.dto.form.GetResidentDetailByIdCardFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.dto.result.ResidentByIdCardResultDTO;
import com.epmet.opendata.feign.impl.GuardarDatosFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "open-data-worker-server", fallback = GuardarDatosFeignClientFallBack.class)
public interface GuardarDatosFeignClient {
@ -16,4 +18,7 @@ public interface GuardarDatosFeignClient {
@PostMapping("/opendata/caResident/getResidentDetailByIdCard")
Result<ResidentByIdCardResultDTO> getResidentDetailByIdCard(GetResidentDetailByIdCardFormDTO form);
@PostMapping("/opendata/caResidentUser/saveCaResidentUser")
Result saveCaResidentUser(@RequestBody SaveCaResidentUserFormDTO dto);
}

6
epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/feign/impl/GuardarDatosFeignClientFallBack.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.opendata.dto.form.GetResidentDetailByIdCardFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.dto.result.ResidentByIdCardResultDTO;
import com.epmet.opendata.feign.GuardarDatosFeignClient;
import org.springframework.stereotype.Component;
@ -21,4 +22,9 @@ public class GuardarDatosFeignClientFallBack implements GuardarDatosFeignClient
return ModuleUtils.feignConError("open-data-worker", "guardarDatosTask", form);
}
@Override
public Result saveCaResidentUser(SaveCaResidentUserFormDTO dto) {
return ModuleUtils.feignConError("open-data-worker", "saveCaResidentUser", dto);
}
}

88
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaResidentUserController.java

@ -0,0 +1,88 @@
package com.epmet.opendata.controller;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
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.ca.CaResidentUserDTO;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.excel.CaResidentUserExcel;
import com.epmet.opendata.service.CaResidentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@RestController
@RequestMapping("caResidentUser")
public class CaResidentUserController {
@Autowired
private CaResidentUserService caResidentUserService;
@RequestMapping("page")
public Result<PageData<CaResidentUserDTO>> page(@RequestParam Map<String, Object> params){
PageData<CaResidentUserDTO> page = caResidentUserService.page(params);
return new Result<PageData<CaResidentUserDTO>>().ok(page);
}
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
public Result<CaResidentUserDTO> get(@PathVariable("id") String id){
CaResidentUserDTO data = caResidentUserService.get(id);
return new Result<CaResidentUserDTO>().ok(data);
}
@NoRepeatSubmit
@PostMapping("save")
public Result save(@RequestBody CaResidentUserDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
caResidentUserService.save(dto);
return new Result();
}
@NoRepeatSubmit
@PostMapping("update")
public Result update(@RequestBody CaResidentUserDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
caResidentUserService.update(dto);
return new Result();
}
@PostMapping("delete")
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
caResidentUserService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<CaResidentUserDTO> list = caResidentUserService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, CaResidentUserExcel.class);
}
@PostMapping("saveCaResidentUser")
public Result saveCaResidentUser(@RequestBody SaveCaResidentUserFormDTO dto){
caResidentUserService.saveCaResidentUser(dto);
return new Result();
}
}

21
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaResidentUserDao.java

@ -0,0 +1,21 @@
package com.epmet.opendata.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.entity.CaResidentUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@Mapper
public interface CaResidentUserDao extends BaseDao<CaResidentUserEntity> {
}

42
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/CaResidentUserEntity.java

@ -0,0 +1,42 @@
package com.epmet.opendata.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEntity;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ca_resident_user")
public class CaResidentUserEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 身份证号
*/
private String idCard;
/**
* ic_resi_user表id
*/
private String icResiUserId;
/**
* 绑定的房屋id
*/
private String homeId;
}

45
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/excel/CaResidentUserExcel.java

@ -0,0 +1,45 @@
package com.epmet.opendata.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@Data
public class CaResidentUserExcel {
@Excel(name = "身份证号")
private String idCard;
@Excel(name = "ic_resi_user表id")
private String icResiUserId;
@Excel(name = "绑定的房屋id")
private String homeId;
@Excel(name = "创建人")
private Long createBy;
@Excel(name = "创建时间")
private Date createDate;
@Excel(name = "最后修改人")
private Long updateBy;
@Excel(name = "最后修改时间")
private Date updateDate;
@Excel(name = "删除标记,normal")
private String deleteFlag;
@Excel(name = "乐观锁")
private Integer versions;
}

30
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/redis/CaResidentUserRedis.java

@ -0,0 +1,30 @@
package com.epmet.opendata.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@Component
public class CaResidentUserRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

82
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaResidentUserService.java

@ -0,0 +1,82 @@
package com.epmet.opendata.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.opendata.dto.ca.CaResidentUserDTO;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.entity.CaResidentUserEntity;
import java.util.List;
import java.util.Map;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
public interface CaResidentUserService extends BaseService<CaResidentUserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<CaResidentUserDTO>
* @author generator
* @date 2022-06-22
*/
PageData<CaResidentUserDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<CaResidentUserDTO>
* @author generator
* @date 2022-06-22
*/
List<CaResidentUserDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CaResidentUserDTO
* @author generator
* @date 2022-06-22
*/
CaResidentUserDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2022-06-22
*/
void save(CaResidentUserDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2022-06-22
*/
void update(CaResidentUserDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2022-06-22
*/
void delete(String[] ids);
void saveCaResidentUser(SaveCaResidentUserFormDTO dto);
}

99
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaResidentUserServiceImpl.java

@ -0,0 +1,99 @@
package com.epmet.opendata.service.impl;
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.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.opendata.dao.CaResidentUserDao;
import com.epmet.opendata.dto.ca.CaResidentUserDTO;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.entity.CaResidentEntity;
import com.epmet.opendata.entity.CaResidentUserEntity;
import com.epmet.opendata.redis.CaResidentUserRedis;
import com.epmet.opendata.service.CaResidentUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-22
*/
@Service
public class CaResidentUserServiceImpl extends BaseServiceImpl<CaResidentUserDao, CaResidentUserEntity> implements CaResidentUserService {
@Autowired
private CaResidentUserRedis caResidentUserRedis;
@Override
public PageData<CaResidentUserDTO> page(Map<String, Object> params) {
IPage<CaResidentUserEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CaResidentUserDTO.class);
}
@Override
public List<CaResidentUserDTO> list(Map<String, Object> params) {
List<CaResidentUserEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CaResidentUserDTO.class);
}
private QueryWrapper<CaResidentUserEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<CaResidentUserEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public CaResidentUserDTO get(String id) {
CaResidentUserEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CaResidentUserDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CaResidentUserDTO dto) {
CaResidentUserEntity entity = ConvertUtils.sourceToTarget(dto, CaResidentUserEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CaResidentUserDTO dto) {
CaResidentUserEntity entity = ConvertUtils.sourceToTarget(dto, CaResidentUserEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public void saveCaResidentUser(SaveCaResidentUserFormDTO dto) {
CaResidentUserEntity entity = ConvertUtils.sourceToTarget(dto,CaResidentUserEntity.class);
insert(entity);
}
}

8
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CaResidentUserDao.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.opendata.dao.CaResidentUserDao">
</mapper>

16
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -59,6 +59,7 @@ import com.epmet.entity.*;
import com.epmet.excel.support.ExportResiUserItemDTO;
import com.epmet.feign.*;
import com.epmet.opendata.dto.form.GetResidentDetailByIdCardFormDTO;
import com.epmet.opendata.dto.form.SaveCaResidentUserFormDTO;
import com.epmet.opendata.dto.result.ResidentByIdCardResultDTO;
import com.epmet.opendata.feign.GuardarDatosFeignClient;
import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient;
@ -142,12 +143,13 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Resource
private IcVolunteerDao icVolunteerDao;
@Autowired
private GuardarDatosFeignClient feignClient;
private GuardarDatosFeignClient guardarDatosFeignClient;
@Resource
private ResiPartyMemberOpenFeignClient resiPartyMemberOpenFeignClient;
@Resource
private GovOrgOpenFeignClient getGovOrgOpenFeignClient;
private QueryWrapper<IcResiUserEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
String idCard = (String) params.get("idCard");
@ -2283,7 +2285,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
}
GetResidentDetailByIdCardFormDTO dto = new GetResidentDetailByIdCardFormDTO();
dto.setIdCard(form.getIdCard());
Result<ResidentByIdCardResultDTO> result = feignClient.getResidentDetailByIdCard(dto);
Result<ResidentByIdCardResultDTO> result = guardarDatosFeignClient.getResidentDetailByIdCard(dto);
ResidentByIdCardResultDTO residentDetailByIdCard = result.getData();
if (org.springframework.util.StringUtils.isEmpty(residentDetailByIdCard)) {
throw new RenException("获取不到人的信息");
@ -2335,15 +2337,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
} else {
throw new RenException("房屋信息不全");
}
SaveCaResidentUserFormDTO saveForm = new SaveCaResidentUserFormDTO();
saveForm.setHomeId(form.getHomeId());
saveForm.setIdCard(form.getIdCard());
if (baseDao.selectCountByIdCard(form.getIdCard(), form.getCustomerId()) > 0) {
String id = baseDao.seletIdByIdCard(entity.getCustomerId(),entity.getIdCard());
baseDao.updateByIdCard(entity);
saveForm.setIcResiUserId(id);
guardarDatosFeignClient.saveCaResidentUser(saveForm);
} else {
baseDao.insert(entity);
String id = baseDao.seletIdByIdCard(entity.getCustomerId(),entity.getIdCard());
saveForm.setIcResiUserId(id);
guardarDatosFeignClient.saveCaResidentUser(saveForm);
}
}

2
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -222,6 +222,8 @@
village_id = #{entity.villageId},
build_id = #{entity.buildId},
unit_id = #{entity.unitId},
pids = #{entity.pids},
grid_id = #{entity.gridId},
updated_time = now()
where
id_card = #{entity.idCard}

Loading…
Cancel
Save