Commit 46b31f43a5a0d77b4e0f012616519a53c2df636d

Authored by YunaiV
1 parent 4f6f132f

✨ feat(mes): 增加生产趋势查询参数验证和首页组件优化

为生产趋势查询添加最小和最大天数验证,确保输入有效性。
优化首页组件,增加数据存在性判断,提升用户体验。
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/home/MesHomeStatisticsController.java
@@ -9,6 +9,8 @@ import io.swagger.v3.oas.annotations.Operation; @@ -9,6 +9,8 @@ import io.swagger.v3.oas.annotations.Operation;
9 import io.swagger.v3.oas.annotations.Parameter; 9 import io.swagger.v3.oas.annotations.Parameter;
10 import io.swagger.v3.oas.annotations.tags.Tag; 10 import io.swagger.v3.oas.annotations.tags.Tag;
11 import jakarta.annotation.Resource; 11 import jakarta.annotation.Resource;
  12 +import jakarta.validation.constraints.Max;
  13 +import jakarta.validation.constraints.Min;
12 import org.springframework.security.access.prepost.PreAuthorize; 14 import org.springframework.security.access.prepost.PreAuthorize;
13 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
14 import org.springframework.web.bind.annotation.GetMapping; 16 import org.springframework.web.bind.annotation.GetMapping;
@@ -48,7 +50,7 @@ public class MesHomeStatisticsController { @@ -48,7 +50,7 @@ public class MesHomeStatisticsController {
48 @Parameter(name = "days", description = "天数", example = "7") 50 @Parameter(name = "days", description = "天数", example = "7")
49 @PreAuthorize("@ss.hasPermission('mes:home:query')") 51 @PreAuthorize("@ss.hasPermission('mes:home:query')")
50 public CommonResult<List<MesHomeProductionTrendRespVO>> getProductionTrend( 52 public CommonResult<List<MesHomeProductionTrendRespVO>> getProductionTrend(
51 - @RequestParam(value = "days", defaultValue = "7") Integer days) { 53 + @RequestParam(value = "days", defaultValue = "7") @Min(1) @Max(90) Integer days) {
52 return success(homeStatisticsService.getProductionTrend(days)); 54 return success(homeStatisticsService.getProductionTrend(days));
53 } 55 }
54 56
yudao-module-mes/src/main/resources/mapper/home/MesHomeStatisticsMapper.xml
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 IFNULL(SUM(unqualified_quantity), 0) AS unqualifiedQuantity 17 IFNULL(SUM(unqualified_quantity), 0) AS unqualifiedQuantity
18 FROM mes_pro_feedback 18 FROM mes_pro_feedback
19 WHERE deleted = 0 19 WHERE deleted = 0
  20 + AND status = ${@cn.iocoder.yudao.module.mes.enums.pro.MesProFeedbackStatusEnum@FINISHED.status}
20 AND feedback_time >= #{beginTime} 21 AND feedback_time >= #{beginTime}
21 <if test="endTime != null"> 22 <if test="endTime != null">
22 AND feedback_time &lt; #{endTime} 23 AND feedback_time &lt; #{endTime}
@@ -36,7 +37,7 @@ @@ -36,7 +37,7 @@
36 SELECT COUNT(*) 37 SELECT COUNT(*)
37 FROM mes_pro_andon_record 38 FROM mes_pro_andon_record
38 WHERE deleted = 0 39 WHERE deleted = 0
39 - AND status = 0 40 + AND status = ${@cn.iocoder.yudao.module.mes.enums.pro.MesProAndonStatusEnum@ACTIVE.status}
40 </select> 41 </select>
41 42
42 <!-- 统计未完成维修工单数(草稿 0、维修中 1、待验收 2) --> 43 <!-- 统计未完成维修工单数(草稿 0、维修中 1、待验收 2) -->
@@ -44,7 +45,9 @@ @@ -44,7 +45,9 @@
44 SELECT COUNT(*) 45 SELECT COUNT(*)
45 FROM mes_dv_repair 46 FROM mes_dv_repair
46 WHERE deleted = 0 47 WHERE deleted = 0
47 - AND status IN (0, 1, 2) 48 + AND status IN (${@cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum@PREPARE.status},
  49 + ${@cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum@CONFIRMED.status},
  50 + ${@cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum@APPROVING.status})
48 </select> 51 </select>
49 52
50 <!-- 按天聚合报工产量 --> 53 <!-- 按天聚合报工产量 -->
@@ -55,6 +58,7 @@ @@ -55,6 +58,7 @@
55 IFNULL(SUM(unqualified_quantity), 0) AS unqualifiedQuantity 58 IFNULL(SUM(unqualified_quantity), 0) AS unqualifiedQuantity
56 FROM mes_pro_feedback 59 FROM mes_pro_feedback
57 WHERE deleted = 0 60 WHERE deleted = 0
  61 + AND status = ${@cn.iocoder.yudao.module.mes.enums.pro.MesProFeedbackStatusEnum@FINISHED.status}
58 AND feedback_time >= #{beginTime} 62 AND feedback_time >= #{beginTime}
59 <if test="endTime != null"> 63 <if test="endTime != null">
60 AND feedback_time &lt; #{endTime} 64 AND feedback_time &lt; #{endTime}