From a2acce763b55a63c7e3255daa371c06cb73ba0dd Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 11 May 2022 10:53:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E7=94=9F=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/IcBirthRecordDTO.java | 179 +++++++++ .../epmet/dto/form/BirthRecordFormDTO.java | 77 ++++ .../controller/IcBirthRecordController.java | 122 ++++++ .../java/com/epmet/dao/IcBirthRecordDao.java | 16 + .../com/epmet/entity/IcBirthRecordEntity.java | 131 +++++++ .../com/epmet/excel/IcBirthRecordExcel.java | 75 ++++ .../epmet/service/IcBirthRecordService.java | 67 ++++ .../impl/IcBirthRecordServiceImpl.java | 370 ++++++++++++++++++ .../resources/mapper/IcBirthRecordDao.xml | 39 ++ 9 files changed, 1076 insertions(+) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BirthRecordFormDTO.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcBirthRecordController.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcBirthRecordDao.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcBirthRecordEntity.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcBirthRecordExcel.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcBirthRecordService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java create mode 100644 epmet-user/epmet-user-server/src/main/resources/mapper/IcBirthRecordDao.xml diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java new file mode 100644 index 0000000000..cbc99af76f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java @@ -0,0 +1,179 @@ +package com.epmet.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@Data +public class IcBirthRecordDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id customer.id + */ + private String customerId; + + /** + * 组织Id + */ + private String agencyId; + + /** + * 组织的pids + */ + private String pids; + + /** + * 网格ID + */ + private String gridId; + private String gridName; + + /** + * 所属小区ID + */ + private String villageId; + + /** + * 所属楼宇Id + */ + private String buildId; + + /** + * 单元id + */ + private String unitId; + + /** + * 所属家庭Id + */ + private String homeId; + private String home; + + /** + * 姓名 + */ + private String name; + + /** + * 手机号 + */ + private String mobile; + + /** + * 性别 + */ + private String gender; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 出生日期 + */ + private String birthday; + + /** + * 出生地 + */ + private String birthplace; + + /** + * 是否享受福利【否:0 是:1】 + */ + private String isWelfare; + + /** + * 父亲姓名 + */ + private String father; + + /** + * 母亲姓名 + */ + private String mother; + private String parentName; + /** + * 胎次 + */ + private Integer count; + + /** + * 申报日期 + */ + private String reportDate; + + /** + * 户主姓名 + */ + private String householderName; + + /** + * 与户主关系【字典表】 + */ + private String householderRelation; + + /** + * 是否勾选补充居民信息0否 1是 + */ + private String isCheck; + /** + * 是否更新居民信息0否 1是 + */ + @JsonIgnore + private String isReplace; + + /** + * 删除标识 0.未删除 1.已删除 + */ + @JsonIgnore + private Integer delFlag; + + /** + * 乐观锁 + */ + @JsonIgnore + private Integer revision; + + /** + * 创建人 + */ + @JsonIgnore + private String createdBy; + + /** + * 创建时间 + */ + @JsonIgnore + private Date createdTime; + + /** + * 更新人 + */ + @JsonIgnore + private String updatedBy; + + /** + * 更新时间 + */ + @JsonIgnore + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BirthRecordFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BirthRecordFormDTO.java new file mode 100644 index 0000000000..adaff9111b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BirthRecordFormDTO.java @@ -0,0 +1,77 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/5/10 10:02 + */ +@NoArgsConstructor +@Data +public class BirthRecordFormDTO extends PageFormDTO implements Serializable { + + private static final long serialVersionUID = 5077167613040462646L; + /** + * 客户ID + */ + private String customerId; + private String staffId; + /** + * 网格ID + */ + private String gridId; + /** + * 小区ID + */ + private String villageId; + /** + * 楼栋ID + */ + private String buildId; + /** + * 单元ID + */ + private String unitId; + /** + * 房屋ID + */ + private String homeId; + /** + * 姓名 + */ + private String name; + /** + * 手机 + */ + private String mobile; + /** + * 身份证 + */ + private String idCard; + /** + * 性别 + */ + private String gender; + /** + * 出生日开始 + */ + private String startTime; + /** + * 出生日期结束 + */ + private String endTime; + /** + * 是否福利 + */ + private String isWelfare; + + /** + * 是否分页 + */ + private Boolean isPage; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcBirthRecordController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcBirthRecordController.java new file mode 100644 index 0000000000..3eed9c901a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcBirthRecordController.java @@ -0,0 +1,122 @@ +package com.epmet.controller; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; +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.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.IcBirthRecordDTO; +import com.epmet.dto.form.BirthRecordFormDTO; +import com.epmet.excel.IcBirthRecordExcel; +import com.epmet.service.IcBirthRecordService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +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.concurrent.atomic.AtomicInteger; + + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@Slf4j +@RestController +@RequestMapping("icBirthRecord") +public class IcBirthRecordController { + + @Autowired + private IcBirthRecordService icBirthRecordService; + + @RequestMapping("page") + public Result> page(@LoginUser TokenDto tokenDto, @RequestBody BirthRecordFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + PageData page = icBirthRecordService.page(formDTO); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + IcBirthRecordDTO data = icBirthRecordService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@LoginUser TokenDto tokenDto, @RequestBody IcBirthRecordDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + icBirthRecordService.save(tokenDto, dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@LoginUser TokenDto tokenDto, @RequestBody IcBirthRecordDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + icBirthRecordService.update(tokenDto, dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + icBirthRecordService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@LoginUser TokenDto tokenDto, @RequestBody BirthRecordFormDTO formDTO, HttpServletResponse response) throws Exception { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + formDTO.setIsPage(false); + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + int pageNo = formDTO.getPageNo(); + + ExcelWriter excelWriter = null; + AtomicInteger i = new AtomicInteger(1); + try { + String fileName = "出生管理.xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcBirthRecordExcel.class).build(); + PageData page = null; + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + do { + page = icBirthRecordService.page(formDTO); + List list = ConvertUtils.sourceToTarget(page.getList(), IcBirthRecordExcel.class); + list.forEach(item -> { + item.setIndex(i.getAndIncrement()); + }); + excelWriter.write(list, writeSheet); + } while (CollectionUtils.isNotEmpty(page.getList()) && page.getList().size() == formDTO.getPageSize()); + } catch (Exception e) { + log.error("export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcBirthRecordDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcBirthRecordDao.java new file mode 100644 index 0000000000..f3cfc215ee --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcBirthRecordDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcBirthRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@Mapper +public interface IcBirthRecordDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcBirthRecordEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcBirthRecordEntity.java new file mode 100644 index 0000000000..116f72e774 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcBirthRecordEntity.java @@ -0,0 +1,131 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_birth_record") +public class IcBirthRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id customer.id + */ + private String customerId; + + /** + * 组织Id + */ + private String agencyId; + + /** + * 组织的pids + */ + private String pids; + + /** + * 网格ID + */ + private String gridId; + + /** + * 所属小区ID + */ + private String villageId; + + /** + * 所属楼宇Id + */ + private String buildId; + + /** + * 单元id + */ + private String unitId; + + /** + * 所属家庭Id + */ + private String homeId; + + /** + * 姓名 + */ + private String name; + + /** + * 手机号 + */ + private String mobile; + + /** + * 性别 + */ + private String gender; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 出生日期 + */ + private String birthday; + + /** + * 出生地 + */ + private String birthplace; + + /** + * 是否享受福利【否:0 是:1】 + */ + private String isWelfare; + + /** + * 父亲姓名 + */ + private String father; + + /** + * 母亲姓名 + */ + private String mother; + + /** + * 胎次 + */ + private Integer count; + + /** + * 申报日期 + */ + private String reportDate; + + /** + * 户主姓名 + */ + private String householderName; + + /** + * 与户主关系【字典表】 + */ + private String householderRelation; + + /** + * 是否勾选补充居民信息0否 1是 + */ + private String isCheck; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcBirthRecordExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcBirthRecordExcel.java new file mode 100644 index 0000000000..92531f44f5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcBirthRecordExcel.java @@ -0,0 +1,75 @@ +package com.epmet.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.HeadStyle; +import com.alibaba.excel.enums.poi.FillPatternTypeEnum; +import lombok.Data; + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) +@Data +public class IcBirthRecordExcel { + + @ColumnWidth(5) + @ExcelProperty(value = "序号",order = 1) + private Integer index; + + @ColumnWidth(20) + @ExcelProperty(value = "姓名",order = 1) + private String name; + + @ColumnWidth(20) + @ExcelProperty(value = "所属网格",order = 1) + private String gridName; + + @ColumnWidth(30) + @ExcelProperty(value = "所属房屋",order = 1) + private String home; + + @ColumnWidth(20) + @ExcelProperty(value = "手机号",order = 1) + private String mobile; + + @ColumnWidth(20) + @ExcelProperty(value = "身份证号",order = 1) + private String idCard; + + @ColumnWidth(5) + @ExcelProperty(value = "性别",order = 1) + private String gender; + + @ColumnWidth(20) + @ExcelProperty(value = "出生日期",order = 1) + private String birthday; + + @ColumnWidth(30) + @ExcelProperty(value = "出生地",order = 1) + private String birthplace; + + @ColumnWidth(20) + @ExcelProperty(value = "出生人的父/母姓名",order = 1) + private String parentName; + + @ColumnWidth(5) + @ExcelProperty(value = "胎次",order = 1) + private Integer count; + + @ColumnWidth(20) + @ExcelProperty(value = "申报户口日期",order = 1) + private String reportDate; + + @ColumnWidth(20) + @ExcelProperty(value = "户主姓名",order = 1) + private String householderName; + + @ColumnWidth(20) + @ExcelProperty(value = "与户主关系",order = 1) + private String householderRelation; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcBirthRecordService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcBirthRecordService.java new file mode 100644 index 0000000000..00ec474c00 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcBirthRecordService.java @@ -0,0 +1,67 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.IcBirthRecordDTO; +import com.epmet.dto.form.BirthRecordFormDTO; +import com.epmet.entity.IcBirthRecordEntity; + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +public interface IcBirthRecordService extends BaseService { + + /** + * 默认分页 + * + * @param formDTO + * @return PageData + * @author generator + * @date 2022-05-10 + */ + PageData page(BirthRecordFormDTO formDTO); + + /** + * 单条查询 + * + * @param id + * @return IcBirthRecordDTO + * @author generator + * @date 2022-05-10 + */ + IcBirthRecordDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-10 + */ + void save(TokenDto tokenDto, IcBirthRecordDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-10 + */ + void update(TokenDto tokenDto, IcBirthRecordDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-05-10 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java new file mode 100644 index 0000000000..60e4d2be60 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java @@ -0,0 +1,370 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.GenderEnum; +import com.epmet.commons.tools.enums.RelationshipEnum; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.IcBirthRecordDao; +import com.epmet.dao.IcResiUserDao; +import com.epmet.dto.ChangeWelfareDTO; +import com.epmet.dto.IcBirthRecordDTO; +import com.epmet.dto.form.BirthRecordFormDTO; +import com.epmet.dto.form.IcResiUserTransferFormDTO; +import com.epmet.dto.result.AllGridsByUserIdResultDTO; +import com.epmet.dto.result.HouseInfoDTO; +import com.epmet.dto.result.SyncResiResDTO; +import com.epmet.entity.IcBirthRecordEntity; +import com.epmet.entity.IcResiUserEntity; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.service.ChangeWelfareService; +import com.epmet.service.IcBirthRecordService; +import com.epmet.service.IcResiUserService; +import com.epmet.service.IcUserTransferRecordService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@Service +public class IcBirthRecordServiceImpl extends BaseServiceImpl implements IcBirthRecordService { + @Resource + private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Resource + private IcResiUserService icResiUserService; + @Resource + private IcUserTransferRecordService icUserTransferRecordService; + @Resource + private IcResiUserDao icResiUserDao; + @Resource + private ChangeWelfareService changeWelfareService; + + @Override + public PageData page(BirthRecordFormDTO formDTO) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException("获取工作人员信息失败"); + } + + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + LambdaQueryWrapper wrapper = getWrapper(formDTO, staffInfo); + List entityList = baseDao.selectList(wrapper); + PageInfo pageInfo = new PageInfo<>(entityList); + List list = ConvertUtils.sourceToTarget(entityList, IcBirthRecordDTO.class); + + if (CollectionUtils.isNotEmpty(list)) { + //查询网格名称 + List gridIds = list.stream().map(IcBirthRecordDTO::getGridId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList()); + Result> gridInfoRes = govOrgOpenFeignClient.getGridListByGridIds(gridIds); + List gridInfoList = gridInfoRes.success() && !CollectionUtils.isEmpty(gridInfoRes.getData()) ? gridInfoRes.getData() : new ArrayList<>(); + Map gridInfoMap = gridInfoList.stream().collect(Collectors.toMap(AllGridsByUserIdResultDTO::getGridId, AllGridsByUserIdResultDTO::getGridName, (key1, key2) -> key2)); + + //查询房子名称 + List houseIdList = list.stream().map(IcBirthRecordDTO::getHomeId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList()); + Set houseIds = new HashSet<>(houseIdList); + Result> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(houseIds, formDTO.getCustomerId()); + List houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>(); + Map houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity())); + list.forEach(item -> { + item.setGridName(gridInfoMap.get(item.getGridId())); + if (houseInfoMap.containsKey(item.getHomeId()) && null != houseInfoMap.get(item.getHomeId())) { + HouseInfoDTO houseInfoDTO = houseInfoMap.get(item.getHomeId()); + item.setHome(houseInfoDTO.getAllName()); + } + if (StringUtils.isNotBlank(item.getFather()) && StringUtils.isNotBlank(item.getMother())) { + item.setParentName(item.getFather().concat(StrConstant.SEPARATOR).concat(item.getMother())); + } else { + String parentName = StringUtils.isBlank(item.getFather())?"":item.getFather() ; + parentName = parentName.concat(StringUtils.isBlank(item.getMother())?"":item.getMother()); + item.setParentName(parentName); + } + if (StringUtils.isNotBlank(item.getHouseholderRelation())) { + item.setHouseholderRelation(RelationshipEnum.getEnum(item.getHouseholderRelation()).getName()); + } + item.setGender(GenderEnum.getName(item.getGender())); + }); + } + + return new PageData<>(list, pageInfo.getTotal()); + } + + @Override + public IcBirthRecordDTO get(String id) { + IcBirthRecordEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, IcBirthRecordDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(TokenDto tokenDto, IcBirthRecordDTO dto) { + //获取工作人员信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + if (null == staffInfo) { + throw new EpmetException("获取工作人员信息失败"); + } + // + SyncResiResDTO sync = icResiUserService.checkUser(tokenDto.getCustomerId(), dto.getIdCard(), staffInfo.getAgencyId()); + //是否补充居民信息 + if (NumConstant.ONE_STR.equals(dto.getIsCheck())) { + //判断是否可迁入 + if (!sync.getMoveInstatus()) { + throw new EpmetException("请联系" + sync.getResiAgencyName() + "迁出该居民后操作"); + } + + IcResiUserEntity userEntity = ConvertUtils.sourceToTarget(dto, IcResiUserEntity.class);; + + userEntity.setCustomerId(tokenDto.getCustomerId()); + userEntity.setAgencyId(staffInfo.getAgencyId()); + userEntity.setPids(staffInfo.getAgencyPIds()); + userEntity.setYhzgx(dto.getHouseholderRelation()); + userEntity.setStatus(NumConstant.ZERO_STR); + userEntity.setSubStatus("11"); + + //判断是否有所属组织,如果有,判断是否属于当前组织,没有的话则直接新增 + if (StringUtils.isNotEmpty(sync.getAgencyId())) { + userEntity.setId(sync.getIcResiUserId()); + if (staffInfo.getAgencyId().equals(sync.getAgencyId())) { + //组织相等的情况 + if (NumConstant.ZERO_STR.equals(sync.getStatus())) { + //正常状态 + if (!dto.getHomeId().equals(sync.getResiHomeId())) { + //房屋信息不一致 + //是否更新 为空,返回确认消息 + if (StringUtils.isBlank(dto.getIsReplace())) { + throw new EpmetException("居民信息中房屋信息与当前选择房屋不一致,是否更新?"); + } else if (NumConstant.ONE_STR.equals(dto.getIsReplace())) { + //更新居民信息 + icResiUserDao.updateById(userEntity); + } + } else { + //房屋信息一致 + //更新居民信息 + icResiUserDao.updateById(userEntity); + } + } else { + //迁出或注销状态, + //更新居民信息 + icResiUserDao.updateById(userEntity); + //迁入记录 + extracted(tokenDto, dto, staffInfo, sync); + } + } else { + //组织不相等的情况 + //更新居民信息 + icResiUserDao.updateById(userEntity); + //迁入记录 + extracted(tokenDto, dto, staffInfo, sync); + + } + } else { + //添加居民信息 + icResiUserDao.insert(userEntity); + //迁入记录 + extracted(tokenDto, dto, staffInfo, sync); + } + } + + //生成出生记录 + IcBirthRecordEntity entity = ConvertUtils.sourceToTarget(dto, IcBirthRecordEntity.class); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setAgencyId(staffInfo.getAgencyId()); + entity.setPids(staffInfo.getAgencyPIds()); + insert(entity); + + //记录享受福利信息 + if (NumConstant.ONE_STR.equals(dto.getIsWelfare())) { + ChangeWelfareDTO welfare = new ChangeWelfareDTO(); + welfare.setCustomerId(tokenDto.getCustomerId()); + welfare.setGridId(dto.getGridId()); + welfare.setUserId(sync.getIcResiUserId()); + welfare.setIdCard(dto.getIdCard()); + welfare.setMobile(dto.getMobile()); + welfare.setName(dto.getName()); + welfare.setGender(dto.getGender()); + welfare.setJoinReason("出生登记选定"); + changeWelfareService.saveWelfareInfo(welfare); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TokenDto tokenDto, IcBirthRecordDTO dto) { + + IcBirthRecordEntity record = baseDao.selectById(dto.getId()); + + //获取工作人员信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + if (null == staffInfo) { + throw new EpmetException("获取工作人员信息失败"); + } + if (NumConstant.ONE_STR.equals(dto.getIsCheck()) && NumConstant.ONE_STR.equals(record.getIsCheck())) { + throw new EpmetException("已补充到居民信息"); + } + //是否补充居民信息 + SyncResiResDTO sync = icResiUserService.checkUser(tokenDto.getCustomerId(), dto.getIdCard(), staffInfo.getAgencyId()); + if (NumConstant.ONE_STR.equals(dto.getIsCheck())) { + //判断是否可迁入 + if (!sync.getMoveInstatus()) { + throw new EpmetException("请联系" + sync.getResiAgencyName() + "迁出该居民后操作"); + } + + IcResiUserEntity userEntity = ConvertUtils.sourceToTarget(record, IcResiUserEntity.class); + userEntity.setCustomerId(tokenDto.getCustomerId()); + userEntity.setAgencyId(staffInfo.getAgencyId()); + userEntity.setPids(staffInfo.getAgencyPIds()); + userEntity.setYhzgx(dto.getHouseholderRelation()); + userEntity.setStatus(NumConstant.ZERO_STR); + userEntity.setSubStatus("11"); + + //判断是否有所属组织,如果有,判断是否属于当前组织,没有的话则直接新增 + if (StringUtils.isNotEmpty(sync.getAgencyId())) { + userEntity.setId(sync.getIcResiUserId()); + if (staffInfo.getAgencyId().equals(sync.getAgencyId())) { + //组织相等的情况 + if (NumConstant.ZERO_STR.equals(sync.getStatus())) { + //正常状态 + if (!dto.getHomeId().equals(sync.getResiHomeId())) { + //房屋信息不一致 + //是否更新 为空,返回确认消息 + if (StringUtils.isBlank(dto.getIsReplace())) { + throw new EpmetException("居民信息中房屋信息与当前选择房屋不一致,是否更新?"); + } else if (NumConstant.ONE_STR.equals(dto.getIsReplace())) { + //更新居民信息 + icResiUserDao.updateById(userEntity); + } + } else { + //房屋信息一致 + //更新居民信息 + icResiUserDao.updateById(userEntity); + } + } else { + //迁出或注销状态, + //更新居民信息 + icResiUserDao.updateById(userEntity); + //迁入记录 + extracted(tokenDto, ConvertUtils.sourceToTarget(record, IcBirthRecordDTO.class), staffInfo, sync); + } + } else { + //组织不相等的情况 + //更新居民信息 + icResiUserDao.updateById(userEntity); + //迁入记录 + extracted(tokenDto, ConvertUtils.sourceToTarget(record, IcBirthRecordDTO.class), staffInfo, sync); + + } + } else { + //添加居民信息 + icResiUserDao.insert(userEntity); + //迁入记录 + extracted(tokenDto, dto, staffInfo, sync); + } + } + + IcBirthRecordEntity entity = ConvertUtils.sourceToTarget(dto, IcBirthRecordEntity.class); + entity.setGridId(null); + entity.setBuildId(null); + entity.setUnitId(null); + entity.setHomeId(null); + entity.setName(null); + entity.setMobile(null); + entity.setIdCard(null); + if (NumConstant.ONE_STR.equals(record.getIsCheck())) { + entity.setIsCheck(null); + } + if (NumConstant.ONE_STR.equals(record.getIsWelfare())) { + entity.setIsWelfare(null); + } + updateById(entity); + + if (NumConstant.ZERO_STR.equals(record.getIsWelfare()) && NumConstant.ONE_STR.equals(dto.getIsWelfare())) { + ChangeWelfareDTO welfare = new ChangeWelfareDTO(); + welfare.setCustomerId(tokenDto.getCustomerId()); + welfare.setGridId(record.getGridId()); + welfare.setUserId(sync.getIcResiUserId()); + welfare.setIdCard(record.getIdCard()); + welfare.setMobile(record.getMobile()); + welfare.setName(record.getName()); + welfare.setGender(record.getGender()); + welfare.setJoinReason("出生登记选定"); + changeWelfareService.saveWelfareInfo(welfare); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @NotNull + private LambdaQueryWrapper getWrapper(BirthRecordFormDTO formDTO, CustomerStaffInfoCacheResult staffInfo) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcBirthRecordEntity::getCustomerId, formDTO.getCustomerId()); + wrapper.and(wq -> wq.eq(IcBirthRecordEntity::getAgencyId, staffInfo.getAgencyId()).or().like(IcBirthRecordEntity::getPids, staffInfo.getAgencyId())); + wrapper.eq(StringUtils.isNotBlank(formDTO.getGridId()), IcBirthRecordEntity::getGridId, formDTO.getGridId()); + wrapper.eq(StringUtils.isNotBlank(formDTO.getVillageId()), IcBirthRecordEntity::getVillageId, formDTO.getVillageId()); + wrapper.eq(StringUtils.isNotBlank(formDTO.getBuildId()), IcBirthRecordEntity::getBuildId, formDTO.getBuildId()); + wrapper.eq(StringUtils.isNotBlank(formDTO.getUnitId()), IcBirthRecordEntity::getUnitId, formDTO.getUnitId()); + wrapper.eq(StringUtils.isNotBlank(formDTO.getHomeId()), IcBirthRecordEntity::getHomeId, formDTO.getHomeId()); + wrapper.eq(StringUtils.isNotBlank(formDTO.getGender()), IcBirthRecordEntity::getGender, formDTO.getGender()); + wrapper.eq(StringUtils.isNotBlank(formDTO.getIsWelfare()), IcBirthRecordEntity::getIsWelfare, formDTO.getIsWelfare()); + wrapper.like(StringUtils.isNotBlank(formDTO.getName()), IcBirthRecordEntity::getName, formDTO.getName()); + wrapper.like(StringUtils.isNotBlank(formDTO.getMobile()), IcBirthRecordEntity::getMobile, formDTO.getMobile()); + wrapper.like(StringUtils.isNotBlank(formDTO.getIdCard()), IcBirthRecordEntity::getIdCard, formDTO.getIdCard()); + wrapper.ge(StringUtils.isNotBlank(formDTO.getStartTime()), IcBirthRecordEntity::getBirthday, formDTO.getStartTime()); + wrapper.le(StringUtils.isNotBlank(formDTO.getEndTime()), IcBirthRecordEntity::getBirthday, formDTO.getEndTime()); + return wrapper; + } + + /** + * 迁入记录 + * @Param tokenDto + * @Param dto + * @Param staffInfo + * @Param sync + * @Return + * @Author zhaoqifeng + * @Date 2022/5/11 9:15 + */ + private void extracted(TokenDto tokenDto, IcBirthRecordDTO dto, CustomerStaffInfoCacheResult staffInfo, SyncResiResDTO sync) { + IcResiUserTransferFormDTO transfer = new IcResiUserTransferFormDTO(); + transfer.setCustomerId(tokenDto.getCustomerId()); + transfer.setStaffId(tokenDto.getUserId()); + transfer.setIcUserId(sync.getIcResiUserId()); + transfer.setType("in"); + transfer.setNewAgencyId(staffInfo.getAgencyId()); + transfer.setNewGridId(dto.getGridId()); + transfer.setNewNeighborHoodId(dto.getVillageId()); + transfer.setNewBuildingId(dto.getBuildId()); + transfer.setNewBuildingUnitId(dto.getUnitId()); + transfer.setNewHouseId(dto.getHomeId()); + transfer.setTransferTime(new Date()); + transfer.setReason("出生登记"); + transfer.setOrigin("birth"); + icUserTransferRecordService.moveOutResi(transfer); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcBirthRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcBirthRecordDao.xml new file mode 100644 index 0000000000..52a3ce76eb --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcBirthRecordDao.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file