Bladeren bron

增加指挥中心-事件类型统计

Memory_LG 2 maanden geleden
bovenliggende
commit
9b97e70d7f

+ 9 - 1
src/main/java/com/sooka/sponest/event/eventProcess/controller/EventProcessController.java

@@ -25,7 +25,7 @@ import static com.sooka.sponest.event.utils.eventConstants.EventConstants.*;
  * @since 2025/07/03
  */
 @RestController
-@RequestMapping("eventProcess")
+@RequestMapping("/eventProcess")
 public class EventProcessController extends BaseController {
 
     @Resource
@@ -251,4 +251,12 @@ public class EventProcessController extends BaseController {
         return AjaxResult.success("事件日志新增成功");
     }
 
+    /**
+     * 指挥中心-事件类型统计
+     */
+    @GetMapping("/getCountFromMenuIdAndEventType")
+    public AjaxResult getCountFromMenuIdAndEventType(EventInfo eventInfo){
+        return eventProcessService.getCountFromMenuIdAndEventType(eventInfo);
+    }
+
 }

+ 0 - 5
src/main/java/com/sooka/sponest/event/eventProcess/domain/EventInfo.java

@@ -133,11 +133,6 @@ public class EventInfo extends BaseBusinessEntity {
      */
     private List<Long> deptIdList = new ArrayList<>();
 
-    /**
-     * 确认火情事件时, 传递事件类型的key
-     */
-    private String newEventType;
-
     private String deptId;
 
 

+ 3 - 0
src/main/java/com/sooka/sponest/event/eventProcess/mapper/EventProcessMapper.java

@@ -8,6 +8,7 @@ import com.sooka.sponest.event.eventProcess.domain.BO.EventInfoBO;
 import com.sooka.sponest.event.eventProcess.domain.EventInfo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface EventProcessMapper {
 
@@ -42,4 +43,6 @@ public interface EventProcessMapper {
     void deleteEventProcess(EventInfo eventInfo);
 
     List<EventInfoBO> selectProcessAttachFromUnconfirmed();
+
+    List<Map<String, Object>> getCountFromMenuIdAndEventType(EventInfo eventInfo);
 }

+ 2 - 0
src/main/java/com/sooka/sponest/event/eventProcess/service/EventProcessService.java

@@ -76,4 +76,6 @@ public interface EventProcessService {
     List<EventInfoBO> selectProcessAttachFromUnconfirmed();
 
     AjaxResult insertProcessEvent(EventProcess eventInfo);
+
+    AjaxResult getCountFromMenuIdAndEventType(EventInfo eventInfo);
 }

+ 47 - 5
src/main/java/com/sooka/sponest/event/eventProcess/service/impl/EventProcessServiceImpl.java

@@ -388,11 +388,6 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 //设置事件状态为确认事件
                 eventInfoBO.setEventStatus(EVENT_STATUS_2);
 
-                //如果确认的是火情事件, 需要设置事件类型;
-                if (StringUtils.isNotEmpty(eventInfo.getNewEventType())) {
-                    eventInfoBO.setEventType(eventInfo.getNewEventType());
-                }
-
                 //将事件主体移动到确认表
                 eventInfoBO.setTableName("event_process");
                 eventProcessMapper.insertEventInfo(eventInfoBO);
@@ -517,6 +512,7 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
 
                 //更新主表状态
                 eventInfo.setEventStatus(EVENT_STATUS_3);
+
                 eventProcessMapper.updateEventProcess(eventInfo);
 
             } catch (Exception e) {
@@ -772,6 +768,52 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
 
     }
 
+    @Override
+    @DataScopeMutiDept(deptAlias = "d")
+    public AjaxResult getCountFromMenuIdAndEventType(EventInfo eventInfo) {
+        setSookaDataBase(eventInfo);
+        // 查询每个菜单配置的事件类型数量
+        List<Map<String, Object>> eventTypeCount = eventProcessMapper.getCountFromMenuIdAndEventType(eventInfo);
+
+        Set<String> menuIdSet = new HashSet<>();
+        eventTypeCount.forEach(map->{
+            menuIdSet.add(MapUtils.getString(map, "menuId"));
+        });
+
+        //格式化处理
+        List<Map<String, Object>> resultData = new ArrayList<>();
+        menuIdSet.forEach(menuId->{
+            //菜单总数
+            Long menuCount = 0L;
+            //子集统计
+            List<Map<String, Object>> childrenData = new ArrayList<>();
+            StringBuilder menuName = new StringBuilder();
+
+            // 使用迭代器遍历 eventTypeCount
+            Iterator<Map<String, Object>> iterator = eventTypeCount.iterator();
+            while (iterator.hasNext()) {
+                Map<String, Object> map = iterator.next();
+                if (menuId.equals(MapUtils.getString(map, "menuId"))) {
+                    if(menuName.length() <= 0){
+                        menuName.append(MapUtils.getString(map, "menuName"));
+                    }
+                    Long typeSum = MapUtils.getLong(map, "typeSum");
+                    menuCount += typeSum;
+                    childrenData.add(map);
+                    // 移除当前元素
+                    iterator.remove();
+                }
+            }
+
+            HashMap<String, Object> menuMap = new HashMap<>();
+            menuMap.put("menuName", menuName.toString());
+            menuMap.put("typeSum", menuCount);
+            menuMap.put("children", childrenData);
+            resultData.add(menuMap);
+        });
+        return AjaxResult.success(resultData);
+    }
+
     /**
      * 列表设置附件路径
      *

+ 26 - 0
src/main/resources/mapper/event/eventProcess/EventProcessMapper.xml

@@ -552,6 +552,32 @@
     <select id="selectProcessAttachFromUnconfirmed" resultMap="EventInfoUnconfirmedResult">
         SELECT event_id FROM event_compensation
     </select>
+
+    <select id="getCountFromMenuIdAndEventType" parameterType="EventInfo" resultType="map">
+        SELECT a.menu_id menuId, a.menu_name menuName, a.event_type eventType, et.event_type_name AS eventTypeName, a.typeSum
+        FROM event_type et
+        LEFT JOIN (
+            SELECT sm.menu_id, smv.remark AS menu_name, sm.event_type_xl AS event_type, COALESCE ( cnt.count, 0 ) AS typeSum
+            FROM (
+                SELECT DISTINCT menu_id, event_type_xl FROM onest_system.sys_menu_event_type
+                UNION
+                SELECT DISTINCT menu_id, event_type FROM onest_system.sys_menu_event_type WHERE event_type = 1
+            ) sm
+            LEFT JOIN (
+                SELECT event_type, COUNT( 1 ) AS count
+                FROM event_process
+                GROUP BY event_type
+                UNION
+                SELECT event_type, COUNT( 1 )
+                FROM event_unconfirmed
+                GROUP BY event_type
+            ) cnt ON sm.event_type_xl = cnt.event_type
+            LEFT JOIN ${database_system}.sys_menu_visu smv ON sm.menu_id = smv.menu_id
+            WHERE smv.STATUS = 0 AND menu_type = 'ZC'
+        ) a ON a.event_type = et.id
+        WHERE menu_id IS NOT NULL
+        ORDER BY a.menu_id, a.event_type
+    </select>
     <!-- **************************************** 业务块 结束 *********************************************** -->