diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java index 24bce5bff3..11b5c5ce4f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java @@ -161,12 +161,15 @@ public class MaskProcessor { return originString.replaceAll("^(\\d{10})\\d+([a-zA-Z0-9]{2})$", new StringBuilder("$1").append(maskStr).append("$2").toString()); } else if (regexUtil.getTypeEnum() == IdCardTypeEnum.PASSPORT) { // 护照,前两位,后两位为明文,其他* - String maskStr = StrUtil.repeatByLength("*", originString.length() - 4); - return originString.replaceAll("^([a-zA-Z0-9]{2})\\d+(\\d{2})$", new StringBuilder("$1").append(maskStr).append("$2").toString()); - } else { - // 其他情况,不码 - return originString; + int clearLength = 4; + int maskedLength = 0; + if ((maskedLength = originString.length() - clearLength) > 0) { + String maskStr = StrUtil.repeatByLength("*", maskedLength); + return originString.replaceAll("^([a-zA-Z0-9]{2})[a-zA-Z0-9]+([a-zA-Z0-9]{2})$", new StringBuilder("$1").append(maskStr).append("$2").toString()); + } } + + return originString; } /** diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 4c18a3ea55..bb7edb3e2a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -871,5 +871,4 @@ public class RedisKeys { public static String getDhToken() { return rootPrefix.concat("dh:token"); } - } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java index ce92400ae0..220ac403a8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java @@ -2,6 +2,7 @@ package com.epmet.commons.tools.security.user; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.utils.EpmetRequestHolder; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java index d44e9bb3fb..96d7d02a62 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java @@ -25,7 +25,7 @@ public class IdCardRegexUtils { /** * 9位护照 */ - private static final Pattern PATTERN_9_PASSPORT = Pattern.compile("^[a-zA-Z]{2}\\d{7}$|^[a-zA-Z]{1}\\d{8}$"); + private static final Pattern PATTERN_9_PASSPORT = Pattern.compile("^[a-zA-Z0-9]{8,9}$"); private String inputText; @@ -86,7 +86,7 @@ public class IdCardRegexUtils { } } - if (input.length() == 9) { + if (input.length() == 9 || input.length() == 8) { Matcher matcher = PATTERN_9_PASSPORT.matcher(input); if (matcher.matches()) { return new IdCardRegexUtils(IdCardTypeEnum.PASSPORT, matcher, input); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/converter/EasyExcelDateConverter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/converter/EasyExcelDateConverter.java new file mode 100644 index 0000000000..b3c1d207d4 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/converter/EasyExcelDateConverter.java @@ -0,0 +1,51 @@ +package com.epmet.commons.tools.utils.poi.excel.converter; + +/** + * desc: + * + * @author: LiuJanJun + * @date: 2022/8/26 4:59 下午 + * @version: 1.0 + */ + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @Author: liujianjun + * @Date: 2022/7/19 + * @Description: yyyy-MM-dd easyExcel 日期转换 + */ +public class EasyExcelDateConverter implements Converter { + + private static final String PATTERN_YYYY_MM_DD = "yyyy-MM-dd"; + + @Override + public Class supportJavaTypeKey() { + return Converter.super.supportJavaTypeKey(); + } + + @Override + public CellDataTypeEnum supportExcelTypeKey() { + return Converter.super.supportExcelTypeKey(); + } + + @Override + public WriteCellData convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_YYYY_MM_DD); + String dateValue = sdf.format(value); + return new WriteCellData<>(dateValue); + } + + //@Override + //public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + // SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_YYYY_MM_DD); + // return sdf.parse(cellData.getStringValue()); + //} +} \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/UserBaseInfoDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/UserBaseInfoDao.xml index 9ba9386fb3..49dad70cf7 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/UserBaseInfoDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/UserBaseInfoDao.xml @@ -7,13 +7,13 @@ SELECT - CONCAT( STREET, '-', SURNAME, CASE WHEN GENDER = '1' THEN '先生' WHEN GENDER = '2' THEN '女士' ELSE '先生/女士' END ) AS linkName, + CONCAT( SURNAME, CASE WHEN GENDER = '1' THEN '先生' WHEN GENDER = '2' THEN '女士' ELSE '先生/女士' END ) AS linkName, MOBILE AS linkMobile, USER_ID as topicId FROM 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 2108042cd6..58109b1b89 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 @@ -23,6 +23,12 @@ public interface ImportTaskConstants { String BIZ_TYPE_IC_ENTERPRISE="ic_enterprise"; String IC_POINT_NUCLEIC_MONITORING = "ic_point_nucleic_monitoring"; String IC_POINT_VACCINES_INOCULATION = "ic_point_vaccines_inoculation"; + // 新冠病毒疫苗接种人员信息台账 + String IC_VACCINE_PRARMETER = "ic_vaccine_prarmeter"; + /** + * 工作日志导入 + */ + String BIZ_TYPE_WORK_DIARY_IMPORT = "work_diary_import"; /** * 核酸检测 */ @@ -62,4 +68,9 @@ public interface ImportTaskConstants { * 城市管理 */ String IC_CITY_MANAGEMENT = "ic_city_management"; + + /** + * 社会组织 + */ + String IC_SOCIETY_ORG="ic_society_org"; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcSocietyOrgDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcSocietyOrgDTO.java index f0304874e5..8b1d9f8a57 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcSocietyOrgDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcSocietyOrgDTO.java @@ -39,6 +39,11 @@ public class IcSocietyOrgDTO implements Serializable { */ private String id; + /** + * 图片地址 + */ + private String imgUrl; + /** * 客户Id */ @@ -74,6 +79,11 @@ public class IcSocietyOrgDTO implements Serializable { */ private String mobile; + /** + * 服务时间 + */ + private String serviceTimeStr; + /** * 起始服务时间 */ @@ -109,34 +119,5 @@ public class IcSocietyOrgDTO implements Serializable { */ private String remarks; - /** - * 删除标识:0.未删除 1.已删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 创建时间 - */ - private Date createdTime; - - /** - * 更新人 - */ - private String updatedBy; - - /** - * 更新时间 - */ - private Date updatedTime; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/WorkdiaryServiceTypeDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/WorkdiaryServiceTypeDTO.java new file mode 100644 index 0000000000..664465c7ae --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/WorkdiaryServiceTypeDTO.java @@ -0,0 +1,81 @@ +package com.epmet.dto; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.dto.result.WorkdiaryServiceRecordDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Data +public class WorkdiaryServiceTypeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + public interface Save extends CustomerClientShowGroup {} + public interface Update extends CustomerClientShowGroup {} + + /** + * 主键 + */ + @NotBlank(message = "未选中任何数据", groups = { Update.class }) + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 服务类型 + */ + private Short serviceType; + + /** + * 服务类型名称 + */ + private String serviceTypeName; + + /** + * 是否启用。0:禁用,1:启用 + */ + private Short enabled; + + /** + * 删除标识 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-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java index 1217c647c5..a78b42a471 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java @@ -23,7 +23,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotEmpty; import java.io.Serializable; import java.util.Date; @@ -48,6 +48,11 @@ public class AddSocietyOrgFormDTO implements Serializable { * agency_id的所有上级 */ private String pids; + /** + * 社会组织头像 + */ + @NotEmpty(message = "组织头像不能为空", groups = { AddSocietyOrgFormDTO.Add.class}) + private String[] imageList; /** * 社会组织名称 */ @@ -63,7 +68,7 @@ public class AddSocietyOrgFormDTO implements Serializable { /** * 负责人 */ - @NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + //@NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) @Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Add.class}) private String personInCharge; /** @@ -72,22 +77,24 @@ public class AddSocietyOrgFormDTO implements Serializable { @NotBlank(message = "负责人电话不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) @Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Add.class}) private String mobile; + /** + * 服务时间 + */ + @NotBlank(message = "服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + private String serviceTimeStr; /** * 起始服务时间 */ - @NotNull(message = "起始服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date serviceStartTime; /** * 终止服务时间 */ - @NotNull(message = "终止服务时间不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date serviceEndTime; /** * 绑定管理员[组织下录入的工作人员] */ - @NotBlank(message = "绑定管理员名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) private String adminStaffId; /** * 地址 @@ -106,4 +113,4 @@ public class AddSocietyOrgFormDTO implements Serializable { public interface Add extends CustomerClientShowGroup {} -} \ No newline at end of file +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java index 2acad633c0..1e65306066 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java @@ -22,6 +22,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; import java.io.Serializable; import java.util.Date; @@ -40,6 +41,12 @@ public class EditSocietyOrgFormDTO implements Serializable { */ @NotBlank(message = "社会组织Id不能为空", groups = { Edit.class, Del.class }) private String societyId; + + /** + * 社会组织头像 + */ + @NotEmpty(message = "组织头像不能为空", groups = { Edit.class}) + private String[] imageList; /** * 社会组织名称 */ @@ -53,13 +60,19 @@ public class EditSocietyOrgFormDTO implements Serializable { /** * 负责人 */ - @Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Edit.class}) + //@Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Edit.class}) private String personInCharge; /** * 负责人电话 */ @Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Edit.class}) private String mobile; + + /** + * 服务时间 + */ + @NotBlank(message = "服务时间不能为空",groups = {Edit.class}) + private String serviceTimeStr; /** * 起始服务时间 */ @@ -92,4 +105,4 @@ public class EditSocietyOrgFormDTO implements Serializable { public interface Edit {} public interface Del {} -} \ No newline at end of file +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java new file mode 100644 index 0000000000..3d581924a3 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java @@ -0,0 +1,38 @@ +package com.epmet.dto.form.workdiaryservice; + +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.util.Date; + +/** + * 工作日志-服务 + */ +@Data +public class WorkdiaryServiceQueryFormDTO extends PageFormDTO { + + private String id; + private Short serviceType; + private String gridId; + private String applicantName; + private String applicantAddress; + private String serviceContent; + private String applicantMobile; + private String principalName; + + //@DateTimeFormat + //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:sss", timezone = "GMT+8") + //private Date serviceTime; + private String remark; + + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date serviceTimeStart; + + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date serviceTimeEnd; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java index 0130b246a7..08404eff6d 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java @@ -44,6 +44,10 @@ public class GetListSocietyOrgResultDTO implements Serializable { private String agencyId; //社会组织Id private String societyId; + /** + * 社会组织头像 + */ + private String imgUrl; //社会组织名称 private String societyName; //服务事项 @@ -52,6 +56,10 @@ public class GetListSocietyOrgResultDTO implements Serializable { private String personInCharge; //负责人电话 private String mobile; + /** + * 服务时间 + */ + private String serviceTimeStr; //起始服务时间 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date serviceStartTime; diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/SocietyOrgListResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/SocietyOrgListResultDTO.java index 38a081d2bc..2d77374893 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/SocietyOrgListResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/SocietyOrgListResultDTO.java @@ -35,6 +35,10 @@ public class SocietyOrgListResultDTO implements Serializable { private String agencyName; //社会组织Id private String societyId; + /** + * 图像 + */ + private String imgUrl; //社会组织名称 private String societyName; //服务事项 @@ -43,6 +47,10 @@ public class SocietyOrgListResultDTO implements Serializable { private String personInCharge; //负责人电话 private String mobile; + /** + * 服务时间 + */ + private String serviceTimeStr; //起始服务时间 //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") //private Date serviceStartTime; diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java new file mode 100755 index 0000000000..8e75f55c34 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java @@ -0,0 +1,143 @@ +package com.epmet.dto.result; + +import java.io.Serializable; +import java.util.Date; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + + +/** + * 工作日志(服务)-记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Data +public class WorkdiaryServiceRecordDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + public interface Save extends CustomerClientShowGroup {} + public interface Update extends CustomerClientShowGroup {} + + /** + * 主键 + */ + @NotBlank(message = "未选中任何数据", groups = { Update.class }) + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 服务类型 + */ + @NotNull(message = "服务类型为必填项", groups = { Save.class }) + private Short serviceType; + private String serviceTypeName; + + /** + * 单位ID + */ + private String agencyId; + + /** + * 网格ID + */ + @NotBlank(message = "网格为必填项", groups = { Save.class }) + private String gridId; + private String gridName; + + /** + * 组织ID path + */ + private String orgIdPath; + + /** + * 申请人ID + */ + @NotBlank(message = "申请人为必填项", groups = { Save.class }) + private String applicantId; + + private String applicantIdCard; + + /** + * 申请人姓名 + */ + private String applicantName; + + /** + * 申请人住址 + */ + @NotBlank(message = "住址为必填项", groups = { Save.class }) + private String applicantAddress; + + /** + * 申请人联系电话 + */ + @NotBlank(message = "联系电话为必填项", groups = { Save.class }) + private String applicantMobile; + + /** + * 服务内容 + */ + @NotBlank(message = "服务内容为必填项", groups = { Save.class }) + private String serviceContent; + + /** + * 服务时间 + */ + @NotNull(message = "服务时间为必填项", groups = { Save.class }) + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date serviceTime; + + /** + * 负责人姓名 + */ + private String principalName; + + /** + * 备注 + */ + private String remark; + + /** + * 删除标识 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-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java index 2b07959e33..3267ef36bb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java @@ -18,34 +18,55 @@ package com.epmet.controller; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; +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.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ExcelPoiUtils; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dto.IcSocietyOrgDTO; import com.epmet.dto.form.AddSocietyOrgFormDTO; import com.epmet.dto.form.EditSocietyOrgFormDTO; import com.epmet.dto.form.GetListSocietyOrgFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.GetListSocietyOrgResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.IcSocietyOrgExcel; +import com.epmet.excel.IcSocietyOrgExportExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcSocietyOrgService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; import org.springframework.util.CollectionUtils; 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.io.PrintWriter; +import java.net.URLEncoder; +import java.nio.file.Path; import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @@ -58,11 +79,13 @@ import java.util.stream.Collectors; @Slf4j @RestController @RequestMapping("societyorg") -public class IcSocietyOrgController { +public class IcSocietyOrgController implements ResultDataResolver { + private static final String DEFAULT_NO_IMG = "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20220826/38eb186191ab48fe8d3920b642b56e64.png"; @Autowired private IcSocietyOrgService societyOrgService; - + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; /** * @Author sun * @Description 新增社会组织 @@ -87,6 +110,19 @@ public class IcSocietyOrgController { return new Result(); } + /** + * @Author sun + * @Description 删除社会组织 + **/ + @RequestMapping("detail/{id}") + public Result detail(@LoginUser TokenDto tokenDto, @PathVariable(value = "id") String id) { + IcSocietyOrgDTO icSocietyOrgDTO = societyOrgService.get(id); + if (StringUtils.isBlank(icSocietyOrgDTO.getImgUrl())){ + icSocietyOrgDTO.setImgUrl(DEFAULT_NO_IMG); + } + return new Result().ok(icSocietyOrgDTO); + } + /** * @Author sun * @Description 删除社会组织 @@ -129,14 +165,50 @@ public class IcSocietyOrgController { **/ @PostMapping("export") public void export(@LoginUser TokenDto tokenDto, @RequestBody GetListSocietyOrgFormDTO formDTO, HttpServletResponse response) throws Exception { + //废弃原来的导出 + // formDTO.setCustomerId(tokenDto.getCustomerId()); + // formDTO.setStaffId(tokenDto.getUserId()); + // formDTO.setIsPage(false); + // GetListSocietyOrgResultDTO list = societyOrgService.getList(formDTO); + // ExcelUtils.exportExcelToTarget(response, null, list.getList(), IcSocietyOrgExportExcel.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setStaffId(tokenDto.getUserId()); formDTO.setIsPage(false); - GetListSocietyOrgResultDTO list = societyOrgService.getList(formDTO); - ExcelUtils.exportExcelToTarget(response, null, list.getList(), IcSocietyOrgExcel.class); + ExcelWriter excelWriter = null; + formDTO.setPageNo(NumConstant.ONE); + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + try { + String fileName = "社会组织" + DateUtils.format(new Date()) + ".xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcSocietyOrgExportExcel.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + GetListSocietyOrgResultDTO data = null; + List list = null; + do { + data = societyOrgService.getList(formDTO); + list = ConvertUtils.sourceToTarget(data.getList(), IcSocietyOrgExportExcel.class); + formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); + excelWriter.write(list, writeSheet); + } while (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("社会组织export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } } /** + * 废弃此方法用下面的importV2 * @Author sun * @Description 九小场所下组织列表导入 **/ @@ -168,4 +240,83 @@ public class IcSocietyOrgController { return new Result().ok(str); } + + /** + * 下载社会组织导入模板 + * @param response + * @throws IOException + */ + @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("templates/societyorg_import_template.xlsx"); + try { + ServletOutputStream os = response.getOutputStream(); + IOUtils.copy(is, os); + } finally { + if (is != null) { + is.close(); + } + } + } + + /** + * + * @param tokenDto + * @param file + * @return + */ + @PostMapping("importV2") + public Result importExcelV2(@LoginUser TokenDto tokenDto, @RequestPart("file") 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_society_org", "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("【社会组织】导入method 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.IC_SOCIETY_ORG); + importTaskForm.setOriginFileName(originalFilename); + + ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm), + ServiceConstant.EPMET_COMMON_SERVICE, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "excel导入社会组织错误", + "社会组织导入失败"); + + // 3.执行导入 + societyOrgService.execAsyncExcelImport(fileSavePath, rstData.getTaskId(),tokenDto.getCustomerId(),tokenDto.getUserId()); + return new Result(); + } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceController.java new file mode 100755 index 0000000000..230e3617ee --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceController.java @@ -0,0 +1,317 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.PageFormDTO; +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.utils.EpmetRequestHolder; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.FileUtils; +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; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dto.WorkdiaryServiceTypeDTO; +import com.epmet.dto.form.workdiaryservice.WorkdiaryServiceQueryFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.dto.result.WorkdiaryServiceRecordDTO; +import com.epmet.entity.WorkdiaryServiceTypeExcel; +import com.epmet.service.WorkdiaryServiceRecordService; +import com.epmet.service.WorkdiaryServiceTypeService; +import com.epmet.utils.ImportTaskUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +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.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.file.Path; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; + + +/** + * 工作日志(服务) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Slf4j +@RestController +@RequestMapping("workdiaryService") +public class WorkdiaryServiceController implements ResultDataResolver { + + @Autowired + private WorkdiaryServiceRecordService workdiaryServiceRecordService; + + @Autowired + private WorkdiaryServiceTypeService workdiaryServiceTypeService; + + @Autowired + private ExecutorService executorService; + + /** + * 记录-分页 + * @return + */ + @RequestMapping("/record/page") + public Result> recordPage(@RequestBody WorkdiaryServiceQueryFormDTO query){ + String gridId = query.getGridId(); + Short serviceType = query.getServiceType(); + String applicantName = query.getApplicantName(); + String applicantAddress = query.getApplicantAddress(); + String serviceContent = query.getServiceContent(); + String applicantMobile = query.getApplicantMobile(); + Integer pageNo = query.getPageNo(); + Integer pageSize = query.getPageSize(); + Date startTime = query.getServiceTimeStart(); + Date endTime = query.getServiceTimeEnd(); + + PageData page = workdiaryServiceRecordService.page( + gridId, serviceType, applicantName, applicantAddress, serviceContent, applicantMobile, startTime, endTime, pageNo, pageSize); + return new Result>().ok(page); + } + + /** + * 记录-单条 + * @param id + * @return + */ + @RequestMapping(value = "/record/{id}/detail",method = {RequestMethod.POST,RequestMethod.GET}) + public Result recordGet(@PathVariable("id") String id){ + WorkdiaryServiceRecordDTO data = workdiaryServiceRecordService.get(id); + return new Result().ok(data); + } + + /** + * 记录-保存 + * @return + */ + @NoRepeatSubmit + @PostMapping("/record/save") + public Result recordSave(@RequestBody WorkdiaryServiceRecordDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, WorkdiaryServiceRecordDTO.Save.class); + workdiaryServiceRecordService.save(dto); + return new Result(); + } + + /** + * 记录-更新 + * @param + * @return + */ + @NoRepeatSubmit + @PostMapping("/record/update") + public Result recordUpdate(@RequestBody WorkdiaryServiceRecordDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, WorkdiaryServiceRecordDTO.Update.class); + workdiaryServiceRecordService.update(dto); + return new Result(); + } + + /** + * 记录-删除 + * @return + */ + @PostMapping("/record/delete") + public Result recordDelete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + workdiaryServiceRecordService.delete(ids); + return new Result(); + } + + /** + * 记录-导出 + * @return + */ + @PostMapping("/record/export") + public void recordExport(@RequestBody WorkdiaryServiceQueryFormDTO query, HttpServletResponse response) throws Exception { + String gridId = query.getGridId(); + Short serviceType = query.getServiceType(); + String applicantName = query.getApplicantName(); + String applicantAddress = query.getApplicantAddress(); + String serviceContent = query.getServiceContent(); + String applicantMobile = query.getApplicantMobile(); + Date serviceTimeStart = query.getServiceTimeStart(); + Date serviceTimeEnd = query.getServiceTimeEnd(); + + workdiaryServiceRecordService.export(gridId, serviceType, applicantName, applicantAddress, serviceContent, + applicantMobile, serviceTimeStart, serviceTimeEnd, response); + } + + /** + * 下载模板 + * @return + */ + @RequestMapping("/record/downloadTemplate") + public void downloadTemplate(HttpServletResponse response) throws UnsupportedEncodingException { + 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"); + + try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("templates/workdiary_service_import.xlsx"); + ServletOutputStream os = response.getOutputStream()) { + IOUtils.copy(is, os); + } catch (IOException e) { + log.error("【工作日志】下载模板-IO错误:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + + /** + * 记录导入 + * @param file + */ + @PostMapping("/record/import") + public Result recordImport(MultipartFile file) { + + if (file == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "请选择文件"); + } + + // 格式校验 + // 只接受如下两种格式后缀 + String originFileName = file.getOriginalFilename(); + String suffix = originFileName.substring(originFileName.lastIndexOf(".")); + if (StringUtils.isBlank(suffix) || (!".xlsx".equals(suffix) && !".xls".equals(suffix))) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "只支持.xls和.xlsx两种格式"); + } + + // 创建保存目录 + Path fileSavePath = null; + try { + Path saveDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("workdiary", "import", EpmetRequestHolder.getLoginUserId()); + fileSavePath = saveDir.resolve(System.currentTimeMillis() + suffix); + } catch (IOException e) { + e.printStackTrace(); + } + + // 将文件保存到本地 + try (FileOutputStream fos = new FileOutputStream(fileSavePath.toString()); + InputStream is = file.getInputStream()) { + IOUtils.copy(is, fos); + } catch (Exception e) { + log.error("【书记日志】上传-保存文件到本地失败:{}", ExceptionUtils.getErrorStackTrace(e)); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + // 创建导入记录 + ImportTaskCommonResultDTO itResult = getResultDataOrThrowsException(ImportTaskUtils.createImportTask(originFileName, ImportTaskConstants.BIZ_TYPE_WORK_DIARY_IMPORT), + ServiceConstant.EPMET_COMMON_SERVICE, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "有导入操作正在进行", "有导入操作正在进行"); + + // 执行异步导入 + Path finalFileSavePath = fileSavePath; + CompletableFuture.runAsync(() -> { + workdiaryServiceRecordService.createImportTaskAndExecuteImport(finalFileSavePath, originFileName, itResult.getTaskId()); + }, executorService); + + return new Result(); + } + + /** + * 服务类型-分页 + * @return + */ + @RequestMapping("/serviceType/page") + public Result> serviceTypePage(@RequestBody PageFormDTO input){ + PageData page = workdiaryServiceTypeService.page(null, input.getPageNo(), input.getPageSize()); + return new Result>().ok(page); + } + + /** + * 列出启用了的类型列表 + * @param input + * @return + */ + @RequestMapping("/serviceType/avaliableList") + public Result> listAvaliableServiceType(@RequestBody PageFormDTO input){ + PageData page = workdiaryServiceTypeService.listAvaliableServiceType(input.getPageNo(), input.getPageSize()); + return new Result>().ok(page); + } + + /** + * 服务类型-单条 + * @return + */ + @RequestMapping(value = "/serviceType/{id}/detail",method = {RequestMethod.POST,RequestMethod.GET}) + public Result serviceTypeGet(@PathVariable("id") String id){ + WorkdiaryServiceTypeDTO data = workdiaryServiceTypeService.get(id); + return new Result().ok(data); + } + + /** + * 服务类型-保存 + * @return + */ + @NoRepeatSubmit + @PostMapping("/serviceType/save") + public Result serviceTypeSave(@RequestBody WorkdiaryServiceTypeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, WorkdiaryServiceTypeDTO.Save.class); + workdiaryServiceTypeService.save(dto); + return new Result(); + } + + /** + * 服务类型-更新 + * @return + */ + @NoRepeatSubmit + @PostMapping("/serviceType/update") + public Result serviceTypeUpdate(@RequestBody WorkdiaryServiceTypeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, WorkdiaryServiceTypeDTO.Update.class); + workdiaryServiceTypeService.update(dto); + return new Result(); + } + + /** + * 服务类型-删除 + * @return + */ + @PostMapping("/serviceType/delete") + public Result serviceTypeDelete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + int failCount = workdiaryServiceTypeService.delete(ids); + if (failCount == 0) { + return new Result(); + } else { + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "部分条目已经被使用,未完全删除,失败条目:" + failCount); + } + } + + /** + * 服务类型-导出 + * @return + */ + @GetMapping("/serviceType/export") + public void serviceTypeExport(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = workdiaryServiceTypeService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, WorkdiaryServiceTypeExcel.class); + } + + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java index 0e78731571..5580421547 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java @@ -59,4 +59,8 @@ public interface IcSocietyOrgDao extends BaseDao { * @Description 查询当前组织下的社会组织数据 **/ List getByAgencyId(@Param("agencyId") String agencyId); + + List selectListForUniqueName(@Param("agencyId") String agencyId, + @Param("societyName") String societyName, + @Param("id") String id); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceRecordDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceRecordDao.java new file mode 100755 index 0000000000..5f33762fb8 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceRecordDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.WorkdiaryServiceRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工作日志(服务)-记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Mapper +public interface WorkdiaryServiceRecordDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java new file mode 100755 index 0000000000..5997be4147 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java @@ -0,0 +1,23 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.WorkdiaryServiceTypeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Mapper +public interface WorkdiaryServiceTypeDao extends BaseDao { + + /** + * 该客户最大的type是啥 + * @param customerId + * @return + */ + Short getMaxType(@Param("customerId") String customerId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcSocietyOrgEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcSocietyOrgEntity.java index 7c6dcc0316..f97113dd58 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcSocietyOrgEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcSocietyOrgEntity.java @@ -73,6 +73,11 @@ public class IcSocietyOrgEntity extends BaseEpmetEntity { private String mobile; /** + * 服务时间 + */ + private String serviceTimeStr; + + /** * 起始服务时间 */ private Date serviceStartTime; @@ -87,6 +92,10 @@ public class IcSocietyOrgEntity extends BaseEpmetEntity { */ private String adminStaffId; + /** + * 图片地址 + */ + private String imgUrl; /** * 地址 */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java new file mode 100755 index 0000000000..a72064b8cd --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java @@ -0,0 +1,98 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 工作日志(服务)-记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("workdiary_service_record") +@NoArgsConstructor +@AllArgsConstructor +public class WorkdiaryServiceRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 服务类型 + */ + private Short serviceType; + + /** + * 单位ID + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 组织ID path + */ + private String orgIdPath; + + /** + * 申请人ID + */ + private String applicantId; + + /** + * 证件号 + */ + private String applicantIdCard; + + /** + * 申请人姓名 + */ + private String applicantName; + + /** + * 申请人住址 + */ + private String applicantAddress; + + /** + * 申请人联系电话 + */ + private String applicantMobile; + + /** + * 服务内容 + */ + private String serviceContent; + + /** + * 服务时间 + */ + private Date serviceTime; + + /** + * 负责人姓名 + */ + private String principalName; + + /** + * 备注 + */ + private String remark; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java new file mode 100755 index 0000000000..868fb4e001 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java @@ -0,0 +1,44 @@ +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; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("workdiary_service_type") +public class WorkdiaryServiceTypeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 服务类型 + */ + private Short serviceType; + + /** + * 服务类型名称 + */ + private String serviceTypeName; + + /** + * 是否启用。0:禁用,1:启用 + */ + private Short enabled; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeExcel.java new file mode 100755 index 0000000000..a8c3340c73 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeExcel.java @@ -0,0 +1,51 @@ +package com.epmet.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Data +public class WorkdiaryServiceTypeExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "客户id") + private String customerId; + + @Excel(name = "服务类型") + private String serviceType; + + @Excel(name = "服务类型名称") + private String serviceName; + + @Excel(name = "是否启用。0:禁用,1:启用") + private Integer enabled; + + @Excel(name = "删除标识 0.未删除 1.已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExcel.java index c4392b5e5a..e48c6cb6d6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExcel.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExcel.java @@ -34,37 +34,28 @@ import java.io.Serializable; @Data public class IcSocietyOrgExcel extends ExcelVerifyInfo implements Serializable { - @Excel(name = "组织名称") + @Excel(name = "所属组织") @NotBlank(message = "不能为空") private String agencyName; - @Excel(name = "社会组织名称") + @Excel(name = "组织名称") @NotBlank(message = "不能为空") @Length(max=50,message = "不能超过50个字") private String societyName; - @Excel(name = "服务事项") + @Excel(name = "服务内容") @NotBlank(message = "不能为空") @Length(max=1000,message = "不能超过1000个字") private String serviceMatters; - @Excel(name = "负责人") - @NotBlank(message = "不能为空") - @Length(max=20,message = "不能超过20个字") - private String personInCharge; - - @Excel(name = "负责人电话") + @Excel(name = "服务电话") @NotBlank(message = "不能为空") @Length(max=11,message = "不能超过11个字") private String mobile; - @Excel(name = "起始服务时间") + @Excel(name = "服务时间") @NotBlank(message = "不能为空") - private String serviceStartTime; - - @Excel(name = "终止服务时间") - @NotBlank(message = "不能为空") - private String serviceEndTime; + private String serviceTimeStr; @Excel(name = "管理员姓名") private String adminStaffName; @@ -72,10 +63,4 @@ public class IcSocietyOrgExcel extends ExcelVerifyInfo implements Serializable { @Excel(name = "地址") private String address; - @Excel(name = "经度") - private String longitude; - - @Excel(name = "维度") - private String latitude; - } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExportExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExportExcel.java new file mode 100644 index 0000000000..5f0c8bdb79 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgExportExcel.java @@ -0,0 +1,42 @@ +package com.epmet.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/8/24 8:41 + */ +@Data +public class IcSocietyOrgExportExcel { + @ExcelProperty(value = "所属组织") + @ColumnWidth(30) + private String agencyName; + + @ExcelProperty(value = "组织名称") + @ColumnWidth(30) + private String societyName; + + @ColumnWidth(50) + @ExcelProperty(value = "服务内容") + private String serviceMatters; + + @ColumnWidth(20) + @ExcelProperty(value = "服务电话") + private String mobile; + + @ColumnWidth(20) + @ExcelProperty(value = "服务时间") + private String serviceTimeStr; + + @ColumnWidth(20) + @ExcelProperty(value = "管理员姓名") + private String adminStaffName; + + /*@ColumnWidth(30) + @ExcelProperty(value = "地址") + private String address;*/ +} + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgImportExcelDTO.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgImportExcelDTO.java new file mode 100644 index 0000000000..bc14e774a0 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcSocietyOrgImportExcelDTO.java @@ -0,0 +1,74 @@ +package com.epmet.excel; + +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; + +/** + * @Description + * @Author yzm + * @Date 2022/8/24 10:46 + */ +@Data +public class IcSocietyOrgImportExcelDTO { + + @ExcelProperty(value = "组织名称") + @NotBlank(message = "组织名称不能为空") + @Length(max=50,message = "组织名称不能超过50个字") + private String societyName; + + @ExcelProperty(value = "服务内容") + @NotBlank(message = "服务内容不能为空") + @Length(max=1000,message = "服务内容不能超过1000个字") + private String serviceMatters; + + @ExcelProperty(value = "服务电话") + @NotBlank(message = "服务电话不能为空") + private String mobile; + + @ExcelProperty(value = "服务时间") + @NotBlank(message = "服务时间不能为空") + private String serviceTimeStr; + + @ExcelProperty(value = "管理员姓名") + private String adminStaffName; + + @ExcelProperty(value = "地址") + private String address; + + @Data + public static class ErrorRow { + + @ColumnWidth(40) + @ExcelProperty(value = "组织名称") + private String societyName; + + @ColumnWidth(50) + @ExcelProperty(value = "服务内容") + private String serviceMatters; + + @ColumnWidth(20) + @ExcelProperty(value = "服务电话") + private String mobile; + + @ColumnWidth(25) + @ExcelProperty(value = "服务时间") + private String serviceTimeStr; + + @ColumnWidth(20) + @ExcelProperty(value = "管理员姓名") + private String adminStaffName; + + @ColumnWidth(50) + @ExcelProperty(value = "地址") + private String address; + + @ColumnWidth(60) + @ExcelProperty("错误信息") + private String errorInfo; + } +} + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/WorkdiaryServiceRecordExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/WorkdiaryServiceRecordExcel.java new file mode 100755 index 0000000000..13a9afdfdd --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/WorkdiaryServiceRecordExcel.java @@ -0,0 +1,79 @@ +package com.epmet.excel; + +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.format.DateTimeFormat; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.poi.excel.converter.EasyExcelDateConverter; +import com.epmet.dto.result.WorkdiaryServiceRecordDTO; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * 工作日志(服务)-记录 excel + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Data +@NoArgsConstructor +public class WorkdiaryServiceRecordExcel { + + @NotBlank(message = "所属网格必填") + @ColumnWidth(25) + @ExcelProperty(value = "所属网格") + private String gridName; + + @NotBlank(message = "服务类型必填") + @ColumnWidth(15) + @ExcelProperty(value = "服务类型") + private String serviceTypeName; + + @NotBlank(message = "申请人必填") + @ColumnWidth(10) + @ExcelProperty(value = "申请人") + private String applicantName; + + @ColumnWidth(10) + @ExcelProperty(value = "证件号") + private String applicantIdCard; + + @ColumnWidth(25) + @ExcelProperty(value = "住址") + private String applicantAddress; + + @NotBlank(message = "服务内容必填") + @ColumnWidth(25) + @ExcelProperty(value = "服务内容") + private String serviceContent; + + @ColumnWidth(15) + @ExcelProperty(value = "联系电话") + private String applicantMobile; + + @ColumnWidth(10) + @ExcelProperty(value = "负责人") + private String principalName; + + @NotNull(message = "服务时间必填") + @ColumnWidth(20) + @ExcelProperty(value = "服务时间") + //@DateTimeFormat("yyyy-MM-dd") + //@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private String serviceTime; + + @ColumnWidth(20) + @ExcelProperty(value = "备注") + private String remark; + + public WorkdiaryServiceRecordExcel(WorkdiaryServiceRecordDTO dto) { + BeanUtil.copyProperties(dto, this); + this.serviceTime = DateUtils.format(dto.getServiceTime()); + } +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/handler/IcSocietyOrgExcelImportListener.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/handler/IcSocietyOrgExcelImportListener.java new file mode 100644 index 0000000000..54b23d8fd2 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/handler/IcSocietyOrgExcelImportListener.java @@ -0,0 +1,157 @@ +package com.epmet.excel.handler; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +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.exception.ValidateException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.ObjectUtil; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.entity.IcSocietyOrgEntity; +import com.epmet.excel.IcSocietyOrgImportExcelDTO; +import com.epmet.service.impl.IcSocietyOrgServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description + * @Author yzm + * @Date 2022/8/24 11:42 + */ +@Slf4j +public class IcSocietyOrgExcelImportListener implements ReadListener { + // 最大条数阈值 + public static final int MAX_THRESHOLD = 2; + private String currentCustomerId; + /** + * 当前操作用户 + */ + private CustomerStaffInfoCacheResult staffInfo; + private IcSocietyOrgServiceImpl icSocietyOrgService; + private List errorRows = new ArrayList<>(); + /** + * 要插入的数据 + */ + private List insertDatas = new ArrayList<>(); + /** + * 根据组织名称更新的数据 + */ + private List updateDatas = new ArrayList<>(); + private Map staffMap=new HashMap<>(); + public IcSocietyOrgExcelImportListener(String customerId, CustomerStaffInfoCacheResult staffInfo, IcSocietyOrgServiceImpl icSocietyOrgService, Map staffMap) { + this.currentCustomerId = customerId; + this.staffInfo = staffInfo; + this.icSocietyOrgService = icSocietyOrgService; + this.staffMap=staffMap; + } + + @Override + public void invoke(IcSocietyOrgImportExcelDTO data, AnalysisContext analysisContext) { + try { + // log.warn("有数据吗?"+JSON.toJSONString(data)); + // 不能为空先校验数据 + ValidatorUtils.validateEntity(data); + // 去除空格 + ObjectUtil.objectToTrim(data); + IcSocietyOrgEntity icSocietyOrgEntity = ConvertUtils.sourceToTarget(data, IcSocietyOrgEntity.class); + icSocietyOrgEntity.setCustomerId(currentCustomerId); + icSocietyOrgEntity.setAgencyId(staffInfo.getAgencyId()); + icSocietyOrgEntity.setPids(staffInfo.getAgencyPIds()); + if(StringUtils.isNotBlank(data.getAdminStaffName())){ + String adminStaffId = null; + for(String key:staffMap.keySet()){ + if (data.getAdminStaffName().equals(staffMap.get(key))) { + adminStaffId=key; + break; + } + } + if (StringUtils.isBlank(adminStaffId)) { + String msg = String.format("当前组织下没有【%s】", data.getAdminStaffName()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + } + icSocietyOrgEntity.setAdminStaffId(adminStaffId); + } + //网格id+场所名称 + List originList = icSocietyOrgService.selectForUniqueName(icSocietyOrgEntity.getAgencyId(), icSocietyOrgEntity.getSocietyName(), null); + if(CollectionUtils.isEmpty(originList)){ + insertDatas.add(icSocietyOrgEntity); + }else{ + IcSocietyOrgEntity origin=originList.get(NumConstant.ZERO); + icSocietyOrgEntity.setId(origin.getId()); + updateDatas.add(icSocietyOrgEntity); + } + + + if (insertDatas.size() == MAX_THRESHOLD) { + execPersist(); + } + if (updateDatas.size() == MAX_THRESHOLD) { + execPersist(); + } + } catch (Exception e) { + String errorMsg = null; + if (e instanceof ValidateException) { + errorMsg = ((ValidateException) e).getMsg(); + }else if(e instanceof EpmetException){ + errorMsg = ((EpmetException) e).getMsg(); + }else { + errorMsg = "未知错误"; + log.error("【社会组织导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); + } + IcSocietyOrgImportExcelDTO.ErrorRow errorRow = new IcSocietyOrgImportExcelDTO.ErrorRow(); + errorRow.setSocietyName(data.getSocietyName()); + errorRow.setServiceMatters(data.getServiceMatters()); + errorRow.setMobile(data.getMobile()); + errorRow.setServiceTimeStr(data.getServiceTimeStr()); + errorRow.setAdminStaffName(data.getAdminStaffName()); + errorRow.setAddress(data.getAddress()); + errorRow.setErrorInfo(errorMsg); + errorRows.add(errorRow); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + log.info("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"); + // 最后几条达不到阈值,这里必须再调用一次 + execPersist(); + } + + /** + * 执行持久化 + */ + private void execPersist() { + try { + if (CollectionUtils.isNotEmpty(insertDatas)) { + icSocietyOrgService.insertBatch(insertDatas); + } + + if (CollectionUtils.isNotEmpty(updateDatas)) { + icSocietyOrgService.updateBatchById(updateDatas); + } + } finally { + insertDatas.clear(); + updateDatas.clear(); + } + } + + /** + * 获取错误行 + * + * @return + */ + public List getErrorRows() { + return errorRows; + } +} + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/listener/WorkdiaryServiceImportListener.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/listener/WorkdiaryServiceImportListener.java new file mode 100644 index 0000000000..0f98babccc --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/listener/WorkdiaryServiceImportListener.java @@ -0,0 +1,54 @@ +package com.epmet.excel.listener; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.excel.WorkdiaryServiceRecordExcel; +import com.epmet.service.WorkdiaryServiceRecordService; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.List; + +/** + * 工作日志-导入-监听器 + */ +@Slf4j +public class WorkdiaryServiceImportListener extends AnalysisEventListener { + + /** + * 200 一批执行导入 + */ + public static final Integer BATCH_SIZE = 200; + + /** + * 数据列表 + */ + private List datas = new ArrayList<>(); + + private WorkdiaryServiceRecordService workdiaryServiceRecordService; + + public WorkdiaryServiceImportListener(WorkdiaryServiceRecordService workdiaryServiceRecordService) { + this.workdiaryServiceRecordService = workdiaryServiceRecordService; + } + + @Override + public void invoke(WorkdiaryServiceRecordExcel data, AnalysisContext context) { + datas.add(data); + if (datas.size() >= BATCH_SIZE) { + // 达到批量阈值,执行一次导入 + try { + workdiaryServiceRecordService.executeBatchImport(datas); + } catch (Exception e) { + log.error("【工作日志】导入-发生未知错误:{}", ExceptionUtils.getErrorStackTrace(e)); + } finally { + datas.clear(); + } + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + workdiaryServiceRecordService.executeBatchImport(datas); + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/redis/WorkdiaryServiceRecordRedis.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/redis/WorkdiaryServiceRecordRedis.java new file mode 100755 index 0000000000..bb15d79a6a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/redis/WorkdiaryServiceRecordRedis.java @@ -0,0 +1,30 @@ +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 工作日志(服务)-记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Component +public class WorkdiaryServiceRecordRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/redis/WorkdiaryServiceTypeRedis.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/redis/WorkdiaryServiceTypeRedis.java new file mode 100755 index 0000000000..bf4dc2ffc1 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/redis/WorkdiaryServiceTypeRedis.java @@ -0,0 +1,30 @@ +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Component +public class WorkdiaryServiceTypeRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcSocietyOrgService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcSocietyOrgService.java index 747ff6f14b..8685acaeef 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcSocietyOrgService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcSocietyOrgService.java @@ -28,6 +28,7 @@ import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcSocietyOrgEntity; import com.epmet.excel.IcSocietyOrgExcel; +import java.nio.file.Path; import java.text.ParseException; import java.util.List; @@ -79,4 +80,13 @@ public interface IcSocietyOrgService extends BaseService { List queryListById(List socialOrgIds); IcSocietyOrgDTO get(String id); + + /** + * 导入社会组织,之前的废弃了 + * @param fileSavePath + * @param taskId + * @param customerId + * @param userId + */ + void execAsyncExcelImport(Path fileSavePath, String taskId, String customerId, String userId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java new file mode 100755 index 0000000000..f574f47f17 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java @@ -0,0 +1,96 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.workdiaryservice.WorkdiaryServiceQueryFormDTO; +import com.epmet.dto.result.WorkdiaryServiceRecordDTO; +import com.epmet.entity.WorkdiaryServiceRecordEntity; +import com.epmet.excel.WorkdiaryServiceRecordExcel; + +import javax.servlet.http.HttpServletResponse; +import java.nio.file.Path; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 工作日志(服务)-记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +public interface WorkdiaryServiceRecordService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-08-23 + */ + PageData page(Map params); + + PageData page(String gridId, Short serviceType, String applicantName, String applicantAddress, + String serviceContent, String applicantMobile, Date serviceTimeStart, Date serviceTimeEnd, + Integer pageNo, Integer pageSize); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-08-23 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return WorkdiaryServiceRecordDTO + * @author generator + * @date 2022-08-23 + */ + WorkdiaryServiceRecordDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-08-23 + */ + void save(WorkdiaryServiceRecordDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-08-23 + */ + void update(WorkdiaryServiceRecordDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-08-23 + */ + void delete(String[] ids); + + void export(String gridId, Short serviceType, String applicantName, String applicantAddress, + String serviceContent, String applicantMobile, Date serviceTimeStart, Date serviceTimeEnd, HttpServletResponse response); + + Integer selectRecordCountOfType(Short serviceType); + + void createImportTaskAndExecuteImport(Path fileSavePath, String originFileName, String taskId); + + void executeBatchImport(List datas); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java new file mode 100755 index 0000000000..255b1db312 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java @@ -0,0 +1,81 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.WorkdiaryServiceTypeDTO; +import com.epmet.entity.WorkdiaryServiceTypeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +public interface WorkdiaryServiceTypeService extends BaseService { + + /** + * 默认分页 + * + * @return PageData + * @author generator + * @date 2022-08-23 + */ + PageData page(Short enabled, Integer pageNo, Integer pageSize); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-08-23 + */ + List list(Map params); + + List list(Short enabled, Integer pageNo, Integer pageSize); + + /** + * 单条查询 + * + * @param id + * @return WorkdiaryServiceTypeDTO + * @author generator + * @date 2022-08-23 + */ + WorkdiaryServiceTypeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-08-23 + */ + void save(WorkdiaryServiceTypeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-08-23 + */ + void update(WorkdiaryServiceTypeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-08-23 + */ + int delete(String[] ids); + + PageData listAvaliableServiceType(Integer pageNo, Integer pageSize); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java index 6542740821..063064f9cd 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java @@ -17,42 +17,58 @@ package com.epmet.service.impl; +import com.alibaba.excel.EasyExcel; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.FileUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.UserDemandConstant; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcSocietyOrgDao; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.IcSocietyOrgDTO; import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; -import com.epmet.dto.result.GetListSocietyOrgResultDTO; -import com.epmet.dto.result.OrgInfoResultDTO; -import com.epmet.dto.result.SocietyOrgListResultDTO; -import com.epmet.dto.result.StaffSinGridResultDTO; +import com.epmet.dto.result.*; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcSocietyOrgEntity; import com.epmet.excel.IcSocietyOrgExcel; +import com.epmet.excel.IcSocietyOrgImportExcelDTO; +import com.epmet.excel.handler.IcSocietyOrgExcelImportListener; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.service.IcSocietyOrgService; import com.epmet.service.IcUserDemandRecService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +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.text.ParseException; -import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -71,6 +87,10 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl%s", formDTO.getSocietyId())); } entity = ConvertUtils.sourceToTarget(formDTO, IcSocietyOrgEntity.class); + //图片必填 + if(formDTO.getImageList() != null && StringUtils.isNotBlank(formDTO.getImageList()[0])){ + entity.setImgUrl(formDTO.getImageList()[0]); + } entity.setId(formDTO.getSocietyId()); baseDao.updateById(entity); } @@ -115,14 +143,17 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl result = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> baseDao.getList(formDTO)); @@ -134,14 +165,16 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl pointMap = icUserDemandRecService.getServicePoint(formDTO.getCustomerId(), UserDemandConstant.SOCIAL_ORG); //2.查询被绑定管理员信息 UserIdsFormDTO dto = new UserIdsFormDTO(); - List staffIdList = result.getList().stream().map(SocietyOrgListResultDTO::getAdminStaffId).collect(Collectors.toList()); - staffIdList = staffIdList.stream().distinct().collect(Collectors.toList()); - dto.setUserIds(staffIdList); - Result> listResult = epmetUserOpenFeignClient.getStaffInfoList(dto); - if (!listResult.success()) { - throw new RenException("获取工作人员基本信息失败......"); + List staffIdList = result.getList().stream().filter(u->StringUtils.isNotBlank(u.getAdminStaffId())).map(SocietyOrgListResultDTO::getAdminStaffId).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(staffIdList)){ + staffIdList = staffIdList.stream().distinct().collect(Collectors.toList()); + dto.setUserIds(staffIdList); + Result> listResult = epmetUserOpenFeignClient.getStaffInfoList(dto); + if (!listResult.success()) { + throw new RenException("获取工作人员基本信息失败......"); + } + result.getList().stream().filter(f->StringUtils.isNotBlank(f.getAdminStaffId())).forEach(r -> listResult.getData().stream().filter(u -> r.getAdminStaffId().equals(u.getStaffId())).forEach(u -> r.setAdminStaffName(u.getStaffName()))); } - result.getList().forEach(r -> listResult.getData().stream().filter(u -> r.getAdminStaffId().equals(u.getStaffId())).forEach(u -> r.setAdminStaffName(u.getStaffName()))); //3.查询被绑定管理员信息 OrgInfoFormDTO org = new OrgInfoFormDTO(); @@ -221,53 +254,59 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl map=new HashMap<>(); //2.查询绑定的管理员信息 - Set staffNames = list.stream().map(item -> item.getAdminStaffName().trim()).collect(Collectors.toSet()); - GetByRealNamesFormDTO dto = new GetByRealNamesFormDTO(); - dto.setCustomerId(customerId); - dto.setRealNames(staffNames); - Result> staffResult = epmetUserOpenFeignClient.getByRealNames(dto); - if (!staffResult.success()) { - throw new RenException("获取工作人员基础信息失败......"); - } - if (null == staffResult.getData()) { - Iterator iter = list.iterator(); - while (iter.hasNext()) { - IcSocietyOrgExcel obj = iter.next(); - numList.add(obj.getRowNum()); - iterator.remove(); + Set staffNames = list.stream().filter(t -> StringUtils.isNotBlank(t.getAdminStaffName())).map(item -> item.getAdminStaffName().trim()).collect(Collectors.toSet()); + if(!CollectionUtils.isEmpty(staffNames)){ + GetByRealNamesFormDTO dto = new GetByRealNamesFormDTO(); + dto.setCustomerId(customerId); + dto.setRealNames(staffNames); + Result> staffResult = epmetUserOpenFeignClient.getByRealNames(dto); + if (!staffResult.success()) { + throw new RenException("获取工作人员基础信息失败......"); } - return numList; + if (null == staffResult.getData()) { + Iterator iter = list.iterator(); + while (iter.hasNext()) { + IcSocietyOrgExcel obj = iter.next(); + numList.add(obj.getRowNum()); + iterator.remove(); + } + return numList; + } + map= staffResult.getData().stream().collect(Collectors.toMap(CustomerStaffDTO::getRealName, CustomerStaffDTO::getUserId)); } - Map map = staffResult.getData().stream().collect(Collectors.toMap(CustomerStaffDTO::getRealName, CustomerStaffDTO::getUserId)); //3.遍历封装有效数据 List houseEntityList = new ArrayList<>(); Iterator iterator1 = list.iterator(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); while (iterator1.hasNext()) { - IcSocietyOrgExcel icHouseExcel = iterator1.next(); + IcSocietyOrgExcel icSocietyOrgExcel = iterator1.next(); IcSocietyOrgEntity entity = new IcSocietyOrgEntity(); entity.setCustomerId(customerId); entity.setAgencyId(staffInfoCache.getAgencyId()); entity.setPids(staffInfoCache.getAgencyPIds()); - entity.setSocietyName(icHouseExcel.getSocietyName()); - entity.setServiceMatters(icHouseExcel.getServiceMatters()); - entity.setPersonInCharge(icHouseExcel.getPersonInCharge()); - entity.setMobile(icHouseExcel.getMobile()); - entity.setServiceStartTime(sdf.parse(icHouseExcel.getServiceStartTime())); - entity.setServiceEndTime(sdf.parse(icHouseExcel.getServiceEndTime())); - entity.setAdminStaffId(map.containsKey(icHouseExcel.getAdminStaffName().trim()) ? map.get(icHouseExcel.getAdminStaffName().trim()) : ""); - if ("".equals(entity.getAdminStaffId())) { - numList.add(icHouseExcel.getRowNum()); - log.warn(String.format("绑定的管理员不存在,管理员名称->%s,行号->%s", icHouseExcel.getAdminStaffName(), icHouseExcel.getRowNum())); + entity.setSocietyName(icSocietyOrgExcel.getSocietyName()); + entity.setServiceMatters(icSocietyOrgExcel.getServiceMatters()); + //负责人去掉 + // entity.setPersonInCharge(icSocietyOrgExcel.getPersonInCharge()); + entity.setMobile(icSocietyOrgExcel.getMobile()); + //服务时间手动输入 + entity.setServiceTimeStr(icSocietyOrgExcel.getServiceTimeStr()); + // entity.setServiceStartTime(sdf.parse(icHouseExcel.getServiceStartTime())); + // entity.setServiceEndTime(sdf.parse(icHouseExcel.getServiceEndTime())); + entity.setAdminStaffId(MapUtils.isNotEmpty(map)&&map.containsKey(icSocietyOrgExcel.getAdminStaffName().trim()) ? map.get(icSocietyOrgExcel.getAdminStaffName().trim()) : ""); + if (StringUtils.isBlank(entity.getAdminStaffId())) { + numList.add(icSocietyOrgExcel.getRowNum()); + log.warn(String.format("绑定的管理员不存在,管理员名称->%s,行号->%s", icSocietyOrgExcel.getAdminStaffName(), icSocietyOrgExcel.getRowNum())); iterator1.remove(); continue; } - entity.setAddress(icHouseExcel.getAddress()); - entity.setLongitude(icHouseExcel.getLongitude()); - entity.setLatitude(icHouseExcel.getLatitude()); + entity.setAddress(icSocietyOrgExcel.getAddress()); + //经纬度不能导入 + // entity.setLongitude(icHouseExcel.getLongitude()); + // entity.setLatitude(icHouseExcel.getLatitude()); houseEntityList.add(entity); } @@ -291,4 +330,115 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl> staffIdsRes=govOrgOpenFeignClient.getAgencyStaffs(agencyIdFormDTO); + if (!staffIdsRes.success() || CollectionUtils.isEmpty(staffIdsRes.getData())) { + String msg = "查询当前组织下工作人员列表异常"; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + } + Result currentAgencyStaffs=epmetUserOpenFeignClient.getCustomerStaffList(staffIdsRes.getData()); + if (!currentAgencyStaffs.success() || null == currentAgencyStaffs.getData() || CollectionUtils.isEmpty(currentAgencyStaffs.getData().getStaffList())) { + String msg = "查询当前组织下工作人员信息异常"; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + } + List staffList=currentAgencyStaffs.getData().getStaffList(); + Map staffMap=staffList.stream().collect(Collectors.toMap(StaffListResultDTO::getStaffId, StaffListResultDTO::getStaffName)); + + IcSocietyOrgExcelImportListener listener = new IcSocietyOrgExcelImportListener(customerId,staffInfo, this,staffMap); + EasyExcel.read(filePath.toFile(), IcSocietyOrgImportExcelDTO.class, listener).headRowNumber(1).sheet(0).doRead(); + + Path errorDescFile = null; + String errorDesFileUrl = null; + List errorRows = listener.getErrorRows(); + + boolean failed = errorRows.size() > 0; + if (failed) { + // 生成并上传错误文件 + try { + // 文件生成 + Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_enterprise", "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, IcSocietyOrgImportExcelDTO.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(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) { + log.error("method exception", e); + } + } + } + } + + private CustomerStaffInfoCacheResult queryCurrentStaff(String customerId, String userId) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); + if (null == staffInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询工作人员缓存信息异常", EpmetErrorCode.SERVER_ERROR.getMsg()); + } + return staffInfo; + } + + public List selectForUniqueName(String agencyId, String societyName, String id) { + return baseDao.selectListForUniqueName(agencyId,societyName,id); + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java new file mode 100755 index 0000000000..7534b9a918 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java @@ -0,0 +1,569 @@ +package com.epmet.service.impl; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.write.metadata.WriteSheet; +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.constant.ServiceConstant; +import com.epmet.commons.tools.dto.result.OptionResultDTO; +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.exception.ValidateException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.*; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.WorkdiaryServiceRecordDao; +import com.epmet.dao.WorkdiaryServiceTypeDao; +import com.epmet.dto.*; +import com.epmet.dto.form.GridOptionFormDTO; +import com.epmet.dto.form.LoginUserDetailsFormDTO; +import com.epmet.dto.form.resi.IcResiPageNonDynamicFormDTO; +import com.epmet.dto.result.*; +import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; +import com.epmet.entity.WorkdiaryServiceRecordEntity; +import com.epmet.excel.WorkdiaryServiceRecordExcel; +import com.epmet.excel.listener.WorkdiaryServiceImportListener; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OssFeignClient; +import com.epmet.redis.WorkdiaryServiceRecordRedis; +import com.epmet.service.WorkdiaryServiceRecordService; +import com.epmet.service.WorkdiaryServiceTypeService; +import com.epmet.utils.ImportTaskUtils; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotNull; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * 工作日志(服务)-记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Service +public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl implements WorkdiaryServiceRecordService, ResultDataResolver { + + @Autowired + private WorkdiaryServiceRecordRedis workdiaryServiceRecordRedis; + + @Autowired + private WorkdiaryServiceTypeDao workdiaryServiceTypeDao; + + @Autowired + private EpmetUserOpenFeignClient userOpenFeignClient; + + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + + @Autowired + private OssFeignClient ossFeignClient; + + private ThreadLocal> importResultDescTl = new ThreadLocal<>(); + + /** + * 工作日志-服务时间-正则表达式 + * 支持模式: + * 2022-01-01 + * 2022-1-1 + * 2022/01/01 + * 2022/01-1 + * ... + */ + private static final Pattern WORKDIARY_SERVICE_TIME_REGEX = Pattern.compile("^(\\s*)(?\\d{4})[-/](?\\d{1,2})[-/](?\\d{1,2})(\\s*)$"); + + /** + * 导入结果描述 + */ + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class ImportResultDesc { + @ColumnWidth(20) + @ExcelProperty(value = "申请人") + private String applicantName; + + @ColumnWidth(30) + @ExcelProperty(value = "服务内容") + private String serviceContent; + + @ColumnWidth(30) + @ExcelProperty(value = "描述") + private String desc; + } + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, WorkdiaryServiceRecordDTO.class); + } + + @Override + public PageData page(String gridId, Short serviceType, String applicantName, String applicantAddress, + String serviceContent, String applicantMobile, Date serviceTimeStart, Date serviceTimeEnd, + Integer pageNo, Integer pageSize) { + + LoginUserDetailsResultDTO currentStaff = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(new LoginUserDetailsFormDTO( + EpmetRequestHolder.getLoginUserApp(), EpmetRequestHolder.getLoginUserClient(), EpmetRequestHolder.getLoginUserId() + )), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "查询工作人员信息失败", "查询工作人员信息失败"); + + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(StringUtils.isNotBlank(gridId), WorkdiaryServiceRecordEntity::getGridId, gridId); + query.eq(serviceType != null, WorkdiaryServiceRecordEntity::getServiceType, serviceType); + query.like(StringUtils.isNotBlank(applicantName), WorkdiaryServiceRecordEntity::getApplicantName, applicantName); + query.like(StringUtils.isNotBlank(applicantAddress), WorkdiaryServiceRecordEntity::getApplicantAddress, applicantAddress); + query.like(StringUtils.isNotBlank(serviceContent), WorkdiaryServiceRecordEntity::getServiceContent, serviceContent); + query.like(StringUtils.isNotBlank(applicantMobile), WorkdiaryServiceRecordEntity::getApplicantMobile, applicantMobile); + query.likeRight(WorkdiaryServiceRecordEntity::getOrgIdPath, currentStaff.getOrgIdPath()); + + // 服务时间查询,两端包含,闭区间 + query.ge(serviceTimeStart != null, WorkdiaryServiceRecordEntity::getServiceTime, serviceTimeStart); + query.le(serviceTimeStart != null, WorkdiaryServiceRecordEntity::getServiceTime, serviceTimeEnd); + + // 创建时间倒序 + query.orderByDesc(WorkdiaryServiceRecordEntity::getCreatedTime); + + // 查找类型列表 + List stList = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(null, 1, 100); + Map stMap = stList.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); + + // 查找服务记录 + PageHelper.startPage(pageNo, pageSize); + List list = baseDao.selectList(query) + .stream() + .map(e -> convertEntity2DTO(e, stMap)) + .collect(Collectors.toList()); + return new PageData<>(list, new PageInfo<>(list).getTotal(), pageSize); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, WorkdiaryServiceRecordDTO.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 WorkdiaryServiceRecordDTO get(String id) { + WorkdiaryServiceRecordEntity entity = baseDao.selectById(id); + return convertEntity2DTO(entity, null); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(WorkdiaryServiceRecordDTO dto) { + WorkdiaryServiceRecordEntity entity = ConvertUtils.sourceToTarget(dto, WorkdiaryServiceRecordEntity.class); + + LoginUserDetailsResultDTO currentStaff = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(new LoginUserDetailsFormDTO( + EpmetRequestHolder.getLoginUserApp(), EpmetRequestHolder.getLoginUserClient(), EpmetRequestHolder.getLoginUserId() + )), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "查询工作人员信息失败", "查询工作人员信息失败"); + + String staffOrgIdPath = currentStaff.getOrgIdPath(); + + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(dto.getGridId()); + + if (gridInfo == null) { + // 说明网格是其他组织下的 + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "网格未找到", "网格未找到"); + } + + String gridOrgIdPath = gridInfo.getPids().concat(":").concat(gridInfo.getId()); + + if (!gridOrgIdPath.contains(staffOrgIdPath)) { + // 说明网格是其他组织下的 + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所选网格不在您所属组织下", "所选网格不在您所属组织下"); + } + + entity.setOrgIdPath(gridOrgIdPath); + entity.setAgencyId(gridInfo.getPid()); + + IcResiUserDTO applicant = getResultDataOrThrowsException(userOpenFeignClient.getIcResiUserDTO(dto.getApplicantId()), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到申请人信息"); + + entity.setCustomerId(EpmetRequestHolder.getLoginUserCustomerId()); + if (applicant != null) { + entity.setApplicantName(applicant.getName()); + entity.setCustomerId(applicant.getCustomerId()); + } + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(WorkdiaryServiceRecordDTO dto) { + WorkdiaryServiceRecordEntity entity = new WorkdiaryServiceRecordEntity(); + + entity.setId(dto.getId()); + entity.setServiceType(dto.getServiceType()); + entity.setGridId(dto.getGridId()); + entity.setApplicantId(dto.getApplicantId()); + entity.setApplicantAddress(dto.getApplicantAddress()); + entity.setServiceContent(dto.getServiceContent()); + entity.setApplicantMobile(dto.getApplicantMobile()); + entity.setPrincipalName(dto.getPrincipalName()); + entity.setServiceTime(dto.getServiceTime()); + entity.setRemark(dto.getRemark()); + //entity.setApplicantIdCard(dto.getApplicantIdCard()); + + // orgidPath + if (StringUtils.isNotBlank(dto.getGridId())) { + Optional.ofNullable(CustomerOrgRedis.getGridInfo(dto.getGridId())) + .ifPresent(gi -> { + entity.setOrgIdPath(gi.getPids().concat(":").concat(gi.getId())); + entity.setAgencyId(gi.getPid()); + }); + } + + if (StringUtils.isNotBlank(dto.getApplicantId())) { + IcResiUserDTO applicant = getResultDataOrThrowsException(userOpenFeignClient.getIcResiUserDTO(dto.getApplicantId()), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到申请人信息"); + + if (applicant != null) { + entity.setApplicantName(applicant.getName()); + entity.setCustomerId(applicant.getCustomerId()); + } + } + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + private WorkdiaryServiceRecordDTO convertEntity2DTO(WorkdiaryServiceRecordEntity entity, Map stMap) { + + if (stMap == null || stMap.size() == 0) { + // 查找类型列表 + List list = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(null, 1, 100); + stMap = list.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); + } + + WorkdiaryServiceRecordDTO d = ConvertUtils.sourceToTarget(entity, WorkdiaryServiceRecordDTO.class); + Optional.ofNullable(CustomerOrgRedis.getGridInfo(entity.getGridId())).ifPresent((gridInfo) -> d.setGridName(gridInfo.getAgencyName() + gridInfo.getGridName())); + d.setServiceTypeName(stMap.get(entity.getServiceType())); + return d; + } + + @Override + public void export(String gridId, Short serviceType, String applicantName, String applicantAddress, + String serviceContent, String applicantMobile, Date serviceTimeStart, Date serviceTimeEnd, HttpServletResponse response) { + + ExcelWriter writer; + try { + writer = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("工作日志导出.xlsx", response)).build(); + } catch (IOException e) { + logger.error("【工作日志-服务】导出-response设置失败:{}", ExceptionUtils.getErrorStackTrace(e)); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + WriteSheet sheet = EasyExcel.writerSheet("工作日志") + .head(WorkdiaryServiceRecordExcel.class) + .build(); + + + try { + //一次500条,分批导出 + int pageSize = 500; + for (int pageNo = 1; ; pageNo++) { + PageData page = this.page(gridId, serviceType, applicantName, applicantAddress, serviceContent, + applicantMobile, serviceTimeStart, serviceTimeEnd, pageNo, pageSize); + + List list = page.getList(); + if (CollectionUtils.isEmpty(list)) { + // 空的,导出结束 + break; + } + + List excelObjects = list.stream().map(e -> new WorkdiaryServiceRecordExcel(e)).collect(Collectors.toList()); + writer.write(excelObjects, sheet); + } + } finally { + writer.finish(); + } + } + + @Override + public Integer selectRecordCountOfType(Short serviceType) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(WorkdiaryServiceRecordEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); + query.eq(WorkdiaryServiceRecordEntity::getServiceType, serviceType); + return baseDao.selectCount(query); + } + + /** + * 创建导入任务并且执行导入 + * @param fileSavePath + */ + @Override + public void createImportTaskAndExecuteImport(Path fileSavePath, String originFileName, String taskId) { + String resultDescFileUtl = null; + // 执行导入操作 + try { + importResultDescTl.set(new ArrayList<>()); + WorkdiaryServiceImportListener listener = new WorkdiaryServiceImportListener(this); + EasyExcel.read(fileSavePath.toFile(), WorkdiaryServiceRecordExcel.class,listener).headRowNumber(1).sheet(0).doRead(); + } catch (Exception e) { + logger.error("【工作日志】-导入-未知错误:{}", ExceptionUtils.getErrorStackTrace(e)); + } finally { + // 清理临时文件 + try { + Files.deleteIfExists(fileSavePath); + } catch (IOException e) { + logger.error("【书记日志】-导入-删除导入临时文件失败,staffId:{}, 文件名称:{}, 错误信息:{}", + EpmetRequestHolder.getLoginUserId(), fileSavePath.toString(), ExceptionUtils.getErrorStackTrace(e)); + } + + // 上传错误描述文件 + try { + resultDescFileUtl = buildAndUploadResultDescFile(importResultDescTl.get()); + } catch (IOException e) { + logger.error("【工作日志】导入-生成和上传错误描述文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + // 清理错误结果描述缓存 + importResultDescTl.remove(); + } + + + + // 修改导入记录状态为已完成 + ImportTaskUtils.finishImportTask(taskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS, resultDescFileUtl, ""); + } + + /** + * 生成和上传错误描述文件 + * @return + */ + private String buildAndUploadResultDescFile(List descs) throws IOException { + if(CollectionUtils.isEmpty(descs)) { + return null; + } + //Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"), + // ImportResultDesc.class, descs); + + String fileName = System.currentTimeMillis() + "_" + EpmetRequestHolder.getLoginUserId() + ".xlsx"; + + FileItem fileItem = new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, FileUtils.getAndCreateDirUnderEpmetFilesDir("workdiary", "result_desc").toFile()) + .createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName); + + // 为了自动关闭流 + try (OutputStream os = fileItem.getOutputStream()) { + EasyExcel.write(os, ImportResultDesc.class).sheet("失败列表").doWrite(descs); + } + + UploadImgResultDTO result = getResultDataOrThrowsException(ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)), + ServiceConstant.EPMET_OSS_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "上传结果描述文件失败", "上传结果描述文件失败"); + + if (!fileItem.isInMemory()) { + fileItem.delete(); + } + return result.getUrl(); + } + + /** + * 执行批量插入 + * @param datas + */ + @Override + public void executeBatchImport(List datas) { + if (CollectionUtils.isEmpty(datas)) { + return; + } + + // 当前登录人 + LoginUserDetailsResultDTO currentStaff = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails( + new LoginUserDetailsFormDTO(EpmetRequestHolder.getLoginUserApp(), EpmetRequestHolder.getLoginUserClient(), EpmetRequestHolder.getLoginUserId())), + ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【工作日志】-导入-没有找到当前登录人信息", "【工作日志】-导入-没有找到当前登录人信息"); + + // 服务类型字典。key:养老 value:object + List serviceTypes = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).page(null, 1, 100).getList(); + Map serviceTypeMap = serviceTypes.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceTypeName, Function.identity())); + + ArrayList diaryRecordList = new ArrayList<>(); + + // 循环校验和填充数据 + for (WorkdiaryServiceRecordExcel row : datas) { + + String gridName = row.getGridName(); + String serviceTypeName = row.getServiceTypeName(); + String applicantName = row.getApplicantName(); + + try { + // 校验必填 + ValidatorUtils.validateEntity(row); + + // 检查服务类型 + WorkdiaryServiceTypeDTO serviceType = serviceTypeMap.get(serviceTypeName); + if (serviceType == null || serviceType.getEnabled().shortValue() == 0) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所选服务类型不存在或已禁用", "所选服务类型不存在或已禁用"); + } + + // 检查网格 + OptionResultDTO grid = findGrid(currentStaff.getAgencyId(), gridName); + if (grid == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "网格不存在,或不在您所属的组织下", "网格不存在,或不在您所属的组织下"); + } + + // 查找居民 + IcResiNonDynamicResultDTO resi = findResi(grid.getValue(), row.getApplicantName(), row.getApplicantMobile()); + + if (StringUtils.isBlank(row.getApplicantMobile())) { + row.setApplicantMobile(resi.getMobile()); + } + + // 没填写住址的,到系统查询 + if (StringUtils.isBlank(row.getApplicantAddress())) { + + HouseAgencyInfoResultDTO house = getResultDataOrThrowsException(govOrgOpenFeignClient.getHouseAgencyInfo(resi.getHomeId()), + ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "查询房屋失败", "查询房屋失败"); + + if (house == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民住址未找到", "居民未找到"); + } + + row.setApplicantAddress(house.getFullName()); + } + + // ---------服务时间 Start 使用正则处理--------- + String serviceTimeStr = row.getServiceTime(); + String year; + String month; + String day; + Matcher stm = WORKDIARY_SERVICE_TIME_REGEX.matcher(serviceTimeStr); + if (stm.matches()) { + year = stm.group("year"); + month = stm.group("month"); + day = stm.group("day"); + } else { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "服务时间格式不正确", + "服务时间格式不正确"); + } + + year = String.format("%04d", Integer.valueOf(year)); + month = String.format("%02d", Integer.valueOf(month)); + day = String.format("%02d", Integer.valueOf(day)); + + Date serviceTime = DateUtils.parseDate(String.format("%s-%s-%s", year, month, day), DateUtils.DATE_PATTERN); + + // ---------服务时间 End--------- + + // 填充到entity + WorkdiaryServiceRecordEntity record = new WorkdiaryServiceRecordEntity( + EpmetRequestHolder.getLoginUserCustomerId(), + serviceType.getServiceType(), + currentStaff.getAgencyId(), + grid.getValue(), + currentStaff.getOrgIdPath().concat(":").concat(grid.getValue()), + resi.getId(), + row.getApplicantIdCard(), + row.getApplicantName(), + row.getApplicantAddress(), + row.getApplicantMobile(), + row.getServiceContent(), + serviceTime, + row.getPrincipalName(), + row.getRemark()); + + diaryRecordList.add(record); + } catch (ValidateException ve) { + importResultDescTl.get().add(new ImportResultDesc(applicantName, row.getServiceContent(), ve.getMsg())); + } catch (EpmetException ee) { + importResultDescTl.get().add(new ImportResultDesc(applicantName, row.getServiceContent(), ee.getMsg())); + } catch (Throwable t) { + logger.error(ExceptionUtils.getThrowableErrorStackTrace(t)); + importResultDescTl.get().add(new ImportResultDesc(applicantName, row.getServiceContent(), "未知错误")); + } + } + + // 批量持久化 + insertBatch(diaryRecordList, 50); + } + + private IcResiNonDynamicResultDTO findResi(String gridId, String applicantName, String mobile) { + PageData page = getResultDataOrThrowsException(userOpenFeignClient.listResiNonDynamic(new IcResiPageNonDynamicFormDTO(gridId, applicantName, mobile, false)), + ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民未找到", "居民未找到"); + + List list = page.getList(); + + if (page == null || CollectionUtils.isEmpty(page.getList())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民未找到", "居民未找到"); + } + + return list.get(0); + } + + /** + * 从组织下查找指定的网格名称,得到网格数据 + * @param agencyId + * @param gridName + * @return + */ + private OptionResultDTO findGrid(String agencyId, String gridName) { + List gridOptions = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridOption(new GridOptionFormDTO(agencyId, "saveOrUpdate")), + ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【工作日志】-导入-网格查询失败", "【工作日志】-导入-网格查询失败"); + + for (OptionResultDTO grid : gridOptions) { + if (gridName.equals(grid.getLabel())) { + return grid; + } + } + + return null; + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java new file mode 100755 index 0000000000..fea0eeaa84 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java @@ -0,0 +1,156 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.distributedlock.DistributedLock; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.EpmetRequestHolder; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.dao.WorkdiaryServiceTypeDao; +import com.epmet.dto.WorkdiaryServiceTypeDTO; +import com.epmet.entity.WorkdiaryServiceTypeEntity; +import com.epmet.redis.WorkdiaryServiceTypeRedis; +import com.epmet.service.WorkdiaryServiceRecordService; +import com.epmet.service.WorkdiaryServiceTypeService; +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; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 工作日志(服务)-服务类型 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-23 + */ +@Service +public class WorkdiaryServiceTypeServiceImpl extends BaseServiceImpl implements WorkdiaryServiceTypeService { + + @Autowired + private WorkdiaryServiceTypeRedis workdiaryServiceTypeRedis; + @Autowired + private RedisUtils redisUtils; + @Autowired + private DistributedLock distributedLock; + + @Override + public PageData page(Short enabled, Integer pageNo, Integer pageSize) { + List list = list(enabled, pageNo, pageSize); + return new PageData<>(list, new PageInfo<>(list).getTotal(), pageSize); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, WorkdiaryServiceTypeDTO.class); + } + + @Override + public List list(Short enabled, Integer pageNo, Integer pageSize) { + LambdaQueryWrapper stQuery = new LambdaQueryWrapper<>(); + stQuery.eq(WorkdiaryServiceTypeEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); + stQuery.eq(enabled != null, WorkdiaryServiceTypeEntity::getEnabled, enabled); + List ds = baseDao.selectList(stQuery).stream().map((e) -> { + WorkdiaryServiceTypeDTO d = new WorkdiaryServiceTypeDTO(); + d.setId(e.getId()); + d.setServiceType(e.getServiceType()); + d.setServiceTypeName(e.getServiceTypeName()); + d.setEnabled(e.getEnabled()); + return d; + }).collect(Collectors.toList()); + return ds; + } + + @Override + public PageData listAvaliableServiceType(Integer pageNo, Integer pageSize) { + return this.page(Short.valueOf("1"), pageNo, pageSize); + } + + 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 WorkdiaryServiceTypeDTO get(String id) { + WorkdiaryServiceTypeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, WorkdiaryServiceTypeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(WorkdiaryServiceTypeDTO dto) { + String customerId = EpmetRequestHolder.getLoginUserCustomerId(); + // 预先检查 + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(WorkdiaryServiceTypeEntity::getCustomerId, customerId); + query.eq(WorkdiaryServiceTypeEntity::getServiceTypeName, dto.getServiceTypeName()); + if (baseDao.selectCount(query) > 0) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "已存在该类别", "已存在该类别"); + } + + WorkdiaryServiceTypeEntity entity = ConvertUtils.sourceToTarget(dto, WorkdiaryServiceTypeEntity.class); + entity.setCustomerId(customerId); + entity.setEnabled(Short.valueOf("1")); + synchronized (this) { + Short max = baseDao.getMaxType(customerId); + entity.setServiceType(++max); + insert(entity); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(WorkdiaryServiceTypeDTO dto) { + WorkdiaryServiceTypeEntity entity = ConvertUtils.sourceToTarget(dto, WorkdiaryServiceTypeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int delete(@RequestBody String[] ids) { + //String.format(""); + //distributedLock.getLock(RedisKeys.getLockByMethodName()); + // todo 此操作与日志记录的新增和修改动作之间需要互斥 + List canDeleteIds = new ArrayList<>(); + int failCount = 0; + for (String id : ids) { + WorkdiaryServiceTypeEntity st = baseDao.selectById(id); + if (st == null) { + continue; + } + WorkdiaryServiceRecordService wsRecordService = SpringContextUtils.getBean(WorkdiaryServiceRecordService.class); + Integer recordCount = wsRecordService.selectRecordCountOfType(st.getServiceType()); + if (recordCount > 0) { + failCount++; + } else { + canDeleteIds.add(id); + } + } + + if (CollectionUtils.isNotEmpty(canDeleteIds)) { + baseDao.deleteBatchIds(canDeleteIds); + } + return failCount; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.28__workdiary_service.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.28__workdiary_service.sql new file mode 100644 index 0000000000..c59d94b2a2 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.28__workdiary_service.sql @@ -0,0 +1,47 @@ +# 服务记录表 +CREATE TABLE `workdiary_service_record` +( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `SERVICE_TYPE` tinyint(3) NOT NULL COMMENT '服务类型', + `AGENCY_ID` varchar(32) NOT NULL COMMENT '单位ID', + `GRID_ID` varchar(32) NOT NULL COMMENT '网格ID', + `ORG_ID_PATH` varchar(255) NOT NULL COMMENT '组织ID path', + `APPLICANT_ID` varchar(32) NOT NULL COMMENT '申请人ID', + `APPLICANT_ID_CARD` varchar(32) default '' COMMENT '申请人证件号', + `APPLICANT_NAME` varchar(32) NOT NULL COMMENT '申请人姓名', + `APPLICANT_ADDRESS` varchar(32) NOT NULL COMMENT '申请人住址', + `APPLICANT_MOBILE` varchar(20) NOT NULL COMMENT '申请人联系电话', + `SERVICE_CONTENT` varchar(255) NOT NULL COMMENT '服务内容', + `SERVICE_TIME` datetime NOT NULL COMMENT '服务时间', + `PRINCIPAL_NAME` varchar(10) default '' COMMENT '负责人姓名', + `REMARK` varchar(255) default '' COMMENT '备注', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) 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`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='工作日志(服务)-记录'; + + +# 工作日志-服务分类 +CREATE TABLE `workdiary_service_type` +( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `SERVICE_TYPE` tinyint(3) NOT NULL COMMENT '服务类型', + `SERVICE_TYPE_NAME` varchar(32) NOT NULL COMMENT '服务类型名称', + `ENABLED` tinyint(1) NOT NULL COMMENT '是否启用。0:禁用,1:启用', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) 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`), + unique index cust_service_type(CUSTOMER_ID asc , SERVICE_TYPE asc , DEL_FLAG asc) using btree +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='工作日志(服务)-服务类型' diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml index 74031c3426..9fc03ab87d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml @@ -7,10 +7,12 @@ SELECT agency_id agencyId, id societyId, + img_url, society_name societyName, service_matters serviceMatters, person_in_charge personInCharge, mobile mobile, + service_time_str, service_start_time serviceStartTime, service_end_time serviceEndTime, admin_staff_id adminStaffId, @@ -90,4 +92,13 @@ AND agency_id = #{agencyId} - \ No newline at end of file + + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceRecordDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceRecordDao.xml new file mode 100755 index 0000000000..0f92add2d8 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceRecordDao.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml new file mode 100755 index 0000000000..b62d6f86c6 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/societyorg_import_template.xlsx b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/societyorg_import_template.xlsx new file mode 100644 index 0000000000..9ca4a73e2f Binary files /dev/null and b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/societyorg_import_template.xlsx differ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/workdiary_service_import.xlsx b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/workdiary_service_import.xlsx new file mode 100644 index 0000000000..0938c354cf Binary files /dev/null and b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/templates/workdiary_service_import.xlsx differ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcNeighborHoodDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcNeighborHoodDTO.java index d50508c522..dbf18ee25a 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcNeighborHoodDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcNeighborHoodDTO.java @@ -69,6 +69,11 @@ public class IcNeighborHoodDTO implements Serializable { */ private String gridId; + /** + * 网格 + */ + private String gridName; + /** * 详细地址 */ @@ -144,4 +149,9 @@ public class IcNeighborHoodDTO implements Serializable { */ private Integer realBuilding; + /** + * 楼栋名 + */ + private String buildingName; + } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CheckHouseInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CheckHouseInfoFormDTO.java new file mode 100644 index 0000000000..106952e90c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CheckHouseInfoFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 根据小区,楼宇,单元名称校验是否存在 + * @Author wgf + * @Date 2022/8/24 9:03 + */ +@Data +public class CheckHouseInfoFormDTO implements Serializable { + private static final long serialVersionUID = 2636608477324780974L; + + private String customerId; + + private String gridId; + private String gridName; + + private String villageId; + private String buildId; + private String unitId; + private String homeId; + + + private String villageName; + private String buildName; + private String unitName; + private String homeName; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GridOptionFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GridOptionFormDTO.java index e6fae52bc9..434af5aed4 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GridOptionFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GridOptionFormDTO.java @@ -1,6 +1,8 @@ package com.epmet.dto.form; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -11,6 +13,8 @@ import java.io.Serializable; * @Date 2021/11/12 10:54 上午 */ @Data +@NoArgsConstructor +@AllArgsConstructor public class GridOptionFormDTO implements Serializable { /** * 部门Id diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/BuildingResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/BuildingResultDTO.java index 212c85a700..dc2624e160 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/BuildingResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/BuildingResultDTO.java @@ -11,13 +11,21 @@ import java.io.Serializable; */ @Data public class BuildingResultDTO implements Serializable { + private static final long serialVersionUID = -2129418426919785999L; + private String buildingId; + private String buildingName; + + private String gridId; + private String gridName; + private String neighborhoodId; + private String neighborhoodName; - private String buildingName; + private String label; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckHomeInfoResultInfo.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckHomeInfoResultInfo.java new file mode 100644 index 0000000000..ab4bc4d963 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckHomeInfoResultInfo.java @@ -0,0 +1,38 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 房屋信息 + * + * @author wgf + * @date 2022/8/23 20:58 + */ +@Data +public class CheckHomeInfoResultInfo implements Serializable { + private static final long serialVersionUID = -2797565581047800011L; + + // 0:校验成功;1:校验失败; + private String code; + // 提示信息 + private String msg; + // 是否新增房屋:0:否;1:是 + private String isAdd; + + private String gridId; + private String gridName; + + private String villageId; + private String villageName; + + private String buildId; + private String buildName; + + private String unitId; + private String unitName; + + private String homeId; + private String homeName; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoByNameResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoByNameResultDTO.java new file mode 100644 index 0000000000..fd91d086b5 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoByNameResultDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 网格所属组织基本信息 + * @Author wgf + * @Date 2020/4/26 22:35 + */ +@Data +public class GridInfoByNameResultDTO implements Serializable { + private static final long serialVersionUID = 4360690752084258055L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格组织ID + */ + private String deptId; + + /** + * 网格名称 + */ + private String deptName; + + /** + * 网格的上级组织 + */ + private String pid; + + /** + * 网格的所有上级组织 + */ + private String pids; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseAgencyInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseAgencyInfoResultDTO.java index d5734e2791..eff5a441d8 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseAgencyInfoResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseAgencyInfoResultDTO.java @@ -21,6 +21,7 @@ public class HouseAgencyInfoResultDTO implements Serializable { private String neighborHoodId; private String buildingId; private String buildingUnitId; + private String fullName; public HouseAgencyInfoResultDTO() { this.agencyId = ""; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 73316bad52..c1aba9bb3c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -475,6 +475,18 @@ public class CustomerAgencyController { return customerAgencyService.getCommunityInfo(formDTO); } + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author wgf + * @Description 根据网格名称查询所属组织信息 + * @Date 2022/6/21 22:41 + **/ + @PostMapping("getGridInfoByGridName") + public Result getGridInfoByGridName(@RequestBody GridInfoVaccinePrarmeterFormDTO formDTO) { + return customerAgencyService.getGridInfoByGridName(formDTO); + } + /** * @param userId * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java index 49e3f15f92..6d828df25a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java @@ -18,11 +18,16 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.IcHouseDTO; +import com.epmet.dto.IcVaccinePrarmeterDTO; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.form.HouseFormDTO; +import com.epmet.dto.form.VaccinePrarmeterListFormDTO; import com.epmet.dto.result.HouseAgencyInfoResultDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseListResultDTO; @@ -136,4 +141,19 @@ public class IcHouseController { public Result> getOwnerHouseList(@RequestBody IcHouseDTO formDTO){ return new Result>().ok(icHouseService.getOwnerHouseList(formDTO)); } + + /** + * Desc: 根据小区,楼宇,单元名称校验是否存在 + * @param formDTO + * @param tokenDto + * @author wgf + * @date 2022/8/24 13:57 + */ + @PostMapping("checkHomeInfo") + public Result checkHomeInfo(@RequestBody CheckHouseInfoFormDTO formDTO, @LoginUser TokenDto tokenDto){ + ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + return icHouseService.checkHomeInfo(formDTO); + + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index 627b5a5d8b..f44e52c44f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -39,6 +39,7 @@ import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcNeighborHoodService; @@ -150,6 +151,20 @@ public class IcNeighborHoodController { return new Result>().ok(icNeighborHoodService.getNeighborHoodOptions(dto.getAgencyId(), dto.getGridId(),tokenDto.getUserId(),tokenDto.getCustomerId())); } + /** + * 获取用户组织下小区列表 + * + * @param tokenDto + * @param dto + * @return com.epmet.commons.tools.utils.Result> + * @author zhy + * @date 2022/8/19 15:56 + */ + @PostMapping("neighborhoodlist") + public Result> getNeighborhoodList(@LoginUser TokenDto tokenDto, @RequestBody IcNeighborHoodDTO dto) { + return new Result>().ok(icNeighborHoodService.getNeighborhoodList(tokenDto, dto)); + } + /** * @Description 小区信息导入 * @param tokenDTO diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index b54b4a28b7..37e8d93c98 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.GridInfoVaccinePrarmeterFormDTO; import com.epmet.dto.form.OrgInfoPointFormDTO; import com.epmet.dto.form.OrgTreeByUserAndTypeFormDTO; import com.epmet.dto.result.*; @@ -352,6 +353,8 @@ public interface CustomerAgencyDao extends BaseDao { CommunityInfoResultDTO getCommunityInfo(OrgInfoPointFormDTO formDTO); + GridInfoByNameResultDTO getGridInfoByGridName(GridInfoVaccinePrarmeterFormDTO formDTO); + CommunityInfoResultDTO getCommunityInfoByUserId(@Param("userId") String userId); /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java index 8b0cd3f470..4e963af722 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java @@ -19,7 +19,9 @@ package com.epmet.dao; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.form.IcBuildingListFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; @@ -224,4 +226,22 @@ public interface IcBuildingDao extends BaseDao { IcBuildingEntity selectByCoding(@Param("coding") String coding, @Param("id") String id); + /** + * 展示所有楼栋和小区信息 + * + * @param dto + * @return java.util.List + * @author zhy + * @date 2022/8/19 17:32 + */ + List listBuildingInfo(IcNeighborHoodDTO dto); + + + /** + * 根据楼宇名称查询楼宇信息 + * @param formDTO + * @return + */ + IcBuildingEntity getBuildingInfoByName(CheckHouseInfoFormDTO formDTO); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingUnitDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingUnitDao.java index 09c40920ed..ebc8c2f888 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingUnitDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingUnitDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.result.HouseInfoResultDTO; import com.epmet.dto.result.OrganizationCommunityDTO; import com.epmet.entity.IcBuildingUnitEntity; @@ -78,4 +79,11 @@ public interface IcBuildingUnitDao extends BaseDao { * @return com.epmet.dto.result.OrganizationCommunityDTO */ OrganizationCommunityDTO selectCommunityByUnitId(@Param("unitId") String unitId); + + /** + * 根据单元名称查询单元信息 + * @param formDTO + * @return + */ + IcBuildingUnitEntity getbuildingUnitInfoByName(CheckHouseInfoFormDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index 3ae10791bf..e8e8157256 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -2,6 +2,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.form.GetHouseInfoToCollectFormDTO; import com.epmet.dto.form.IcHouseListFormDTO; import com.epmet.dto.result.*; @@ -201,4 +202,11 @@ public interface IcHouseDao extends BaseDao { */ IcHouseInfoCollectResultDTO getHouseInfoToCollect(GetHouseInfoToCollectFormDTO formDTO); + /** + * 校验房屋 + * @param formDTO + * @return + */ + IcHouseEntity getHouseInfoByName(CheckHouseInfoFormDTO formDTO); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java index a1999a0ee6..afe0374247 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.NeighborHoodAndManagementDTO; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.form.HouseInformationFormDTO; import com.epmet.dto.form.IcNeighborHoodListFormDTO; import com.epmet.dto.result.*; @@ -211,4 +212,12 @@ public interface IcNeighborHoodDao extends BaseDao { * @Date 2022/6/29 16:48 */ List getHouseList(HouseInformationFormDTO formDTO); + + + /** + * 根据名称查小区信息 + * @param formDTO + * @return + */ + IcNeighborHoodEntity getNeighborHoodInfoByName(CheckHouseInfoFormDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index bec4188167..e71189e0ad 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -327,6 +327,15 @@ public interface CustomerAgencyService extends BaseService **/ Result getCommunityInfo(OrgInfoPointFormDTO formDTO); + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author wgf + * @Description 根据网格名称查询所属组织信息 + * @Date 2022/6/21 22:41 + **/ + Result getGridInfoByGridName(GridInfoVaccinePrarmeterFormDTO formDTO); + /** * @param userId * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java index 522acba117..77a5bdd4ad 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java @@ -3,8 +3,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcHouseDTO; import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.form.HouseFormDTO; import com.epmet.dto.result.HouseAgencyInfoResultDTO; import com.epmet.dto.result.HouseInfoDTO; @@ -130,4 +132,11 @@ public interface IcHouseService extends BaseService { * @Date 2022/7/19 17:41 */ List getOwnerHouseList(IcHouseDTO formDTO); + + /** + * 根据小区,楼宇,单元名称校验是否存在 + * @param formDTO + * @return + */ + Result checkHomeInfo(CheckHouseInfoFormDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 085c363819..913b4496c4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -20,16 +20,19 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.dto.result.OptionResultDTO; 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.dto.IcNeighborHoodDTO; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.NeighborHoodAndManagementDTO; import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.entity.IcNeighborHoodPropertyEntity; import com.epmet.entity.IcPropertyManagementEntity; +import org.springframework.web.bind.annotation.RequestBody; import java.io.IOException; import java.io.InputStream; @@ -115,6 +118,17 @@ public interface IcNeighborHoodService extends BaseService */ List getNeighborHoodOptions(String agencyId, String gridId,String staffId,String customerId); + /** + * 获取用户组织下小区列表 + * + * @param tokenDto + * @param dto + * @return java.util.List + * @author zhy + * @date 2022/8/19 15:57 + */ + List getNeighborhoodList(TokenDto tokenDto, IcNeighborHoodDTO dto); + /** * @Description 通过ID查询小区信息 * @Param ids diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index f2c0392dc7..760f9690ad 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -1580,6 +1580,13 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl().ok(communityInfoResultDTO); } + @Override + public Result getGridInfoByGridName(GridInfoVaccinePrarmeterFormDTO formDTO) { + GridInfoByNameResultDTO gridInfoByNameResultDTO = baseDao.getGridInfoByGridName(formDTO); + + return new Result().ok(gridInfoByNameResultDTO); + } + @Override public Result getCommunityInfoByUserId(String userId) { CommunityInfoResultDTO communityInfoResultDTO = baseDao.getCommunityInfoByUserId(userId); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index e8de32ecce..933a07daeb 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -264,8 +264,10 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { houseChangeRecordCollect(formDTO.getId(), formDTO.getCustomerId(), icHouseDTO); icHouseDao.updateById(entity); + IcHouseDTO houseDTO = icHouseService.get(formDTO.getId()); + //删除房屋缓存 - icHouseRedis.delHouseInfo(formDTO.getId(), entity.getCustomerId()); + icHouseRedis.delHouseInfo(formDTO.getId(), houseDTO.getCustomerId()); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java index d31a2cbb54..76df21476b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java @@ -20,12 +20,9 @@ import com.epmet.dto.IcHouseDTO; import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.CheckHouseInfoFormDTO; import com.epmet.dto.form.HouseFormDTO; -import com.epmet.dto.result.HouseAgencyInfoResultDTO; -import com.epmet.dto.result.HomeInfoResultDTO; -import com.epmet.dto.result.HouseInfoDTO; -import com.epmet.dto.result.HouseListResultDTO; -import com.epmet.dto.result.HousesNameResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.IcBuildingEntity; import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.entity.IcHouseEntity; @@ -339,4 +336,56 @@ public class IcHouseServiceImpl extends BaseServiceImpl icHouseRedis.getHouseInfo(item.getId(), item.getCustomerId())).collect(Collectors.toList()); } + + @Override + public Result checkHomeInfo(CheckHouseInfoFormDTO formDTO) { + CheckHomeInfoResultInfo checkHomeInfoResultInfo = ConvertUtils.sourceToTarget(formDTO, CheckHomeInfoResultInfo.class); + + // 校验小区 + IcNeighborHoodEntity icNeighborHoodEntity = icNeighborHoodDao.getNeighborHoodInfoByName(formDTO); + if(icNeighborHoodEntity != null && StringUtils.isNotBlank(icNeighborHoodEntity.getId())){ + formDTO.setVillageId(icNeighborHoodEntity.getId()); + checkHomeInfoResultInfo.setVillageId(icNeighborHoodEntity.getId()); + }else{ + checkHomeInfoResultInfo.setCode("1"); + checkHomeInfoResultInfo.setMsg("小区名称未匹配到数据"); + return new Result().ok(checkHomeInfoResultInfo); + } + + // 校验楼宇 + IcBuildingEntity icBuildingEntity = icBuildingDao.getBuildingInfoByName(formDTO); + if(icBuildingEntity != null && StringUtils.isNotBlank(icBuildingEntity.getId())){ + formDTO.setBuildId(icBuildingEntity.getId()); + checkHomeInfoResultInfo.setBuildId(icBuildingEntity.getId()); + }else{ + checkHomeInfoResultInfo.setCode("1"); + checkHomeInfoResultInfo.setMsg("楼宇名称未匹配到数据"); + return new Result().ok(checkHomeInfoResultInfo); + } + + // 校验单元 + IcBuildingUnitEntity icBuildingUnitEntity = buildingUnitDao.getbuildingUnitInfoByName(formDTO); + if(icBuildingUnitEntity != null && StringUtils.isNotBlank(icBuildingUnitEntity.getId())){ + formDTO.setUnitId(icBuildingUnitEntity.getId()); + checkHomeInfoResultInfo.setUnitId(icBuildingUnitEntity.getId()); + }else{ + checkHomeInfoResultInfo.setCode("1"); + checkHomeInfoResultInfo.setMsg("单元名称未匹配到数据"); + return new Result().ok(checkHomeInfoResultInfo); + } + + // 校验房屋 + IcHouseEntity icHouseEntity = baseDao.getHouseInfoByName(formDTO); + checkHomeInfoResultInfo.setCode("0"); + if(icHouseEntity != null && StringUtils.isNotBlank(icHouseEntity.getId())){ + checkHomeInfoResultInfo.setHomeId(icHouseEntity.getId()); + checkHomeInfoResultInfo.setMsg("该房屋为已存在房屋"); + checkHomeInfoResultInfo.setIsAdd("0"); + }else{ + checkHomeInfoResultInfo.setMsg("该房屋暂不存在"); + checkHomeInfoResultInfo.setIsAdd("1"); + } + + return new Result().ok(checkHomeInfoResultInfo); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 14c9af3048..3ca505d172 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -40,6 +40,7 @@ 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.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerGridConstant; @@ -49,6 +50,7 @@ import com.epmet.dto.*; import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.InfoByNamesResultDTO; import com.epmet.dto.result.UploadImgResultDTO; @@ -210,6 +212,20 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl getNeighborhoodList(TokenDto tokenDto, IcNeighborHoodDTO dto) { + dto.setCustomerId(tokenDto.getCustomerId()); + if (StringUtils.isBlank(dto.getAgencyId()) && StringUtils.isEmpty(dto.getGridId())) { + log.info("agencyId与gridId都为空时,默认查询当前工作人员所属组织下的小区"); + CustomerStaffInfoCacheResult result= CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + if (null == result || StringUtils.isBlank(result.getAgencyId())) { + log.error(String.format("staffId:%s,工作人员缓存信息查询异常")); + return Collections.emptyList(); + } + dto.setAgencyId(result.getAgencyId()); + } + return icBuildingDao.listBuildingInfo(dto); + } + /** * @param ids * @Description 通过ID查询小区信息 diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index acf894391f..8493df5d81 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -916,6 +916,21 @@ limit 1 + + + + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingUnitDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingUnitDao.xml index fe5a0ef73b..c46c387e01 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingUnitDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingUnitDao.xml @@ -59,5 +59,16 @@ and u.id=#{unitId} + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 8b900c90dd..5d6fbe270f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -393,6 +393,7 @@ h.BUILDING_UNIT_ID, nh.AGENCY_ID, nh.GRID_ID, + h.FULL_NAME, nh.AGENCY_PIDS AS pids FROM ic_house h INNER JOIN ic_neighbor_hood nh ON (nh.ID = h.NEIGHBOR_HOOD_ID AND nh.DEL_FLAG = '0') @@ -549,5 +550,14 @@ and DOOR_NAME = #{doorName} + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index 2f76bc1b7a..96ec0dd57f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -662,6 +662,15 @@ ORDER BY SORT, DOOR_NAME+0 + diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index 3bb3a435d7..8d502c339d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -403,7 +403,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl{ if(topicInfo.getPublishedUser().equals(re.getUserId())){ //话题发起人 - String street = re.getStreet() == null ? "" : re.getStreet() + "-"; +// String street = re.getStreet() == null ? "" : re.getStreet() + "-"; String realName = re.getRealName() == null ? "" : re.getRealName(); - topicInfo.setPublishedUser(street + realName); + topicInfo.setPublishedUser(realName); } }); } else { @@ -2754,7 +2754,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl{ if(issueResult.getUserId().equals(re.getUserId())){ //话题发起人 - String street = re.getStreet() == null ? "" : re.getStreet() + "-"; String realName = re.getRealName() == null ? "" : re.getRealName(); - issueDetailResult.setIssueInitiator(street + realName); + issueDetailResult.setIssueInitiator(realName); } }); } else { diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java index e39bd2182c..c9a2f9996e 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java @@ -7,6 +7,7 @@ import com.epmet.dto.form.LatestGridInfoFormDTO; import com.epmet.dto.result.AllGridsByUserIdResultDTO; import com.epmet.dto.result.LatestGridInfoResultDTO; import com.epmet.modules.grid.service.ResiMineGridService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -63,7 +64,12 @@ public class ResiMineGridController { //formDTO.setAppId(appId); formDTO.setCustomerId(token.getCustomerId()); formDTO.setUserId(token.getUserId()); - return new Result().ok(resiMineGridService.latestGridInfo(formDTO)); + LatestGridInfoResultDTO data = resiMineGridService.latestGridInfo(formDTO); + //todo 兼容 一个老的 等删除这个if就行 + if ((data == null || StringUtils.isBlank(data.getGridId())&&"c2527f3d5cb8958583cc1348c328a784".equals(token.getCustomerId()))){ + return new Result().ok(null); + } + return new Result().ok(data); } /** diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccinePrarmeterDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccinePrarmeterDTO.java index 08c5da3ce1..a7d56eeec7 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccinePrarmeterDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccinePrarmeterDTO.java @@ -90,6 +90,7 @@ public class IcVaccinePrarmeterDTO implements Serializable { * 户口性质:0户籍 1外来 */ private String householdType; + private String householdTypeName; /** * 姓名 @@ -110,6 +111,7 @@ public class IcVaccinePrarmeterDTO implements Serializable { * 是否接种:0否1是 */ private String isVaccination; + private String isVaccinationName; /** * 第一次接种时间 @@ -181,4 +183,15 @@ public class IcVaccinePrarmeterDTO implements Serializable { */ private Date updatedTime; -} \ No newline at end of file + /** + * 审核状态:0待审核 1审核不通过 2审核通过 + */ + private String checkState; + private String checkStateName; + + /** + * 审核理由 + */ + private String checkReason; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java index 6ef7eb715e..5cc4b7ea6a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java @@ -54,7 +54,7 @@ public class EditInfoFormDTO implements Serializable { /** * 路牌号 */ - @NotBlank(message = "路牌号不能为空",groups = AddUserShowGroup.class) +// @NotBlank(message = "路牌号不能为空",groups = AddUserShowGroup.class) private String street; /** * 小区名称 diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GridInfoVaccinePrarmeterFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GridInfoVaccinePrarmeterFormDTO.java new file mode 100644 index 0000000000..18e124e529 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GridInfoVaccinePrarmeterFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 所属网格 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-06-20 + */ +@Data +public class GridInfoVaccinePrarmeterFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所属网格名称 + */ + private String gridName; + + /** + * 当前登录人组织ID + */ + private String agencyId; + + + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcVaccineCheckFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcVaccineCheckFormDTO.java new file mode 100644 index 0000000000..7eb317b62e --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcVaccineCheckFormDTO.java @@ -0,0 +1,79 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 新冠病毒疫苗接种人员信息台账-审核入参 + * + * @author wgf + * @since v1.0.0 2022-08-25 + */ +@Data +public class IcVaccineCheckFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @NotBlank(message = "Id不能为空") + private String id; + + /** + * 审核状态:0待审核 1未通过 2已通过 + */ + @NotBlank(message = "审核状态不能为空") + private String checkState; + + /** + * 审核原因 + */ + private String checkReason; + + /** + * 所属小区ID; + */ + private String villageId; + + /** + * 所属楼宇Id + */ + private String buildId; + + /** + * 单元号 + */ + private String unitId; + + /** + * 房间ID + */ + private String homeId; + + /** + * 房间号 + */ + private String homeName; + + /** + * 客户ID(审核人) + */ + private String customerId; + + /** + * 员工ID(审核人) + */ + private String userId; + + /** + * 员工姓名(审核人) + */ + private String realName; + + + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinePrarmeterListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinePrarmeterListFormDTO.java new file mode 100644 index 0000000000..4fbc71217b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinePrarmeterListFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author wgf + * @DateTime 2022/8/22 10:30 + * @DESC + */ +@Data +public class VaccinePrarmeterListFormDTO extends PageFormDTO implements Serializable { + + private static final long serialVersionUID = -498378993902522370L; + + /** + * 手机号 + */ + private String mobile; + + /** + * 地点名称 + */ + private String name; + + /** + * 证件号 + */ + private String idCard; + + private String isVaccination; + private String gridId; + private String villageId; + private String buildId; + private String unitId; + private String homeId; + + + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/IcResiPageNonDynamicFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/IcResiPageNonDynamicFormDTO.java new file mode 100644 index 0000000000..e5453cda85 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/resi/IcResiPageNonDynamicFormDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.form.resi; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class IcResiPageNonDynamicFormDTO extends PageFormDTO { + + private String gridId; + + private String name; + + private String mobile; + + /** + * 是否模糊。true:模糊,false:精确 + */ + private Boolean fuzzy = false; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/IcResiNonDynamicResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/IcResiNonDynamicResultDTO.java new file mode 100644 index 0000000000..52da33987e --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/resi/IcResiNonDynamicResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result.resi; + +import lombok.Data; + +/** + * 居民基础信息V2 + */ +@Data +public class IcResiNonDynamicResultDTO { + private String id; + private String name; + private String customerId; + private String agencyId; + private String gridId; + private String villageId; + private String buildId; + private String unitId; + private String homeId; + private String mobile; + private String idCard; + private String gender; + private String idCardType; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index e37454ed35..47a67e5fbd 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -3,12 +3,15 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; +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.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; +import com.epmet.dto.form.resi.IcResiPageNonDynamicFormDTO; import com.epmet.dto.result.*; +import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; import com.epmet.feign.fallback.EpmetUserOpenFeignClientFallbackFactory; import com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO; import org.springframework.cloud.openfeign.FeignClient; @@ -871,4 +874,12 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/customerstaff/customerstaff") Result> customerStaff(@RequestBody GridStaffUploadtFormDTO formDTO); + + /** + * 居民列表,非动态 + * @param input + * @return + */ + @PostMapping("/epmetuser/icresiuser/nonDynamic/listResi") + Result> listResiNonDynamic(@RequestBody IcResiPageNonDynamicFormDTO input); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 71711e66a8..7c9cc3b2a4 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -2,13 +2,16 @@ package com.epmet.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; +import com.epmet.dto.form.resi.IcResiPageNonDynamicFormDTO; import com.epmet.dto.result.*; +import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO; import org.springframework.web.bind.annotation.RequestBody; @@ -671,4 +674,8 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "customerStaff", formDTO); } + @Override + public Result> listResiNonDynamic(IcResiPageNonDynamicFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "listResiNonDynamic", input); + } } 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 7ac26844dd..3ef123383f 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 @@ -55,8 +55,10 @@ import com.epmet.constant.SystemMessageType; import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.*; +import com.epmet.dto.form.resi.IcResiPageNonDynamicFormDTO; import com.epmet.dto.result.*; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; import com.epmet.enums.IcResiUserTableEnum; import com.epmet.excel.PartyMemberAgeExportExcel; import com.epmet.excel.PartyMemberEducationExportExcel; @@ -1389,4 +1391,23 @@ public class IcResiUserController implements ResultDataResolver { return new Result().ok(icResiUserService.icUserMatchGrid(formDTO)); } + /** + * 居民列表分页查询 非动态 + * @param input + * @return + */ + @PostMapping("/nonDynamic/listResi") + public Result> listResiNonDynamic(@RequestBody IcResiPageNonDynamicFormDTO input) { + + String gridId = input.getGridId(); + String name = input.getName(); + Integer pageNo = input.getPageNo(); + Integer pageSize = input.getPageSize(); + Boolean fuzzy = input.getFuzzy(); + String mobile = input.getMobile(); + + PageData page = icResiUserService.listResiNonDynamic(fuzzy, gridId, name, mobile, pageNo, pageSize); + return new Result>().ok(page); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccinePrarmeterController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccinePrarmeterController.java index 102e5e0ea7..674686ca73 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccinePrarmeterController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccinePrarmeterController.java @@ -1,21 +1,40 @@ package com.epmet.controller; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.MaskResponse; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ExcelPoiUtils; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcVaccinePrarmeterDao; import com.epmet.dto.IcVaccinePrarmeterDTO; +import com.epmet.dto.form.IcVaccineCheckFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.form.VaccinePrarmeterListFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.excel.IcVaccinePrarmeterExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcVaccinePrarmeterService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,14 +47,23 @@ import java.util.Map; */ @RestController @RequestMapping("icVaccinePrarmeter") +@Slf4j public class IcVaccinePrarmeterController { @Autowired private IcVaccinePrarmeterService icVaccinePrarmeterService; + @Autowired + private IcVaccinePrarmeterDao icVaccinePrarmeterDao; + + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @RequestMapping("page") +// @MaskResponse(fieldNames = {"MOBILE", "ID_CARD"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) public Result> page(@RequestParam Map params){ - PageData page = icVaccinePrarmeterService.page(params); +// PageData page = icVaccinePrarmeterService.page(params); + PageData page = icVaccinePrarmeterService.getPhrasePage(params); return new Result>().ok(page); } @@ -55,7 +83,7 @@ public class IcVaccinePrarmeterController { } @NoRepeatSubmit - @PutMapping("update") + @PostMapping("update") public Result update(@RequestBody IcVaccinePrarmeterDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -77,6 +105,90 @@ public class IcVaccinePrarmeterController { ExcelUtils.exportExcelToTarget(response, null, list, IcVaccinePrarmeterExcel.class); } + /** + * Desc: 【新冠病毒疫苗接种人员信息台账】导出 + * @param response + * @param formDTO + * @param tokenDto + * @author wgf + * @date 2022/6/24 13:57 + */ + @PostMapping("vaccine-export") + public void vaccineExport(HttpServletResponse response, @RequestBody VaccinePrarmeterListFormDTO formDTO, @LoginUser TokenDto tokenDto) throws Exception { + ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class); + List list = icVaccinePrarmeterDao.vaccineExport(formDTO); + ExcelUtils.exportExcelToTarget(response, null, list, IcVaccinePrarmeterExcel.class); + + } + + /** + * 导出模板 + * @param response + * @throws Exception + */ + @PostMapping("exporttemplate") + public void exportTemplate( HttpServletResponse response) throws Exception { + TemplateExportParams templatePath = new TemplateExportParams("excel/ic_vaccine_prarmeter_excel.xls"); + ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"新冠病毒疫苗接种人员信息台账",response); + } + + /** + * Desc: 【新冠病毒疫苗接种人员信息台账】导入 + * @param + * @author wgf + * @date 2022/8/22 13:40 + */ + @PostMapping("importFile") + public Result importFile(@LoginUser TokenDto tokenDto, @RequestParam("file") MultipartFile file){ + if (file.isEmpty()) { + throw new EpmetException("请上传文件"); + } + // 校验文件类型 + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (!"xls".equals(extension) && !"xlsx".equals(extension)) { + throw new EpmetException("文件类型不匹配"); + } + + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.IC_VACCINE_PRARMETER); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new EpmetException(9999,"存在进行中的导入"); + } + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(tokenDto.getUserId()); + input.setTaskId(result.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + commonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); + } + icVaccinePrarmeterService.importFile(tokenDto,inputStream,result.getData().getTaskId()); + return new Result(); + } + + /** + * 信息采集-审核 + * @param formDTO + * @param tokenDto + * @return + */ + @PostMapping("vaccineCheck") + public Result vaccineCheck(@RequestBody IcVaccineCheckFormDTO formDTO, @LoginUser TokenDto tokenDto) { + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setCustomerId(tokenDto.getCustomerId()); + icVaccinePrarmeterService.vaccineCheck(formDTO,tokenDto); + + return new Result(); + } + + + } 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 index d4db61ad5b..55b4591be3 100644 --- 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 @@ -64,4 +64,12 @@ public interface IcVaccineDao extends BaseDao { IcVaccineDTO getVaccineDTO(@Param("customerId") String customerId, @Param("icVaccineId") String icVaccineId, @Param("idCard") String idCard, @Param("inoculateTime") String inoculateTime); + /** + * 根据身份证号以及接种时间查询接种信息 + * @param idCard + * @param time + * @return + */ + List getVaccineListByIdCard(@Param("idCard") String idCard,@Param("time") String time); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccinePrarmeterDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccinePrarmeterDao.java index a2e7c17a67..c5bdfcdbf7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccinePrarmeterDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccinePrarmeterDao.java @@ -1,9 +1,15 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcPointNucleicMonitoringDTO; +import com.epmet.dto.IcVaccinePrarmeterDTO; +import com.epmet.dto.form.VaccinePrarmeterListFormDTO; import com.epmet.entity.IcVaccinePrarmeterEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; +import java.util.Map; + /** * 新冠病毒疫苗接种人员信息台账 * @@ -12,5 +18,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcVaccinePrarmeterDao extends BaseDao { - -} \ No newline at end of file + + List vaccineExport(VaccinePrarmeterListFormDTO formDTO); + + /** + * 条件查询 + * @param params + * @return + */ + List getPhrasePage(Map params); + +} 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 index 60d80b3f61..6d087a1055 100644 --- 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 @@ -14,4 +14,8 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface IcVaccineRelationDao extends BaseDao { int delRelation(@Param("icVaccineId") String icNatId, @Param("agencyId") String agencyId); -} \ No newline at end of file + + void updateRelationInfoByVaccineId(IcVaccineRelationEntity icVaccineRelationEntity); + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccinePrarmeterEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccinePrarmeterEntity.java index c5dde0c103..c6b982f80d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccinePrarmeterEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccinePrarmeterEntity.java @@ -151,4 +151,14 @@ public class IcVaccinePrarmeterEntity extends BaseEpmetEntity { */ private String note; + /** + * 审核状态:0待审核 1审核不通过 2审核通过 + */ + private String checkState; + + /** + * 审核理由 + */ + private String checkReason; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterExcel.java index dc58b059b3..06cb0b9e15 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterExcel.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterExcel.java @@ -14,49 +14,28 @@ import java.util.Date; @Data public class IcVaccinePrarmeterExcel { - @Excel(name = "主键") - private String id; - @Excel(name = "客户Id customer.id") - private String customerId; - - @Excel(name = "网格ID") - private String gridId; @Excel(name = "网格名称") private String gridName; - @Excel(name = "组织Id") - private String agencyId; - - @Excel(name = "组织的pids") - private String pids; - - @Excel(name = "所属小区ID;") - private String villageId; @Excel(name = "所属小区名称") private String villageName; - @Excel(name = "所属楼宇Id") - private String buildId; @Excel(name = "所属楼宇名称") private String buildName; - @Excel(name = "单元id") - private String unitId; @Excel(name = "单元名") private String unitName; - @Excel(name = "所属家庭Id") - private String homeId; @Excel(name = "房间名") private String homeName; - @Excel(name = "户口性质:0户籍 1外来") + @Excel(name = "户口性质", replace = {"户籍_0","外来_1"}) private String householdType; @Excel(name = "姓名") @@ -65,10 +44,10 @@ public class IcVaccinePrarmeterExcel { @Excel(name = "联系电话") private String mobile; - @Excel(name = "身份证号") + @Excel(name = "证件号") private String idCard; - @Excel(name = "是否接种:0否1是") + @Excel(name = "是否接种", replace = {"否_0","是_1"}) private String isVaccination; @Excel(name = "第一次接种时间") @@ -89,29 +68,18 @@ public class IcVaccinePrarmeterExcel { @Excel(name = "第三次接种地点") private String thirdVacSite; - @Excel(name = "原因:禁忌症/拒绝接种/其他原因") + @Excel(name = "原因") private String reason; @Excel(name = "备注") private String note; - @Excel(name = "删除标识 0.未删除 1.已删除") - private Integer delFlag; - - @Excel(name = "乐观锁") - private Integer revision; - - @Excel(name = "创建人") - private String createdBy; - - @Excel(name = "创建时间") - private Date createdTime; + @Excel(name = "审核状态", replace = {"待审核_0","审核不通过_1","审核通过_2"}) + private String checkState; - @Excel(name = "更新人") - private String updatedBy; + @Excel(name = "审核理由") + private String checkReason; - @Excel(name = "更新时间") - private Date updatedTime; -} \ No newline at end of file +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterImportExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterImportExcel.java new file mode 100644 index 0000000000..3d9ed7a6a7 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterImportExcel.java @@ -0,0 +1,97 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; +import lombok.Data; + +import java.util.Date; + +/** + * 新冠病毒疫苗接种人员信息台账 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-22 + */ +@Data +public class IcVaccinePrarmeterImportExcel { + + @Excel(name = "所属网格") + private String gridName; + + @Excel(name = "所属小区") + private String villageName; + + @Excel(name = "所属楼宇") + private String buildName; + + @Excel(name = "单元") + private String unitName; + + @Excel(name = "所属家庭") + private String homeName; + + @Excel(name = "户口性质", replace = {"户籍_0","外来_1"}) + private String householdType; + + @Excel(name = "姓名") + private String name; + + @Excel(name = "联系电话") + private String mobile; + + @Excel(name = "证件号") + private String idCard; + + @Excel(name = "是否接种", replace = {"否_0","是_1"}) + private String isVaccination; + + @Excel(name = "第一次接种时间", format = "yyyy-MM-dd HH:mm:ss") + private String firstVacTime; + + @Excel(name = "第一次接种地点") + private String firstVacSite; + + @Excel(name = "第二次接种时间", format = "yyyy-MM-dd HH:mm:ss") + private String secondVacTime; + + @Excel(name = "第二次接种地点") + private String secondVacSite; + + @Excel(name = "第三次接种时间", format = "yyyy-MM-dd HH:mm:ss") + private String thirdVacTime; + + @Excel(name = "第三次接种地点") + private String thirdVacSite; + + @Excel(name = "原因") + private String reason; + + @Excel(name = "备注") + private String note; + + @ExcelIgnore + private Boolean addStatus = false; + + @ExcelIgnore + private Integer num; + + /** + * 所属网格ID + */ + @ExcelIgnore + private String gridId; + + /** + * 组织ID + */ + @ExcelIgnore + private String agencyId; + + /** + * 组织ID所有上级 + */ + @ExcelIgnore + private String pids; + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/IcVaccinePrarmeterImportErrorModel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/IcVaccinePrarmeterImportErrorModel.java new file mode 100644 index 0000000000..8cce05d852 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/IcVaccinePrarmeterImportErrorModel.java @@ -0,0 +1,77 @@ +package com.epmet.excel.error; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * @Author wgf + * @DateTime 2022/6/21 16:57 + * @DESC + */ +@Data +public class IcVaccinePrarmeterImportErrorModel { + + @Excel(name = "行号",width = 10) + private Integer num; + + + @Excel(name = "所属网格",width = 30) + private String gridName; + + @Excel(name = "所属小区",width = 30) + private String villageName; + + @Excel(name = "所属楼宇",width = 30) + private String buildName; + + @Excel(name = "单元",width = 30) + private String unitName; + + @Excel(name = "所属家庭",width = 30) + private String homeName; + + @Excel(name = "户口性质", width = 30, replace = {"户籍_0","外来_1"}) + private String householdType; + + @Excel(name = "姓名",width = 30) + private String name; + + @Excel(name = "联系电话",width = 30) + private String mobile; + + @Excel(name = "证件号",width = 30) + private String idCard; + + @Excel(name = "是否接种", width = 30, replace = {"否_0","是_1"}) + private String isVaccination; + + @Excel(name = "第一次接种时间",width = 30) + private String firstVacTime; + + @Excel(name = "第一次接种地点",width = 30) + private String firstVacSite; + + @Excel(name = "第二次接种时间",width = 30) + private String secondVacTime; + + @Excel(name = "第二次接种地点",width = 30) + private String secondVacSite; + + @Excel(name = "第三次接种时间",width = 30) + private String thirdVacTime; + + @Excel(name = "第三次接种地点",width = 30) + private String thirdVacSite; + + @Excel(name = "原因",width = 30) + private String reason; + + @Excel(name = "备注",width = 30) + private String note; + + @Excel(name = "错误信息", width = 200) + private String errorMsg; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index be03fdfc96..dd77ffba06 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.CommunityInfoResultDTO; +import com.epmet.dto.result.GridInfoByNameResultDTO; import com.epmet.dto.result.GridInfoResultDTO; import com.epmet.dto.result.IcHouseInfoCollectResultDTO; import com.epmet.feign.fallback.GovOrgFeignClientFallBack; @@ -74,6 +75,16 @@ public interface GovOrgFeignClient { @PostMapping("/gov/org/customeragency/getCommunityInfo") Result getCommunityInfo(OrgInfoPointFormDTO formDTO); + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author wgf + * @Description 根据网格名称查询所属网格信息 + * @Date 2020/4/26 23:16 + **/ + @PostMapping("/gov/org/customeragency/getGridInfoByGridName") + Result getGridInfoByGridName(GridInfoVaccinePrarmeterFormDTO formDTO); + /** * @param userId * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java index 77d306b310..a89cf10924 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.CommunityInfoResultDTO; +import com.epmet.dto.result.GridInfoByNameResultDTO; import com.epmet.dto.result.GridInfoResultDTO; import com.epmet.dto.result.IcHouseInfoCollectResultDTO; import com.epmet.feign.GovOrgFeignClient; @@ -46,6 +47,11 @@ public class GovOrgFeignClientFallBack implements GovOrgFeignClient { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCommunityInfo",formDTO); } + @Override + public Result getGridInfoByGridName(GridInfoVaccinePrarmeterFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridInfoByGridName",formDTO); + } + @Override public Result getCommunityInfoByUserId(String userId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCommunityInfoByUserId",userId); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java index 435b99f213..83b08d384e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java @@ -135,7 +135,7 @@ public class UserBaseInfoRedis { && StringUtils.isNotBlank(gridResult.getData().getBelongsGridName())){ String gridFullName = gridResult.getData().getBelongsGridName(); baseInfo.setRegisteredGridName(gridFullName); - StringBuffer buffer = new StringBuffer(gridFullName.split(ModuleConstant.DASH)[NumConstant.ONE]).append(ModuleConstant.DASH).append(baseInfo.getSurname()); + StringBuffer buffer = new StringBuffer(baseInfo.getSurname()); switch (baseInfo.getGender()) { case NumConstant.ONE_STR: buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_MALE); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java index 8aaf21fe7d..70d92655a5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java @@ -91,8 +91,8 @@ public interface IcPointNucleicMonitoringService extends BaseService { */ IcUserMatchGridResultDTO icUserMatchGrid(IcUserMatchGridFormDTO formDTO); + PageData listResiNonDynamic(Boolean fuzzy, String gridId, String name, String mobile, Integer pageNo, Integer pageSize); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccinePrarmeterService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccinePrarmeterService.java index c9f1e9de1e..41137212df 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccinePrarmeterService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccinePrarmeterService.java @@ -2,9 +2,13 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.IcVaccinePrarmeterDTO; +import com.epmet.dto.form.IcResiCollectCheckFormDTO; +import com.epmet.dto.form.IcVaccineCheckFormDTO; import com.epmet.entity.IcVaccinePrarmeterEntity; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -26,6 +30,13 @@ public interface IcVaccinePrarmeterService extends BaseService page(Map params); + /** + * 分页条件查询 + * @param params + * @return + */ + PageData getPhrasePage(Map params); + /** * 默认查询 * @@ -75,4 +86,20 @@ public interface IcVaccinePrarmeterService extends BaseService staffInfoList = new ArrayList<>(); userIds.forEach(staffId -> { CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), staffId); - if (staffInfo == null) { - log.error("getStaffInfoList fail customerId:{}, staffId:{} not exist in db", formDTO.getCustomerId(), staffId); - return; + if (null != staffInfo) { + StaffSinGridResultDTO resultDTO = new StaffSinGridResultDTO(); + resultDTO.setStaffId(staffId); + resultDTO.setStaffName(staffInfo.getRealName()); + resultDTO.setHeadPhoto(staffInfo.getHeadPhoto()); + resultDTO.setGender(staffInfo.getGender()); + + List roleInfoList = new ArrayList<>(); + staffInfo.getRoleMap().forEach((key, value) -> { + RoleResultDTO dto = new RoleResultDTO(); + dto.setRoleKey(key); + dto.setRoleName(value); + roleInfoList.add(dto); + }); + resultDTO.setRoleList(roleInfoList); + staffInfoList.add(resultDTO); } - StaffSinGridResultDTO resultDTO = new StaffSinGridResultDTO(); - resultDTO.setStaffId(staffId); - resultDTO.setStaffName(staffInfo.getRealName()); - resultDTO.setHeadPhoto(staffInfo.getHeadPhoto()); - resultDTO.setGender(staffInfo.getGender()); - - List roleInfoList = new ArrayList<>(); - staffInfo.getRoleMap().forEach((key, value) -> { - RoleResultDTO dto = new RoleResultDTO(); - dto.setRoleKey(key); - dto.setRoleName(value); - roleInfoList.add(dto); - }); - resultDTO.setRoleList(roleInfoList); - staffInfoList.add(resultDTO); }); /*List staffInfoList = customerStaffDao.getStaffInfoList(userIds); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 3976b304fc..2a57869b36 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -632,7 +632,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // ================== 数据补充 =================== IdCardRegexUtils regexUtilInstance = IdCardRegexUtils.parse(idCard); if (regexUtilInstance == null) { - String s = "请输入正确的证件号"; + String s = "证件号解析错误,或不支持的证件类型。(请使用身份证号或者护照号)"; throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s); } 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 0f55cab634..2f44c543d5 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 @@ -63,6 +63,7 @@ import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.result.*; import com.epmet.dto.result.demand.IcResiDemandDictDTO; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.resi.IcResiNonDynamicResultDTO; import com.epmet.entity.*; import com.epmet.excel.support.ExportResiUserItemDTO; import com.epmet.feign.*; @@ -3333,4 +3334,21 @@ public class IcResiUserServiceImpl extends BaseServiceImpl" + customer); return customer; } + + @Override + public PageData listResiNonDynamic(Boolean fuzzy, String gridId, String name, String mobile, Integer pageNo, Integer pageSize) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcResiUserEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); + query.eq(StringUtils.isNotBlank(gridId), IcResiUserEntity::getGridId, gridId); + // 一个模糊一个精确 + query.eq((!fuzzy && StringUtils.isNotBlank(name)), IcResiUserEntity::getName, name); + query.like((fuzzy && StringUtils.isNotBlank(name)), IcResiUserEntity::getName, name); + + query.eq((!fuzzy && StringUtils.isNotBlank(mobile)), IcResiUserEntity::getMobile, mobile); + query.like((fuzzy && StringUtils.isNotBlank(mobile)), IcResiUserEntity::getMobile, mobile); + + PageHelper.startPage(pageNo, pageSize); + List list = baseDao.selectList(query).stream().map((e) -> ConvertUtils.sourceToTarget(e, IcResiNonDynamicResultDTO.class)).collect(Collectors.toList()); + return new PageData(list, new PageInfo<>(list).getTotal(), pageSize); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccinePrarmeterServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccinePrarmeterServiceImpl.java index a30c43a58a..6edf94b941 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccinePrarmeterServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccinePrarmeterServiceImpl.java @@ -1,24 +1,75 @@ package com.epmet.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +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.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +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.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.ExcelPoiUtils; +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.IcVaccinePrarmeterDao; +import com.epmet.dao.IcVaccineRelationDao; import com.epmet.dto.IcVaccinePrarmeterDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.GridInfoByNameResultDTO; +import com.epmet.dto.result.IcHouseInfoCollectResultDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.entity.*; +import com.epmet.entity.IcResiUserEntity; +import com.epmet.entity.IcUserChangeRecordEntity; import com.epmet.entity.IcVaccinePrarmeterEntity; +import com.epmet.excel.IcVaccinePrarmeterImportExcel; +import com.epmet.excel.error.IcVaccinePrarmeterImportErrorModel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.GovOrgFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.redis.IcVaccinePrarmeterRedis; +import com.epmet.service.IcUserChangeRecordService; import com.epmet.service.IcVaccinePrarmeterService; +import lombok.SneakyThrows; +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.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; 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.util.Arrays; -import java.util.List; -import java.util.Map; +import javax.annotation.Resource; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 新冠病毒疫苗接种人员信息台账 @@ -27,11 +78,37 @@ import java.util.Map; * @since v1.0.0 2022-08-22 */ @Service -public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl implements IcVaccinePrarmeterService { +@Slf4j +public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl implements IcVaccinePrarmeterService,ResultDataResolver { - @Autowired + @Resource private IcVaccinePrarmeterRedis icVaccinePrarmeterRedis; + @Resource + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + + @Resource + private OssFeignClient ossFeignClient; + + @Resource + private GovOrgFeignClient govOrgFeignClient; + + @Resource + private IcResiUserDao icResiUserDao; + + @Resource + private IcUserChangeRecordService icUserChangeRecordService; + + @Resource + private IcVaccineDao icVaccineDao; + + @Resource + private IcVaccineRelationDao icVaccineRelationDao; + + @Autowired + private EpmetUserOpenFeignClient userOpenFeignClient; + + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -41,6 +118,18 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl getPhrasePage(Map params) { + IPage page = getPage(params); + List list = baseDao.getPhrasePage(params); + return new PageData<>(list, page.getTotal()); + } + @Override public List list(Map params) { List entityList = baseDao.selectList(getWrapper(params)); @@ -66,14 +155,26 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl errorInfo = new ArrayList<>(); + + try { + List list = ExcelPoiUtils.importExcel(inputStream, 0,1, IcVaccinePrarmeterImportExcel.class); + if (CollectionUtils.isEmpty(list)){ + closeTask(taskId,tokenDto.getUserId(), ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,""); + return; + } + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + if (null == staffInfo){ + throw new EpmetException("未查询到工作人员信息"+tokenDto.getUserId()); + } + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId()); + if (null == agencyInfo){ + throw new EpmetException("未查询到组织信息"+staffInfo.getAgencyId()); + } + + // 校验空单元格以及网格名称是否正确 + checkInfo(list,errorInfo,tokenDto); + + if (list.size() > errorInfo.size()){ + Map groupByName = list.stream().collect(Collectors.groupingBy(IcVaccinePrarmeterImportExcel::getName, Collectors.counting())); + groupByName.forEach((name,count) -> { + if (Integer.valueOf(count.toString()).compareTo(1) != 0){ + for (IcVaccinePrarmeterImportExcel i : list) { + if (name.equals(i.getName()) && !i.getAddStatus()){ + errorInfo.add(getErrorInfo(i,"数据重复",i.getNum())); + i.setAddStatus(true); + } + } + } + }); + } + Map> groupByStatus = list.stream().collect(Collectors.groupingBy(IcVaccinePrarmeterImportExcel::getAddStatus)); + List needInsert = groupByStatus.get(false); + if (CollectionUtils.isNotEmpty(needInsert)){ + List entities = ConvertUtils.sourceToTarget(needInsert, IcVaccinePrarmeterEntity.class); + entities.forEach(e -> { + // 设置客户ID + e.setCustomerId(tokenDto.getCustomerId()); + // 设置审核状态为待审核 + e.setCheckState("0"); + }); + insertBatch(entities); + } + if (CollectionUtils.isNotEmpty(errorInfo)){ + String url = importOssUpload(errorInfo, IcVaccinePrarmeterImportErrorModel.class); + closeTask(taskId,tokenDto.getUserId(), ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,url); + }else { + closeTask(taskId,tokenDto.getUserId(),ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS,""); + } + }catch (Exception e){ + log.error(e.getMessage()); + closeTask(taskId,tokenDto.getUserId(),ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,""); + } + } + + /** + * 校验空单元格以及网格名称是否正确 + * @param list + * @param errorInfo + * @param tokenDto + */ + public void checkInfo(List list, List errorInfo, TokenDto tokenDto){ + LoginUserDetailsFormDTO form = new LoginUserDetailsFormDTO(); + form.setUserId(tokenDto.getUserId()); + form.setClient(tokenDto.getClient()); + form.setApp(tokenDto.getApp()); + LoginUserDetailsResultDTO userDetailsResultDTO = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(form), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.SERVER_ERROR.getCode(), + "获取当前登录人组织id失败", + null); + + for (int i = 0; i < list.size(); i++) { + list.get(i).setNum(i+1); + if (StringUtils.isBlank(list.get(i).getGridName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "所属网格不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getVillageName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "所属小区不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getBuildName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "所属楼宇不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getUnitName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "单元不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getHomeName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "门牌号不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "姓名不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getIdCard()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "证件号不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getMobile()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "咨询电话不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getIsVaccination()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "是否接种不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if("0".equals(list.get(i).getIsVaccination())){ + // 未接种 判断是否填写原因 + if (StringUtils.isBlank(list.get(i).getReason()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "选择未接种时,原因不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if("其他原因".equals(list.get(i).getReason())){ + // 未接种原因选择其他,判断是否填写备注 + if (StringUtils.isBlank(list.get(i).getNote()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "选择其他原因时,备注不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + } + + }else{ + // 已接种 判断是否填写接种时间地点 + if (StringUtils.isBlank(list.get(i).getFirstVacTime()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "第一次接种时间不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + if (StringUtils.isBlank(list.get(i).getFirstVacSite()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "第一次接种地点不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } +// if (StringUtils.isBlank(list.get(i).getSecondVacTime()) && !list.get(i).getAddStatus()){ +// errorInfo.add(getErrorInfo(list.get(i), "第二次接种时间不能为空",i+1)); +// list.get(i).setAddStatus(true); +// continue; +// } +// if (StringUtils.isBlank(list.get(i).getSecondVacSite()) && !list.get(i).getAddStatus()){ +// errorInfo.add(getErrorInfo(list.get(i), "第二次接种地点不能为空",i+1)); +// list.get(i).setAddStatus(true); +// continue; +// } +// if (StringUtils.isBlank(list.get(i).getThirdVacTime()) && !list.get(i).getAddStatus()){ +// errorInfo.add(getErrorInfo(list.get(i), "第三次接种时间不能为空",i+1)); +// list.get(i).setAddStatus(true); +// continue; +// } +// if (StringUtils.isBlank(list.get(i).getThirdVacSite()) && !list.get(i).getAddStatus()){ +// errorInfo.add(getErrorInfo(list.get(i), "第三次接种地点不能为空",i+1)); +// list.get(i).setAddStatus(true); +// continue; +// } + } + + // 校验所属网格通过名称能否匹配到ID + GridInfoVaccinePrarmeterFormDTO formDTO = new GridInfoVaccinePrarmeterFormDTO(); + formDTO.setGridName(list.get(i).getGridName()); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setAgencyId(userDetailsResultDTO.getAgencyId()); + Result resultDTOResult = govOrgFeignClient.getGridInfoByGridName(formDTO); + GridInfoByNameResultDTO gridInfoByNameResultDTO = resultDTOResult.getData(); + if(gridInfoByNameResultDTO == null && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "所属网格匹配失败",i+1)); + list.get(i).setAddStatus(true); + continue; + }else{ + list.get(i).setGridId(gridInfoByNameResultDTO.getDeptId()); + list.get(i).setAgencyId(gridInfoByNameResultDTO.getPid()); + list.get(i).setPids(gridInfoByNameResultDTO.getPids()); + } + + } + } + + /** + * Desc: 文件上传并返回url + * @param errorRows + * @param tClass + * @author wgf + * @date 2022/8/23 09:16 + */ + public String importOssUpload(Collection errorRows, Class tClass) throws IOException { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"), + tClass, errorRows); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("调用OSS上传结果描述文件失败"); + return null; + } + return uploadResult.getData().getUrl(); + } + + /** + * Desc: 关闭任务 + * @param taskId + * @param userId + * @param status + * @param url + * @author wgf + * @date 2022/8/23 09:05 + */ + public void closeTask(String taskId,String userId,String status,String url){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(userId); + input.setTaskId(taskId); + input.setProcessStatus(status); + input.setResultDescFilePath(url); + commonServiceOpenFeignClient.finishImportTask(input); + } + + /** + * Desc: 构造错误信息 + * @param dto + * @param info + * @param num + * @author wgf + * @date 2022/8/23 17:17 + */ + public IcVaccinePrarmeterImportErrorModel getErrorInfo(IcVaccinePrarmeterImportExcel dto, String info, Integer num){ + IcVaccinePrarmeterImportErrorModel result = ConvertUtils.sourceToTarget(dto, IcVaccinePrarmeterImportErrorModel.class); + result.setErrorMsg(info); + result.setNum(num); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void vaccineCheck(IcVaccineCheckFormDTO formDTO, TokenDto tokenDto) { + + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(),tokenDto.getUserId()); + formDTO.setRealName(staffInfo.getRealName()); + + // 获取新冠病毒疫苗接种人员信息台账表信息 + IcVaccinePrarmeterEntity icVaccinePrarmeterEntity = baseDao.selectById(formDTO.getId()); + + // 更新审核信息 + icVaccinePrarmeterEntity.setCheckState(formDTO.getCheckState()); + icVaccinePrarmeterEntity.setCheckReason(formDTO.getCheckReason()); + icVaccinePrarmeterEntity.setVillageId(formDTO.getVillageId()); + icVaccinePrarmeterEntity.setBuildId(formDTO.getBuildId()); + icVaccinePrarmeterEntity.setUnitId(formDTO.getUnitId()); + icVaccinePrarmeterEntity.setHomeId(formDTO.getHomeId()); + + baseDao.updateById(icVaccinePrarmeterEntity); + + // 审核状态:0待审核 1未通过 2已通过 + if("2".equals(formDTO.getCheckState())){ + + String icResiUserId = ""; + + // 根据身份证号和房屋ID获取人员信息 + IcResiUserEntity userIdCardEntity = queryOriginUserByIdCard(icVaccinePrarmeterEntity.getIdCard(),icVaccinePrarmeterEntity.getCustomerId()); + + if(StringUtils.isBlank(icVaccinePrarmeterEntity.getHomeId())){ + // 新增房屋(新增房屋操作已在审核接口之前,前端调用新增接口实现) + // 更新登记表房屋ID + icVaccinePrarmeterEntity = updateHomeId(icVaccinePrarmeterEntity,formDTO); + + if(userIdCardEntity != null){ + icResiUserId = userIdCardEntity.getId(); + // 已存在人员 人员房屋不一致(更新人员信息和变更记录) + updateUserInfo(icVaccinePrarmeterEntity,true,formDTO,userIdCardEntity); + }else{ + // 不存在人员 + icResiUserId = insertUserInfo(icVaccinePrarmeterEntity,formDTO); + } + }else{ + // 更新房屋 + updateHouseInfo(icVaccinePrarmeterEntity); + + Map userMap = queryOriginUserByHomeId(icVaccinePrarmeterEntity.getHomeId(),icVaccinePrarmeterEntity.getCustomerId()); + if(userIdCardEntity != null){ + icResiUserId = userIdCardEntity.getId(); + // 已存在人员 + if(userMap.containsKey(icVaccinePrarmeterEntity.getIdCard())){ + // 人员房屋一致(只更新人员信息) + updateUserInfo(icVaccinePrarmeterEntity,false,formDTO,userIdCardEntity); + }else{ + // 人员房屋不一致(更新人员信息和变更记录) + updateUserInfo(icVaccinePrarmeterEntity,true,formDTO,userIdCardEntity); + } + }else{ + // 不存在人员 + icResiUserId = insertUserInfo(icVaccinePrarmeterEntity,formDTO); + } + } + + // 同步接种记录 and 疫苗接种记录关系 + synchronizationVaccineInfo(icVaccinePrarmeterEntity,icResiUserId); + + + } + } + + /** + * 同步接种记录 and 疫苗接种记录关系 + * @param icVaccinePrarmeterEntity + * @param icResiUserId + */ + @SneakyThrows + private void synchronizationVaccineInfo(IcVaccinePrarmeterEntity icVaccinePrarmeterEntity,String icResiUserId){ + if(!"1".equals(icVaccinePrarmeterEntity.getIsVaccination())){ + return; + } + // 同步接种记录 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // 处理第一次接种时间格式 + String firstTime = icVaccinePrarmeterEntity.getFirstVacTime(); + if(StringUtils.isBlank(firstTime)){ + return; + } + Date firstDate = sdf.parse(firstTime); + icVaccinePrarmeterEntity.setFirstVacTime(sdf.format(firstDate)); + // 查询第一次接种信息 + List icVaccineEntityFirstList = icVaccineDao.getVaccineListByIdCard(icVaccinePrarmeterEntity.getIdCard(),sdf.format(firstDate)); + if(icVaccineEntityFirstList.size() > 0){ + // 更新疫苗接种记录 and 疫苗接种记录关系 + for(IcVaccineEntity entity : icVaccineEntityFirstList){ + updateVaccineInfo(entity,icVaccinePrarmeterEntity); + + } + + }else{ + // 新增疫苗接种记录 and 疫苗接种记录关系 + insertVaccineInfo(icVaccinePrarmeterEntity,icResiUserId,firstDate); + + } + + // 处理第二次接种时间格式 + String secondTime = icVaccinePrarmeterEntity.getSecondVacTime(); + if(StringUtils.isBlank(secondTime)){ + return; + } + Date secondDate = sdf.parse(secondTime); + icVaccinePrarmeterEntity.setSecondVacTime(sdf.format(secondDate)); + // 查询第二次接种信息 + List icVaccineEntitySecondList = icVaccineDao.getVaccineListByIdCard(icVaccinePrarmeterEntity.getIdCard(),sdf.format(secondDate)); + if(icVaccineEntitySecondList.size() > 0){ + // 更新疫苗接种记录 and 疫苗接种记录关系 + for(IcVaccineEntity entity : icVaccineEntitySecondList){ + updateVaccineInfo(entity,icVaccinePrarmeterEntity); + + } + + }else{ + // 新增疫苗接种记录 and 疫苗接种记录关系 + insertVaccineInfo(icVaccinePrarmeterEntity,icResiUserId,firstDate); + + } + + // 处理第三次接种时间格式 + String thirdTime = icVaccinePrarmeterEntity.getThirdVacTime(); + if(StringUtils.isBlank(thirdTime)){ + return; + } + Date thirdDate = sdf.parse(thirdTime); + icVaccinePrarmeterEntity.setThirdVacTime(sdf.format(thirdDate)); + // 查询第三次接种信息 + List icVaccineEntityThirdList = icVaccineDao.getVaccineListByIdCard(icVaccinePrarmeterEntity.getIdCard(),sdf.format(thirdDate)); + if(icVaccineEntityThirdList.size() > 0){ + // 更新疫苗接种记录 and 疫苗接种记录关系 + for(IcVaccineEntity entity : icVaccineEntityThirdList){ + updateVaccineInfo(entity,icVaccinePrarmeterEntity); + + } + + }else{ + // 新增疫苗接种记录 and 疫苗接种记录关系 + insertVaccineInfo(icVaccinePrarmeterEntity,icResiUserId,firstDate); + + } + } + + /** + * 更新疫苗接种记录 and 疫苗接种记录关系 + * @param entity + * @param icVaccinePrarmeterEntity + */ + private void updateVaccineInfo(IcVaccineEntity entity,IcVaccinePrarmeterEntity icVaccinePrarmeterEntity){ + // 更新疫苗接种记录 + entity.setInoculateAddress(icVaccinePrarmeterEntity.getFirstVacSite()); + entity.setUserType("prarmeter"); + entity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + icVaccineDao.updateById(entity); + + // 更新疫苗接种记录关系 + IcVaccineRelationEntity icVaccineRelationEntity = new IcVaccineRelationEntity(); + icVaccineRelationEntity.setIcVaccineId(entity.getId()); + icVaccineRelationEntity.setUserType("prarmeter"); + icVaccineRelationEntity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + icVaccineRelationDao.updateRelationInfoByVaccineId(icVaccineRelationEntity); + + } + + /** + * 新增疫苗接种记录 and 疫苗接种记录关系 + * @param icVaccinePrarmeterEntity + * @param icResiUserId + * @param time + */ + private void insertVaccineInfo(IcVaccinePrarmeterEntity icVaccinePrarmeterEntity,String icResiUserId,Date time){ + IcVaccineEntity icVaccineEntity = new IcVaccineEntity(); + icVaccineEntity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + icVaccineEntity.setName(icVaccinePrarmeterEntity.getName()); + icVaccineEntity.setMobile(icVaccinePrarmeterEntity.getMobile()); + icVaccineEntity.setIdCard(icVaccinePrarmeterEntity.getIdCard()); + icVaccineEntity.setIsResiUser("1"); + icVaccineEntity.setUserType("prarmeter"); + icVaccineEntity.setUserId(icResiUserId); + icVaccineEntity.setInoculateTime(time); + icVaccineEntity.setInoculateAddress(icVaccinePrarmeterEntity.getFirstVacSite()); + icVaccineDao.insert(icVaccineEntity); + + // 新增关系 + IcVaccineRelationEntity icVaccineRelationEntity = new IcVaccineRelationEntity(); + icVaccineRelationEntity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + icVaccineRelationEntity.setAgencyId(icVaccinePrarmeterEntity.getAgencyId()); + icVaccineRelationEntity.setPids(icVaccinePrarmeterEntity.getPids()); + icVaccineRelationEntity.setIcVaccineId(icVaccineEntity.getId()); + icVaccineRelationEntity.setUserType("prarmeter"); + icVaccineRelationDao.insert(icVaccineRelationEntity); + } + + /** + * 更新新冠病毒疫苗接种人员信息台账表房屋ID + * @param icVaccinePrarmeterEntity + * @param formDTO + * @return + */ + private IcVaccinePrarmeterEntity updateHomeId(IcVaccinePrarmeterEntity icVaccinePrarmeterEntity,IcVaccineCheckFormDTO formDTO){ + + // fegin获取房屋信息 + GetHouseInfoToCollectFormDTO getHouseInfoToCollectFormDTO = new GetHouseInfoToCollectFormDTO(); + getHouseInfoToCollectFormDTO.setBuildingUnitId(formDTO.getUnitId()); + getHouseInfoToCollectFormDTO.setDoorName(formDTO.getHomeName()); + Result resultDTOResult = govOrgFeignClient.getHouseInfoToCollect(getHouseInfoToCollectFormDTO); + IcHouseInfoCollectResultDTO icHouseInfoCollectResultDTO = resultDTOResult.getData(); + + // 新增房屋后需要collect更新上房屋ID + // log + icVaccinePrarmeterEntity.setHomeId(icHouseInfoCollectResultDTO.getId()); + baseDao.updateById(icVaccinePrarmeterEntity); + return icVaccinePrarmeterEntity; + + } + + /** + * 更新房屋信息 + * @param icVaccinePrarmeterEntity + */ + private void updateHouseInfo(IcVaccinePrarmeterEntity icVaccinePrarmeterEntity){ + CollectHouseFormDTO collectHouseFormDTO = new CollectHouseFormDTO(); + collectHouseFormDTO.setId(icVaccinePrarmeterEntity.getHomeId()); + + + // fegin获取房屋信息 + GetHouseInfoToCollectFormDTO getHouseInfoToCollectFormDTO = new GetHouseInfoToCollectFormDTO(); + getHouseInfoToCollectFormDTO.setBuildingUnitId(icVaccinePrarmeterEntity.getUnitId()); + getHouseInfoToCollectFormDTO.setDoorName(icVaccinePrarmeterEntity.getHomeName()); + Result resultDTOResult = govOrgFeignClient.getHouseInfoToCollect(getHouseInfoToCollectFormDTO); + IcHouseInfoCollectResultDTO icHouseInfoCollectResultDTO = resultDTOResult.getData(); + + collectHouseFormDTO.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + collectHouseFormDTO.setResiNumber((icHouseInfoCollectResultDTO.getResiNumber() + 1)); + collectHouseFormDTO.setRentFlag(icHouseInfoCollectResultDTO.getRentFlag()); + collectHouseFormDTO.setOwnerName(icHouseInfoCollectResultDTO.getOwnerName()); + govOrgFeignClient.updateCollect(collectHouseFormDTO); + + } + + /** + * 获取人员信息 + * @param idCard + * @return + */ + private IcResiUserEntity queryOriginUserByIdCard(String idCard,String customerId) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcResiUserEntity::getIdCard, idCard); + query.eq(IcResiUserEntity::getCustomerId, customerId); + IcResiUserEntity originUser = icResiUserDao.selectOne(query); + return originUser; + } + + private Map queryOriginUserByHomeId(String homeId,String customerId) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcResiUserEntity::getHomeId, homeId); + query.eq(IcResiUserEntity::getCustomerId, customerId); + List originUserList = icResiUserDao.selectList(query); + Map memMap = originUserList.stream().collect(Collectors.toMap(IcResiUserEntity::getIdCard, Function.identity())); + return memMap; + } + + /** + * 更新人员信息 + * @param icVaccinePrarmeterEntity 登记信息 + * @param isUpdateLog 是否更新记录 + * @param formDTO 入参 + * @param userEntity 根据身份证号查询到的user信息 + */ + private void updateUserInfo(IcVaccinePrarmeterEntity icVaccinePrarmeterEntity,Boolean isUpdateLog, + IcVaccineCheckFormDTO formDTO,IcResiUserEntity userEntity){ + + userEntity.setPids(icVaccinePrarmeterEntity.getPids()); // ic_resi_user表的组织的pids 含agencyId本身 + userEntity.setAgencyId(icVaccinePrarmeterEntity.getAgencyId()); + userEntity.setGridId(icVaccinePrarmeterEntity.getGridId()); + userEntity.setVillageId(icVaccinePrarmeterEntity.getVillageId()); + userEntity.setBuildId(icVaccinePrarmeterEntity.getBuildId()); + userEntity.setUnitId(icVaccinePrarmeterEntity.getUnitId()); + userEntity.setHomeId(icVaccinePrarmeterEntity.getHomeId()); + userEntity.setName(icVaccinePrarmeterEntity.getName()); + userEntity.setMobile(icVaccinePrarmeterEntity.getMobile()); + userEntity.setIdCard(icVaccinePrarmeterEntity.getIdCard()); + icResiUserDao.updateById(userEntity); + + // 判断是否需要更新记录 + if(isUpdateLog){ + //变更记录表 + IcUserChangeRecordEntity changeRecordEntity = new IcUserChangeRecordEntity(); + changeRecordEntity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + changeRecordEntity.setOperatorId(formDTO.getUserId()); + changeRecordEntity.setIcUserId(userEntity.getId()); + changeRecordEntity.setOperatorName(formDTO.getRealName()); + changeRecordEntity.setIcUserName(userEntity.getName()); + changeRecordEntity.setType("update"); + changeRecordEntity.setTypeName("修改"); + changeRecordEntity.setBeforeChangeName("-"); + changeRecordEntity.setAfterChangeName("-"); + changeRecordEntity.setChangeTime(new java.util.Date()); + icUserChangeRecordService.insert(changeRecordEntity); + } + + } + + /** + * 新增人员信息 + * @param icVaccinePrarmeterEntity + * @param formDTO + */ + private String insertUserInfo(IcVaccinePrarmeterEntity icVaccinePrarmeterEntity,IcVaccineCheckFormDTO formDTO){ + + // 新增人员 + IcResiUserEntity userEntity = new IcResiUserEntity(); + userEntity.setPids(icVaccinePrarmeterEntity.getPids()); // ic_resi_user表的组织的pids 含agencyId本身 + userEntity.setAgencyId(icVaccinePrarmeterEntity.getAgencyId()); + userEntity.setGridId(icVaccinePrarmeterEntity.getGridId()); + userEntity.setVillageId(icVaccinePrarmeterEntity.getVillageId()); + userEntity.setBuildId(icVaccinePrarmeterEntity.getBuildId()); + userEntity.setUnitId(icVaccinePrarmeterEntity.getUnitId()); + userEntity.setHomeId(icVaccinePrarmeterEntity.getHomeId()); + userEntity.setName(icVaccinePrarmeterEntity.getName()); + userEntity.setMobile(icVaccinePrarmeterEntity.getMobile()); + userEntity.setIdCard(icVaccinePrarmeterEntity.getIdCard()); + userEntity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + icResiUserDao.insert(userEntity); + + //变更记录表 + IcUserChangeRecordEntity changeRecordEntity = new IcUserChangeRecordEntity(); + changeRecordEntity.setCustomerId(icVaccinePrarmeterEntity.getCustomerId()); + changeRecordEntity.setOperatorId(formDTO.getUserId()); + changeRecordEntity.setIcUserId(userEntity.getId()); + changeRecordEntity.setOperatorName(formDTO.getRealName()); + changeRecordEntity.setIcUserName(userEntity.getName()); + changeRecordEntity.setType("add"); + changeRecordEntity.setTypeName("新增"); + changeRecordEntity.setBeforeChangeName("-"); + changeRecordEntity.setAfterChangeName("-"); + changeRecordEntity.setChangeTime(new java.util.Date()); + icUserChangeRecordService.insert(changeRecordEntity); + + return userEntity.getId(); + + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java index bf7f42d6f9..d853d884dc 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java @@ -37,10 +37,10 @@ import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.RegisterRelationDTO; import com.epmet.dto.UserResiInfoDTO; import com.epmet.dto.form.*; +import com.epmet.dto.result.NewUserRoleResultDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.UserInfoOnEnterGridResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO; -import com.epmet.dto.result.NewUserRoleResultDTO; import com.epmet.entity.RegisterRelationEntity; import com.epmet.entity.UserCustomerEntity; import com.epmet.feign.GovOrgFeignClient; @@ -212,8 +212,14 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl registerRecordWithDiffCustAndGrid = diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 4cccbd7bf4..56a5f56400 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -194,16 +194,16 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl select id, NAME,MOBILE from ic_resi_user - WHERE DEL_FLAG = '0' + WHERE 1=1 id = #{icResiUserId} 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 index 0ed766fb77..b8113074cf 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml @@ -174,4 +174,13 @@ m.ID_CARD = t.ID_CARD AND m.DEL_FLAG = '0' + + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccinePrarmeterDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccinePrarmeterDao.xml index 363554832c..b06633761b 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccinePrarmeterDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccinePrarmeterDao.xml @@ -39,5 +39,147 @@ + - \ No newline at end of file + + + + 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 index 011c1c7de1..acaf54c95f 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineRelationDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineRelationDao.xml @@ -12,5 +12,10 @@ AND AGENCY_ID = #{agencyId} + + update ic_vaccine_relation + set CUSTOMER_ID = #{customerId},USER_TYPE = #{userType} + where IC_VACCINE_ID = #{icVaccineId} + - \ No newline at end of file + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml index d308058d06..8267ec45ba 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml @@ -62,8 +62,6 @@ uri.RESI_VISIT_ID, ubi.BUILDING_ADDRESS, CONCAT( - ubi.STREET, - '-', ubi.SURNAME, ( CASE WHEN ubi.GENDER = '1' THEN '先生' WHEN ubi.GENDER = '2' THEN '女士' ELSE '先生/女士' END ) ) AS show_name, @@ -83,8 +81,6 @@ SELECT uri.USER_ID, CONCAT( - uri.STREET, - '-', uri.SURNAME, ( CASE WHEN uw.SEX = '1' THEN '先生' WHEN uw.SEX = '2' THEN '女士' ELSE '先生/女士' END ) ) AS show_name @@ -121,8 +117,6 @@ ubi.DISTRICT, ubi.BUILDING_ADDRESS, CONCAT( - ubi.STREET, - '-', ubi.SURNAME, ( CASE WHEN ubi.GENDER = '1' THEN '先生' WHEN ubi.GENDER = '2' THEN '女士' ELSE '先生/女士' END ) ) AS show_name, @@ -141,8 +135,6 @@ SELECT CONCAT( - uri.street, - '-', uri.surname, CASE WHEN uri.GENDER = '1' THEN @@ -184,8 +172,6 @@ END ) AS issueInitiator, CONCAT( - uri.street, - '-', uri.surname, uri.NAME ) AS realUserName