diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index a059504d2e..3b1ed3c0c4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -253,6 +253,7 @@ public enum EpmetErrorCode { NEIGHBORHOOD_DEL_FAILED(8922,""), IC_NAT_IDCARD_NATTIME(8923,"已存在相同记录"), IC_NAT(8924,"平台已存在记录,请去修改原有记录"), + RESI_IC_NAT(8925,"已存在记录,请联系社区工作人员修改"), //通用错误码 start diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerUserDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerUserDao.java deleted file mode 100644 index efd5cde8c0..0000000000 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerUserDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dataaggre.dao.epmetuser; - -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dataaggre.entity.epmetuser.CustomerUserEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * 居民用户信息,此表已作废 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-12-25 - */ -@Mapper -public interface CustomerUserDao extends BaseDao { - -} \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/CustomerUserEntity.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/CustomerUserEntity.java deleted file mode 100644 index bad1b5b830..0000000000 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/CustomerUserEntity.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dataaggre.entity.epmetuser; - -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 2020-12-25 - */ -@Data -@EqualsAndHashCode(callSuper=false) -@TableName("customer_user") -public class CustomerUserEntity extends BaseEpmetEntity { - - private static final long serialVersionUID = 1L; - - /** - * 客户Id CUSTOMER.id - */ - private String customerId; - - /** - * 微信openId - */ - private String wxOpenId; - - /** - * 微信unionId - */ - private String wxUnionId; - - /** - * 手机号 - */ - private String mobile; - - /** - * 昵称 - */ - private String nickname; - - /** - * 性别:0.未知 1.男性2女性 - */ - private Integer sex; - - /** - * 头像 - */ - private String headImgUrl; - - /** - * 国家 - */ - private String country; - - /** - * 省份 - */ - private String province; - - /** - * 城市 - */ - private String city; - - /** - * 语言 - */ - private String language; - -} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerUserDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerUserDao.xml deleted file mode 100644 index 9676ace2cc..0000000000 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerUserDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java index e15f7f5057..e6e567c43b 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java @@ -22,6 +22,10 @@ public interface ImportTaskConstants { * 核酸检测 */ String BIZ_TYPE_IC_NAT = "ic_nat"; + /** + * 疫苗接种 + */ + String BIZ_TYPE_IC_VACCINE = "ic_vaccine"; /** * 行程上报 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java index 8234693f38..21499eef9a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java @@ -4,8 +4,11 @@ import java.io.Serializable; import java.util.Date; import java.util.List; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.Max; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @@ -21,8 +24,8 @@ public class IcEpidemicSpecialAttentionDTO implements Serializable { private static final long serialVersionUID = 1L; - public interface IcEpidemicSpecialAttentionUpdate{} - public interface IcEpidemicSpecialAttentionAdd{} + public interface IcEpidemicSpecialAttentionUpdate extends CustomerClientShowGroup {} + public interface IcEpidemicSpecialAttentionAdd extends CustomerClientShowGroup {} /** * ID @@ -81,12 +84,14 @@ public class IcEpidemicSpecialAttentionDTO implements Serializable { /** * 原因 */ - private String reason; + @Length(max = 500,message = "原因限制500字以内",groups = {IcEpidemicSpecialAttentionAdd.class,IcEpidemicSpecialAttentionUpdate.class}) + private String reason; /** * 备注 */ - private String remark; + @Length(max = 500,message = "备注限制500字以内",groups = {IcEpidemicSpecialAttentionAdd.class,IcEpidemicSpecialAttentionUpdate.class}) + private String remark; /** * @@ -126,6 +131,7 @@ public class IcEpidemicSpecialAttentionDTO implements Serializable { /** * 通知内容 */ + @Length(max = 500,message = "通知内容限制500字以内",groups = {IcEpidemicSpecialAttentionAdd.class,IcEpidemicSpecialAttentionUpdate.class}) private String content; } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineDTO.java new file mode 100644 index 0000000000..73a5d69fe0 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineDTO.java @@ -0,0 +1,119 @@ +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 疫苗接种记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Data +public class IcVaccineDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 唯一标识 + */ + private String id; + + /** + * 客户Id customer.id + */ + private String customerId; + + /** + * 姓名 + */ + private String name; + + /** + * 手机号 + */ + private String mobile; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 是否客户下居民(0:否 1:是) + */ + private String isResiUser; + + /** + * 数据来源【导入的:import;】 + */ + private String userType; + + /** + * 接种时间 + */ + private Date inoculateTime; + + /** + * 接种地点 + */ + private String inoculateAddress; + + /** + * 疫苗厂家 + */ + private String manufacturer; + + /** + * 预留字段1 + */ + private String field1; + + /** + * 预留字段2 + */ + private String field2; + + /** + * 预留字段3 + */ + private String field3; + + /** + * 备注 + */ + private String remaek; + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineRelationDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineRelationDTO.java new file mode 100644 index 0000000000..3dfbaf85cd --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineRelationDTO.java @@ -0,0 +1,82 @@ +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 疫苗接种记录关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Data +public class IcVaccineRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id + */ + private String agencyId; + + /** + * 组织pids,包含当前agencyId值 + */ + private String pids; + + /** + * 疫苗记录表Id(ic_vaccine.id) + */ + private String icVaccineId; + + /** + * 关系数据的绑定途径【 +数字社区录入:icresi; +导入的:import; +同步的:synchro】 + */ + private String userType; + + /** + * 删除标识 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcNatFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcNatFormDTO.java index 9472ea4314..258f28c66b 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcNatFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcNatFormDTO.java @@ -100,6 +100,7 @@ public class AddIcNatFormDTO implements Serializable { //token中信息 private String customerId; private String staffId; + private String client; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EpidemicPreventionFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EpidemicPreventionFormDTO.java index 83d22c6a13..345d7496b0 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EpidemicPreventionFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EpidemicPreventionFormDTO.java @@ -28,6 +28,7 @@ public class EpidemicPreventionFormDTO extends PageFormDTO implements Serializab * 网格ID */ private String gridId; + private String staffId; /** * 小区ID */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java index a3fca9b02b..95ae25cd79 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java @@ -2,7 +2,6 @@ package com.epmet.dto.form; import lombok.Data; -import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -18,13 +17,13 @@ public class IcResiCollectMemFormDTO implements Serializable { /** * 居住成员1姓名 */ - @NotBlank(message = "姓名不能为空", groups = {ResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + // @NotBlank(message = "姓名不能为空", groups = {ResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) private String name; /** * 居住成员1身份证号 */ - @NotBlank(message = "身份证号不能为空", groups = {ResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + // @NotBlank(message = "身份证号不能为空", groups = {ResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) private String idNum; /** diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageTripReportFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageTripReportFormDTO.java index af23243c03..80ecb83186 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageTripReportFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageTripReportFormDTO.java @@ -1,7 +1,9 @@ package com.epmet.dto.form; import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; @@ -32,11 +34,13 @@ public class PageTripReportFormDTO extends PageFormDTO implements Serializable { * 来源地区名称 */ private String sourceAddress; + /** * 来到本地时间 */ - private Date startDate; - private Date endDate; + private String startDate; + + private String endDate; /** * token里设置 diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java index bd24801531..7aadaf3fcb 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java @@ -1,10 +1,12 @@ package com.epmet.dto.form; -import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Size; import java.io.Serializable; import java.util.List; @@ -22,22 +24,22 @@ public class SendNoticeFormDTO implements Serializable { /** * 用户列表 */ - @NotNull(message = "用户列表不能为空", groups = DefaultGroup.class) + @NotEmpty(message = "用户列表不能为空", groups = CustomerClientShowGroup.class) private List userList; /** * 通知渠道通知渠道 0小程序通知,1短信通知 */ - @NotNull(message = "通知渠道不能为空", groups = DefaultGroup.class) + @NotEmpty(message = "请选择通知渠道", groups = CustomerClientShowGroup.class) private List channel; /** * 通知来源 0 行程上报,1 疫苗接种,2 核酸检测 */ - @NotNull(message = "通知来源不能为空", groups = DefaultGroup.class) + @NotEmpty(message = "通知来源不能为空", groups = CustomerClientShowGroup.class) private String origin; /** * 通知内容 */ - @NotNull(message = "通知内容不能为空", groups = DefaultGroup.class) + @Size(min = 1, max = 500, message = "通知内容不超过500字", groups = CustomerClientShowGroup.class) private String content; /** * 组织名 diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccineListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccineListFormDTO.java new file mode 100644 index 0000000000..213c8fb9de --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccineListFormDTO.java @@ -0,0 +1,67 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description 疫苗接种信息查询 + * @Author sun + */ +@Data +public class VaccineListFormDTO extends PageFormDTO { + + private static final long serialVersionUID = -6809065476616323072L; + + public interface Detail extends CustomerClientShowGroup { + } + public interface Del extends CustomerClientShowGroup { + } + public interface Synchro extends CustomerClientShowGroup { + } + + /** + * 身份证号 + */ + private String idCard; + /** + * 当前组织:current 根组织:all + */ + private String searchType; + private String agencyId; + /** + * 姓名 + */ + private String name; + /** + * 手机号 + */ + private String mobile; + /** + * 是否客户下居民(0:否 1:是) + */ + private String isResiUser; + /** + * 检测开始时间yyyy-MM-dd HH:mm + */ + private String startTime; + /** + * 检测结束时间yyyy-MM-dd HH:mm间yy-mm-dd + */ + private String endTime; + + /** + * 核酸记录Id + */ + @NotBlank(message = "疫苗接种记录Id不能为空", groups = { Detail.class, Del.class, Synchro.class}) + private String icVaccineId; + + /** + * token里设置 + */ + private String customerId; + private String userId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListCommonExcelResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListCommonExcelResultDTO.java new file mode 100644 index 0000000000..4c301085d9 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListCommonExcelResultDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.result; + +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; + +/** + * @Description 疫苗接种-全局导出 + * @Author sun + */ +@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) +@Data +public class IcVaccineListCommonExcelResultDTO extends IcVaccineListResultDTO{ + private static final long serialVersionUID = 1L; + + /** + * 是否客户下居民(0:否 1:是) + */ + @ColumnWidth(20) + @ExcelProperty(value = "本辖区居民",order = 6) + private String isResiUser; + + + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListResultDTO.java new file mode 100644 index 0000000000..3bd51e39eb --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListResultDTO.java @@ -0,0 +1,89 @@ +package com.epmet.dto.result; + +import com.alibaba.excel.annotation.ExcelIgnore; +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 com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description 核酸检测-我的上报记录 + * @Author sun + */ +@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) +@Data +public class IcVaccineListResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 组织Id + */ + @ExcelIgnore + private String agencyId; + + private String vaccineId; + + private String userId; + + /** + * 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other + */ + @ExcelIgnore + private String userType; + + /** + * 姓名 + */ + @ColumnWidth(20) + @ExcelProperty(value = "姓名",order = 1) + private String name; + + /** + * 手机号 + */ + @ColumnWidth(20) + @ExcelProperty(value = "手机号",order = 2) + private String mobile; + + /** + * 身份证号 + */ + @ColumnWidth(25) + @ExcelProperty(value = "身份证号",order = 3) + private String idCard; + + /** + * 检测时间,yyyy-MM-dd HH:mm + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + @ColumnWidth(25) + @ExcelProperty(value = "接种时间",order = 4) + private Date inoculateTime; + + /** + * 检测结果 + */ + @ColumnWidth(20) + @ExcelProperty(value = "接种地点",order = 5) + private String inoculateAddress; + + /** + * 是否客户下居民(0:否 1:是) + */ + @ExcelIgnore + private String isResiUser; + + /** + * 检测地点 + */ + @ColumnWidth(30) + @ExcelProperty(value = "疫苗厂家",order = 7) + private String manufacturer; + + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/MyNatListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/MyNatListResultDTO.java index feb97d97f5..355d52d213 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/MyNatListResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/MyNatListResultDTO.java @@ -67,4 +67,10 @@ public class MyNatListResultDTO implements Serializable { */ private String attachmentUrl; + /** + * 检测时间,yyyy-MM-dd HH:mm + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date reportTime; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicPreventionController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicPreventionController.java index de3612756d..c490634108 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicPreventionController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicPreventionController.java @@ -60,6 +60,7 @@ public class IcEpidemicPreventionController{ @PostMapping("page") public Result> search(@LoginUser TokenDto tokenDto, @RequestBody EpidemicPreventionFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); PageData result = icResiUserService.epidemicPreventionList(formDTO); return new Result>().ok(result); } @@ -67,6 +68,7 @@ public class IcEpidemicPreventionController{ @PostMapping("user-list") public Result> userList(@LoginUser TokenDto tokenDto, @RequestBody EpidemicPreventionFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); PageData result = icResiUserService.userList(formDTO); return new Result>().ok(result); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java index 22610aa6b8..c03c2b50db 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatController.java @@ -89,6 +89,7 @@ public class IcNatController implements ResultDataResolver { ValidatorUtils.validateEntity(formDTO, AddIcNatFormDTO.Nat.class); formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setStaffId(tokenDto.getUserId()); + formDTO.setClient(tokenDto.getClient()); icNucleinService.add(formDTO); return new Result(); } @@ -246,7 +247,7 @@ public class IcNatController implements ResultDataResolver { response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition"); //response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("社区自组织导入模板", "UTF-8") + ".xlsx"); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("核酸检测导入模板", "UTF-8") + ".xlsx"); InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_nat.xlsx"); try { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java index b0b8a31553..ab0529b158 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java @@ -8,6 +8,7 @@ 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.CustomerClientShowGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcNoticeDTO; @@ -72,7 +73,7 @@ public class IcNoticeController { @PostMapping("sendNotice") public Result sendNotice(@LoginUser TokenDto tokenDto, @RequestBody SendNoticeFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); + ValidatorUtils.validateEntity(formDTO, CustomerClientShowGroup.class); formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setStaffId(tokenDto.getUserId()); icNoticeService.sendNotice(formDTO); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 7289670c7a..fbc82de26d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -502,17 +502,6 @@ public class IcResiUserController implements ResultDataResolver { return new Result(); } - @PostMapping("test") - public Result>> test(@LoginUser TokenDto tokenDto, @RequestBody DynamicQueryFormDTO formDTO) { - formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); - //formDTO.setCustomerId(tokenDto.getCustomerId()); - return new Result>>().ok(icResiUserService.dynamicQuery(formDTO.getCustomerId(), - formDTO.getFormCode(), - formDTO.getResultTableName(), - formDTO.getConditions(), - tokenDto.getUserId(), null)); - } - /** * @param formDTO * @Description 查询个人数据 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineController.java new file mode 100644 index 0000000000..2f02950d92 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineController.java @@ -0,0 +1,229 @@ +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.AppClientConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.*; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.form.VaccineListFormDTO; +import com.epmet.dto.result.IcVaccineListCommonExcelResultDTO; +import com.epmet.dto.result.IcVaccineListResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.service.IcVaccineService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; +import java.nio.file.Path; +import java.util.List; +import java.util.UUID; + + +/** + * 疫苗接种记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Slf4j +@RestController +@RequestMapping("icVaccine") +public class IcVaccineController implements ResultDataResolver { + + @Autowired + private IcVaccineService icVaccineService; + + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + + /** + * @Author sun + * @Description 【疫苗】疫苗接种信息列表 + **/ + @NoRepeatSubmit + @PostMapping("vaccine-list") + public Result> vaccineList(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + return new Result>().ok(icVaccineService.icVaccineList(formDTO)); + } + + /** + * @Author zxc + * @Description 【疫苗】疫苗接种信息同步 + **/ + @NoRepeatSubmit + @PostMapping("synchro") + public Result synchro(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, VaccineListFormDTO.Synchro.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + icVaccineService.synchro(formDTO); + return new Result(); + } + + /** + * @Author zxc + * @Description 【疫苗】疫苗接种信息取消同步 + **/ + @NoRepeatSubmit + @PostMapping("cancelsynchro") + public Result cancelSynchro(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, VaccineListFormDTO.Synchro.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + icVaccineService.cancelSynchro(formDTO); + return new Result<>(); + } + + /** + * 导入excel + * @return + */ + @PostMapping("import") + public Result importExcel(MultipartFile file) { + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); + + // 1.暂存文件 + String originalFilename = file.getOriginalFilename(); + String extName = originalFilename.substring(originalFilename.lastIndexOf(".")); + + Path fileSavePath; + try { + Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_vaccine", "import"); + fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName)); + } catch (IOException e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【疫苗接种导入】创建临时存储文件失败:{}", errorMsg); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败"); + } + + InputStream is = null; + FileOutputStream os = null; + + try { + is = file.getInputStream(); + os = new FileOutputStream(fileSavePath.toString()); + IOUtils.copy(is, os); + } catch (Exception e) { + log.error("importExcel exception", e); + } finally { + org.apache.poi.util.IOUtils.closeQuietly(is); + org.apache.poi.util.IOUtils.closeQuietly(os); + } + + // 2.生成导入任务记录 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(userId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_IC_VACCINE); + importTaskForm.setOriginFileName(originalFilename); + + ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm), + ServiceConstant.EPMET_COMMON_SERVICE, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "excel导入疫苗接种信息错误", + "导入居民疫苗接种信息失败"); + + // 3.执行导入 + icVaccineService.execAsyncExcelImport(fileSavePath, rstData.getTaskId()); + + return new Result(); + } + + /** + * @Author zxc + * @Description 【疫苗】疫苗接种信息下载模板 + **/ + @RequestMapping(value = "import-template-download", method = {RequestMethod.GET, RequestMethod.POST}) + public void downloadTemplate(HttpServletResponse response) throws IOException { + response.setCharacterEncoding("UTF-8"); + response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition"); + response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("疫苗接种导入模板", "UTF-8") + ".xlsx"); + + InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_vaccine.xlsx"); + try { + ServletOutputStream os = response.getOutputStream(); + IOUtils.copy(is, os); + } finally { + if (is != null) { + is.close(); + } + } + + } + + /** + * @Author sun + * @Description 【疫苗】疫苗接种信息列表 + **/ + @NoRepeatSubmit + @PostMapping("export") + public void export(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO, HttpServletResponse response) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setIsPage(false); + ExcelWriter excelWriter = null; + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + int pageNo = formDTO.getPageNo(); + try { + // 这里 需要指定写用哪个class去写 + String fileName = "疫苗接种信息.xlsx"; + if ("all".equals(formDTO.getSearchType())) { + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcVaccineListResultDTO.class).build(); + }else { + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcVaccineListCommonExcelResultDTO.class).build(); + } + + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").build(); + PageData data = null; + do { + data = icVaccineService.icVaccineList(formDTO); + data.getList().forEach(o-> { + o.setIsResiUser(NumConstant.ONE_STR.equals(o.getIsResiUser()) ? "是" : "否"); + }); + formDTO.setPageNo(++pageNo); + if ("current".equals(formDTO.getSearchType())) { + List list = ConvertUtils.sourceToTarget(data.getList(), IcVaccineListResultDTO.class); + excelWriter.write(list, writeSheet); + }else{ + excelWriter.write(data.getList(), writeSheet); + } + } while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); + + }catch (Exception e){ + log.error("export exception", e); + }finally { + // 千万别忘记finish 会帮忙关闭流 + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiVaccineController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineRelationController.java similarity index 57% rename from epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiVaccineController.java rename to epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineRelationController.java index 722c2966eb..b24494d2c9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiVaccineController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineRelationController.java @@ -8,55 +8,54 @@ 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.dto.IcResiVaccineDTO; -import com.epmet.service.IcResiVaccineService; +import com.epmet.dto.IcVaccineRelationDTO; +import com.epmet.service.IcVaccineRelationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.List; import java.util.Map; /** - * 居民疫苗情况 + * 疫苗接种记录关系表 * * @author generator generator@elink-cn.com - * @since v1.0.0 2022-03-28 + * @since v1.0.0 2022-04-06 */ @RestController -@RequestMapping("icResiVaccine") -public class IcResiVaccineController { +@RequestMapping("icVaccineRelation") +public class IcVaccineRelationController { @Autowired - private IcResiVaccineService icResiVaccineService; + private IcVaccineRelationService icVaccineRelationService; @RequestMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = icResiVaccineService.page(params); - return new Result>().ok(page); + public Result> page(@RequestParam Map params){ + PageData page = icVaccineRelationService.page(params); + return new Result>().ok(page); } @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) - public Result get(@PathVariable("id") String id){ - IcResiVaccineDTO data = icResiVaccineService.get(id); - return new Result().ok(data); + public Result get(@PathVariable("id") String id){ + IcVaccineRelationDTO data = icVaccineRelationService.get(id); + return new Result().ok(data); } @NoRepeatSubmit @PostMapping("save") - public Result save(@RequestBody IcResiVaccineDTO dto){ + public Result save(@RequestBody IcVaccineRelationDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - icResiVaccineService.save(dto); + icVaccineRelationService.save(dto); return new Result(); } @NoRepeatSubmit @PostMapping("update") - public Result update(@RequestBody IcResiVaccineDTO dto){ + public Result update(@RequestBody IcVaccineRelationDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - icResiVaccineService.update(dto); + icVaccineRelationService.update(dto); return new Result(); } @@ -64,7 +63,7 @@ public class IcResiVaccineController { public Result delete(@RequestBody String[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); - icResiVaccineService.delete(ids); + icVaccineRelationService.delete(ids); return new Result(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java index 2602b5858a..547ef63ca8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java @@ -40,5 +40,5 @@ public interface IcResiCollectDao extends BaseDao { * @param userId * @return */ - String selectLastSubmitId(@Param("customerId") String customerId, @Param("userId") String userId); + List selectLastSubmitId(@Param("customerId") String customerId, @Param("userId") String userId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiVaccineDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiVaccineDao.java deleted file mode 100644 index 4679c59587..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiVaccineDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.epmet.dao; - -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.entity.IcResiVaccineEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * 居民疫苗情况 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2022-03-28 - */ -@Mapper -public interface IcResiVaccineDao extends BaseDao { - -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineDao.java new file mode 100644 index 0000000000..3868760fab --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineDao.java @@ -0,0 +1,71 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcNatDTO; +import com.epmet.dto.form.MyNatListFormDTO; +import com.epmet.dto.form.VaccineListFormDTO; +import com.epmet.dto.result.IcVaccineListResultDTO; +import com.epmet.dto.result.MyNatListResultDTO; +import com.epmet.dto.result.NatListResultDTO; +import com.epmet.entity.IcVaccineEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 疫苗接种记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Mapper +public interface IcVaccineDao extends BaseDao { + /** + * @Author sun + * @Description 核酸检测-按条件查询核酸记录 + **/ + List getMyNatList(MyNatListFormDTO formDTO); + + /** + * @Author sun + * @Description 【核酸】本辖区核酸检测信息列表 + * + * @param formDTO*/ + List getIcVaccineList(VaccineListFormDTO formDTO); + + /** + * @Author sun + * @Description 【核酸】客户下核酸检测信息列表 + * + * @param formDTO*/ + List getCustomerIcVaccineList(VaccineListFormDTO formDTO); + + /** + * @Author sun + * @Description 删除操作--物理删除业务数据 + **/ + int delById(@Param("icNatId") String icNatId); + + /** + * 插入或者更新 + * + * @param e + */ + void insertOrUpdate(IcVaccineEntity e); + + /** + * @Author sun + * @Description 按条件查询业务数据 + **/ + IcNatDTO getNatDTO(@Param("customerId") String customerId, @Param("icNatId") String icNatId, @Param("idCard") String idCard, @Param("natTime") String natTime, @Param("natResult") String natResult); + + /** + * desc:根据客户id 更新是否居民状态 + * + * @param customerId + * @param icResiUserId 如果为空则更新全部 + * @return + */ + int updateIsResiFlag(@Param("customerId") String customerId, @Param("icResiUserId") String icResiUserId); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineRelationDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineRelationDao.java new file mode 100644 index 0000000000..60d80b3f61 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineRelationDao.java @@ -0,0 +1,17 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcVaccineRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 疫苗接种记录关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Mapper +public interface IcVaccineRelationDao extends BaseDao { + int delRelation(@Param("icVaccineId") String icNatId, @Param("agencyId") String agencyId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiVaccineEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineEntity.java similarity index 68% rename from epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiVaccineEntity.java rename to epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineEntity.java index f26abbe525..9bef5581d7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiVaccineEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineEntity.java @@ -1,5 +1,7 @@ package com.epmet.entity; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.epmet.commons.mybatis.entity.BaseEpmetEntity; @@ -9,21 +11,22 @@ import lombok.EqualsAndHashCode; import java.util.Date; /** - * 居民疫苗情况 + * 疫苗接种记录 * * @author generator generator@elink-cn.com - * @since v1.0.0 2022-03-28 + * @since v1.0.0 2022-04-06 */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("ic_resi_vaccine") -public class IcResiVaccineEntity extends BaseEpmetEntity { +@TableName("ic_vaccine") +public class IcVaccineEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; /** * 客户Id customer.id */ + @TableField(fill = FieldFill.INSERT_UPDATE) private String customerId; /** @@ -41,6 +44,16 @@ public class IcResiVaccineEntity extends BaseEpmetEntity { */ private String idCard; + /** + * 是否客户下居民(0:否 1:是) + */ + private String isResiUser; + + /** + * 数据来源【导入的:import;】 + */ + private String userType; + /** * 接种时间 */ @@ -74,6 +87,6 @@ public class IcResiVaccineEntity extends BaseEpmetEntity { /** * 备注 */ - private String remaek; + private String remark; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineRelationEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineRelationEntity.java new file mode 100644 index 0000000000..0c1b6c88ac --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineRelationEntity.java @@ -0,0 +1,55 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +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-04-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_vaccine_relation") +public class IcVaccineRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + @TableField(fill = FieldFill.INSERT) + private String customerId; + + /** + * 居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id + */ + private String agencyId; + + /** + * 组织pids,包含当前agencyId值 + */ + private String pids; + + /** + * 疫苗记录表Id(ic_vaccine.id) + */ + private String icVaccineId; + + /** + * 关系数据的绑定途径【 +数字社区录入:icresi; +导入的:import; +同步的:synchro】 + */ + private String userType; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcVaccineImportExcelData.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcVaccineImportExcelData.java new file mode 100644 index 0000000000..6dca8bc4bb --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcVaccineImportExcelData.java @@ -0,0 +1,64 @@ +package com.epmet.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 疫苗接种信息导入excel数据 + */ +@Data +public class IcVaccineImportExcelData implements Serializable { + + private static final long serialVersionUID = -700535059296633797L; + @NotBlank(message = "姓名为必填项") + @ExcelProperty("姓名") + private String name; + + @NotBlank(message = "手机号为必填项") + @ExcelProperty("手机号") + private String mobile; + + @NotBlank(message = "身份证号为必填项") + @ExcelProperty("身份证号") + @Length(max = 18, message = "身份证号长度不正确,应小于18位") + private String idCard; + + @NotNull(message = "接种时间为必填项") + @ExcelProperty("接种时间") + private Date inoculateTime; + + @NotBlank(message = "接种地点为必填项") + @ExcelProperty("接种地点") + private String inoculateAddress; + + @NotBlank(message = "疫苗厂家为必填项") + @ExcelProperty("疫苗厂家") + private String manufacturer; + + @Data + public static class RowRemarkMessage { + + @ExcelProperty("姓名") + @ColumnWidth(20) + private String name; + + @ExcelProperty("手机号") + @ColumnWidth(20) + private String mobile; + + @ColumnWidth(20) + @ExcelProperty("身份证号") + private String idCard; + + @ColumnWidth(60) + @ExcelProperty("错误信息") + private String errorInfo; + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcVaccineExcelImportListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcVaccineExcelImportListener.java new file mode 100644 index 0000000000..e12d4549a9 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcVaccineExcelImportListener.java @@ -0,0 +1,136 @@ +package com.epmet.excel.handler; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.ValidateException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.entity.IcVaccineEntity; +import com.epmet.excel.data.IcNatImportExcelData; +import com.epmet.excel.data.IcVaccineImportExcelData; +import com.epmet.service.impl.IcNatServiceImpl; +import com.epmet.service.impl.IcVaccineServiceImpl; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 核酸检测excel导入监听器 + */ +@Data +@Slf4j +public class IcVaccineExcelImportListener implements ReadListener { + + /** + * 最大条数阈值 + */ + public static final int MAX_THRESHOLD = 200; + + private String currentUserId; + /** + * 当前组织ID + */ + private String currentAgencyId; + + private String currentAgencyPids; + + /** + * 数据 + */ + private List datas = new ArrayList<>(); + + /** + * 错误项列表 + */ + private List errorRows = new ArrayList<>(); + /** + * 其他被标记出来的列表列表 + */ + private List otherRows = new ArrayList<>(); + + private IcVaccineServiceImpl icVaccineService; + + public IcVaccineExcelImportListener(String currentUserId, String currentAgencyId, String currentAgencyPids, IcVaccineServiceImpl icVaccineService) { + this.currentUserId = currentUserId; + this.currentAgencyId = currentAgencyId; + this.currentAgencyPids = currentAgencyPids; + this.icVaccineService = icVaccineService; + } + + @Override + public void invoke(IcVaccineImportExcelData data, AnalysisContext context) { + + try { + // 先校验数据 + ValidatorUtils.validateEntity(data); + + // 取出前后空格 + if (StringUtils.isNotBlank(data.getName())) { + data.setName(data.getName().trim()); + } + if (StringUtils.isNotBlank(data.getMobile())) { + data.setMobile(data.getMobile().trim()); + } + if (StringUtils.isNotBlank(data.getInoculateAddress())) { + data.setInoculateAddress(data.getInoculateAddress().trim()); + } + if (StringUtils.isNotBlank(data.getIdCard())) { + data.setIdCard(data.getIdCard().trim()); + } + + IcVaccineEntity icVaccineEntity = ConvertUtils.sourceToTarget(data, IcVaccineEntity.class); + icVaccineEntity.setUserType("import"); + datas.add(icVaccineEntity); + + if (datas.size() == MAX_THRESHOLD) { + execPersist(); + } + } catch (Exception e) { + String errorMsg = null; + if (e instanceof ValidateException) { + errorMsg = ((ValidateException) e).getMsg(); + } else { + errorMsg = "未知错误"; + log.error("【疫苗接种信息导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); + errorRow.setName(data.getName()); + errorRow.setMobile(data.getMobile()); + errorRow.setIdCard(data.getIdCard()); + errorRow.setErrorInfo(errorMsg); + errorRows.add(errorRow); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + // 最后几条达不到阈值,这里必须再调用一次 + execPersist(); + } + + /** + * 执行持久化 + */ + private void execPersist() { + try { + if (datas != null && datas.size() > 0) { + icVaccineService.batchPersist(datas, this); + } + } finally { + datas.clear(); + } + } + + /** + * 获取错误行 + * @return + */ + public List getErrorRows() { + return errorRows; + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiVaccineService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiVaccineService.java deleted file mode 100644 index c1b2ea0655..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiVaccineService.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.epmet.service; - -import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.IcResiVaccineDTO; -import com.epmet.dto.result.VaccineListDTO; -import com.epmet.entity.IcResiVaccineEntity; - -import java.util.List; -import java.util.Map; - -/** - * 居民疫苗情况 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2022-03-28 - */ -public interface IcResiVaccineService extends BaseService { - - /** - * 默认分页 - * - * @param params - * @return PageData - * @author generator - * @date 2022-03-28 - */ - PageData page(Map params); - - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2022-03-28 - */ - List list(Map params); - - /** - * 单条查询 - * - * @param id - * @return IcResiVaccineDTO - * @author generator - * @date 2022-03-28 - */ - IcResiVaccineDTO get(String id); - - /** - * 默认保存 - * - * @param dto - * @return void - * @author generator - * @date 2022-03-28 - */ - void save(IcResiVaccineDTO dto); - - /** - * 默认更新 - * - * @param dto - * @return void - * @author generator - * @date 2022-03-28 - */ - void update(IcResiVaccineDTO dto); - - /** - * 批量删除 - * - * @param ids - * @return void - * @author generator - * @date 2022-03-28 - */ - void delete(String[] ids); - - /** - * 获取居民疫苗接种信息 - * - * @Param idCard - * @Return {@link List< VaccineListDTO>} - * @Author zhaoqifeng - * @Date 2022/3/30 10:24 - */ - List getVaccineList(String customerId, String idCard); -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineRelationService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineRelationService.java new file mode 100644 index 0000000000..a7c9339f6e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineRelationService.java @@ -0,0 +1,78 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.IcVaccineRelationDTO; +import com.epmet.entity.IcVaccineRelationEntity; + +import java.util.List; +import java.util.Map; + +/** + * 疫苗接种记录关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +public interface IcVaccineRelationService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-04-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-04-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return IcVaccineRelationDTO + * @author generator + * @date 2022-04-06 + */ + IcVaccineRelationDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-04-06 + */ + void save(IcVaccineRelationDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-04-06 + */ + void update(IcVaccineRelationDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-04-06 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineService.java new file mode 100644 index 0000000000..b84626a8c8 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineService.java @@ -0,0 +1,56 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.VaccineListFormDTO; +import com.epmet.dto.result.IcVaccineListResultDTO; +import com.epmet.dto.result.VaccineListDTO; +import com.epmet.entity.IcVaccineEntity; + +import java.nio.file.Path; +import java.util.List; + +/** + * 疫苗接种记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +public interface IcVaccineService extends BaseService { + + /** + * @Author sun + * @Description 【核酸】核酸检测信息列表 + * + * @param formDTO + * @return*/ + PageData icVaccineList(VaccineListFormDTO formDTO); + + /** + * @Author zxc + * @Description 【核酸】核酸检测信息同步 + **/ + void synchro(VaccineListFormDTO formDTO); + + /** + * @Author zxc + * @Description 【核酸】核酸检测信息取消同步 + **/ + void cancelSynchro(VaccineListFormDTO formDTO); + + /** + * 执行Excel导入 + * @param filePath + */ + void execAsyncExcelImport(Path filePath, String importTaskId); + + /** + * 获取居民疫苗接种信息 + * + * @Param idCard + * @Return {@link List } + * @Author zhaoqifeng + * @Date 2022/3/30 10:24 + */ + List getVaccineList(String customerId, String idCard); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java index bd9faff62b..f27bc46842 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java @@ -334,7 +334,8 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl imp if (null != icNatDTO && icNatDTO.getNatResult().equals(formDTO.getNatResult())) { throw new RenException(EpmetErrorCode.IC_NAT_IDCARD_NATTIME.getCode(), EpmetErrorCode.IC_NAT_IDCARD_NATTIME.getMsg()); } else if (null != icNatDTO && !icNatDTO.getNatResult().equals(formDTO.getNatResult())) { + if ("wxmp".equals(formDTO.getClient())) { + throw new RenException(EpmetErrorCode.RESI_IC_NAT.getCode(), EpmetErrorCode.RESI_IC_NAT.getMsg()); + } throw new RenException(EpmetErrorCode.IC_NAT.getCode(), EpmetErrorCode.IC_NAT.getMsg()); } //1.获取所填居民所属组织缓存信息 @@ -488,6 +491,9 @@ public class IcNatServiceImpl extends BaseServiceImpl imp String natResult = e.getNatResult(); String natAddress = e.getNatAddress(); + // 居民信息 + IcResiUserEntity resi = getResi(customerId, idCard, null); + //1.先看客户下有没有这个人 IcNatEntity resiNat = getResiNat(customerId, idCard, natTime); if (resiNat != null && !"import".equals(resiNat.getUserType())) { @@ -547,7 +553,6 @@ public class IcNatServiceImpl extends BaseServiceImpl imp resiNat.setUpdatedBy(currentUserId); resiNat.setUpdatedTime(new Date()); - IcResiUserEntity resi = getResi(customerId, idCard, null); resiNat.setIsResiUser(resi != null ? "1" : "0"); resiNat.setUserId(resi != null ? resi.getId() : ""); @@ -555,15 +560,14 @@ public class IcNatServiceImpl extends BaseServiceImpl imp } // 还要创建关系。只有本辖区及下级居民,才建立关系 - if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { - createNatRelation(resiNat.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); + if (resi != null) { + createNatRelation(resiNat.getId(), resi.getAgencyId(), resi.getPids()); } return; } // 执行新增操作 - IcResiUserEntity resi = getResi(customerId, idCard, null); e.setIsResiUser(resi != null ? "1" : "0"); e.setUserId(resi != null ? resi.getId() : ""); e.setUserType("import"); @@ -571,8 +575,8 @@ public class IcNatServiceImpl extends BaseServiceImpl imp baseDao.insert(e); // 还要创建关系。只有本辖区及下级居民,才建立关系 - if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { - createNatRelation(e.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); + if (resi != null) { + createNatRelation(e.getId(), resi.getAgencyId(), resi.getPids()); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java index c306bec8aa..28fd02753b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java @@ -137,7 +137,10 @@ public class IcNoticeServiceImpl extends BaseServiceImpl entityList = formDTO.getUserList().stream().map(item -> { + List userBeanList = formDTO.getUserList().stream().collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>( + Comparator.comparing( SendNoticeFormDTO.UserListBean::getIdCard))), ArrayList::new)); + List entityList = userBeanList.stream().map(item -> { IcNoticeEntity entity = new IcNoticeEntity(); entity.setCustomerId(formDTO.getCustomerId()); entity.setChannel(channel); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java index b0befce180..fe75c7acbb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java @@ -2,6 +2,7 @@ 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.exception.EpmetErrorCode; @@ -25,6 +26,7 @@ import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.IcResiCollectService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -144,6 +146,7 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl resiCoolectIds = baseDao.selectLastSubmitId(formDTO.getCustomerId(), formDTO.getUserId()); + String latestResiCollectId = CollectionUtils.isNotEmpty(resiCoolectIds) ? resiCoolectIds.get(NumConstant.ZERO) : StrConstant.EPMETY_STR; if (StringUtils.isNotBlank(latestResiCollectId)) { resDTO.setResiCollectId(latestResiCollectId); //之前提交过 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 5817f5a5c2..38d58ce001 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -43,6 +43,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; 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.utils.SpringContextUtils; import com.epmet.constant.IcPlatformConstant; import com.epmet.constant.IcResiUserConstant; import com.epmet.constant.UserConstant; @@ -121,8 +122,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl epidemicPreventionList(EpidemicPreventionFormDTO formDTO) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null != staffInfo) { + formDTO.setAgencyId(staffInfo.getAgencyId()); + } PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); List list = baseDao.getEpidemicPreventionList(formDTO); PageInfo pageInfo = new PageInfo<>(list); @@ -1282,6 +1287,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl userList(EpidemicPreventionFormDTO formDTO) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null != staffInfo) { + formDTO.setAgencyId(staffInfo.getAgencyId()); + } PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); List list = new ArrayList<>(); if (formDTO.getAttentionType().equals(NumConstant.TWO)){ @@ -1348,7 +1357,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl natList = icNatService.getNatList(formDTO.getCustomerId(), icResiUser.getIdCard()); result.setNatList(natList); //疫苗接种 - List vaccineList = icResiVaccineService.getVaccineList(formDTO.getCustomerId(), icResiUser.getIdCard()); + List vaccineList = SpringContextUtils.getBean(IcVaccineService.class).getVaccineList(formDTO.getCustomerId(), icResiUser.getIdCard()); result.setVaccineList(vaccineList); //行程信息 List tripList = icTripReportRecordService.tripList(formDTO.getCustomerId(), icResiUser.getIdCard()); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiVaccineServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiVaccineServiceImpl.java deleted file mode 100644 index 2f5f0b0928..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiVaccineServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.epmet.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -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.utils.ConvertUtils; -import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.dao.IcResiVaccineDao; -import com.epmet.dto.IcResiVaccineDTO; -import com.epmet.dto.result.VaccineListDTO; -import com.epmet.entity.IcResiVaccineEntity; -import com.epmet.service.IcResiVaccineService; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * 居民疫苗情况 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2022-03-28 - */ -@Service -public class IcResiVaccineServiceImpl extends BaseServiceImpl implements IcResiVaccineService { - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, IcResiVaccineDTO.class); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, IcResiVaccineDTO.class); - } - - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; - } - - @Override - public IcResiVaccineDTO get(String id) { - IcResiVaccineEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, IcResiVaccineDTO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(IcResiVaccineDTO dto) { - IcResiVaccineEntity entity = ConvertUtils.sourceToTarget(dto, IcResiVaccineEntity.class); - insert(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(IcResiVaccineDTO dto) { - IcResiVaccineEntity entity = ConvertUtils.sourceToTarget(dto, IcResiVaccineEntity.class); - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - - /** - * 获取居民疫苗接种信息 - * - * @param idCard - * @Param idCard - * @Return {@link List< VaccineListDTO >} - * @Author zhaoqifeng - * @Date 2022/3/30 10:24 - */ - @Override - public List getVaccineList(String customerId, String idCard) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(IcResiVaccineEntity::getCustomerId, customerId); - wrapper.eq(IcResiVaccineEntity::getIdCard, idCard); - wrapper.orderByDesc(IcResiVaccineEntity::getInoculateTime); - List list = baseDao.selectList(wrapper); - if (CollectionUtils.isEmpty(list)) { - return Collections.emptyList(); - } - return list.stream().map(item -> { - VaccineListDTO dto = new VaccineListDTO(); - dto.setAddress(item.getInoculateAddress()); - dto.setManufactor(item.getManufacturer()); - dto.setVaccinateTime(DateUtils.format(item.getInoculateTime(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); - return dto; - }).collect(Collectors.toList()); - } - -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java index 2aaf0c8fad..5be16161fc 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java @@ -351,33 +351,36 @@ public class IcTripReportRecordServiceImpl extends BaseServiceImpl errorRows = listener.getErrorRows(); - // 生成并上传错误文件 - try { - // 文件生成 - Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_trip_preport", "import", "error_des"); - String fileName = UUID.randomUUID().toString().concat(".xlsx"); - errorDescFile = errorDescDir.resolve(fileName); - - FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); - FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); - OutputStream os = fileItem.getOutputStream(); - - EasyExcel.write(os, IcTripReportExcelData.ErrorRow.class).sheet("导入失败列表").doWrite(errorRows); - - // 文件上传oss - Result errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); - if (errorDesFileUploadResult.success()) { - errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); - } - } finally { - if (Files.exists(errorDescFile)) { - Files.delete(errorDescFile); + boolean failed = errorRows.size() > 0; + if (failed) { + // 生成并上传错误文件 + try { + // 文件生成 + Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_trip_preport", "import", "error_des"); + String fileName = UUID.randomUUID().toString().concat(".xlsx"); + errorDescFile = errorDescDir.resolve(fileName); + + FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); + OutputStream os = fileItem.getOutputStream(); + + EasyExcel.write(os, IcTripReportExcelData.ErrorRow.class).sheet("导入失败列表").doWrite(errorRows); + + // 文件上传oss + Result errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + if (errorDesFileUploadResult.success()) { + errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); + } + } finally { + if (Files.exists(errorDescFile)) { + Files.delete(errorDescFile); + } } } ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); importFinishTaskForm.setTaskId(importTaskId); - importFinishTaskForm.setProcessStatus(errorRows.size() <= 0 ? ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS : ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); importFinishTaskForm.setOperatorId(userId); importFinishTaskForm.setResultDesc(""); importFinishTaskForm.setResultDescFilePath(errorDesFileUrl); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineRelationServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineRelationServiceImpl.java new file mode 100644 index 0000000000..6920ddf8d5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineRelationServiceImpl.java @@ -0,0 +1,82 @@ +package com.epmet.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.dao.IcVaccineRelationDao; +import com.epmet.dto.IcVaccineRelationDTO; +import com.epmet.entity.IcVaccineRelationEntity; +import com.epmet.service.IcVaccineRelationService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 疫苗接种记录关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Service +public class IcVaccineRelationServiceImpl extends BaseServiceImpl implements IcVaccineRelationService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, IcVaccineRelationDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, IcVaccineRelationDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public IcVaccineRelationDTO get(String id) { + IcVaccineRelationEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, IcVaccineRelationDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(IcVaccineRelationDTO dto) { + IcVaccineRelationEntity entity = ConvertUtils.sourceToTarget(dto, IcVaccineRelationEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(IcVaccineRelationDTO dto) { + IcVaccineRelationEntity entity = ConvertUtils.sourceToTarget(dto, IcVaccineRelationEntity.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-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineServiceImpl.java new file mode 100644 index 0000000000..ec33974bf8 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineServiceImpl.java @@ -0,0 +1,466 @@ +package com.epmet.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.EpmetRequestHolder; +import com.epmet.commons.tools.utils.FileUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcResiUserDao; +import com.epmet.dao.IcVaccineDao; +import com.epmet.dao.IcVaccineRelationDao; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.form.VaccineListFormDTO; +import com.epmet.dto.result.IcVaccineListResultDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.dto.result.VaccineListDTO; +import com.epmet.entity.IcResiUserEntity; +import com.epmet.entity.IcVaccineEntity; +import com.epmet.entity.IcVaccineRelationEntity; +import com.epmet.excel.data.IcNatImportExcelData; +import com.epmet.excel.data.IcVaccineImportExcelData; +import com.epmet.excel.handler.IcVaccineExcelImportListener; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; +import com.epmet.service.IcVaccineService; +import com.epmet.service.UserService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.http.entity.ContentType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 疫苗接种记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-04-06 + */ +@Slf4j +@Service +public class IcVaccineServiceImpl extends BaseServiceImpl implements IcVaccineService, ResultDataResolver { + + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @Autowired + private OssFeignClient ossFeignClient; + @Autowired + private IcVaccineRelationDao icVaccineRelationDao; + @Autowired + private IcResiUserDao icResiUserDao; + @Autowired + private UserService userService; + + /** + * @Author sun + * @Description 【疫苗】本组织及下级疫苗接种信息列表 + * + * @param formDTO + * @return*/ + @Override + public PageData icVaccineList(VaccineListFormDTO formDTO) { + //1.根据是查询客户数据还是本辖区数据走不同逻辑 + if ("current".equals(formDTO.getSearchType())) { + //本辖区数据 + //2.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + formDTO.setAgencyId(staffInfo.getAgencyId()); + //3.按条件查询业务数据 + PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) + .doSelectPageInfo(() -> baseDao.getIcVaccineList(formDTO)); + return new PageData(data.getList(), data.getTotal()); + } else if ("all".equals(formDTO.getSearchType())) { + //客户下数据 + PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) + .doSelectPageInfo(() -> baseDao.getCustomerIcVaccineList(formDTO)); + return new PageData(data.getList(), data.getTotal()); + } + + return new PageData(new ArrayList(), 0); + } + + /** + * @Author zxc + * @Description 【疫苗】疫苗接种信息同步 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void synchro(VaccineListFormDTO formDTO) { + //1.检验疫苗基础信息是否存在 + IcVaccineEntity entity = baseDao.selectById(formDTO.getIcVaccineId()); + if (null == entity) { + log.error(String.format("疫苗记录数据不存在同步失败,疫苗记录Id->%s", formDTO.getIcVaccineId())); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据同步失败,疫苗记录数据不存在"); + } + //获取工作人员缓存数据 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + //2.不管是否已存在关系数据都是先删后增 + icVaccineRelationDao.delRelation(formDTO.getIcVaccineId(), staffInfo.getAgencyId()); + //3.新增关系数据 + IcVaccineRelationEntity icVaccineRelationEntity = new IcVaccineRelationEntity(); + icVaccineRelationEntity.setCustomerId(formDTO.getCustomerId()); + icVaccineRelationEntity.setIcVaccineId(formDTO.getIcVaccineId()); + icVaccineRelationEntity.setAgencyId(staffInfo.getAgencyId()); + icVaccineRelationEntity.setPids(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(staffInfo.getAgencyPIds())?staffInfo.getAgencyPIds()+":"+staffInfo.getAgencyId():staffInfo.getAgencyId()); + icVaccineRelationEntity.setUserType("synchro"); + icVaccineRelationDao.insert(icVaccineRelationEntity); + } + + /** + * @Author zxc + * @Description 【疫苗】疫苗接种信息取消同步 + * + * @param formDTO*/ + @Override + @Transactional(rollbackFor = Exception.class) + public void cancelSynchro(VaccineListFormDTO formDTO) { + //1.获取工作人员缓存数据 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + //1.物理删除关系数据 + if (icVaccineRelationDao.delRelation(formDTO.getIcVaccineId(), staffInfo.getAgencyId()) < NumConstant.ONE) { + log.error(String.format("数据取消同步失败,疫苗记录Id->%s", formDTO.getAgencyId())); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "取消同步操作失败"); + } + } + + @Async + @Override + public void execAsyncExcelImport(Path filePath, String importTaskId) { + String userId = null; + try { + userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); + String app = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + + LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(app, client, userId); + + String agencyId = loginUserDetails.getAgencyId(); + + IcVaccineExcelImportListener listener = new IcVaccineExcelImportListener(userId, agencyId, loginUserDetails.getOrgIdPath().replace(":".concat(agencyId), ""), this); + + EasyExcel.read(filePath.toFile(), IcVaccineImportExcelData.class, listener).headRowNumber(2).sheet(0).doRead(); + + Path errorDescFile = null; + String errorDesFileUrl = null; + + List errorRows = listener.getErrorRows(); + List otherRows = listener.getOtherRows(); + + boolean failed = errorRows.size() > 0; + + // 合并到一起写入 + errorRows.addAll(otherRows); + + // 生成并上传描述文件 + if (errorRows.size() > 0) { + try { + // 文件生成 + Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_vaccine", "import", "error_des"); + String fileName = UUID.randomUUID().toString().concat(".xlsx"); + errorDescFile = errorDescDir.resolve(fileName); + + FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); + OutputStream os = fileItem.getOutputStream(); + + EasyExcel.write(os, IcNatImportExcelData.RowRemarkMessage.class).sheet("信息列表").doWrite(errorRows); + // 文件上传oss + Result errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + if (errorDesFileUploadResult.success()) { + errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); + } + + } finally { + if (Files.exists(errorDescFile)) { + Files.delete(errorDescFile); + } + } + } + + ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); + importFinishTaskForm.setTaskId(importTaskId); + importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + importFinishTaskForm.setOperatorId(userId); + importFinishTaskForm.setResultDesc(""); + importFinishTaskForm.setResultDescFilePath(errorDesFileUrl); + + Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); + if (!result.success()) { + log.error("【疫苗接种导入】finishImportTask失败"); + } + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【疫苗接种导入】出错:{}", errorMsg); + + ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); + importFinishTaskForm.setTaskId(importTaskId); + importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importFinishTaskForm.setOperatorId(userId); + importFinishTaskForm.setResultDesc("导入失败"); + + Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); + if (!result.success()) { + log.error("【疫苗接种导入】导入记录状态修改为'完成'失败"); + } + } finally { + // 删除临时文件 + if (Files.exists(filePath)) { + try { + Files.delete(filePath); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } + + /** + * 批量持久化 + * @param entities + */ + public void batchPersist(List entities, IcVaccineExcelImportListener listener) { + String customerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID); + String currentUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); + + entities.forEach(e -> { + try { + persisVaccine(e, customerId, currentUserId, listener); + } catch (Exception exception) { + String errorMsg = ExceptionUtils.getErrorStackTrace(exception); + log.error(errorMsg); + + IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); + errorRow.setName(e.getName()); + errorRow.setMobile(e.getMobile()); + errorRow.setIdCard(e.getIdCard()); + errorRow.setErrorInfo("未知系统错误"); + listener.getErrorRows().add(errorRow); + } + }); + } + + /** + * 单条持久化 + * @param e + * @param customerId + * @param currentUserId + * @param listener + */ + @Transactional(rollbackFor = Exception.class) + public void persisVaccine(IcVaccineEntity e, String customerId, String currentUserId, IcVaccineExcelImportListener listener) { + List otherRows = listener.getOtherRows(); + String agencyPids = listener.getCurrentAgencyPids(); + String agencyId = listener.getCurrentAgencyId(); + + String idCard = e.getIdCard(); + String name = e.getName(); + String mobile = e.getMobile(); + String manufacturer = e.getManufacturer(); + Date inoculateTime = e.getInoculateTime(); + String inoculateAddress = e.getInoculateAddress(); + + // 居民信息 + IcResiUserEntity resi = getResi(customerId, idCard, null); + + //1.先看客户下有没有这个人 + IcVaccineEntity resiVaccine = getResiVaccine(customerId, idCard, inoculateTime); + if (resiVaccine != null && !"import".equals(resiVaccine.getUserType())) { + // 有这个人,并且不是导入的 + String message = "已存在该次疫苗接种录入记录,请到系统中修改"; + + IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); + errorRow.setName(name); + errorRow.setMobile(mobile); + errorRow.setIdCard(idCard); + errorRow.setErrorInfo(message); + otherRows.add(errorRow); + return; + } + + if (resiVaccine != null) { + boolean needUpdate = false; + + // 有这个人,也是导入的,那就要更新le + Boolean isNameChanged = false; + if (!name.equals(resiVaccine.getName())) { + isNameChanged = true; + resiVaccine.setName(name); + needUpdate = true; + } + + if (!inoculateAddress.equals(resiVaccine.getInoculateAddress())) { + resiVaccine.setInoculateAddress(inoculateAddress); + needUpdate = true; + } + + if (!manufacturer.equals(resiVaccine.getManufacturer())) { + resiVaccine.setManufacturer(manufacturer); + needUpdate = true; + } + + if (!mobile.equals(resiVaccine.getMobile())) { + resiVaccine.setMobile(mobile); + needUpdate = true; + } + + if (isNameChanged) { + String message = "平台存在相同记录身份证号与姓名不一致,已更新最新姓名"; + IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); + errorRow.setName(name); + errorRow.setMobile(mobile); + errorRow.setIdCard(idCard); + errorRow.setErrorInfo(message); + otherRows.add(errorRow); + } + + if (needUpdate) { + resiVaccine.setUpdatedBy(currentUserId); + resiVaccine.setUpdatedTime(new Date()); + + resiVaccine.setIsResiUser(resi != null ? "1" : "0"); + + baseDao.updateById(resiVaccine); + } + + // 建立关系 + if (resi != null) { + createVaccineRelation(resiVaccine.getId(), resi.getAgencyId(), resi.getPids()); + } + + return; + } + + // 执行新增操作 + e.setIsResiUser(resi != null ? "1" : "0"); + e.setUserType("import"); + + baseDao.insert(e); + + // 只要是居民,就创建上关系 + if (resi != null) { + createVaccineRelation(e.getId(), resi.getAgencyId(), resi.getPids()); + } + } + + /** + * 是否是指定条件下的居民; + * 0:否 + * 1:是 + * @param customerId + * @param idCard + * @return + */ + public IcResiUserEntity getResi(String customerId, String idCard, String pids) { + LambdaQueryWrapper query = new LambdaQueryWrapper(); + query.eq(IcResiUserEntity::getCustomerId, customerId); + query.eq(IcResiUserEntity::getIdCard, idCard); + if (StringUtils.isNotBlank(pids)) { + query.likeRight(IcResiUserEntity::getPids, pids); + } + return icResiUserDao.selectOne(query); + } + + /** + * + * @param customerId + * @param idCard + * @return + */ + public IcVaccineEntity getResiVaccine(String customerId, String idCard, Date natTime) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcVaccineEntity::getCustomerId, customerId); + query.eq(IcVaccineEntity::getIdCard, idCard); + query.eq(IcVaccineEntity::getInoculateTime, natTime); + return baseDao.selectOne(query); + } + + /** + * 创建关系 + * @param vaccineId + * @param currentUserAgencyId + */ + private void createVaccineRelation(String vaccineId, String currentUserAgencyId, String agencyPids) { + + // 没有关系创建关系,有关系就跳过 + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcVaccineRelationEntity::getIcVaccineId, vaccineId); + query.eq(IcVaccineRelationEntity::getAgencyId, currentUserAgencyId); + if (icVaccineRelationDao.selectCount(query) > 0) { + return; + } + + IcVaccineRelationEntity relation = new IcVaccineRelationEntity(); + relation.setAgencyId(currentUserAgencyId); + relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId))); + relation.setIcVaccineId(vaccineId); + relation.setUserType("import"); + icVaccineRelationDao.insert(relation); + } + + /** + * 获取居民疫苗接种信息 + * + * @param idCard + * @Param idCard + * @Return {@link List< VaccineListDTO >} + * @Author zhaoqifeng + * @Date 2022/3/30 10:24 + */ + @Override + public List getVaccineList(String customerId, String idCard) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcVaccineEntity::getCustomerId, customerId); + wrapper.eq(IcVaccineEntity::getIdCard, idCard); + wrapper.orderByDesc(IcVaccineEntity::getInoculateTime); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(item -> { + VaccineListDTO dto = new VaccineListDTO(); + dto.setAddress(item.getInoculateAddress()); + dto.setManufactor(item.getManufacturer()); + dto.setVaccinateTime(DateUtils.format(item.getInoculateTime(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); + return dto; + }).collect(Collectors.toList()); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.37__ic_epidemic_special_attention.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.37__ic_epidemic_special_attention.sql new file mode 100644 index 0000000000..c16c75f965 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.37__ic_epidemic_special_attention.sql @@ -0,0 +1,21 @@ +CREATE TABLE `ic_epidemic_special_attention` ( + `ID` varchar(64) NOT NULL COMMENT 'ID', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `ORG_ID` varchar(64) NOT NULL COMMENT '当前工作人员所属组织ID', + `PID` varchar(64) NOT NULL COMMENT '组织ID上级', + `PIDS` varchar(255) NOT NULL COMMENT '组织ID所有上级', + `IS_ATTENTION` tinyint(1) NOT NULL COMMENT '是否关注 1:关注,0:取消关注', + `ATTENTION_TYPE` tinyint(1) NOT NULL COMMENT '关注类型,核酸检测:2,疫苗接种:1,行程上报:0', + `NAME` varchar(64) NOT NULL COMMENT '姓名', + `MOBILE` varchar(11) NOT NULL COMMENT '手机号', + `ID_CARD` varchar(18) NOT NULL COMMENT '身份证号', + `REASON` varchar(1000) DEFAULT NULL COMMENT '原因', + `REMARK` varchar(1000) DEFAULT NULL COMMENT '备注', + `DEL_FLAG` int(11) NOT NULL, + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='疫情特别关注'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.38__ic_vaccine.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.38__ic_vaccine.sql new file mode 100644 index 0000000000..825a0cd8c4 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.38__ic_vaccine.sql @@ -0,0 +1,41 @@ +#添加 疫苗接种相关表 +CREATE TABLE `ic_vaccine` ( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id customer.id', + `NAME` varchar(64) NOT NULL COMMENT '姓名', + `MOBILE` varchar(11) NOT NULL COMMENT '手机号', + `ID_CARD` varchar(18) NOT NULL COMMENT '身份证号', + `IS_RESI_USER` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否客户下居民(0:否 1:是)', + `USER_TYPE` varchar(32) NOT NULL COMMENT '数据来源【导入的:import;】', + `INOCULATE_TIME` datetime NOT NULL COMMENT '接种时间', + `INOCULATE_ADDRESS` varchar(32) NOT NULL DEFAULT '' COMMENT '接种地点', + `MANUFACTURER` varchar(32) NOT NULL DEFAULT '' COMMENT '疫苗厂家', + `FIELD1` varchar(32) DEFAULT NULL COMMENT '预留字段1', + `FIELD2` varchar(255) DEFAULT NULL COMMENT '预留字段2', + `FIELD3` varchar(255) DEFAULT NULL COMMENT '预留字段3', + `REMARK` varchar(255) DEFAULT NULL COMMENT '备注', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(2) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE, + KEY `idx_ic_card` (`ID_CARD`) USING BTREE +) COMMENT='疫苗接种记录'; + +CREATE TABLE `ic_vaccine_relation` ( + `ID` varchar(64) NOT NULL COMMENT 'ID', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id', + `PIDS` varchar(255) NOT NULL COMMENT '组织pids,包含当前agencyId值', + `IC_VACCINE_ID` varchar(64) NOT NULL COMMENT '疫苗记录表Id(ic_vaccine.id)', + `USER_TYPE` varchar(32) NOT NULL COMMENT '关系数据的绑定途径【\r\n数字社区录入:icresi;\r\n导入的:import;\r\n同步的:synchro】', + `DEL_FLAG` int(1) NOT NULL COMMENT '删除标识', + `REVISION` int(2) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) COMMENT='疫苗接种记录关系表'; diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.39__edit_special_attention_length.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.39__edit_special_attention_length.sql new file mode 100644 index 0000000000..6292ff6e20 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.39__edit_special_attention_length.sql @@ -0,0 +1,2 @@ +alter table ic_epidemic_special_attention modify column remark VARCHAR(500); +alter table ic_epidemic_special_attention modify column reason VARCHAR(500); \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_vaccine.xlsx b/epmet-user/epmet-user-server/src/main/resources/excel/ic_vaccine.xlsx new file mode 100644 index 0000000000..b1d0b56179 Binary files /dev/null and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_vaccine.xlsx differ diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml index 1510da99b8..dc8ae898b1 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml @@ -28,7 +28,7 @@ IFNULL((SELECT DATE_FORMAT(CREATED_TIME,'%Y-%m-%d %H:%i:%s') FROM ic_notice WHERE DEL_FLAG = '0' AND ORIGIN = #{attentionType} AND ID_CARD = a.ID_CARD ORDER BY CREATED_TIME DESC LIMIT 1),'') AS lastInformTime, IFNULL(v.vaccinationCount,0) AS vaccinationCount FROM ic_epidemic_special_attention a - LEFT JOIN (SELECT id_card ,count(1) AS vaccinationCount FROM ic_resi_vaccine WHERE DEL_FLAG = 0 GROUP BY ID_CARD) v ON (v.ID_CARD = a.ID_CARD) + LEFT JOIN (SELECT id_card ,count(1) AS vaccinationCount FROM ic_vaccine WHERE DEL_FLAG = 0 GROUP BY ID_CARD) v ON (v.ID_CARD = a.ID_CARD) WHERE a.DEL_FLAG = 0 AND a.ORG_ID = #{orgId} AND ATTENTION_TYPE = #{attentionType} @@ -109,4 +109,4 @@ ) - \ No newline at end of file + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml index 8392bf5856..5c4ad0b6e7 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml @@ -15,7 +15,8 @@ nat_result natResult, nat_address natAddress, file_name fileName, - attachment_url attachmentUrl + attachment_url attachmentUrl, + created_time reportTime FROM ic_nat WHERE diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml index 98725fa04e..777622c9f5 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml @@ -84,6 +84,5 @@ AND ( m.CREATED_BY = #{userId} OR m.UPDATED_BY = #{userId} ) ORDER BY m.UPDATED_TIME DESC - LIMIT 1 \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index b3fef04dbc..d5fb91de45 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -658,7 +658,7 @@ ic_resi_user a LEFT JOIN ( SELECT ID_CARD, count( id ) AS count - FROM ic_resi_vaccine + FROM ic_vaccine WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} AND DATE_FORMAT(INOCULATE_TIME,"%Y-%m-%d") > #{startDate} @@ -680,6 +680,7 @@ GROUP BY ID_CARD ) c ON a.ID_CARD = c.ID_CARD WHERE a.DEL_FLAG = '0' + AND a.`STATUS` = '0' AND a.CUSTOMER_ID = #{customerId} @@ -738,6 +739,7 @@ FROM ic_resi_user a LEFT JOIN ( SELECT ID_CARD, count( id ) AS count,created_time FROM ic_nat WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} GROUP BY ID_CARD ) c ON a.ID_CARD = c.ID_CARD WHERE a.DEL_FLAG = '0' + and a.status = 0 AND a.CUSTOMER_ID = #{customerId} @@ -773,8 +775,9 @@ b.created_time, IFNULL( b.count, 0 ) AS vaccineCount FROM ic_resi_user a - LEFT JOIN ( SELECT ID_CARD, count( id ) AS count,created_time FROM ic_resi_vaccine WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} GROUP BY ID_CARD ) b ON a.ID_CARD = b.ID_CARD + LEFT JOIN ( SELECT ID_CARD, count( id ) AS count,created_time FROM ic_vaccine WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} GROUP BY ID_CARD ) b ON a.ID_CARD = b.ID_CARD WHERE a.DEL_FLAG = '0' + and a.status = 0 AND a.CUSTOMER_ID = #{customerId} diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiVaccineDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiVaccineDao.xml deleted file mode 100644 index a330bccba9..0000000000 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiVaccineDao.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml index f667e9826d..0ccd2c31d8 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml @@ -57,7 +57,7 @@ AND ARRIVE_DATE #{endDate} ORDER BY - r.CREATED_TIME DESC + r.ARRIVE_DATE DESC diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml new file mode 100644 index 0000000000..9eb104ad06 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + DELETE FROM ic_nat WHERE id = #{icNatId} + + + + INSERT INTO epmet_user.ic_nat + (ID, CUSTOMER_ID, AGENCY_ID, PIDS, USER_ID, + USER_TYPE, NAME, MOBILE, ID_CARD, NAT_TIME, NAT_RESULT, NAT_ADDRESS, FILE_NAME, ATTACHMENT_TYPE, ATTACHMENT_URL, + DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) + VALUES (#{id}, #{customerId}, #{agencyId}, #{pids}, #{userId}, + #{userType}, #{name}, #{mobile}, #{idCard}, #{natTime}, + #{natResult}, #{natAddress}, #{fileName}, #{attachmentType}, #{attachmentUrl}, + #{delFlag}, #{revision}, #{createdBy}, #{createdTime}, #{updatedBy}, + #{updatedTime}) + ON DUPLICATE KEY update + NAME=#{name}, + MOBILE=#{mobile}, + NAT_ADDRESS=#{natAddress}, + NAT_RESULT=#{natResult}, + UPDATED_BY=#{updatedBy}, + UPDATED_TIME=NOW() + + + UPDATE ic_nat m, + ( + SELECT if(DEL_FLAG,0,1) resiFlag, ID_CARD FROM ic_resi_user + WHERE + 1=1 + + AND ID = #{icResiUserId} + + AND CUSTOMER_ID = #{customerId} + AND DEL_FLAG = '0' + ) t + SET m.IS_RESI_USER = t.resiFlag + WHERE + m.ID_CARD = t.ID_CARD + AND m.DEL_FLAG = '0' + + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineRelationDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineRelationDao.xml new file mode 100644 index 0000000000..011c1c7de1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineRelationDao.xml @@ -0,0 +1,16 @@ + + + + + + + DELETE + FROM ic_vaccine_relation + WHERE + ic_vaccine_id = #{icVaccineId} + + AND AGENCY_ID = #{agencyId} + + + + \ No newline at end of file