<?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" 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="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" typeHandler="com.nanometer.smartlab.entity.handler.StoreTypeHandler"></result>
|
<result property="projectNum" column="project_num"></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" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></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>
|
</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="getOpeReagentStatus" parameterType="java.lang.String" 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="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
|
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
|
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="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"/>
|
|
order by oa.reagent_code asc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</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
|
and (oa.status = -1 or oa.status = 0 )
|
<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
|
<include refid="queryJoins"/>
|
where oa.valid_flag = 1
|
<include refid="queryWhereSqlForLab"/>
|
</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
|
and (oa.status = -1 or oa.status = 0 )
|
<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">
|
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>
|
|
<select id="getOpeReagentStatusByReagentCode" parameterType="java.lang.String" 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} and status=#{status}
|
</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}
|
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" parameterType="java.lang.String" >
|
delete from ope_reagent_status
|
where reagent_code=#{reagentCode}
|
</delete>
|
|
|
<select id="getReagentStatusByContainerId" parameterType="java.lang.String" 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>
|
|
<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>
|
</mapper>
|