|
|
@@ -5,17 +5,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<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" />
|
|
|
+ <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">
|
|
|
@@ -25,69 +25,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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
|
|
|
@@ -339,7 +276,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="endCreateTime != null and endCreateTime != ''"><!-- 申请结束时间 -->
|
|
|
AND date_format(ah.create_time,'%y%m%d') <= date_format(#{endCreateTime},'%y%m%d')
|
|
|
</if>
|
|
|
-
|
|
|
<if test="beginOverTime != null and beginOverTime != ''"><!-- 完成开始时间 -->
|
|
|
AND date_format(ah.over_time,'%y%m%d') >= date_format(#{beginOverTime},'%y%m%d')
|
|
|
</if>
|
|
|
@@ -352,8 +288,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</where>
|
|
|
GROUP BY ah.`id`
|
|
|
)xx ORDER BY xx.createTime DESC
|
|
|
-
|
|
|
-
|
|
|
</select>
|
|
|
|
|
|
<select id="getListByIds" resultMap="ActHxpapplyResult">
|
|
|
@@ -432,54 +366,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
)t1
|
|
|
GROUP BY t1.`chemical_id`
|
|
|
)x2 ON x1.chemical_id = x2.chemical_id
|
|
|
-
|
|
|
-
|
|
|
- <!-- 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.stockNum,0), x1.chemical_unit) restStock FROM (
|
|
|
SELECT cjc.`chemical_id`,SUM(s.usages-s.tare) stockNum, che.chemical_unit FROM hxp_stock s
|
|
|
@@ -595,49 +483,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
)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,CASE WHEN CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)))>0
|
|
|
- THEN CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0))) ELSE 0 END 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(cjc.chemical_amount-cjc.tare) stockNum FROM
|
|
|
- hxp_chemical_join_cabinet cjc
|
|
|
- <where>
|
|
|
- cjc.`status` IN(0,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 x1.cabinet_id cabinetId,CASE WHEN CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)))>0
|
|
|
THEN CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0))) ELSE 0 END 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`
|
|
|
@@ -688,8 +534,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
)x2 ON x1.cabinet_id = x2.cabinet_id
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
-
|
|
|
<select id="getRestStockByManyCabinetAndChemical" parameterType="com.zd.chemical.domain.vo.ActRestStockManySearch" resultType="com.zd.chemical.domain.vo.ActRestStockManyVo">
|
|
|
SELECT x1.chemical_id chemicalId,x1.cabinet_id cabinetId,CASE WHEN CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0)))>0
|
|
|
THEN CONCAT((IFNULL(x1.applyNum,0)-IFNULL(x2.stockNum,0))) ELSE 0 END restStock FROM (
|
|
|
@@ -743,42 +587,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
)x2 ON x1.chemical_id = x2.chemical_id AND 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>
|
|
|
-
|
|
|
+ <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>
|
|
|
+ <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>
|
|
|
|