From 5d1d4b8516c6071a4bb69ba507f6d23eb73e8a67 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期五, 31 三月 2023 14:10:38 +0800
Subject: [PATCH] 驾驶舱接口优化

---
 ycl-platform/src/main/java/com/ycl/service/cockpitManage/ITeamConstructionService.java                 |    4 +
 ycl-platform/src/main/resources/application-dev.yml                                                    |    2 
 document/驾驶舱数据接口文档(ai物联和综合决策).docx                                                                     |    0 
 ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java |   37 +++++++++---
 ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamIndex.java                                 |   41 +++++++++++++
 ycl-platform/src/main/java/com/ycl/service/cockpitManage/impl/TeamConstructionServiceImpl.java         |    7 ++
 ycl-platform/src/main/java/com/ycl/mapper/cockpitManage/TeamConstructionMapper.java                    |    5 +
 ycl-platform/src/main/resources/mapper/cockpitManage/TeamConstructionMapper.xml                        |   49 ++++++++++++++++
 ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamConstruction.java                          |   31 +++++++---
 9 files changed, 154 insertions(+), 22 deletions(-)

diff --git "a/document/\351\251\276\351\251\266\350\210\261\346\225\260\346\215\256\346\216\245\345\217\243\346\226\207\346\241\243\357\274\210ai\347\211\251\350\201\224\345\222\214\347\273\274\345\220\210\345\206\263\347\255\226\357\274\211.docx" "b/document/\351\251\276\351\251\266\350\210\261\346\225\260\346\215\256\346\216\245\345\217\243\346\226\207\346\241\243\357\274\210ai\347\211\251\350\201\224\345\222\214\347\273\274\345\220\210\345\206\263\347\255\226\357\274\211.docx"
index d6ccb54..3732dce 100644
--- "a/document/\351\251\276\351\251\266\350\210\261\346\225\260\346\215\256\346\216\245\345\217\243\346\226\207\346\241\243\357\274\210ai\347\211\251\350\201\224\345\222\214\347\273\274\345\220\210\345\206\263\347\255\226\357\274\211.docx"
+++ "b/document/\351\251\276\351\251\266\350\210\261\346\225\260\346\215\256\346\216\245\345\217\243\346\226\207\346\241\243\357\274\210ai\347\211\251\350\201\224\345\222\214\347\273\274\345\220\210\345\206\263\347\255\226\357\274\211.docx"
Binary files differ
diff --git a/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java b/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java
index 1aea260..57471f9 100644
--- a/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java
+++ b/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java
@@ -216,18 +216,35 @@
     @GetMapping("/team_index")
     public CommonResult<List<TeamIndex>> teamIndex(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        LambdaQueryWrapper<TeamConstruction> queryWrapper = new LambdaQueryWrapper<TeamConstruction>().eq(TeamConstruction::getStatus, 1).eq(TeamConstruction::getIsDelete, 0);
-        List<TeamConstruction> list = teamConstructionService.list(queryWrapper);
-        List<TeamIndex> teamIndexList = BeanUtil.copyToList(list, TeamIndex.class);
+
+        // LambdaQueryWrapper<TeamConstruction> queryWrapper = new LambdaQueryWrapper<TeamConstruction>().eq(TeamConstruction::getStatus, 1).eq(TeamConstruction::getIsDelete, 0);
+        // List<TeamConstruction> list = teamConstructionService.list(queryWrapper);
+        // List<TeamIndex> teamIndexList = BeanUtil.copyToList(list, TeamIndex.class);
+        // teamIndexList.forEach(o -> {
+        //     o.setStepTimely(0.0);
+        //     o.setStepDelayed(0.0);
+        //     o.setStepOvertime(0.0);
+        //     o.setHandleTimely(0.0);
+        //     o.setHandleDelayed(0.0);
+        //     o.setHandleOvertime(0.0);
+        //     o.setNoHandle(0.0);
+        // });
+        List<TeamIndex> teamIndexList = teamConstructionService.teamIndex(params.getBeginTime(), params.getEndTime());
         teamIndexList.forEach(o -> {
-            o.setStepTimely(0.6);
-            o.setStepDelayed(0.3);
-            o.setStepOvertime(0.1);
-            o.setHandleTimely(0.6);
-            o.setHandleDelayed(0.2);
-            o.setHandleOvertime(0.1);
-            o.setNoHandle(0.1);
+
+            o.setAllocation(20 * ((double) o.getPunctualityCount() / (double) o.getAllCount())
+                    + 18 * ((double) o.getOverCount() / (double) o.getAllCount())
+                    + 15 * ((double) o.getNoHandleCount() / (double) o.getAllCount()));
+            o.setHandle(20 * ((double) o.getPunctualityCount() / (double) o.getAllCount())
+                    + 5 * ((double) o.getOverCount() / (double) o.getAllCount())
+                    - 2 * ((double) o.getNoHandleCount() / (double) o.getAllCount()));
+
+            o.setOnline(0.0);
+            o.setDuration(0.0);
+            o.setDistance(0.0);
         });
         return CommonResult.success(teamIndexList);
     }
 }
+
+
diff --git a/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamConstruction.java b/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamConstruction.java
index 833bfca..40ca494 100644
--- a/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamConstruction.java
+++ b/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamConstruction.java
@@ -56,73 +56,79 @@
     private Integer upUndergraduatePeopleNumber;
 
     /**
-     * 鏈瀛﹀巻鍙婁互涓婁汉鏁�
+     * 鎸佽瘉浜烘暟
      */
     @TableField("holder_number")
     @ExcelProperty(value = "鎸佽瘉浜烘暟", index = 3)
     private Integer holderNumber;
 
     /**
+     * 鎵ф硶浜哄憳鎬绘暟
+     */
+    @TableField("law_enforcement_officer")
+    @ExcelProperty(value = "鎵ф硶浜哄憳鎬绘暟", index = 4)
+    private Integer lawEnforcementOfficer;
+    /**
      * 45宀佷互涓嬩汉鏁�
      */
     @TableField("under_forty_five_people_number")
-    @ExcelProperty(value = "45宀佷互涓嬩汉鏁�", index = 4)
+    @ExcelProperty(value = "45宀佷互涓嬩汉鏁�", index = 5)
     private Integer underFortyFivePeopleNumber;
 
     /**
      * 娉曞緥鑱屼笟璧勬牸璇佷汉鏁�
      */
     @TableField("legal_professional_qualification_certificate_people_number")
-    @ExcelProperty(value = "娉曞緥鑱屼笟璧勬牸璇佷汉鏁�", index = 5)
+    @ExcelProperty(value = "娉曞緥鑱屼笟璧勬牸璇佷汉鏁�", index = 6)
     private Integer legalProfessionalQualificationCertificatePeopleNumber;
 
     /**
      * 閫氭姤鏁伴噺
      */
     @TableField("report_number")
-    @ExcelProperty(value = "閫氭姤鏁伴噺", index = 6)
+    @ExcelProperty(value = "閫氭姤鏁伴噺", index = 7)
     private Integer reportNumber;
 
     /**
      * 杩濈邯琛屼负鏁伴噺
      */
     @TableField("disciplinary_offence_number")
-    @ExcelProperty(value = "杩濈邯琛屼负鏁伴噺", index = 7)
+    @ExcelProperty(value = "杩濈邯琛屼负鏁伴噺", index = 8)
     private Integer disciplinaryOffenceNumber;
 
     /**
      * 杩濇硶鐘姜琛屼负鏁伴噺
      */
     @TableField("criminal_offense_number")
-    @ExcelProperty(value = "杩濇硶鐘姜琛屼负鏁伴噺", index = 8)
+    @ExcelProperty(value = "杩濇硶鐘姜琛屼负鏁伴噺", index = 9)
     private Integer criminalOffenseNumber;
 
     /**
      * 姣忔湀妗堜欢鏁伴噺
      */
     @TableField("month_case_number")
-    @ExcelProperty(value = "姣忔湀妗堜欢鏁伴噺", index = 9)
+    @ExcelProperty(value = "姣忔湀妗堜欢鏁伴噺", index = 10)
     private Integer monthCaseNumber;
 
     /**
      * 姣忔湀妗堜欢鏁伴噺
      */
     @TableField("month_index_number")
-    @ExcelProperty(value = "姣忔湀鎸囨爣鏁�", index = 10)
+    @ExcelProperty(value = "姣忔湀鎸囨爣鏁�", index = 11)
     private Integer monthIndexNumber;
 
     /**
      * 鏈秴鏃舵浠舵暟閲�
      */
     @TableField("no_timeout_case_number")
-    @ExcelProperty(value = "鏈秴鏃舵浠舵暟閲�", index = 11)
+    @ExcelProperty(value = "鏈秴鏃舵浠舵暟閲�", index = 12)
     private Integer noTimeoutCaseNumber;
 
     /**
      * 澶嶈瘔鎴栬瘔璁兼暟閲�
      */
     @TableField("review_or_lawsuit_number")
-    @ExcelProperty(value = "澶嶈瘔鎴栬瘔璁兼暟閲�", index = 12)
+    @ExcelProperty(value = "澶嶈瘔鎴栬瘔璁兼暟閲�", index = 13)
     private Integer reviewOrLawsuitNumber;
 
     /**
@@ -152,4 +158,9 @@
     @TableField("update_time")
     @ExcelIgnore
     private LocalDateTime updateTime;
+
+
+    @TableField("region_id")
+    @ExcelIgnore
+    private Long regionId;
 }
\ No newline at end of file
diff --git a/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamIndex.java b/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamIndex.java
index 0ea8399..0f3b569 100644
--- a/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamIndex.java
+++ b/ycl-platform/src/main/java/com/ycl/entity/cockpitManage/TeamIndex.java
@@ -22,7 +22,6 @@
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
-@TableName("ums_team_construction")
 public class TeamIndex extends TeamConstruction implements Serializable {
 
     private Double stepTimely;
@@ -33,4 +32,44 @@
     private Double handleOvertime;
     private Double noHandle;
 
+    /**
+     * 鎺ユ敹鍒板眬淇℃伅鎸囨尌涓績涓嬫淳浠诲姟锛屽彈鐞嗗苟鍒嗘淳鏃舵晥
+     */
+    private Double allocation;
+
+    /**
+     * 澶勭疆浜哄憳鎺ュ彈鍒嗘淳鍚庣殑澶勭悊閫熷害
+     */
+    private Double handle;
+
+    /**
+     * 涓槦闃熷憳鎵ф硶璁板綍浠瘡鏃ュ湪绾跨巼
+     */
+    private Double online;
+
+    /**
+     * 涓槦闃熷憳鎵ф硶璁板綍浠瘡鏃ュ钩鍧囨椂闀�
+     */
+    private Double duration;
+
+    /**
+     * 涓槦闃熷憳鎵ф硶璁板綍浠瘡鏃ュ钩鍧囧綊闆嗚窛绂�
+     */
+    private Double distance;
+    /**
+     * 妗堜欢鎬绘暟
+     */
+    private Integer allCount;
+    /**
+     * 鍑嗘椂妗堜欢
+     */
+    private Integer punctualityCount;
+    /**
+     * 瓒呮椂妗堜欢
+     */
+    private Integer overCount;
+    /**
+     * 鏈鐞嗘浠�
+     */
+    private Integer noHandleCount;
 }
\ No newline at end of file
diff --git a/ycl-platform/src/main/java/com/ycl/mapper/cockpitManage/TeamConstructionMapper.java b/ycl-platform/src/main/java/com/ycl/mapper/cockpitManage/TeamConstructionMapper.java
index 16adec8..1edc6a3 100644
--- a/ycl-platform/src/main/java/com/ycl/mapper/cockpitManage/TeamConstructionMapper.java
+++ b/ycl-platform/src/main/java/com/ycl/mapper/cockpitManage/TeamConstructionMapper.java
@@ -2,6 +2,10 @@
 
 import com.ycl.entity.cockpitManage.TeamConstruction;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ycl.entity.cockpitManage.TeamIndex;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,5 @@
  */
 public interface TeamConstructionMapper extends BaseMapper<TeamConstruction> {
 
+    List<TeamIndex> teamIndex(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
 }
diff --git a/ycl-platform/src/main/java/com/ycl/service/cockpitManage/ITeamConstructionService.java b/ycl-platform/src/main/java/com/ycl/service/cockpitManage/ITeamConstructionService.java
index e6b671c..60b9fee 100644
--- a/ycl-platform/src/main/java/com/ycl/service/cockpitManage/ITeamConstructionService.java
+++ b/ycl-platform/src/main/java/com/ycl/service/cockpitManage/ITeamConstructionService.java
@@ -2,6 +2,9 @@
 
 import com.ycl.entity.cockpitManage.TeamConstruction;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ycl.entity.cockpitManage.TeamIndex;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,5 @@
  */
 public interface ITeamConstructionService extends IService<TeamConstruction> {
 
+    List<TeamIndex> teamIndex(String beginTime, String endTime);
 }
diff --git a/ycl-platform/src/main/java/com/ycl/service/cockpitManage/impl/TeamConstructionServiceImpl.java b/ycl-platform/src/main/java/com/ycl/service/cockpitManage/impl/TeamConstructionServiceImpl.java
index b940f3c..bfcf063 100644
--- a/ycl-platform/src/main/java/com/ycl/service/cockpitManage/impl/TeamConstructionServiceImpl.java
+++ b/ycl-platform/src/main/java/com/ycl/service/cockpitManage/impl/TeamConstructionServiceImpl.java
@@ -1,10 +1,13 @@
 package com.ycl.service.cockpitManage.impl;
 
 import com.ycl.entity.cockpitManage.TeamConstruction;
+import com.ycl.entity.cockpitManage.TeamIndex;
 import com.ycl.mapper.cockpitManage.TeamConstructionMapper;
 import com.ycl.service.cockpitManage.ITeamConstructionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * <p>
@@ -17,4 +20,8 @@
 @Service
 public class TeamConstructionServiceImpl extends ServiceImpl<TeamConstructionMapper, TeamConstruction> implements ITeamConstructionService {
 
+    @Override
+    public List<TeamIndex> teamIndex(String beginTime, String endTime) {
+        return baseMapper.teamIndex(beginTime, endTime);
+    }
 }
diff --git a/ycl-platform/src/main/resources/application-dev.yml b/ycl-platform/src/main/resources/application-dev.yml
index 1a441d0..7f25105 100644
--- a/ycl-platform/src/main/resources/application-dev.yml
+++ b/ycl-platform/src/main/resources/application-dev.yml
@@ -35,7 +35,7 @@
         timeout: 0
 
   datasource:
-    url: jdbc:mysql://42.193.1.25:3306/sccg0318?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false
+    url: jdbc:mysql://42.193.1.25:3306/sccg?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false
     username: root
     password: 321$YcYl@1970!
     type: com.alibaba.druid.pool.DruidDataSource
diff --git a/ycl-platform/src/main/resources/mapper/cockpitManage/TeamConstructionMapper.xml b/ycl-platform/src/main/resources/mapper/cockpitManage/TeamConstructionMapper.xml
new file mode 100644
index 0000000..b63a45a
--- /dev/null
+++ b/ycl-platform/src/main/resources/mapper/cockpitManage/TeamConstructionMapper.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ycl.mapper.cockpitManage.TeamConstructionMapper">
+
+    <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+    <resultMap id="BaseResultMap" type="com.ycl.entity.cockpitManage.TeamConstruction">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="people_number" property="peopleNumber"/>
+        <result column="up_undergraduate_people_number" property="upUndergraduatePeopleNumber"/>
+        <result column="under_forty_five_people_number" property="underFortyFivePeopleNumber"/>
+        <result column="legal_professional_qualification_certificate_people_number"
+                property="legalProfessionalQualificationCertificatePeopleNumber"/>
+        <result column="report_number" property="reportNumber"/>
+        <result column="disciplinary_offence_number" property="disciplinaryOffenceNumber"/>
+        <result column="criminal_offense_number" property="criminalOffenseNumber"/>
+        <result column="month_case_number" property="monthCaseNumber"/>
+        <result column="month_index_number" property="monthIndexNumber"/>
+        <result column="no_timeout_case_number" property="noTimeoutCaseNumber"/>
+        <result column="review_or_lawsuit_number" property="reviewOrLawsuitNumber"/>
+        <result column="holder_number" property="holderNumber"/>
+        <result column="law_enforcement_officer" property="lawEnforcementOfficer"/>
+    </resultMap>
+    <resultMap id="VOMap" extends="BaseResultMap" type="com.ycl.entity.cockpitManage.TeamIndex">
+
+        <result column="all_count" property="allCount"/>
+        <result column="no_handle_count" property="noHandleCount"/>
+        <result column="over_count" property="overCount"/>
+        <result column="punctuality_count" property="punctualityCount"/>
+    </resultMap>
+    <select id="teamIndex" resultMap="VOMap">
+        SELECT tc.id,tc.name,  tc.people_number,  tc.up_undergraduate_people_number,  tc.under_forty_five_people_number,  tc.legal_professional_qualification_certificate_people_number,  tc.report_number,  tc.disciplinary_offence_number,tc.criminal_offense_number,  tc.month_case_number,  tc.month_index_number,  tc.no_timeout_case_number,tc.review_or_lawsuit_number,  tc.holder_number,  tc.law_enforcement_officer ,
+        count(bc.id) all_count,
+        sum(case WHEN (dr.state =1 and (dr.limit_time > dr.end_time or dr.limit_time is null) ) THEN 1 ELSE 0 END) punctuality_count,
+        sum(case WHEN (dr.state =1 and dr.limit_time &lt; dr.end_time and dr.end_time is not null ) THEN 1 ELSE 0 END) over_count,
+        sum(case WHEN (dr.state =1 and dr.limit_time &lt; dr.end_time and dr.end_time is null ) THEN 1 ELSE 0 END) no_handle_count
+        from ums_team_construction tc
+        LEFT JOIN ums_base_case bc on tc.region_id = bc.street_id
+        <if test="beginTime!=null and beginTime!=''">
+            and bc.alarm_time between #{beginTime} and #{endTime}
+        </if>
+        LEFT JOIN ums_dispose_record dr on bc.id = dr.base_case_id
+
+        GROUP BY tc.id,tc.name,  tc.people_number,  tc.up_undergraduate_people_number,  tc.under_forty_five_people_number,  tc.legal_professional_qualification_certificate_people_number,  tc.report_number,  tc.disciplinary_offence_number,tc.criminal_offense_number,  tc.month_case_number,  tc.month_index_number,  tc.no_timeout_case_number,tc.review_or_lawsuit_number,  tc.holder_number,  tc.law_enforcement_officer
+
+    </select>
+
+
+</mapper>

--
Gitblit v1.8.0