Commit 131ad9be5df3876eb07d743c7a31487d750229b4

Authored by wangqian
1 parent 3fe9c3e6

首页统计接口

Showing 13 changed files with 1181 additions and 160 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/MaintainSummaryController.java
1 package com.zteits.urbanops.module.garden.controller.admin.homepage; 1 package com.zteits.urbanops.module.garden.controller.admin.homepage;
2 2
3 import com.zteits.urbanops.framework.common.pojo.CommonResult; 3 import com.zteits.urbanops.framework.common.pojo.CommonResult;
4 -import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;  
5 -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitCountByCompanyReqVO; 4 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo;
6 import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO; 5 import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO;
7 -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.MaintainProportionReqVO;  
8 import com.zteits.urbanops.module.garden.service.homepage.MaintainSummaryService; 6 import com.zteits.urbanops.module.garden.service.homepage.MaintainSummaryService;
9 import io.swagger.v3.oas.annotations.Operation; 7 import io.swagger.v3.oas.annotations.Operation;
10 import io.swagger.v3.oas.annotations.tags.Tag; 8 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -30,89 +28,34 @@ public class MaintainSummaryController { @@ -30,89 +28,34 @@ public class MaintainSummaryController {
30 28
31 @PostMapping("/getSummary") 29 @PostMapping("/getSummary")
32 @Operation(summary = "首页汇总") 30 @Operation(summary = "首页汇总")
33 - public CommonResult<Map<String, Object>> getSummary(@Valid @RequestBody HomePageSummaryReqVO req) {  
34 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
35 - return success(maintainSummaryService.selectMaintainSummary(req, companyId)); 31 + public CommonResult<Map<String, Object>> getSummary() {
  32 + return success(maintainSummaryService.getSummary());
36 } 33 }
37 34
38 - @PostMapping("/getSummary/maintain_type")  
39 - @Operation(summary = "首页汇总-养护类型统计")  
40 - public CommonResult<Map<String, List<Map<String, Object>>>> getSummaryByMaintainType(@Valid @RequestBody HomePageSummaryReqVO req) {  
41 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
42 - return success(maintainSummaryService.getSummaryByMaintainType(req, companyId)); 35 + @PostMapping("/getWorkTaskTrend")
  36 + @Operation(summary = "任务趋势图")
  37 + public CommonResult<Map<String, Object>> getWorkTaskTrend(@Valid @RequestBody HomePageSummaryReqVO req) {
  38 + return success(maintainSummaryService.getWorkTaskTrend(req));
43 } 39 }
44 40
45 - @PostMapping("/getSummary/maintain_type/proportion")  
46 - @Operation(summary = "首页汇总-养护类型占比")  
47 - public CommonResult<List<Map<String, Object>>> getSummaryByMaintainProportion(@Valid @RequestBody HomePageSummaryReqVO req) {  
48 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
49 - return success(maintainSummaryService.getSummaryByMaintainProportion(req, companyId)); 41 + @PostMapping("/getWorkOrderRatio")
  42 + @Operation(summary = "工单占比")
  43 + public CommonResult<Map<String, Object>> getWorkOrderRatio(@Valid @RequestBody HomePageSummaryReqVO req) {
  44 + return success(maintainSummaryService.getWorkOrderRatio(req));
50 } 45 }
51 -  
52 - @PostMapping("/getSummary/plant_type/proportion")  
53 - @Operation(summary = "首页汇总-植物类型占比")  
54 - public CommonResult<List<Map<String, Object>>> getSummaryByPlantProportion(@Valid @RequestBody HomePageSummaryReqVO req) {  
55 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
56 - return success(maintainSummaryService.getSummaryByPlantProportion(req, companyId)); 46 + @PostMapping("/getWorkOrderDistribution")
  47 + @Operation(summary = "子公司工单分布")
  48 + public CommonResult<Map<String, CommitWorkOrderRespVo>> getWorkOrderDistribution(@Valid @RequestBody HomePageSummaryReqVO req) {
  49 + return success(maintainSummaryService.getWorkOrderDistribution(req));
57 } 50 }
58 -  
59 - @PostMapping("/getSummary/company")  
60 - @Operation(summary = "首页汇总-按公司统计")  
61 - public CommonResult<Map<String, Object>> getSummaryByCompany(@Valid @RequestBody HomePageSummaryReqVO req) {  
62 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
63 - return success(maintainSummaryService.selectSummaryByCompany(req, companyId)); 51 + @PostMapping("/getWorkOrderHeatmap")
  52 + @Operation(summary = "工单热力图")
  53 + public CommonResult<List<Map<String, Object>>> getWorkOrderHeatmap() {
  54 + return success(maintainSummaryService.getWorkOrderHeatmap());
64 } 55 }
65 -  
66 - @PostMapping("/proportion/by/company")  
67 - @Operation(summary = "首页汇总-按公司统计提交量占比")  
68 - public CommonResult<List<Map<String, Object>>> proportionByCompany(@Valid @RequestBody HomePageSummaryReqVO req) {  
69 - return success(maintainSummaryService.getProportionByCompany(req.beginTime, req.endTime));  
70 - }  
71 -  
72 - @PostMapping("/commitCount/by/company")  
73 - @Operation(summary = "按公司统计-提交工单数量")  
74 - public CommonResult<List<Map<String, Object>>> getCommitCountByCompany(@Valid @RequestBody CommitCountByCompanyReqVO req) {  
75 - return success(maintainSummaryService.getCommitCountByCompany(req));  
76 - }  
77 -  
78 - @PostMapping("/pressing_type/by/company")  
79 - @Operation(summary = "按公司统计-紧急程度占比")  
80 - public CommonResult<List<Map<String, Object>>> getPressingTypeByCompany(@Valid @RequestBody CommitCountByCompanyReqVO req) {  
81 - return success(maintainSummaryService.getPressingTypeByCompany(req));  
82 - }  
83 -  
84 - @PostMapping("/process/order/xc")  
85 - @Operation(summary = "个人-巡查处理工单量排名")  
86 - public CommonResult<List<Map<String, Object>>> getXcProcessOrder(@Valid @RequestBody CommitCountByCompanyReqVO req) {  
87 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
88 - return success(maintainSummaryService.getXcProcessOrder(companyId, req.beginTime, req.endTime));  
89 - }  
90 -  
91 - @PostMapping("/process/order/yh")  
92 - @Operation(summary = "个人-养护处理工单量排名")  
93 - public CommonResult<List<Map<String, Object>>> getProcessOrderReturn(@Valid @RequestBody CommitCountByCompanyReqVO req) {  
94 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
95 - return success(maintainSummaryService.getProcessOrderReturn(companyId, req.beginTime, req.endTime));  
96 - }  
97 -  
98 - @PostMapping("/commitCount/group/commitDate")  
99 - @Operation(summary = "按时间统计-工单提交量")  
100 - public CommonResult<Map<String, List<Object>>> getCommitCountByTime(@Valid @RequestBody CommitCountByCompanyReqVO req) {  
101 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
102 - return success(maintainSummaryService.getCommitCountByTime(companyId, req));  
103 - }  
104 -  
105 - @PostMapping("/orderList/by/status")  
106 - @Operation(summary = "按单位-工单处理情况")  
107 - public CommonResult<List<Map<String, Object>>> getOrderList(@Valid @RequestBody MaintainProportionReqVO req) {  
108 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
109 - return success(maintainSummaryService.getOrderList(companyId, req.getTaskStatus()));  
110 - }  
111 -  
112 - @PostMapping("/maintainTypeCount")  
113 - @Operation(summary = "首页汇总-养护类型统计")  
114 - public CommonResult<Map<String, Object>> maintainTypeAndGrowthRate(@Valid @RequestBody HomePageSummaryReqVO req) {  
115 - Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();  
116 - return success(maintainSummaryService.getSummaryByMaintainTypeAndGrowthRate(req, companyId)); 56 + @PostMapping("/getWorkOrderTrend")
  57 + @Operation(summary = "工单趋势图")
  58 + public CommonResult<Map<String, Object>> getWorkOrderTrend(@Valid @RequestBody HomePageSummaryReqVO req) {
  59 + return success(maintainSummaryService.getWorkOrderTrend(req));
117 } 60 }
118 -}  
119 \ No newline at end of file 61 \ No newline at end of file
  62 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/CommitCountByCompanyReqVO.java deleted
1 -package com.zteits.urbanops.module.garden.controller.admin.homepage.vo;  
2 -  
3 -import jakarta.validation.constraints.NotEmpty;  
4 -import lombok.Data;  
5 -  
6 -@Data  
7 -public class CommitCountByCompanyReqVO {  
8 - @NotEmpty  
9 - public String beginTime;  
10 - @NotEmpty  
11 - public String endTime;  
12 -}  
13 \ No newline at end of file 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/CommitTaskStatisticsRespVo.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.homepage.vo;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * @Classname CommitTaskStatisticsResp
  7 + * @Description 任务公共返回
  8 + * @Date 2025/12/30 16:12
  9 + * @Created by wangqian
  10 + */
  11 +@Data
  12 +public class CommitTaskStatisticsRespVo {
  13 +
  14 + private String dateValue;
  15 +
  16 + private String busiLine;
  17 +
  18 + private String busiLineName;
  19 +
  20 + private Integer planNum;
  21 +
  22 + private Integer planFinishNum;
  23 +
  24 + private Integer inspectionPlanNum;
  25 +
  26 + private Integer inspectionPlanFinishNum;
  27 +
  28 + private Integer maintainPlanNum;
  29 +
  30 + private Integer maintainPlanFinishNum;
  31 +
  32 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/CommitWorkOrderRespVo.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.homepage.vo;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * @Classname CommitWorkOrderRespVo
  7 + * @Description 子公司分布返回
  8 + * @Date 2025/12/30 22:01
  9 + * @Created by wangqian
  10 + */
  11 +@Data
  12 +public class CommitWorkOrderRespVo {
  13 +
  14 + private Long companyId;
  15 +
  16 + private String companyName;
  17 + //巡查
  18 + private Integer patrolWorkOrde;
  19 + //ai
  20 + private Integer aiWorkOrde;
  21 + //12345
  22 + private Integer outhWorkOrder;
  23 +
  24 + //网格
  25 + private Integer gridWorkOrder;
  26 +
  27 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/HomePageSummaryReqVO.java
1 package com.zteits.urbanops.module.garden.controller.admin.homepage.vo; 1 package com.zteits.urbanops.module.garden.controller.admin.homepage.vo;
2 2
  3 +import io.swagger.v3.oas.annotations.media.Schema;
3 import jakarta.validation.constraints.NotEmpty; 4 import jakarta.validation.constraints.NotEmpty;
4 import lombok.Data; 5 import lombok.Data;
5 6
6 @Data 7 @Data
7 public class HomePageSummaryReqVO { 8 public class HomePageSummaryReqVO {
  9 +
8 @NotEmpty 10 @NotEmpty
  11 + @Schema(description = "开始时间", example = "2025-01-01")
9 public String beginTime; 12 public String beginTime;
  13 + /*结束时间*/
10 @NotEmpty 14 @NotEmpty
  15 + @Schema(description = "结束时间", example = "2025-12-10")
11 public String endTime; 16 public String endTime;
12 -}  
13 \ No newline at end of file 17 \ No newline at end of file
  18 + @Schema(description = "查询类型", example = "类型:order_type,优先级:pressing_type,来源:source_id")
  19 + private String queryType;
  20 + @Schema(description = "查询状态", example = "新提交工单:1,进行中工单:2 ,已完成工单:3")
  21 + private String queryState;
  22 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/MaintainProportionReqVO.java deleted
1 -package com.zteits.urbanops.module.garden.controller.admin.homepage.vo;  
2 -  
3 -import jakarta.validation.constraints.NotNull;  
4 -import lombok.Data;  
5 -  
6 -@Data  
7 -public class MaintainProportionReqVO {  
8 - @NotNull  
9 - private Integer taskStatus;  
10 -}  
11 \ No newline at end of file 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/WorkOrderTrendRespVo.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.homepage.vo;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * @Classname CommitTaskStatisticsResp
  7 + * @Description 任务公共返回
  8 + * @Date 2025/12/30 16:12
  9 + * @Created by wangqian
  10 + */
  11 +@Data
  12 +public class WorkOrderTrendRespVo {
  13 +
  14 + private String dateValue;
  15 +
  16 + private String busiLine;
  17 +
  18 + private String companyId;
  19 +
  20 + private String companyName;
  21 +
  22 + private String totalCount;
  23 +
  24 +
  25 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/homepage/HomepageSummaryMapper.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.dal.mysql.homepage;
  2 +
  3 +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
  4 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo;
  5 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo;
  6 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.WorkOrderTrendRespVo;
  7 +import com.zteits.urbanops.module.garden.dal.dataobject.departmentcost.DepartmentCostDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +import org.apache.ibatis.annotations.Param;
  10 +
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * @Classname HomepageSummaryMapper
  16 + * @Description 首页统计
  17 + * @Date 2025/12/29 22:01
  18 + * @Created by wangqian
  19 + */
  20 +@Mapper
  21 +public interface HomepageSummaryMapper extends BaseMapperX<DepartmentCostDO> {
  22 +
  23 + /**
  24 + * @Author wangqian
  25 + * @Description 根据条件汇总巡检计划已完成、未完成
  26 + * @Date 2025/12/29 22:06
  27 + */
  28 + Map countInspectionPlanByCompanyId(@Param("companyId") Long companyId);
  29 + /**
  30 + * @Author wangqian
  31 + * @Description 根据条件汇总养护计划已完成、未完成
  32 + * @Date 2025/12/29 22:06
  33 + */
  34 + Map countMaintainPlanByCompanyId(@Param("companyId") Long companyId);
  35 + /**
  36 + * @Author wangqian
  37 + * @Description 根据条件按业务线汇总进行中的工单
  38 + * @Date 2025/12/29 22:06
  39 + */
  40 + List<Map<String, String>> countInProgressWorkOrder(@Param("companyId") Long companyId);
  41 + /**
  42 + * @Author wangqian
  43 + * @Description 已完成工单,根据工单类型汇总,无效工单:快速工单;有效工单:其他;
  44 + * @Date 2025/12/29 23:05
  45 + */
  46 + List<Map<String, String>> countCompletedWorkOrder(@Param("companyId") Long companyId);
  47 + /**
  48 + * @Author wangqian
  49 + * @Description 根据条件汇总业务线巡查计划次数
  50 + * @Date 2025/12/30 16:24
  51 + */
  52 + List<CommitTaskStatisticsRespVo> countInspectionPlanNumByBusiLine(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
  53 +
  54 + /**
  55 + * @Author wangqian
  56 + * @Description 根据条件汇总业务线养护计划次数
  57 + * @Date 2025/12/30 16:24
  58 + */
  59 + List<CommitTaskStatisticsRespVo> countMaintainPlanNumByBusiLine(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
  60 +
  61 + /**
  62 + * @Author wangqian
  63 + * @Description
  64 + * @Date 2025/12/30 19:26
  65 + */
  66 + List<Map<String, String>> countRatioByOrderType(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
  67 +
  68 + List<Map<String, String>> countRatioBySourceId(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
  69 +
  70 + List<Map<String, String>> countRatioByPressingType(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
  71 +
  72 + /**
  73 + * @Author wangqian
  74 + * @Description 公司+问题单类型汇总
  75 + * @Date 2025/12/30 21:52
  76 + */
  77 + List<CommitWorkOrderRespVo> countWorkOrderDistribution(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
  78 + /**
  79 + * @Author wangqian
  80 + * @Description 热力图
  81 + * @Date 2025/12/31 14:29
  82 + */
  83 + List<Map<String, Object>> countWorkOrderHeatmap(@Param("companyId") Long companyId);
  84 + /**
  85 + * @Author wangqian
  86 + * @Description 工单趋势
  87 + * @Date 2025/12/30 23:40
  88 + */
  89 + List<WorkOrderTrendRespVo> countWorkOrderTrend(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("queryState") String queryState);
  90 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/CommonConstants.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.enums;
  2 +
  3 +/**
  4 + * @Classname CommonConstants
  5 + * @Description 公共静态参数
  6 + * @Date 2026/1/3 10:15
  7 + * @Created by wangqian
  8 + */
  9 +public interface CommonConstants {
  10 +
  11 + public static final String DEFAULT_COUNT = "0";
  12 +
  13 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/homepage/MaintainSummaryService.java
1 package com.zteits.urbanops.module.garden.service.homepage; 1 package com.zteits.urbanops.module.garden.service.homepage;
2 2
3 -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitCountByCompanyReqVO; 3 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo;
4 import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO; 4 import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO;
5 -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.MaintainProportionReqVO;  
6 5
7 import java.util.List; 6 import java.util.List;
8 import java.util.Map; 7 import java.util.Map;
9 8
10 public interface MaintainSummaryService { 9 public interface MaintainSummaryService {
11 - Map<String, Object> selectMaintainSummary(HomePageSummaryReqVO req, Long companyId);  
12 - Map<String, List<Map<String, Object>>> getSummaryByMaintainType(HomePageSummaryReqVO req, Long companyId);  
13 - List<Map<String, Object>> getSummaryByMaintainProportion(HomePageSummaryReqVO req, Long companyId);  
14 - List<Map<String, Object>> getSummaryByPlantProportion(HomePageSummaryReqVO req, Long companyId);  
15 - Map<String, Object> selectSummaryByCompany(HomePageSummaryReqVO req, Long companyId);  
16 - List<Map<String, Object>> getCommitCountByCompany(CommitCountByCompanyReqVO req);  
17 - List<Map<String, Object>> getPressingTypeByCompany(CommitCountByCompanyReqVO req);  
18 - List<Map<String, Object>> getProcessOrderReturn(Long companyId, String beginTime, String endTime);  
19 - List<Map<String, Object>> getProportionByCompany(String beginTime, String endTime);  
20 - List<Map<String, Object>> getXcProcessOrder(Long companyId, String beginTime, String endTime);  
21 - Map<String, List<Object>> getCommitCountByTime(Long companyId, CommitCountByCompanyReqVO req);  
22 - List<Map<String, Object>> getOrderList(Long companyId, Integer taskStatus);  
23 - Map<String, Object> getSummaryByMaintainTypeAndGrowthRate(HomePageSummaryReqVO req, Long companyId);  
24 -}  
25 \ No newline at end of file 10 \ No newline at end of file
  11 + /**
  12 + * @Author wangqian
  13 + * @Description 首页汇总 巡查计划、养护计划、进行中工单、已完成工单
  14 + * @Date 2025/12/29 21:31
  15 + * @Param req
  16 + * @Return java.util.Map<java.lang.String,java.lang.Object>
  17 + */
  18 + Map<String, Object> getSummary();
  19 + /**
  20 + * @Author wangqian
  21 + * @Description 根据条件查询任务趋势
  22 + * @Date 2025/12/29 23:40
  23 + * @Param req
  24 + */
  25 + Map<String, Object> getWorkTaskTrend(HomePageSummaryReqVO req);
  26 + /**
  27 + * @Author wangqian
  28 + * @Description 根据不同维度查询工单占比(工单类型、紧急程度、来源)
  29 + * @Date 2025/12/30 9:58
  30 + * @Param req
  31 + * @Return java.util.Map<java.lang.String,java.lang.Object>
  32 + */
  33 + Map<String, Object> getWorkOrderRatio(HomePageSummaryReqVO req);
  34 + /**
  35 + * @Author wangqian
  36 + * @Description 按公司、问题单类型分组,查询个问题单个数
  37 + * @Date 2025/12/30 21:50
  38 + * @Param req
  39 + */
  40 + Map<String, CommitWorkOrderRespVo> getWorkOrderDistribution(HomePageSummaryReqVO req);
  41 + /**
  42 + * @Author wangqian
  43 + * @Description 工单热量图
  44 + * @Date 2025/12/31 14:26
  45 + * @Return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
  46 + */
  47 + List<Map<String, Object>> getWorkOrderHeatmap();
  48 + /**
  49 + * @Author wangqian
  50 + * @Description 以时间+单位为维度,统计工单数量
  51 + * @Date 2025/12/30 23:25
  52 + * @Param req
  53 + * @Return java.util.Map<java.lang.String,java.lang.Object>
  54 + */
  55 + Map<String, Object> getWorkOrderTrend(HomePageSummaryReqVO req);
  56 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/homepage/MaintainSummaryServiceImpl.java
1 package com.zteits.urbanops.module.garden.service.homepage; 1 package com.zteits.urbanops.module.garden.service.homepage;
2 2
3 -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitCountByCompanyReqVO; 3 +import cn.hutool.core.bean.BeanUtil;
  4 +import cn.hutool.core.util.ObjectUtil;
  5 +import com.zteits.urbanops.framework.common.biz.system.dict.dto.DictDataRespDTO;
  6 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  7 +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;
  8 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo;
  9 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo;
4 import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO; 10 import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO;
5 -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.MaintainProportionReqVO; 11 +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.WorkOrderTrendRespVo;
  12 +import com.zteits.urbanops.module.garden.dal.mysql.homepage.HomepageSummaryMapper;
  13 +import com.zteits.urbanops.module.garden.enums.CommonConstants;
  14 +import com.zteits.urbanops.module.system.api.dept.DeptApi;
  15 +import com.zteits.urbanops.module.system.api.dict.DictDataApi;
  16 +import com.zteits.urbanops.module.system.controller.admin.dept.vo.dept.DeptRespVO;
  17 +import com.zteits.urbanops.module.system.enums.DictTypeConstants;
  18 +import jakarta.annotation.Resource;
  19 +import me.zhyd.oauth.utils.StringUtils;
  20 +import org.apache.commons.collections4.CollectionUtils;
6 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
7 22
  23 +import java.text.DateFormat;
  24 +import java.text.ParseException;
  25 +import java.text.SimpleDateFormat;
8 import java.util.*; 26 import java.util.*;
  27 +import java.util.function.Function;
  28 +import java.util.stream.Collectors;
  29 +
  30 +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
  31 +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0;
  32 +import static com.zteits.urbanops.module.garden.enums.CommonConstants.DEFAULT_COUNT;
9 33
10 @Service 34 @Service
11 public class MaintainSummaryServiceImpl implements MaintainSummaryService { 35 public class MaintainSummaryServiceImpl implements MaintainSummaryService {
12 - @Override  
13 - public Map<String, Object> selectMaintainSummary(HomePageSummaryReqVO req, Long companyId) {  
14 - return Collections.emptyMap();  
15 - }  
16 36
17 - @Override  
18 - public Map<String, List<Map<String, Object>>> getSummaryByMaintainType(HomePageSummaryReqVO req, Long companyId) {  
19 - return Collections.emptyMap();  
20 - } 37 + @Resource
  38 + private HomepageSummaryMapper homepageSummaryMapper;
  39 + @Resource
  40 + private DeptApi deptApi;
  41 + @Resource
  42 + private DictDataApi dictDataApi;
21 43
22 @Override 44 @Override
23 - public List<Map<String, Object>> getSummaryByMaintainProportion(HomePageSummaryReqVO req, Long companyId) {  
24 - return Collections.emptyList(); 45 + public Map<String, Object> getSummary() {
  46 + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();
  47 + if(null == companyId || companyId == 0L || companyId == 100L){
  48 + companyId = null;
  49 + }
  50 + Map<String, Object> respMap = new HashMap<>();
  51 + Long finalCompanyId = companyId;
  52 + // 巡查计划、已完成、未完成
  53 + Map<String, Object> countInspectionPlan = countInspectionPlanByCompanyId(finalCompanyId);
  54 + // 养护计划、已挖成、未完成
  55 + Map<String, Object> countMaintainPlan = countMaintainPlanByCompanyId(finalCompanyId);
  56 + // 进行中工单、园林、市政、物业
  57 + Map<String, Object> countInProgressWorkOrder = countInProgressWorkOrder(finalCompanyId);
  58 + // 已完成工单 有效工单、无效工单
  59 + Map<String, Object> countCompletedWorkOrder = countCompletedWorkOrder(finalCompanyId);
  60 +
  61 + // 等待所有查询完成
  62 + respMap.put("inspectionPlan", countInspectionPlan);
  63 + respMap.put("maintainPlan", countMaintainPlan);
  64 + respMap.put("inProgressWorkOrder", countInProgressWorkOrder);
  65 + respMap.put("completedWorkOrder", countCompletedWorkOrder);
  66 + return respMap;
25 } 67 }
26 68
27 @Override 69 @Override
28 - public List<Map<String, Object>> getSummaryByPlantProportion(HomePageSummaryReqVO req, Long companyId) {  
29 - return Collections.emptyList();  
30 - } 70 + public Map<String, Object> getWorkTaskTrend(HomePageSummaryReqVO req) {
  71 + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();
  72 + if(null == companyId || companyId == 0L || companyId == 100L){
  73 + companyId = null;
  74 + }
  75 + Map<String,Object> chartData = new HashMap<>();
  76 + //1、数据结构初始化
  77 + List<String> days = getDays(req.beginTime, req.endTime);
  78 + List<DictDataRespDTO> dictDataList = dictDataApi.getDictDataList(DictTypeConstants.BUSINESS_LINE);
  79 + List<String> allBusiLines = dictDataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
  80 + Map<String, List<CommitTaskStatisticsRespVo>> defaultData = addTaskDefaultData(req, days, dictDataList);
  81 + //2、查询巡检计划汇总
  82 + List<CommitTaskStatisticsRespVo> inspectionPlanList = homepageSummaryMapper.countInspectionPlanNumByBusiLine(companyId, req.getBeginTime(), req.getEndTime());
  83 + //根据业务线分组
  84 + Map<String, List<CommitTaskStatisticsRespVo>> inspectionPlanGroupMap =
  85 + inspectionPlanList.stream().filter(vo -> {
  86 + String busiLine = vo.getBusiLine();
  87 + if (busiLine == null) {
  88 + return false;
  89 + }
  90 + return !busiLine.trim().isEmpty();
  91 + })
  92 + .collect(Collectors.groupingBy(CommitTaskStatisticsRespVo::getBusiLine));
  93 + //3、查询养护计划汇总
  94 + List<CommitTaskStatisticsRespVo> maintainPlanList = homepageSummaryMapper.countMaintainPlanNumByBusiLine(companyId, req.getBeginTime(), req.getEndTime());
  95 + //根据业务线分组
  96 + Map<String, List<CommitTaskStatisticsRespVo>> maintainPlanGroupMap =
  97 + maintainPlanList.stream().filter(vo -> {
  98 + String busiLine = vo.getBusiLine();
  99 + if (busiLine == null) {
  100 + return false;
  101 + }
  102 + return !busiLine.trim().isEmpty();
  103 + })
  104 + .collect(Collectors.groupingBy(CommitTaskStatisticsRespVo::getBusiLine));
  105 +
  106 +
  107 +
  108 +
  109 + // 步骤1:获取所有唯一的业务线(busiLine)集合
  110 + for (String busiLine : allBusiLines) {
  111 + List<CommitTaskStatisticsRespVo> defaultVoList = defaultData.get(busiLine);
  112 + if (CollectionUtils.isEmpty(defaultVoList)) {
  113 + // 若当前业务线无默认数据,直接跳过,无需赋值
  114 + continue;
  115 + }
  116 + // ********** 第一步:处理巡检计划数据赋值 **********
  117 + // 获取当前业务线的巡检计划列表(判空,避免null)
  118 + List<CommitTaskStatisticsRespVo> inspectionPlans = inspectionPlanGroupMap.get(busiLine);
  119 + if (CollectionUtils.isNotEmpty(inspectionPlans)) {
  120 + // 联合标识:根据你的VO实际字段调整(示例:dateValue + "_" + busiLine,确保唯一匹配)
  121 + Map<String, CommitTaskStatisticsRespVo> inspectionMap = inspectionPlans.stream()
  122 + .filter(inspectVo ->
  123 + inspectVo.getDateValue() != null && !inspectVo.getDateValue().trim().isEmpty()
  124 + && inspectVo.getBusiLine() != null
  125 + )
  126 + .collect(Collectors.toMap(
  127 + // 键:唯一标识(
  128 + inspectVo -> inspectVo.getDateValue() + "_" + inspectVo.getBusiLine(),
  129 + // 值:巡检计划VO本身
  130 + inspectVo -> inspectVo,
  131 + (existing, newValue) -> existing
  132 + ));
  133 +
  134 + // 遍历默认数据列表,匹配并赋值巡检计划数据
  135 + for (CommitTaskStatisticsRespVo defaultVo : defaultVoList) {
  136 + // 构建默认VO的唯一标识(与巡检计划的标识保持一致)
  137 + String matchKey = defaultVo.getDateValue() + "_" + defaultVo.getBusiLine();
  138 + if (inspectionMap.containsKey(matchKey)) {
  139 + CommitTaskStatisticsRespVo inspectVo = inspectionMap.get(matchKey);
  140 + defaultVo.setInspectionPlanNum(inspectVo.getInspectionPlanNum());
  141 + defaultVo.setInspectionPlanFinishNum(inspectVo.getInspectionPlanFinishNum());
  142 + }
  143 + }
  144 + }
  145 + // ********** 第二步:处理养护计划数据赋值**********
  146 + // 获取当前业务线的养护计划列表(判空,避免null)
  147 + List<CommitTaskStatisticsRespVo> maintainPlans = maintainPlanGroupMap.get(busiLine);
  148 + if (CollectionUtils.isNotEmpty(maintainPlans)) {
  149 + // 构建「联合唯一标识-养护计划VO」Map,提高匹配效率
  150 + Map<String, CommitTaskStatisticsRespVo> maintainMap = maintainPlans.stream()
  151 + .filter(maintainVo ->
  152 + maintainVo.getDateValue() != null && !maintainVo.getDateValue().trim().isEmpty()
  153 + && maintainVo.getBusiLine() != null
  154 + )
  155 + .collect(Collectors.toMap(
  156 + maintainVo -> maintainVo.getDateValue() + "_" + maintainVo.getBusiLine(),
  157 + maintainVo -> maintainVo,
  158 + (existing, newValue) -> existing
  159 + ));
31 160
  161 + // 遍历默认数据列表,匹配并赋值养护计划数据
  162 + for (CommitTaskStatisticsRespVo defaultVo : defaultVoList) {
  163 + String matchKey = defaultVo.getDateValue() + "_" + defaultVo.getBusiLine();
  164 + if (maintainMap.containsKey(matchKey)) {
  165 + CommitTaskStatisticsRespVo maintainVo = maintainMap.get(matchKey);
  166 + // 赋值:
  167 + defaultVo.setMaintainPlanNum(maintainVo.getMaintainPlanNum());
  168 + defaultVo.setMaintainPlanFinishNum(maintainVo.getMaintainPlanFinishNum());
  169 +
  170 + Integer inspectionNum = defaultVo.getInspectionPlanNum() == null ? 0 : defaultVo.getInspectionPlanNum();
  171 + Integer maintainNum = defaultVo.getMaintainPlanNum() == null ? 0 : defaultVo.getMaintainPlanNum();
  172 + Integer inspectionFinishNum = defaultVo.getInspectionPlanFinishNum() == null ? 0 : defaultVo.getInspectionPlanFinishNum();
  173 + Integer maintainFinishNum = defaultVo.getMaintainPlanFinishNum() == null ? 0 : defaultVo.getMaintainPlanFinishNum();
  174 + // 统一计算总计划数和总完成数
  175 + defaultVo.setPlanNum(inspectionNum + maintainNum);
  176 + defaultVo.setPlanFinishNum(inspectionFinishNum + maintainFinishNum);
  177 + }
  178 + }
  179 + }
  180 + }
  181 +
  182 + chartData.put("data", defaultData);
  183 + //日期集合
  184 + chartData.put("timeData",days);
  185 + return chartData;
  186 + }
  187 + /**
  188 + * @Author wangqian
  189 + * @Description 工单占比
  190 + * @Date 2025/12/30 23:45
  191 + */
32 @Override 192 @Override
33 - public Map<String, Object> selectSummaryByCompany(HomePageSummaryReqVO req, Long companyId) {  
34 - return Collections.emptyMap(); 193 + public Map<String, Object> getWorkOrderRatio(HomePageSummaryReqVO req) {
  194 + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();
  195 + if(null == companyId || companyId == 0L || companyId == 100L){
  196 + companyId = null;
  197 + }
  198 + if ("order_type".equals(req.getQueryType())) {
  199 + //工单类型 Q:快速工单,C:普通工单, A:ai工单,W:网格工单,O:12345工单
  200 + // 1. 定义工单类型数组(便于后续扩展,新增类型只需在数组中添加)
  201 + List<DictDataRespDTO> dictDataList = dictDataApi.getDictDataList(DictTypeConstants.WORKORDER_TYPE);
  202 + List<String> orderTypes = dictDataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
  203 + // 2. 初始化响应Map并设置默认空字符串
  204 + Map<String, Object> respMap = new HashMap<>();
  205 + for (String type : orderTypes) {
  206 + respMap.put(type, "0");
  207 + }
  208 + List<Map<String, String>> orderMap = homepageSummaryMapper.countRatioByOrderType(companyId, req.getBeginTime(), req.getEndTime());
  209 + if (ObjectUtil.isNotEmpty(orderMap)) {
  210 + // 5. 批量遍历赋值,修复逻辑:值非空时覆盖默认值
  211 + for (Map<String, String> mapItem : orderMap) {
  212 + String orderType = mapItem.get("orderType");
  213 + if (ObjectUtil.isNotEmpty(orderType) && respMap.containsKey(orderType)) {
  214 + String totalCount = String.valueOf(mapItem.get("totalCount"));
  215 + if (StringUtils.isNotEmpty(totalCount)) {
  216 + respMap.put(orderType, totalCount);
  217 + }
  218 + }
  219 + }
  220 + }
  221 + //合并C和Q
  222 + // 1. 获取respMap中C和Q的原始值
  223 + Object cObj = respMap.get("C");
  224 + Object qObj = respMap.get("Q");
  225 +
  226 + // 2. 初始化C和Q的数值为0(避免空值或转换失败导致异常)
  227 + long cNum = 0;
  228 + long qNum = 0;
  229 +
  230 + // 3. 转换C值为数字(兼容String/Integer/Long类型,处理格式异常)
  231 + if (ObjectUtil.isNotEmpty(cObj)) {
  232 + cNum = Long.parseLong(cObj.toString().trim());
  233 + }
  234 + // 4. 转换Q值为数字(同C值,兼容多类型并处理异常)
  235 + if (ObjectUtil.isNotEmpty(qObj)) {
  236 + qNum = Long.parseLong(qObj.toString().trim());
  237 + }
  238 + // 5. 求和后赋值给C键,覆盖原有C值
  239 + long totalCQ = cNum + qNum;
  240 + respMap.put("C", totalCQ);
  241 +
  242 + // 6. 删除Q键,确保最终返回的Map中无Q键
  243 + respMap.remove("Q");
  244 +
  245 + return respMap;
  246 + } else if ("source_id".equals(req.getQueryType())){
  247 + //来源 事件来源 1、巡查,2、游客居民,3、12345,4、网格 5、大区经理 6、ai
  248 + // 1. 定义工单类型数组(便于后续扩展,新增类型只需在数组中添加)
  249 + List<DictDataRespDTO> dictDataList = dictDataApi.getDictDataList(DictTypeConstants.WORKORDER_SOURCE_TYPE);
  250 + List<String> sourceIds = dictDataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
  251 +
  252 + // 2. 初始化响应Map并设置默认空字符串
  253 + Map<String, Object> respMap = sourceIds.stream()
  254 + .collect(Collectors.toMap(
  255 + sourceId -> sourceId, // 键:业务线
  256 + unused -> DEFAULT_COUNT, // 值:默认0
  257 + (existing, newValue) -> existing, // 重复业务线保留原有值
  258 + HashMap::new // 指定返回HashMap类型
  259 + ));
  260 + List<Map<String, String>> orderMap = homepageSummaryMapper.countRatioBySourceId(companyId, req.getBeginTime(), req.getEndTime());
  261 + if (ObjectUtil.isNotEmpty(orderMap)) {
  262 + for (Map<String, String> mapItem : orderMap) {
  263 + String sourceId = String.valueOf(mapItem.get("sourceId"));
  264 + if (ObjectUtil.isNotEmpty(sourceId) && respMap.containsKey(sourceId)) {
  265 + String totalCount = String.valueOf(mapItem.get("totalCount"));
  266 + if (StringUtils.isNotEmpty(totalCount)) {
  267 + respMap.put(sourceId, totalCount);
  268 + }
  269 + }
  270 + }
  271 + }
  272 + return respMap;
  273 + } else {
  274 + //默认紧急程度 工单紧急程度:特级、紧急、一般
  275 + // 1. 定义工单类型数组(便于后续扩展,新增类型只需在数组中添加)
  276 + List<DictDataRespDTO> dictDataList = dictDataApi.getDictDataList(DictTypeConstants.WORKORDER_PRESSING_TYPE);
  277 + List<String> pressingTypes = dictDataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
  278 + // 2. 初始化响应Map并设置默认空字符串
  279 + Map<String, Object> respMap = pressingTypes.stream()
  280 + .collect(Collectors.toMap(
  281 + pressingType -> pressingType, // 键:业务线
  282 + unused -> DEFAULT_COUNT, // 值:默认0
  283 + (existing, newValue) -> existing, // 重复业务线保留原有值
  284 + HashMap::new // 指定返回HashMap类型
  285 + ));
  286 +
  287 + List<Map<String, String>> orderMap = homepageSummaryMapper.countRatioByPressingType(companyId, req.getBeginTime(), req.getEndTime());
  288 + if (ObjectUtil.isNotEmpty(orderMap)) {
  289 + for (Map<String, String> mapItem : orderMap) {
  290 + String pressingType = String.valueOf(mapItem.get("pressingType"));
  291 + if (ObjectUtil.isNotEmpty(pressingType) && respMap.containsKey(pressingType)) {
  292 + String totalCount = String.valueOf(mapItem.get("totalCount"));
  293 + if (StringUtils.isNotEmpty(totalCount)) {
  294 + respMap.put(pressingType, totalCount);
  295 + }
  296 + }
  297 + }
  298 + }
  299 + return respMap;
  300 + }
35 } 301 }
  302 + /**
  303 + * @Author wangqian
  304 + * @Description 子公司工单分布
  305 + * @Date 2025/12/30 23:45
  306 + */
  307 + @Override
  308 + public Map<String, CommitWorkOrderRespVo> getWorkOrderDistribution(HomePageSummaryReqVO req) {
  309 + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();
  310 + if(null == companyId || companyId == 0L || companyId == 100L){
  311 + companyId = null;
  312 + }
  313 + Map<String, CommitWorkOrderRespVo> respMap = new HashMap<>();
  314 + //初始化对象
  315 + List<CommitWorkOrderRespVo> respList = new ArrayList<>();
  316 + List<DeptRespVO> deptRespVOList = deptApi.getCompanyList();
  317 + for (DeptRespVO deptRespVO : deptRespVOList) {
  318 + CommitWorkOrderRespVo vo = new CommitWorkOrderRespVo();
  319 + vo.setCompanyId(deptRespVO.getId());
  320 + vo.setCompanyName(deptRespVO.getName());
  321 + vo.setPatrolWorkOrde(0);
  322 + vo.setGridWorkOrder(0);
  323 + vo.setAiWorkOrde(0);
  324 + vo.setOuthWorkOrder(0);
  325 + respList.add(vo);
  326 + }
  327 +
  328 + List<CommitWorkOrderRespVo> countList = homepageSummaryMapper.countWorkOrderDistribution(companyId,req.getBeginTime(), req.getEndTime());
  329 + Map<Long, CommitWorkOrderRespVo> companyIdMap = new HashMap<>();
  330 + if (CollectionUtils.isNotEmpty(countList)) {
  331 + companyIdMap = countList.stream()
  332 + .collect(Collectors.toMap(
  333 + CommitWorkOrderRespVo::getCompanyId,
  334 + item -> item,
  335 + (existing, newValue) -> existing
  336 + ));
  337 + }
  338 + for (CommitWorkOrderRespVo respVo : respList) {
  339 + if (!companyIdMap.isEmpty()) {
  340 + CommitWorkOrderRespVo vo = companyIdMap.get(respVo.getCompanyId());
  341 + if(vo != null) {
  342 + respVo.setAiWorkOrde(vo.getAiWorkOrde());
  343 + respVo.setGridWorkOrder(vo.getGridWorkOrder());
  344 + respVo.setPatrolWorkOrde(vo.getPatrolWorkOrde());
  345 + respVo.setOuthWorkOrder(vo.getOuthWorkOrder());
  346 + }
  347 + }
  348 + }
  349 + // 排序
  350 + String[] companyNames = {"蓟城广安", "蓟城德胜", "西城园林", "三海投资", "绿美园林"};
  351 + Map<String, Integer> companyIndexMap = new HashMap<>();
  352 + for (int i = 0; i < companyNames.length; i++) {
  353 + companyIndexMap.put(companyNames[i], i);
  354 + }
  355 + List<CommitWorkOrderRespVo> sortedList = respList.stream()
  356 + // 过滤:仅保留companyNames中存在的单位
  357 + .filter(item -> companyIndexMap.containsKey(item.getCompanyName()))
  358 + // 按预定义顺序排序
  359 + .sorted(Comparator.comparing(item -> companyIndexMap.get(item.getCompanyName())))
  360 + .collect(Collectors.toList());
36 361
  362 + Map<String, CommitWorkOrderRespVo> orderedMap = sortedList.stream()
  363 + .collect(Collectors.toMap(
  364 + CommitWorkOrderRespVo::getCompanyName,
  365 + Function.identity(),
  366 + (existing, replacement) -> existing,
  367 + LinkedHashMap::new
  368 + ));
  369 +
  370 + return orderedMap;
  371 + }
  372 + /**
  373 + * @Author wangqian
  374 + * @Description 热力图
  375 + * @Date 2025/12/31 14:27
  376 + */
37 @Override 377 @Override
38 - public List<Map<String, Object>> getCommitCountByCompany(CommitCountByCompanyReqVO req) {  
39 - return Collections.emptyList(); 378 + public List<Map<String, Object>> getWorkOrderHeatmap() {
  379 + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();
  380 + if(null == companyId || companyId == 0L || companyId == 100L){
  381 + companyId = null;
  382 + }
  383 + return homepageSummaryMapper.countWorkOrderHeatmap(companyId);
40 } 384 }
41 385
  386 + /**
  387 + * @Author wangqian
  388 + * @Description 工单趋势图
  389 + * @Date 2025/12/31 11:44
  390 + */
42 @Override 391 @Override
43 - public List<Map<String, Object>> getPressingTypeByCompany(CommitCountByCompanyReqVO req) {  
44 - return Collections.emptyList(); 392 + public Map<String, Object> getWorkOrderTrend(HomePageSummaryReqVO req) {
  393 + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId();
  394 + if(null == companyId || companyId == 0L || companyId == 100L){
  395 + companyId = null;
  396 + }
  397 + if (StringUtils.isEmpty(req.getQueryState())) {
  398 + throw exception0(BAD_REQUEST.getCode(),"querystate不能为空");
  399 + }
  400 + //返回对象
  401 + Map<String,Object> chartData = new HashMap<>();
  402 + // 1. 初始化响应Map
  403 + Map<String, List<WorkOrderTrendRespVo>> respMap = addDefaultData(req);
  404 + // 2、汇总工单数量
  405 + List<WorkOrderTrendRespVo> countList = homepageSummaryMapper.countWorkOrderTrend(companyId, req.getBeginTime(), req.getEndTime(), req.getQueryState());
  406 + Map<String, List<WorkOrderTrendRespVo>> busiLineGroup;
  407 + if (CollectionUtils.isNotEmpty(countList)) {
  408 + busiLineGroup = countList.stream()
  409 + // 核心:过滤掉busiLine为null或空字符串(含全空格)的记录
  410 + .filter(vo -> {
  411 + if (vo.getBusiLine() == null) {
  412 + return false;
  413 + }
  414 + return !vo.getBusiLine().trim().isEmpty();
  415 + })
  416 + .collect(Collectors.groupingBy(WorkOrderTrendRespVo::getBusiLine));
  417 + } else {
  418 + busiLineGroup = new HashMap<>();
  419 + }
  420 + // 3. 核心:按 busiLine + companyId + dateValue 赋值真实totalCount
  421 + // 遍历respMap中的每个业务线(key=业务线,value=该业务线默认VO列表)
  422 + for (Map.Entry<String, List<WorkOrderTrendRespVo>> respEntry : respMap.entrySet()) {
  423 + String busiLine = respEntry.getKey(); // 当前业务线(如yl/sz/wy)
  424 + List<WorkOrderTrendRespVo> defaultVoList = respEntry.getValue(); // 该业务线默认VO列表
  425 +
  426 + // 3.1 从查询结果中,获取当前业务线对应的真实VO列表
  427 + List<WorkOrderTrendRespVo> realVoList = busiLineGroup.get(busiLine);
  428 + if (CollectionUtils.isEmpty(realVoList)) {
  429 + // 若当前业务线无查询结果,直接跳过,保留默认值0
  430 + continue;
  431 + }
  432 +
  433 + // 3.2 构建「联合标识-真实totalCount」的Map,提高匹配效率
  434 + // 联合标识:companyId_dateValue(因为busiLine已匹配,内部无需重复拼接)
  435 + Map<String, String> realCountMap = realVoList.stream()
  436 + .filter(realVo -> realVo.getCompanyId() != null && realVo.getDateValue() != null) // 过滤空值,避免异常
  437 + .collect(Collectors.toMap(
  438 + // 键:companyId + "_" + dateValue(唯一标识)
  439 + realVo -> realVo.getCompanyId() + "_" + realVo.getDateValue(),
  440 + // 值:真实的totalCount(注意:需根据你的VO类型调整,若为数字可直接赋值)
  441 + realVo -> realVo.getTotalCount(),
  442 + // 若存在重复联合标识,保留第一个值(避免报错)
  443 + (existing, newValue) -> existing
  444 + ));
  445 +
  446 + // 3.3 遍历默认VO列表,匹配并赋值真实totalCount
  447 + for (WorkOrderTrendRespVo defaultVo : defaultVoList) {
  448 + // 构建默认VO的联合标识,与真实值Map匹配
  449 + String key = defaultVo.getCompanyId() + "_" + defaultVo.getDateValue();
  450 + // 若存在真实值,替换默认值;不存在则保留0
  451 + if (realCountMap.containsKey(key)) {
  452 + defaultVo.setTotalCount(realCountMap.get(key));
  453 + }
  454 + }
  455 + }
  456 + chartData.put("data", respMap);
  457 + return chartData;
45 } 458 }
  459 + /**
  460 + * @Author wangqian
  461 + * @Description 初始化返回对象
  462 + * @Date 2025/12/31 22:27
  463 + */
  464 + private Map<String, List<WorkOrderTrendRespVo>> addDefaultData(HomePageSummaryReqVO req){
  465 + Map<String, List<WorkOrderTrendRespVo>> respMap = new HashMap<>();
  466 + List<WorkOrderTrendRespVo> newList = new ArrayList<>();
  467 + List<String> days = getDays(req.beginTime, req.endTime);
  468 + List<DeptRespVO> companyList = deptApi.getCompanyList();
  469 + days.forEach(dayy->{
  470 + companyList.forEach(resp ->{
  471 + WorkOrderTrendRespVo type = new WorkOrderTrendRespVo();
  472 + type.setDateValue(dayy);
  473 + type.setTotalCount("0"); // 默认总数为0
  474 + type.setCompanyId(String.valueOf(resp.getId()));
  475 + type.setCompanyName(resp.getName());
  476 + newList.add(type);
  477 + });
  478 + });
46 479
47 - @Override  
48 - public List<Map<String, Object>> getProcessOrderReturn(Long companyId, String beginTime, String endTime) {  
49 - return Collections.emptyList(); 480 + List<DictDataRespDTO> dictDataList = dictDataApi.getDictDataList(DictTypeConstants.BUSINESS_LINE);
  481 + List<String> busiLines = dictDataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
  482 +
  483 + // 6. 为每个业务线生成专属列表并赋值busiLine
  484 + for (String type : busiLines) {
  485 + // 核心:通过map拷贝对象并设置busiLine,避免引用共享
  486 + List<WorkOrderTrendRespVo> busiLineList = newList.stream()
  487 + // 拷贝原对象,创建新对象并设置当前业务线
  488 + .map(original -> {
  489 + WorkOrderTrendRespVo copy = new WorkOrderTrendRespVo();
  490 + BeanUtils.copyProperties(original, copy);
  491 + // 设置当前业务线(核心:为该列表专属赋值)
  492 + copy.setBusiLine(type);
  493 + return copy;
  494 + })
  495 + .collect(Collectors.toList());
  496 + // 将业务线-对应列表存入Map
  497 + respMap.put(type, busiLineList);
  498 + }
  499 + return respMap;
50 } 500 }
51 501
52 - @Override  
53 - public List<Map<String, Object>> getProportionByCompany(String beginTime, String endTime) {  
54 - return Collections.emptyList(); 502 + /**
  503 + * @Author wangqian
  504 + * @Description 初始化任务趋势图
  505 + * @Date 2026/1/3 10:43
  506 + */
  507 + private Map<String, List<CommitTaskStatisticsRespVo>> addTaskDefaultData(HomePageSummaryReqVO req, List<String> days, List<DictDataRespDTO> dictDataList ){
  508 + Map<String, List<CommitTaskStatisticsRespVo>> respMap = new HashMap<>();
  509 + List<CommitTaskStatisticsRespVo> newList = new ArrayList<>();
  510 + //1、日期赋值
  511 + days.forEach(dayy->{
  512 + CommitTaskStatisticsRespVo vo = new CommitTaskStatisticsRespVo();
  513 + vo.setDateValue(dayy);
  514 + vo.setPlanNum(0); // 默认总数为0
  515 + vo.setPlanFinishNum(0);
  516 + vo.setInspectionPlanNum(0);
  517 + vo.setInspectionPlanFinishNum(0);
  518 + vo.setMaintainPlanNum(0);
  519 + vo.setMaintainPlanFinishNum(0);
  520 + newList.add(vo);
  521 + });
  522 +
  523 + // 2. 为每个业务线生成专属列表并赋值busiLine
  524 + for (DictDataRespDTO dto : dictDataList) {
  525 + // 核心:通过map拷贝对象并设置busiLine,避免引用共享
  526 + List<CommitTaskStatisticsRespVo> busiLineList = newList.stream()
  527 + // 拷贝原对象,创建新对象并设置当前业务线
  528 + .map(original -> {
  529 + CommitTaskStatisticsRespVo copy = new CommitTaskStatisticsRespVo();
  530 + BeanUtils.copyProperties(original, copy);
  531 + copy.setBusiLine(dto.getValue());
  532 + copy.setBusiLineName(dto.getLabel());
  533 + return copy;
  534 + })
  535 + .collect(Collectors.toList());
  536 + // 将业务线-对应列表存入Map
  537 + respMap.put(dto.getValue(), busiLineList);
  538 + }
  539 + return respMap;
55 } 540 }
  541 + /**
  542 + * @Author wangqian
  543 + * @Description 巡检计划统计
  544 + * @Date 2025/12/29 22:15
  545 + * @Param companyId
  546 + * @Return java.util.Map<java.lang.String,java.lang.Object>
  547 + */
  548 + private Map<String, Object> countInspectionPlanByCompanyId(Long companyId) {
  549 + return homepageSummaryMapper.countInspectionPlanByCompanyId(companyId);
  550 + }
  551 + /**
  552 + * @Author wangqian
  553 + * @Description 养护计划统计
  554 + * @Date 2025/12/29 22:15
  555 + * @Param companyId
  556 + * @Return java.util.Map<java.lang.String,java.lang.Object>
  557 + */
  558 + private Map<String, Object> countMaintainPlanByCompanyId(Long companyId) {
  559 + return homepageSummaryMapper.countMaintainPlanByCompanyId(companyId);
  560 + }
  561 + /**
  562 + * @Author wangqian
  563 + * @Description 进行中的工单
  564 + * @Date 2025/12/29 22:15
  565 + * @Param companyId
  566 + * @Return java.util.Map<java.lang.String,java.lang.Object>
  567 + */
  568 + private Map<String, Object> countInProgressWorkOrder(Long companyId) {
  569 + // 1. 定义工单类型数组(便于后续扩展,新增类型只需在数组中添加)
  570 + List<DictDataRespDTO> dictDataList = dictDataApi.getDictDataList(DictTypeConstants.BUSINESS_LINE);
  571 + List<String> busiLines = dictDataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
56 572
57 - @Override  
58 - public List<Map<String, Object>> getXcProcessOrder(Long companyId, String beginTime, String endTime) {  
59 - return Collections.emptyList(); 573 + // 2. 初始化响应Map并设置默认空字符串
  574 + Map<String, Object> respMap = busiLines.stream()
  575 + .collect(Collectors.toMap(
  576 + busiLine -> busiLine, // 键:业务线
  577 + unused -> DEFAULT_COUNT, // 值:默认0
  578 + (existing, newValue) -> existing, // 重复业务线保留原有值
  579 + HashMap::new // 指定返回HashMap类型
  580 + ));
  581 + Integer sumTotalCount = 0;
  582 + List<Map<String, String>> orderMap = homepageSummaryMapper.countInProgressWorkOrder(companyId);
  583 + if (ObjectUtil.isNotEmpty(orderMap)) {
  584 + for (Map<String, String> mapItem : orderMap) {
  585 + String busiLine = mapItem.get("busiLine");
  586 + if (ObjectUtil.isNotEmpty(busiLine) && respMap.containsKey(busiLine)) {
  587 + String totalCount = String.valueOf(mapItem.get("totalCount"));
  588 + if (ObjectUtil.isNotEmpty(totalCount)) {
  589 + respMap.put(busiLine, totalCount);
  590 + sumTotalCount = sumTotalCount + Integer.parseInt(totalCount);
  591 + }
  592 + }
  593 + }
  594 + }
  595 + respMap.put("totalCount", sumTotalCount);
  596 + return respMap;
60 } 597 }
61 598
62 - @Override  
63 - public Map<String, List<Object>> getCommitCountByTime(Long companyId, CommitCountByCompanyReqVO req) {  
64 - return Collections.emptyMap(); 599 + private Map<String, Object> countCompletedWorkOrder(Long companyId) {
  600 + // 1. 定义工单类型数组(便于后续扩展,新增类型只需在数组中添加)
  601 + String[] queryTypes = {"validOrder", "invalidOrder"};
  602 + // 2. 初始化响应Map并设置默认空字符串
  603 + Map<String, Object> respMap = new HashMap<>();
  604 + for (String type : queryTypes) {
  605 + respMap.put(type, "0");
  606 + }
  607 + Integer sumTotalCount = 0;
  608 + List<Map<String, String>> orderMap = homepageSummaryMapper.countCompletedWorkOrder(companyId);
  609 + if (ObjectUtil.isNotEmpty(orderMap)) {
  610 + for (Map<String, String> mapItem : orderMap) {
  611 + String busiLine = mapItem.get("validOrder");
  612 + if (ObjectUtil.isNotEmpty(busiLine) && respMap.containsKey(busiLine)) {
  613 + String totalCount = String.valueOf(mapItem.get("totalCount"));
  614 + if (ObjectUtil.isNotEmpty(totalCount)) {
  615 + respMap.put(busiLine, totalCount);
  616 + sumTotalCount = sumTotalCount + Integer.parseInt(totalCount);
  617 + }
  618 + }
  619 + }
  620 + }
  621 + respMap.put("totalCount", sumTotalCount);
  622 + return respMap;
65 } 623 }
66 624
67 - @Override  
68 - public List<Map<String, Object>> getOrderList(Long companyId, Integer taskStatus) {  
69 - return Collections.emptyList(); 625 + public static List<String> getDays(String startTime, String endTime) {
  626 +
  627 + // 返回的日期集合
  628 + List<String> days = new ArrayList<String>();
  629 +
  630 + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  631 + try {
  632 + Date start = dateFormat.parse(startTime);
  633 + Date end = dateFormat.parse(endTime);
  634 +
  635 + Calendar tempStart = Calendar.getInstance();
  636 + tempStart.setTime(start);
  637 +
  638 + Calendar tempEnd = Calendar.getInstance();
  639 + tempEnd.setTime(end);
  640 + //tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
  641 + while (tempStart.before(tempEnd)) {
  642 + days.add(dateFormat.format(tempStart.getTime()));
  643 + tempStart.add(Calendar.DAY_OF_YEAR, 1);
  644 + }
  645 +
  646 + } catch (ParseException e) {
  647 + e.printStackTrace();
  648 + }
  649 +
  650 + return days;
70 } 651 }
71 652
72 - @Override  
73 - public Map<String, Object> getSummaryByMaintainTypeAndGrowthRate(HomePageSummaryReqVO req, Long companyId) {  
74 - return Collections.emptyMap(); 653 + /**
  654 + * 字符串类型数字求和工具方法(兼容空值、非数字格式)
  655 + * @param num1 第一个数字字符串
  656 + * @param num2 第二个数字字符串
  657 + * @return 求和后的字符串(转换失败/空值按0处理)
  658 + */
  659 + private String sumStringNum(String num1, String num2) {
  660 + // 转换第一个数字:空值/非数字按0处理
  661 + long n1 = 0;
  662 + if (StringUtils.isNotEmpty(num1)) {
  663 + try {
  664 + n1 = Long.parseLong(num1.trim());
  665 + } catch (NumberFormatException e) {
  666 + // 非数字格式,保持0(可选打印日志提示)
  667 + // log.warn("数字字符串转换失败:{}", num1);
  668 + }
  669 + }
  670 +
  671 + // 转换第二个数字:空值/非数字按0处理
  672 + long n2 = 0;
  673 + if (StringUtils.isNotEmpty(num2)) {
  674 + try {
  675 + n2 = Long.parseLong(num2.trim());
  676 + } catch (NumberFormatException e) {
  677 + // 非数字格式,保持0
  678 + // log.warn("数字字符串转换失败:{}", num2);
  679 + }
  680 + }
  681 +
  682 + // 求和后转为字符串返回(与VO字段类型一致)
  683 + return String.valueOf(n1 + n2);
75 } 684 }
76 -}  
77 \ No newline at end of file 685 \ No newline at end of file
  686 +}
urbanops-module-garden/src/main/resources/mapper/homepage/HomepageSummaryMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.zteits.urbanops.module.garden.dal.mysql.homepage.HomepageSummaryMapper">
  4 +
  5 + <select id="countInspectionPlanByCompanyId" resultType="java.util.Map" parameterType="java.lang.Long">
  6 + SELECT
  7 + SUM(CASE WHEN t.finish_state = 1 THEN 1 ELSE 0 END) AS unfinishedCount,
  8 + SUM(CASE WHEN t.finish_state = 2 THEN 1 ELSE 0 END) AS finishedCount,
  9 + SUM(CASE WHEN t.finish_state = 3 THEN 1 ELSE 0 END) AS invalidCount,
  10 + SUM(CASE WHEN t.finish_state = 4 THEN 1 ELSE 0 END) AS terminatedCount,
  11 + COUNT(1) AS totalCount
  12 + FROM
  13 + garden_inspection_plan t
  14 + <where>
  15 + t.deleted = 0
  16 + <if test="companyId != null">
  17 + AND t.worker_company_id = #{companyId}
  18 + </if>
  19 + </where>
  20 + </select>
  21 +
  22 + <select id="countMaintainPlanByCompanyId" resultType="java.util.Map" parameterType="java.lang.Long">
  23 + SELECT
  24 + SUM(CASE WHEN t.finish_state = 1 THEN 1 ELSE 0 END) AS unfinishedCount,
  25 + SUM(CASE WHEN t.finish_state = 2 THEN 1 ELSE 0 END) AS finishedCount,
  26 + SUM(CASE WHEN t.finish_state = 3 THEN 1 ELSE 0 END) AS invalidCount,
  27 + SUM(CASE WHEN t.finish_state = 4 THEN 1 ELSE 0 END) AS terminatedCount,
  28 + COUNT(1) AS totalCount
  29 + FROM
  30 + garden_maintain_plan t
  31 + <where>
  32 + t.deleted = 0
  33 + <if test="companyId != null">
  34 + AND t.worker_company_id = #{companyId}
  35 + </if>
  36 + </where>
  37 + </select>
  38 +
  39 + <select id="countInProgressWorkOrder" resultType="java.util.Map" parameterType="java.lang.Long">
  40 + SELECT
  41 + t.busi_line as busiLine,
  42 + COUNT(1) AS totalCount
  43 + FROM
  44 + workorder_main_info t
  45 + <where>
  46 + t.deleted = 0
  47 + AND t.buz_status != '200'
  48 + <if test="companyId != null">
  49 + AND t.worker_company_id = #{companyId}
  50 + </if>
  51 + </where>
  52 + GROUP BY
  53 + t.busi_line
  54 + </select>
  55 +
  56 + <select id="countCompletedWorkOrder" resultType="java.util.Map" parameterType="java.lang.Long">
  57 + SELECT
  58 + CASE WHEN t.worker_id IS NOT NULL THEN 'validOrder'
  59 + ELSE 'invalidOrder'
  60 + END AS workorder_valid_status,
  61 + COUNT(1) AS totalCount
  62 + FROM
  63 + workorder_main_info t
  64 + <where>
  65 + t.deleted = 0
  66 + AND t.buz_status = '200'
  67 + <if test="companyId != null">
  68 + AND t.worker_company_id = #{companyId}
  69 + </if>
  70 + </where>
  71 + GROUP BY
  72 + CASE WHEN t.worker_id IS NOT NULL THEN 'validOrder'
  73 + ELSE 'invalidOrder'
  74 + END
  75 + </select>
  76 + <!-- 巡查计划次数统计-->
  77 + <select id="countInspectionPlanNumByBusiLine" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo">
  78 + select v.date_value dateValue,
  79 + busi_line as busiLine ,
  80 + IFNULL(SUM(plan_num), 0) AS inspectionPlanNum,
  81 + IFNULL(sum(plan_finish_num),0) AS inspectionPlanFinishNum
  82 + from view_statics_times v
  83 + left join garden_inspection_plan_detail t
  84 + on v.date_value = DATE_FORMAT(t.end_time , '%Y-%m-%d') and deleted =0 and finish_state NOT IN (3, 4)
  85 + <if test="companyId != null">
  86 + AND company_id = #{companyId}
  87 + </if>
  88 + <where>
  89 + <if test="beginTime != null and beginTime != ''">
  90 + AND v.date_value >= #{beginTime}
  91 + </if>
  92 + <if test="endTime != null and endTime != ''">
  93 + AND v.date_value &lt; #{endTime}
  94 + </if>
  95 + </where>
  96 + group by v.date_value,busi_line
  97 + </select>
  98 + <!-- 养护计划次统计-->
  99 + <select id="countMaintainPlanNumByBusiLine" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo">
  100 + select v.date_value,
  101 + busi_line as busiLine ,
  102 + IFNULL(SUM(plan_num), 0) AS maintainPlanNum,
  103 + IFNULL(sum(plan_finish_num),0) as maintainPlanFinishNum
  104 + from view_statics_times v
  105 + left join garden_maintain_plan_detail t
  106 + on v.date_value = DATE_FORMAT(t.end_time , '%Y-%m-%d') and busi_line='yl' and deleted =0 and finish_state NOT IN (3, 4)
  107 + <if test="companyId != null">
  108 + AND company_id = #{companyId}
  109 + </if>
  110 + <where>
  111 + <if test="beginTime != null and beginTime != ''">
  112 + AND v.date_value >= #{beginTime}
  113 + </if>
  114 + <if test="endTime != null and endTime != ''">
  115 + AND v.date_value &lt; #{endTime}
  116 + </if>
  117 + </where>
  118 + group by v.date_value,busi_line
  119 + </select>
  120 +
  121 + <select id="countRatioByOrderType" resultType="java.util.Map">
  122 + SELECT
  123 + t.order_type AS orderType,
  124 + COUNT(1) AS totalCount
  125 + FROM
  126 + workorder_main_info t
  127 + <where>
  128 + deleted = 0
  129 + <if test="companyId != null">
  130 + and t.worker_company_id = #{companyId}
  131 + </if>
  132 + <if test="beginTime != null and beginTime != ''">
  133 + AND t.create_time >= #{beginTime}
  134 + </if>
  135 + <if test="endTime != null and endTime != ''">
  136 + AND t.create_time &lt; #{endTime}
  137 + </if>
  138 + </where>
  139 + GROUP BY
  140 + t.order_type
  141 + </select>
  142 + <select id="countRatioBySourceId" resultType="java.util.Map">
  143 + SELECT
  144 + t.source_id as sourceId,
  145 + COUNT(1) AS totalCount
  146 + FROM
  147 + workorder_main_info t
  148 + <where>
  149 + deleted = 0
  150 + <if test="companyId != null">
  151 + and t.worker_company_id = #{companyId}
  152 + </if>
  153 + <if test="beginTime != null and beginTime != ''">
  154 + AND t.create_time >= #{beginTime}
  155 + </if>
  156 + <if test="endTime != null and endTime != ''">
  157 + AND t.create_time &lt; #{endTime}
  158 + </if>
  159 + </where>
  160 + GROUP BY
  161 + t.source_id
  162 + </select>
  163 + <select id="countRatioByPressingType" resultType="java.util.Map" >
  164 + SELECT
  165 + t.pressing_type as pressingType,
  166 + COUNT(1) AS totalCount
  167 + FROM
  168 + workorder_main_info t
  169 + <where>
  170 + deleted = 0
  171 + <if test="companyId != null">
  172 + and t.worker_company_id = #{companyId}
  173 + </if>
  174 + <if test="beginTime != null and beginTime != ''">
  175 + AND t.create_time >= #{beginTime}
  176 + </if>
  177 + <if test="endTime != null and endTime != ''">
  178 + AND t.create_time &lt; #{endTime}
  179 + </if>
  180 + </where>
  181 + GROUP BY
  182 + t.pressing_type
  183 + </select>
  184 + <select id="countWorkOrderDistribution" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo">
  185 + SELECT
  186 + t.worker_company_id as companyId ,
  187 + sum(case when t.order_type='Q' or t.order_type='C' then 1 else 0 end) as patrolWorkOrde,
  188 + sum(case when t.order_type='A' then 1 else 0 end) as aiWorkOrde,
  189 + sum(case when t.order_type='W' then 1 else 0 end) as gridWorkOrder,
  190 + sum(case when t.order_type='O' then 1 else 0 end) as outhWorkOrderO
  191 + FROM
  192 + workorder_main_info t
  193 + <where>
  194 + deleted = 0
  195 + <if test="companyId != null">
  196 + and t.worker_company_id = #{companyId}
  197 + </if>
  198 + <if test="beginTime != null and beginTime != ''">
  199 + AND t.create_time >= #{beginTime}
  200 + </if>
  201 + <if test="endTime != null and endTime != ''">
  202 + AND t.create_time &lt; #{endTime}
  203 + </if>
  204 + </where>
  205 + GROUP BY
  206 + t.worker_company_id
  207 + </select>
  208 + <!--热量图-->
  209 + <select id="countWorkOrderHeatmap" resultType="java.util.Map" >
  210 + SELECT
  211 + t.lat, t.lon, COUNT(1) AS totalCount
  212 + FROM
  213 + workorder_main_info t
  214 + <where>
  215 + t.deleted = 0
  216 + <if test="companyId != null">
  217 + and t.worker_company_id = #{companyId}
  218 + </if>
  219 + </where>
  220 + GROUP BY
  221 + t.lat,t.lon
  222 + </select>
  223 +
  224 + <select id="countWorkOrderTrend" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.WorkOrderTrendRespVo">
  225 + select v.date_value as dateValue,
  226 + t.busi_line as busiLine,
  227 + t.worker_company_id as companyId,
  228 + <choose>
  229 + <when test='queryState != null and queryState eq "1"'>
  230 + sum(case when v.date_value = DATE_FORMAT(t.create_time , '%Y-%m-%d') then 1 else 0 end) as totalCount
  231 + </when>
  232 + <when test='queryState != null and queryState eq "2"'>
  233 + sum(case when t.buz_status != '200' then 1 else 0 end) as totalCount
  234 + </when>
  235 + <when test='queryState != null and queryState eq "3"'>
  236 + sum(case when t.buz_status = '200' then 1 else 0 end) as totalCount
  237 + </when>
  238 + </choose>
  239 + from view_statics_times v
  240 + left join workorder_main_info t
  241 + on v.date_value = DATE_FORMAT(t.create_time , '%Y-%m-%d') and deleted =0
  242 + <where>
  243 + <if test="beginTime != null and beginTime != ''">
  244 + AND v.date_value >= #{beginTime}
  245 + </if>
  246 + <if test="endTime != null and endTime != ''">
  247 + AND v.date_value &lt; #{endTime}
  248 + </if>
  249 + </where>
  250 + group by v.date_value,t.busi_line,t.worker_company_id
  251 + </select>
  252 +
  253 +</mapper>
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/enums/DictTypeConstants.java
@@ -23,4 +23,15 @@ public interface DictTypeConstants { @@ -23,4 +23,15 @@ public interface DictTypeConstants {
23 String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态 23 String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态
24 String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态 24 String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态
25 25
  26 + String WORKORDER_SOURCE_TYPE = "workorder_source_type"; // 工单来源
  27 + String WORKORDER_PRESSING_TYPE = "workorder_pressing_type"; // 工单紧急程度
  28 +
  29 + String BUSINESS_LINE = "business_line"; // 业务线
  30 +
  31 + String WORKORDER_TYPE = "work_order_type"; //工单类型
  32 +
  33 +
  34 +
  35 +
  36 +
26 } 37 }