diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index 7f1fb8e728..e516c5fba7 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -24,6 +24,7 @@ 2.8.6 1.11.3 1.18.4 + 3.0.3 @@ -177,6 +178,25 @@ javase 3.4.1 + + com.alibaba + easyexcel + ${easyexcel.version} + + + poi + org.apache.poi + + + poi-ooxml + org.apache.poi + + + poi-ooxml-schemas + org.apache.poi + + + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java new file mode 100644 index 0000000000..389338f717 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java @@ -0,0 +1,57 @@ +package com.epmet.commons.tools.enums; + +import com.epmet.commons.tools.exception.EpmetErrorCode; + +/** + * @author Administrator + */ +public enum ChannelEnum { + //通知渠道 0小程序通知,1短信通知 + APP("0", "小程序通知"), + MESSAGE("1", "短信通知"), + ALL("2", "小程序通知,短信通知"); + private String code; + private String name; + + + ChannelEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(String code) { + ChannelEnum[] houseTypeEnums = values(); + for (ChannelEnum houseTypeEnum : houseTypeEnums) { + if (houseTypeEnum.getCode() == code) { + return houseTypeEnum.getName(); + } + } + return EpmetErrorCode.SERVER_ERROR.getMsg(); + } + + public static String getCode(String name) { + ChannelEnum[] houseTypeEnums = values(); + for (ChannelEnum houseTypeEnum : houseTypeEnums) { + if (houseTypeEnum.getName().equals(name)) { + return houseTypeEnum.getCode(); + } + } + return null; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/epmet-module/data-report/data-report-server/pom.xml b/epmet-module/data-report/data-report-server/pom.xml index 472525e5e7..cf8312e897 100644 --- a/epmet-module/data-report/data-report-server/pom.xml +++ b/epmet-module/data-report/data-report-server/pom.xml @@ -100,12 +100,6 @@ 2.0.0 compile - - com.alibaba - easyexcel - 3.0.3 - compile - diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/UserMessageTypeConstant.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/UserMessageTypeConstant.java index c4f703049c..57ac759211 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/UserMessageTypeConstant.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/UserMessageTypeConstant.java @@ -164,6 +164,10 @@ public interface UserMessageTypeConstant { */ String PROJECT_REMIND="project_remind"; + /** + * 防疫通知 + */ + String ANTIEPIDEMIC="antiepidemic"; /** diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatDTO.java index df1f7db433..9c98833ed4 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -129,10 +130,10 @@ public class IcNatDTO implements Serializable { /** * 通知渠道 0小程序通知,1短信通知,多选是数组 */ - private List channel; + private List channel = new ArrayList<>(); /** * 通知内容 */ - private String content; + private String content = ""; } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java index 6e0fb6b20b..72520ef800 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java @@ -1,8 +1,12 @@ package com.epmet.dto; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; +import java.util.List; /** @@ -19,26 +23,41 @@ public class IcNoticeDTO implements Serializable { /** * 唯一标识 */ + @JsonIgnore private String id; /** * 客户Id customer.id */ + @JsonIgnore private String customerId; /** * 通知渠道 0小程序通知,1短信通知 */ private String channel; - + private List channelList; /** * 通知来源 0行程上报,1疫苗接种,2核酸检测 */ + @JsonIgnore private String origin; + /** + * 用户ID + */ + @JsonIgnore + private String userId; + /** + * 手机号 + */ + @JsonIgnore + private String mobile; + /** * 被通知人身份证号 */ + @JsonIgnore private String idCard; /** @@ -54,31 +73,37 @@ public class IcNoticeDTO implements Serializable { /** * 删除标识:0.未删除 1.已删除 */ + @JsonIgnore private Integer delFlag; /** * 乐观锁 */ + @JsonIgnore private Integer revision; /** * 创建人 */ + @JsonIgnore private String createdBy; /** * 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date createdTime; /** * 更新人 */ + @JsonIgnore private String updatedBy; /** * 更新时间 */ + @JsonIgnore private Date updatedTime; } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcNatFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcNatFormDTO.java index 6000b6a969..73928633fb 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 @@ -6,6 +6,7 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -56,7 +57,7 @@ public class AddIcNatFormDTO implements Serializable { /** * 检测时间 */ - @NotBlank(message = "检测时间不能为空", groups = Nat.class) + //@NotBlank(message = "检测时间不能为空", groups = Nat.class) @JsonFormat(pattern="yyyy-MM-dd HH:mm") private Date natTime; /** @@ -83,11 +84,11 @@ public class AddIcNatFormDTO implements Serializable { /** * 通知渠道 0小程序通知,1短信通知,多选是数组 */ - private List channel; + private List channel = new ArrayList<>(); /** * 通知内容 */ - private String content; + private String content = ""; //token中信息 private String customerId; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionFormDTO.java deleted file mode 100644 index e1fcde9b28..0000000000 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionFormDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.epmet.dto.form; - -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @Author zxc - * @DateTime 2022/3/28 13:47 - * @DESC - */ -@Data -public class CancelAttentionFormDTO implements Serializable { - - private static final long serialVersionUID = 2252387281427013057L; - - /** - * 身份证 - */ - private String idCard; - - /** - * 关注类型,核酸检测:2,疫苗接种:1 - */ - private Integer attentionType ; -} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionPackageFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionPackageFormDTO.java new file mode 100644 index 0000000000..f0c8f9a900 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionPackageFormDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/3/28 16:48 + * @DESC + */ +@Data +public class CancelAttentionPackageFormDTO implements Serializable { + + private static final long serialVersionUID = 2198470055930997870L; + + public interface CancelAttentionPackageForm{} + + + /** + * 身份证 + */ + @NotNull(message = "idCard不能为空",groups = CancelAttentionPackageForm.class) + private List idCards; + + /** + * 关注类型,核酸检测:2,疫苗接种:1 + */ + @NotNull(message = "attentionType不能为空",groups = CancelAttentionPackageForm.class) + private Integer attentionType ; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java new file mode 100644 index 0000000000..057ee17921 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/3/28 16:13 + */ +@Data +public class IcNoticeFormDTO extends PageFormDTO implements Serializable { + private static final long serialVersionUID = 7392894573654015338L; + private String customerId; + @NotBlank(message = "身份证号不能为空", groups = DefaultGroup.class) + private String idCard; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java index b19a1d9caf..e9620dc5d2 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/MyNatListFormDTO.java @@ -1,17 +1,17 @@ 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; -import java.io.Serializable; /** * @Description 核酸检测-我的上报记录 * @Author sun */ @Data -public class MyNatListFormDTO implements Serializable { +public class MyNatListFormDTO extends PageFormDTO { private static final long serialVersionUID = 9156247659994638103L; public interface MyNat extends CustomerClientShowGroup { @@ -49,11 +49,6 @@ public class MyNatListFormDTO implements Serializable { * 检测结束时间yyyy-MM-dd HH:mm间yy-mm-dd */ private String endTime; - /** - * 分页参数 - */ - private Integer pageNo = 1; - private Integer pageSize = 10; /** * 核酸记录Id @@ -61,7 +56,9 @@ public class MyNatListFormDTO implements Serializable { @NotBlank(message = "核酸记录Id不能为空", groups = { Detail.class, Del.class, Synchro.class}) private String icNatId; - //token信息 + /** + * token里设置 + */ private String customerId; private String userId; 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 new file mode 100644 index 0000000000..0d038cf71a --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java @@ -0,0 +1,63 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.DefaultGroup; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/3/28 14:14 + */ +@NoArgsConstructor +@Data +public class SendNoticeFormDTO implements Serializable { + private static final long serialVersionUID = 4800907725063604885L; + private String customerId; + /** + * 用户列表 + */ + @NotNull(message = "用户列表不能为空", groups = DefaultGroup.class) + private List userList; + /** + * 通知渠道通知渠道 0小程序通知,1短信通知 + */ + @NotNull(message = "通知渠道不能为空", groups = DefaultGroup.class) + private List channel; + /** + * 通知来源 0 行程上报,1 疫苗接种,2 核酸检测 + */ + @NotNull(message = "通知来源不能为空", groups = DefaultGroup.class) + private String origin; + /** + * 通知内容 + */ + @NotNull(message = "通知内容不能为空", groups = DefaultGroup.class) + private String content; + /** + * 组织名 + */ + @NotNull(message = "组织名不能为空", groups = DefaultGroup.class) + private String orgName; + + @NoArgsConstructor + @Data + public static class UserListBean { + /** + * 用户ID + */ + private String userId; + /** + * 手机号 + */ + private String mobile; + /** + * 身份证 + */ + private String idCard; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java index d3cbead954..a65563bb5b 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatListResultDTO.java @@ -1,76 +1,88 @@ 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.ArrayList; import java.util.Date; -import java.util.List; /** * @Description 核酸检测-我的上报记录 * @Author sun */ +@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) @Data public class NatListResultDTO implements Serializable { private static final long serialVersionUID = 1L; - //总条数 - private Integer total; - List list = new ArrayList<>(); + /** + * 核酸记录Id + */ + @ExcelIgnore + private String icNatId; + /** + * 组织Id + */ + @ExcelIgnore + private String agencyId; + /** + * 居民端小程序的用户id、数字社区的icResiUserId、其他情况无值 + */ + @ExcelIgnore + private String userId; + /** + * 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other + */ + @ExcelIgnore + private String userType; - @Data - public static class NatListDTO { + /** + * 姓名 + */ + @ColumnWidth(20) + @ExcelProperty("姓名") + private String name; - /** - * 核酸记录Id - */ - private String icNatId; - /** - * 组织Id - */ - private String agencyId; - /** - * 居民端小程序的用户id、数字社区的icResiUserId、其他情况无值 - */ - private String userId; - /** - * 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other - */ - private String userType; + /** + * 手机号 + */ + @ColumnWidth(20) + @ExcelProperty("手机号") + private String mobile; - /** - * 姓名 - */ - private String name; + /** + * 身份证号 + */ + @ColumnWidth(25) + @ExcelProperty("身份证号") + private String idCard; - /** - * 手机号 - */ - private String mobile; + /** + * 检测时间,yyyy-MM-dd HH:mm + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + @ColumnWidth(25) + @ExcelProperty("检测时间") + private Date natTime; - /** - * 身份证号 - */ - private String idCard; + /** + * 检测结果 + */ + @ColumnWidth(20) + @ExcelProperty("检测结果") + private String natResult; - /** - * 检测时间,yyyy-MM-dd HH:mm - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") - private Date natTime; + /** + * 检测地点 + */ + @ColumnWidth(30) + @ExcelProperty("检测地点") + private String natAddress; - /** - * 检测结果 - */ - private String natResult; - - /** - * 检测地点 - */ - private String natAddress; - - } } diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 0189ee8ce0..fb8ea8e9b4 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -18,25 +18,6 @@ epmet-admin-client 2.0.0 - - com.alibaba - easyexcel - 3.0.3 - - - poi - org.apache.poi - - - poi-ooxml - org.apache.poi - - - poi-ooxml-schemas - org.apache.poi - - - com.epmet epmet-user-client diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java index cf91237a2d..42fcc20c23 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java @@ -12,10 +12,7 @@ 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.IcEpidemicSpecialAttentionDTO; -import com.epmet.dto.form.CancelAttentionFormDTO; -import com.epmet.dto.form.NatListFormDTO; -import com.epmet.dto.form.VaccinationAddFormDTO; -import com.epmet.dto.form.VaccinationListFormDTO; +import com.epmet.dto.form.*; import com.epmet.service.IcEpidemicSpecialAttentionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -55,15 +52,13 @@ public class IcEpidemicSpecialAttentionController { /** * Desc:【疫苗接种关注名单,核酸检测关注名单】新增 - * @param list + * @param formDTO * @param tokenDto * @author zxc * @date 2022/3/28 13:35 */ @PostMapping("vaccination-add") - public Result vaccinationAdd(@RequestBody List list,@LoginUser TokenDto tokenDto){ - VaccinationAddFormDTO formDTO = new VaccinationAddFormDTO(); - formDTO.setList(list); + public Result vaccinationAdd(@RequestBody VaccinationAddFormDTO formDTO,@LoginUser TokenDto tokenDto){ ValidatorUtils.validateEntity(formDTO, VaccinationAddFormDTO.VaccinationAddForm.class); formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); @@ -85,13 +80,14 @@ public class IcEpidemicSpecialAttentionController { /** * Desc: 取消关注 - * @param list + * @param formDTO * @author zxc * @date 2022/3/28 13:51 */ @PostMapping("cancel-attention") - public Result cancelAttention(@RequestBody List list){ - icEpidemicSpecialAttentionService.cancelAttention(list); + public Result cancelAttention(@RequestBody CancelAttentionPackageFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, CancelAttentionPackageFormDTO.CancelAttentionPackageForm.class); + icEpidemicSpecialAttentionService.cancelAttention(formDTO); return new 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 7491f946c1..fd3d23f2f6 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 @@ -1,5 +1,8 @@ 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; @@ -8,12 +11,13 @@ 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.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.EpmetRequestHolder; import com.epmet.commons.tools.utils.FileUtils; +import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; @@ -30,13 +34,22 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcNatService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; +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 java.io.*; import java.nio.file.Files; import java.nio.file.Path; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; import java.util.List; import java.util.Map; import java.util.UUID; @@ -64,7 +77,7 @@ public class IcNatController implements ResultDataResolver { * @Author sun * @Description 核酸检测-上报核酸记录 **/ - @NoRepeatSubmit + //@NoRepeatSubmit @PostMapping("add") public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddIcNatFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, AddIcNatFormDTO.Nat.class); @@ -91,10 +104,10 @@ public class IcNatController implements ResultDataResolver { **/ @NoRepeatSubmit @PostMapping("natlist") - public Result natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) { + public Result> natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); - return new Result().ok(icNucleinService.natList(formDTO)); + return new Result>().ok(icNucleinService.natList(formDTO)); } /** @@ -114,7 +127,8 @@ public class IcNatController implements ResultDataResolver { **/ @NoRepeatSubmit @PostMapping("edit") - public Result edit(@RequestBody AddIcNatFormDTO formDTO) { + public Result edit(@LoginUser TokenDto tokenDto, @RequestBody AddIcNatFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); icNucleinService.edit(formDTO); return new Result(); } @@ -199,5 +213,69 @@ public class IcNatController implements ResultDataResolver { return new Result(); } + /** + * @Author sun + * @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.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"); + + InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_nat.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 MyNatListFormDTO formDTO, HttpServletResponse response) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + + //formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); + //formDTO.setUserId("73ae6280e46a6653a5605d51d5462725"); + + formDTO.setPage(false); + + ExcelWriter excelWriter = null; + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + int pageNo = formDTO.getPageNo(); + try { + // 这里 需要指定写用哪个class去写 + String fileName = "核酸检测信息.xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response),NatListResultDTO.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").build(); + PageData data = null; + do { + data = icNucleinService.natList(formDTO); + formDTO.setPageNo(++pageNo); + 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/IcNoticeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java index 11000e575d..f7cb128fc4 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 @@ -1,21 +1,22 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcNoticeDTO; +import com.epmet.dto.form.IcNoticeFormDTO; +import com.epmet.dto.form.SendNoticeFormDTO; import com.epmet.service.IcNoticeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.List; -import java.util.Map; - /** * 防疫通知 @@ -31,8 +32,9 @@ public class IcNoticeController { private IcNoticeService icNoticeService; @RequestMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = icNoticeService.page(params); + public Result> page(@LoginUser TokenDto tokenDto, @RequestBody IcNoticeFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + PageData page = icNoticeService.page(formDTO); return new Result>().ok(page); } @@ -68,6 +70,12 @@ public class IcNoticeController { return new Result(); } - + @PostMapping("sendNotice") + public Result sendNotice(@LoginUser TokenDto tokenDto, @RequestBody SendNoticeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + icNoticeService.sendNotice(formDTO); + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java index cc1d3ba4a1..11b6b3ab09 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java @@ -5,6 +5,7 @@ import com.epmet.dto.form.VaccinationListFormDTO; import com.epmet.dto.result.VaccinationListResultDTO; import com.epmet.entity.IcEpidemicSpecialAttentionEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -33,4 +34,22 @@ public interface IcEpidemicSpecialAttentionDao extends BaseDao natList(VaccinationListFormDTO formDTO); + /** + * Desc: 取消关注 + * @param list + * @param attentionType + * @author zxc + * @date 2022/3/28 16:59 + */ + void cancelAttention(@Param("list")List list,@Param("attentionType")Integer attentionType); + + /** + * Desc: 查询已经存在的关注 + * @param attentionType + * @param list + * @author zxc + * @date 2022/3/28 17:29 + */ + List getExistList(@Param("attentionType")Integer attentionType,@Param("list")List list); + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java index 91ce606f2d..4ac7359f2e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java @@ -29,11 +29,11 @@ public interface IcNatDao extends BaseDao { * @Author sun * @Description 【核酸】核酸检测信息列表 **/ - List getNatList(MyNatListFormDTO formDTO); + List getNatList(MyNatListFormDTO formDTO); /** * @Author sun * @Description 删除/取消同步操作--物理删除业务数据 **/ - boolean delById(@Param("icNatId") String icNatId); -} \ No newline at end of file + int delById(@Param("icNatId") String icNatId); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java index 0114b3c5e7..133d56dfcd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java @@ -1,13 +1,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 防疫通知 * @@ -36,6 +33,15 @@ public class IcNoticeEntity extends BaseEpmetEntity { */ private String origin; + /** + * 用户ID + */ + private String userId; + /** + * 手机号 + */ + private String mobile; + /** * 被通知人身份证号 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java index c1f051233d..3690df2640 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java @@ -3,7 +3,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcEpidemicSpecialAttentionDTO; -import com.epmet.dto.form.CancelAttentionFormDTO; +import com.epmet.dto.form.CancelAttentionPackageFormDTO; import com.epmet.dto.form.VaccinationAddFormDTO; import com.epmet.dto.form.VaccinationListFormDTO; import com.epmet.entity.IcEpidemicSpecialAttentionEntity; @@ -106,9 +106,9 @@ public interface IcEpidemicSpecialAttentionService extends BaseService list); + void cancelAttention(CancelAttentionPackageFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java index 872e178f7f..c460d99906 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java @@ -11,7 +11,6 @@ import com.epmet.entity.IcNatEntity; import java.nio.file.Path; import java.util.List; -import java.util.Map; /** * 核酸上报记录 @@ -36,8 +35,9 @@ public interface IcNatService extends BaseService { /** * @Author sun * @Description 【核酸】核酸检测信息列表 - **/ - NatListResultDTO natList(MyNatListFormDTO formDTO); + * + * @return*/ + PageData natList(MyNatListFormDTO formDTO); /** * @Author sun @@ -68,4 +68,4 @@ public interface IcNatService extends BaseService { * @param filePath */ void execAsyncExcelImport(Path filePath, String importTaskId); -} \ No newline at end of file +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java index 82d94c16d9..937cca916a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java @@ -3,6 +3,8 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcNoticeDTO; +import com.epmet.dto.form.IcNoticeFormDTO; +import com.epmet.dto.form.SendNoticeFormDTO; import com.epmet.entity.IcNoticeEntity; import java.util.List; @@ -19,12 +21,12 @@ public interface IcNoticeService extends BaseService { /** * 默认分页 * - * @param params + * @param dto * @return PageData * @author generator * @date 2022-03-28 */ - PageData page(Map params); + PageData page(IcNoticeFormDTO formDTO); /** * 默认查询 @@ -75,4 +77,23 @@ public interface IcNoticeService extends BaseService { * @date 2022-03-28 */ void delete(String[] ids); + + /** + * 发送通知 + * + * @Param formDTO + * @Return + * @Author zhaoqifeng + * @Date 2022/3/28 14:19 + */ + void sendNotice(SendNoticeFormDTO formDTO); + + /** + * 获取人员最新一条通知 + * @Param idCard + * @Return {@link IcNoticeDTO} + * @Author zhaoqifeng + * @Date 2022/3/28 15:43 + */ + IcNoticeDTO getNotice(String customerId, String idCard); } \ No newline at end of file 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 d9651531f1..aac9eceb61 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 @@ -7,20 +7,20 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.IcEpidemicSpecialAttentionDao; import com.epmet.dto.IcEpidemicSpecialAttentionDTO; -import com.epmet.dto.form.CancelAttentionFormDTO; -import com.epmet.dto.form.NatListFormDTO; -import com.epmet.dto.form.VaccinationAddFormDTO; -import com.epmet.dto.form.VaccinationListFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.VaccinationListResultDTO; import com.epmet.entity.IcEpidemicSpecialAttentionEntity; import com.epmet.service.IcEpidemicSpecialAttentionService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 疫情特别关注 @@ -100,10 +101,10 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl result = new PageData(new ArrayList(), NumConstant.ZERO_L); CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); if (null == staffInfo){ - throw new EpmetException("为查询到工作人员信息"+formDTO.getUserId()); + throw new EpmetException("未查询到工作人员信息"+formDTO.getUserId()); } formDTO.setOrgId(staffInfo.getAgencyId()); // 关注类型,核酸检测:2,疫苗接种:1 @@ -128,6 +129,11 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl entities = ConvertUtils.sourceToTarget(formDTO.getList(), IcEpidemicSpecialAttentionEntity.class); + List idCards = entities.stream().map(m -> m.getIdCard()).collect(Collectors.toList()); + Integer attentionType = entities.get(NumConstant.ZERO).getAttentionType(); + List existList = baseDao.getExistList(attentionType, idCards); + if (CollectionUtils.isNotEmpty(existList)){ + for (String s : existList) { + for (int i = NumConstant.ZERO; i < entities.size(); i++) { + if (s.equals(entities.get(i).getIdCard())){ + entities.remove(i); + continue; + } + } + } + } + entities.forEach(e -> { + + e.setIsAttention(NumConstant.ONE); + e.setOrgId(agencyInfo.getId()); + e.setPid(agencyInfo.getPid()); + e.setPids(agencyInfo.getPids()); + e.setCustomerId(formDTO.getCustomerId()); + }); + insertBatch(entities); + //TODO 发送通知 } /** @@ -157,13 +195,16 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl list) { - + @Transactional(rollbackFor = Exception.class) + public void cancelAttention(CancelAttentionPackageFormDTO formDTO) { + if (CollectionUtils.isNotEmpty(formDTO.getIdCards())){ + baseDao.cancelAttention(formDTO.getIdCards(), formDTO.getAttentionType()); + } } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java index 6414431035..e1c2e4d395 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java @@ -25,11 +25,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcNatDao; import com.epmet.dto.IcNatDTO; +import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.form.AddIcNatFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.LoginUserDetailsFormDTO; import com.epmet.dto.form.MyNatListFormDTO; import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.form.SendNoticeFormDTO; import com.epmet.dto.result.MyNatListResultDTO; import com.epmet.dto.result.NatListResultDTO; import com.epmet.dto.result.UploadImgResultDTO; @@ -40,9 +42,11 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.IcNatService; +import com.epmet.service.IcNoticeService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory; @@ -54,6 +58,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.commons.CommonsMultipartFile; +import java.util.ArrayList; import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; @@ -79,6 +84,9 @@ public class IcNatServiceImpl extends BaseServiceImpl imp @Autowired private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private IcNoticeService icNoticeService; + @Autowired private OssFeignClient ossFeignClient; @@ -87,6 +95,7 @@ public class IcNatServiceImpl extends BaseServiceImpl imp * @Description 核酸检测-上报核酸记录 **/ @Override + @Transactional(rollbackFor = Exception.class) public void add(AddIcNatFormDTO formDTO) { //1.获取所填居民所属组织缓存信息 AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getAgencyId()); @@ -100,7 +109,16 @@ public class IcNatServiceImpl extends BaseServiceImpl imp //3.新增通知表信息 if (formDTO.getChannel().size() > NumConstant.ZERO) { - //TODO + SendNoticeFormDTO dto = new SendNoticeFormDTO(); + List userList = new ArrayList<>(); + userList.add(ConvertUtils.sourceToTarget(formDTO, SendNoticeFormDTO.UserListBean.class)); + dto.setCustomerId(formDTO.getCustomerId()); + dto.setUserList(userList); + dto.setChannel(formDTO.getChannel()); + dto.setOrigin("2"); + dto.setContent(formDTO.getContent()); + dto.setOrgName(agencyInfo.getOrganizationName()); + icNoticeService.sendNotice(dto); } } @@ -119,10 +137,10 @@ public class IcNatServiceImpl extends BaseServiceImpl imp /** * @Author sun * @Description 【核酸】核酸检测信息列表 - **/ + * + * @return*/ @Override - public NatListResultDTO natList(MyNatListFormDTO formDTO) { - NatListResultDTO resultDTO = new NatListResultDTO(); + public PageData natList(MyNatListFormDTO formDTO) { //1.根据orgType值判断是查询当前组织下还是整个客户下数据 if ("current".equals(formDTO.getOrgType())) { //获取工作人员缓存信息 @@ -134,12 +152,9 @@ public class IcNatServiceImpl extends BaseServiceImpl imp } //2.按条件查询业务数据 - PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()) + PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.isPage()) .doSelectPageInfo(() -> baseDao.getNatList(formDTO)); - resultDTO.setTotal((int) data.getTotal()); - resultDTO.setList(data.getList()); - - return resultDTO; + return new PageData(data.getList(),data.getTotal()); } /** @@ -157,7 +172,11 @@ public class IcNatServiceImpl extends BaseServiceImpl imp resultDTO = ConvertUtils.sourceToTarget(entity, IcNatDTO.class); //2.查询对应的通知记录信息 - //TODO + IcNoticeDTO dto = icNoticeService.getNotice(entity.getCustomerId(), entity.getIdCard()); + if (null != dto) { + resultDTO.setChannel(dto.getChannelList()); + resultDTO.setContent(dto.getContent()); + } return resultDTO; } @@ -167,17 +186,34 @@ public class IcNatServiceImpl extends BaseServiceImpl imp * @Description 【核酸】核酸检测信息修改 **/ @Override + @Transactional(rollbackFor = Exception.class) public void edit(AddIcNatFormDTO formDTO) { //1.更新核酸记录表数据 IcNatEntity entity = ConvertUtils.sourceToTarget(formDTO, IcNatEntity.class); + entity.setId(formDTO.getIcNatId()); if (!updateById(entity)) { - log.error(String.format("数据修改失败,核酸记录Id->", formDTO.getIcNatId())); + log.error(String.format("数据修改失败,核酸记录Id->%s", formDTO.getIcNatId())); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "核酸记录修改失败"); } //3.新增通知表信息 if (formDTO.getChannel().size() > NumConstant.ZERO) { - //TODO + IcNatEntity icNatEntity = baseDao.selectById(formDTO.getIcNatId()); + //1.获取所填居民所属组织缓存信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(icNatEntity.getAgencyId()); + if (null == agencyInfo) { + throw new RenException(String.format("获取组织缓存信息失败%s", icNatEntity.getAgencyId())); + } + SendNoticeFormDTO dto = new SendNoticeFormDTO(); + List userList = new ArrayList<>(); + userList.add(ConvertUtils.sourceToTarget(formDTO, SendNoticeFormDTO.UserListBean.class)); + dto.setCustomerId(formDTO.getCustomerId()); + dto.setUserList(userList); + dto.setChannel(formDTO.getChannel()); + dto.setOrigin("2"); + dto.setContent(formDTO.getContent()); + dto.setOrgName(agencyInfo.getOrganizationName()); + icNoticeService.sendNotice(dto); } } @@ -186,10 +222,11 @@ public class IcNatServiceImpl extends BaseServiceImpl imp * @Description 【核酸】核酸检测信息删除/取消同步 **/ @Override + @Transactional(rollbackFor = Exception.class) public void del(MyNatListFormDTO formDTO) { //1.物理删除业务数据 - if (baseDao.delById(formDTO.getIcNatId())) { - log.error(String.format("数据删除/取消同步失败,核酸记录Id->", formDTO.getIcNatId())); + if (baseDao.delById(formDTO.getIcNatId()) < NumConstant.ONE) { + log.error(String.format("数据删除/取消同步失败,核酸记录Id->%s", formDTO.getIcNatId())); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据操作失败"); } } @@ -199,20 +236,21 @@ public class IcNatServiceImpl extends BaseServiceImpl imp * @Description 【核酸】核酸检测信息同步 **/ @Override + @Transactional(rollbackFor = Exception.class) public void synchro(MyNatListFormDTO formDTO) { + //1.获取工作人员缓存数据 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } //1.根据核酸记录Id查询业务数据并进行必要校验 IcNatEntity entity = baseDao.selectById(formDTO.getIcNatId()); - if (null == entity || formDTO.getAgencyId().equals(entity.getAgencyId()) + if (null == entity || staffInfo.getAgencyId().equals(entity.getAgencyId()) || (!"import".equals(entity.getUserType()) && !"synchro".equals(entity.getUserType()))) { - log.error(String.format("数据同步失败,核酸记录Id->", formDTO.getIcNatId())); + log.error(String.format("数据同步失败,核酸记录Id->%s", formDTO.getIcNatId())); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据同步失败,不是导入数据或非本组织数据"); } - //2.获取工作人员缓存数据 - //获取工作人员缓存信息 - CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); - if (null == staffInfo) { - throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); - } + //3.待同步组织新增业务数据 entity.setId(""); entity.setAgencyId(staffInfo.getAgencyId()); @@ -312,4 +350,4 @@ public class IcNatServiceImpl extends BaseServiceImpl imp public void batchPersist(List entities) { insertBatch(entities); } -} \ No newline at end of file +} 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 9c1d1c4628..64fe1016c2 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 @@ -1,23 +1,39 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; +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.*; +import com.epmet.commons.tools.enums.ChannelEnum; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.SmsTemplateConstant; +import com.epmet.constant.UserMessageTypeConstant; import com.epmet.dao.IcNoticeDao; import com.epmet.dto.IcNoticeDTO; +import com.epmet.dto.form.IcNoticeFormDTO; +import com.epmet.dto.form.ProjectSendMsgFormDTO; +import com.epmet.dto.form.SendNoticeFormDTO; +import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.entity.IcNoticeEntity; +import com.epmet.feign.MessageFeignClient; import com.epmet.service.IcNoticeService; +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.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 防疫通知 @@ -25,16 +41,35 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2022-03-28 */ +@Slf4j @Service public class IcNoticeServiceImpl extends BaseServiceImpl implements IcNoticeService { + @Resource + private MessageFeignClient messageFeignClient; + @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, IcNoticeDTO.class); + public PageData page(IcNoticeFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcNoticeEntity::getCustomerId, formDTO.getCustomerId()); + wrapper.eq(IcNoticeEntity::getIdCard, formDTO.getIdCard()); + wrapper.orderByDesc(IcNoticeEntity::getCreatedTime); + List list = baseDao.selectList(wrapper); + PageInfo pageInfo = new PageInfo<>(list); + List dtoList = ConvertUtils.sourceToTarget(list, IcNoticeDTO.class); + + if (CollectionUtils.isNotEmpty(dtoList)) { + dtoList.forEach(item -> { + List channelList = Arrays.asList(item.getChannel().split(StrConstant.COMMA)); + if (channelList.size() == NumConstant.ONE) { + item.setChannel(ChannelEnum.getName(channelList.get(0))); + } else { + item.setChannel(ChannelEnum.getName(NumConstant.TWO_STR)); + } + }); + } + return new PageData<>(dtoList, pageInfo.getTotal()); } @Override @@ -80,4 +115,91 @@ public class IcNoticeServiceImpl extends BaseServiceImpl entityList = formDTO.getUserList().stream().map(item -> { + IcNoticeEntity entity = new IcNoticeEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setChannel(channel); + entity.setContent(formDTO.getContent()); + entity.setOrigin(formDTO.getOrigin()); + entity.setUserId(item.getUserId()); + entity.setMobile(item.getMobile()); + entity.setIdCard(item.getIdCard()); + entity.setOrgName(formDTO.getOrgName()); + return entity; + }).collect(Collectors.toList()); + insertBatch(entityList); + + //通知 + List msgList = new ArrayList<>(); + //短信消息 + List smsList = new ArrayList<>(); + + entityList.forEach(item -> { + if (StringUtils.isNotBlank(item.getUserId())) { + UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); + messageFormDTO.setCustomerId(item.getCustomerId()); + messageFormDTO.setApp(AppClientConstant.APP_GOV); + messageFormDTO.setGridId(StrConstant.STAR); + messageFormDTO.setUserId(item.getUserId()); + messageFormDTO.setTitle("您有一条通知消息!"); + messageFormDTO.setMessageContent(item.getContent()); + messageFormDTO.setReadFlag(Constant.UNREAD); + messageFormDTO.setMessageType(UserMessageTypeConstant.ANTIEPIDEMIC); + messageFormDTO.setTargetId(item.getId()); + msgList.add(messageFormDTO); + } + //TODO + if (StringUtils.isNotBlank(item.getMobile())) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(item.getCustomerId()); + sms.setMobile(item.getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_OVERDUE); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } + }); + + Result result = messageFeignClient.saveUserMessageList(msgList); + if (!result.success()) { + log.error("发送小程序消息失败" + JSON.toJSONString(result)); + } + } + + /** + * 获取人员最新一条通知 + * + * @param idCard + * @Param idCard + * @Return {@link IcNoticeDTO} + * @Author zhaoqifeng + * @Date 2022/3/28 15:43 + */ + @Override + public IcNoticeDTO getNotice(String customerId, String idCard) { + IcNoticeDTO result = new IcNoticeDTO(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcNoticeEntity::getCustomerId, customerId); + wrapper.eq(IcNoticeEntity::getIdCard, idCard); + wrapper.orderByDesc(IcNoticeEntity::getCreatedTime); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isNotEmpty(list)) { + result = ConvertUtils.sourceToTarget(list.get(NumConstant.ZERO), IcNoticeDTO.class); + result.setChannelList(Arrays.asList(result.getChannel().split(StrConstant.COMMA))); + } + return result; + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_nat.xlsx b/epmet-user/epmet-user-server/src/main/resources/excel/ic_nat.xlsx new file mode 100644 index 0000000000..4d7df5944a Binary files /dev/null and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_nat.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 63c556f0c0..ef7660a3c4 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 @@ -3,6 +3,20 @@ + + + UPDATE ic_epidemic_special_attention + SET UPDATED_TIME = NOW(), + IS_ATTENTION = 0 + WHERE del_flag = 0 + AND attention_type = #{attentionType} + AND id_card IN ( + + #{l} + + ) + + + + + \ 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 b0e8a01607..a16f593941 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 @@ -22,9 +22,10 @@ del_flag = '0' AND customer_id = #{customerId} AND id_card = #{idCard} + ORDER BY nat_time DESC - SELECT id icNatId, agency_id agencyId, @@ -42,7 +43,7 @@ del_flag = '0' AND customer_id = #{customerId} - AND pids like concat('%', #{agencyId}, '%') + AND (agency_id = #{agencyId} OR pids like concat('%', #{agencyId}, '%')) AND name like concat('%', #{name}, '%') @@ -59,10 +60,11 @@ AND nat_time #{endTime} + ORDER BY nat_time, id_card DESC DELETE FROM ic_nat WHERE id = #{icNatId} - \ No newline at end of file +