|
|
@@ -0,0 +1,628 @@
|
|
|
+<?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.ActHxpapplyMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.zd.chemical.domain.ActHxpapply" id="ActHxpapplyResult">
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="applyNum" column="apply_num" />
|
|
|
+ <result property="applyReason" column="apply_reason" />
|
|
|
+ <result property="subId" column="sub_id" />
|
|
|
+ <result property="applyStatus" column="apply_status" />
|
|
|
+ <result property="userId" column="user_id" />
|
|
|
+ <result property="createBy" column="create_by" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="updateBy" column="update_by" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
+ <result property="remark" column="remark" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectActHxpapplyVo">
|
|
|
+ select id, apply_num, apply_reason, sub_id, apply_status, user_id, create_by, create_time, update_by, update_time, remark from act_hxpapply
|
|
|
+ </sql>
|
|
|
+ <sql id="selectActHxpapplyListVo">
|
|
|
+ select t.id, t.apply_num, t.apply_reason, t.sub_id, t.apply_status, t.user_id, t.create_by, t.create_time, t.update_by, t.update_time, t.remark from act_hxpapply as t
|
|
|
+ </sql>
|
|
|
+ <select id="selectActHxpapplyList" parameterType="com.zd.chemical.domain.vo.ActHxpapplySearch" resultType="com.zd.chemical.domain.vo.ActHxpapplyListVo">
|
|
|
+ <!--SELECT xx.applyNum,xx.subscriber,xx.subName,xx.chemicalNames,xx.createTime,xx.overTime,xx.approvalContent,xx.approvalStatus,-->
|
|
|
+ <!--CASE WHEN xx.approvalStatus = 0 THEN-->
|
|
|
+ <!--(SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.currentApprover))-->
|
|
|
+ <!--ELSE ''-->
|
|
|
+ <!--END currentApprover,-->
|
|
|
+ <!--CASE WHEN xx.approvalStatus = 3 THEN ''-->
|
|
|
+ <!--ELSE (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.historyApprover))-->
|
|
|
+ <!--END historyApprover,-->
|
|
|
+ <!--xx.currentApprover currentApproverIds-->
|
|
|
+ <!--FROM (-->
|
|
|
+ <!--SELECT ah.`apply_num` applyNum,-->
|
|
|
+ <!--su.nick_name subscriber,-->
|
|
|
+ <!--st.`name` subName,-->
|
|
|
+ <!--GROUP_CONCAT(hd.chemical_name) chemicalNames,-->
|
|
|
+ <!--ah.`create_time` createTime,-->
|
|
|
+ <!--ak.`over_time` overTime,-->
|
|
|
+ <!--CASE WHEN ak.approval_status=0 THEN '审批中'-->
|
|
|
+ <!--ELSE CASE WHEN ak.approval_status=1 THEN '已通过'-->
|
|
|
+ <!--ELSE CASE WHEN ak.approval_status=2 THEN '已拒绝'-->
|
|
|
+ <!--ELSE '已撤销'-->
|
|
|
+ <!--END-->
|
|
|
+ <!--END-->
|
|
|
+ <!--END approvalContent,-->
|
|
|
+ <!--ak.approval_status approvalStatus,-->
|
|
|
+ <!--(SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND an.node_status = 0-->
|
|
|
+ <!--AND apk.approval_status=0 ORDER BY an.node_order ASC LIMIT 1) currentApprover,-->
|
|
|
+ <!--(SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND (an.node_status = 1 OR an.node_status = 2)-->
|
|
|
+ <!--AND (apk.approval_status=0 OR apk.approval_status=1) ORDER BY an.node_order DESC LIMIT 1) historyApprover-->
|
|
|
+ <!--FROM act_hxpapply ah LEFT JOIN sys_user su ON su.user_id = ah.`user_id`-->
|
|
|
+ <!--LEFT JOIN lab_subject st ON st.id = ah.`sub_id`-->
|
|
|
+ <!--LEFT JOIN act_hxpapply_detail hd ON hd.hxpapply_id = ah.id-->
|
|
|
+ <!--LEFT JOIN act_applytask ak ON ak.`task_id` = ah.`id`-->
|
|
|
+ <!--<where>-->
|
|
|
+ <!--ah.apply_status in(1,3)-->
|
|
|
+ <!--<if test="searchValue != null ">-->
|
|
|
+ <!--and (-->
|
|
|
+ <!--ah.apply_num like concat('%', #{searchValue}, '%') or-->
|
|
|
+ <!--su.nick_name like concat('%', #{searchValue}, '%') or-->
|
|
|
+ <!--hd.chemical_name like concat('%', #{searchValue}, '%') or-->
|
|
|
+ <!--st.name like concat('%', #{searchValue}, '%')-->
|
|
|
+ <!--)-->
|
|
|
+ <!--</if>-->
|
|
|
+ <!--<if test="approvalStatus != null ">-->
|
|
|
+ <!--and ak.approval_status = #{approvalStatus}-->
|
|
|
+ <!--</if>-->
|
|
|
+ <!--<if test="beginCreateTime != null and beginCreateTime != ''"><!– 申请开始时间 –>-->
|
|
|
+ <!--AND date_format(ak.create_time,'%y%m%d') >= date_format(#{beginCreateTime},'%y%m%d')-->
|
|
|
+ <!--</if>-->
|
|
|
+ <!--<if test="endCreateTime != null and endCreateTime != ''"><!– 申请结束时间 –>-->
|
|
|
+ <!--AND date_format(ak.create_time,'%y%m%d') <= date_format(#{endCreateTime},'%y%m%d')-->
|
|
|
+ <!--</if>-->
|
|
|
+
|
|
|
+ <!--<if test="beginOverTime != null and beginOverTime != ''"><!– 完成开始时间 –>-->
|
|
|
+ <!--AND date_format(ak.over_time,'%y%m%d') >= date_format(#{beginOverTime},'%y%m%d')-->
|
|
|
+ <!--</if>-->
|
|
|
+ <!--<if test="endOverTime != null and endOverTime != ''"><!– 完成结束时间 –>-->
|
|
|
+ <!--AND date_format(ak.over_time,'%y%m%d') <= date_format(#{endOverTime},'%y%m%d')-->
|
|
|
+ <!--</if>-->
|
|
|
+ <!--</where>-->
|
|
|
+ <!--GROUP BY ah.`id`-->
|
|
|
+ <!--)xx ORDER BY xx.createTime DESC-->
|
|
|
+
|
|
|
+
|
|
|
+ SELECT xx1.* FROM (
|
|
|
+ SELECT xx.id,xx.applyNum,xx.subscriber,xx.subName,xx.chemicalNames,xx.createTime,xx.overTime,xx.approvalContent,xx.approvalStatus,
|
|
|
+ CASE WHEN xx.approvalStatus = 0 THEN
|
|
|
+ (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.currentApprover))
|
|
|
+ ELSE ''
|
|
|
+ END currentApprover,
|
|
|
+ CASE WHEN xx.approvalStatus = 3 THEN ''
|
|
|
+ ELSE (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.historyApprover))
|
|
|
+ END historyApprover,
|
|
|
+ xx.currentApprover currentApproverIds,xx.userId
|
|
|
+ FROM (
|
|
|
+
|
|
|
+ SELECT ah.id,ah.`apply_num` applyNum,
|
|
|
+ su.nick_name subscriber,
|
|
|
+ st.`name` subName,
|
|
|
+ GROUP_CONCAT(hd.chemical_name ORDER BY hd.chemical_name DESC,'-申购量:',hd.apply_num,'g' SEPARATOR '; ') chemicalNames,
|
|
|
+ ah.`create_time` createTime,
|
|
|
+ ak.`over_time` overTime,
|
|
|
+ CASE WHEN ak.approval_status=0 THEN '审批中'
|
|
|
+ ELSE CASE WHEN ak.approval_status=1 THEN '已通过'
|
|
|
+ ELSE CASE WHEN ak.approval_status=2 THEN '已拒绝'
|
|
|
+ ELSE '已撤销'
|
|
|
+ END
|
|
|
+ END
|
|
|
+ END approvalContent,
|
|
|
+ ak.approval_status approvalStatus,
|
|
|
+ (SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND an.node_status = 0
|
|
|
+ AND apk.approval_status=0 ORDER BY an.node_order ASC LIMIT 1) currentApprover,
|
|
|
+ (SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND (an.node_status = 1 OR an.node_status = 2)
|
|
|
+ AND (apk.approval_status=0 OR apk.approval_status=1) ORDER BY an.node_order DESC LIMIT 1) historyApprover,
|
|
|
+ ah.user_id userId
|
|
|
+ FROM act_hxpapply ah LEFT JOIN sys_user su ON su.user_id = ah.`user_id`
|
|
|
+ LEFT JOIN lab_subject st ON st.id = ah.`sub_id`
|
|
|
+ LEFT JOIN act_hxpapply_detail hd ON hd.hxpapply_id = ah.id
|
|
|
+ LEFT JOIN act_applytask ak ON ak.`task_id` = ah.`id`
|
|
|
+ <where>
|
|
|
+ ah.apply_status in(1,3)
|
|
|
+ <if test="searchValue != null ">
|
|
|
+ and (
|
|
|
+ ah.apply_num like concat('%', #{searchValue}, '%') or
|
|
|
+ su.nick_name like concat('%', #{searchValue}, '%') or
|
|
|
+ hd.chemical_name like concat('%', #{searchValue}, '%') or
|
|
|
+ st.name like concat('%', #{searchValue}, '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="approvalStatus != null ">
|
|
|
+ and ak.approval_status = #{approvalStatus}
|
|
|
+ </if>
|
|
|
+ <if test="beginCreateTime != null and beginCreateTime != ''"><!-- 申请开始时间 -->
|
|
|
+ AND date_format(ak.create_time,'%y%m%d') >= date_format(#{beginCreateTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="endCreateTime != null and endCreateTime != ''"><!-- 申请结束时间 -->
|
|
|
+ AND date_format(ak.create_time,'%y%m%d') <= date_format(#{endCreateTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="beginOverTime != null and beginOverTime != ''"><!-- 完成开始时间 -->
|
|
|
+ AND date_format(ak.over_time,'%y%m%d') >= date_format(#{beginOverTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="endOverTime != null and endOverTime != ''"><!-- 完成结束时间 -->
|
|
|
+ AND date_format(ak.over_time,'%y%m%d') <= date_format(#{endOverTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId != ''"><!-- 创建人id -->
|
|
|
+ and ah.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY ah.`id`
|
|
|
+ )xx WHERE FIND_IN_SET(#{loginUserId},xx.currentApprover) ORDER BY xx.createTime DESC
|
|
|
+ )xx1
|
|
|
+ UNION
|
|
|
+ SELECT xx1.* FROM (
|
|
|
+ SELECT xx.id,xx.applyNum,xx.subscriber,xx.subName,xx.chemicalNames,xx.createTime,xx.overTime,xx.approvalContent,xx.approvalStatus,
|
|
|
+ CASE WHEN xx.approvalStatus = 0 THEN
|
|
|
+ (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.currentApprover))
|
|
|
+ ELSE ''
|
|
|
+ END currentApprover,
|
|
|
+ CASE WHEN xx.approvalStatus = 3 THEN ''
|
|
|
+ ELSE (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.historyApprover))
|
|
|
+ END historyApprover,
|
|
|
+ xx.currentApprover currentApproverIds,xx.userId
|
|
|
+ FROM (
|
|
|
+
|
|
|
+ SELECT ah.id,ah.`apply_num` applyNum,
|
|
|
+ su.nick_name subscriber,
|
|
|
+ st.`name` subName,
|
|
|
+ GROUP_CONCAT(hd.chemical_name ORDER BY hd.chemical_name DESC,'-申购量:',hd.apply_num,'g' SEPARATOR '; ') chemicalNames,
|
|
|
+ ah.`create_time` createTime,
|
|
|
+ ak.`over_time` overTime,
|
|
|
+ CASE WHEN ak.approval_status=0 THEN '审批中'
|
|
|
+ ELSE CASE WHEN ak.approval_status=1 THEN '已通过'
|
|
|
+ ELSE CASE WHEN ak.approval_status=2 THEN '已拒绝'
|
|
|
+ ELSE '已撤销'
|
|
|
+ END
|
|
|
+ END
|
|
|
+ END approvalContent,
|
|
|
+ ak.approval_status approvalStatus,
|
|
|
+ (SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND an.node_status = 0
|
|
|
+ AND apk.approval_status=0 ORDER BY an.node_order ASC LIMIT 1) currentApprover,
|
|
|
+ (SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND (an.node_status = 1 OR an.node_status = 2)
|
|
|
+ AND (apk.approval_status=0 OR apk.approval_status=1) ORDER BY an.node_order DESC LIMIT 1) historyApprover,
|
|
|
+ ah.user_id userId
|
|
|
+ FROM act_hxpapply ah LEFT JOIN sys_user su ON su.user_id = ah.`user_id`
|
|
|
+ LEFT JOIN lab_subject st ON st.id = ah.`sub_id`
|
|
|
+ LEFT JOIN act_hxpapply_detail hd ON hd.hxpapply_id = ah.id
|
|
|
+ LEFT JOIN act_applytask ak ON ak.`task_id` = ah.`id`
|
|
|
+ <where>
|
|
|
+ ah.apply_status in(1,3)
|
|
|
+ <if test="searchValue != null ">
|
|
|
+ and (
|
|
|
+ ah.apply_num like concat('%', #{searchValue}, '%') or
|
|
|
+ su.nick_name like concat('%', #{searchValue}, '%') or
|
|
|
+ hd.chemical_name like concat('%', #{searchValue}, '%') or
|
|
|
+ st.name like concat('%', #{searchValue}, '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="approvalStatus != null ">
|
|
|
+ and ak.approval_status = #{approvalStatus}
|
|
|
+ </if>
|
|
|
+ <if test="beginCreateTime != null and beginCreateTime != ''"><!-- 申请开始时间 -->
|
|
|
+ AND date_format(ak.create_time,'%y%m%d') >= date_format(#{beginCreateTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="endCreateTime != null and endCreateTime != ''"><!-- 申请结束时间 -->
|
|
|
+ AND date_format(ak.create_time,'%y%m%d') <= date_format(#{endCreateTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="beginOverTime != null and beginOverTime != ''"><!-- 完成开始时间 -->
|
|
|
+ AND date_format(ak.over_time,'%y%m%d') >= date_format(#{beginOverTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="endOverTime != null and endOverTime != ''"><!-- 完成结束时间 -->
|
|
|
+ AND date_format(ak.over_time,'%y%m%d') <= date_format(#{endOverTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId != ''"><!-- 创建人id -->
|
|
|
+ and ah.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY ah.`id`
|
|
|
+
|
|
|
+ )xx ORDER BY xx.createTime DESC
|
|
|
+ )xx1
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="draftsList" parameterType="com.zd.chemical.domain.vo.ActHxpapplySearch" resultType="com.zd.chemical.domain.vo.ActHxpapplyDraftsListVo">
|
|
|
+ SELECT xx.id,xx.applyNum,xx.subscriber,xx.subName,xx.chemicalNames,xx.createTime,xx.overTime,xx.approvalContent,xx.approvalStatus,
|
|
|
+ CASE WHEN xx.approvalStatus = 0 THEN
|
|
|
+ (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.currentApprover))
|
|
|
+ ELSE ''
|
|
|
+ END currentApprover,
|
|
|
+ CASE WHEN xx.approvalStatus = 3 THEN ''
|
|
|
+ ELSE (SELECT GROUP_CONCAT(ur.user_id,';',ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id,xx.historyApprover))
|
|
|
+ END historyApprover,
|
|
|
+ xx.currentApprover currentApproverIds
|
|
|
+ FROM (
|
|
|
+ SELECT ah.id,ah.`apply_num` applyNum,
|
|
|
+ su.nick_name subscriber,
|
|
|
+ st.`name` subName,
|
|
|
+ GROUP_CONCAT(hd.chemical_name,'-申购量:',hd.apply_num,'g' SEPARATOR '; ') chemicalNames,
|
|
|
+ ah.`create_time` createTime,
|
|
|
+ ak.`over_time` overTime,
|
|
|
+ CASE WHEN ak.approval_status=0 THEN '审批中'
|
|
|
+ ELSE CASE WHEN ak.approval_status=1 THEN '已通过'
|
|
|
+ ELSE CASE WHEN ak.approval_status=2 THEN '已拒绝'
|
|
|
+ ELSE '已撤销'
|
|
|
+ END
|
|
|
+ END
|
|
|
+ END approvalContent,
|
|
|
+ ak.approval_status approvalStatus,
|
|
|
+ (SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND an.node_status = 0
|
|
|
+ AND apk.approval_status=0 ORDER BY an.node_order ASC LIMIT 1) currentApprover,
|
|
|
+ (SELECT an.apply_user_ids FROM act_applytask apk,act_applytask_node an WHERE an.applytask_id = apk.id AND apk.id = ak.id AND (an.node_status = 1 OR an.node_status = 2)
|
|
|
+ AND (apk.approval_status=0 OR apk.approval_status=1) ORDER BY an.node_order DESC LIMIT 1) historyApprover
|
|
|
+ FROM act_hxpapply ah LEFT JOIN sys_user su ON su.user_id = ah.`user_id`
|
|
|
+ LEFT JOIN lab_subject st ON st.id = ah.`sub_id`
|
|
|
+ LEFT JOIN act_hxpapply_detail hd ON hd.hxpapply_id = ah.id
|
|
|
+ LEFT JOIN act_applytask ak ON ak.`task_id` = ah.`id`
|
|
|
+ <where>
|
|
|
+ ah.apply_status =2 and ah.user_id = #{loginUserId}
|
|
|
+ <if test="searchValue != null ">
|
|
|
+ and (
|
|
|
+ ah.apply_num like concat('%', #{searchValue}, '%') or
|
|
|
+ su.nick_name like concat('%', #{searchValue}, '%') or
|
|
|
+ hd.chemical_name like concat('%', #{searchValue}, '%') or
|
|
|
+ st.name like concat('%', #{searchValue}, '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="approvalStatus != null ">
|
|
|
+ and ak.approval_status = #{approvalStatus}
|
|
|
+ </if>
|
|
|
+ <if test="beginCreateTime != null and beginCreateTime != ''"><!-- 申请开始时间 -->
|
|
|
+ AND date_format(ak.create_time,'%y%m%d') >= date_format(#{beginCreateTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="endCreateTime != null and endCreateTime != ''"><!-- 申请结束时间 -->
|
|
|
+ AND date_format(ak.create_time,'%y%m%d') <= date_format(#{endCreateTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="beginOverTime != null and beginOverTime != ''"><!-- 完成开始时间 -->
|
|
|
+ AND date_format(ak.over_time,'%y%m%d') >= date_format(#{beginOverTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="endOverTime != null and endOverTime != ''"><!-- 完成结束时间 -->
|
|
|
+ AND date_format(ak.over_time,'%y%m%d') <= date_format(#{endOverTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId != ''"><!-- 创建人id -->
|
|
|
+ and ah.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY ah.`id`
|
|
|
+ )xx ORDER BY xx.createTime DESC
|
|
|
+
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getListByIds" resultMap="ActHxpapplyResult">
|
|
|
+ <include refid="selectActHxpapplyVo"/>
|
|
|
+ <where>
|
|
|
+ id in
|
|
|
+ <foreach item="id" collection="list" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectActHxpapplyById" resultType="com.zd.chemical.domain.vo.ActHxpapplyInfoVo">
|
|
|
+ select a.id, a.apply_num, a.apply_reason, a.sub_id, a.apply_status, a.user_id, a.create_by, a.create_time, a.update_by
|
|
|
+ , a.update_time, a.remark,
|
|
|
+ (select ur.nick_name from sys_user ur where ur.user_id = a.user_id) applyUserName,
|
|
|
+ st.name subName,st.dept_id deptId
|
|
|
+ from act_hxpapply a left join lab_subject st on st.id = a.sub_id
|
|
|
+ where a.id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getRestStock" resultType="java.util.Map">
|
|
|
+ SELECT x1.chemical_id chemicalId,CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)),'g') restStock FROM (
|
|
|
+ SELECT hd.`chemical_id`,IFNULL(SUM(hd.`apply_num`),0) applyNum FROM act_hxpapply ah LEFT JOIN act_hxpapply_detail hd ON ah.`id` = hd.`hxpapply_id`
|
|
|
+ LEFT JOIN act_applytask ak ON ah.`id` = ak.`task_id`
|
|
|
+ LEFT JOIN lab_subject st ON ah.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ ak.`approval_status`=1 AND hd.`tick_status`=1
|
|
|
+ <if test="deptId != null ">
|
|
|
+ and st.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="subId != null ">
|
|
|
+ and ah.sub_id = #{subId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ and hd.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetId != null ">
|
|
|
+ and hd.`cabinet_id` = #{cabinetId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY hd.`chemical_id`
|
|
|
+ )x1 LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT cjc.`chemical_id`,SUM(s.usages-s.tare) stockNum FROM hxp_stock s
|
|
|
+ LEFT JOIN hxp_chemical_join_cabinet cjc ON s.`join_id` = cjc.`id`
|
|
|
+ LEFT JOIN lab_subject st ON s.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ s.status = 1
|
|
|
+ <if test="deptId != null ">
|
|
|
+ and st.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="subId != null ">
|
|
|
+ and s.sub_id = #{subId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ and cjc.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetId != null ">
|
|
|
+ and cjc.`cabinet_id` = #{cabinetId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY cjc.`chemical_id`
|
|
|
+ )x2 ON x1.chemical_id = x2.chemical_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getRestStockClassif" resultType="com.zd.chemical.domain.vo.ActRestStockVo">
|
|
|
+ SELECT 1 chemicalId,CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)),'g') restStock FROM (
|
|
|
+ SELECT hd.`chemical_id`,IFNULL(SUM(hd.`apply_num`),0) applyNum FROM act_hxpapply ah LEFT JOIN act_hxpapply_detail hd ON ah.`id` = hd.`hxpapply_id`
|
|
|
+ LEFT JOIN act_applytask ak ON ah.`id` = ak.`task_id`
|
|
|
+ LEFT JOIN lab_subject st ON ah.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ ak.`approval_status`=1 AND hd.`tick_status`=1
|
|
|
+ <if test="deptId != null ">
|
|
|
+ AND st.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND hd.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY hd.`chemical_id`
|
|
|
+ )x1 LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT cjc.`chemical_id`,SUM(s.usages-s.tare) stockNum FROM hxp_stock s
|
|
|
+ LEFT JOIN hxp_chemical_join_cabinet cjc ON s.`join_id` = cjc.`id`
|
|
|
+ LEFT JOIN lab_subject st ON s.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ s.status = 1
|
|
|
+ <if test="deptId != null ">
|
|
|
+ AND st.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND cjc.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY cjc.`chemical_id`
|
|
|
+ )x2 ON x1.chemical_id = x2.chemical_id
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT 2 chemicalId,CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)),'g') restStock FROM (
|
|
|
+ SELECT hd.`chemical_id`,IFNULL(SUM(hd.`apply_num`),0) applyNum FROM act_hxpapply ah LEFT JOIN act_hxpapply_detail hd ON ah.`id` = hd.`hxpapply_id`
|
|
|
+ LEFT JOIN act_applytask ak ON ah.`id` = ak.`task_id`
|
|
|
+ LEFT JOIN lab_subject st ON ah.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ ak.`approval_status`=1 AND hd.`tick_status`=1
|
|
|
+
|
|
|
+ <if test="subId != null ">
|
|
|
+ AND ah.sub_id = #{subId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND hd.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY hd.`chemical_id`
|
|
|
+ )x1 LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT cjc.`chemical_id`,SUM(s.usages-s.tare) stockNum FROM hxp_stock s
|
|
|
+ LEFT JOIN hxp_chemical_join_cabinet cjc ON s.`join_id` = cjc.`id`
|
|
|
+ LEFT JOIN lab_subject st ON s.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ s.status = 1
|
|
|
+ <if test="subId != null ">
|
|
|
+ AND s.sub_id = #{subId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND cjc.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </where>
|
|
|
+ GROUP BY cjc.`chemical_id`
|
|
|
+ )x2 ON x1.chemical_id = x2.chemical_id
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT 3 chemicalId,CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)),'g') restStock FROM (
|
|
|
+ SELECT hd.`chemical_id`,IFNULL(SUM(hd.`apply_num`),0) applyNum FROM act_hxpapply ah LEFT JOIN act_hxpapply_detail hd ON ah.`id` = hd.`hxpapply_id`
|
|
|
+ LEFT JOIN act_applytask ak ON ah.`id` = ak.`task_id`
|
|
|
+ LEFT JOIN lab_subject st ON ah.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ ak.`approval_status`=1 AND hd.`tick_status`=1
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND hd.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetId != null ">
|
|
|
+ AND hd.`cabinet_id` = #{cabinetId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY hd.`chemical_id`
|
|
|
+ )x1 LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT cjc.`chemical_id`,SUM(s.usages-s.tare) stockNum FROM hxp_stock s
|
|
|
+ LEFT JOIN hxp_chemical_join_cabinet cjc ON s.`join_id` = cjc.`id`
|
|
|
+ LEFT JOIN lab_subject st ON s.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ s.status = 1
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND cjc.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetId != null ">
|
|
|
+ AND cjc.`cabinet_id` = #{cabinetId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY cjc.`chemical_id`
|
|
|
+ )x2 ON x1.chemical_id = x2.chemical_id
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT 4 chemicalId,CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)),'g') restStock FROM (
|
|
|
+ SELECT hd.`chemical_id`,IFNULL(SUM(hd.`apply_num`),0) applyNum FROM act_hxpapply ah LEFT JOIN act_hxpapply_detail hd ON ah.`id` = hd.`hxpapply_id`
|
|
|
+ LEFT JOIN act_applytask ak ON ah.`id` = ak.`task_id`
|
|
|
+ LEFT JOIN lab_subject st ON ah.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ ak.`approval_status`=1 AND hd.`tick_status`=1
|
|
|
+ <if test="deptId != null ">
|
|
|
+ AND st.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="subId != null ">
|
|
|
+ AND ah.sub_id = #{subId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND hd.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetId != null ">
|
|
|
+ AND hd.`cabinet_id` = #{cabinetId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY hd.`chemical_id`
|
|
|
+ )x1 LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT cjc.`chemical_id`,SUM(s.usages-s.tare) stockNum FROM hxp_stock s
|
|
|
+ LEFT JOIN hxp_chemical_join_cabinet cjc ON s.`join_id` = cjc.`id`
|
|
|
+ LEFT JOIN lab_subject st ON s.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ s.status = 1
|
|
|
+ <if test="deptId != null ">
|
|
|
+ AND st.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="subId != null ">
|
|
|
+ AND s.sub_id = #{subId}
|
|
|
+ </if>
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ AND cjc.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetId != null ">
|
|
|
+ AND cjc.`cabinet_id` = #{cabinetId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY cjc.`chemical_id`
|
|
|
+ )x2 ON x1.chemical_id = x2.chemical_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getRestStockByManyCabinet" parameterType="com.zd.chemical.domain.vo.ActRestStockManySearch" resultType="com.zd.chemical.domain.vo.ActRestStockManyVo">
|
|
|
+ SELECT x1.cabinet_id cabinetId,CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0))) restStock FROM (
|
|
|
+ SELECT hd.`cabinet_id`,IFNULL(SUM(hd.`apply_num`),0) applyNum FROM act_hxpapply ah LEFT JOIN act_hxpapply_detail hd ON ah.`id` = hd.`hxpapply_id`
|
|
|
+ LEFT JOIN act_applytask ak ON ah.`id` = ak.`task_id`
|
|
|
+ LEFT JOIN lab_subject st ON ah.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ ak.`approval_status`=1 AND hd.`tick_status`=1
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ and hd.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="cabinetIds != null ">
|
|
|
+ and hd.`cabinet_id` in
|
|
|
+ <foreach item="id" collection="cabinetIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY hd.`cabinet_id`
|
|
|
+ )x1 LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT cjc.`cabinet_id`,SUM(s.usages-s.tare) stockNum FROM hxp_stock s
|
|
|
+ LEFT JOIN hxp_chemical_join_cabinet cjc ON s.`join_id` = cjc.`id`
|
|
|
+ LEFT JOIN lab_subject st ON s.sub_id = st.id
|
|
|
+ <where>
|
|
|
+ s.status = 1
|
|
|
+ <if test="chemicalId != null ">
|
|
|
+ and cjc.`chemical_id` = #{chemicalId}
|
|
|
+ </if>
|
|
|
+ <if test="cabinetIds != null ">
|
|
|
+ and cjc.`cabinet_id` in
|
|
|
+ <foreach item="id" collection="cabinetIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY cjc.`cabinet_id`
|
|
|
+ )x2 ON x1.cabinet_id = x2.cabinet_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <insert id="insertActHxpapply" parameterType="com.zd.chemical.domain.ActHxpapply" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into act_hxpapply
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="applyNum != null">apply_num,</if>
|
|
|
+
|
|
|
+ <if test="applyReason != null">apply_reason,</if>
|
|
|
+
|
|
|
+ <if test="subId != null">sub_id,</if>
|
|
|
+
|
|
|
+ <if test="applyStatus != null">apply_status,</if>
|
|
|
+
|
|
|
+ <if test="userId != null">user_id,</if>
|
|
|
+
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+
|
|
|
+ <if test="updateBy != null">update_by,</if>
|
|
|
+
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
+
|
|
|
+ <if test="remark != null">remark,</if>
|
|
|
+
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="applyNum != null">#{applyNum},</if>
|
|
|
+ <if test="applyReason != null">#{applyReason},</if>
|
|
|
+ <if test="subId != null">#{subId},</if>
|
|
|
+ <if test="applyStatus != null">#{applyStatus},</if>
|
|
|
+ <if test="userId != null">#{userId},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="updateBy != null">#{updateBy},</if>
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
+ <if test="remark != null">#{remark},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateActHxpapply" parameterType="com.zd.chemical.domain.ActHxpapply">
|
|
|
+ update act_hxpapply
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="applyNum != null">apply_num = #{applyNum},</if>
|
|
|
+ <if test="applyReason != null">apply_reason = #{applyReason},</if>
|
|
|
+ <if test="subId != null">sub_id = #{subId},</if>
|
|
|
+ <if test="applyStatus != null">apply_status = #{applyStatus},</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="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteActHxpapplyById">
|
|
|
+ delete from act_hxpapply where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteActHxpapplyByIds">
|
|
|
+ delete from act_hxpapply where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+</mapper>
|