| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?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.zd.chemical.mapper.HxpChemicalJoinCabinetMapper">
- <resultMap type="com.zd.chemical.domain.HxpChemicalJoinCabinet" id="HxpChemicalJoinCabinetResult">
- <result property="id" column="id"/>
- <result property="joinNum" column="join_num"/>
- <result property="subId" column="sub_id"/>
- <result property="chemicalId" column="chemical_id"/>
- <result property="cabinetId" column="cabinet_id"/>
- <result property="chemicalAmount" column="chemical_amount"/>
- <result property="chemicalAmountUnit" column="chemical_amount_unit"/>
- <result property="expireTime" column="expire_time"/>
- <result property="userId" column="user_id"/>
- <result property="createBy" column="create_by"/>
- <result property="createTime" column="create_time"/>
- <result property="status" column="status"/>
- </resultMap>
- <sql id="selectHxpChemicalJoinCabinetVo">
- select id,join_num,sub_id, chemical_id, cabinet_id,chemical_amount,chemical_amount_unit,expire_time, user_id, create_by, create_time,status from hxp_chemical_join_cabinet
- </sql>
- <sql id="selectHxpChemicalJoinCabinetListVo">
- select t.id,t.join_num,t.sub_id, t.chemical_id, t.cabinet_id,t.chemical_amount,t.chemical_amount_unit,t.expire_time, t.user_id, t.create_by, t.create_time,t.status from hxp_chemical_join_cabinet as t
- </sql>
- <select id="selectHxpChemicalJoinCabinetList" parameterType="com.zd.chemical.domain.vo.HxpChemicalJoinCabinetSearch" resultType="com.zd.chemical.domain.vo.HxpChemicalJoinCabinetListVo">
- SELECT cjc.`id`,cjc.`join_num` joinNum,cl.chemical_name chemicalName,IFNULL(CONCAT(cjc.chemical_amount,cjc.`chemical_amount_unit`),'') chemicalAmountUnit,cjc.expire_time expireTime,ct.cabinet_name cabinetName,
- (SELECT he.name FROM lab_hardware he WHERE he.id = cjc.cabinetlock_id) lockName,
- CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = ct.`sub_id`),'-',(SELECT dt.dept_name FROM sys_dept dt,lab_subject st WHERE dt.dept_id = st.build_id AND st.id = ct.`sub_id`),
- '-',(SELECT bg.name FROM lab_building bg,lab_subject st WHERE bg.id = st.floor_id AND st.id = ct.`sub_id`),
- IFNULL(CONCAT('-',(SELECT slt.room_num room FROM lab_build_floor_layout slt,lab_subject st WHERE slt.sub_id = st.id AND st.id = ct.`sub_id`)),'')) posi,
- ct.cabinet_num cabinetNum,
- CASE WHEN cjc.status=0 THEN '未入库' ELSE CASE WHEN sk.status=2 OR sk.status=3 THEN '已出库' ELSE CASE WHEN cjc.status=1 THEN '已入库' ELSE
- case when sk.status=4 then '已过期' else '未知'
- end
- END
- END
- END cabinetStatus,
- cjc.create_time createTime,
- (SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = cjc.user_id) createBy,cjc.status,
- IFNULL(CONCAT(cjc.tare,cl.chemical_unit),'') tare
- FROM hxp_chemical_join_cabinet cjc LEFT JOIN hxp_cabinet ct ON ct.id = cjc.cabinet_id
- LEFT JOIN hxp_chemical cl ON cjc.chemical_id = cl.id
- LEFT JOIN lab_subject st ON ct.sub_id = st.id
- LEFT JOIN hxp_stock sk ON sk.join_id = cjc.id
- <where>
- <if test="chemicalId != null "> and cjc.chemical_id= #{chemicalId}</if>
- <if test="searchValue != null ">
- and (
- cl.chemical_name like concat('%',#{searchValue},'%') or
- cl.another_name like concat('%',#{searchValue},'%') or
- cl.cas_num like concat('%',#{searchValue},'%') or
- cjc.join_num like concat('%',#{searchValue},'%') or
- st.name like concat('%',#{searchValue},'%')
- )
- </if>
- <if test="status != null ">
- <if test="status == 0 ">
- and cjc.status= #{status}
- </if>
- <if test="status == 1">
- and sk.status= #{status}
- </if>
- <if test="status == 2 ">
- and (sk.status=2 OR sk.status=3)
- </if>
- <if test="status == 4">
- and sk.status= #{status}
- </if>
- </if>
- <if test="userId != null">
- and cjc.user_id = #{userId}
- </if>
- </where>
- order by cjc.create_time desc
- </select>
- <select id="selectHxpChemicalJoinCabinetById" parameterType="Long" resultMap="HxpChemicalJoinCabinetResult">
- <include refid="selectHxpChemicalJoinCabinetVo"/>
- where id = #{id}
- </select>
- <select id="queryUserNameBySafeUserId" parameterType="string" resultType="string">
- SELECT GROUP_CONCAT(nick_name) safeUserName FROM sys_user WHERE FIND_IN_SET(user_id, #{safeUserId})
- </select>
- <select id="queryUserPhoneBySafeUserId" parameterType="string" resultType="string">
- SELECT GROUP_CONCAT(phonenumber) safeUserPhone FROM sys_user WHERE FIND_IN_SET(user_id, #{safeUserId})
- </select>
- <select id="selectChemicalVoList" resultType="com.zd.chemical.domain.vo.AioChemicalVo">
- select
- che.chemical_num,
- che.chemical_name,
- che.chemical_classify,
- che.chemical_shape,
- che.measuring_method,
- che.chemical_unit,
- che.verification,
- che.another_name,
- che.cas_num,
- che.factory,
- che.purity,
- che.collect_hour,
- che.collect_minute,
- che.join_hazard_id as hazardId,
- jo.id joinId,
- jo.join_num,
- jo.sub_id,
- jo.chemical_id,
- jo.cabinet_id,
- jo.chemical_amount,
- jo.chemical_amount_unit,
- jo.expire_time,
- cab.cabinet_num,
- cab.cabinet_name,
- cab.cabinet_status,
- s.safe_user_id,
- jo.tare,
- cc.label_type,
- cc.print_code,
- (select ccf.classify_name from hxp_chemical_classify ccf where ccf.id = che.chemical_classify) classifyName,
- (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda WHERE dda.dict_type = 'hxp_classifyattribute' AND
- FIND_IN_SET(dda.dict_value, (select classify_attribute from hxp_chemical where id = jo.chemical_id
- ))) classifyAttribute
- from hxp_chemical_join_cabinet jo
- inner join hxp_cabinet cab on cab.id = jo.cabinet_id and cab.sub_id = jo.sub_id
- inner join hxp_chemical che on che.id = jo.chemical_id
- inner join lab_subject s on jo.sub_id = s.id
- left join hxp_classify_config cc on che.chemical_classify = cc.join_classify_id
- <where>
- jo.sub_id = #{subId} and jo.status = 0
- <if test="cabinetId != null">
- and jo.cabinet_id = #{cabinetId}
- </if>
- <if test="labelType != null">
- and che.label_type = #{labelType}
- </if>
- <if test="chemicalName != null and chemicalName != ''">
- and (
- che.chemical_name like concat("%", #{chemicalName}, "%")
- or che.another_name like concat("%", #{chemicalName}, "%")
- or che.chemical_name_char like concat(#{chemicalName}, "%")
- or che.another_name_char like concat(#{chemicalName}, "%")
- )
- </if>
- </where>
- order by che.chemical_name , jo.create_time desc
- </select>
- <select id="selByChemical" parameterType="Long" resultMap="HxpChemicalJoinCabinetResult">
- <include refid="selectHxpChemicalJoinCabinetVo"/>
- where chemical_id = #{id}
- </select>
- <select id="selectChemicalListById" parameterType="com.zd.chemical.domain.HxpChemicalJoinCabinet" resultType="com.zd.chemical.domain.HxpChemicalJoinCabinet">
- SELECT
- jo.id joinId,
- jo.join_num,
- jo.sub_id,
- jo.chemical_id,
- jo.cabinet_id,
- jo.chemical_amount,
- jo.chemical_amount_unit,
- jo.expire_time
- FROM hxp_chemical_join_cabinet jo
- INNER JOIN hxp_stock sk ON jo.id = sk.`join_id`
- <where>
- <if test="id != null">
- and jo.`id` = #{id}
- </if>
- </where>
- </select>
- <insert id="insertHxpChemicalJoinCabinet" parameterType="com.zd.chemical.domain.HxpChemicalJoinCabinet" useGeneratedKeys="true" keyProperty="id">
- insert into hxp_chemical_join_cabinet
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="joinNum != null">join_num,</if>
- <if test="subId != null">sub_id,</if>
- <if test="chemicalId != null">chemical_id,</if>
- <if test="cabinetId != null">cabinet_id,</if>
- <if test="cabinetlockId != null">cabinetlock_id,</if>
- <if test="chemicalAmount != null">chemical_amount,</if>
- <if test="chemicalAmountUnit != null">chemical_amount_unit,</if>
- <if test="expireTime != null">expire_time,</if>
- <if test="userId != null">user_id,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="tare != null">tare,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="joinNum != null">#{joinNum},</if>
- <if test="subId != null">#{subId},</if>
- <if test="chemicalId != null">#{chemicalId},</if>
- <if test="cabinetId != null">#{cabinetId},</if>
- <if test="cabinetlockId != null">#{cabinetlockId},</if>
- <if test="chemicalAmount != null">#{chemicalAmount},</if>
- <if test="chemicalAmountUnit != null">#{chemicalAmountUnit},</if>
- <if test="expireTime != null">#{expireTime},</if>
- <if test="userId != null">#{userId},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="tare != null">#{tare},</if>
- </trim>
- </insert>
- <update id="updateHxpChemicalJoinCabinet" parameterType="com.zd.chemical.domain.HxpChemicalJoinCabinet">
- update hxp_chemical_join_cabinet
- <trim prefix="SET" suffixOverrides=",">
- <if test="chemicalId != null">chemical_id = #{chemicalId},</if>
- <if test="cabinetId != null">cabinet_id = #{cabinetId},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="status != null">status = #{status},</if>
- </trim>
- where id = #{id}
- </update>
- <update id="updateExpiredByIds">
- update hxp_chemical_join_cabinet set status = 4 where id in
- <foreach item="id" collection="list" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateChemicalJoinCabinetByExpired">
- update hxp_chemical_join_cabinet set status = 4 where status != 2 and status != 4 and date_format(expire_time,'%Y-%m-%d') < date_format(now(),'%Y-%m-%d')
- </update>
- <delete id="deleteHxpChemicalJoinCabinetById" parameterType="Long">
- delete from hxp_chemical_join_cabinet where id = #{id}
- </delete>
- <delete id="deleteHxpChemicalJoinCabinetByIds" parameterType="String">
- delete from hxp_chemical_join_cabinet where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <delete id="delByChemical" parameterType="String">
- delete from hxp_chemical_join_cabinet where chemical_id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|