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/OpeApplyDao.xml |  116 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 98 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/dao/OpeApplyDao.xml b/src/main/java/com/nanometer/smartlab/dao/OpeApplyDao.xml
index d6b7303..0ef0a7f 100644
--- a/src/main/java/com/nanometer/smartlab/dao/OpeApplyDao.xml
+++ b/src/main/java/com/nanometer/smartlab/dao/OpeApplyDao.xml
@@ -116,12 +116,9 @@
             and (oa.approve_user_id = #{searchApproval} or oa.before_approve_user_id = #{searchApproval})
         </if>
 
-        <if test="applyUserName != null and applyUserName != ''">
-            and su.name like #{applyUserName}
-        </if>
-
         <if test="approvaUserName != null and approvaUserName != ''">
-            and (suApprove.name like #{approvaUserName} or sys.name like #{approvaUserName})
+            and (suApprove.name like concat('%',#{approvaUserName},'%')
+            or sys.name like concat('%',#{approvaUserName},'%') )
         </if>
 
 		<if test="editId != null and editId != ''">
@@ -177,7 +174,9 @@
       left join sys_user as fir on fir.id=oa.first_user
     left join base_meta as bm on sr.product_home = bm.id
     where oa.valid_flag = 1
-      and sr.valid_flag = 1
+    <if test="isShow != null and isShow ==0">
+        and (ss.valid_flag = 1 or sr.type = 0)
+    </if>
     <include refid="queryWhereSql"/>
     order by oa.create_time desc
     <if test="first != null and pageSize != null">
@@ -195,7 +194,10 @@
       left join sys_user as sys on sys.id=oa.before_approve_user_id
       left join sys_user as fir on fir.id=oa.first_user
       left join base_meta as bm on sr.product_home = bm.id
-      where oa.valid_flag = 1 and sr.valid_flag = 1
+      where oa.valid_flag = 1
+      <if test="isShow != null and isShow ==0">
+          and (ss.valid_flag = 1 or sr.type = 0)
+      </if>
     <include refid="queryWhereSql"/>
   </select>
 
@@ -205,14 +207,23 @@
   </insert>
 
   <insert id="insertOpeApplyList" parameterType="java.util.List">
-    insert into ope_apply
-    	(id, apply_code, reagent_id, num, deadline, apply_user_id, objective, status, approve_user_id, memo, valid_flag, create_time, update_time,apply_goal,apply_price,first_user)
-    values
-	    <foreach collection="list" item="opeApply" separator=",">
-	    	(#{opeApply.id}, #{opeApply.applyCode}, #{opeApply.reagent.id}, #{opeApply.num}, #{opeApply.deadline},
-	    	#{opeApply.applyUserId}, #{opeApply.objective}, #{opeApply.status}, #{opeApply.approveUserId}, #{opeApply.memo}, 1, now(), now(),#{opeApply.applyGoal},#{opeApply.reagent.price},#{opeApply.approveUserId})
-	    </foreach>
+      insert into ope_apply
+      (id, apply_code, reagent_id, num, deadline, apply_user_id, objective, status, approve_user_id, memo, valid_flag, create_time, update_time,apply_goal,apply_price,first_user)
+      values
+      <foreach collection="list" item="opeApply" separator=",">
+          (#{opeApply.id}, #{opeApply.applyCode}, #{opeApply.reagent.id}, #{opeApply.num}, #{opeApply.deadline},
+          #{opeApply.applyUserId}, #{opeApply.objective}, #{opeApply.status}, #{opeApply.approveUserId}, #{opeApply.memo}, 1, now(), now(),#{opeApply.applyGoal},#{opeApply.reagent.price},#{opeApply.approveUserId})
+      </foreach>
   </insert>
+    <insert id="insertList">
+        insert into ope_apply
+        (id, apply_code, reagent_id, num, deadline, apply_user_id, objective, status, approve_user_id, memo, valid_flag, create_time, update_time,apply_goal,apply_price,first_user)
+        values
+        <foreach collection="list" item="opeApply" separator=",">
+            (#{opeApply.id}, #{opeApply.applyCode}, #{opeApply.reagent.id}, #{opeApply.num}, #{opeApply.deadline},
+            #{opeApply.applyUserId}, #{opeApply.objective}, #{opeApply.status}, #{opeApply.approveUserId}, #{opeApply.memo}, 1, #{opeApply.createTime}, #{opeApply.updateTime},#{opeApply.applyGoal},#{opeApply.reagent.price},#{opeApply.approveUserId})
+        </foreach>
+    </insert>
 
     <update id="updateFirst" parameterType="java.util.Map">
         update ope_apply set first_user=approve_user_id where id=#{id}
@@ -232,7 +243,11 @@
   </update>
 
   <update id="updateOpeApplyStatus" parameterType="java.util.Map" >
-    update ope_apply set status=#{status}, memo=#{memo}, update_time=now()
+    update ope_apply set status=#{status},
+     <if test="memo !=null and memo != ''">
+         memo=#{memo},
+     </if>
+      update_time=now()
     where id in
     <foreach collection="applyIds" item="item" index="index" open="(" separator="," close=")">
       #{item}
@@ -360,7 +375,7 @@
         LEFT JOIN base_meta AS bm1 ON sr.product_home = bm1.id
         LEFT JOIN sys_project as project on project.project = su.project
         LEFT JOIN sys_user as su1 on su1.id = project.sys_user_id
-        where oa.valid_flag = 1 and (oa.status=4 or oa.status=6)
+        where oa.valid_flag = 1 and (oa.status=4 or oa.status=6 or oa.status = 10)
         <include refid="getOpeApplyReserveList_queryWhereSql" />
         <if test="isAllApply != null">
             <choose>
@@ -426,8 +441,34 @@
         LEFT JOIN base_meta AS bm1 ON sr.product_home = bm1.id
         LEFT JOIN sys_project as project on project.project = su.project
         LEFT JOIN sys_user as su1 on su1.id = project.sys_user_id
-        where oa.valid_flag = 1 and (oa.status=4 or oa.status=6)
-        <include refid="getOpeApplyReserveList_queryWhereSql" />
+        where oa.valid_flag = 1 and (
+        <choose>
+            <when test="status == @com.nanometer.smartlab.entity.enumtype.ApplyStatus@EXPIRED">
+                oa.status = 10
+            </when>
+            <otherwise>
+                oa.status=4 or oa.status=6
+            </otherwise>
+        </choose>
+        )
+        <if test="reagentName != null and reagentName != ''">
+            and sr.name like concat('%',#{reagentName},'%')
+        </if>
+        <if test="personName != null and personName != ''">
+            and su.name like concat('%',#{personName},'%')
+        </if>
+        <if test="userId != null and userId != ''">
+            and oa.apply_user_id =#{userId}
+        </if>
+        <if test="status != null and status != ''">
+            and oa.status =#{status}
+        </if>
+        <if test="productSn != null and productSn != ''">
+            and sr.product_sn like concat('%',#{productSn},'%')
+        </if>
+        <if test="applyCode != null and applyCode != ''">
+            and oa.apply_code = #{applyCode}
+        </if>
         <if test="isAllApply != null">
             <choose>
                 <when test="isAllApply == 1">
@@ -485,6 +526,45 @@
         where oa.valid_flag = 1
         and oa.id = #{0}
     </select>
+    <select id="getOpeApplyReserveListByNameForRowData"
+            resultMap="OpeApplyReserve">
+         SELECT
+        oa.id,
+        oa.apply_code,
+        sr.id reagent_id,
+        oa. STATUS,
+        sr.product_sn reagentProductSn,
+        sr.`name` reagentName,
+        bm2.meta_value controlProducts,
+        bm3.meta_value reagentFormat,
+        sr.main_metering reagentMainMetering,
+        sr.price reagentPrice,
+        sr.cas reagentCas,
+        oa.article_number articleNumber,
+        bm4.meta_value reagentCharacter,
+        bm1.meta_value productHome,
+        sr.dangerous_flag,
+        oa.num,
+        oa.apply_user_id apply_user,
+        oa.used,
+        su.`name` apply_user_id,
+        su.project,
+        su1.`name` as projectManage,
+        oa.arrival_time
+        FROM
+        ope_apply AS oa
+        LEFT JOIN sys_reagent sr ON sr.id = oa.reagent_id
+        LEFT JOIN sys_user su ON su.id = oa.apply_user_id
+        LEFT JOIN base_meta AS bm2 ON sr.control_products = bm2.id
+        LEFT JOIN base_meta AS bm3 ON sr.reagent_format = bm3.id
+        LEFT JOIN base_meta AS bm4 ON sr.reagent_character = bm4.id
+        LEFT JOIN base_meta AS bm1 ON sr.product_home = bm1.id
+        LEFT JOIN sys_project as project on project.project = su.project
+        LEFT JOIN sys_user as su1 on su1.id = project.sys_user_id
+        where oa.id = #{id}
+
+
+    </select>
 
 
     <update id="updateByReId" parameterType="java.util.Map">

--
Gitblit v1.9.2