From a1e90c3da21d88f994bac9c1feb91bf40e53a44d Mon Sep 17 00:00:00 2001
From: 李宇 <986321569@qq.com>
Date: 星期三, 18 八月 2021 13:01:21 +0800
Subject: [PATCH] 耗材无供应商也显示,申购管理试剂库、申请履历、收藏不显示无效试剂和无供应商试剂 可显示无供应商的耗材

---
 src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml |  241 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 231 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml b/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml
index 58945c0..373fdbb 100644
--- a/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml
+++ b/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml
@@ -174,11 +174,15 @@
   </select>
 
     <select id="getOpeReagentStatusInfoList" parameterType="java.util.Map"  resultMap="OpeReagentStatus">
-		select s.id ,name,cas, deadline,reagent_code,bm3.meta_value reagent_format,r.main_metering,bm1.meta_value reagent_type,bm2.meta_value product_home from ope_reagent_status s
+		select s.id ,name,cas, deadline,reagent_code,bm3.meta_value reagent_format,r.main_metering,bm1.meta_value reagent_type,bm2.meta_value product_home,
+		bm4.meta_value reagent_unit,
+		s.article_number
+		from ope_reagent_status s
 		left join sys_reagent r on r.id = s.reagent_id
 		left join base_meta bm1 on bm1.id = r.reagent_type
 		left join base_meta bm2 on bm2.id = r.product_home
 		left join base_meta bm3 on bm3.id = r.reagent_format
+		left join base_meta bm4 on bm4.id = r.reagent_unit
 		where s.update_time >= #{startTime} and #{endTime} > s.update_time
         <if test="containerid != null">
       		and s.container_id = #{containerid}
@@ -202,12 +206,74 @@
   </select>
 
 	<select id="getOpeReagentStatusListForLab" parameterType="java.util.Map" resultMap="OpeReagentStatus">
-		<include refid="queryColumns"/>
+		select oa.*,
+		sr.*,
+		sr.id as reagentId,
+		su.name as userName,
+		<if test="status != null">
+			<choose>
+				<when test="status == 1 or status == 2">
+					swc.container_code as containerCode,
+					sw.name as houseName,
+				</when>
+			</choose>
+		</if>
+		ss.name as supplierName
 		from ope_reagent_status as oa
-		<include refid="queryJoins"/>
+		left join sys_reagent sr on oa.reagent_id = sr.id
+		left join sys_supplier as ss on sr.supplier_id = ss.id
+		left join sys_user as su on oa.user_id = su.id
+		<if test="status != null">
+			<choose>
+				<when test="status == 1">
+					left join sys_warehouse as sw on sw.id = oa.house_id
+					left join sys_warehouse_container as swc on swc.id = oa.container_id
+				</when>
+				<when test="status == 2">
+					left join sys_laboratory as sw on sw.id = oa.house_id
+					left join sys_laboratory_container as swc on swc.id = oa.container_id
+				</when>
+			</choose>
+		</if>
 		where oa.valid_flag = 1
-		<include refid="queryWhereSqlForLab"/>
-
+		<if test="reagentId != null and reagentId != ''">
+			and oa.reagent_id = #{reagentId}
+		</if>
+		<if test="userId != null and userId != ''">
+			and oa.user_id = #{userId}
+		</if>
+		<if test="department != null and department != ''">
+			and sw.department = #{department}
+		</if>
+		<if test="departmentUserIds != null">
+			and oa.user_id in
+			<foreach collection="departmentUserIds" item="item" index="index" open="(" separator="," close=")">
+				#{item}
+			</foreach>
+		</if>
+		<if test="articleNumber != null and articleNumber != ''">
+			and oa.article_number = #{articleNumber}
+		</if>
+		<if test="editId != null and editId != ''">
+			and oa.id != #{editId}
+		</if>
+		<if test="reagentCode != null and reagentCode != ''">
+			and oa.reagent_code like #{reagentCode}
+		</if>
+		<if test="status != null">
+			and oa.status = #{status}
+		</if>
+		<if test="name != null and name != ''">
+			and sr.name like #{name}
+		</if>
+		<choose>
+			<when test="status == 2 and project != null and project != ''">
+				and sw.project like concat("%",#{project},"%")
+			</when>
+            <when test="status == 2 and labName != null and labName != ''">
+                and sw.name like concat("%",#{labName},"%")
+            </when>
+		</choose>
 		order by oa.reagent_code asc
 		<if test="first != null and pageSize != null">
 			limit #{first}, #{pageSize}
@@ -219,7 +285,6 @@
     from ope_reagent_status as oa
    <include refid="queryJoins3"/>
     where oa.valid_flag = 1
-    	  and (oa.status = -1 or oa.status = 0 )
     <include refid="queryWhereSql3"/>
 	<if	test="applyPerson != null and applyPerson != ''"  >
 		and su.name like concat("%",#{applyPerson},"%")
@@ -248,9 +313,60 @@
 	<select id="getOpeReagentStatusTotalCountForLab" parameterType="java.util.Map" resultType="int">
 		select count(1)
 		from ope_reagent_status as oa
-		<include refid="queryJoins"/>
+		left join sys_reagent sr on oa.reagent_id = sr.id
+		left join sys_supplier as ss on sr.supplier_id = ss.id
+		left join sys_user as su on oa.user_id = su.id
+		<if test="status != null">
+			<choose>
+				<when test="status == 1">
+					left join sys_warehouse as sw on sw.id = oa.house_id
+					left join sys_warehouse_container as swc on swc.id = oa.container_id
+				</when>
+				<when test="status == 2">
+					left join sys_laboratory as sw on sw.id = oa.house_id
+					left join sys_laboratory_container as swc on swc.id = oa.container_id
+				</when>
+			</choose>
+		</if>
 		where oa.valid_flag = 1
-		<include refid="queryWhereSqlForLab"/>
+		<if test="reagentId != null and reagentId != ''">
+			and oa.reagent_id = #{reagentId}
+		</if>
+		<if test="userId != null and userId != ''">
+			and oa.user_id = #{userId}
+		</if>
+		<if test="department != null and department != ''">
+			and sw.department = #{department}
+		</if>
+		<if test="departmentUserIds != null">
+			and oa.user_id in
+			<foreach collection="departmentUserIds" item="item" index="index" open="(" separator="," close=")">
+				#{item}
+			</foreach>
+		</if>
+		<if test="articleNumber != null and articleNumber != ''">
+			and oa.article_number = #{articleNumber}
+		</if>
+		<if test="editId != null and editId != ''">
+			and oa.id != #{editId}
+		</if>
+		<if test="reagentCode != null and reagentCode != ''">
+			and oa.reagent_code like #{reagentCode}
+		</if>
+		<if test="status != null">
+			and oa.status = #{status}
+		</if>
+		<if test="name != null and name != ''">
+			and sr.name like #{name}
+		</if>
+		<choose>
+			<when test="status == 2 and project != null and project != ''">
+				and sw.project like concat("%",#{project},"%")
+			</when>
+            <when test="status == 2 and labName != null and labName != ''">
+                and sw.name like concat("%",#{labName},"%")
+            </when>
+		</choose>
 	</select>
 
   <select id="getPersonReagentStatusTotalCount" parameterType="java.util.Map" resultType="int">
@@ -259,7 +375,6 @@
    <include refid="queryJoins2"/>
    left  join sys_user su on su.id = oa.user_id
     where oa.valid_flag = 1
-   		 and (oa.status = -1 or oa.status = 0 )
     <include refid="queryWhereSql2"/>
 	  <if	test="applyPerson != null and applyPerson != ''"  >
 		  and su.name like concat("%",#{applyPerson},"%")
@@ -277,6 +392,10 @@
         insert into ope_reagent_status(id, reagent_id, article_number, reagent_code, status, house_id, container_id, user_id, remainder, place, store_type, valid_flag, update_time,project_num)
         values (#{id}, #{reagentId}, #{articleNumber}, #{reagentCode}, #{status}, #{houseId}, #{containerId}, #{userId}, #{remainder}, #{place}, #{storeType}, 1, now(),#{projectNum})
     </insert>
+    <insert id="insertOpeReagentStatus2" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus">
+		insert into ope_reagent_status(id, reagent_id, article_number, reagent_code, status, house_id, container_id, user_id, remainder, place, store_type, valid_flag, update_time,project_num,apply_code,order_code)
+        values (#{id}, #{reagentId}, #{articleNumber}, #{reagentCode}, #{status}, #{houseId}, #{containerId}, #{userId}, #{remainder}, #{place}, #{storeType}, 1, now(),#{projectNum},#{applyCode},#{orderCode})
+	</insert>
 
     <select id="getOpeReagentStatusByReagentCode" parameterType="java.lang.String" resultMap="OpeReagentStatus">
         select *
@@ -419,11 +538,113 @@
 	<update id="updateByReId" parameterType="java.util.Map">
         update ope_reagent_status set reagent_id=#{newReId} where reagent_id=#{oldReId}
     </update>
+    <update id="updateArticleNumberByRCode">
+		update ope_reagent_status set article_number = #{1}
+		where reagent_code = #{0}
+	</update>
 
-<select id="selectReagentCodesByReId" parameterType="java.lang.String" resultType="java.lang.String">
+    <select id="selectReagentCodesByReId" parameterType="java.lang.String" resultType="java.lang.String">
 	select reagent_code from ope_reagent_status WHERE
 	reagent_id = #{reagentId}
 	and valid_flag = 1
 	ORDER BY update_time
 </select>
+    <select id="countReagentByArticleAndWarehouse" resultType="java.lang.Integer">
+		select count(*)
+		from ope_reagent_status
+		WHERE status = 1
+		<if test="reagentId != null and reagentId !=''">
+			and reagent_id = #{reagentId}
+		</if>
+		<if test="articleNumber != null and articleNumber !=''">
+			and article_number = #{articleNumber}
+		</if>
+		<if test="warehouseId != null and warehouseId !=''">
+			and house_id = #{warehouseId}
+		</if>
+	</select>
+	<select id="selectExportList" resultType="java.util.Map">
+		select oa.article_number articleNumber,
+		oa.reagent_code reagentCode,
+		oa.remainder,
+		bm1.meta_value productHome,
+		bm2.meta_value reagentFomart,
+		sr.name reagentName,
+		sr.cas cas,
+		<if test="status != null">
+			<choose>
+				<when test="status == 1 or status == 2">
+					swc.container_code as containerCode,
+					sw.name as houseName,
+				</when>
+			</choose>
+		</if>
+		ss.name as supplierName
+		from ope_reagent_status as oa
+		left join sys_reagent sr on oa.reagent_id = sr.id
+		left join base_meta bm1 on bm1.id = sr.product_home
+		left join base_meta bm2 on bm2.id = sr.reagent_format
+		left join sys_supplier as ss on sr.supplier_id = ss.id
+		left join sys_user as su on oa.user_id = su.id
+		<if test="status != null">
+			<choose>
+				<when test="status == 1">
+					left join sys_warehouse as sw on sw.id = oa.house_id
+					left join sys_warehouse_container as swc on swc.id = oa.container_id
+				</when>
+				<when test="status == 2">
+					left join sys_laboratory as sw on sw.id = oa.house_id
+					left join sys_laboratory_container as swc on swc.id = oa.container_id
+				</when>
+			</choose>
+		</if>
+		where oa.valid_flag = 1
+		<if test="reagentId != null and reagentId != ''">
+			and oa.reagent_id = #{reagentId}
+		</if>
+		<if test="userId != null and userId != ''">
+			and oa.user_id = #{userId}
+		</if>
+		<if test="department != null and department != ''">
+			and sw.department = #{department}
+		</if>
+		<if test="departmentUserIds != null">
+			and oa.user_id in
+			<foreach collection="departmentUserIds" item="item" index="index" open="(" separator="," close=")">
+				#{item}
+			</foreach>
+		</if>
+		<if test="articleNumber != null and articleNumber != ''">
+			and oa.article_number = #{articleNumber}
+		</if>
+		<if test="editId != null and editId != ''">
+			and oa.id != #{editId}
+		</if>
+		<if test="reagentCode != null and reagentCode != ''">
+			and oa.reagent_code like  concat("%",#{reagentCode},"%")
+		</if>
+		<if test="status != null">
+			and oa.status = #{status}
+		</if>
+		<if test="name != null and name != ''">
+			and sr.name like concat("%",#{name},"%")
+		</if>
+		<choose>
+			<when test="status == 2 and project != null and project != ''">
+				and sw.project like concat("%",#{project},"%")
+			</when>
+            <when test="status == 2 and labName != null and labName != ''">
+                and sw.name like concat("%",#{labName},"%")
+            </when>
+		</choose>
+		order by oa.reagent_code asc
+	</select>
+    <select id="getStatus" resultMap="OpeReagentStatus">
+
+		  select *
+        from ope_reagent_status
+        where valid_flag = 1
+        and reagent_code = #{reagentCode}
+        and reagent_id = #{reagentId}
+	</select>
 </mapper>

--
Gitblit v1.9.2