Commit b4059112f69b869dd60d42c686c272539fad810f
1 parent
4c9efe7f
子公司工单分布按来源统计
Showing
6 changed files
with
157 additions
and
4 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/MaintainSummaryController.java
| ... | ... | @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.garden.controller.admin.homepage; |
| 2 | 2 | |
| 3 | 3 | import com.zteits.urbanops.framework.common.pojo.CommonResult; |
| 4 | 4 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo; |
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderSourceRespVo; | |
| 5 | 6 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO; |
| 6 | 7 | import com.zteits.urbanops.module.garden.service.homepage.MaintainSummaryService; |
| 7 | 8 | import io.swagger.v3.oas.annotations.Operation; |
| ... | ... | @@ -48,6 +49,12 @@ public class MaintainSummaryController { |
| 48 | 49 | public CommonResult<Map<String, CommitWorkOrderRespVo>> getWorkOrderDistribution(@Valid @RequestBody HomePageSummaryReqVO req) { |
| 49 | 50 | return success(maintainSummaryService.getWorkOrderDistribution(req)); |
| 50 | 51 | } |
| 52 | + | |
| 53 | + @PostMapping("/getWorkOrderDistributionBySource") | |
| 54 | + @Operation(summary = "子公司工单分布") | |
| 55 | + public CommonResult<Map<String, CommitWorkOrderSourceRespVo>> getWorkOrderDistributionBySource(@Valid @RequestBody HomePageSummaryReqVO req) { | |
| 56 | + return success(maintainSummaryService.getWorkOrderDistributionBySource(req)); | |
| 57 | + } | |
| 51 | 58 | @PostMapping("/getWorkOrderHeatmap") |
| 52 | 59 | @Operation(summary = "工单热力图") |
| 53 | 60 | public CommonResult<List<Map<String, Object>>> getWorkOrderHeatmap() { | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/homepage/vo/CommitWorkOrderSourceRespVo.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 CommitWorkOrderSourceRespVo { | |
| 13 | + | |
| 14 | + private Long companyId; | |
| 15 | + | |
| 16 | + private String companyName; | |
| 17 | + //巡查 | |
| 18 | + private Integer patrolCount; | |
| 19 | + // | |
| 20 | + private Integer touristResidentCount; | |
| 21 | + //12345 | |
| 22 | + private Integer otherCount; | |
| 23 | + //网格 | |
| 24 | + private Integer gridCount; | |
| 25 | + //大区经理 | |
| 26 | + private Integer regionalManagerCount; | |
| 27 | + //ai | |
| 28 | + private Integer aiCount; | |
| 29 | + | |
| 30 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/homepage/HomepageSummaryMapper.java
| ... | ... | @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.garden.dal.mysql.homepage; |
| 3 | 3 | import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | 4 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo; |
| 5 | 5 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo; |
| 6 | +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderSourceRespVo; | |
| 6 | 7 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.WorkOrderTrendRespVo; |
| 7 | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.departmentcost.DepartmentCostDO; |
| 8 | 9 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -77,6 +78,13 @@ public interface HomepageSummaryMapper extends BaseMapperX<DepartmentCostDO> { |
| 77 | 78 | List<CommitWorkOrderRespVo> countWorkOrderDistribution(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); |
| 78 | 79 | /** |
| 79 | 80 | * @Author wangqian |
| 81 | + * @Description 公司+问题来源 | |
| 82 | + * @Date 2025/12/30 21:52 | |
| 83 | + */ | |
| 84 | + List<CommitWorkOrderSourceRespVo> countWorkOrderDistributionBySource(@Param("companyId") Long companyId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * @Author wangqian | |
| 80 | 88 | * @Description 热力图 |
| 81 | 89 | * @Date 2025/12/31 14:29 |
| 82 | 90 | */ | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/homepage/MaintainSummaryService.java
| 1 | 1 | package com.zteits.urbanops.module.garden.service.homepage; |
| 2 | 2 | |
| 3 | 3 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo; |
| 4 | +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderSourceRespVo; | |
| 4 | 5 | import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO; |
| 5 | 6 | |
| 6 | 7 | import java.util.List; |
| ... | ... | @@ -37,6 +38,14 @@ public interface MaintainSummaryService { |
| 37 | 38 | * @Param req |
| 38 | 39 | */ |
| 39 | 40 | Map<String, CommitWorkOrderRespVo> getWorkOrderDistribution(HomePageSummaryReqVO req); |
| 41 | + | |
| 42 | + /** | |
| 43 | + * @Author wangqian | |
| 44 | + * @Description 按公司、问题来源统计 | |
| 45 | + * @Date 2025/12/30 21:50 | |
| 46 | + * @Param req | |
| 47 | + */ | |
| 48 | + Map<String, CommitWorkOrderSourceRespVo> getWorkOrderDistributionBySource(HomePageSummaryReqVO req); | |
| 40 | 49 | /** |
| 41 | 50 | * @Author wangqian |
| 42 | 51 | * @Description 工单热量图 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/homepage/MaintainSummaryServiceImpl.java
| ... | ... | @@ -5,10 +5,7 @@ import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import com.zteits.urbanops.framework.common.biz.system.dict.dto.DictDataRespDTO; |
| 6 | 6 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 7 | 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; | |
| 10 | -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.HomePageSummaryReqVO; | |
| 11 | -import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.WorkOrderTrendRespVo; | |
| 8 | +import com.zteits.urbanops.module.garden.controller.admin.homepage.vo.*; | |
| 12 | 9 | import com.zteits.urbanops.module.garden.dal.mysql.homepage.HomepageSummaryMapper; |
| 13 | 10 | import com.zteits.urbanops.module.garden.enums.CommonConstants; |
| 14 | 11 | import com.zteits.urbanops.module.system.api.dept.DeptApi; |
| ... | ... | @@ -345,6 +342,76 @@ public class MaintainSummaryServiceImpl implements MaintainSummaryService { |
| 345 | 342 | |
| 346 | 343 | return orderedMap; |
| 347 | 344 | } |
| 345 | + | |
| 346 | + @Override | |
| 347 | + public Map<String, CommitWorkOrderSourceRespVo> getWorkOrderDistributionBySource(HomePageSummaryReqVO req) { | |
| 348 | + Long companyId = SecurityFrameworkUtils.getLoginUserDeptId(); | |
| 349 | + if(null == companyId || companyId == 0L || companyId == 100L){ | |
| 350 | + companyId = null; | |
| 351 | + } | |
| 352 | + Map<String, CommitWorkOrderSourceRespVo> respMap = new HashMap<>(); | |
| 353 | + //初始化对象 | |
| 354 | + List<CommitWorkOrderSourceRespVo> respList = new ArrayList<>(); | |
| 355 | + List<DeptRespVO> deptRespVOList = deptApi.getCompanyList(); | |
| 356 | + for (DeptRespVO deptRespVO : deptRespVOList) { | |
| 357 | + CommitWorkOrderSourceRespVo vo = new CommitWorkOrderSourceRespVo(); | |
| 358 | + vo.setCompanyId(deptRespVO.getId()); | |
| 359 | + vo.setCompanyName(deptRespVO.getName()); | |
| 360 | + vo.setPatrolCount(0); | |
| 361 | + vo.setTouristResidentCount(0); | |
| 362 | + vo.setGridCount(0); | |
| 363 | + vo.setOtherCount(0); | |
| 364 | + vo.setAiCount(0); | |
| 365 | + vo.setRegionalManagerCount(0); | |
| 366 | + respList.add(vo); | |
| 367 | + } | |
| 368 | + | |
| 369 | + List<CommitWorkOrderSourceRespVo> countList = homepageSummaryMapper.countWorkOrderDistributionBySource(companyId,req.getBeginTime(), req.getEndTime()); | |
| 370 | + Map<Long, CommitWorkOrderSourceRespVo> companyIdMap = new HashMap<>(); | |
| 371 | + if (CollectionUtils.isNotEmpty(countList)) { | |
| 372 | + companyIdMap = countList.stream() | |
| 373 | + .collect(Collectors.toMap( | |
| 374 | + CommitWorkOrderSourceRespVo::getCompanyId, | |
| 375 | + item -> item, | |
| 376 | + (existing, newValue) -> existing | |
| 377 | + )); | |
| 378 | + } | |
| 379 | + for (CommitWorkOrderSourceRespVo respVo : respList) { | |
| 380 | + if (!companyIdMap.isEmpty()) { | |
| 381 | + CommitWorkOrderSourceRespVo vo = companyIdMap.get(respVo.getCompanyId()); | |
| 382 | + if(vo != null) { | |
| 383 | + respVo.setPatrolCount(vo.getPatrolCount()); | |
| 384 | + respVo.setTouristResidentCount(vo.getTouristResidentCount()); | |
| 385 | + respVo.setGridCount(vo.getGridCount()); | |
| 386 | + respVo.setAiCount(vo.getAiCount()); | |
| 387 | + respVo.setOtherCount(vo.getOtherCount()); | |
| 388 | + respVo.setRegionalManagerCount(vo.getRegionalManagerCount()); | |
| 389 | + } | |
| 390 | + } | |
| 391 | + } | |
| 392 | + // 排序 | |
| 393 | + String[] companyNames = {"蓟城广安", "蓟城德胜", "西城园林", "三海投资", "绿美园林"}; | |
| 394 | + Map<String, Integer> companyIndexMap = new HashMap<>(); | |
| 395 | + for (int i = 0; i < companyNames.length; i++) { | |
| 396 | + companyIndexMap.put(companyNames[i], i); | |
| 397 | + } | |
| 398 | + List<CommitWorkOrderSourceRespVo> sortedList = respList.stream() | |
| 399 | + // 过滤:仅保留companyNames中存在的单位 | |
| 400 | + .filter(item -> companyIndexMap.containsKey(item.getCompanyName())) | |
| 401 | + // 按预定义顺序排序 | |
| 402 | + .sorted(Comparator.comparing(item -> companyIndexMap.get(item.getCompanyName()))) | |
| 403 | + .collect(Collectors.toList()); | |
| 404 | + | |
| 405 | + Map<String, CommitWorkOrderSourceRespVo> orderedMap = sortedList.stream() | |
| 406 | + .collect(Collectors.toMap( | |
| 407 | + CommitWorkOrderSourceRespVo::getCompanyName, | |
| 408 | + Function.identity(), | |
| 409 | + (existing, replacement) -> existing, | |
| 410 | + LinkedHashMap::new | |
| 411 | + )); | |
| 412 | + | |
| 413 | + return orderedMap; | |
| 414 | + } | |
| 348 | 415 | /** |
| 349 | 416 | * @Author wangqian |
| 350 | 417 | * @Description 热力图 | ... | ... |
urbanops-module-garden/src/main/resources/mapper/homepage/HomepageSummaryMapper.xml
| ... | ... | @@ -205,6 +205,38 @@ |
| 205 | 205 | GROUP BY |
| 206 | 206 | t.worker_company_id |
| 207 | 207 | </select> |
| 208 | + <select id="countWorkOrderDistributionBySource" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderSourceRespVo"> | |
| 209 | + SELECT | |
| 210 | + t.worker_company_id AS companyId, | |
| 211 | + -- source_id=1:巡查工单 | |
| 212 | + SUM(CASE WHEN t.source_id = 1 THEN 1 ELSE 0 END) AS patrolCount, | |
| 213 | + -- source_id=2:游客居民工单 | |
| 214 | + SUM(CASE WHEN t.source_id = 2 THEN 1 ELSE 0 END) AS touristResidentCount, | |
| 215 | + -- source_id=3:12345工单 | |
| 216 | + SUM(CASE WHEN t.source_id = 3 THEN 1 ELSE 0 END) AS otherCount, | |
| 217 | + -- source_id=4:网格工单 | |
| 218 | + SUM(CASE WHEN t.source_id = 4 THEN 1 ELSE 0 END) AS gridCount, | |
| 219 | + -- source_id=5:大区经理工单 | |
| 220 | + SUM(CASE WHEN t.source_id = 5 THEN 1 ELSE 0 END) AS regionalManagerCount, | |
| 221 | + -- source_id=6:AI工单 | |
| 222 | + SUM(CASE WHEN t.source_id = 6 THEN 1 ELSE 0 END) AS aiCount | |
| 223 | + FROM | |
| 224 | + workorder_main_info t | |
| 225 | + <where> | |
| 226 | + deleted = 0 | |
| 227 | + <if test="companyId != null"> | |
| 228 | + and t.worker_company_id = #{companyId} | |
| 229 | + </if> | |
| 230 | + <if test="beginTime != null and beginTime != ''"> | |
| 231 | + AND t.create_time >= #{beginTime} | |
| 232 | + </if> | |
| 233 | + <if test="endTime != null and endTime != ''"> | |
| 234 | + AND t.create_time < #{endTime} | |
| 235 | + </if> | |
| 236 | + </where> | |
| 237 | + GROUP BY | |
| 238 | + t.worker_company_id | |
| 239 | + </select> | |
| 208 | 240 | <!--热量图--> |
| 209 | 241 | <select id="countWorkOrderHeatmap" resultType="java.util.Map" > |
| 210 | 242 | SELECT | ... | ... |