|
1
|
package com.lframework.xingyun.sc.procurement.controller.summary;
|
1
|
package com.lframework.xingyun.sc.procurement.controller.summary;
|
|
2
|
|
2
|
|
|
3
|
import com.lframework.starter.common.constants.StringPool;
|
3
|
import com.lframework.starter.common.constants.StringPool;
|
|
|
|
4
|
+import com.lframework.starter.common.utils.CollectionUtil;
|
|
4
|
import com.lframework.starter.web.core.annotations.security.HasPermission;
|
5
|
import com.lframework.starter.web.core.annotations.security.HasPermission;
|
|
5
|
import com.lframework.starter.web.core.components.resp.InvokeResult;
|
6
|
import com.lframework.starter.web.core.components.resp.InvokeResult;
|
|
6
|
import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
|
7
|
import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
|
|
7
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
8
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
|
8
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
9
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
|
|
|
10
|
+import com.lframework.starter.web.inner.service.system.SysUserRoleService;
|
|
9
|
import com.lframework.xingyun.sc.bo.procurement.GetDomesticPlanSummaryBo;
|
11
|
import com.lframework.xingyun.sc.bo.procurement.GetDomesticPlanSummaryBo;
|
|
|
|
12
|
+import com.lframework.xingyun.sc.handlers.MessageHandler;
|
|
10
|
import com.lframework.xingyun.sc.procurement.entity.summary.DomesticPlanSummary;
|
13
|
import com.lframework.xingyun.sc.procurement.entity.summary.DomesticPlanSummary;
|
|
|
|
14
|
+import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
|
|
11
|
import com.lframework.xingyun.sc.procurement.service.summary.DomesticPlanSummaryService;
|
15
|
import com.lframework.xingyun.sc.procurement.service.summary.DomesticPlanSummaryService;
|
|
12
|
import com.lframework.xingyun.sc.procurement.vo.summary.QueryDomesticPlanSummaryVo;
|
16
|
import com.lframework.xingyun.sc.procurement.vo.summary.QueryDomesticPlanSummaryVo;
|
|
13
|
import io.swagger.annotations.Api;
|
17
|
import io.swagger.annotations.Api;
|
|
14
|
import io.swagger.annotations.ApiImplicitParam;
|
18
|
import io.swagger.annotations.ApiImplicitParam;
|
|
15
|
import io.swagger.annotations.ApiOperation;
|
19
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
20
|
+import java.time.LocalDate;
|
|
|
|
21
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
22
|
+import java.util.Collections;
|
|
|
|
23
|
+import java.util.List;
|
|
|
|
24
|
+import java.util.Map;
|
|
|
|
25
|
+import javax.annotation.Resource;
|
|
16
|
import javax.validation.Valid;
|
26
|
import javax.validation.Valid;
|
|
17
|
import javax.validation.constraints.NotBlank;
|
27
|
import javax.validation.constraints.NotBlank;
|
|
18
|
import lombok.extern.slf4j.Slf4j;
|
28
|
import lombok.extern.slf4j.Slf4j;
|
|
19
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
20
|
import org.springframework.format.annotation.DateTimeFormat;
|
29
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
21
|
import org.springframework.scheduling.annotation.Scheduled;
|
30
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
22
|
import org.springframework.validation.annotation.Validated;
|
31
|
import org.springframework.validation.annotation.Validated;
|
|
23
|
import org.springframework.web.bind.annotation.GetMapping;
|
32
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
24
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
25
|
import org.springframework.web.bind.annotation.PostMapping;
|
33
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
26
|
import org.springframework.web.bind.annotation.RequestMapping;
|
34
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
27
|
import org.springframework.web.bind.annotation.RequestParam;
|
35
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
28
|
import org.springframework.web.bind.annotation.RestController;
|
36
|
import org.springframework.web.bind.annotation.RestController;
|
|
29
|
|
37
|
|
|
30
|
-import java.time.LocalDate;
|
|
|
|
31
|
-
|
|
|
|
32
|
@Api(tags = "内贸计划明细汇总表管理")
|
38
|
@Api(tags = "内贸计划明细汇总表管理")
|
|
33
|
@Slf4j
|
39
|
@Slf4j
|
|
34
|
@Validated
|
40
|
@Validated
|
|
@@ -36,8 +42,14 @@ import java.time.LocalDate; |
|
@@ -36,8 +42,14 @@ import java.time.LocalDate; |
|
36
|
@RequestMapping("/procurement/plan/summary")
|
42
|
@RequestMapping("/procurement/plan/summary")
|
|
37
|
public class DomesticPlanSummaryController extends DefaultBaseController {
|
43
|
public class DomesticPlanSummaryController extends DefaultBaseController {
|
|
38
|
|
44
|
|
|
39
|
- @Autowired
|
45
|
+ @Resource
|
|
40
|
private DomesticPlanSummaryService domesticPlanSummaryService;
|
46
|
private DomesticPlanSummaryService domesticPlanSummaryService;
|
|
|
|
47
|
+ @Resource
|
|
|
|
48
|
+ private ProcurementPlanService procurementPlanService;
|
|
|
|
49
|
+ @Resource
|
|
|
|
50
|
+ private SysUserRoleService sysUserRoleService;
|
|
|
|
51
|
+ @Resource
|
|
|
|
52
|
+ private MessageHandler messageHandler;
|
|
41
|
|
53
|
|
|
42
|
@ApiOperation("分页查询内贸计划明细汇总表列表")
|
54
|
@ApiOperation("分页查询内贸计划明细汇总表列表")
|
|
43
|
@HasPermission({"plan-manage:detail-form:query"})
|
55
|
@HasPermission({"plan-manage:detail-form:query"})
|
|
@@ -77,4 +89,37 @@ public class DomesticPlanSummaryController extends DefaultBaseController { |
|
@@ -77,4 +89,37 @@ public class DomesticPlanSummaryController extends DefaultBaseController { |
|
77
|
log.error("[内贸计划明细汇总表] 定时任务执行失败!", e);
|
89
|
log.error("[内贸计划明细汇总表] 定时任务执行失败!", e);
|
|
78
|
}
|
90
|
}
|
|
79
|
}
|
91
|
}
|
|
|
|
92
|
+
|
|
|
|
93
|
+ @Scheduled(cron = "0 0 0 * * ?")
|
|
|
|
94
|
+ @ApiOperation(hidden = true, value = "每天凌晨12点提醒供应管理科计划管理员:昨天创建的采购计划总数/完成数/流程中数")
|
|
|
|
95
|
+ public void scheduledNotifyYesterdayPlanAdmin() {
|
|
|
|
96
|
+ try {
|
|
|
|
97
|
+ log.info("[采购计划统计提醒] 定时任务开始执行 凌晨12点...");
|
|
|
|
98
|
+ LocalDate yesterday = LocalDate.now().minusDays(1);
|
|
|
|
99
|
+ Map<String, Long> stat = procurementPlanService.countCreatedPlansByDate(yesterday);
|
|
|
|
100
|
+ long total = stat.getOrDefault("totalCount", 0L);
|
|
|
|
101
|
+ long completed = stat.getOrDefault("completedCount", 0L);
|
|
|
|
102
|
+ long inProgress = stat.getOrDefault("inProgressCount", 0L);
|
|
|
|
103
|
+
|
|
|
|
104
|
+ // 组装消息
|
|
|
|
105
|
+ String dateStr = yesterday.format(DateTimeFormatter.ofPattern(StringPool.DATE_PATTERN));
|
|
|
|
106
|
+ String title = String.format("%s 采购计划创建统计提醒", dateStr);
|
|
|
|
107
|
+ String content = String.format(
|
|
|
|
108
|
+ "【采购计划统计提醒】%s 创建的采购计划共 %d 单,流程已完成(COMPLETED) %d 单,流程中 %d 单。请相关计划管理员及时跟进处理!",
|
|
|
|
109
|
+ dateStr, total, completed, inProgress);
|
|
|
|
110
|
+ String bizKey = "PROCUREMENT_PLAN_STAT_" + dateStr;
|
|
|
|
111
|
+
|
|
|
|
112
|
+ // 发送给供应管理科计划管理员
|
|
|
|
113
|
+ List<String> userIds = sysUserRoleService.listUserIdByRoleCodes(Collections.singletonList("gyglkjhgly"));
|
|
|
|
114
|
+ if (CollectionUtil.isEmpty(userIds)) {
|
|
|
|
115
|
+ log.warn("[采购计划统计提醒] 供应管理科计划管理员 下无用户,跳过消息发送!");
|
|
|
|
116
|
+ return;
|
|
|
|
117
|
+ }
|
|
|
|
118
|
+ messageHandler.sendMsg(userIds, title, content, bizKey, null);
|
|
|
|
119
|
+ log.info("[采购计划统计提醒] 消息发送完成 接收人{}个 总数{}完成{}流程中{}",
|
|
|
|
120
|
+ userIds.size(), total, completed, inProgress);
|
|
|
|
121
|
+ } catch (Exception e) {
|
|
|
|
122
|
+ log.error("[采购计划统计提醒] 定时任务执行失败!", e);
|
|
|
|
123
|
+ }
|
|
|
|
124
|
+ }
|
|
80
|
} |
125
|
} |