diff --git a/fw-dalaran-common/pom.xml b/fw-dalaran-common/pom.xml index 9b611a4..dc87b07 100644 --- a/fw-dalaran-common/pom.xml +++ b/fw-dalaran-common/pom.xml @@ -48,6 +48,10 @@ net.coobird thumbnailator + + org.springframework.boot + spring-boot + diff --git a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/ConfigProperties.java b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/ConfigProperties.java new file mode 100644 index 0000000..c709531 --- /dev/null +++ b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/ConfigProperties.java @@ -0,0 +1,27 @@ +package cn.fw.dalaran.common; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @author wmy3969 + * @version 1.0 + * @date 2022/12/29 9:43 + * @Description 配置文件关联 + */ +@Data +@ConfigurationProperties(prefix = "url") +public class ConfigProperties { + /** + * 图片文件 + */ + private String show; + /** + * 删除map缓存 + */ + private String delMapCache; + /** + * 重新计算综合得分 + */ + private String reCalcScore; +} diff --git a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/constants/DalaranConstants.java b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/constants/Constants.java index e746fbf..012977d 100644 --- a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/constants/DalaranConstants.java +++ b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/constants/Constants.java @@ -6,7 +6,7 @@ package cn.fw.dalaran.common.constants; * @date 2022/4/13 16:40 * @Description Dalaran系统常量 */ -public interface DalaranConstants { +public interface Constants { /** * 系统名 */ @@ -30,9 +30,19 @@ public interface DalaranConstants { /** * 账号配置角色码 */ - String ZHSZ_ROLE_CODE = "ZMT-ZHSZ"; + String ZHSZ_ROLE_CODE = "MKT-HDCZ"; /** * 直播审计角色码 */ String ZBSJ_ROLE_CODE = "ZMT-ZBSJ"; + + /** + * 薪酬绩效相关常量 + */ + interface Performance { + /** + * 综合得分目标达成率 + */ + String SCORE_RATE = "6574EA0766114615"; + } } diff --git a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/DateUtil.java b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/DateUtil.java index 8133c50..27a67f0 100644 --- a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/DateUtil.java +++ b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/DateUtil.java @@ -1,13 +1,14 @@ package cn.fw.dalaran.common.utils; +import cn.fw.common.exception.BusinessException; + import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.*; +import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; -import java.util.Calendar; -import java.util.Date; -import java.util.Objects; +import java.util.*; /** * 日期处理工具 @@ -17,6 +18,9 @@ import java.util.Objects; */ public final class DateUtil { + public static final String START = "start"; + public static final String END = "end"; + static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); /** @@ -26,7 +30,6 @@ public final class DateUtil { throw new UnsupportedOperationException(); } - public static Date parse(String date) { try { return sdf.parse(date); @@ -56,46 +59,6 @@ public final class DateUtil { return localDateTime2Date(date2LocalDate(date).plusDays(1).atStartOfDay()); } - /** - * 处理日期,保留年月日 - */ - public static LocalDate date2LocalDate(final Date date) { - if (date == null) { - return null; - } - return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()).toLocalDate(); - } - - public static LocalTime date2LocalTime(final Date date) { - if (date == null) { - return null; - } - return LocalTime.of(date.getHours(), date.getMinutes(), date.getSeconds()); - } - - public static LocalDateTime date2LocalDateTime(final Date date) { - Instant instant = date.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - return instant.atZone(zoneId).toLocalDateTime(); - } - - /** - * convert LocalDateTime to Date - */ - public static Date localDateTime2Date(final LocalDateTime dateTime) { - return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant()); - } - - /** - * convert LocalDate to Date - */ - public static Date localDate2Date(final LocalDate localDate) { - if (localDate == null) { - return null; - } - return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); - } - public static Date getBeginInTime(Date inTime) { if (inTime == null) { return null; @@ -561,6 +524,366 @@ public final class DateUtil { return a > 18 && a <= 23; } + + /** + * 获取date的天的时间范围 + * date: 2022-8-18 11:19:32 + * return: 2022-8-18 0:00:00 ——> 2022-8-18 23:59:59 + */ + public static Map getDayRange(Date date) { + Map dateMap = new HashMap<>(); + dateMap.put(START, dayBegin(date)); + dateMap.put(END, dayEnd(date)); + return dateMap; + } + + /** + * 获取date的月份的时间范围 + * date: 2022-8-18 11:19:32 + * return: 2022-8-01 0:00:00 ——> 2022-8-31 23:59:59 + */ + public static Map getMonthRange(Date date) { + Map dateMap = new HashMap<>(); + LocalDate localDate = date2LocalDate(date); + dateMap.put(START, dayBegin(localDate2Date(localDate.withDayOfMonth(1)))); + dateMap.put(END, dayEnd(localDate2Date(localDate.with(TemporalAdjusters.lastDayOfMonth())))); + return dateMap; + } + + /** + * 获取date的近4个月的时间范围 + * date: 2022-8-18 11:19:32 + * return: 2022-5-01 0:00:00 ——> 2022-8-31 23:59:59 + */ + public static Map get4MonthRange(Date date) { + Map dateMap = new HashMap<>(); + LocalDate localDate = date2LocalDate(date); + dateMap.put(START, dayBegin(localDate2Date(localDate.withDayOfMonth(1).minusMonths(3)))); + dateMap.put(END, dayEnd(localDate2Date(localDate.with(TemporalAdjusters.lastDayOfMonth())))); + return dateMap; + } + + /** + * 获取date的近1年的时间范围 + * date: 2022-8-18 11:19:32 + * return: 2021-9-01 0:00:00 ——> 2022-8-31 23:59:59 + */ + public static Map getOneYearRange(Date date) { + Map dateMap = new HashMap<>(); + LocalDate localDate = date2LocalDate(date); + dateMap.put(START, dayBegin(localDate2Date(localDate.withDayOfMonth(1).minusMonths(11)))); + dateMap.put(END, dayEnd(localDate2Date(localDate.with(TemporalAdjusters.lastDayOfMonth())))); + return dateMap; + } + + /** + * 获取指定时间那天的最小时间 + * date: 2022-8-18 11:19:32 + * return: 2022-8-18 0:00:00 + */ + public static Date dayBegin(Date date) { + return localDateTime2Date(LocalDateTime + .of(date2LocalDate(Objects.requireNonNull(date)), LocalTime.MIN) + ); + } + + /** + * 获取指定时间那天的最大时间 + * date: 2022-8-18 11:19:32 + * return: 2022-8-18 23:59:59 + */ + public static Date dayEnd(Date date) { + return localDateTime2Date(LocalDateTime + .of(date2LocalDate(Objects.requireNonNull(date)), LocalTime.MAX) + ); + } + + /** + * 获取指定时间那月的最小时间 + * date: 2022-8-18 11:19:32 + * return: 2022-8-01 0:00:00 + */ + public static Date monthBegin(Date date) { + return localDateTime2Date(LocalDateTime + .of(date2LocalDate(Objects.requireNonNull(date)).withDayOfMonth(1), LocalTime.MIN) + ); + } + + /** + * 获取指定时间那月的最大时间 + * date: 2022-8-18 11:19:32 + * return: 2022-8-31 23:59:59 + */ + public static Date monthEnd(Date date) { + return localDateTime2Date(LocalDateTime + .of(date2LocalDate(Objects.requireNonNull(date)).with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX) + ); + } + + /** + * LocalDate转Date + */ + public static Date localDate2Date(LocalDate localDate) { + return Date.from(Objects.requireNonNull(localDate) + .atStartOfDay() + .atZone(ZoneId.systemDefault()) + .toInstant() + ); + } + + /** + * LocalDateTime转Date + */ + public static Date localDateTime2Date(LocalDateTime localDateTime) { + return Date.from(Objects.requireNonNull(localDateTime) + .atZone(ZoneId.systemDefault()) + .toInstant() + ); + } + + /** + * Date转LocalDateTime + */ + public static LocalDateTime date2LocalDateTime(Date date) { + return Objects.requireNonNull(date) + .toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDateTime() + ; + } + + /** + * Date转LocalTime + */ + public static LocalTime date2LocalTime(Date date) { + return Objects.requireNonNull(date) + .toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalTime() + ; + } + + /** + * Date转LocalDate + */ + public static LocalDate date2LocalDate(Date date) { + return Objects.requireNonNull(date) + .toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate() + ; + } + + /** + * 时间戳转LocalDate + */ + public static LocalDate timestamp2LocalDate(Long timestamp) { + return Instant. + ofEpochMilli(Objects.requireNonNull(timestamp)) + .atZone(ZoneId.systemDefault()) + .toLocalDate() + ; + } + + /** + * 时间戳转LocalDateTime + */ + public static LocalDateTime timestamp2LocalDateTime(Long timestamp) { + return Instant. + ofEpochMilli(Objects.requireNonNull(timestamp)) + .atZone(ZoneId.systemDefault()) + .toLocalDateTime() + ; + } + + /** + * LocalDate转时间戳 + */ + public static Long localDate2Timestamp(LocalDate localDate) { + return Objects.requireNonNull(localDate) + .atStartOfDay(ZoneId.systemDefault()) + .toInstant() + .toEpochMilli() + ; + } + + /** + * LocalDateTime转时间戳 + */ + public static Long localDateTime2Timestamp(LocalDateTime localDateTime) { + return Objects.requireNonNull(localDateTime) + .toInstant(ZoneOffset.ofHours(8)) + .toEpochMilli() + ; + } + + /** + * 按照pattern指定的格式格式化LocalDateTime对象 + */ + public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(Objects.requireNonNull(pattern)); + return Objects.requireNonNull(localDateTime).format(dtf); + } + + /** + * 两个时间是否在同一天 + */ + public static boolean sameDay(Date day1, Date day2) { + return Objects.equals(date2LocalDate(Objects.requireNonNull(day1)), date2LocalDate(Objects.requireNonNull(day2))); + } + + /** + * 两个时间是否在同一月 + */ + public static boolean sameMonth(Date day1, Date day2) { + LocalDate date1 = date2LocalDate(Objects.requireNonNull(day1)); + LocalDate date2 = date2LocalDate(Objects.requireNonNull(day2)); + return Objects.equals(date1.getYear(), date2.getYear()) && Objects.equals(date1.getMonthValue(), date2.getMonthValue()); + } + + /** + * 两个时间是否在同一年 + */ + public static boolean sameYear(Date day1, Date day2) { + LocalDate date1 = date2LocalDate(Objects.requireNonNull(day1)); + LocalDate date2 = date2LocalDate(Objects.requireNonNull(day2)); + return Objects.equals(date1.getYear(), date2.getYear()); + } + + /** + * 指定时间 + 指定秒 + */ + public static Date plusSeconds(Date date, int seconds) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusSeconds(Math.abs(seconds))); + } + + /** + * 指定时间 - 指定秒 + */ + public static Date minusSeconds(Date date, int seconds) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusSeconds(Math.abs(seconds))); + } + + /** + * 指定时间 + 指定分钟 + */ + public static Date plusMinutes(Date date, int minutes) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusMinutes(Math.abs(minutes))); + } + + /** + * 指定时间 - 指定秒 + */ + public static Date minusMinutes(Date date, int minutes) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusMinutes(Math.abs(minutes))); + } + + /** + * 指定时间 + 指定小时 + */ + public static Date plusHours(Date date, int hours) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusHours(Math.abs(hours))); + } + + /** + * 指定时间 - 指定小时 + */ + public static Date minusHours(Date date, int hours) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusHours(Math.abs(hours))); + } + + /** + * 指定时间 + 指定天 + */ + public static Date plusDays(Date date, int days) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusDays(Math.abs(days))); + } + + /** + * 指定时间 - 指定天 + */ + public static Date minusDays(Date date, int days) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusDays(Math.abs(days))); + } + + /** + * 指定时间 + 指定星期 + */ + public static Date plusWeeks(Date date, int weeks) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusWeeks(Math.abs(weeks))); + } + + /** + * 指定时间 - 指定星期 + */ + public static Date minusWeeks(Date date, int weeks) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusWeeks(Math.abs(weeks))); + } + + /** + * 指定时间 + 指定月 + */ + public static Date plusMonths(Date date, int months) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusMonths(Math.abs(months))); + } + + /** + * 指定时间 - 指定月 + */ + public static Date minusMonths(Date date, int months) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusMonths(Math.abs(months))); + } + + /** + * 指定时间 + 指定年 + */ + public static Date plusYears(Date date, int years) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).plusYears(Math.abs(years))); + } + + /** + * 指定时间 - 指定年 + */ + public static Date minusYears(Date date, int years) { + return localDateTime2Date(date2LocalDateTime(Objects.requireNonNull(date)).minusYears(Math.abs(years))); + } + + /** + * 校验时间有无重叠 + * + * @param startDate1 开始时间1 + * @param endDate1 结束时间1 + * @param startDate2 开始时间2 + * @param endDate2 结束时间2 + * @return 两个时间区间是否有重叠 + */ + public static boolean validDateOverlap(Date startDate1, Date endDate1, Date startDate2, Date endDate2) { + if (startDate1.after(endDate1) || startDate2.after(endDate2)) + throw new BusinessException("开始时间必须在结束时间之前"); + return !endDate2.before(startDate1) && !startDate2.after(endDate1) && !endDate1.before(startDate2) && !startDate1.after(endDate2); + } + + /** + * 毫秒->xx天xx小时xx分xx秒xx毫秒 + */ + public static String millisToString(Long totalMillis) { + totalMillis = Math.abs(totalMillis); + int secondMillis = 1000;// 每秒钟毫秒数 + int minuteMillis = secondMillis * 60;// 每分钟毫秒数 + int hourMillis = minuteMillis * 60;// 每小时毫秒数 + int dayMillis = hourMillis * 24;// 每天毫秒数 + long days = totalMillis / dayMillis;// 共有多少天 + long hours = (totalMillis - days * dayMillis) / hourMillis;// 还有多少小时 + long minutes = (totalMillis - days * dayMillis - hours * hourMillis) / minuteMillis;// 还有多少分钟 + /*long seconds = (totalMillis - days * dayMillis - hours * hourMillis - minutes * minuteMillis) / secondMillis;// 还有多少秒 + long millis = totalMillis - days * dayMillis - hours * hourMillis - minutes * minuteMillis - seconds * secondMillis;// 还有多少毫秒*/ + return (days > 0 ? days : 0) + "天" + + (hours > 0 ? hours : 0) + "小时" + + (minutes > 0 ? minutes : 0) + "分" /*+ + (seconds > 0 ? seconds : 0) + "秒" + + (millis > 0 ? millis : 0) + "毫秒"*/; + } + public static void main(String[] args) throws ParseException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = format.parse("2020-09-19 15:45:30"); diff --git a/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/ActivityThemeDao.java b/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/ActivityThemeDao.java index 9a83a99..85405a7 100644 --- a/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/ActivityThemeDao.java +++ b/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/ActivityThemeDao.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author wmy3969 * @version 1.0 @@ -19,4 +21,11 @@ public interface ActivityThemeDao extends BaseMapper { * @param param 修改的参数封装 */ boolean alertTheme(@Param("param") ActivityTheme param); + + /** + * 获取已经逻辑删除的主题列表 + * + * @return 已经逻辑删除的主题列表 + */ + List getHasDelActivityTheme(); } diff --git a/fw-dalaran-dao/src/main/resources/mapper/ActivityThemeDaoMapper.xml b/fw-dalaran-dao/src/main/resources/mapper/ActivityThemeDaoMapper.xml index 9e9f77d..55733a1 100644 --- a/fw-dalaran-dao/src/main/resources/mapper/ActivityThemeDaoMapper.xml +++ b/fw-dalaran-dao/src/main/resources/mapper/ActivityThemeDaoMapper.xml @@ -43,4 +43,9 @@ + + + diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/ConfigGroup.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/ConfigGroup.java index 52473f7..a9f485d 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/ConfigGroup.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/ConfigGroup.java @@ -54,7 +54,7 @@ public class ConfigGroup { */ private String configIds; /** - * 全部门店(-1:授权范围内, 0:否, 1:是) + * 全部门店(-2:初始化, -1:授权范围内, 0:否, 1:是) */ private Integer allShop; /** diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/GlobalConfig.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/GlobalConfig.java index 3e3674a..c9d78ff 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/GlobalConfig.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/GlobalConfig.java @@ -30,7 +30,7 @@ public class GlobalConfig implements Serializable { */ private Long configGroupId; /** - * 配置项类型(1:封面, 2:话题) + * 配置项类型(1:封面, 2:话题, 3:综合得分标准分) */ private Integer type; /** diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/TodoHistory.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/TodoHistory.java index 81cada9..6e306f1 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/TodoHistory.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/TodoHistory.java @@ -46,4 +46,11 @@ public class TodoHistory extends BaseAuditableTimeEntity { * 附加信息 */ private String extra; + + /** + * 自定义去重条件 + */ + public String getRemoveDuplicatesCondition() { + return this.getUserId() + "-->" + this.getDataId(); + } } diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/enums/ConfigEnum.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/enums/ConfigEnum.java index f9d9afb..e8387f3 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/enums/ConfigEnum.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/enums/ConfigEnum.java @@ -20,6 +20,10 @@ public enum ConfigEnum implements IEnum { * 话题相似度 */ TOPIC_SIMILARITY(2, "话题相似度"), + /** + * 综合得分集团标准分 + */ + STANDARD_SCORE(3,"综合得分集团标准分") ; /** diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/ConfigGroupVo.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/ConfigGroupVo.java index e38f113..420f454 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/ConfigGroupVo.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/ConfigGroupVo.java @@ -33,6 +33,10 @@ public class ConfigGroupVo { */ private String userName; /** + * 能否编辑 + */ + private boolean canAlter; + /** * 集团id */ private Long groupId; diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LiveCheckVo.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LiveCheckVo.java index faff8ec..7b224f1 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LiveCheckVo.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LiveCheckVo.java @@ -19,13 +19,13 @@ public class LiveCheckVo { /** * 待审核直播列表 */ - private List liveList; + private List liveList; /** * 待审核直播 */ @Data - public static class liveSummary { + public static class LiveSummary { /** * 主键id */ diff --git a/fw-dalaran-rpc/pom.xml b/fw-dalaran-rpc/pom.xml index c69d88c..25b3c0c 100644 --- a/fw-dalaran-rpc/pom.xml +++ b/fw-dalaran-rpc/pom.xml @@ -39,6 +39,11 @@ cn.fw fw-attendance-sdk + + + cn.fw + fw-morax-sdk + javax.validation diff --git a/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/erp/ErpTaskRpc.java b/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/erp/ErpTaskRpc.java index a211288..1081abf 100644 --- a/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/erp/ErpTaskRpc.java +++ b/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/erp/ErpTaskRpc.java @@ -1,7 +1,7 @@ package cn.fw.dalaran.rpc.erp; import cn.fw.common.exception.BusinessException; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.rpc.erp.dto.TaskSetReq; import cn.fw.data.base.domain.common.Message; import cn.fw.erp.sdk.api.TaskApi; @@ -29,7 +29,7 @@ public class ErpTaskRpc { try { TaskAddReq addReq = new TaskAddReq<>(); BeanUtils.copyProperties(req, addReq); - addReq.setSystem(DalaranConstants.APPLICATION_NAME); + addReq.setSystem(Constants.APPLICATION_NAME); final Message msg = taskApi.addTask(addReq); log.info("调用ERP系统添加定时任务结果[{}]", JSON.toJSONString(msg)); } catch (Exception e) { diff --git a/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/morax/SalaryRpc.java b/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/morax/SalaryRpc.java new file mode 100644 index 0000000..e0d64d4 --- /dev/null +++ b/fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/morax/SalaryRpc.java @@ -0,0 +1,59 @@ +package cn.fw.dalaran.rpc.morax; + +import cn.fw.dalaran.common.utils.PublicUtil; +import cn.fw.data.base.domain.common.Message; +import cn.fw.morax.sdk.api.IKpiReportService; +import cn.fw.morax.sdk.api.ISalaryReportService; +import cn.fw.morax.sdk.dto.CustomList; +import cn.fw.morax.sdk.dto.kpi.KpiGroupUserQuery; +import cn.fw.morax.sdk.dto.kpi.KpiGroupUserResult; +import cn.fw.morax.sdk.dto.kpi.UserIndicatorReq; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.Collections; +import java.util.List; + + +/** + * @author wmy3969 + * @version 1.0 + * @date 2022/10/9 14:05 + * @Description 绩效薪酬rpc + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class SalaryRpc { + + private final IKpiReportService kpiApi;// 绩效api + private final ISalaryReportService salaryApi;// 薪酬api + + /** + * 查询绩效组人员 + */ + public List queryGroupUsers(KpiGroupUserQuery kpiGroupUserQuery) { + try { + Message> groupUser = kpiApi.queryKpiGroupUser(kpiGroupUserQuery); + PublicUtil.assertTrue(groupUser.isSuccess(), "查询绩效组人员失败!"); + return groupUser.getData(); + } catch (Exception e) { + log.error("查询绩效组人员发生错误, 错误信息为: {}", e.getMessage()); + return Collections.emptyList(); + } + } + + /** + * 上报人员绩效数据 + */ + public void reportKpi(CustomList userIndicatorList) { + try { + Message msg = kpiApi.indicatorReport(userIndicatorList); + PublicUtil.assertTrue(msg.isSuccess(), "上报人员绩效数据失败!"); + } catch (Exception e) { + log.error("上报人员绩效数据发生错误, 错误信息为: {}", e.getMessage()); + } + } + +} diff --git a/fw-dalaran-server/pom.xml b/fw-dalaran-server/pom.xml index 89ec4f1..42b458b 100644 --- a/fw-dalaran-server/pom.xml +++ b/fw-dalaran-server/pom.xml @@ -26,6 +26,11 @@ cn.fw fw-notice-sdk + + + cn.fw + fw-morax-sdk + cn.fw fw-attendance-sdk @@ -65,6 +70,10 @@ spring-boot-starter-actuator + io.micrometer + micrometer-registry-prometheus + + org.springframework.boot spring-boot-starter-undertow @@ -141,11 +150,10 @@ 1.0.0 - org.hibernate.validator - hibernate-validator - 6.0.11.Final + org.springframework.boot + spring-boot-configuration-processor + true - @@ -158,6 +166,7 @@ **/*.yml **/*.properties **/*.xml + **/banner.txt diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/Application.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/Application.java index 725bf87..a374e33 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/Application.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/Application.java @@ -1,14 +1,17 @@ package cn.fw.dalaran.server; +import cn.fw.dalaran.common.ConfigProperties; import cn.fw.security.auth.client.EnableAuthClient; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; @@ -17,7 +20,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; /** * 启动类 * - *@author kurisu + * @author kurisu */ @EnableAsync @SpringBootApplication @@ -31,6 +34,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @MapperScan("cn.fw.**.dao") @ComponentScan({"cn.fw.dalaran.*"}) @EnableFeignClients({"cn.fw.**.sdk"}) +@EnableAspectJAutoProxy(exposeProxy = true) +@EnableConfigurationProperties({ConfigProperties.class}) public class Application { public static void main(final String[] args) { SpringApplication.run(Application.class, args); diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java index 3bf20c1..38cacc1 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java @@ -41,6 +41,7 @@ public class OtherController { private final OtherBizService otherBizService; private final Common common; + //private final TodoTask todoTask;// 定时任务 /** * 获取直播审计页面 @@ -73,7 +74,7 @@ public class OtherController { */ @GetMapping("/getLiveCheckDetails") @ControllerMethod("获取某条审计详情") - public Message getLiveCheckDetails(@NotNull(message = "请必须指定数据id") Long id) { + public Message getLiveCheckDetails(@NotNull(message = "请必须指定数据id") Long id) { return success(otherBizService.getLiveCheckDetails(id)); } @@ -104,4 +105,16 @@ public class OtherController { return success(result); } + /** + * 重发直播审计待办 + * + * @param timestamp 时间戳 + * @return + */ + /*@GetMapping("/resendLiveCheckBacklog") + public Message test(@NotNull(message = "请必须指定时间戳") Long timestamp) { + todoTask.sendLiveCheckBacklog(timestamp); + return Message.success(); + }*/ + } diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/ConfigGroupController.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/ConfigGroupController.java index fdeb1fc..d6cf2fb 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/ConfigGroupController.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/ConfigGroupController.java @@ -1,6 +1,5 @@ package cn.fw.dalaran.server.controller.web; -import cn.fw.common.web.annotation.ControllerMethod; import cn.fw.common.web.auth.LoginAuthBean; import cn.fw.common.web.auth.annotation.CurrentUser; import cn.fw.dalaran.domain.vo.ConfigGroupVo; @@ -42,7 +41,6 @@ public class ConfigGroupController { * @return 操作结果 */ @GetMapping("/init") - @ControllerMethod("初始化配置组") public Message init(@CurrentUser LoginAuthBean user) { return success(configGroupService.init(user.getUserId(), user.getGroupId())); } @@ -66,7 +64,6 @@ public class ConfigGroupController { * @return 符合条件的配置列表 */ @GetMapping("/list") - @ControllerMethod("查询配置列表") public Message> list(@CurrentUser LoginAuthBean user) { return success(configGroupService.queryList(user.getUserId(), user.getGroupId())); } diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestBizService.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestBizService.java new file mode 100644 index 0000000..6a5d837 --- /dev/null +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestBizService.java @@ -0,0 +1,98 @@ +package cn.fw.dalaran.server.controller.web; + +import cn.fw.attendance.sdk.api.AttendanceApi; +import cn.fw.attendance.sdk.api.StaffStatusApi; +import cn.fw.attendance.sdk.api.dto.UsersScheduleDetailsDto; +import cn.fw.attendance.sdk.api.result.UserStatusVo; +import cn.fw.attendance.sdk.api.result.UsersScheduleDetailsVo; +import cn.fw.dalaran.domain.db.Account; +import cn.fw.dalaran.domain.enums.PlatformEnum; +import cn.fw.dalaran.service.data.AccountService; +import cn.fw.data.base.domain.common.Message; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +/** + * @author wmy3969 + * @version 1.0 + * @date 2022/10/12 0:23 + * @Description + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class TestBizService { + + /* + * A(不+事务注解)中调用B(+事务注解): + * A无事务, B无事务 + * + * A(+事务注解)中调用B(+事务注解): + * A有事务, B无事务 + * + * 解决方案: + * 1: bean中自己注入自己, 让A中调用B方法使用注入的自己去调用B方法(testBizService.methodB(), 而不是this.methodB()) + * 2: 配置类上声明@EnableAspectJAutoProxy(exposeProxy = true), 然后业务方法((TestBizService) AopContext.currentProxy()).methodB() + * AopContext.currentProxy()其实就是获取的代理对象, bean中注入的自己也是代理对象 + */ + + private TestBizService testBizService; + private final StaffStatusApi staffStatusApi; + private final AttendanceApi attendanceApi; + + @Autowired + public void inject(TestBizService testBizService) { + this.testBizService = testBizService; + } + + private final AccountService accountService; + + @Transactional(rollbackFor = Exception.class) + public void methodA() { + Message details = staffStatusApi.getUserStatusDetails(Arrays.asList(760L, 1545L, 1486L, 1342L), 1611975222000L, 1675047222937L); + UsersScheduleDetailsDto dto = new UsersScheduleDetailsDto(); + dto.setGroupId(2L); + dto.setUserIds(Arrays.asList(760L, 1545L, 1486L, 1342L)); + dto.setStartTime(new Date(1646818372000L)); + dto.setEndTime(new Date(1678354372000L)); + Message> scheduleDetails = attendanceApi.getUsersScheduleDetails(dto); + Account account = new Account(); + account.setAccount("methodA"); + account.setYn(Boolean.FALSE); + account.setGroupId(2L); + account.setType(PlatformEnum.DY); + account.setUserId(1545L); + account.setShopId(11L); + accountService.save(account); + try { + //this.methodB(); + //testBizService.methodB(); + //testBizService1.methodB(); + ((TestBizService) AopContext.currentProxy()).methodB(); + } catch (Exception e) { + e.printStackTrace(); + } + //int i = 1 / 0; + } + + @Transactional(rollbackFor = Exception.class/*, propagation = Propagation.REQUIRES_NEW*/) + public void methodB() { + Account account = new Account(); + account.setAccount("methodB"); + account.setYn(Boolean.FALSE); + account.setGroupId(2L); + account.setType(PlatformEnum.DY); + account.setUserId(1545L); + account.setShopId(11L); + accountService.save(account); + int i = 1 / 0; + } +} diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestController.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestController.java new file mode 100644 index 0000000..98c1304 --- /dev/null +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestController.java @@ -0,0 +1,35 @@ +package cn.fw.dalaran.server.controller.web; + +import cn.fw.security.auth.client.annotation.Authorization; +import cn.fw.security.auth.client.annotation.IgnoreAuth; +import cn.fw.security.auth.client.enums.AuthType; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author wmy3969 + * @version 1.0 + * @date 2022/10/12 0:23 + * @Description + */ +@Slf4j +@Validated +@RestController +@RequiredArgsConstructor +@Authorization(AuthType.ERP) +@RequestMapping("/web/test") +@IgnoreAuth +public class TestController { + + private final TestBizService testBizService; + + @GetMapping("/methodA") + public void methodA() { + testBizService.methodA(); + } + +} diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/InitStaffWorkStatusConsumer.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/InitStaffWorkStatusConsumer.java index a19b07e..ee3bc8e 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/InitStaffWorkStatusConsumer.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/InitStaffWorkStatusConsumer.java @@ -1,6 +1,6 @@ package cn.fw.dalaran.server.rocketMQ; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.domain.db.Account; import cn.fw.dalaran.domain.db.ActivityTheme; import cn.fw.dalaran.service.data.AccountService; @@ -25,9 +25,9 @@ import java.util.stream.Collectors; @Component @RequiredArgsConstructor @RocketMQMessageListener( - topic = "task-" + DalaranConstants.APPLICATION_NAME, - consumerGroup = DalaranConstants.APPLICATION_NAME + "-task-" + DalaranConstants.INIT_ACCOUNT_STATUS, - selectorExpression = DalaranConstants.INIT_ACCOUNT_STATUS) + topic = "task-" + Constants.APPLICATION_NAME, + consumerGroup = Constants.APPLICATION_NAME + "-task-" + Constants.INIT_ACCOUNT_STATUS, + selectorExpression = Constants.INIT_ACCOUNT_STATUS) public class InitStaffWorkStatusConsumer implements RocketMQListener { private final AccountService accountService; @@ -35,7 +35,7 @@ public class InitStaffWorkStatusConsumer implements RocketMQListener { @Override public void onMessage(Long themeId) { - log.info("收到topic为: task-{}, tag为: {}的消息, 消息内容(themeId): {}", DalaranConstants.APPLICATION_NAME, DalaranConstants.INIT_ACCOUNT_STATUS, themeId); + log.info("收到topic为: task-{}, tag为: {}的消息, 消息内容(themeId): {}", Constants.APPLICATION_NAME, Constants.INIT_ACCOUNT_STATUS, themeId); ActivityTheme theme; if (Objects.nonNull(theme = activityThemeService.getById(themeId))) { if (Objects.equals(theme.getAllShop(), 0)) { diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/SalaryEventConsumer.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/SalaryEventConsumer.java new file mode 100644 index 0000000..9de59ef --- /dev/null +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/SalaryEventConsumer.java @@ -0,0 +1,86 @@ +package cn.fw.dalaran.server.rocketMQ; + +import cn.fw.dalaran.common.constants.Constants; +import cn.fw.dalaran.common.utils.PublicUtil; +import cn.fw.dalaran.rpc.morax.SalaryRpc; +import cn.fw.dalaran.service.data.ActivityThemeService; +import cn.fw.morax.sdk.dto.CustomList; +import cn.fw.morax.sdk.dto.kpi.KpiGroupUserQuery; +import cn.fw.morax.sdk.dto.kpi.KpiGroupUserResult; +import cn.fw.morax.sdk.dto.kpi.KpiReportNoticeMQ; +import cn.fw.morax.sdk.dto.kpi.UserIndicatorReq; +import cn.fw.starter.redis.redis.RedisUtil; +import com.alibaba.fastjson.JSON; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Objects; + +/** + * @author wmy3969 + * @version 1.0 + * @date 2022/10/09 10:51 + * @Description 薪酬绩效MQ + */ +@Slf4j +@Component +@RequiredArgsConstructor +@RocketMQMessageListener( + topic = KpiReportNoticeMQ.TOPIC, + consumerGroup = Constants.APPLICATION_NAME + "-" + KpiReportNoticeMQ.TOPIC) +public class SalaryEventConsumer implements RocketMQListener { + + private final RedisUtil redisUtil;// redis操作工具 + private final SalaryRpc salaryRpc;// 薪酬绩效rpc + private final ActivityThemeService activityThemeService;// 活动主题业务 + + /** + * 处理'上报薪酬绩效'消息 + * + * @param kpiReport + */ + @Override + public void onMessage(KpiReportNoticeMQ kpiReport) { + String indicatorCode = kpiReport.getIndicatorCode(); + if (Objects.equals(Constants.Performance.SCORE_RATE, indicatorCode)) + return; + log.info("收到上报薪酬绩效消息 message:{}", JSON.toJSONString(kpiReport)); + String redisKey = "SalaryEventConsumer:onMessage"; + if (redisUtil.getLock(redisKey)) { + try { + KpiGroupUserQuery param = new KpiGroupUserQuery(); + param.setGroupId(kpiReport.getGroupId()); + param.setDataDate(kpiReport.getUploadDate().getTime()); + param.setPostId(kpiReport.getPostId()); + param.setIndicatorCode(indicatorCode); + List users = salaryRpc.queryGroupUsers(param); + CustomList indicates = new CustomList<>(); + users.forEach(item -> {// 遍历每个组 + /*BigDecimal targetValue = item.getTargetValue();// 目标值 + TargetTypeEnum targetType = item.getTargetType();// 获取目标类型*/ + List userIdList = item.getUserIdList(); + userIdList.forEach(item1 -> {// 每个组下的不同人 + UserIndicatorReq userIndicator = PublicUtil.copy(item1, UserIndicatorReq.class); + userIndicator.setIndicatorCode(indicatorCode); + userIndicator.setDataDate(kpiReport.getUploadDate()); + userIndicator.setUid(kpiReport.getUid()); + //userIndicator.setValue(); + indicates.add(userIndicator); + }); + }); + salaryRpc.reportKpi(indicates); + } catch (Exception e) { + log.error("处理上报薪酬绩效消息发生异常 message:{}", JSON.toJSONString(kpiReport), e); + } finally { + redisUtil.unlock(redisKey); + } + } else { + log.info("执行cn.fw.dalaran.server.rocketMQ.SalaryEventConsumer.onMessage()方法获取锁失败, 不消费消息"); + } + } + +} diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/StaffLeaveEventConsumer.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/StaffLeaveEventConsumer.java index 33d182f..6e78eb3 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/StaffLeaveEventConsumer.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/StaffLeaveEventConsumer.java @@ -1,6 +1,6 @@ package cn.fw.dalaran.server.rocketMQ; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.domain.db.Account; import cn.fw.dalaran.service.data.AccountService; import cn.fw.ehr.sdk.api.mq.StaffLeaveEvent; @@ -24,7 +24,7 @@ import java.util.Date; @RequiredArgsConstructor @RocketMQMessageListener( topic = StaffLeaveEvent.TOPIC, - consumerGroup = DalaranConstants.APPLICATION_NAME + "-" + StaffLeaveEvent.TOPIC) + consumerGroup = Constants.APPLICATION_NAME + "-" + StaffLeaveEvent.TOPIC) public class StaffLeaveEventConsumer implements RocketMQListener { private final AccountService accountService; diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java index 7b1e40b..8a4a2c2 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java @@ -38,7 +38,8 @@ public class OtherTask { .list() .stream() .filter(item -> activityThemeService.themeHaveStopCatchData(item.getEndTime(), 7)) - .collect(Collectors.toList());// 找到需要审计的主题 + .collect(Collectors.toList());// 找到需要删除的主题 + themeList.addAll(activityThemeService.getHasDelActivityTheme());// 找到已经逻辑删除的主题 if (CollectionUtils.isEmpty(themeList)) return; String tempDir = common.getActivityThemeCoverDir(); @@ -48,9 +49,6 @@ public class OtherTask { sb.append("activityTheme"); sb.append(File.separator); sb.append(item.getId()); - sb.append("「"); - sb.append(item.getTheme()); - sb.append("」"); String dirPath = sb.toString(); File file = new File(dirPath); if (file.isDirectory()) diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java index ff33072..a1a0e68 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java @@ -1,6 +1,7 @@ package cn.fw.dalaran.server.task; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.constants.Constants; +import cn.fw.dalaran.common.utils.DateUtil; import cn.fw.dalaran.domain.db.Account; import cn.fw.dalaran.domain.db.ActivityTheme; import cn.fw.dalaran.domain.db.LivePool; @@ -52,7 +53,7 @@ public class TodoTask { List list = todoHistoryService.list(Wrappers.lambdaQuery() .eq(TodoHistory::getSend, Boolean.FALSE) .eq(TodoHistory::getDone, Boolean.FALSE) - .ge(TodoHistory::getCreateTime, new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000L))// 创建时间不超过7天的 + .ge(TodoHistory::getCreateTime, DateUtil.minusDays(new Date(), 7))// 创建时间不超过7天的 );// 找到需要推送待办的数据项 if (CollectionUtils.isEmpty(list)) { return; @@ -60,10 +61,10 @@ public class TodoTask { final Map> todoMap = list.stream() .collect(Collectors.groupingBy(TodoHistory::getTodoCode));// 根据待办编码分组 final List loginAccount = Optional - .ofNullable(todoMap.get(DalaranConstants.ACCOUNT_INVALID)) + .ofNullable(todoMap.get(Constants.ACCOUNT_INVALID)) .orElse(new ArrayList<>()); final List checkLive = Optional - .ofNullable(todoMap.get(DalaranConstants.CHECK_LIVE)) + .ofNullable(todoMap.get(Constants.CHECK_LIVE)) .orElse(new ArrayList<>()); for (TodoHistory history : loginAccount) {// 处理账号登录待办 Account account = accountService.getById(history.getDataId()); @@ -116,12 +117,12 @@ public class TodoTask { return; } for (TodoHistory history : list) { - if (Objects.equals(history.getTodoCode(), DalaranConstants.ACCOUNT_INVALID)) {// 账号失效待办 + /*if (Objects.equals(history.getTodoCode(), Constants.ACCOUNT_INVALID)) {// 账号失效待办 Account account = accountService.getById(history.getDataId()); if (Objects.isNull(account)) { continue; } - } + }*/ BackLogItemDTO dto = new BackLogItemDTO(history.getUserId(), history.getTodoCode(), history.getDataId().toString(), new Date(), history.getShopId());// 构造待办参数 if (todoRpcService.complete(dto)) { @@ -136,15 +137,24 @@ public class TodoTask { */ @Scheduled(fixedRate = 15 * 60 * 1000, initialDelay = 5 * 1000) public void sendLiveCheckBacklog() { + this.sendLiveCheckBacklog(System.currentTimeMillis()); + } + + /** + * 发送直播审计待办 + * + * @param timeStamp 指定时间 + */ + public void sendLiveCheckBacklog(Long timeStamp) { final List themeList = activityThemeService.lambdaQuery() - .gt(ActivityTheme::getEndTime, new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000)) + .gt(ActivityTheme::getEndTime, new Date(timeStamp - 7 * 24 * 3600 * 1000)) .list() .stream() .filter(item -> { - final long timeSub = System.currentTimeMillis() - item.getEndTime().getTime(); + final long timeSub = timeStamp - item.getEndTime().getTime(); return 24 * 3600 * 1000 < timeSub && timeSub < 2 * 24 * 3600 * 1000; }) - .collect(Collectors.toList());// 找到需要审计的主题 + .collect(Collectors.toList());// 找到(理论上)需要审计的主题 if (CollectionUtils.isEmpty(themeList)) return; final List bestLives = livePoolService.lambdaQuery() @@ -155,8 +165,9 @@ public class TodoTask { .eq(LivePool::getValidLive, 11) .list();// 找到主题对应的所有人的最佳直播 final List waitCheckThemeIds = bestLives.stream() - .map(LivePool::getThemeId).distinct() - .collect(Collectors.toList());// 找到需要审核的主题id集合 + .map(LivePool::getThemeId) + .distinct() + .collect(Collectors.toList());// 根据最佳直播分布, 找到(真正)需要审核的主题id集合 if (CollectionUtils.isEmpty(waitCheckThemeIds)) return; final List usersInShopIds = accountService.lambdaQuery() @@ -170,13 +181,13 @@ public class TodoTask { .distinct()// 祛除重复门店 .collect(Collectors.toList());// 最佳直播的账户分布在对应的门店id集合 final List themeVos = themeList.stream() - .filter(item -> waitCheckThemeIds.contains(item.getId())) + .filter(item -> waitCheckThemeIds.contains(item.getId()))// 过滤出(真正)需要审核的主题 .map(ActivityTheme::toVO) .collect(Collectors.toList());// 将主题转换成vo if (CollectionUtils.isEmpty(themeVos)) return; List hasSaveTodo = todoHistoryService.lambdaQuery() - .eq(TodoHistory::getTodoCode, DalaranConstants.CHECK_LIVE) + .eq(TodoHistory::getTodoCode, Constants.CHECK_LIVE) .in(TodoHistory::getDataId, themeVos.stream() .map(ActivityThemeVo::getId) .collect(Collectors.toList()) @@ -186,12 +197,12 @@ public class TodoTask { .stream() .map(item -> {// 遍历每个门店 TodoHistory todo = new TodoHistory(); - List users = userRoleRpcService.getUsers(item, DalaranConstants.ZBSJ_ROLE_CODE);// 获取门店拥有'直播审计'角色的人 - if (users.size() > 0) { + List users = userRoleRpcService.getUsers(item, Constants.ZBSJ_ROLE_CODE);// 获取门店拥有'直播审计'角色的人 + if (!users.isEmpty()) { todo.setSend(false); todo.setDone(false); todo.setTodoDone(false); - todo.setTodoCode(DalaranConstants.CHECK_LIVE); + todo.setTodoCode(Constants.CHECK_LIVE); todo.setDataId(themeVos.stream() .filter(item1 -> item1.getShopIds().contains(item)) .collect(Collectors.toList()) @@ -205,7 +216,7 @@ public class TodoTask { }) .filter(item -> Objects.nonNull(item.getTodoCode())) .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> - new TreeSet<>(Comparator.comparing(TodoHistory::getDataId))), ArrayList::new) + new TreeSet<>(Comparator.comparing(TodoHistory::getRemoveDuplicatesCondition))), ArrayList::new) ); if (!Objects.equals(hasSaveTodo.size(), 0) && Objects.equals(collect.size(), hasSaveTodo.size())) return; diff --git a/fw-dalaran-server/src/main/resources/application-dev.yml b/fw-dalaran-server/src/main/resources/application-dev.yml index e8db712..3207f05 100644 --- a/fw-dalaran-server/src/main/resources/application-dev.yml +++ b/fw-dalaran-server/src/main/resources/application-dev.yml @@ -23,3 +23,8 @@ logging: nacos: plugin: namespace: df959b8c-de58-4d02-b9fb-d65ca3be05f3 + +url: + show: https://testgate.feewee.cn/file/show?fid= #文件服务器地址 + del-map-cache: http://testgate.feewee.cn/report2/dalaran/004/other/clearCache #清除报表系统自媒体数据缓存 + re-calc-score: http://testgate.feewee.cn/report2/debug/extract/data/dalaran?dateType=DAILY&type=Dalaran004D&date= #重新抽取综合得分 diff --git a/fw-dalaran-server/src/main/resources/application-local.yml b/fw-dalaran-server/src/main/resources/application-local.yml index 07a2061..365bec3 100644 --- a/fw-dalaran-server/src/main/resources/application-local.yml +++ b/fw-dalaran-server/src/main/resources/application-local.yml @@ -12,8 +12,14 @@ nacos: spring: application: name: fw-dalaran-local + banner: + location: "classpath:banner.txt" + redis: + host: 172.26.154.169 + password: fw@test@redis + port: 6378 rocketmq: -# name-server: 192.168.0.230:9876 + # name-server: 192.168.0.230:9876 name-server: 172.26.154.169:9876 producer: group: ${spring.application.name} @@ -27,4 +33,7 @@ jedis: pwd: fw@test@redis port: 6378 -file-server-addr: 'http://testgate.feewee.cn/file/show?fid=' +url: + show: https://testgate.feewee.cn/file/show?fid= #文件服务器地址 + del-map-cache: http://testgate.feewee.cn/report2/dalaran/004/other/clearCache #清除报表系统自媒体数据缓存 + re-calc-score: http://testgate.feewee.cn/report2/debug/extract/data/dalaran?dateType=DAILY&type=Dalaran004D&date= #重新抽取综合得分 diff --git a/fw-dalaran-server/src/main/resources/application-prd.yml b/fw-dalaran-server/src/main/resources/application-prd.yml index 3c3e59f..99f20fe 100644 --- a/fw-dalaran-server/src/main/resources/application-prd.yml +++ b/fw-dalaran-server/src/main/resources/application-prd.yml @@ -51,4 +51,7 @@ rocketmq: task: switch: 'on' -file-server-addr: 'http://gate.feewee.cn/file/show?fid=' +url: + show: https://gate.feewee.cn/file/show?fid= #文件服务器地址 + del-map-cache: http://gate.feewee.cn/report2/dalaran/004/other/clearCache #清除报表系统自媒体数据缓存 + re-calc-score: http://gate.feewee.cn/report2/debug/extract/data/dalaran?dateType=DAILY&type=Dalaran004D&date= #重新抽取综合得分 diff --git a/fw-dalaran-server/src/main/resources/application-test.yml b/fw-dalaran-server/src/main/resources/application-test.yml index b417ac2..f5efdaf 100644 --- a/fw-dalaran-server/src/main/resources/application-test.yml +++ b/fw-dalaran-server/src/main/resources/application-test.yml @@ -46,4 +46,4 @@ logging: task: switch: 'on' -file-server-addr: 'http://testgate.feewee.cn/file/show?fid=' +file-server-addr: 'https://testgate.feewee.cn/file/show?fid=' diff --git a/fw-dalaran-server/src/main/resources/application.yml b/fw-dalaran-server/src/main/resources/application.yml index 23d5bf3..8547a81 100644 --- a/fw-dalaran-server/src/main/resources/application.yml +++ b/fw-dalaran-server/src/main/resources/application.yml @@ -1,4 +1,6 @@ spring: + banner: + charset: US-ASCII application: name: fw-dalaran attachment: @@ -112,3 +114,20 @@ logbook: task: switch: 'on' todocode: 'xiOMX9KlMg' + +management: + endpoints: + web: + exposure: + include: '*' + # 监控路径前缀 + base-path: /actuator + endpoint: + # 开启允许远程shutdown,通过post请求。 + shutdown: + enabled: true + health: + show-details: always + metrics: + tags: + application: ${spring.application.name} diff --git a/fw-dalaran-service/pom.xml b/fw-dalaran-service/pom.xml index cd481cd..ef13418 100644 --- a/fw-dalaran-service/pom.xml +++ b/fw-dalaran-service/pom.xml @@ -114,14 +114,14 @@ com.baomidou mybatis-plus-boot-starter - + diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/AccountBizService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/AccountBizService.java index 425df6f..7f4df85 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/AccountBizService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/AccountBizService.java @@ -2,7 +2,7 @@ package cn.fw.dalaran.service.biz; import cn.fw.common.page.AppPage; import cn.fw.common.web.annotation.DisLock; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.common.exception.BusinessException; import cn.fw.dalaran.common.utils.DateUtil; import cn.fw.dalaran.domain.db.Account; @@ -10,6 +10,7 @@ import cn.fw.dalaran.domain.db.TodoHistory; import cn.fw.dalaran.domain.dto.AccountDTO; import cn.fw.dalaran.domain.dto.AccountQueryDTO; import cn.fw.dalaran.domain.dto.UpdateAccountParam; +import cn.fw.dalaran.domain.enums.AccountStatusEnum; import cn.fw.dalaran.domain.enums.PlatformEnum; import cn.fw.dalaran.domain.vo.AccountStatusVo; import cn.fw.dalaran.domain.vo.AccountVO; @@ -40,8 +41,8 @@ import static cn.fw.common.businessvalidator.Validator.BV; @RequiredArgsConstructor public class AccountBizService { - private final AccountService accountService; - private final TodoHistoryService todoHistoryService; + private final AccountService accountService;// 账号业务 + private final TodoHistoryService todoHistoryService;// 待办业务 private final UserRoleRpcService userRoleRpcService; /** @@ -112,9 +113,9 @@ public class AccountBizService { history.setDataId(account1.getId()); history.setShopId(account1.getShopId()); history.setUserId(account1.getUserId()); - history.setTodoCode(DalaranConstants.ACCOUNT_INVALID); + history.setTodoCode(Constants.ACCOUNT_INVALID); todos.add(history); - List users = userRoleRpcService.getUsers(account1.getShopId(), DalaranConstants.ZHSZ_ROLE_CODE); + List users = userRoleRpcService.getUsers(account1.getShopId(), Constants.ZHSZ_ROLE_CODE); if (!CollectionUtils.isEmpty(users)) { Long managerId = users.get(0).getUserId(); TodoHistory manageTodo = new TodoHistory(); @@ -128,7 +129,7 @@ public class AccountBizService { .map(Account::getId) .collect(Collectors.toList());// 失败账号id List todayHasSendList = todoHistoryService.lambdaQuery() - .eq(TodoHistory::getTodoCode, DalaranConstants.ACCOUNT_INVALID) + .eq(TodoHistory::getTodoCode, Constants.ACCOUNT_INVALID) .in(!CollectionUtils.isEmpty(waitSendIds), TodoHistory::getDataId, waitSendIds) .last(" and DATEDIFF(create_time, NOW()) = 0") .list(); @@ -256,8 +257,8 @@ public class AccountBizService { .eq(Account::getAffirm, Boolean.TRUE) .eq(Account::getValid, Boolean.TRUE) .eq(Account::getType, platformEnum) - .ne(Account::getAccountStatus, -1) - //.eq(Account::getAccountStatus, 1) + .ne(Account::getAccountStatus, AccountStatusEnum.HAS_LEAVE.getValue()) + //.eq(Account::getAccountStatus, AccountStatusEnum.IN_WORK.getValue()) .eq(Account::getYn, Boolean.TRUE) ); if (CollectionUtils.isEmpty(list)) { @@ -281,6 +282,11 @@ public class AccountBizService { */ @Transactional(rollbackFor = Exception.class) public boolean deleteAccount(Long id) { + todoHistoryService.lambdaUpdate() + .eq(TodoHistory::getDataId, id) + .eq(TodoHistory::getTodoCode, Constants.ACCOUNT_INVALID) + .set(TodoHistory::getDone, Boolean.TRUE) + .update();// 账号删除完成登录待办 return accountService.lambdaUpdate() .eq(Account::getId, id) .set(Account::getYn, 0) diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java index edab9a4..e075087 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java @@ -781,8 +781,9 @@ public class CommonBizService { } public static void main(String[] args) { - String workTitle = "#长安汽车618闪购 #长安univ #自有引力"; - String setTopic = "#618厂店联动团购会#长安汽车618闪购#嗨购618团购会"; + System.out.println(System.getProperty("java.io.tmpdir")); + String workTitle = "#现车加\\\"免\\\"开新过新年"; + String setTopic = "#温暖回家路提现车过新年,#现车加\\免\\开新过新年,#温暖回家路春节不打烊,#开年有礼大展宏兔,#智电超能体验,#开新年夜FUN,#温暖回家路一路有你,#展厅实车带货UNI-K iDD".replace(",", ""); Set strings1 = processTags(workTitle); Set strings2 = processTags(setTopic); System.out.println(CollectionUtils.containsAny(strings1, strings2)); @@ -841,7 +842,7 @@ public class CommonBizService { resultSet.retainAll(configTags);// 交集 //resultSet.removeAll(configTags);// 差集 //resultSet.addAll(configTags);// 并集 - containsTag = resultSet.size() > 0; + containsTag = !resultSet.isEmpty(); } else {// LCS计算话题匹配度 for (String configTag : configTags) { for (String tag : tags) { @@ -971,17 +972,17 @@ public class CommonBizService { public BigDecimal validCover(String theme, Long themeId, String fileId, String coverUrl, String account, String itemId, Integer type) throws Exception { int[][] imagePixArr1;// 图片1的像素数组 int[][] imagePixArr2;// 图片2的像素数组 - File imageFile1 = this.findLocalCacheImageTheme(theme, themeId, fileId); + File imageFile1 = this.findLocalCacheImageTheme(/*theme,*/ themeId, fileId); imagePixArr1 = ImageUtils.readImagePixel(imageFile1); File imageFile2; - File localCacheImage = this.findLocalCacheImageUser(theme, themeId, account, itemId, type); + File localCacheImage = this.findLocalCacheImageUser(/*theme,*/ themeId, account, itemId, type); if (Objects.nonNull(localCacheImage)) { imageFile2 = localCacheImage; } else { imageFile2 = ImageUtils.convertFileByUrl(coverUrl, itemId); String tempDir = common.getActivityThemeCoverDir(); File file = new File(ImageUtils.modifyResolution1(imageFile2.getPath(), - tempDir + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"), + tempDir + "activityTheme" + File.separator + themeId /*+ "#" + theme*/ + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"), "fw_theme_cover_" + itemId, 512, 512)); if (imageFile2.delete()) { @@ -989,7 +990,7 @@ public class CommonBizService { } } imagePixArr2 = ImageUtils.readImagePixel(imageFile2); - String msg = String.format("\n 主题: %s\n 设置封面文件id: %s\n 账户号: %s\n %s%s\n", theme, fileId, account, Objects.equals(type, 1) ? "短视频id: " : "直播间号: ", itemId); + String msg = String.format("\n 主题id: %s \n 主题名: %s\n 设置封面文件id: %s\n 账户号: %s\n %s%s\n", themeId, theme, fileId, account, Objects.equals(type, 1) ? "短视频id: " : "直播间号: ", itemId); return BigDecimal.valueOf(ImageUtils.calcSimilarity(ImageUtils.getFingerprint(imagePixArr1), ImageUtils.getFingerprint(imagePixArr2), msg)); } @@ -1002,9 +1003,9 @@ public class CommonBizService { * @param itemId 视频id/直播间id * @param type 1:视频, 2:直播 */ - private File findLocalCacheImageUser(String theme, Long themeId, String account, String itemId, Integer type) { + private File findLocalCacheImageUser(/*String theme,*/ Long themeId, String account, String itemId, Integer type) { String tempDir = common.getActivityThemeCoverDir(); - File file = new File(tempDir + File.separator + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live")); + File file = new File(tempDir + File.separator + "activityTheme" + File.separator + themeId /*+ "#" + theme*/ + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live")); if (!file.exists()) { boolean mkdirs = file.mkdirs(); if (mkdirs) @@ -1021,15 +1022,15 @@ public class CommonBizService { } /** - * 获取本地已下载的主题背景图 + * 获取本地已下载的主题背景图(主题预设封面图) * * @param theme 主题名 * @param themeId 主题id * @param fileId 文件id(主题配置指定封面图文件) */ - private File findLocalCacheImageTheme(String theme, Long themeId, String fileId) { + private File findLocalCacheImageTheme(/*String theme,*/ Long themeId, String fileId) { String tempDir = common.getActivityThemeCoverDir(); - File file = new File(tempDir + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + "settingCover"); + File file = new File(tempDir + "activityTheme" + File.separator + themeId /*+ "#" + theme*/ + File.separator + "settingCover"); if (!file.exists()) { boolean mkdirs = file.mkdirs(); if (mkdirs) diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java index 229c3db..75ba723 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java @@ -1,6 +1,7 @@ package cn.fw.dalaran.service.biz; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.ConfigProperties; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.common.exception.BusinessException; import cn.fw.dalaran.common.utils.PublicUtil; import cn.fw.dalaran.common.utils.StringUtils; @@ -43,6 +44,7 @@ import java.util.stream.Collectors; public class OtherBizService { @Value("${spring.profiles.active}") private String env;// 获取系统当前环境 + private final ConfigProperties configProperties; private final ActivityThemeService activityThemeService; private final LivePoolService livePoolService; private final LiveCheckResultService liveCheckResultService; @@ -58,10 +60,10 @@ public class OtherBizService { * @param themeId 主题id * @return 审计视图 */ - @Transactional + @Transactional(rollbackFor = Exception.class) public LiveCheckVo getLiveCheck(Long userId, Long themeId) { LiveCheckVo vo = new LiveCheckVo(); - final List userRoleRange = userRoleRpcService.getUserRoleRange(userId, DalaranConstants.ZBSJ_ROLE_CODE);// 查询用户角色授权范围 + final List userRoleRange = userRoleRpcService.getUserRoleRange(userId, Constants.ZBSJ_ROLE_CODE);// 查询用户角色授权范围 List waitCheckLives = new ArrayList<>(); List list = liveCheckResultService.lambdaQuery() .eq(LiveCheckResult::getThemeId, themeId) @@ -103,13 +105,13 @@ public class OtherBizService { } if (!CollectionUtils.isEmpty(waitCheckLives)) { vo.setTheme(ActivityTheme.toVO(Objects.requireNonNull(activityThemeService.getById(themeId)))); - vo.setLiveList(PublicUtil.copyList(waitCheckLives, LiveCheckVo.liveSummary.class).stream() + vo.setLiveList(PublicUtil.copyList(waitCheckLives, LiveCheckVo.LiveSummary.class).stream() .peek(item -> { final LivePool live = livePoolService.getById(item.getLiveId()); item.setTitle(live.getTitle()); item.setPlaybackUrl(live.getPlaybackUrl()); }) - .sorted(Comparator.comparing(LiveCheckVo.liveSummary::getCounterfeit)) + .sorted(Comparator.comparing(LiveCheckVo.LiveSummary::getCounterfeit)) .collect(Collectors.toList()) ); } @@ -123,7 +125,7 @@ public class OtherBizService { * @param param 审核结果 * @return 操作结果 */ - @Transactional + @Transactional(rollbackFor = Exception.class) public boolean saveCheckResult(Long userId, LiveCheckParams param) { final Integer type = param.getType(); final Long dataId = param.getDataId(); @@ -172,7 +174,7 @@ public class OtherBizService { liveCheckResult.setValid(Objects.equals(liveCheckResult.getCounterfeit(), 0) && Objects.equals(liveCheckResult.getPay(), 0) ? 1 : 0); return liveCheckResultService.updateById(liveCheckResult); } else if (Objects.equals(type, 1)) {// 完成待办 - final List summaries = this.getLiveCheck(userId, dataId).getLiveList(); + final List summaries = this.getLiveCheck(userId, dataId).getLiveList(); if (summaries.stream().anyMatch(item -> Objects.equals(item.getCounterfeit(), -1))) { throw new BusinessException("还有未完成审核的直播, 请完成所有直播审核后重新提交"); } else { @@ -180,12 +182,12 @@ public class OtherBizService { .set(TodoHistory::getDone, true) .eq(TodoHistory::getUserId, userId) .eq(TodoHistory::getDataId, dataId) - .eq(TodoHistory::getTodoCode, DalaranConstants.CHECK_LIVE) + .eq(TodoHistory::getTodoCode, Constants.CHECK_LIVE) .update()) throw new BusinessException("完成待办失败"); final List invalidLiveIds = summaries.stream() .filter(item -> Objects.equals(item.getValid(), 0)) - .map(LiveCheckVo.liveSummary::getLiveId) + .map(LiveCheckVo.LiveSummary::getLiveId) .collect(Collectors.toList()); if (!CollectionUtils.isEmpty(invalidLiveIds)) { ActivityTheme activityTheme = activityThemeService.getById(param.getDataId()); @@ -196,7 +198,8 @@ public class OtherBizService { while (!flag && cnt < 5) { if (cnt > 0) LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(1)); - flag = this.sendGetRequest("http://" + (env.contains("prd") ? "" : "test") + "gate.feewee.cn/report2/debug/extract/data/dalaran?dateType=DAILY&type=Dalaran004D&date=" + + this.sendGetRequest(configProperties.getDelMapCache());// 清空缓存 + flag = this.sendGetRequest(configProperties.getReCalcScore() + sdf.format(activityTheme.getEndTime()) ); cnt++; @@ -211,7 +214,7 @@ public class OtherBizService { .set(LiveCheckResult::getStatus, type) .in(LiveCheckResult::getId, summaries .stream() - .map(LiveCheckVo.liveSummary::getId) + .map(LiveCheckVo.LiveSummary::getId) .collect(Collectors.toList()) ).update(); } @@ -225,9 +228,9 @@ public class OtherBizService { * @param id * @return */ - public LiveCheckVo.liveSummary getLiveCheckDetails(Long id) { + public LiveCheckVo.LiveSummary getLiveCheckDetails(Long id) { final LiveCheckResult checkResult = liveCheckResultService.getById(id); - final LiveCheckVo.liveSummary liveSummary = PublicUtil.copy(checkResult, LiveCheckVo.liveSummary.class); + final LiveCheckVo.LiveSummary liveSummary = PublicUtil.copy(checkResult, LiveCheckVo.LiveSummary.class); final LivePool live = livePoolService.getById(checkResult.getLiveId()); liveSummary.setTitle(live.getTitle()); liveSummary.setPlaybackUrl(live.getPlaybackUrl()); diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/ActivityThemeService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/ActivityThemeService.java index c733c84..d9460a8 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/ActivityThemeService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/ActivityThemeService.java @@ -111,4 +111,11 @@ public interface ActivityThemeService extends IService { * @return 主题是否结束数据抓取 */ boolean themeHaveStopCatchData(Date themeEndTime, int delayDays); + + /** + * 获取已经逻辑删除的主题列表 + * + * @return 已经逻辑删除的主题列表 + */ + List getHasDelActivityTheme(); } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java index 3ae5bfc..dbc5b1e 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java @@ -2,7 +2,8 @@ package cn.fw.dalaran.service.data.impl; import cn.fw.common.page.AppPage; import cn.fw.common.web.auth.LoginAuthBean; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.ConfigProperties; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.common.exception.BusinessException; import cn.fw.dalaran.common.utils.DateUtil; import cn.fw.dalaran.common.utils.ImageUtils; @@ -35,7 +36,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -59,8 +59,7 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class ActivityThemeServiceImpl extends ServiceImpl implements ActivityThemeService { - @Value("${file-server-addr}") - private String serverAddr; + private final ConfigProperties configProperties; private final ActivityThemeDao activityThemeDao; private final ConfigGroupService configGroupService; private final ThemeFileService themeFileService; @@ -83,7 +82,14 @@ public class ActivityThemeServiceImpl extends ServiceImpl validDateOverlap(item.getStartTime(), item.getEndTime(), vo.getStartTime(), vo.getEndTime()) &&// 验证时间重叠 /*(Objects.equals(item.getAllShop(), 1) || vo.getAllShop() || validShopOverlap(Arrays.stream(item.getShopIds().split(",")).map(Long::valueOf).collect(Collectors.toList()), vo.getShopIds()))// 验证门店重叠*/ - (Objects.equals(item.getAllShop(), 1) || configGroup.getAllShop() > 0 || validShopOverlap(Arrays.stream(item.getShopIds().split(",")).map(Long::valueOf).collect(Collectors.toList()), Arrays.stream(configGroup.getShopIds().split(",")).map(Long::valueOf).collect(Collectors.toList())))// 验证门店重叠 + (Objects.equals(item.getAllShop(), 1) || configGroup.getAllShop() > 0 || + validShopOverlap(Arrays.stream(item.getShopIds().split(",")) + .map(Long::valueOf) + .collect(Collectors.toList()), Arrays.stream(configGroup.getShopIds().split(",")) + .map(Long::valueOf) + .collect(Collectors.toList()) + ) + )// 验证门店重叠 ); } @@ -125,7 +131,7 @@ public class ActivityThemeServiceImpl extends ServiceImplbuilder() .executeTime(new Date(activityTheme.getStartTime().getTime() + 24 * 3600 * 1000L)) - .system(DalaranConstants.APPLICATION_NAME) + .system(Constants.APPLICATION_NAME) .param(activityTheme.getId()) - .tag(DalaranConstants.INIT_ACCOUNT_STATUS) + .tag(Constants.INIT_ACCOUNT_STATUS) .build() ); this.saveFiles(activityTheme.getId(), themeVo.getAllFileDesc()); @@ -189,7 +195,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl fileList = params.getCovers() @@ -363,9 +369,9 @@ public class ActivityThemeServiceImpl extends ServiceImpl { try { String fileId = item.getFid(); - File downloadFile = ImageUtils.convertFileByUrl(serverAddr + fileId, fileId); + File downloadFile = ImageUtils.convertFileByUrl(configProperties.getShow() + fileId, fileId); ImageUtils.modifyResolution1(downloadFile.getPath(), - tempDir + "activityTheme" + File.separator + activityTheme.getId() + "「" + activityTheme.getTheme() + "」" + File.separator + "settingCover", + tempDir + "activityTheme" + File.separator + activityTheme.getId() /*+ "#" + activityTheme.getTheme()*/ + File.separator + "settingCover", "fw_theme_cover_" + fileId, 512, 512); boolean result = downloadFile.delete(); @@ -376,6 +382,47 @@ public class ActivityThemeServiceImpl extends ServiceImpl { + try { + File downloadFile = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=" + item, item); + ImageUtils.modifyResolution(downloadFile.getPath(), + tempDir + "activityTheme" + File.separator + themeId /*+ "#" + activityTheme.getTheme()*/ + File.separator + "settingCover", + "fw_theme_cover_" + item, + 512, 512); + boolean result = downloadFile.delete(); + } catch (Exception e) { + log.error("下载转换封面图失败", e); + } + }); + } + + /** * 监听器, 收到消息后执行更新主题信息 * * @param msg 消息 @@ -435,4 +482,14 @@ public class ActivityThemeServiceImpl extends ServiceImpl getHasDelActivityTheme() { + return activityThemeDao.getHasDelActivityTheme(); + } + } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ConfigGroupServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ConfigGroupServiceImpl.java index 9b2255b..408b3f7 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ConfigGroupServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ConfigGroupServiceImpl.java @@ -1,6 +1,6 @@ package cn.fw.dalaran.service.data.impl; -import cn.fw.dalaran.common.constants.DalaranConstants; +import cn.fw.dalaran.common.constants.Constants; import cn.fw.dalaran.common.exception.BusinessException; import cn.fw.dalaran.dao.ConfigGroupDao; import cn.fw.dalaran.domain.db.ActivityTheme; @@ -66,14 +66,15 @@ public class ConfigGroupServiceImpl extends ServiceImpl 0) - throw new BusinessException("该用户存在一个已初始化但未赋值修改的配置组"); + .list() + .isEmpty() + ) throw new BusinessException("该用户存在一个已初始化但未赋值修改的配置组"); ConfigGroup configGroup = new ConfigGroup(); configGroup.setUserId(userId); configGroup.setGroupId(groupId); @@ -94,7 +95,7 @@ public class ConfigGroupServiceImpl extends ServiceImpl 0) throw new BusinessException("该集团已存在门店配置, 新配置不能设置为[全部门店]"); + if (!list.isEmpty()) throw new BusinessException("该集团已存在门店配置, 新配置不能设置为[全部门店]"); } else if (list.stream().anyMatch(item -> Objects.equals(item.getAllShop(), 1))) {// 已存在的配置组是否有全部门店的 throw new BusinessException("该集团已存在[全部门店]配置, 新配置不能生效"); } else { List shopIds = param.getShopIds();// 本次配置指定生效门店 List shopNames = param.getShopNames();// 本次配置指定生效门店 if (Objects.equals(allShop, -1)) {// 指定为授权门店 - List userRoleRange = userRoleRpcService.getUserRoleRange(param.getUserId(), DalaranConstants.ZBSZ_ROLE_CODE);// 查询用户角色授权范围 + List userRoleRange = userRoleRpcService.getUserRoleRange(param.getUserId(), Constants.ZBSZ_ROLE_CODE);// 查询用户角色授权范围 shopIds.clear(); shopNames.clear(); for (ShopMsg shopMsg : userRoleRange) { @@ -201,20 +202,20 @@ public class ConfigGroupServiceImpl extends ServiceImpl queryList(Long userId, Long groupId) { - List collect = this.lambdaQuery() + Map> collectMap = this.lambdaQuery() .eq(ConfigGroup::getGroupId, groupId) .list() .stream() .map(item -> this.processVo(item, true)) - .collect(Collectors.toList()); - Map> collectMap = collect.stream() .collect(Collectors.groupingBy(ConfigGroupVo::getUserId)); List vos = new ArrayList<>(Optional .ofNullable(collectMap.get(userId)) .orElse(new ArrayList<>()) );// 尝试获取属于登录用户的配置组 + /* 下面两步操作, 为了让属于自己的配置组能展示在最前面 */ collectMap.remove(userId);// 将属于该用户的配置从map中移除 collectMap.forEach((k, v) -> vos.addAll(v));// 将其他人的配置组加入vo + vos.forEach(item -> item.setCanAlter(Objects.equals(item.getUserId(), userId)));// 标记是否是自己的配置组 return vos; } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/GlobalConfigServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/GlobalConfigServiceImpl.java index 2fcb1e1..a648965 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/GlobalConfigServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/GlobalConfigServiceImpl.java @@ -6,6 +6,7 @@ import cn.fw.dalaran.domain.db.GlobalConfig; import cn.fw.dalaran.domain.enums.ConfigEnum; import cn.fw.dalaran.service.data.GlobalConfigService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -25,6 +26,13 @@ import java.util.stream.Collectors; @Service("globalConfigService") public class GlobalConfigServiceImpl extends ServiceImpl implements GlobalConfigService { + private GlobalConfigServiceImpl globalConfigService; + + @Autowired + public void inject(GlobalConfigServiceImpl globalConfigService) { + this.globalConfigService = globalConfigService; + } + /** * 获取列表 * @@ -39,6 +47,7 @@ public class GlobalConfigServiceImpl extends ServiceImpl globalConfigs) { - PublicUtil.assertFalse(globalConfigs.stream().anyMatch(item -> item.getRate().compareTo(BigDecimal.ZERO) < 0), "占比必须 > 0%"); - PublicUtil.assertFalse(globalConfigs.stream().anyMatch(item -> item.getRate().compareTo(BigDecimal.valueOf(100)) > 0), "占比必须 < 100%"); + PublicUtil.assertFalse(globalConfigs.stream() + .anyMatch(item -> item.getRate().compareTo(BigDecimal.ZERO) < 0), "占比必须 > 0%"); + PublicUtil.assertFalse(globalConfigs.stream() + .anyMatch(item -> item.getRate().compareTo(BigDecimal.valueOf(100)) > 0), "占比必须 < 100%"); this.saveOrUpdateBatch(PublicUtil.copyList(globalConfigs, GlobalConfig.class)); } @@ -62,7 +73,7 @@ public class GlobalConfigServiceImpl extends ServiceImpl initConfigList(Long configGroupId) { final List list = this.lambdaQuery() .eq(GlobalConfig::getConfigGroupId, configGroupId) @@ -76,13 +87,15 @@ public class GlobalConfigServiceImpl extends ServiceImpl collect1 = list.stream() .filter(item1 -> Objects.equals(item.getValue(), item1.getType())) .collect(Collectors.toList()); - if (collect1.size() > 0) { + if (!collect1.isEmpty()) { rate = collect1.get(0).getRate(); } return new GlobalConfig(configGroupId, item.getValue(), rate); }) .collect(Collectors.toList()); this.saveBatch(collect); + //int i = 1 / 0; return collect; } + } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/LivePoolServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/LivePoolServiceImpl.java index 35e8bba..e6ebf47 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/LivePoolServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/LivePoolServiceImpl.java @@ -87,7 +87,7 @@ public class LivePoolServiceImpl extends ServiceImpl impl * @return */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public boolean markBestLive(Long liveId) { final LivePool live = this.getById(liveId); final Long themeId = live.getThemeId();// 获取主题id diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ValidConfigNewServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ValidConfigNewServiceImpl.java index 2a37c5c..00b3fed 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ValidConfigNewServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ValidConfigNewServiceImpl.java @@ -38,7 +38,7 @@ public class ValidConfigNewServiceImpl extends ServiceImpl details) { details.forEach(item -> this.updateById(ValidConfigNewVo.toDB(item))); publisher.publishEvent("validConfigAlertEvent#" + details.get(0).getConfigGroupId()); @@ -84,7 +84,7 @@ public class ValidConfigNewServiceImpl extends ServiceImpl initVideoConfigList(Long configGroupId) { final List list = this.lambdaQuery() .eq(ValidConfigNew::getConfigGroupId, configGroupId) @@ -115,7 +115,7 @@ public class ValidConfigNewServiceImpl extends ServiceImpl initLiveConfigList(Long configGroupId) { final List list = this.lambdaQuery() .eq(ValidConfigNew::getConfigGroupId, configGroupId) diff --git a/fw-dalaran-service/src/main/test/codeGenerator/CodeGenerator.java b/fw-dalaran-service/src/main/test/codeGenerator/CodeGenerator.java index c694053..03857a4 100644 --- a/fw-dalaran-service/src/main/test/codeGenerator/CodeGenerator.java +++ b/fw-dalaran-service/src/main/test/codeGenerator/CodeGenerator.java @@ -1,25 +1,12 @@ package codeGenerator; -import com.baomidou.mybatisplus.annotation.DbType; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.generator.AutoGenerator; -import com.baomidou.mybatisplus.generator.config.DataSourceConfig; -import com.baomidou.mybatisplus.generator.config.GlobalConfig; -import com.baomidou.mybatisplus.generator.config.PackageConfig; -import com.baomidou.mybatisplus.generator.config.StrategyConfig; -import com.baomidou.mybatisplus.generator.config.po.TableFill; -import com.baomidou.mybatisplus.generator.config.rules.DateType; -import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; import org.junit.Test; -import java.util.ArrayList; - public class CodeGenerator { @Test public void getCode() { - // 1、全局配置 + /*// 1、全局配置 GlobalConfig globalConfig = new GlobalConfig(); globalConfig .setOutputDir("D:\\Users\\wmy\\feiweiProjects\\fw-dalaran\\fw-dalaran-domain\\src\\main\\java\\codeGenerate" + "/src/main/java")//1.修改为你项目的目录 @@ -80,7 +67,7 @@ public class CodeGenerator { .setPackageInfo(packageConfig) .setStrategy(strategyConfig); // 7、执行 - autoGenerator.execute(); + autoGenerator.execute();*/ } } diff --git a/fw-dalaran-service/src/main/test/example/ImageListener.java b/fw-dalaran-service/src/main/test/example/ImageListener.java index 9c9d435..8c06c9a 100644 --- a/fw-dalaran-service/src/main/test/example/ImageListener.java +++ b/fw-dalaran-service/src/main/test/example/ImageListener.java @@ -19,8 +19,8 @@ public class ImageListener implements ActionListener { } public ImageListener() throws Exception { - File imageFile1 = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=e1d71b45dd0e4d73bde25afc3e260de5"); - File imageFile2 = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=7dfedbed8996443584b6b2221b79235e"); + File imageFile1 = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=0684ce9b0d384ff1a1070c61b7ed376c"); + File imageFile2 = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=0aff5b6acf6040459b6d5e69f1290c3b"); //File imageFile2 = ImageUtils.convertFileByUrl("https://p2.a.yximgs.com/upic/2022/01/20/20/BMjAyMjAxMjAyMDEyMTZfNDcwOTM0NDgyXzY1MzMwMDA5Mjk0XzJfMw==_B0296c8ed5afa94b9b7a06dd1612c3ecb.jpg?tag=1-1642748356-nil-0-ndrgo4aid6-21e0d82706b2e935&clientCacheKey=3x4xb3uvxtpibvc.jpg&di=abd4f314&bp=10000"); /*File imageFile1 = new File("C:\\Users\\wmy3969\\Desktop\\2.png"); File imageFile2 = new File("C:\\Users\\wmy3969\\Desktop\\2022.4.23-4.30短视频背景封面jpg\\春风十里焕新鲸喜\\1.png");*/ diff --git a/pom.xml b/pom.xml index 9d54145..a053ff6 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ 1.0.0 1.0.0 1.0 + 1.0.0 1.2.78 3.0.0 1.0.1 @@ -147,6 +148,12 @@ fw-backlog-sdk ${fw.backlog.sdk} + + + cn.fw + fw-morax-sdk + ${fw.morax.sdk.version} + cn.fw fw-erp-sdk @@ -167,6 +174,11 @@ mybatis-typehandlers-jsr310 ${mybatis-typehandlers-jsr310} + + org.springframework.boot + spring-boot-configuration-processor + 2.1.12.RELEASE + @@ -192,17 +204,17 @@ mybatis-plus-boot-starter 3.3.2 - + - +