<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.nanometer.smartlab.dao.OpeReagentStatusDao">
|
<resultMap id="OpeReagentStatus" type="com.nanometer.smartlab.entity.OpeReagentStatus">
|
<id property="id" column="id"/>
|
<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" ></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>
|
<result property="userName" column="userName"></result>
|
<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"></result>
|
<result property="projectId" column="project_id"></result>
|
|
<result property="containerCode" column="containerCode"></result>
|
<result property="houseName" column="houseName"></result>
|
|
|
<association property="reagent" javaType="com.nanometer.smartlab.entity.SysReagent">
|
<id property="id" column="reagentId"/>
|
<result property="name" column="name"></result>
|
<result property="cas" column="cas"></result>
|
<result property="reagentType" column="reagent_type"></result>
|
<result property="reagentCharacter" column="reagent_character"></result>
|
<result property="supplierId" column="supplier_id"></result>
|
<result property="reagentFormat" column="reagent_format"></result>
|
<result property="mainMetering" column="main_metering"></result>
|
<result property="reagentUnit" column="reagent_unit"></result>
|
<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"></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>
|
|
<update id="updateTimeByCode" parameterType="java.util.Map">
|
update ope_reagent_status set update_time=now() where reagent_code=#{code}
|
</update>
|
|
<update id="updateStatusByCode" parameterType="java.util.Map">
|
update ope_reagent_status set status=#{status} where reagent_code=#{code}
|
</update>
|
|
<sql id="queryWhereSql">
|
<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="reagentName != null and reagentName != ''">
|
and sr.name = #{reagentName}
|
</if>
|
</sql>
|
|
<sql id="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>
|
</sql>
|
|
|
|
<sql id="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
|
</sql>
|
|
<sql id="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>
|
</sql>
|
|
<select id="getOpeReagentStatusById" 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.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
|
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}
|
</if>
|
<if test="status != null">
|
and s.status = #{status}
|
</if>
|
</select>
|
|
<select id="getOpeReagentStatusList" 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="queryWhereSql"/>
|
|
order by oa.reagent_code asc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
|
|
<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">
|
<include refid="queryColumns3"/>
|
from ope_reagent_status as oa
|
<include refid="queryJoins3"/>
|
where oa.valid_flag = 1
|
<include refid="queryWhereSql3"/>
|
<if test="applyPerson != null and applyPerson != ''" >
|
and su.name like concat("%",#{applyPerson},"%")
|
</if>
|
<if test="startTime != null and startTime != ''">
|
and #{startTime} < oa.update_time
|
</if>
|
<if test="endTime != null and endTime != ''">
|
and oa.update_time < #{endTime}
|
</if>
|
|
order by oa.update_time DESC
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
|
<select id="getOpeReagentStatusTotalCount" parameterType="java.util.Map" resultType="int">
|
select count(1)
|
from ope_reagent_status as oa
|
<include refid="queryJoins"/>
|
where oa.valid_flag = 1
|
<include refid="queryWhereSql"/>
|
</select>
|
|
<select id="getOpeReagentStatusTotalCountForLab" parameterType="java.util.Map" resultType="int">
|
select count(1)
|
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>
|
</select>
|
|
<select id="getPersonReagentStatusTotalCount" parameterType="java.util.Map" resultType="int">
|
select count(1)
|
from ope_reagent_status as oa
|
<include refid="queryJoins2"/>
|
left join sys_user su on su.id = oa.user_id
|
where oa.valid_flag = 1
|
<include refid="queryWhereSql2"/>
|
<if test="applyPerson != null and applyPerson != ''" >
|
and su.name like concat("%",#{applyPerson},"%")
|
</if>
|
<if test="startTime != null and startTime != ''">
|
and #{startTime} < oa.update_time
|
</if>
|
<if test="endTime != null and endTime != ''">
|
and oa.update_time < #{endTime}
|
</if>
|
</select>
|
|
|
<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( 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>
|
|
<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}
|
</select>
|
|
<select id="getOpeReagentStatusByReagentCode2" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus" resultMap="OpeReagentStatus">
|
select *
|
from ope_reagent_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_id=#{projectId}
|
where id=#{id}
|
</update>
|
|
|
<update id="syncOpeReagentStatus" parameterType="java.util.Map">
|
<choose>
|
<!--0:个人领用 1:在仓库sys_warehouse_container 2:在实验室sys_laboratory_container 3:报废-->
|
<when test="status == 0">
|
update ope_reagent_status set update_time = #{updateTime}, status = #{status}, realstatus = #{realstatus},container_id = 0, house_id = 0, user_id= #{userId} ,remainder= #{remainder} where reagent_code = #{reagentCode}
|
</when>
|
<when test="status == 1">
|
update ope_reagent_status set update_time = #{updateTime}, status = #{status}, realstatus = #{realstatus},house_id= #{houseId}, container_id= #{containerId}, user_id= #{userId} ,remainder= #{remainder} where reagent_code = #{reagentCode}
|
</when>
|
<when test="status == 2">
|
update ope_reagent_status set update_time = #{updateTime}, status = #{status}, realstatus = #{realstatus},house_id= #{houseId}, container_id= #{containerId}, user_id= #{userId} ,remainder= #{remainder} where reagent_code = #{reagentCode}
|
</when>
|
<when test="status == 3">
|
update ope_reagent_status set update_time = #{updateTime}, status = #{status}, realstatus = #{realstatus},user_id= #{userId} ,remainder= #{remainder} where reagent_code = #{reagentCode}
|
</when>
|
</choose>
|
</update>
|
|
<update id="updateOpeReagentStatusForInterface" parameterType="com.nanometer.smartlab.entity.OpeReagentStatus">
|
update ope_reagent_status set status=#{status}, user_id=#{userId}, update_time=now(), container_id=#{containerId}
|
where reagent_code=#{reagentCode}
|
</update>
|
|
|
<delete id="deleteByReagentCode" >
|
delete from ope_reagent_status
|
where reagent_code=#{reagentCode}
|
</delete>
|
|
|
<select id="getReagentStatusByContainerId" resultMap="OpeReagentStatus">
|
select *
|
from ope_reagent_status ors
|
LEFT JOIN sys_reagent sr on sr.id = ors.reagent_id
|
where ors.valid_flag = 1 and ors.container_id = #{containerId}
|
</select>
|
|
<sql id="queryJoins2">
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
</sql>
|
|
<sql id="queryWhereSql2">
|
<if test="reagentCode != null and reagentCode != ''">
|
and oa.reagent_code like #{reagentCode}
|
</if>
|
<if test="reagentName != null and reagentName != ''">
|
and sr.name like concat('%',#{reagentName},'%')
|
</if>
|
<if test="userId != null and userId != ''">
|
and userId=#{userId}
|
</if>
|
</sql>
|
|
<sql id="queryColumns3">
|
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
|
</sql>
|
|
<sql id="queryJoins3">
|
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>
|
</sql>
|
<sql id="queryWhereSql3">
|
<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="reagentName != null and reagentName != ''">
|
and sr.name like concat('%',#{reagentName},'%')
|
</if>
|
</sql>
|
<select id="selectByReId" resultMap="OpeReagentStatus">
|
select * from ope_reagent_status where reagent_id=#{id}
|
</select>
|
|
<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" resultType="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>
|
|
<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>
|