From 211d0831278d4305bc271a1771f4f1b3902d0b4e Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Thu, 5 May 2022 10:10:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=BB=E4=BA=A1=E4=BA=BA=E5=91=98=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/power/dto/rent/RentDeathDTO.java | 109 +++++++++++++++ .../rent/controller/RentDeathController.java | 81 +++++++++++ .../power/modules/rent/dao/RentDeathDao.java | 16 +++ .../modules/rent/entity/RentDeathEntity.java | 79 +++++++++++ .../modules/rent/excel/RentDeathExcel.java | 72 ++++++++++ .../modules/rent/redis/RentDeathRedis.java | 30 +++++ .../rent/service/RentDeathService.java | 79 +++++++++++ .../service/impl/RentDeathServiceImpl.java | 127 ++++++++++++++++++ .../resources/mapper/rent/RentDeathDao.xml | 28 ++++ 9 files changed, 621 insertions(+) create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/rent/RentDeathDTO.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentDeathController.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/dao/RentDeathDao.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/entity/RentDeathEntity.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/excel/RentDeathExcel.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/redis/RentDeathRedis.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentDeathService.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentDeathServiceImpl.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/rent/RentDeathDao.xml diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/rent/RentDeathDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/rent/RentDeathDTO.java new file mode 100644 index 0000000..7b1e1cf --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/rent/RentDeathDTO.java @@ -0,0 +1,109 @@ +package com.epmet.plugin.power.dto.rent; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 死亡名单表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-05 + */ +@Data +public class RentDeathDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * epmet用户主键 + */ + private String userId; + + /** + * 姓名 + */ + private String name; + + /** + * 身份证 + */ + private String idCard; + + /** + * 手机号 + */ + private String mobile; + + /** + * 性别 0女 1男 + */ + private String gender; + + /** + * 类型 0 租客 1 房东 + */ + private String type; + + /** + * 加入时间 + */ + private String joinDate; + + /** + * 加入原因 + */ + private String joinReason; + + /** + * 移除时间 + */ + private String removeDate; + + /** + * 移除原因 + */ + private String removeReason; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 客户ID + */ + private String customerId; + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentDeathController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentDeathController.java new file mode 100644 index 0000000..a519f60 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentDeathController.java @@ -0,0 +1,81 @@ +package com.epmet.plugin.power.modules.rent.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.plugin.power.dto.rent.RentDeathDTO; +import com.epmet.plugin.power.modules.rent.excel.RentDeathExcel; +import com.epmet.plugin.power.modules.rent.service.RentDeathService; +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-05-05 + */ +@RestController +@RequestMapping("rentDeath") +public class RentDeathController { + + @Autowired + private RentDeathService rentDeathService; + + @RequestMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = rentDeathService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + RentDeathDTO data = rentDeathService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody RentDeathDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + return rentDeathService.save(dto); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody RentDeathDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + rentDeathService.update(dto); + return new Result(); + } + + @RequestMapping(value = "delete", method = {RequestMethod.POST, RequestMethod.DELETE}) + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + rentDeathService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = rentDeathService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, RentDeathExcel.class); + } + + + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/dao/RentDeathDao.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/dao/RentDeathDao.java new file mode 100644 index 0000000..a9df131 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/dao/RentDeathDao.java @@ -0,0 +1,16 @@ +package com.epmet.plugin.power.modules.rent.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.plugin.power.modules.rent.entity.RentDeathEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 死亡名单表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-05 + */ +@Mapper +public interface RentDeathDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/entity/RentDeathEntity.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/entity/RentDeathEntity.java new file mode 100644 index 0000000..a4cdff1 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/entity/RentDeathEntity.java @@ -0,0 +1,79 @@ +package com.epmet.plugin.power.modules.rent.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +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-05-05 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("pli_rent_death") +public class RentDeathEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * epmet用户主键 + */ + private String userId; + + /** + * 姓名 + */ + private String name; + + /** + * 身份证 + */ + private String idCard; + + /** + * 手机号 + */ + private String mobile; + + /** + * 性别 0女 1男 + */ + private String gender; + + /** + * 类型 0 租客 1 房东 + */ + private String type; + + /** + * 加入时间 + */ + private String joinDate; + + /** + * 加入原因 + */ + private String joinReason; + + /** + * 移除时间 + */ + private String removeDate; + + /** + * 移除原因 + */ + private String removeReason; + + /** + * 客户ID + */ + private String customerId; + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/excel/RentDeathExcel.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/excel/RentDeathExcel.java new file mode 100644 index 0000000..f52a33d --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/excel/RentDeathExcel.java @@ -0,0 +1,72 @@ +package com.epmet.plugin.power.modules.rent.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-05-05 + */ +@Data +public class RentDeathExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "epmet用户主键") + private String userId; + + @Excel(name = "姓名") + private String name; + + @Excel(name = "身份证") + private String idCard; + + @Excel(name = "手机号") + private String mobile; + + @Excel(name = "性别 0女 1男") + private String gender; + + @Excel(name = "类型 0 租客 1 房东") + private String type; + + @Excel(name = "加入时间") + private String joinDate; + + @Excel(name = "加入原因") + private String joinReason; + + @Excel(name = "移除时间") + private String removeDate; + + @Excel(name = "移除原因") + private String removeReason; + + @Excel(name = "删除标记 0:未删除,1:已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "客户ID") + private String customerId; + + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/redis/RentDeathRedis.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/redis/RentDeathRedis.java new file mode 100644 index 0000000..18ba5b6 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/redis/RentDeathRedis.java @@ -0,0 +1,30 @@ +package com.epmet.plugin.power.modules.rent.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-05-05 + */ +@Component +public class RentDeathRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentDeathService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentDeathService.java new file mode 100644 index 0000000..23935f8 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentDeathService.java @@ -0,0 +1,79 @@ +package com.epmet.plugin.power.modules.rent.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.plugin.power.dto.rent.RentDeathDTO; +import com.epmet.plugin.power.modules.rent.entity.RentDeathEntity; + +import java.util.List; +import java.util.Map; + +/** + * 死亡名单表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-05 + */ +public interface RentDeathService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-05-05 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-05-05 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return RentDeathDTO + * @author generator + * @date 2022-05-05 + */ + RentDeathDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-05 + */ + Result save(RentDeathDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-05 + */ + void update(RentDeathDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-05-05 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentDeathServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentDeathServiceImpl.java new file mode 100644 index 0000000..88f4492 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentDeathServiceImpl.java @@ -0,0 +1,127 @@ +package com.epmet.plugin.power.modules.rent.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.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.form.RentTenantDataFormDTO; +import com.epmet.dto.result.RentTenantDataResultDTO; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.plugin.power.dto.rent.RentDeathDTO; +import com.epmet.plugin.power.modules.rent.dao.RentDeathDao; +import com.epmet.plugin.power.modules.rent.entity.RentDeathEntity; +import com.epmet.plugin.power.modules.rent.redis.RentDeathRedis; +import com.epmet.plugin.power.modules.rent.service.RentDeathService; +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.util.*; + +/** + * 死亡名单表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-05 + */ +@Service +public class RentDeathServiceImpl extends BaseServiceImpl implements RentDeathService { + + @Autowired + private RentDeathRedis rentDeathRedis; + + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + + @Autowired + LoginUserUtil loginUserUtil; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, RentDeathDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, RentDeathDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String) params.get(FieldConstant.ID_HUMP); + String name = (String) params.get("name"); + String idCard = (String) params.get("idCard"); + String mobile = (String) params.get("mobile"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.eq(StringUtils.isNotBlank(name), "NAME", name); + wrapper.eq(StringUtils.isNotBlank(idCard), "ID_CARD", idCard); + wrapper.eq(StringUtils.isNotBlank(mobile), "MOBILE", mobile); + wrapper.ge(StringUtils.isNotBlank(startTime), "JOIN_DATE", startTime); + wrapper.le(StringUtils.isNotBlank(endTime), "JOIN_DATE", endTime); + + return wrapper; + } + + @Override + public RentDeathDTO get(String id) { + RentDeathEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, RentDeathDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result save(RentDeathDTO dto) { + RentTenantDataFormDTO formDTO = new RentTenantDataFormDTO(); + formDTO.setUserId(dto.getUserId()); + formDTO.setCustomerId(loginUserUtil.getLoginUserCustomerId()); + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class, DefaultGroup.class); + Result result = epmetUserOpenFeignClient.getRentResiUserInfo(formDTO); + + dto.setIdCard(result.getData().getIdCard()); + dto.setMobile(result.getData().getMobile()); + Map params = new HashMap<>(4); + params.put("idCard", dto.getIdCard()); + if (!list(params).isEmpty()) { + return new Result().error("该人员已经迁入死亡人口"); + } + + dto.setJoinDate(DateUtils.format(new Date())); + RentDeathEntity entity = ConvertUtils.sourceToTarget(dto, RentDeathEntity.class); + entity.setCustomerId(loginUserUtil.getLoginUserCustomerId()); + insert(entity); + return new Result(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(RentDeathDTO dto) { + RentDeathEntity entity = ConvertUtils.sourceToTarget(dto, RentDeathEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/rent/RentDeathDao.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/rent/RentDeathDao.xml new file mode 100644 index 0000000..6db3b9b --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/rent/RentDeathDao.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file