refactor(sk-module): 优化多个模块的代码结构和功能
- 移除了 EquipmentInfoDuration 类中未使用的导入 - 优化了 InspectionAnalysisServiceImpl 中的任务查询逻辑- 更新了 InspectionPlanMapper.xml 中的 SQL 查询 - 增加了 WebSocket 类中的 AI 消息发送功能
正在显示
4 个修改的文件
包含
45 行增加
和
21 行删除
1 | package com.skua.modules.statistics.entity; | 1 | package com.skua.modules.statistics.entity; |
2 | 2 | ||
3 | import java.io.Serializable; | ||
4 | import java.util.Date; | ||
5 | import com.baomidou.mybatisplus.annotation.IdType; | 3 | import com.baomidou.mybatisplus.annotation.IdType; |
6 | import com.baomidou.mybatisplus.annotation.TableId; | 4 | import com.baomidou.mybatisplus.annotation.TableId; |
7 | import com.baomidou.mybatisplus.annotation.TableName; | 5 | import com.baomidou.mybatisplus.annotation.TableName; |
... | @@ -12,9 +10,6 @@ import io.swagger.annotations.ApiModelProperty; | ... | @@ -12,9 +10,6 @@ import io.swagger.annotations.ApiModelProperty; |
12 | import lombok.Data; | 10 | import lombok.Data; |
13 | import lombok.EqualsAndHashCode; | 11 | import lombok.EqualsAndHashCode; |
14 | import lombok.experimental.Accessors; | 12 | import lombok.experimental.Accessors; |
15 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
16 | import netscape.javascript.JSUtil; | ||
17 | import org.springframework.format.annotation.DateTimeFormat; | ||
18 | import org.jeecgframework.poi.excel.annotation.Excel; | 13 | import org.jeecgframework.poi.excel.annotation.Excel; |
19 | 14 | ||
20 | /** | 15 | /** | ... | ... |
... | @@ -3,7 +3,13 @@ | ... | @@ -3,7 +3,13 @@ |
3 | <mapper namespace="com.skua.modules.inspection.mapper.InspectionPlanMapper"> | 3 | <mapper namespace="com.skua.modules.inspection.mapper.InspectionPlanMapper"> |
4 | 4 | ||
5 | <select id="getPage" resultType="com.skua.modules.inspection.entity.InspectionPlan"> | 5 | <select id="getPage" resultType="com.skua.modules.inspection.entity.InspectionPlan"> |
6 | select * from inspection_plan p | 6 | select p.*,ifnull(e.equip_count,0) as equip_count from inspection_plan p |
7 | LEFT join | ||
8 | (select n.inspection_plan_id,count(g.equip_info_id) equip_count | ||
9 | from inspection_plan_point n | ||
10 | left join inspection_point_fill_group g on n.inspection_point_id = g.inspection_point_id | ||
11 | where g.equip_info_id != '' GROUP BY n.inspection_plan_id | ||
12 | ) e on p.id = e.inspection_plan_id | ||
7 | where p.del_flag = '0' | 13 | where p.del_flag = '0' |
8 | <if test="departId!=null and departId!=''"> | 14 | <if test="departId!=null and departId!=''"> |
9 | AND p.depart_id = #{departId} | 15 | AND p.depart_id = #{departId} | ... | ... |
1 | package com.skua.modules.inspection.service.impl; | 1 | package com.skua.modules.inspection.service.impl; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
4 | import com.baomidou.mybatisplus.core.metadata.IPage; | ||
4 | import com.skua.core.context.BaseContextHandler; | 5 | import com.skua.core.context.BaseContextHandler; |
5 | import com.skua.core.util.ConvertUtils; | 6 | import com.skua.core.util.ConvertUtils; |
6 | import com.skua.core.util.DateUtils; | 7 | import com.skua.core.util.DateUtils; |
... | @@ -369,12 +370,18 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService | ... | @@ -369,12 +370,18 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService |
369 | inspectionTaskIndicatorsVO.setAbnormalRate("0"); | 370 | inspectionTaskIndicatorsVO.setAbnormalRate("0"); |
370 | inspectionTaskIndicatorsVO.setProcessedAbnormalRate("0"); | 371 | inspectionTaskIndicatorsVO.setProcessedAbnormalRate("0"); |
371 | //查询时间内巡检任务信息 | 372 | //查询时间内巡检任务信息 |
373 | InspectionTaskVO inspectionTaskVO = new InspectionTaskVO(); | ||
372 | QueryWrapper<InspectionTask> inspectionTaskQueryWrapper = new QueryWrapper(); | 374 | QueryWrapper<InspectionTask> inspectionTaskQueryWrapper = new QueryWrapper(); |
373 | if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) { | 375 | if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) { |
374 | inspectionTaskQueryWrapper.ge("inspection_cycle_start_date", startDate + " 00:00:00"); | 376 | inspectionTaskQueryWrapper.ge("inspection_cycle_start_date", startDate + " 00:00:00"); |
375 | inspectionTaskQueryWrapper.le("inspection_cycle_start_date", endDate + " 23:59:59"); | 377 | inspectionTaskQueryWrapper.le("inspection_cycle_start_date", endDate + " 23:59:59"); |
378 | inspectionTaskVO.setStartTime(inspectionTaskVO.getStartTime() + " 00:00:00"); | ||
379 | inspectionTaskVO.setEndTime(inspectionTaskVO.getEndTime() + " 23:59:59"); | ||
376 | } | 380 | } |
377 | List<InspectionTask> inspectionTaskList = inspectionTaskService.list(inspectionTaskQueryWrapper); | 381 | // List<InspectionTask> inspectionTaskList = inspectionTaskService.list(inspectionTaskQueryWrapper); |
382 | IPage<InspectionTask> pageList = inspectionTaskService.getPage(null, inspectionTaskVO); | ||
383 | List<InspectionTask> inspectionTaskList = pageList.getRecords(); | ||
384 | |||
378 | //各状态的数量 | 385 | //各状态的数量 |
379 | Map<String, List<InspectionTask>> taskStateMap = new HashMap<>(); | 386 | Map<String, List<InspectionTask>> taskStateMap = new HashMap<>(); |
380 | List<InspectionTask> inspectionTasks; | 387 | List<InspectionTask> inspectionTasks; |
... | @@ -393,13 +400,13 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService | ... | @@ -393,13 +400,13 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService |
393 | //未检任务 | 400 | //未检任务 |
394 | List<InspectionTask> notCheckedInspectionTaskList = taskStateMap.get("3") == null ? new ArrayList<>() : taskStateMap.get("3"); | 401 | List<InspectionTask> notCheckedInspectionTaskList = taskStateMap.get("3") == null ? new ArrayList<>() : taskStateMap.get("3"); |
395 | //进行中任务 | 402 | //进行中任务 |
396 | List<InspectionTask> inProgressInspectionTaskList = taskStateMap.get("1") == null ? new ArrayList<>() : taskStateMap.get("1"); | 403 | // List<InspectionTask> inProgressInspectionTaskList = taskStateMap.get("1") == null ? new ArrayList<>() : taskStateMap.get("1"); |
397 | //已检任务数 | 404 | //已检任务数 |
398 | int checkedInspectionTaskCount = checkedInspectionTaskList.size(); | 405 | int checkedInspectionTaskCount = checkedInspectionTaskList.size(); |
399 | //未检任务数 | 406 | //未检任务数 |
400 | int notCheckedInspectionTaskCount = notCheckedInspectionTaskList.size(); | 407 | int notCheckedInspectionTaskCount = notCheckedInspectionTaskList.size(); |
401 | //进行中任务数 | 408 | //进行中任务数 |
402 | int inProgressInspectionTaskCount = inProgressInspectionTaskList.size(); | 409 | // int inProgressInspectionTaskCount = inProgressInspectionTaskList.size(); |
403 | //已检任务ID集合 | 410 | //已检任务ID集合 |
404 | List<String> checkedInspectionTaskIdList = checkedInspectionTaskList.stream().map(InspectionTask::getId).collect(Collectors.toList()); | 411 | List<String> checkedInspectionTaskIdList = checkedInspectionTaskList.stream().map(InspectionTask::getId).collect(Collectors.toList()); |
405 | if (checkedInspectionTaskIdList.size() > 0) { | 412 | if (checkedInspectionTaskIdList.size() > 0) { |
... | @@ -442,12 +449,12 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService | ... | @@ -442,12 +449,12 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService |
442 | processInstanceStateMap.put(state, tempProcessInstanceIdList); | 449 | processInstanceStateMap.put(state, tempProcessInstanceIdList); |
443 | } | 450 | } |
444 | //异常项数量(问题上报) | 451 | //异常项数量(问题上报) |
445 | Integer abnormalItemsCount = problemReportPlanList.size(); | 452 | // Integer abnormalItemsCount = problemReportPlanList.size(); |
446 | //已处理异常项数量(问题上报) | 453 | //已处理异常项数量(问题上报) |
447 | Integer processedAbnormalItemsCount = 0; | 454 | // Integer processedAbnormalItemsCount = 0; |
448 | if (processInstanceStateMap != null && processInstanceStateMap.get(FlowEngineConstant.STATUS_FINISHED) != null) { | 455 | // if (processInstanceStateMap != null && processInstanceStateMap.get(FlowEngineConstant.STATUS_FINISHED) != null) { |
449 | processedAbnormalItemsCount = processInstanceStateMap.get(FlowEngineConstant.STATUS_FINISHED).size(); | 456 | // processedAbnormalItemsCount = processInstanceStateMap.get(FlowEngineConstant.STATUS_FINISHED).size(); |
450 | } | 457 | // } |
451 | //完成率 | 458 | //完成率 |
452 | String completionRate = "0"; | 459 | String completionRate = "0"; |
453 | if (totalInspectionTaskCount != 0) { | 460 | if (totalInspectionTaskCount != 0) { |
... | @@ -464,14 +471,14 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService | ... | @@ -464,14 +471,14 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService |
464 | abnormalRate = numberFormat.format(abnormalInspectionTaskCount / (double) checkedInspectionTaskCount * 100); | 471 | abnormalRate = numberFormat.format(abnormalInspectionTaskCount / (double) checkedInspectionTaskCount * 100); |
465 | } | 472 | } |
466 | //异常项处理率 | 473 | //异常项处理率 |
467 | String processedAbnormalRate = "0"; | 474 | // String processedAbnormalRate = "0"; |
468 | if (abnormalItemsCount != 0) { | 475 | // if (abnormalItemsCount != 0) { |
469 | processedAbnormalRate = numberFormat.format(processedAbnormalItemsCount / (double)abnormalItemsCount * 100); | 476 | // processedAbnormalRate = numberFormat.format(processedAbnormalItemsCount / (double)abnormalItemsCount * 100); |
470 | } | 477 | // } |
471 | inspectionTaskIndicatorsVO.setCompletionRate(completionRate); | 478 | inspectionTaskIndicatorsVO.setCompletionRate(completionRate); |
472 | inspectionTaskIndicatorsVO.setUnCompletionRate(unCompletionRate); | 479 | inspectionTaskIndicatorsVO.setUnCompletionRate(unCompletionRate); |
473 | inspectionTaskIndicatorsVO.setAbnormalRate(abnormalRate); | 480 | inspectionTaskIndicatorsVO.setAbnormalRate(abnormalRate); |
474 | inspectionTaskIndicatorsVO.setProcessedAbnormalRate(processedAbnormalRate); | 481 | // inspectionTaskIndicatorsVO.setProcessedAbnormalRate(processedAbnormalRate); |
475 | } | 482 | } |
476 | return inspectionTaskIndicatorsVO; | 483 | return inspectionTaskIndicatorsVO; |
477 | } | 484 | } |
... | @@ -940,7 +947,7 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService | ... | @@ -940,7 +947,7 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService |
940 | } | 947 | } |
941 | inspectionAbnormalItemsTrendVO.setInspectionTaskDate(date); | 948 | inspectionAbnormalItemsTrendVO.setInspectionTaskDate(date); |
942 | if(totalCheckeItemsCount - checkedItemsCount < 0){ | 949 | if(totalCheckeItemsCount - checkedItemsCount < 0){ |
943 | inspectionAbnormalItemsTrendVO.setNotCheckedItemsCount(0); | 950 | inspectionAbnormalItemsTrendVO.setNotCheckedItemsCount(checkedItemsCount - totalCheckeItemsCount); |
944 | }else{ | 951 | }else{ |
945 | inspectionAbnormalItemsTrendVO.setNotCheckedItemsCount(totalCheckeItemsCount - checkedItemsCount); | 952 | inspectionAbnormalItemsTrendVO.setNotCheckedItemsCount(totalCheckeItemsCount - checkedItemsCount); |
946 | } | 953 | } | ... | ... |
... | @@ -49,13 +49,29 @@ public class WebSocket { | ... | @@ -49,13 +49,29 @@ public class WebSocket { |
49 | 49 | ||
50 | @OnMessage | 50 | @OnMessage |
51 | public void onMessage(String message) { | 51 | public void onMessage(String message) { |
52 | //log.info("【websocket消息】收到客户端消息:"+message); | 52 | log.info("【websocket消息】收到客户端消息:"+message); |
53 | sendAiMessage(message);//发送消息给AI | ||
53 | JSONObject obj = new JSONObject(); | 54 | JSONObject obj = new JSONObject(); |
54 | obj.put("cmd", "heartcheck");//业务类型 | 55 | obj.put("cmd", "heartcheck");//业务类型 |
55 | obj.put("msgTxt", "心跳响应");//消息内容 | 56 | obj.put("msgTxt", "心跳响应");//消息内容 |
56 | session.getAsyncRemote().sendText(obj.toJSONString()); | 57 | session.getAsyncRemote().sendText(obj.toJSONString()); |
57 | } | 58 | } |
58 | 59 | ||
60 | public void sendAiMessage(String message) { | ||
61 | //message中是否包含“AiMessage” | ||
62 | if(message.contains("AiMessage")){ | ||
63 | //以:分割message | ||
64 | String[] str = message.split(":"); | ||
65 | if(str.length>1){ | ||
66 | JSONObject obj = new JSONObject(); | ||
67 | obj.put("cmd", "ai"); | ||
68 | obj.put("type", "menu"); | ||
69 | obj.put("questen", str[1]); | ||
70 | sendOneMessage("e9ca23d68d884d4ebb19d07889727dae", obj.toJSONString()); | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
59 | // 此为广播消息 | 75 | // 此为广播消息 |
60 | public void sendAllMessage(String message) { | 76 | public void sendAllMessage(String message) { |
61 | log.info("【websocket消息】广播消息:"+message); | 77 | log.info("【websocket消息】广播消息:"+message); | ... | ... |
-
请 注册 或 登录 后发表评论