From 47a751cb301d05276ae5d75145d57b2d090fe4e1 Mon Sep 17 00:00:00 2001 From: kongzy <kongzy> Date: 星期一, 01 七月 2024 10:58:35 +0800 Subject: [PATCH] change --- src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml | 361 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 331 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml b/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml index e1e86dc..1decb18 100644 --- a/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml +++ b/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml @@ -6,9 +6,9 @@ <result property="reagentId" column="reagent_id"></result> <result property="articleNumber" column="article_number"></result> <result property="reagentCode" column="reagent_code"></result> - <result property="status" column="status" typeHandler="com.nanometer.smartlab.entity.handler.ArrivalStatusHandler"></result> - <result property="realstatus" column="realstatus" typeHandler="com.nanometer.smartlab.entity.handler.RealStatusHandler"></result> - <result property="validFlag" column="valid_flag" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></result> + <result property="status" column="status" ></result> + <result property="realstatus" column="realstatus" ></result> + <result property="validFlag" column="valid_flag" ></result> <result property="houseId" column="house_id"></result> <result property="containerId" column="container_id"></result> <result property="userId" column="user_id"></result> @@ -16,8 +16,8 @@ <result property="updateTime" column="update_time"></result> <result property="remainder" column="remainder"></result> <result property="place" column="place"></result> - <result property="storeType" column="store_type" typeHandler="com.nanometer.smartlab.entity.handler.StoreTypeHandler"></result> - <result property="projectNum" column="project_num"></result> + <result property="storeType" column="store_type"></result> + <result property="projectId" column="project_id"></result> <result property="containerCode" column="containerCode"></result> <result property="houseName" column="houseName"></result> @@ -36,12 +36,13 @@ <result property="price" column="price"></result> <result property="perBox" column="per_box"></result> <result property="memo" column="memo"></result> - <result property="validFlag" column="valid_flag" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></result> + <result property="validFlag" column="valid_flag"></result> <result property="createTime" column="create_time"></result> <result property="updateTime" column="update_time"></result> <result property="supplierName" column="supplierName"></result> <result property="deadline" column="deadline"></result> <result property="productHome" column="product_home"></result> + <result property="density" column="density"></result> </association> </resultMap> @@ -145,18 +146,18 @@ <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 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 as sw on sw.id = oa.house_id left join sys_laboratory_container as swc on swc.id = oa.container_id </when> </choose> </if> </sql> - <select id="getOpeReagentStatus" parameterType="java.lang.String" resultMap="OpeReagentStatus" > + <select id="getOpeReagentStatusById" resultMap="OpeReagentStatus" > select oa.*, sr.*, sr.id as reagentId, @@ -173,9 +174,27 @@ where oa.id = #{id} and oa.valid_flag = 1 </select> + <select id="getOpeReagentStatusByCode" resultMap="OpeReagentStatus" > + select oa.*, + sr.*, + sr.id as reagentId, + su.name as userName, + (case when oa.status=1 then (select sw.container_code from sys_warehouse_container sw where sw.id=oa.container_id) + when oa.status=2 then (select sw.container_code from sys_laboratory_container sw where sw.id=oa.container_id) else '' END)as containerCode, + (case when oa.status=1 then (select sw.name from sys_warehouse sw where sw.id=oa.house_id) + when oa.status=2 then (select sw.name from sys_laboratory sw where sw.id=oa.house_id) else '' END)as houseName, + ss.name as supplierName + from ope_reagent_status as oa + 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 + where oa.reagent_code = #{reagentCode} and oa.valid_flag = 1 + </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, bm4.meta_value reagent_unit, + r.density, s.article_number from ope_reagent_status s left join sys_reagent r on r.id = s.reagent_id @@ -205,17 +224,129 @@ </if> </select> - <select id="getOpeReagentStatusListForLab" parameterType="java.util.Map" resultMap="OpeReagentStatus"> - <include refid="queryColumns"/> - from ope_reagent_status as oa - <include refid="queryJoins"/> - where oa.valid_flag = 1 - <include refid="queryWhereSqlForLab"/> + <select id="getOpeReagentStatusList22" parameterType="java.util.Map" resultMap="OpeReagentStatus"> + <include refid="queryColumns"/> + from ope_reagent_status as oa + 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"> + inner 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"> + inner 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="articleNumber != null and articleNumber != ''"> + and oa.article_number = #{articleNumber} + </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="applyCode != null and applyCode != ''"> + and oa.apply_code = #{applyCode} + </if> + </where> + order by oa.reagent_code asc + <if test="first != null and pageSize != null"> + limit #{first}, #{pageSize} + </if> + </select> + + <select id="getOpeReagentStatusListForLab" parameterType="java.util.Map" resultMap="OpeReagentStatus"> + 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 + 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 + <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} </if> + </select> + + <select id="getLabNoContainerByProjectId" parameterType="java.util.Map" resultMap="OpeReagentStatus"> + select oa.*,sr.*,sr.id as reagent_id,sl.name as house_name from sys_laboratory sl + left join ope_reagent_status as oa on oa.house_id=sl.id + left join sys_reagent sr on sr.id=oa.reagent_id + where find_in_set(#{projectId},sl.project) </select> <select id="getPersonReagentStatusList" parameterType="java.util.Map" resultMap="OpeReagentStatus"> @@ -223,7 +354,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},"%") @@ -252,9 +382,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"> @@ -263,7 +444,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,16 +457,26 @@ </select> - <insert id="insertOpeReagentStatus" 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) - values (#{id}, #{reagentId}, #{articleNumber}, #{reagentCode}, #{status}, #{houseId}, #{containerId}, #{userId}, #{remainder}, #{place}, #{storeType}, 1, now(),#{projectNum}) + <insert id="insertOpeReagentStatus" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus" useGeneratedKeys = "true" keyProperty = "id"> + insert into ope_reagent_status( reagent_id, article_number, reagent_code, status, house_id, container_id, user_id, remainder, place, store_type, valid_flag, update_time,project_id) + values ( #{reagentId}, #{articleNumber}, #{reagentCode}, #{status}, #{houseId}, #{containerId}, #{userId}, #{remainder}, #{place}, #{storeType}, 1, now(),#{projectId}) </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 into ope_reagent_status( reagent_id, article_number, reagent_code, status, house_id, container_id, user_id, remainder, place, store_type, valid_flag, update_time,project_id,apply_code,order_code) + values (#{reagentId}, #{articleNumber}, #{reagentCode}, #{status}, #{houseId}, #{containerId}, #{userId}, #{remainder}, #{place}, #{storeType}, 1, now(),#{projectId},#{applyCode},#{orderCode}) </insert> - <select id="getOpeReagentStatusByReagentCode" parameterType="java.lang.String" resultMap="OpeReagentStatus"> + <insert id="batchInsertOpeReagentStatus"> + insert into ope_reagent_status( reagent_id, article_number, reagent_code, status, house_id, container_id, user_id, remainder, place, store_type, valid_flag, update_time,project_id,apply_code,order_code) + values + <foreach collection ="list" item="reagentStatus" separator =","> + (#{reagentStatus.reagentId}, #{reagentStatus.articleNumber}, #{reagentStatus.reagentCode}, #{reagentStatus.status}, #{reagentStatus.houseId}, #{reagentStatus.containerId}, #{reagentStatus.userId}, #{reagentStatus.remainder}, #{reagentStatus.place}, #{reagentStatus.storeType}, 1, now(),#{reagentStatus.projectId},#{reagentStatus.applyCode},#{reagentStatus.orderCode}) + </foreach > + </insert> + + <select id="getOpeReagentStatusByReagentCode" resultMap="OpeReagentStatus"> select * from ope_reagent_status where valid_flag = 1 and reagent_code = #{reagentCode} @@ -295,11 +485,17 @@ <select id="getOpeReagentStatusByReagentCode2" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus" resultMap="OpeReagentStatus"> select * from ope_reagent_status - where valid_flag = 1 and reagent_code = #{reagentCode} and status=#{status} + <where> + valid_flag = 1 and reagent_code = #{reagentCode} + <if test="status!=null"> + and status=#{status} + </if> + </where> + limit 1 </select> <update id="updateOpeReagentStatusDao" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus"> - update ope_reagent_status set status=#{status},house_id=#{houseId},container_id=#{containerId}, user_id=#{userId}, place=#{place}, update_time=now(),project_num=#{projectNum} + update ope_reagent_status set status=#{status},house_id=#{houseId},container_id=#{containerId}, user_id=#{userId}, place=#{place}, update_time=now(),project_id=#{projectId} where id=#{id} </update> @@ -328,13 +524,13 @@ </update> - <delete id="deleteByReagentCode" parameterType="java.lang.String" > + <delete id="deleteByReagentCode" > delete from ope_reagent_status where reagent_code=#{reagentCode} </delete> - <select id="getReagentStatusByContainerId" parameterType="java.lang.String" resultMap="OpeReagentStatus"> + <select id="getReagentStatusByContainerId" resultMap="OpeReagentStatus"> select * from ope_reagent_status ors LEFT JOIN sys_reagent sr on sr.id = ors.reagent_id @@ -427,8 +623,12 @@ <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" resultType="string"> select reagent_code from ope_reagent_status WHERE reagent_id = #{reagentId} and valid_flag = 1 @@ -448,4 +648,105 @@ 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> + + <update id="updateOpeReagentStatusByCode" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus"> + update ope_reagent_status set status=#{status} + where reagent_code=#{reagentCode} + </update> + + <update id="batchUpdateReagentStatusByIds"> + update ope_reagent_status set house_id=#{houseId} , container_id=#{containerId},status=#{status} + where id in + <foreach collection="ids" item="id" separator="," open="(" close=")"> + #{id} + </foreach> + </update> + + <select id="getReagentStatusCountByApplyCode" resultType="integer"> + select count(1) from ope_reagent_status where apply_code=#{applyCode} and status!=1 + </select> </mapper> -- Gitblit v1.9.2