From e2c14ffb0a6237bb5c397f5d0baaa4fa70cfe3b0 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期一, 11 九月 2023 11:20:01 +0800
Subject: [PATCH] MOM系统-9-11

---
 inspect-server/src/main/resources/mapper/RawInspectMapper.xml |  134 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 106 insertions(+), 28 deletions(-)

diff --git a/inspect-server/src/main/resources/mapper/RawInspectMapper.xml b/inspect-server/src/main/resources/mapper/RawInspectMapper.xml
index f8bfd64..985266e 100644
--- a/inspect-server/src/main/resources/mapper/RawInspectMapper.xml
+++ b/inspect-server/src/main/resources/mapper/RawInspectMapper.xml
@@ -3,39 +3,117 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yuanchu.mom.mapper.RawInspectMapper">
+    <select id="selCountRaw" resultType="java.lang.Integer">
+        select count(id)
+        from mom_ocean.raw_inspect
+        where state=1
+        and ins_state=1
+        and judge_state=#{judgeState}
+        <if test="begin != null and begin!=''">
+            and raw_inspect.create_time &gt;= #{begin}
+        </if>
+        <if test="end != null and end!=''">
+            and raw_inspect.create_time &lt;= #{end}
+        </if>
+    </select>
+    <select id="seAllCount" resultType="java.lang.Long">
+        select count(id)
+        from mom_ocean.raw_inspect
+        where state=1
+        <if test="begin != null and begin!=''">
+            and raw_inspect.create_time &gt;= #{begin}
+        </if>
+        <if test="end != null and end!=''">
+            and raw_inspect.create_time &lt;= #{end}
+        </if>
+    </select>
 
-    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.RawInspect">
-        <id property="id" column="id" jdbcType="INTEGER"/>
-        <result property="code" column="code" jdbcType="VARCHAR"/>
-        <result property="name" column="name" jdbcType="VARCHAR"/>
-        <result property="specifications" column="specifications" jdbcType="VARCHAR"/>
-        <result property="unit" column="unit" jdbcType="VARCHAR"/>
-        <result property="number" column="number" jdbcType="INTEGER"/>
-        <result property="insState" column="ins_state" jdbcType="INTEGER"/>
-        <result property="judgeState" column="judge_state" jdbcType="INTEGER"/>
-        <result property="insTime" column="ins_time" jdbcType="DATE"/>
-        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
-        <result property="state" column="state" jdbcType="INTEGER"/>
-        <result property="createTime" column="create_time" jdbcType="DATE"/>
-        <result property="updateTime" column="update_time" jdbcType="DATE"/>
-        <result property="formTime" column="form_time" jdbcType="DATE"/>
-    </resultMap>
-    <select id="selectRawInspectsByLimit" resultType="com.yuanchu.mom.pojo.RawInspect">
-        select id, code, name, specifications, unit, number, ins_state, judge_state, ins_time, user_name, create_time, form_time
-        from raw_inspect
-        where state = 1
+    <!--鍒嗛〉鏌ヨ鍘熸潗鏂欐楠屽崟鍒楄〃-->
+    <select id="selectRawInspectsList" resultType="java.util.Map">
+        select id,
+        DATE_FORMAT(form_time, '%Y-%m-%d') formTime,
+        code,
+        name,
+        specifications,
+        unit,
+        number,
+        DATE_FORMAT(create_time, '%Y-%m-%d') createTime,
+        user_name,
+        DATE_FORMAT(ins_time, '%Y-%m-%d') insTime,
+        ins_state,
+        judge_state
+        from mom_ocean.raw_inspect
+        where state=1
         <if test="formTime!=null and formTime!=''">
-            and form_time = #{formTime}
+            and form_time=#{formTime}
         </if>
-        <if test="createTime!=null and createTime!=''">
-            and create_time = #{createTime}
+        <if test="code!=null and code!=''">
+            and code like concat('%',#{code},'%')
         </if>
-        <if test="insState!=2">
-            and ins_state = #{insState}
+        <if test="insState!=null">
+            and ins_state=#{insState}
         </if>
-        <if test="judgeState!=2">
-            and judge_state = #{judgeState}
+        <if test="name!=null and name!=''">
+            and name like concat('%',#{name},'%')
         </if>
-        limit #{pageSize},#{countSize}
+        ORDER BY id DESC
+    </select>
+
+    <!--鏍规嵁鍘熸潗鏂欐楠屽崟id鏌ョ湅璇︽儏-->
+    <resultMap id="oneMap" type="map">
+        <id property="code" column="rcode"/>
+        <result property="formTime" column="formTime"/>
+        <result property="creatTime" column="creatTime"/>
+        <result property="name" column="rname"/>
+        <result property="specifications" column="specifications"/>
+        <result property="runit" column="runit"/>
+        <result property="number" column="number"/>
+        <result property="supplier" column="supplier"/>
+        <result property="judgeState" column="judge_state"/>
+        <result property="userName" column="user_name"/>
+        <collection property="children" resultMap="twoMap" javaType="List"/>
+    </resultMap>
+    <resultMap id="twoMap" type="Map">
+        <id property="rpId" column="rpId"/>
+        <result property="rpName" column="rpName"/>
+        <result property="rpUnit" column="rpUnit"/>
+        <result property="required" column="required"/>
+        <result property="internal" column="internal"/>
+        <result property="testValue" column="test_value"/>
+        <result property="testState" column="test_state"/>
+        <result property="deviceName" column="devName"/>
+        <result property="deviceId" column="deviceId"/>
+        <result property="uName" column="uName"/>
+    </resultMap>
+
+    <select id="selectRawInspectsListById" resultMap="oneMap">
+        select DATE_FORMAT(form_time, '%Y-%m-%d')     formTime,
+               r.code                                 rcode,
+               r.name                                 rname,
+               specifications,
+               r.unit                                 runit,
+               number,
+               DATE_FORMAT(r.create_time, '%Y-%m-%d') creatTime,
+               supplier,
+               judge_state,
+               user_name,
+               rp.id                                  rpId,
+               rp.name                                rpName,
+               rp.unit                                rpUnit,
+               required,
+               internal,
+               test_value,
+               test_state,
+               device.name                            devName,
+               device.`id`                            deviceId,
+               user.name                              uName
+        from mom_ocean.raw_ins_product rp
+                 left join mom_ocean.raw_inspect r on rp.raw_inspect_id = r.id
+                 left join mom_ocean.device
+                           on rp.device_id = device.id
+                 left join mom_ocean.user on rp.user_id = user.id
+        where r.state = 1
+          and rp.state = 1
+          and r.id = #{id}
     </select>
 </mapper>

--
Gitblit v1.9.3