Browse Source
# Conflicts: # epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.javamaster
442 changed files with 20129 additions and 688 deletions
@ -0,0 +1,8 @@ |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1560458000894500866', 'icpartyact_auto_publish_time', '党组织活动自动发布时间', '党组织活动自动发布时间', 35, 0, 0, '1', '2022-08-19 10:45:54', '1', '2022-08-19 10:46:11'); |
|||
|
|||
|
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1560458233091170305', 1560458000894500866, '活动开始前1天', '1', '0', '活动开始前1天', 1, 0, 0, '1', '2022-08-19 10:46:49', '1', '2022-08-19 10:46:49'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1560458276439302146', 1560458000894500866, '活动开始前3天', '3', '0', '活动开始前3天', 2, 0, 0, '1', '2022-08-19 10:47:00', '1', '2022-08-19 10:47:00'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1560458332076744705', 1560458000894500866, '活动开始前5天', '5', '0', '活动开始前5天', 3, 0, 0, '1', '2022-08-19 10:47:13', '1', '2022-08-19 10:47:13'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1560458388007788545', 1560458000894500866, '活动开始前7天', '7', '0', '活动开始前7天', 4, 0, 0, '1', '2022-08-19 10:47:26', '1', '2022-08-19 10:47:26'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1561627442626142210', 1560458000894500866, '现在发布', '0', '0', '', 5, 0, 0, '1', '2022-08-22 16:12:51', '1', '2022-08-22 16:12:51'); |
|||
@ -0,0 +1,17 @@ |
|||
package com.epmet.commons.feignclient.dtos.result; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
/** |
|||
* 报表简要信息result dto |
|||
*/ |
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class JiMuReportBriefResultDTO { |
|||
private String id; |
|||
private String code; |
|||
private String name; |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 党建小助手发布活动、活动到期提醒、活动发布提醒推送MQ |
|||
* @author sun |
|||
*/ |
|||
@Data |
|||
public class PartyMeetingMessageMQMsg extends MqBaseFormDTO implements Serializable { |
|||
|
|||
//客户Id
|
|||
private String customerId; |
|||
//活动/日程Id
|
|||
private String icPartyActId; |
|||
//动作类型 发布活动:publish 提前提醒:remind 日程通知:notify
|
|||
private String type; |
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
/** |
|||
* 唯一整件类型 |
|||
*/ |
|||
public enum IdCardTypeEnum { |
|||
|
|||
OTHERS("0", "其他"), |
|||
SFZH("1", "身份证号"), |
|||
PASSPORT("2", "护照"); |
|||
|
|||
private String type; |
|||
private String name; |
|||
|
|||
IdCardTypeEnum(String type, String name) { |
|||
this.type = type; |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getType() { |
|||
return type; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
} |
|||
@ -0,0 +1,155 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
import com.epmet.commons.tools.enums.IdCardTypeEnum; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.time.DateTimeException; |
|||
import java.time.LocalDate; |
|||
import java.time.Period; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
/** |
|||
* 唯一整件正则工具 |
|||
*/ |
|||
public class IdCardRegexUtils { |
|||
|
|||
/** |
|||
* 15位身份证号的正则表达式 |
|||
*/ |
|||
private static final Pattern PATTERN_15_ID = Pattern.compile("^\\d{6}(?<year>\\d{2})(?<month>0[1-9]|1[0-2])(?<day>[0-2][0-9]|3[0-1])\\d{2}(?<sex>\\d)$"); |
|||
/** |
|||
* 18位身份证号的正则表达式 |
|||
*/ |
|||
private static final Pattern PATTERN_18_ID = Pattern.compile("^\\d{6}(?<year>\\d{4})(?<month>0[1-9]|1[0-2])(?<day>[0-2][0-9]|3[0-1])\\d{2}(?<sex>\\d)[0-9a-xA-X]$"); |
|||
|
|||
/** |
|||
* 9位护照 |
|||
*/ |
|||
private static final Pattern PATTERN_9_PASSPORT = Pattern.compile("^[a-zA-Z0-9]{8,9}$"); |
|||
|
|||
private String inputText; |
|||
|
|||
private Matcher matcher; |
|||
|
|||
private IdCardTypeEnum idCardType; |
|||
|
|||
private IdCardRegexUtils(IdCardTypeEnum idCardType, Matcher matcher, String inputText) { |
|||
this.idCardType = idCardType; |
|||
this.matcher = matcher; |
|||
this.inputText = inputText; |
|||
} |
|||
|
|||
/** |
|||
* 正则解析结果 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public static class ParsedContent { |
|||
private String birthdayYear; |
|||
private String birthdayMonth; |
|||
private String birthdayDay; |
|||
private String sex; |
|||
private Integer age; |
|||
} |
|||
|
|||
/** |
|||
* desc:校验输入的证件号是否合法 |
|||
* @param input |
|||
* @return |
|||
*/ |
|||
public static boolean validateIdCard(String input){ |
|||
IdCardRegexUtils parse = IdCardRegexUtils.parse(input); |
|||
return parse != null; |
|||
} |
|||
|
|||
/** |
|||
* 解析正则 |
|||
* @param input |
|||
* @return |
|||
*/ |
|||
public static IdCardRegexUtils parse(String input) { |
|||
if (input == null || input.trim().length() == 0) { |
|||
return null; |
|||
} |
|||
|
|||
if (input.length() == 15) { |
|||
Matcher matcher = PATTERN_15_ID.matcher(input); |
|||
if (matcher.matches()) { |
|||
return new IdCardRegexUtils(IdCardTypeEnum.SFZH, matcher, input); |
|||
} |
|||
} |
|||
|
|||
if (input.length() == 18) { |
|||
Matcher matcher = PATTERN_18_ID.matcher(input); |
|||
if (matcher.matches()) { |
|||
return new IdCardRegexUtils(IdCardTypeEnum.SFZH, matcher, input); |
|||
} |
|||
} |
|||
|
|||
if (input.length() == 9 || input.length() == 8) { |
|||
Matcher matcher = PATTERN_9_PASSPORT.matcher(input); |
|||
if (matcher.matches()) { |
|||
return new IdCardRegexUtils(IdCardTypeEnum.PASSPORT, matcher, input); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 获取解析结果 |
|||
* @return |
|||
*/ |
|||
public ParsedContent getParsedResult() { |
|||
if (matcher == null || idCardType == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (IdCardTypeEnum.SFZH == idCardType) { |
|||
//是身份证号,可以解析
|
|||
String year; |
|||
if (inputText.length() == 15) { |
|||
// 15位身份证号,years前需要拼上19
|
|||
year = "19".concat(matcher.group("year")); |
|||
} else { |
|||
year = matcher.group("year"); |
|||
} |
|||
String month = matcher.group("month"); |
|||
String day = matcher.group("day"); |
|||
String sex = matcher.group("sex"); |
|||
|
|||
// ------- 年龄Start----------
|
|||
Integer age; |
|||
try { |
|||
LocalDate birthday = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day)); |
|||
age = Period.between(birthday, LocalDate.now()).getYears(); |
|||
} catch (DateTimeException e) { |
|||
throw new EpmetException("身份证号解析年龄失败:" + ExceptionUtils.getErrorStackTrace(e)); |
|||
} |
|||
// ------- 年龄End----------
|
|||
return new ParsedContent(year, month, day, sex, age); |
|||
} |
|||
|
|||
// 其他类型暂时不可解析
|
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 获取类型枚举 |
|||
* @return |
|||
*/ |
|||
public IdCardTypeEnum getTypeEnum() { |
|||
return idCardType; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
IdCardRegexUtils parse = IdCardRegexUtils.parse("370282198801303017"); |
|||
ParsedContent parsedResult = parse.getParsedResult(); |
|||
System.out.println(parsedResult); |
|||
} |
|||
} |
|||
@ -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<Date> { |
|||
|
|||
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());
|
|||
//}
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
package com.epmet.dataaggre.dao.epmetuser; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 核酸监测点 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-06-20 |
|||
*/ |
|||
@Mapper |
|||
public interface IcPointNucleicMonitoringDao extends BaseDao<IcPointNucleicMonitoringEntity> { |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
package com.epmet.dataaggre.dao.epmetuser; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 疫苗接种点 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-06-20 |
|||
*/ |
|||
@Mapper |
|||
public interface IcPointVaccinesInoculationDao extends BaseDao<IcPointVaccinesInoculationEntity> { |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
package com.epmet.dataaggre.entity.epmetuser; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 核酸监测点 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-06-20 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_point_nucleic_monitoring") |
|||
public class IcPointNucleicMonitoringEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 所属组织ID |
|||
*/ |
|||
private String orgId; |
|||
|
|||
/** |
|||
* 所属组织名称 |
|||
*/ |
|||
private String orgName; |
|||
|
|||
/** |
|||
* 组织ID上级 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 组织ID所有上级 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 核酸监测点名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 服务时间 |
|||
*/ |
|||
private String serveTime; |
|||
|
|||
/** |
|||
* 咨询电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 监测点地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
package com.epmet.dataaggre.entity.epmetuser; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 疫苗接种点 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-06-20 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_point_vaccines_inoculation") |
|||
public class IcPointVaccinesInoculationEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 所属组织ID |
|||
*/ |
|||
private String orgId; |
|||
|
|||
/** |
|||
* 所属组织名称 |
|||
*/ |
|||
private String orgName; |
|||
|
|||
/** |
|||
* 组织ID上级 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 组织ID所有上级 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 疫苗接种点名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 接种日期 |
|||
*/ |
|||
private String inoculationDate; |
|||
|
|||
/** |
|||
* 接种上午开始时间 |
|||
*/ |
|||
private String moStartTime; |
|||
|
|||
/** |
|||
* 接种上午结束时间 |
|||
*/ |
|||
private String moEndTime; |
|||
|
|||
/** |
|||
* 接种下午开始时间 |
|||
*/ |
|||
private String afStartTime; |
|||
|
|||
/** |
|||
* 接种下午结束时间 |
|||
*/ |
|||
private String afEndTime; |
|||
|
|||
/** |
|||
* 暂无疫苗(1:是;2:否) |
|||
*/ |
|||
private String noAvailableVaccines; |
|||
|
|||
/** |
|||
* 咨询电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 接种点地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
@ -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<PageData<WorkdiaryServiceRecordDTO>> 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<WorkdiaryServiceRecordDTO> page = workdiaryServiceRecordService.page( |
|||
gridId, serviceType, applicantName, applicantAddress, serviceContent, applicantMobile, startTime, endTime, pageNo, pageSize); |
|||
return new Result<PageData<WorkdiaryServiceRecordDTO>>().ok(page); |
|||
} |
|||
|
|||
/** |
|||
* 记录-单条 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value = "/record/{id}/detail",method = {RequestMethod.POST,RequestMethod.GET}) |
|||
public Result<WorkdiaryServiceRecordDTO> recordGet(@PathVariable("id") String id){ |
|||
WorkdiaryServiceRecordDTO data = workdiaryServiceRecordService.get(id); |
|||
return new Result<WorkdiaryServiceRecordDTO>().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<PageData<WorkdiaryServiceTypeDTO>> serviceTypePage(@RequestBody PageFormDTO input){ |
|||
PageData<WorkdiaryServiceTypeDTO> page = workdiaryServiceTypeService.page(null, input.getPageNo(), input.getPageSize()); |
|||
return new Result<PageData<WorkdiaryServiceTypeDTO>>().ok(page); |
|||
} |
|||
|
|||
/** |
|||
* 列出启用了的类型列表 |
|||
* @param input |
|||
* @return |
|||
*/ |
|||
@RequestMapping("/serviceType/avaliableList") |
|||
public Result<PageData<WorkdiaryServiceTypeDTO>> listAvaliableServiceType(@RequestBody PageFormDTO input){ |
|||
PageData<WorkdiaryServiceTypeDTO> page = workdiaryServiceTypeService.listAvaliableServiceType(input.getPageNo(), input.getPageSize()); |
|||
return new Result<PageData<WorkdiaryServiceTypeDTO>>().ok(page); |
|||
} |
|||
|
|||
/** |
|||
* 服务类型-单条 |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value = "/serviceType/{id}/detail",method = {RequestMethod.POST,RequestMethod.GET}) |
|||
public Result<WorkdiaryServiceTypeDTO> serviceTypeGet(@PathVariable("id") String id){ |
|||
WorkdiaryServiceTypeDTO data = workdiaryServiceTypeService.get(id); |
|||
return new Result<WorkdiaryServiceTypeDTO>().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<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<WorkdiaryServiceTypeDTO> list = workdiaryServiceTypeService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, WorkdiaryServiceTypeExcel.class); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -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<WorkdiaryServiceRecordEntity> { |
|||
|
|||
} |
|||
@ -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<WorkdiaryServiceTypeEntity> { |
|||
|
|||
/** |
|||
* 该客户最大的type是啥 |
|||
* @param customerId |
|||
* @return |
|||
*/ |
|||
Short getMaxType(@Param("customerId") String customerId); |
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
|
|||
} |
|||
@ -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;*/ |
|||
} |
|||
|
|||
@ -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; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,78 @@ |
|||
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.epmet.excel.converter.WorkDiaryServiceEasyExcelDateConverter; |
|||
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 = "服务时间", converter = WorkDiaryServiceEasyExcelDateConverter.class) |
|||
private Date serviceTime; |
|||
|
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
public WorkdiaryServiceRecordExcel(WorkdiaryServiceRecordDTO dto) { |
|||
BeanUtil.copyProperties(dto, this); |
|||
//this.serviceTime = DateUtils.format(dto.getServiceTime());
|
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package com.epmet.excel.converter; |
|||
|
|||
import com.alibaba.excel.converters.Converter; |
|||
import com.alibaba.excel.enums.CellDataTypeEnum; |
|||
import com.alibaba.excel.metadata.GlobalConfiguration; |
|||
import com.alibaba.excel.metadata.data.ReadCellData; |
|||
import com.alibaba.excel.metadata.data.WriteCellData; |
|||
import com.alibaba.excel.metadata.property.ExcelContentProperty; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDateTime; |
|||
import java.time.ZoneId; |
|||
import java.time.temporal.ChronoUnit; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 框架:easyexcel |
|||
* 目的:工作日志(服务),对服务时间日期类型的转换 |
|||
*/ |
|||
public class WorkDiaryServiceEasyExcelDateConverter implements Converter<Date> { |
|||
|
|||
private static final String PATTERN_YYYY_MM_DD = "yyyy-MM-dd"; |
|||
|
|||
/** |
|||
* excel内容转化为java时间 |
|||
* @param cellData |
|||
* @param contentProperty |
|||
* @param globalConfiguration |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public Date convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
|||
if (cellData.getType() == CellDataTypeEnum.NUMBER) { |
|||
// 数字类型,是1900-01-03到excel中数据日期的天数差值
|
|||
LocalDateTime localDate = LocalDateTime.of(1900, 1, 1, 0, 0, 0) |
|||
// 不知为何,这个日期差值,多了2天,需要减去
|
|||
.minus(2L, ChronoUnit.DAYS) |
|||
.plus(cellData.getNumberValue().longValue(), ChronoUnit.DAYS); |
|||
return Date.from(localDate.atZone(ZoneId.systemDefault()).toInstant()); |
|||
} else { |
|||
// 字符串,正常格式化
|
|||
Date dateData = new SimpleDateFormat(PATTERN_YYYY_MM_DD).parse(cellData.getStringValue()); |
|||
return dateData; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* java日期转为excel内容 |
|||
* @param value |
|||
* @param contentProperty |
|||
* @param globalConfiguration |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
|||
String dataStr = new SimpleDateFormat(PATTERN_YYYY_MM_DD).format(value); |
|||
return new WriteCellData(dataStr); |
|||
} |
|||
} |
|||
@ -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<IcSocietyOrgImportExcelDTO> { |
|||
// 最大条数阈值
|
|||
public static final int MAX_THRESHOLD = 2; |
|||
private String currentCustomerId; |
|||
/** |
|||
* 当前操作用户 |
|||
*/ |
|||
private CustomerStaffInfoCacheResult staffInfo; |
|||
private IcSocietyOrgServiceImpl icSocietyOrgService; |
|||
private List<IcSocietyOrgImportExcelDTO.ErrorRow> errorRows = new ArrayList<>(); |
|||
/** |
|||
* 要插入的数据 |
|||
*/ |
|||
private List<IcSocietyOrgEntity> insertDatas = new ArrayList<>(); |
|||
/** |
|||
* 根据组织名称更新的数据 |
|||
*/ |
|||
private List<IcSocietyOrgEntity> updateDatas = new ArrayList<>(); |
|||
private Map<String,String> staffMap=new HashMap<>(); |
|||
public IcSocietyOrgExcelImportListener(String customerId, CustomerStaffInfoCacheResult staffInfo, IcSocietyOrgServiceImpl icSocietyOrgService, Map<String,String> 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<IcSocietyOrgEntity> 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<IcSocietyOrgImportExcelDTO.ErrorRow> getErrorRows() { |
|||
return errorRows; |
|||
} |
|||
} |
|||
|
|||
@ -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<WorkdiaryServiceRecordExcel> { |
|||
|
|||
/** |
|||
* 200 一批执行导入 |
|||
*/ |
|||
public static final Integer BATCH_SIZE = 200; |
|||
|
|||
/** |
|||
* 数据列表 |
|||
*/ |
|||
private List<WorkdiaryServiceRecordExcel> 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); |
|||
} |
|||
} |
|||
@ -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; |
|||
} |
|||
|
|||
} |
|||
@ -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; |
|||
} |
|||
|
|||
} |
|||
@ -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<WorkdiaryServiceRecordEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<WorkdiaryServiceRecordDTO> |
|||
* @author generator |
|||
* @date 2022-08-23 |
|||
*/ |
|||
PageData<WorkdiaryServiceRecordDTO> page(Map<String, Object> params); |
|||
|
|||
PageData<WorkdiaryServiceRecordDTO> 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<WorkdiaryServiceRecordDTO> |
|||
* @author generator |
|||
* @date 2022-08-23 |
|||
*/ |
|||
List<WorkdiaryServiceRecordDTO> list(Map<String, Object> 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<WorkdiaryServiceRecordExcel> datas); |
|||
} |
|||
@ -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<WorkdiaryServiceTypeEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @return PageData<WorkdiaryServiceTypeDTO> |
|||
* @author generator |
|||
* @date 2022-08-23 |
|||
*/ |
|||
PageData<WorkdiaryServiceTypeDTO> page(Short enabled, Integer pageNo, Integer pageSize); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<WorkdiaryServiceTypeDTO> |
|||
* @author generator |
|||
* @date 2022-08-23 |
|||
*/ |
|||
List<WorkdiaryServiceTypeDTO> list(Map<String, Object> params); |
|||
|
|||
List<WorkdiaryServiceTypeDTO> 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<WorkdiaryServiceTypeDTO> listAvaliableServiceType(Integer pageNo, Integer pageSize); |
|||
} |
|||
@ -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<WorkdiaryServiceRecordDao, WorkdiaryServiceRecordEntity> 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<List<ImportResultDesc>> 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*)(?<year>\\d{4})[-/](?<month>\\d{1,2})[-/](?<day>\\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<WorkdiaryServiceRecordDTO> page(Map<String, Object> params) { |
|||
IPage<WorkdiaryServiceRecordEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, WorkdiaryServiceRecordDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public PageData<WorkdiaryServiceRecordDTO> 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<WorkdiaryServiceRecordEntity> 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<WorkdiaryServiceTypeDTO> stList = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(null, 1, 100); |
|||
Map<Short, String> stMap = stList.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); |
|||
|
|||
// 查找服务记录
|
|||
PageHelper.startPage(pageNo, pageSize); |
|||
List<WorkdiaryServiceRecordDTO> 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<WorkdiaryServiceRecordDTO> list(Map<String, Object> params) { |
|||
List<WorkdiaryServiceRecordEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, WorkdiaryServiceRecordDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<WorkdiaryServiceRecordEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<WorkdiaryServiceRecordEntity> 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<Short, String> stMap) { |
|||
|
|||
if (stMap == null || stMap.size() == 0) { |
|||
// 查找类型列表
|
|||
List<WorkdiaryServiceTypeDTO> 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<WorkdiaryServiceRecordDTO> page = this.page(gridId, serviceType, applicantName, applicantAddress, serviceContent, |
|||
applicantMobile, serviceTimeStart, serviceTimeEnd, pageNo, pageSize); |
|||
|
|||
List<WorkdiaryServiceRecordDTO> list = page.getList(); |
|||
if (CollectionUtils.isEmpty(list)) { |
|||
// 空的,导出结束
|
|||
break; |
|||
} |
|||
|
|||
List<WorkdiaryServiceRecordExcel> 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<WorkdiaryServiceRecordEntity> 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<ImportResultDesc> 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<WorkdiaryServiceRecordExcel> 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<WorkdiaryServiceTypeDTO> serviceTypes = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).page(null, 1, 100).getList(); |
|||
Map<String, WorkdiaryServiceTypeDTO> serviceTypeMap = serviceTypes.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceTypeName, Function.identity())); |
|||
|
|||
ArrayList<WorkdiaryServiceRecordEntity> 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(), |
|||
row.getServiceTime(), |
|||
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<IcResiNonDynamicResultDTO> page = getResultDataOrThrowsException(userOpenFeignClient.listResiNonDynamic(new IcResiPageNonDynamicFormDTO(gridId, applicantName, mobile, false)), |
|||
ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民未找到", "居民未找到"); |
|||
|
|||
List<IcResiNonDynamicResultDTO> 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<OptionResultDTO> 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; |
|||
} |
|||
} |
|||
@ -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<WorkdiaryServiceTypeDao, WorkdiaryServiceTypeEntity> implements WorkdiaryServiceTypeService { |
|||
|
|||
@Autowired |
|||
private WorkdiaryServiceTypeRedis workdiaryServiceTypeRedis; |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
@Autowired |
|||
private DistributedLock distributedLock; |
|||
|
|||
@Override |
|||
public PageData<WorkdiaryServiceTypeDTO> page(Short enabled, Integer pageNo, Integer pageSize) { |
|||
List<WorkdiaryServiceTypeDTO> list = list(enabled, pageNo, pageSize); |
|||
return new PageData<>(list, new PageInfo<>(list).getTotal(), pageSize); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkdiaryServiceTypeDTO> list(Map<String, Object> params) { |
|||
List<WorkdiaryServiceTypeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, WorkdiaryServiceTypeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkdiaryServiceTypeDTO> list(Short enabled, Integer pageNo, Integer pageSize) { |
|||
LambdaQueryWrapper<WorkdiaryServiceTypeEntity> stQuery = new LambdaQueryWrapper<>(); |
|||
stQuery.eq(WorkdiaryServiceTypeEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|||
stQuery.eq(enabled != null, WorkdiaryServiceTypeEntity::getEnabled, enabled); |
|||
List<WorkdiaryServiceTypeDTO> 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<WorkdiaryServiceTypeDTO> listAvaliableServiceType(Integer pageNo, Integer pageSize) { |
|||
return this.page(Short.valueOf("1"), pageNo, pageSize); |
|||
} |
|||
|
|||
private QueryWrapper<WorkdiaryServiceTypeEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<WorkdiaryServiceTypeEntity> 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<WorkdiaryServiceTypeEntity> 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<String> 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; |
|||
} |
|||
|
|||
} |
|||
@ -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 ='工作日志(服务)-服务类型' |
|||
@ -0,0 +1,31 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.WorkdiaryServiceRecordDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.WorkdiaryServiceRecordEntity" id="workdiaryServiceRecordMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="serviceType" column="SERVICE_TYPE"/> |
|||
<result property="agencyId" column="AGENCY_ID"/> |
|||
<result property="gridId" column="GRID_ID"/> |
|||
<result property="orgIdPath" column="ORG_ID_PATH"/> |
|||
<result property="applicantId" column="APPLICANT_ID"/> |
|||
<result property="applicantIdCard" column="APPLICANT_ID_CARD"/> |
|||
<result property="applicantName" column="APPLICANT_NAME"/> |
|||
<result property="applicantAddress" column="APPLICANT_ADDRESS"/> |
|||
<result property="applicantMobile" column="APPLICANT_MOBILE"/> |
|||
<result property="serviceContent" column="SERVICE_CONTENT"/> |
|||
<result property="serviceTime" column="SERVICE_TIME"/> |
|||
<result property="principalName" column="PRINCIPAL_NAME"/> |
|||
<result property="remark" column="REMARK"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.WorkdiaryServiceTypeDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.WorkdiaryServiceTypeEntity" id="workdiaryServiceTypeMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="serviceType" column="SERVICE_TYPE"/> |
|||
<result property="serviceTypeName" column="SERVICE_TYPE_NAME"/> |
|||
<result property="enabled" column="ENABLED"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<!--该客户最大的type是啥--> |
|||
<select id="getMaxType" resultType="java.lang.Short"> |
|||
select ifnull(max(SERVICE_TYPE), 0) max |
|||
from workdiary_service_type |
|||
where CUSTOMER_ID = #{customerId} |
|||
and DEL_FLAG = '0' |
|||
</select> |
|||
</mapper> |
|||
Binary file not shown.
Binary file not shown.
@ -1,17 +0,0 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.plugin.power.dto.visit.form.VisitorLogoutFormDTO; |
|||
|
|||
public interface PliPowerService { |
|||
|
|||
/** |
|||
* 访客登出 |
|||
* |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @author zhy |
|||
* @date 2022/5/30 10:25 |
|||
*/ |
|||
Result visitorLogout(VisitorLogoutFormDTO formDTO); |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.plugin.power.dto.visit.form.VisitorLogoutFormDTO; |
|||
import com.epmet.plugin.power.feign.PliPowerFeignClient; |
|||
import com.epmet.service.PliPowerService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName StatsUserServiceImpl |
|||
* @Auth wangc |
|||
* @Date 2020-06-29 09:41 |
|||
*/ |
|||
@Service |
|||
public class PliPowerServiceImpl implements PliPowerService { |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
|
|||
@Autowired |
|||
private PliPowerFeignClient pliPowerFeignClient; |
|||
|
|||
@Override |
|||
public Result visitorLogout(VisitorLogoutFormDTO formDTO) { |
|||
return pliPowerFeignClient.visitorLogout(formDTO); |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.epmet.task; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yzm |
|||
* @Date 2022/8/22 15:13 |
|||
*/ |
|||
@Slf4j |
|||
@Component("autoPublishIcPartyActTask") |
|||
public class AutoPublishIcPartyActTask implements ITask { |
|||
@Autowired |
|||
private ResiPartyMemberOpenFeignClient resiPartyMemberOpenFeignClient; |
|||
/** |
|||
* 活动时间2022-08-15 10:30 选择的是提前3天自动发布 |
|||
* 本任务是自动发布活动 |
|||
* //2022-8-9号 8:00 收到一个:您有一个活动3天后即将自动发布
|
|||
* |
|||
* @param params 参数,多参数使用JSON数据 |
|||
*/ |
|||
@Override |
|||
public void run(String params) { |
|||
Result result=resiPartyMemberOpenFeignClient.autoPublishIcPartyAct(); |
|||
if(result.success()){ |
|||
log.info("autoPublishIcPartyActTask执行成功"); |
|||
}else{ |
|||
log.info("autoPublishIcPartyActTask执行失败"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,31 @@ |
|||
package com.epmet.task; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.feign.GovOrgOpenFeignClient; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author zhaoqifeng |
|||
* @Date 2022/9/6 17:35 |
|||
*/ |
|||
@Component("enterprisePatrolRemindTask") |
|||
@Slf4j |
|||
public class EnterprisePatrolRemindTask implements ITask { |
|||
@Resource |
|||
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|||
|
|||
@Override |
|||
public void run(String params) { |
|||
log.info("EnterprisePatrolRemindTask定时任务正在执行,参数为:{}", params); |
|||
Result result = govOrgOpenFeignClient.sendEnterprisePatrolRemindMessage(); |
|||
if (result.success()) { |
|||
log.info("EnterprisePatrolRemindTask定时任务执行成功"); |
|||
} else { |
|||
log.error("EnterprisePatrolRemindTask定时任务执行失败:" + result.getMsg()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
package com.epmet.task; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yzm |
|||
* @Date 2022/8/22 15:07 |
|||
*/ |
|||
@Slf4j |
|||
@Component("noticePartyActAutoPublishTask") |
|||
public class NoticePartyActAutoPublishTask implements ITask { |
|||
@Autowired |
|||
private ResiPartyMemberOpenFeignClient resiPartyMemberOpenFeignClient; |
|||
|
|||
/** |
|||
* 活动时间2022-08-15 10:30 选择的是提前3天自动发布 |
|||
* //2022-8-12 10:30自动发布,收到消息:您有一个活动已经发布
|
|||
* 本任务是通知:2022-8-9号 8:00 收到一个:您有一个活动3天后即将自动发布 |
|||
* |
|||
* @param params 参数,多参数使用JSON数据 |
|||
*/ |
|||
@Override |
|||
public void run(String params) { |
|||
Result result=resiPartyMemberOpenFeignClient.noticePartyActAutoPublishTask(); |
|||
if(result.success()){ |
|||
log.info("noticePartyActAutoPublishTask执行成功"); |
|||
}else{ |
|||
log.info("noticePartyActAutoPublishTask执行失败"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,41 +0,0 @@ |
|||
package com.epmet.task; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.plugin.power.dto.visit.form.VisitorLogoutFormDTO; |
|||
import com.epmet.service.PliPowerService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 访客登出 |
|||
* |
|||
* @author zhy |
|||
* @date 2022/5/30 10:23 |
|||
*/ |
|||
@Component("pliVisitorLogoutTask") |
|||
public class PliVisitorLogoutTask implements ITask { |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
|
|||
@Autowired |
|||
private PliPowerService pliPowerService; |
|||
|
|||
@Override |
|||
public void run(String params) { |
|||
logger.info("VisitorLogoutTask定时任务正在执行,参数为:{}", params); |
|||
VisitorLogoutFormDTO formDTO = new VisitorLogoutFormDTO(); |
|||
if (StringUtils.isNotBlank(params)) { |
|||
formDTO = JSON.parseObject(params, VisitorLogoutFormDTO.class); |
|||
} |
|||
Result result = pliPowerService.visitorLogout(formDTO); |
|||
if (result.success()) { |
|||
logger.info("VisitorLogoutTask定时任务执行成功"); |
|||
} else { |
|||
logger.error("VisitorLogoutTask定时任务执行失败:" + result.getMsg()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.epmet.task.ic; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.task.ITask; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* desc:定时弥补数据 保证数据的一致性 |
|||
*/ |
|||
@Slf4j |
|||
@Component("icUpdateYlfnTask") |
|||
public class IcUpdateYlfnTask implements ITask { |
|||
|
|||
@Resource |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
/** |
|||
* 执行定时任务接口 |
|||
* |
|||
* @param params 参数,多参数使用JSON数据 |
|||
*/ |
|||
@Override |
|||
public void run(String params) { |
|||
Result result = epmetUserOpenFeignClient.updateYlfn(); |
|||
if (result.success()) { |
|||
log.info("icUpdateYlfnTask定时任务正在执行定时任务执行成功"); |
|||
} else { |
|||
log.warn("icUpdateYlfnTask定时任务正在执行定时任务执行失败:" + result.getMsg()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,104 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 用户消息表(党建小助手) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-08-19 |
|||
*/ |
|||
@Data |
|||
public class IcMessageDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* app=resi时,此列为gridId,其他情况暂定 * |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 被通知的用户id |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 消息通知对象:居民端用户resi、政府端工作人员gov、运营端工作人员oper |
|||
*/ |
|||
private String app; |
|||
|
|||
/** |
|||
* 消息分类 党建活动:party_act 党建日程:party_schedule |
|||
*/ |
|||
private String messageType; |
|||
|
|||
/** |
|||
* 消息类型对应的业务Id |
|||
*/ |
|||
private String targetId; |
|||
|
|||
/** |
|||
* 消息标题 |
|||
*/ |
|||
private String title; |
|||
|
|||
/** |
|||
* 消息通知内容 |
|||
*/ |
|||
private String messageContent; |
|||
|
|||
/** |
|||
* read已读、unread未读 |
|||
*/ |
|||
private String readFlag; |
|||
|
|||
/** |
|||
* 删除标记 0:未删除,1:已删除 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人(发布消息的人) |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 调用者 |
|||
*/ |
|||
private String referer; |
|||
|
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class IcMessageFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 2697079163476964749L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
@NotBlank(message = "客户id不能为空") |
|||
private String customerId; |
|||
|
|||
/** |
|||
* app=resi时,此列为gridId,其他情况暂定 * |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 对应用户id |
|||
*/ |
|||
@NotBlank(message = "通知用户id为空") |
|||
private String userId; |
|||
|
|||
/** |
|||
* 消息通知对象:居民端用户resi、政府端工作人员gov、运营端工作人员oper |
|||
*/ |
|||
@NotBlank(message = "消息通知对象不能为空") |
|||
private String app; |
|||
|
|||
/** |
|||
* 消息标题 |
|||
*/ |
|||
@NotBlank(message = "消息标题不能为空") |
|||
private String title; |
|||
|
|||
/** |
|||
* 消息通知内容 |
|||
*/ |
|||
@NotBlank(message = "通知内容不能为空") |
|||
private String messageContent; |
|||
|
|||
/** |
|||
* read已读、unread未读 |
|||
*/ |
|||
@NotBlank(message = "readFlag不能为空") |
|||
private String readFlag; |
|||
|
|||
/** |
|||
* 调用者 【分内部调用和外部调用,内部调用值为空,外部默认为:外挂-站内信】 |
|||
*/ |
|||
private String referer; |
|||
|
|||
/** |
|||
* 消息分类:info-上传下达消息 详见UserMessageTypeConstant |
|||
*/ |
|||
private String messageType; |
|||
/** |
|||
* 消息对应的业务id,比如message_type=info时,此列存储的是消息id,可跳转到消息详情 |
|||
*/ |
|||
private String targetId; |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class IcMessageListFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 2697079163476964749L; |
|||
|
|||
private Integer pageNo = 1; |
|||
private Integer pageSize = 20; |
|||
private Boolean isPage = true; |
|||
//token中信息
|
|||
private String customerId; |
|||
private String userId; |
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class ReadIcMessageFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 2697079163476964749L; |
|||
|
|||
/** |
|||
* 消息Id |
|||
*/ |
|||
private String id; |
|||
//token中信息
|
|||
private String customerId; |
|||
private String userId; |
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.AssertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.dto.IcMessageDTO; |
|||
import com.epmet.dto.form.IcMessageFormDTO; |
|||
import com.epmet.dto.form.IcMessageListFormDTO; |
|||
import com.epmet.dto.form.ReadIcMessageFormDTO; |
|||
import com.epmet.service.IcMessageService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 用户消息表(党建小助手) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-08-19 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("icMessage") |
|||
public class IcMessageController { |
|||
|
|||
@Autowired |
|||
private IcMessageService icMessageService; |
|||
|
|||
@RequestMapping("list") |
|||
public Result<PageData<IcMessageDTO>> list(@LoginUser TokenDto tokenDto, @RequestBody IcMessageListFormDTO formDTO){ |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
return new Result<PageData<IcMessageDTO>>().ok(icMessageService.list(formDTO)); |
|||
} |
|||
|
|||
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) |
|||
public Result<IcMessageDTO> get(@PathVariable("id") String id){ |
|||
IcMessageDTO data = icMessageService.get(id); |
|||
return new Result<IcMessageDTO>().ok(data); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("save") |
|||
public Result save(@RequestBody IcMessageDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
icMessageService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("update") |
|||
public Result update(@RequestBody IcMessageDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
icMessageService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("delete") |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
icMessageService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 批量插入未读消息 |
|||
**/ |
|||
@PostMapping("saveicmessagelist") |
|||
public Result saveIcMessageList(@RequestBody List<IcMessageFormDTO> msgList) { |
|||
icMessageService.saveIcMessageList(msgList); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 单条或批量修改已读 |
|||
**/ |
|||
@PostMapping("read") |
|||
public Result read(@LoginUser TokenDto tokenDto, @RequestBody ReadIcMessageFormDTO formDTO) { |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
icMessageService.read(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("unreadcount/{userId}") |
|||
public Result<Integer> unReadCount(@PathVariable ("userId") String userId) { |
|||
return new Result<Integer>().ok(icMessageService.unReadCount(userId)); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.IcMessageDTO; |
|||
import com.epmet.dto.form.IcMessageListFormDTO; |
|||
import com.epmet.dto.form.ReadIcMessageFormDTO; |
|||
import com.epmet.entity.IcMessageEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 用户消息表(党建小助手) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-08-19 |
|||
*/ |
|||
@Mapper |
|||
public interface IcMessageDao extends BaseDao<IcMessageEntity> { |
|||
|
|||
List<IcMessageDTO> selectMessageList(IcMessageListFormDTO formDTO); |
|||
|
|||
void upByUserId(ReadIcMessageFormDTO formDTO); |
|||
|
|||
Integer selectUnReadCount(@Param("userId") String userId); |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
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-19 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_message") |
|||
public class IcMessageEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* app=resi时,此列为gridId,其他情况暂定 * |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 被通知的用户id |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 消息通知对象:居民端用户resi、政府端工作人员gov、运营端工作人员oper |
|||
*/ |
|||
private String app; |
|||
|
|||
/** |
|||
* 消息分类 党建活动:party_act 党建日程:party_schedule |
|||
*/ |
|||
private String messageType; |
|||
|
|||
/** |
|||
* 消息类型对应的业务Id |
|||
*/ |
|||
private String targetId; |
|||
|
|||
/** |
|||
* 消息标题 |
|||
*/ |
|||
private String title; |
|||
|
|||
/** |
|||
* 消息通知内容 |
|||
*/ |
|||
private String messageContent; |
|||
|
|||
/** |
|||
* read已读、unread未读 |
|||
*/ |
|||
private String readFlag; |
|||
|
|||
/** |
|||
* 调用者 |
|||
*/ |
|||
private String referer; |
|||
|
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.IcMessageDTO; |
|||
import com.epmet.dto.form.IcMessageFormDTO; |
|||
import com.epmet.dto.form.IcMessageListFormDTO; |
|||
import com.epmet.dto.form.ReadIcMessageFormDTO; |
|||
import com.epmet.entity.IcMessageEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 用户消息表(党建小助手) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-08-19 |
|||
*/ |
|||
public interface IcMessageService extends BaseService<IcMessageEntity> { |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param formDTO |
|||
* @return java.util.List<IcMessageDTO> |
|||
* @author generator |
|||
* @date 2022-08-19 |
|||
*/ |
|||
PageData<IcMessageDTO> list(IcMessageListFormDTO formDTO); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return IcMessageDTO |
|||
* @author generator |
|||
* @date 2022-08-19 |
|||
*/ |
|||
IcMessageDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-08-19 |
|||
*/ |
|||
void save(IcMessageDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-08-19 |
|||
*/ |
|||
void update(IcMessageDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-08-19 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
void saveIcMessageList(List<IcMessageFormDTO> msgList); |
|||
|
|||
void read(ReadIcMessageFormDTO formDTO); |
|||
|
|||
Integer unReadCount(String userId); |
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.enums.DictTypeEnum; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dao.IcMessageDao; |
|||
import com.epmet.dto.IcMessageDTO; |
|||
import com.epmet.dto.form.IcMessageFormDTO; |
|||
import com.epmet.dto.form.IcMessageListFormDTO; |
|||
import com.epmet.dto.form.IcMoveInListFormDTO; |
|||
import com.epmet.dto.form.ReadIcMessageFormDTO; |
|||
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|||
import com.epmet.dto.result.HouseInfoDTO; |
|||
import com.epmet.dto.result.IcMoveInListResultDTO; |
|||
import com.epmet.entity.IcMessageEntity; |
|||
import com.epmet.service.IcMessageService; |
|||
import com.github.pagehelper.PageHelper; |
|||
import com.github.pagehelper.PageInfo; |
|||
import org.apache.commons.collections4.MapUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.*; |
|||
import java.util.function.Function; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 用户消息表(党建小助手) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-08-19 |
|||
*/ |
|||
@Service |
|||
public class IcMessageServiceImpl extends BaseServiceImpl<IcMessageDao, IcMessageEntity> implements IcMessageService { |
|||
|
|||
|
|||
@Override |
|||
public PageData<IcMessageDTO> list(IcMessageListFormDTO formDTO) { |
|||
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); |
|||
List<IcMessageDTO> list = baseDao.selectMessageList(formDTO); |
|||
PageInfo<IcMessageDTO> pageInfo = new PageInfo<>(list); |
|||
return new PageData<>(list, pageInfo.getTotal()); |
|||
} |
|||
|
|||
private QueryWrapper<IcMessageEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<IcMessageEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public IcMessageDTO get(String id) { |
|||
IcMessageEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, IcMessageDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(IcMessageDTO dto) { |
|||
IcMessageEntity entity = ConvertUtils.sourceToTarget(dto, IcMessageEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(IcMessageDTO dto) { |
|||
IcMessageEntity entity = ConvertUtils.sourceToTarget(dto, IcMessageEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public void saveIcMessageList(List<IcMessageFormDTO> msgList) { |
|||
List<IcMessageEntity> entityList = ConvertUtils.sourceToTarget(msgList, IcMessageEntity.class); |
|||
insertBatch(entityList); |
|||
} |
|||
|
|||
@Override |
|||
public void read(ReadIcMessageFormDTO formDTO) { |
|||
//id入参有值就按id修改,没值就按用户修改
|
|||
if(StringUtils.isNotBlank(formDTO.getId())){ |
|||
IcMessageEntity entity = new IcMessageEntity(); |
|||
entity.setId(formDTO.getId()); |
|||
entity.setReadFlag("read"); |
|||
updateById(entity); |
|||
return; |
|||
} |
|||
//批量修改某个人消息列表
|
|||
baseDao.upByUserId(formDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Integer unReadCount(String userId) { |
|||
return baseDao.selectUnReadCount(userId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
CREATE TABLE `ic_message` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '主键', |
|||
`customer_id` varchar(64) NOT NULL COMMENT '客户id', |
|||
`grid_id` varchar(64) NOT NULL DEFAULT '*' COMMENT '暂定 *', |
|||
`user_id` varchar(64) NOT NULL COMMENT '被通知的用户id', |
|||
`app` varchar(32) NOT NULL COMMENT '消息通知对象:居民端用户resi、政府端工作人员gov、运营端工作人员oper', |
|||
`message_type` varchar(32) DEFAULT NULL COMMENT '消息分类 党建小助手:party', |
|||
`target_id` varchar(64) DEFAULT NULL COMMENT '消息类型对应的业务Id', |
|||
`title` varchar(255) NOT NULL COMMENT '消息标题', |
|||
`message_content` varchar(3096) NOT NULL COMMENT '消息通知内容', |
|||
`read_flag` varchar(32) NOT NULL DEFAULT 'unread' COMMENT 'read已读、unread未读', |
|||
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标记 0:未删除,1:已删除', |
|||
`REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人(发布消息的人)', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
`REFERER` varchar(20) DEFAULT NULL COMMENT '调用者', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='用户消息表(党建小助手)'; |
|||
@ -0,0 +1,2 @@ |
|||
ALTER TABLE epmet_message.`ic_message` |
|||
MODIFY COLUMN `message_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '消息分类 \r\n党建活动:party_act \r\n党建日程:party_schedule \r\n' AFTER `app`; |
|||
@ -0,0 +1,40 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.IcMessageDao"> |
|||
|
|||
<select id="selectMessageList" resultType="com.epmet.dto.IcMessageDTO"> |
|||
SELECT |
|||
* |
|||
FROM |
|||
ic_message |
|||
WHERE |
|||
del_flag = '0' |
|||
AND customer_id = #{customerId} |
|||
AND user_id = #{userId} |
|||
ORDER BY CREATED_TIME desc |
|||
</select> |
|||
|
|||
<update id="upByUserId" parameterType="com.epmet.dto.form.ReadIcMessageFormDTO"> |
|||
UPDATE ic_message |
|||
SET read_flag = 'read', |
|||
updated_by = #{userId}, |
|||
updated_time = NOW() |
|||
WHERE |
|||
del_flag = '0' |
|||
AND customer_id = #{customerId} |
|||
AND user_id = #{userId} |
|||
</update> |
|||
|
|||
<select id="selectUnReadCount" resultType="java.lang.Integer"> |
|||
SELECT |
|||
COUNT(id) |
|||
FROM |
|||
ic_message |
|||
WHERE |
|||
del_flag = '0' |
|||
AND read_flag = 'unread' |
|||
AND user_id = #{userId} |
|||
</select> |
|||
|
|||
</mapper> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue