From 48de12e1635b99d593048398af45d186c8f39234 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期二, 29 七月 2025 11:10:42 +0800
Subject: [PATCH] 危化品简化版修改

---
 hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 106 insertions(+), 10 deletions(-)

diff --git a/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml b/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml
index 1f28eb0..eb1576e 100644
--- a/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml
@@ -17,6 +17,7 @@
         <result property="updateTime"     column="update_time"     />
         <result property="remark"         column="remark"          />
         <result property="warehouseName"         column="warehouse_name"          />
+        <result property="cupboardName"         column="cupboard_name"          />
         <association property="hazmatBasic" javaType="com.gkhy.hazmat.system.domain.HzHazmatBasic" resultMap="hazmatBasicResult" />
     </resultMap>
 
@@ -38,10 +39,12 @@
     <sql id="selectHazmatVo">
         select a.id, a.basic_id, a.warehouse_id, a.code,a.remaining, a.state,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
                b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.hazmat_type as basic_hazmat_type,b.hazmat_character as basic_hazmat_character,
-               b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,c.name as warehouse_name
+               b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,
+               b.product_sn,b.min_package as basic_min_package,c.name as warehouse_name,d.cupboard_name as cupboard_name
         from hz_hazmat a
         left join hz_hazmat_basic b on b.id=a.basic_id
         left join hz_warehouse c on c.id=a.warehouse_id
+        left join hz_warehouse_cupboard d on d.id=a.cupboard_id
     </sql>
 
     <update id="deleteHazmatById" parameterType="com.gkhy.hazmat.system.domain.HzHazmat">
@@ -73,7 +76,7 @@
     </select>
 
     <select id="selectHazmatGroupWareHouse" resultType="com.gkhy.hazmat.system.domain.vo.HzHazmatWarehouseVO">
-        select a.basic_id,a.warehouse_id,
+        select a.basic_id,a.warehouse_id,a.cupboard_id,
         (select count(1) from hz_hazmat where state=0 and basic_id=a.basic_id and warehouse_id=a.warehouse_id) as stock,
         (select count(1) from hz_hazmat where state=1 and basic_id=a.basic_id and warehouse_id=a.warehouse_id) as miss_stock
         from hz_hazmat a
@@ -97,9 +100,9 @@
             <if test="params.productSn != null and params.productSn != ''">
                 AND b.product_sn =#{params.productSn}
             </if>
-            and a.del_flag=0
+            and a.del_flag=0 and b.del_flag = 0
         </where>
-        group by a.basic_id,a.warehouse_id
+        group by a.basic_id,a.warehouse_id, a.cupboard_id
     </select>
 
 
@@ -107,7 +110,16 @@
     <select id="selectHazmatCountOfWarehouse" resultType="integer">
         select count(a.id) from hz_hazmat a
         inner join hz_hazmat_basic b on b.id=basic_id
-        where a.warehouse_id=#{warehouseId} and b.id=#{basicId} and a.company_id=#{companyId} and b.company_id=#{companyId} and a.del_flag=0 and (a.state=0 or a.state=1)
+        where a.warehouse_id=#{warehouseId} and b.id=#{basicId} and a.company_id=#{companyId} and b.company_id=#{companyId}
+          and a.del_flag=0 and (a.state=0 or a.state=1) and a.cupboard_id = #{cupboardId}
+    </select>
+
+
+    <select id="selectHazmatWarehouseCheck" resultType="com.gkhy.hazmat.system.domain.vo.TabooDisVo">
+        select DISTINCT b.peculiarity_number spNum ,b.id  from hz_hazmat a
+                                    inner join hz_hazmat_basic b on b.id=basic_id
+        where a.warehouse_id=#{warehouseId}  and a.company_id=#{companyId} and b.company_id=#{companyId}
+          and a.del_flag=0 and (a.state=0 or a.state=1) and a.cupboard_id = #{cupboardId}
     </select>
 
     <select id="selectHazmatByCode" resultMap="HzHazmatResult">
@@ -137,13 +149,28 @@
     </select>
 
     <select id="useCountStatic" resultType="com.gkhy.hazmat.system.domain.vo.HzHazmatUseVO">
-        select count(*) as count,basic_id from hz_hazmat
-        where create_time &gt;= #{startTime} and create_time &lt;= #{endTime} and state =3
+        SELECT
+        count(*) AS count,
+        hh2.basic_id
+        FROM
+        hz_hazmat hh2
+        LEFT JOIN hz_hazmat_flow hhf2 on hh2.id = hhf2.hazmat_id
+        LEFT JOIN sys_user sy on hhf2.create_id =  sy.id
+        LEFT JOIN sys_dept sd on sy.depart_id = sd.id
+        where hh2.create_time &gt;= #{startTime} and hh2.create_time &lt;= #{endTime} and hh2.state =3 and hhf2.state = 4
         <if test="companyId!=null">
-            and company_id=#{companyId}
+            and hh2.company_id=#{companyId}
         </if>
-        group by basic_id
-        order by count desc
+        <if test="userId!=null">
+            and hh2f.create_id = #{userId}
+        </if>
+        <if test="departId!=null">
+            and sd.id = #{departId}
+        </if>
+        GROUP BY
+        hh2.basic_id
+        ORDER BY
+        count DESC
     </select>
 
 
@@ -157,4 +184,73 @@
         order by a.id
         limit #{startIndex},#{pageSize}
     </select>
+    <select id="useCountHourlyStatic" resultType="com.gkhy.hazmat.system.domain.vo.HzEntryRecordVO">
+        SELECT
+        DATE_FORMAT(create_time, '%H') AS hour,
+        COUNT(*) AS count
+        FROM hz_hazmat
+        WHERE create_time &gt;= #{startDate}
+        AND create_time &lt; #{endDate}
+        AND state IN (2, 3)
+        <if test="companyId != null">
+            AND company_id = #{companyId}
+        </if>
+        GROUP BY hour
+        ORDER BY hour ASC
+    </select>
+
+
+
+    <select id="companyMessage" resultType="com.gkhy.hazmat.system.domain.vo.HzCompanyMessage">
+        SELECT
+            sc.id,
+            sc.name as company_name,
+            scf.longitude,
+            scf.latitude,
+            COALESCE(hw.warehouse_count, 0) AS warehouse_count,
+            COALESCE(htw.warning_count, 0) AS warning_count,
+            htw.latest_warning_time
+        FROM sys_company sc
+                 LEFT JOIN (
+            SELECT company_id, COUNT(*) AS warehouse_count
+            FROM hz_warehouse
+            WHERE del_flag = 0
+            GROUP BY company_id
+        ) hw ON sc.id = hw.company_id
+                 LEFT JOIN (
+            SELECT
+                company_id,
+                COUNT(*) AS warning_count,
+                MAX(create_time) AS latest_warning_time
+            FROM hz_taboo_warning
+            WHERE del_flag = 0
+            GROUP BY company_id
+        ) htw ON sc.id = htw.company_id
+        LEFT JOIN sys_config scf on sc.id = scf.company_id
+        <where>
+            sc.del_flag = 0
+            <if test="type!=null">
+                and sc.type = #{type}
+            </if>
+        </where>
+        ORDER BY htw.latest_warning_time DESC;
+    </select>
+    <select id="countTotal" resultType="java.lang.Integer">
+        SELECT
+        COUNT(*) AS total_count
+        FROM hz_hazmat
+        WHERE state IN (2, 3)
+        <if test="companyId != null">
+            AND company_id = #{companyId}
+        </if>
+    </select>
+    <!--    SELECT COUNT(*) AS count, DATE_FORMAT(create_time, '%H') AS hour-->
+<!--    FROM hz_hazmat-->
+<!--    WHERE create_time &gt;= #{startDate} AND create_time &lt;  #{endDate}-->
+<!--    AND state IN (2, 3)-->
+<!--    <if test="companyId != null">-->
+<!--        AND company_id = #{companyId}-->
+<!--    </if>-->
+<!--    GROUP BY hour-->
+<!--    ORDER BY hour ASC-->
 </mapper>

--
Gitblit v1.9.2