From ddb3068a51a8af8aa9a8f8c2cb9b6e9228b0c8d9 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 28 八月 2024 11:53:27 +0800
Subject: [PATCH] 同步国标设备、点播定时任务优化

---
 ycl-server/src/main/resources/mapper/zgyw/YwUnitMapper.xml |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/ycl-server/src/main/resources/mapper/zgyw/YwUnitMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/YwUnitMapper.xml
index 6af2bf0..9df4474 100644
--- a/ycl-server/src/main/resources/mapper/zgyw/YwUnitMapper.xml
+++ b/ycl-server/src/main/resources/mapper/zgyw/YwUnitMapper.xml
@@ -4,7 +4,7 @@
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ycl.platform.mapper.YwUnitMapper">
 
-    <resultMap type="YwUnit" id="YwUnitResult">
+    <resultMap type="YwUnitVo" id="YwUnitResult">
         <result property="id"    column="id"    />
         <result property="unitCode"    column="unit_code"    />
         <result property="unitName"    column="unit_name"    />
@@ -13,8 +13,6 @@
         <result property="unitAdminAccount"    column="unit_admin_account"    />
         <result property="remark"    column="remark"    />
         <result property="createTime"    column="create_time"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="deleted"    column="deleted"    />
     </resultMap>
 
     <sql id="selectYwUnitVo">
@@ -33,6 +31,20 @@
     <select id="selectYwUnitById" parameterType="Long" resultMap="YwUnitResult">
         <include refid="selectYwUnitVo"/>
         where id = #{id}
+    </select>
+
+    <select id="workList" resultType="com.ycl.platform.domain.vo.YwUnitVO">
+        SELECT
+            a.*,
+            COUNT(b.id) AS work_order_count
+        FROM
+            t_yw_unit a
+                LEFT JOIN
+            t_work_order b ON a.id = b.unit_id AND b.deleted = 0 AND b.status = 'WAIT_DISTRIBUTE'
+        WHERE
+            a.deleted = 0
+        GROUP BY
+            a.id;
     </select>
 
     <insert id="insertYwUnit" parameterType="YwUnit" useGeneratedKeys="true" keyProperty="id">
@@ -87,4 +99,26 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="getByUserId" resultMap="YwUnitResult">
+        SELECT
+             tyw.*
+        FROM
+             t_yw_unit tyw
+                 INNER JOIN t_unit_people tup ON tup.unit_id = tyw.id and tyw.deleted = 0
+                 INNER JOIN t_yw_people typ ON tup.yw_people_id = typ.id AND typ.user_id = #{userId} AND typ.deleted = 0
+    </select>
+
+    <select id="ywUnitCount" resultType="java.util.Map">
+        SELECT
+            u.unit_name AS name,
+            COUNT(tcs.id) AS num,
+            100 - SUM(score) AS score
+        FROM
+            t_contract_score tcs
+                LEFT JOIN t_yw_unit u ON tcs.unit_id = u.id
+        WHERE tcs.deleted = 0
+        GROUP BY tcs.unit_id
+        ORDER BY score DESC
+    </select>
 </mapper>

--
Gitblit v1.8.0