Commit 43e02b402089ec4e2faa9166701b7012ece47798

Authored by 王明元
2 parents 7ddfd0ec 8e204818

Merge remote-tracking branch 'origin/main'

fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/report/score/ThemeScoreListVo.java
1 1 package cn.fw.dalaran.domain.vo.report.score;
2 2  
3 3 import cn.fw.dalaran.domain.vo.report.UserFansCountVo;
4   -import com.alibaba.fastjson.annotation.JSONField;
5   -import com.fasterxml.jackson.annotation.JsonIgnore;
6 4 import lombok.Data;
7 5 import lombok.EqualsAndHashCode;
8 6  
9 7 import java.math.BigDecimal;
10   -import java.util.Objects;
  8 +import java.util.Date;
11 9  
12 10  
13 11 /**
... ... @@ -51,5 +49,12 @@ public class ThemeScoreListVo extends ScoreSummaryVo {
51 49 * 目标及计分情况结果
52 50 */
53 51 private TargetResultDto targetResult;
54   -
  52 + /**
  53 + * 主题开始时间
  54 + */
  55 + private Date themeBeginTime;
  56 + /**
  57 + * 主题结束时间
  58 + */
  59 + private Date themeEndTime;
55 60 }
... ...
fw-dalaran-rpc/src/main/java/cn/fw/dalaran/rpc/ehr/EhrRpc.java
... ... @@ -7,8 +7,10 @@ import cn.fw.dalaran.rpc.dto.StaffInfoRpc;
7 7 import cn.fw.dalaran.rpc.dto.StaffShopSelectRpc;
8 8 import cn.fw.data.base.db.query.Page;
9 9 import cn.fw.data.base.domain.common.Message;
  10 +import cn.fw.ehr.sdk.api.PostApi;
10 11 import cn.fw.ehr.sdk.api.StaffApi;
11 12 import cn.fw.ehr.sdk.api.dto.ManagerScopeCheckDto;
  13 +import cn.fw.ehr.sdk.api.result.PostInfo;
12 14 import cn.fw.ehr.sdk.api.result.StaffBaseInfo;
13 15 import cn.fw.ehr.sdk.api.result.StaffInfo;
14 16 import cn.fw.ehr.sdk.api.result.StaffShopSelectVo;
... ... @@ -19,10 +21,7 @@ import lombok.extern.slf4j.Slf4j;
19 21 import org.springframework.stereotype.Service;
20 22 import org.springframework.util.CollectionUtils;
21 23  
22   -import java.util.ArrayList;
23   -import java.util.List;
24   -import java.util.Objects;
25   -import java.util.Set;
  24 +import java.util.*;
26 25  
27 26 /**
28 27 * @author wmy3969
... ... @@ -35,6 +34,7 @@ import java.util.Set;
35 34 @RequiredArgsConstructor
36 35 public class EhrRpc {
37 36  
  37 + private final PostApi postApi;
38 38 private final StaffApi staffApi;
39 39  
40 40 /**
... ... @@ -101,6 +101,33 @@ public class EhrRpc {
101 101 }
102 102  
103 103 /**
  104 + * 查询指定岗位ID的岗位信息
  105 + *
  106 + * @param postId 岗位ID
  107 + * @return 岗位信息
  108 + */
  109 + public PostInfo getPostInfo(final Long postId) {
  110 + if (Objects.isNull(postId)) {
  111 + return null;
  112 + }
  113 + try {
  114 + final Message<List<PostInfo>> message = postApi.getPostList(Collections.singletonList(postId));
  115 + log.info("调用人事系统查询指定岗位ID的岗位信息:result[{}],code[{}],data[{}]", message.getResult()
  116 + , message.getCode(), message.getData());
  117 + if (message.isSuccess() && Objects.nonNull(message.getData())) {
  118 + return message.getData().get(0);
  119 + }
  120 + if (!message.isSuccess()) {
  121 + throw new BusinessException(message.getResult());
  122 + }
  123 + return null;
  124 + } catch (Exception e) {
  125 + log.error("调用人事系统查询指定岗位ID的岗位信息失败", e);
  126 + }
  127 + return null;
  128 + }
  129 +
  130 + /**
104 131 * 根据职工id集合批量获取职工基础信息
105 132 *
106 133 * @param staffIds 职工的id的集合
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/web/TestController.java
... ... @@ -266,18 +266,4 @@ public class TestController {
266 266 );
267 267 }
268 268  
269   - @GetMapping("/getGroupActivityTheme")
270   - public Message<Map<String, List<ActivityTheme>>> getGroupActivityTheme(Long groupId, Long shopId) {
271   - return Message.success(commonBizService.getGroupActivityTheme(groupId, shopId));
272   - }
273   -
274   - /**
275   - * 按账号处理
276   - */
277   - @PostMapping("/retry/staff/change/shop")
278   - public Message<Void> calThemeTarget(@RequestBody StaffPostChangeEvent staffPostChangeEvent) {
279   - accountChangeBizService.handleSyncStaffAccountShop(staffPostChangeEvent);
280   - return Message.success();
281   - }
282   -
283 269 }
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/ehr/StaffChangePostConsumer.java renamed to fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/StaffChangePostConsumer.java
1   -package cn.fw.dalaran.server.rocketMQ.ehr;
  1 +package cn.fw.dalaran.server.rocketMQ;
2 2  
3   -import cn.fw.dalaran.service.biz.account.AccountChangeBizService;
  3 +import cn.fw.dalaran.service.biz.account.AccountTaskBizService;
4 4 import cn.fw.ehr.sdk.api.mq.StaffPostChangeEvent;
5 5 import cn.fw.rocketmq.annotation.RocketListeners;
6 6 import cn.fw.rocketmq.annotation.RocketMQListener;
... ... @@ -18,14 +18,14 @@ import lombok.extern.slf4j.Slf4j;
18 18 @RequiredArgsConstructor
19 19 @RocketListeners(topic = StaffPostChangeEvent.TOPIC, consumerGroup = "${spring.application.name}_" + StaffPostChangeEvent.TOPIC)
20 20 public class StaffChangePostConsumer {
21   - private final AccountChangeBizService accountChangeBizService;
  21 + private final AccountTaskBizService accountTaskBizService;
22 22  
23 23  
24 24 @RocketMQListener(messageClass = StaffPostChangeEvent.class)
25 25 public void onMessage(StaffPostChangeEvent staffPostChangeEvent) {
26 26 log.info("收到员工调岗MQ, staffPostChangeEvent:[{}]", staffPostChangeEvent);
27 27 try {
28   - accountChangeBizService.handleSyncStaffAccountShop(staffPostChangeEvent);
  28 + accountTaskBizService.handleStaffChangePost(staffPostChangeEvent);
29 29 } catch (Exception e) {
30 30 log.error("员工调岗MQ处理失败, staffPostChangeEvent:{}", staffPostChangeEvent, e);
31 31 throw e;
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/rocketMQ/StaffLeaveEventConsumer.java
1 1 package cn.fw.dalaran.server.rocketMQ;
2 2  
3 3 import cn.fw.dalaran.common.constants.Constants;
4   -import cn.fw.dalaran.domain.db.Account;
5   -import cn.fw.dalaran.service.biz.account.AccountBizService;
6   -import cn.fw.dalaran.service.data.AccountService;
  4 +import cn.fw.dalaran.service.biz.account.AccountChangeBizService;
  5 +import cn.fw.dalaran.service.biz.account.AccountTaskBizService;
7 6 import cn.fw.ehr.sdk.api.mq.StaffLeaveEvent;
8 7 import com.alibaba.fastjson.JSON;
9 8 import lombok.RequiredArgsConstructor;
... ... @@ -11,9 +10,6 @@ import lombok.extern.slf4j.Slf4j;
11 10 import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
12 11 import org.apache.rocketmq.spring.core.RocketMQListener;
13 12 import org.springframework.stereotype.Component;
14   -import org.springframework.util.CollectionUtils;
15   -
16   -import java.util.List;
17 13  
18 14 /**
19 15 * @author wmy3969
... ... @@ -28,9 +24,7 @@ import java.util.List;
28 24 topic = StaffLeaveEvent.TOPIC,
29 25 consumerGroup = Constants.APPLICATION_NAME + "-" + StaffLeaveEvent.TOPIC)
30 26 public class StaffLeaveEventConsumer implements RocketMQListener<StaffLeaveEvent> {
31   -
32   - private final AccountService accountService;
33   - private final AccountBizService accountBizService;
  27 + private final AccountTaskBizService accountTaskBizService;
34 28  
35 29 /**
36 30 * 员工离职, 删除员工自媒体账号
... ... @@ -40,32 +34,6 @@ public class StaffLeaveEventConsumer implements RocketMQListener&lt;StaffLeaveEvent
40 34 @Override
41 35 public void onMessage(StaffLeaveEvent staffLeaveEvent) {
42 36 log.info("收到员工离职消息 message:{}", JSON.toJSONString(staffLeaveEvent));
43   - try {
44   - Long staffId = staffLeaveEvent.getId();// 获取该职工的id
45   - boolean result = false;
46   - int tryCount = 0;
47   - while (!result && tryCount < 3) {
48   - List<Account> accounts = accountService.lambdaQuery()
49   - .eq(Account::getUserId, staffId)
50   - .list();
51   - if (CollectionUtils.isEmpty(accounts))
52   - break;
53   - accounts.forEach(item -> accountBizService.deleteAccount(item.getId()));
54   - /*result = accountService.lambdaUpdate()
55   - .eq(Account::getUserId, staffId)
56   - .set(Account::getValid, 0)
57   - .set(Account::getAffirm, 0)
58   - .set(Account::getYn, 0)
59   - .set(Account::getAccountStatus, -1)
60   - .set(Account::getLeaveTime, new Date())
61   - .update();*/
62   - result = true;
63   - if (!result)
64   - Thread.sleep(3000);
65   - tryCount++;
66   - }
67   - } catch (Exception e) {
68   - log.error("处理员工离职消息发生异常 message:{}", JSON.toJSONString(staffLeaveEvent), e);
69   - }
  37 + accountTaskBizService.handleStaffLeave(staffLeaveEvent.getId());
70 38 }
71 39 }
... ...
fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/account/AccountChangeBizService.java
... ... @@ -8,23 +8,17 @@ import cn.fw.dalaran.domain.db.VideoPool;
8 8 import cn.fw.dalaran.domain.db.config.ActivityTheme;
9 9 import cn.fw.dalaran.domain.dto.common.ShopDto;
10 10 import cn.fw.dalaran.domain.enums.account.AccountTypeEnum;
11   -import cn.fw.dalaran.rpc.ehr.EhrRpc;
12 11 import cn.fw.dalaran.service.biz.LocalCacheService;
13   -import cn.fw.dalaran.service.biz.config.ConfigCommonBizService;
14 12 import cn.fw.dalaran.service.data.AccountService;
15 13 import cn.fw.dalaran.service.data.ActivityThemeService;
16 14 import cn.fw.dalaran.service.data.LivePoolService;
17 15 import cn.fw.dalaran.service.data.VideoPoolService;
18   -import cn.fw.ehr.sdk.api.mq.StaffPostChangeEvent;
19   -import cn.fw.ehr.sdk.api.result.StaffBaseInfo;
20 16 import com.alibaba.fastjson.JSON;
21   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
22 17 import lombok.RequiredArgsConstructor;
23 18 import lombok.extern.slf4j.Slf4j;
24 19 import org.springframework.stereotype.Service;
25 20 import org.springframework.transaction.annotation.Transactional;
26 21  
27   -import java.util.Collections;
28 22 import java.util.Date;
29 23 import java.util.List;
30 24 import java.util.Objects;
... ... @@ -40,13 +34,11 @@ import java.util.stream.Collectors;
40 34 @Service
41 35 @RequiredArgsConstructor
42 36 public class AccountChangeBizService {
43   - private final EhrRpc ehrRpc;
44 37 private final AccountService accountService;
45 38 private final LivePoolService livePoolService;
46 39 private final VideoPoolService videoPoolService;
47 40 private final LocalCacheService localCacheService;
48 41 private final ActivityThemeService activityThemeService;
49   - private final ConfigCommonBizService configCommonBizService;
50 42  
51 43 /**
52 44 * 恢复账号对应进行中直播、短视频数据
... ... @@ -70,117 +62,39 @@ public class AccountChangeBizService {
70 62 .eq(VideoPool::getStatus, 0)
71 63 .in(VideoPool::getThemeId, themeIds)
72 64 .in(VideoPool::getAccountId, accountIds).list();// 查询出被标记无效的短视频数据(未关单的主题, 且数据归属于该账号的)
73   - this.changeLiveBelong(account, livePools, themes);
74   - this.changeVideoBelong(account, videoPools, themes);
75   - }
76   -
77   - /**
78   - * 冻结账号进行中直播、短视频数据
79   - *
80   - * @param account 账号
81   - */
82   - @Transactional(rollbackFor = Exception.class)
83   - public void accountDataFreeze(Account account, List<ActivityTheme> themes, List<Account> accounts) {
84   - if (PublicUtil.isEmpty(account.getAffirm()) || !account.getAffirm()) {
85   - return;
86   - }
87   - themes = PublicUtil.isEmpty(themes) ? activityThemeService.getGoingActivityTheme() : themes;
88   - accounts = PublicUtil.isEmpty(accounts) ? accountService.getByAccountNoIgnoreLogicDel(account.getAccount()) : accounts;
89   - if (PublicUtil.isEmpty(themes) || PublicUtil.isEmpty(accounts)) {
  65 + ActivityTheme activityTheme = this.getBelongActivityTheme(themes, account.getShopId());
  66 + if (PublicUtil.isEmpty(activityTheme)) {
90 67 return;
91 68 }
92   - List<Long> accountIds = accounts.stream().filter(item -> Objects.equals(item.getType(), account.getType())).map(Account::getId).collect(Collectors.toList());
93   - List<Long> themeIds = themes.stream().map(ActivityTheme::getId).collect(Collectors.toList());
94   - // 标记归属短视频为无效
95   - this.freezeAccountVideoData(account, themeIds, accountIds);
96   - // 标记归属直播为无效
97   - this.freezeAccountLiveData(account, themeIds, accountIds);
  69 + this.changeLiveBelong(account, livePools, activityTheme);
  70 + this.changeVideoBelong(account, videoPools, activityTheme);
98 71 }
99 72  
100 73 /**
101   - * 处理人员门店变动
  74 + * 找到门店对应主题
102 75 *
103   - * @param changeEvent 人员门店变动
  76 + * @param themes 正在进行中的活动主题列表
  77 + * @return 对应主题详情
104 78 */
105   - @Transactional(rollbackFor = Exception.class)
106   - public void handleSyncStaffAccountShop(StaffPostChangeEvent changeEvent) {
107   - Long staffId = changeEvent.getStaffId();
108   - List<Account> accountList = accountService.list(Wrappers.<Account>lambdaQuery()
109   - .eq(Account::getUserId, changeEvent.getStaffId())
110   - .eq(Account::getYn, 1));
111   - if (PublicUtil.isEmpty(accountList)) {
112   - log.info("未配置账号");
113   - return;
114   - }
115   - //刷新账号
116   - StaffBaseInfo staffInfo = ehrRpc.getStaffBaseInfo(changeEvent.getStaffId());
117   - Long oldShopId = accountList.get(0).getShopId();
118   - Long newShopId = changeEvent.getNewShopId();
119   - if (!Objects.equals(oldShopId, newShopId)) {
120   - configCommonBizService.handleUserJoinThemeBacklog(staffInfo.getGroupId(), oldShopId, staffId,
121   - false, true);
122   - configCommonBizService.handleUserJoinThemeBacklog(staffInfo.getGroupId(), newShopId, staffId,
123   - true, true);
124   - }
125   - List<Account> hasChangeAccount = accountList.stream().filter(account -> !account.getShopId().equals(newShopId)).peek(account -> {
126   - account.setShopId(newShopId);
127   - account.setShopName(changeEvent.getNewShopName());
128   - }).collect(Collectors.toList());
129   - if (PublicUtil.isEmpty(hasChangeAccount)) {
130   - return;
131   - }
132   - accountService.updateBatchById(hasChangeAccount);
133   - //调整进行中数据归属
134   - List<ActivityTheme> themes = activityThemeService.getGoingActivityTheme();
135   - if (PublicUtil.isNotEmpty(themes)) {
136   - hasChangeAccount.forEach(account -> {
137   - this.accountDataFreeze(account, themes, Collections.singletonList(account));
138   - this.accountDataRestore(account, themes, Collections.singletonList(account));
139   - });
  79 + private ActivityTheme getBelongActivityTheme(List<ActivityTheme> themes, Long shopId) {
  80 + for (ActivityTheme theme : themes) {
  81 + List<ShopDto> shops = JSON.parseArray(theme.getShopJson(), ShopDto.class);
  82 + if (shops.stream().anyMatch(r -> r.getShopId().equals(shopId))) {
  83 + return theme;
  84 + }
140 85 }
141   - }
142   -
143   - /**
144   - * 冻结账号正在进行中的视频数据
145   - */
146   - @Transactional(rollbackFor = Exception.class)
147   - public void freezeAccountVideoData(Account account, List<Long> themeIds, List<Long> accountIds) {
148   - videoPoolService.lambdaUpdate()
149   - .set(VideoPool::getStatus, 0)
150   - .in(VideoPool::getThemeId, themeIds)
151   - .in(VideoPool::getAccountId, accountIds)
152   - .eq(VideoPool::getPlatform, account.getType())
153   - .set(VideoPool::getUpdateTime, new Date())
154   - .update();
155   - }
156   -
157   - /**
158   - * 冻结账号正在进行中的视频数据
159   - */
160   - @Transactional(rollbackFor = Exception.class)
161   - public void freezeAccountLiveData(Account account, List<Long> themeIds, List<Long> accountIds) {
162   - livePoolService.lambdaUpdate()
163   - .set(LivePool::getStatus, 0)
164   - .in(LivePool::getThemeId, themeIds)
165   - .in(LivePool::getAccountId, accountIds)
166   - .eq(LivePool::getPlatform, account.getType())
167   - .set(LivePool::getUpdateTime, new Date())
168   - .update();
  86 + return null;
169 87 }
170 88  
171 89 /**
172 90 * 改变短视频数据归属信息
173 91 *
174   - * @param account 账号实体(本次添加的最新账号)
175   - * @param videoPools 短视频数据列表
176   - * @param themes 正在进行中的活动主题列表
  92 + * @param account 账号实体(本次添加的最新账号)
  93 + * @param videoPools 短视频数据列表
  94 + * @param activityTheme 正在进行中的活动主题列表
177 95 */
178 96 @Transactional(rollbackFor = Exception.class)
179   - public void changeVideoBelong(Account account, List<VideoPool> videoPools, List<ActivityTheme> themes) {
180   - ActivityTheme activityTheme = this.getBelongActivityTheme(themes, account.getShopId());
181   - if (PublicUtil.isEmpty(activityTheme)) {
182   - return;
183   - }
  97 + public void changeVideoBelong(Account account, List<VideoPool> videoPools, ActivityTheme activityTheme) {
184 98 Long manager1Id = localCacheService.getBelongManagerId(account.getGroupId(), account.getShopId(), RoleMsgEnum.XSZG);
185 99 Long manager2Id = localCacheService.getBelongManagerId(account.getGroupId(), account.getShopId(), RoleMsgEnum.XSJL);
186 100 Long manager3Id = localCacheService.getBelongManagerId(account.getGroupId(), account.getShopId(), RoleMsgEnum.XSZJL);
... ... @@ -203,15 +117,11 @@ public class AccountChangeBizService {
203 117 /**
204 118 * 改变直播数据归属信息
205 119 *
206   - * @param account 账号实体(本次添加的最新账号)
207   - * @param themes 正在进行中的活动主题列表
  120 + * @param account 账号实体(本次添加的最新账号)
  121 + * @param activityTheme 正在进行中的活动主题列表
208 122 */
209 123 @Transactional(rollbackFor = Exception.class)
210   - public void changeLiveBelong(Account account, List<LivePool> livePoolList, List<ActivityTheme> themes) {
211   - ActivityTheme activityTheme = this.getBelongActivityTheme(themes, account.getShopId());
212   - if (PublicUtil.isEmpty(activityTheme)) {
213   - return;
214   - }
  124 + public void changeLiveBelong(Account account, List<LivePool> livePoolList, ActivityTheme activityTheme) {
215 125 Long manager1Id = localCacheService.getBelongManagerId(account.getGroupId(), account.getShopId(), RoleMsgEnum.XSZG);
216 126 Long manager2Id = localCacheService.getBelongManagerId(account.getGroupId(), account.getShopId(), RoleMsgEnum.XSJL);
217 127 Long manager3Id = localCacheService.getBelongManagerId(account.getGroupId(), account.getShopId(), RoleMsgEnum.XSZJL);
... ... @@ -232,19 +142,54 @@ public class AccountChangeBizService {
232 142 }
233 143  
234 144 /**
235   - * 找到门店对应主题
  145 + * 冻结账号进行中直播、短视频数据
236 146 *
237   - * @param themes 正在进行中的活动主题列表
238   - * @return 对应主题详情
  147 + * @param account 账号
239 148 */
240   - private ActivityTheme getBelongActivityTheme(List<ActivityTheme> themes, Long shopId) {
241   - for (ActivityTheme theme : themes) {
242   - List<ShopDto> shops = JSON.parseArray(theme.getShopJson(), ShopDto.class);
243   - if (shops.stream().anyMatch(r -> r.getShopId().equals(shopId))) {
244   - return theme;
245   - }
  149 + @Transactional(rollbackFor = Exception.class)
  150 + public void accountDataFreeze(Account account, List<ActivityTheme> themes, List<Account> accounts) {
  151 + if (PublicUtil.isEmpty(account.getAffirm()) || !account.getAffirm()) {
  152 + return;
246 153 }
247   - return null;
  154 + themes = PublicUtil.isEmpty(themes) ? activityThemeService.getGoingActivityTheme() : themes;
  155 + accounts = PublicUtil.isEmpty(accounts) ? accountService.getByAccountNoIgnoreLogicDel(account.getAccount()) : accounts;
  156 + if (PublicUtil.isEmpty(themes) || PublicUtil.isEmpty(accounts)) {
  157 + return;
  158 + }
  159 + List<Long> accountIds = accounts.stream().filter(item -> Objects.equals(item.getType(), account.getType())).map(Account::getId).collect(Collectors.toList());
  160 + List<Long> themeIds = themes.stream().map(ActivityTheme::getId).collect(Collectors.toList());
  161 + // 标记归属短视频为无效
  162 + this.freezeAccountVideoData(account, themeIds, accountIds);
  163 + // 标记归属直播为无效
  164 + this.freezeAccountLiveData(account, themeIds, accountIds);
  165 + }
  166 +
  167 + /**
  168 + * 冻结账号正在进行中的视频数据
  169 + */
  170 + @Transactional(rollbackFor = Exception.class)
  171 + public void freezeAccountVideoData(Account account, List<Long> themeIds, List<Long> accountIds) {
  172 + videoPoolService.lambdaUpdate()
  173 + .set(VideoPool::getStatus, 0)
  174 + .in(VideoPool::getThemeId, themeIds)
  175 + .in(VideoPool::getAccountId, accountIds)
  176 + .eq(VideoPool::getPlatform, account.getType())
  177 + .set(VideoPool::getUpdateTime, new Date())
  178 + .update();
  179 + }
  180 +
  181 + /**
  182 + * 冻结账号正在进行中的视频数据
  183 + */
  184 + @Transactional(rollbackFor = Exception.class)
  185 + public void freezeAccountLiveData(Account account, List<Long> themeIds, List<Long> accountIds) {
  186 + livePoolService.lambdaUpdate()
  187 + .set(LivePool::getStatus, 0)
  188 + .in(LivePool::getThemeId, themeIds)
  189 + .in(LivePool::getAccountId, accountIds)
  190 + .eq(LivePool::getPlatform, account.getType())
  191 + .set(LivePool::getUpdateTime, new Date())
  192 + .update();
248 193 }
249 194 }
250 195  
... ...
fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/account/AccountTaskBizService.java 0 → 100644
  1 +package cn.fw.dalaran.service.biz.account;
  2 +
  3 +import cn.fw.dalaran.common.domain.enums.RoleMsgEnum;
  4 +import cn.fw.dalaran.common.utils.PublicUtil;
  5 +import cn.fw.dalaran.domain.db.Account;
  6 +import cn.fw.dalaran.domain.db.config.ActivityTheme;
  7 +import cn.fw.dalaran.rpc.ehr.EhrRpc;
  8 +import cn.fw.dalaran.service.biz.config.ConfigCommonBizService;
  9 +import cn.fw.dalaran.service.data.AccountService;
  10 +import cn.fw.dalaran.service.data.ActivityThemeService;
  11 +import cn.fw.ehr.sdk.api.mq.StaffPostChangeEvent;
  12 +import cn.fw.ehr.sdk.api.result.PostInfo;
  13 +import cn.fw.ehr.sdk.api.result.StaffBaseInfo;
  14 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  15 +import lombok.RequiredArgsConstructor;
  16 +import lombok.extern.slf4j.Slf4j;
  17 +import org.springframework.stereotype.Service;
  18 +import org.springframework.transaction.annotation.Transactional;
  19 +
  20 +import java.util.Collections;
  21 +import java.util.List;
  22 +import java.util.Objects;
  23 +import java.util.stream.Collectors;
  24 +
  25 +/**
  26 + * 账号定时任务
  27 + *
  28 + * @author: LYM
  29 + * @date: 2024/4/8 11:24
  30 + */
  31 +@Slf4j
  32 +@Service
  33 +@RequiredArgsConstructor
  34 +public class AccountTaskBizService {
  35 + private final EhrRpc ehrRpc;
  36 + private final AccountService accountService;
  37 + private final ActivityThemeService activityThemeService;
  38 + private final ConfigCommonBizService configCommonBizService;
  39 + private final AccountChangeBizService accountChangeBizService;
  40 +
  41 + /**
  42 + * 处理人员离职事件
  43 + *
  44 + * @param staffId 员工id
  45 + */
  46 + @Transactional(rollbackFor = Exception.class)
  47 + public void handleStaffLeave(Long staffId) {
  48 + this.removeAccount(staffId);
  49 + }
  50 +
  51 + /**
  52 + * 处理调岗
  53 + *
  54 + * @param event 员工id
  55 + */
  56 + @Transactional(rollbackFor = Exception.class)
  57 + public void handleStaffChangePost(StaffPostChangeEvent event) {
  58 + PostInfo postInfo = ehrRpc.getPostInfo(event.getNewPostId());
  59 + if (!RoleMsgEnum.XSGW.getCode().equals(postInfo.getRoleCode())) {
  60 + this.removeAccount(event.getStaffId());
  61 + return;
  62 + }
  63 + this.changeShop(event);
  64 + }
  65 +
  66 + /**
  67 + * 删除账号
  68 + *
  69 + * @param staffId 员工id
  70 + */
  71 + @Transactional(rollbackFor = Exception.class)
  72 + public void removeAccount(Long staffId) {
  73 + List<Account> accountList = accountService.list(Wrappers.<Account>lambdaQuery()
  74 + .eq(Account::getUserId, staffId));
  75 + if (PublicUtil.isEmpty(accountList)) {
  76 + return;
  77 + }
  78 + List<Long> ids = accountList.stream().map(Account::getId).collect(Collectors.toList());
  79 + accountService.remove(Wrappers.<Account>lambdaQuery().in(Account::getId, ids));
  80 + accountList.forEach(account -> accountChangeBizService.accountDataFreeze(account, null, null));
  81 + }
  82 +
  83 + /**
  84 + * 处理人员门店变动
  85 + *
  86 + * @param event 员工id
  87 + */
  88 + @Transactional(rollbackFor = Exception.class)
  89 + public void changeShop(StaffPostChangeEvent event) {
  90 + List<Account> accountList = accountService.list(Wrappers.<Account>lambdaQuery()
  91 + .eq(Account::getUserId, event.getStaffId())
  92 + .eq(Account::getYn, 1));
  93 + if (PublicUtil.isEmpty(accountList)) {
  94 + log.info("未配置账号");
  95 + return;
  96 + }
  97 + //刷新账号
  98 + Long staffId = event.getStaffId();
  99 + StaffBaseInfo staffInfo = ehrRpc.getStaffBaseInfo(event.getStaffId());
  100 + Long oldShopId = accountList.get(0).getShopId();
  101 + Long newShopId = event.getNewShopId();
  102 + if (!Objects.equals(oldShopId, newShopId)) {
  103 + configCommonBizService.handleUserJoinThemeBacklog(staffInfo.getGroupId(), oldShopId, staffId,
  104 + false, true);
  105 + configCommonBizService.handleUserJoinThemeBacklog(staffInfo.getGroupId(), newShopId, staffId,
  106 + true, true);
  107 + }
  108 + List<Account> hasChangeAccount = accountList.stream()
  109 + .filter(account -> !account.getShopId().equals(newShopId))
  110 + .peek(account -> {
  111 + account.setShopId(newShopId);
  112 + account.setShopName(event.getNewShopName());
  113 + }).collect(Collectors.toList());
  114 + if (PublicUtil.isEmpty(hasChangeAccount)) {
  115 + return;
  116 + }
  117 + accountService.updateBatchById(hasChangeAccount);
  118 + //调整进行中数据归属
  119 + List<ActivityTheme> themes = activityThemeService.getGoingActivityTheme();
  120 + if (PublicUtil.isNotEmpty(themes)) {
  121 + hasChangeAccount.forEach(account -> {
  122 + accountChangeBizService.accountDataFreeze(account, themes, Collections.singletonList(account));
  123 + accountChangeBizService.accountDataRestore(account, themes, Collections.singletonList(account));
  124 + });
  125 + }
  126 + }
  127 +}
  128 +
... ...
fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/report/score/ScoreMonthBizService.java
... ... @@ -280,7 +280,11 @@ public class ScoreMonthBizService {
280 280 ThemeScoreListVo scoreListVo = new ThemeScoreListVo();
281 281 scoreListVo.setId(themeId.toString());
282 282 ActivityTheme theme = collect.get(entry.getKey());
283   - scoreListVo.setName(Objects.isNull(theme) ? null : theme.getTheme());
  283 + if (PublicUtil.isNotEmpty(theme)) {
  284 + scoreListVo.setName(theme.getTheme());
  285 + scoreListVo.setThemeBeginTime(theme.getStartTime());
  286 + scoreListVo.setThemeEndTime(theme.getEndTime());
  287 + }
284 288  
285 289 ScoreResultDto result = themeMap.getOrDefault(themeId, new ScoreResultDto());
286 290 scoreListVo.setI1(result.getThemeScore());
... ...