| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788 |
- <?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.HxpStockMapper">
- <resultMap type="com.zd.chemical.domain.HxpStock" id="HxpStockResult">
- <result property="id" column="id"/>
- <result property="joinId" column="join_id"/>
- <result property="chemicalNum" column="chemical_num"/>
- <result property="userId" column="user_id"/>
- <result property="chemicalName" column="chemical_name"/>
- <result property="createBy" column="create_by"/>
- <result property="cabinetNum" column="cabinet_num"/>
- <result property="createTime" column="create_time"/>
- <result property="cabinetName" column="cabinet_name"/>
- <result property="updateBy" column="update_by"/>
- <result property="chemicalClassify" column="chemical_classify"/>
- <result property="updateTime" column="update_time"/>
- <result property="remark" column="remark"/>
- <result property="status" column="status"/>
- <result property="chemicalShape" column="chemical_shape"/>
- <result property="labelType" column="label_type"/>
- <result property="printCode" column="print_code"/>
- <result property="joinType" column="join_type"/>
- <result property="joinUserId" column="join_user_id"/>
- <result property="joinTime" column="join_time"/>
- <result property="expirationTime" column="expiration_time"/>
- <result property="measuringMethod" column="measuring_method"/>
- <result property="chemicalUnit" column="chemical_unit"/>
- <result property="verification" column="verification"/>
- <result property="anotherName" column="another_name"/>
- <result property="casNum" column="cas_num"/>
- <result property="factory" column="factory"/>
- <result property="purity" column="purity"/>
- <result property="joinOneUser" column="join_one_user"/>
- <result property="joinTwoUser" column="join_two_user"/>
- <result property="joinVideo" column="join_video"/>
- <result property="tagCode" column="tag_code"/>
- <result property="rfidCode" column="rfid_code"/>
- <result property="usages" column="usages"/>
- <result property="outUserId" column="out_user_id"/>
- <result property="outOneUser" column="out_one_user"/>
- <result property="outTwoUser" column="out_two_user"/>
- <result property="outTime" column="out_time"/>
- <result property="outUsages" column="out_usages"/>
- <result property="subId" column="sub_id"/>
- <result property="tare" column="tare"/>
- </resultMap>
- <sql id="selectHxpStockVo">
- select id,
- join_id,
- chemical_num,
- user_id,
- chemical_name,
- create_by,
- cabinet_num,
- create_time,
- cabinet_name,
- update_by,
- chemical_classify,
- update_time,
- remark,
- status,
- chemical_shape,
- label_type,
- print_code,
- join_type,
- join_user_id,
- join_time,
- expiration_time,
- measuring_method,
- chemical_unit,
- verification,
- another_name,
- cas_num,
- factory,
- purity,
- join_one_user,
- join_two_user,
- join_video,
- tag_code,
- rfid_code,
- usages,
- out_user_id,
- out_one_user,
- out_two_user,
- out_time,
- out_usages,
- sub_id,
- tare
- from hxp_stock
- </sql>
- <sql id="selectHxpStockListVo">
- select t.id,
- t.join_id,
- t.chemical_num,
- t.user_id,
- t.chemical_name,
- t.create_by,
- t.cabinet_num,
- t.create_time,
- t.cabinet_name,
- t.update_by,
- t.chemical_classify,
- t.update_time,
- t.remark,
- t.status,
- t.label_type,
- t.print_code,
- t.join_type,
- t.join_user_id,
- t.join_time,
- t.expiration_time,
- t.measuring_method,
- t.chemical_unit,
- t.verification,
- t.another_name,
- t.cas_num,
- t.factory,
- t.purity,
- t.join_one_user,
- t.join_two_user,
- t.join_video,
- t.tag_code,
- t.rfid_code,
- t.usages,
- t.out_user_id,
- t.out_one_user,
- t.out_two_user,
- t.out_time,
- t.out_usages,
- t.sub_id,
- t.tare,
- jc.chemical_amount,
- jc.chemical_amount_unit,
- s.safe_user_id,
- t.chemical_shape,
- ( select join_hazard_id from hxp_chemical where id = jc.chemical_id ) hazardId,
- (select ccf.classify_name from hxp_chemical_classify ccf where ccf.id = t.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 = jc.chemical_id
- ))) classifyAttribute
- from hxp_stock as t left join hxp_chemical_join_cabinet jc on jc.id = t.join_id
- left join lab_subject s on s.id = t.sub_id
- left join hxp_chemical che on jc.chemical_id = che.id
- </sql>
- <select id="selectHxpStockList" parameterType="com.zd.chemical.domain.HxpStock" resultMap="HxpStockResult">
- <include refid="selectHxpStockListVo"/>
- <where>
- <if test="id != null ">and t.id = #{id}</if>
- <if test="joinId != null ">and t.join_id = #{joinId}</if>
- <if test="chemicalNum != null and chemicalNum != ''">and t.chemical_num = #{chemicalNum}</if>
- <if test="userId != null ">and t.user_id = #{userId}</if>
- <if test="cabinetId != null">
- and jc.cabinet_id = #{cabinetId}
- </if>
- <if test="chemicalName != null and chemicalName != ''">
- and (t.chemical_name like concat('%', #{chemicalName}, '%')
- or t.another_name like concat('%', #{chemicalName}, '%')
- or che.chemical_name_char like concat(#{chemicalName}, '%')
- or che.another_name_char like concat(#{chemicalName}, '%')
- )
- </if>
- <if test="cabinetNum != null and cabinetNum != ''">and t.cabinet_num = #{cabinetNum}</if>
- <if test="cabinetName != null and cabinetName != ''">and t.cabinet_name like concat('%', #{cabinetName},
- '%')
- </if>
- <if test="chemicalClassify != null and chemicalClassify != ''">and t.chemical_classify =
- #{chemicalClassify}
- </if>
- <if test="status != null ">and t.status = #{status}</if>
- <if test="chemicalShape != null and chemicalShape != ''">and t.chemical_shape = #{chemicalShape}</if>
- <if test="labelType != null and labelType != ''">and t.label_type = #{labelType}</if>
- <if test="joinType != null ">and t.join_type = #{joinType}</if>
- <if test="joinUserId != null ">and t.join_user_id = #{joinUserId}</if>
- <if test="joinTime != null ">and t.join_time = #{joinTime}</if>
- <if test="expirationTime != null ">and t.expiration_time = #{expirationTime}</if>
- <if test="measuringMethod != null ">and t.measuring_method = #{measuringMethod}</if>
- <if test="chemicalUnit != null and chemicalUnit != ''">and chemical_unit = #{chemicalUnit}</if>
- <if test="verification != null ">and t.verification = #{verification}</if>
- <if test="anotherName != null and anotherName != ''">and t.another_name like concat('%', #{anotherName},
- '%')
- </if>
- <if test="casNum != null and casNum != ''">and t.cas_num = #{casNum}</if>
- <if test="factory != null and factory != ''">and t.factory = #{factory}</if>
- <if test="purity != null and purity != ''">and t.purity = #{purity}</if>
- <if test="joinOneUser != null ">and t.join_one_user = #{joinOneUser}</if>
- <if test="joinTwoUser != null ">and t.join_two_user = #{joinTwoUser}</if>
- <if test="tagCode != null and tagCode != ''">and t.tag_code = #{tagCode}</if>
- <if test="usages != null ">and t.usages = #{usages}</if>
- <if test="outUserId != null ">and t.out_user_id = #{outUserId}</if>
- <if test="outTime != null ">and t.out_time = #{outTime}</if>
- <if test="outUsages != null ">and t.out_usages = #{outUsages}</if>
- <if test="subId != null ">and t.sub_id = #{subId}</if>
- <if test="scanCode != null and scanCode != ''">
- and (t.tag_code = #{scanCode} or t.rfid_code = #{scanCode})
- </if>
- </where>
- </select>
- <select id="selectHxpStockById" parameterType="Long" resultMap="HxpStockResult">
- <include refid="selectHxpStockListVo"/>
- where t.id = #{id}
- </select>
- <select id="selectCountByTagCode" resultType="java.lang.Integer">
- select count(1)
- from hxp_stock
- where tag_code = #{tagCode}
- </select>
- <select id="selectHxpStockListDetail" parameterType="com.zd.chemical.domain.vo.HxpStockSearch"
- resultType="com.zd.chemical.domain.vo.HxpStockDetailVO">
- SELECT sk.id,(SELECT cjc.join_num FROM hxp_chemical_join_cabinet cjc WHERE cjc.id = sk.join_id) joinNum,
- sk.chemical_name chemicalName,
- (SELECT cl.cas_num FROM hxp_chemical_join_cabinet cjc,hxp_chemical cl WHERE cjc.id = sk.join_id AND cjc.chemical_id = cl.id) casNum,
- ct.cabinet_name cabinetName,
- CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = sk.`sub_id`),
- '-', (SELECT dt.dept_name FROM sys_dept dt,lab_subject st WHERE dt.dept_id = st.build_id AND st.id = sk.`sub_id`),
- '-',(SELECT bg.name FROM lab_building bg,lab_subject st WHERE bg.id = st.floor_id AND st.id = sk.`sub_id`),
- '-', (SELECT slt.room FROM lab_subject_layout slt, lab_subject st WHERE slt.id = st.layout_id AND st.id = sk.`sub_id`)) posi,
- (SELECT cc.classify_name FROM hxp_chemical_classify cc WHERE cc.id = sk.chemical_classify) classifyName,
- (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda,hxp_chemical_join_cabinet cjc,hxp_chemical cl
- WHERE cjc.id = sk.join_id AND cjc.chemical_id = cl.id AND dda.dict_type = 'hxp_classifyattribute' AND FIND_IN_SET(dda.dict_value, cl.classify_attribute)) classifyAttribute,
- IFNULL((SELECT CONCAT(cjc.chemical_amount, cjc.chemical_amount_unit)
- FROM hxp_chemical_join_cabinet cjc
- WHERE cjc.id = sk.join_id),
- '无') chemicalAmountUnit,
- IFNULL((SELECT CONCAT(cjc.tare, cjc.chemical_amount_unit)
- FROM hxp_chemical_join_cabinet cjc
- WHERE cjc.id = sk.join_id),
- '无') tareUnit,
- CASE WHEN sk.label_type = 1 THEN 'RFID' ELSE '二维码' END labelType,
- sk.tag_code tagCode,
- sk.expiration_time expirationTime,
- CONCAT(sk.usages-IFNULL(sk.tare,0), sk.chemical_unit) usages,
- CASE WHEN sk.status=2 OR sk.status=3 THEN CONCAT(0, sk.chemical_unit) ELSE
- CONCAT(sk.out_usages-IFNULL(sk.tare,0), sk.chemical_unit) END outUsages,
- CASE
- WHEN sk.status = 1 THEN '在库'
- ELSE CASE WHEN sk.status = 2 THEN '用结出库'
- else case when sk.status = 3 then '作废出库'
- else '已过期'
- end END END stockStatus,
- sk.join_time joinTime,
- sk.out_time outTime
- FROM hxp_stock sk LEFT JOIN hxp_chemical_join_cabinet cjc ON sk.join_id = cjc.id
- LEFT JOIN hxp_chemical cl ON cjc.chemical_id = cl.id
- LEFT JOIN hxp_cabinet ct ON ct.id = cjc.cabinet_id
- LEFT JOIN lab_subject st ON ct.sub_id = st.id
- <where>
- <if test="searchValue != null and searchValue != ''">
- 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="chemicalClassify != null">
- AND cl.chemical_classify = #{chemicalClassify}
- </if>
- <if test="labelType != null">
- AND sk.label_type = #{labelType}
- </if>
- <if test="deptId != null">
- AND st.dept_id = #{deptId}
- </if>
- <if test="cabinetId != null">
- AND cjc.cabinet_id = #{cabinetId}
- </if>
- <if test="status != null">
- AND sk.status = #{status}
- </if>
- <if test="classifyAttribute != null ">
- and FIND_IN_SET(#{classifyAttribute}, cl.classify_attribute)
- </if>
- <if test="joinTimeBegin != null">
- AND date_format(sk.join_time,'%Y-%m-%d') >= date_format(#{joinTimeBegin},'%Y-%m-%d')
- </if>
- <if test="joinTimeEnd != null">
- AND date_format(sk.join_time,'%Y-%m-%d') <= date_format(#{joinTimeEnd},'%Y-%m-%d')
- </if>
- <if test="outTimeBegin != null">
- AND date_format(sk.out_time,'%Y-%m-%d') >= date_format(#{outTimeBegin},'%Y-%m-%d')
- </if>
- <if test="outTimeEnd != null">
- AND date_format(sk.out_time,'%Y-%m-%d') <= date_format(#{outTimeEnd},'%Y-%m-%d')
- </if>
- <if test="ids!=null and ids.size > 0">
- AND sk.id IN
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- </where>
- order by sk.create_time desc
- </select>
- <select id="selectHxpStockListJoin" parameterType="com.zd.chemical.domain.vo.HxpStockSearch"
- resultType="com.zd.chemical.domain.vo.HxpStockJoinVO">
- SELECT sk.id,sk.join_time joinTime,
- (SELECT cjc.join_num FROM hxp_chemical_join_cabinet cjc WHERE cjc.id = sk.join_id) joinNum
- ,
- sk.chemical_name chemicalName,
- (SELECT cl.cas_num FROM hxp_chemical_join_cabinet cjc,hxp_chemical cl WHERE cjc.id = sk.join_id AND cjc.chemical_id = cl.id) casNum,
- (SELECT cc.classify_name FROM hxp_chemical_classify cc WHERE cc.id = sk.chemical_classify) classifyName,
- (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda,hxp_chemical_join_cabinet cjc,hxp_chemical cl
- WHERE cjc.id = sk.join_id AND cjc.chemical_id = cl.id AND dda.dict_type = 'hxp_classifyattribute' AND FIND_IN_SET(dda.dict_value, cl.classify_attribute)) classifyAttribute,
- CASE
- WHEN sk.chemical_shape = 1 THEN CONCAT('固体', '(', sk.chemical_unit, ')')
- ELSE CONCAT('液体', '(', sk.chemical_unit, ')') END chemicalShape,
- IFNULL((SELECT CONCAT(cjc.chemical_amount, cjc.chemical_amount_unit)
- FROM hxp_chemical_join_cabinet cjc
- WHERE cjc.id = sk.join_id),
- '无') chemicalAmountUnit,
- IFNULL((SELECT CONCAT(cjc.tare, cjc.chemical_amount_unit)
- FROM hxp_chemical_join_cabinet cjc
- WHERE cjc.id = sk.join_id),
- '无') tareUnit,
- CASE WHEN sk.label_type = 1 THEN 'RFID' ELSE '二维码' END labelType,
- sk.tag_code tagCode,
- ct.cabinet_name cabinetName,
- CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = sk.`sub_id`),
- '-', (SELECT dt.dept_name FROM sys_dept dt, lab_subject st WHERE dt.dept_id = st.build_id AND st.id = sk.`sub_id`),
- '-',(SELECT bg.name FROM lab_building bg,lab_subject st WHERE bg.id = st.floor_id AND st.id = sk.`sub_id`),
- '-', (SELECT slt.room FROM lab_subject_layout slt, lab_subject st WHERE slt.id = st.layout_id AND st.id = sk.`sub_id`)) posi,
- CASE WHEN sk.join_type = 1 THEN '称重' ELSE '录入' END joinType,
- CONCAT(sk.usages-IFNULL(sk.tare,0), sk.chemical_unit) usages,
- CONCAT(sk.out_usages-IFNULL(sk.tare,0), sk.chemical_unit) outUsages,
- CONCAT(ifnull((SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = sk.join_user_id), "")) operator,
- CONCAT(ifnull((SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = sk.join_one_user), ""),
- case when sk.join_two_user is not null then '、' else '' end,
- ifnull((SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = sk.join_two_user), "")) verify,
- sk.join_video as joinVideo,
- ll.close_lock_video
- FROM hxp_stock sk LEFT JOIN hxp_chemical_join_cabinet cjc ON sk.join_id = cjc.id
- LEFT JOIN hxp_chemical cl ON cjc.chemical_id = cl.id
- LEFT JOIN hxp_cabinet ct ON ct.id = cjc.cabinet_id
- LEFT JOIN lab_subject st ON ct.sub_id = st.id
- left join hxp_cabinetlock_log ll on sk.id = ll.stock_id and ll.operation_type = 1
- <where>
- <if test="searchValue != null and searchValue != ''">
- 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="chemicalClassify != null">
- AND cl.chemical_classify = #{chemicalClassify}
- </if>
- <if test="classifyAttribute != null ">
- and FIND_IN_SET(#{classifyAttribute}, cl.classify_attribute)
- </if>
- <if test="deptId != null">
- AND st.dept_id = #{deptId}
- </if>
- <if test="cabinetId != null">
- AND cjc.cabinet_id = #{cabinetId}
- </if>
- <if test="labelType != null ">
- AND sk.label_type = #{labelType}
- </if>
- <if test="joinTimeBegin != null">
- AND date_format(sk.join_time,'%Y-%m-%d') >= date_format(#{joinTimeBegin},'%Y-%m-%d')
- </if>
- <if test="joinTimeEnd != null">
- AND date_format(sk.join_time,'%Y-%m-%d') <= date_format(#{joinTimeEnd},'%Y-%m-%d')
- </if>
- <if test="ids!=null and ids.size > 0">
- AND sk.id IN
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="loginUserId!=null">
- and sk.join_user_id = #{loginUserId}
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- </where>
- order by sk.join_time desc
- </select>
- <select id="selectHxpStockListOut" parameterType="com.zd.chemical.domain.vo.HxpStockSearch"
- resultType="com.zd.chemical.domain.vo.HxpStockOutVO">
- SELECT sk.id,sk.out_time outTime,
- (SELECT cjc.join_num FROM hxp_chemical_join_cabinet cjc WHERE cjc.id = sk.join_id) joinNum,
- sk.chemical_name chemicalName,
- (SELECT cl.cas_num FROM hxp_chemical_join_cabinet cjc,hxp_chemical cl WHERE cjc.id = sk.join_id AND cjc.chemical_id = cl.id) casNum,
- (SELECT cc.classify_name FROM hxp_chemical_classify cc WHERE cc.id = sk.chemical_classify) classifyName,
- (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda,hxp_chemical_join_cabinet cjc,hxp_chemical cl
- WHERE cjc.id = sk.join_id AND cjc.chemical_id = cl.id and dda.dict_type = 'hxp_classifyattribute' AND FIND_IN_SET(dda.dict_value, cl.classify_attribute)) classifyAttribute,
- CASE
- WHEN sk.chemical_shape = 1 THEN CONCAT('固体', '(', sk.chemical_unit, ')')
- ELSE CONCAT('液体', '(', sk.chemical_unit, ')') END chemicalShape,
- IFNULL((SELECT CONCAT(cjc.chemical_amount, cjc.chemical_amount_unit)
- FROM hxp_chemical_join_cabinet cjc
- WHERE cjc.id = sk.join_id),
- '无') chemicalAmountUnit,
- IFNULL((SELECT CONCAT(cjc.tare, cjc.chemical_amount_unit)
- FROM hxp_chemical_join_cabinet cjc
- WHERE cjc.id = sk.join_id),
- '无') tareUnit,
- CASE WHEN sk.label_type = 1 THEN 'RFID' ELSE '二维码' END labelType,
- sk.tag_code tagCode,
- ct.cabinet_name cabinetName,
- CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = sk.`sub_id`),
- '-', (SELECT dt.dept_name FROM sys_dept dt, lab_subject st WHERE dt.dept_id = st.build_id AND st.id = sk.`sub_id`),
- '-',(SELECT bg.name FROM lab_building bg,lab_subject st WHERE bg.id = st.floor_id AND st.id = sk.`sub_id`),
- '-', (SELECT slt.room FROM lab_subject_layout slt, lab_subject st WHERE slt.id = st.layout_id AND st.id = sk.`sub_id`)) posi,
- CONCAT(sk.out_usages-IFNULL(sk.tare,0), sk.chemical_unit) outUsages,
- CASE WHEN sk.status = 2 THEN '用结出库' ELSE '作废出库' END stockStatus,
- CONCAT(ifnull((SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = sk.out_user_id), "")) operator,
- CONCAT(ifnull((SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = sk.out_one_user), ""),
- case when sk.out_two_user is not null then '、' else '' end,
- ifnull((SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = sk.out_two_user), "")) verify,
- ll.close_lock_video
- FROM hxp_stock sk LEFT JOIN hxp_chemical_join_cabinet cjc ON sk.join_id = cjc.id
- LEFT JOIN hxp_chemical cl ON cjc.chemical_id = cl.id
- LEFT JOIN hxp_cabinet ct ON ct.id = cjc.cabinet_id
- LEFT JOIN lab_subject st ON ct.sub_id = st.id
- left join hxp_cabinetlock_log ll on sk.id = ll.stock_id and ll.operation_type = 2
- <where>
- and sk.status IN (2, 3)
- <if test="searchValue != null and searchValue != ''">
- 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="chemicalClassify != null">
- AND cl.chemical_classify = #{chemicalClassify}
- </if>
- <if test="classifyAttribute != null ">
- and FIND_IN_SET(#{classifyAttribute}, cl.classify_attribute)
- </if>
- <if test="deptId != null">
- AND st.dept_id = #{deptId}
- </if>
- <if test="cabinetId != null">
- AND cjc.cabinet_id = #{cabinetId}
- </if>
- <if test="status != null">
- AND sk.status = #{status}
- </if>
- <if test="labelType != null">
- AND sk.label_type = #{labelType}
- </if>
- <if test="outTimeBegin != null">
- AND date_format(sk.out_time,'%Y-%m-%d') >= date_format(#{outTimeBegin},'%Y-%m-%d')
- </if>
- <if test="outTimeEnd != null">
- AND date_format(sk.out_time,'%Y-%m-%d') <= date_format(#{outTimeEnd},'%Y-%m-%d')
- </if>
- <if test="ids!=null and ids.size > 0">
- AND sk.id IN
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="loginUserId!=null">
- and sk.join_user_id = #{loginUserId}
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- </where>
- order by sk.out_time desc
- </select>
- <select id="selectByRfidCode" resultType="com.zd.chemical.domain.HxpStock">
- <include refid="selectHxpStockVo"/>
- where rfid_code = #{rfidCode} and status = 1
- limit 1
- </select>
- <select id="selectCountByRfidCode" resultType="java.lang.Integer">
- select count(1) from hxp_stock where rfid_code = #{rfidCode}
- <if test="id != null">
- and id != #{id}
- </if>
- </select>
- <select id="selectStockByExpired" resultType="com.zd.chemical.domain.vo.HxpStockVO">
- SELECT sk.id,
- sk.join_id,
- sk.chemical_num,
- sk.user_id,
- sk.chemical_name,
- sk.create_by,
- sk.cabinet_num,
- sk.create_time,
- sk.cabinet_name,
- sk.update_by,
- sk.chemical_classify,
- sk.update_time,
- sk.remark,
- sk.STATUS,
- sk.chemical_shape,
- sk.label_type,
- sk.print_code,
- sk.join_type,
- sk.join_user_id,
- sk.join_time,
- sk.expiration_time,
- sk.measuring_method,
- sk.chemical_unit,
- sk.verification,
- sk.another_name,
- sk.cas_num,
- sk.factory,
- sk.purity,
- sk.join_one_user,
- sk.join_two_user,
- sk.tag_code,
- sk.rfid_code,
- sk.usages,
- sk.out_user_id,
- sk.out_one_user,
- sk.out_two_user,
- sk.out_time,
- sk.out_usages,
- sk.sub_id,
- sk.tare,
- '1' expireStatus,
- st.`name` subName,
- st.safe_user_id as safeUserId
- FROM hxp_stock sk LEFT JOIN lab_subject st ON sk.sub_id = st.`id`
- WHERE sk.STATUS = 1 AND DATEDIFF(sk.expiration_time, NOW()) = 30
- UNION
- SELECT sk.id,
- sk.join_id,
- sk.chemical_num,
- sk.user_id,
- sk.chemical_name,
- sk.create_by,
- sk.cabinet_num,
- sk.create_time,
- sk.cabinet_name,
- sk.update_by,
- sk.chemical_classify,
- sk.update_time,
- sk.remark,
- sk.status,
- sk.chemical_shape,
- sk.label_type,
- sk.print_code,
- sk.join_type,
- sk.join_user_id,
- sk.join_time,
- sk.expiration_time,
- sk.measuring_method,
- sk.chemical_unit,
- sk.verification,
- sk.another_name,
- sk.cas_num,
- sk.factory,
- sk.purity,
- sk.join_one_user,
- sk.join_two_user,
- sk.tag_code,
- sk.rfid_code,
- sk.usages,
- sk.out_user_id,
- sk.out_one_user,
- sk.out_two_user,
- sk.out_time,
- sk.out_usages,
- sk.sub_id,
- sk.tare,
- '2' expireStatus,
- st.`name` subName,
- st.safe_user_id as safeUserId
- FROM hxp_stock sk LEFT JOIN lab_subject st ON sk.sub_id = st.`id`
- WHERE sk.status = 1 AND DATE_FORMAT(sk.expiration_time,'%Y-%m-%d') < DATE_FORMAT(NOW(),'%Y-%m-%d')
- </select>
- <insert id="insertHxpStock" parameterType="com.zd.chemical.domain.HxpStock" useGeneratedKeys="true"
- keyProperty="id">
- insert into hxp_stock
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="joinId != null">join_id,</if>
- <if test="chemicalNum != null">chemical_num,</if>
- <if test="userId != null">user_id,</if>
- <if test="chemicalName != null">chemical_name,</if>
- <if test="createBy != null and createBy != ''">create_by,</if>
- <if test="cabinetNum != null">cabinet_num,</if>
- <if test="createTime != null">create_time,</if>
- <if test="cabinetName != null">cabinet_name,</if>
- <if test="updateBy != null and updateBy != ''">update_by,</if>
- <if test="chemicalClassify != null">chemical_classify,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="status != null">status,</if>
- <if test="chemicalShape != null">chemical_shape,</if>
- <if test="labelType != null">label_type,</if>
- <if test="printCode != null">print_code,</if>
- <if test="joinType != null">join_type,</if>
- <if test="joinUserId != null">join_user_id,</if>
- <if test="joinTime != null">join_time,</if>
- <if test="expirationTime != null">expiration_time,</if>
- <if test="measuringMethod != null">measuring_method,</if>
- <if test="chemicalUnit != null and chemicalUnit != ''">chemical_unit,</if>
- <if test="verification != null">verification,</if>
- <if test="anotherName != null and anotherName != ''">another_name,</if>
- <if test="casNum != null and casNum != ''">cas_num,</if>
- <if test="factory != null and factory != ''">factory,</if>
- <if test="purity != null and purity != ''">purity,</if>
- <if test="joinOneUser != null">join_one_user,</if>
- <if test="joinTwoUser != null">join_two_user,</if>
- <if test="joinVideo != null">join_video,</if>
- <if test="tagCode != null">tag_code,</if>
- <if test="rfidCode != null">rfid_code,</if>
- <if test="usages != null">usages,</if>
- <if test="outUserId != null">out_user_id,</if>
- <if test="outOneUser != null">out_one_user,</if>
- <if test="outTwoUser != null">out_two_user,</if>
- <if test="outTime != null">out_time,</if>
- <if test="outUsages != null">out_usages,</if>
- <if test="subId != null">sub_id,</if>
- <if test="tare != null">tare,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="joinId != null">#{joinId},</if>
- <if test="chemicalNum != null">#{chemicalNum},</if>
- <if test="userId != null">#{userId},</if>
- <if test="chemicalName != null">#{chemicalName},</if>
- <if test="createBy != null and createBy != ''">#{createBy},</if>
- <if test="cabinetNum != null">#{cabinetNum},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="cabinetName != null">#{cabinetName},</if>
- <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
- <if test="chemicalClassify != null">#{chemicalClassify},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="status != null">#{status},</if>
- <if test="chemicalShape != null">#{chemicalShape},</if>
- <if test="labelType != null">#{labelType},</if>
- <if test="printCode != null">#{printCode},</if>
- <if test="joinType != null">#{joinType},</if>
- <if test="joinUserId != null">#{joinUserId},</if>
- <if test="joinTime != null">#{joinTime},</if>
- <if test="expirationTime != null">#{expirationTime},</if>
- <if test="measuringMethod != null">#{measuringMethod},</if>
- <if test="chemicalUnit != null and chemicalUnit != ''">#{chemicalUnit},</if>
- <if test="verification != null">#{verification},</if>
- <if test="anotherName != null and anotherName != ''">#{anotherName},</if>
- <if test="casNum != null and casNum != ''">#{casNum},</if>
- <if test="factory != null and factory != ''">#{factory},</if>
- <if test="purity != null and purity != ''">#{purity},</if>
- <if test="joinOneUser != null">#{joinOneUser},</if>
- <if test="joinTwoUser != null">#{joinTwoUser},</if>
- <if test="joinVideo != null">#{joinVideo},</if>
- <if test="tagCode != null">#{tagCode},</if>
- <if test="rfidCode != null">#{rfidCode},</if>
- <if test="usages != null">#{usages},</if>
- <if test="outUserId != null">#{outUserId},</if>
- <if test="outOneUser != null">#{outOneUser},</if>
- <if test="outTwoUser != null">#{outTwoUser},</if>
- <if test="outTime != null">#{outTime},</if>
- <if test="outUsages != null">#{outUsages},</if>
- <if test="subId != null">#{subId},</if>
- <if test="tare != null">#{tare},</if>
- </trim>
- </insert>
- <update id="updateHxpStock" parameterType="com.zd.chemical.domain.HxpStock">
- update hxp_stock
- <trim prefix="SET" suffixOverrides=",">
- <if test="joinId != null">join_id = #{joinId},</if>
- <if test="chemicalNum != null">chemical_num = #{chemicalNum},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="chemicalName != null">chemical_name = #{chemicalName},</if>
- <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
- <if test="cabinetNum != null">cabinet_num = #{cabinetNum},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="cabinetName != null">cabinet_name = #{cabinetName},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- <if test="chemicalClassify != null">chemical_classify = #{chemicalClassify},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="status != null">status = #{status},</if>
- <if test="chemicalShape != null">chemical_shape = #{chemicalShape},</if>
- <if test="labelType != null">label_type = #{labelType},</if>
- <if test="printCode != null">print_code = #{printCode},</if>
- <if test="joinType != null">join_type = #{joinType},</if>
- <if test="joinUserId != null">join_user_id = #{joinUserId},</if>
- <if test="joinTime != null">join_time = #{joinTime},</if>
- <if test="expirationTime != null">expiration_time = #{expirationTime},</if>
- <if test="measuringMethod != null">measuring_method = #{measuringMethod},</if>
- <if test="chemicalUnit != null and chemicalUnit != ''">chemical_unit = #{chemicalUnit},</if>
- <if test="verification != null">verification = #{verification},</if>
- <if test="anotherName != null and anotherName != ''">another_name = #{anotherName},</if>
- <if test="casNum != null and casNum != ''">cas_num = #{casNum},</if>
- <if test="factory != null and factory != ''">factory = #{factory},</if>
- <if test="purity != null and purity != ''">purity = #{purity},</if>
- <if test="joinOneUser != null">join_one_user = #{joinOneUser},</if>
- <if test="joinTwoUser != null">join_two_user = #{joinTwoUser},</if>
- <if test="joinVideo != null">join_video = #{joinVideo},</if>
- <if test="tagCode != null">tag_code = #{tagCode},</if>
- <if test="rfidCode != null">rfid_code = #{rfidCode},</if>
- <if test="usages != null">usages = #{usages},</if>
- <if test="outUserId != null">out_user_id = #{outUserId},</if>
- <if test="outOneUser != null">out_one_user = #{outOneUser},</if>
- <if test="outTwoUser != null">out_two_user = #{outTwoUser},</if>
- <if test="outTime != null">out_time = #{outTime},</if>
- <if test="outUsages != null">out_usages = #{outUsages},</if>
- <if test="subId != null">sub_id = #{subId},</if>
- <if test="tare != null">tare = #{tare},</if>
- </trim>
- where id = #{id}
- </update>
- <update id="updateExpiredByIds">
- update hxp_stock set status = 4 where id in
- <foreach item="id" collection="list" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <delete id="deleteHxpStockById" parameterType="Long">
- delete
- from hxp_stock
- where id = #{id}
- </delete>
- <delete id="deleteHxpStockByIds" parameterType="String">
- delete from hxp_stock where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|