| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <?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.airbottle.mapper.QpTaskMapper">
- <resultMap type="com.zd.airbottle.domain.vo.QpTaskVO" id="QpTaskResult">
- <result property="id" column="id"/>
- <result property="location" column="location"/>
- <result property="locationId" column="location_id"/>
- <result property="userId" column="user_id"/>
- <result property="userName" column="user_name"/>
- <result property="phone" column="phone"/>
- <result property="deptId" column="dept_id"/>
- <result property="deptName" column="dept_name"/>
- <result property="type" column="type"/>
- <result property="createTime" column="create_time"/>
- </resultMap>
- <resultMap type="com.zd.airbottle.domain.vo.QpAirGoodsConfigRelationVo" id="QpAirGoodsConfigRelationVo">
- </resultMap>
- <sql id="selectQpTaskVo">
- select id,
- location,
- location_id,
- user_id,
- user_name,
- phone,
- dept_id,
- dept_name,
- type,
- create_time
- from qp_task
- </sql>
- <sql id="selectQpTaskListVo">
- select t.id,
- t.location,
- t.location_id,
- t.user_id,
- t.user_name,
- t.phone,
- t.dept_id,
- t.dept_name,
- t.type,
- t.create_time,
- (select f.name
- from lab_build_floor f
- where f.type = 1
- and f.id = (
- select f.parent_id
- from lab_build_floor f
- where f.id =
- (select bfl.build_id
- from lab_build_floor_layout bfl
- where bfl.sub_id = t.location_id))) campus,/**校区**/
- (select f.`name`
- from lab_build_floor f
- where f.type = 2
- and f.id =
- (select bfl.build_id
- from lab_build_floor_layout bfl
- where bfl.sub_id = t.location_id)) building,/**楼栋*/
- (select bfl.room_num
- from lab_build_floor_layout bfl
- where bfl.sub_id = t.location_id) room,/*房间号**/
- (select COALESCE(sum(bottle_number), 0)
- from qp_task_detail d
- where d.task_id = t.id) applyNum, /**申请总数**/
- (select count(1)
- from qp_bottle_storage st
- where st.task_id = t.id
- and st.air_status = 0) storageNum, /** 入库总数 **/
- (select count(1)
- from qp_bottle_storage st
- where st.task_id = t.id
- and st.air_status = 1) refuseNum, /** 拒收总数 **/
- (select COALESCE(sum(bottle_number), 0)
- from qp_task_detail td
- where td.task_id = t.id
- and qp_status = 0) wpsNum,/** 未派送总数 **/
- ((select ifnull((SELECT sum(td.bottle_number)
- FROM qp_task_detail td
- WHERE td.task_id = t.id
- AND qp_status = 1), 0)
- from dual) - (select count(1) from qp_bottle_storage where task_id = t.id)) drkNum /** 待入库总数 **/
- from qp_task as t
- LEFT JOIN sys_dept d on t.dept_id = d.dept_id
- LEFT JOIN sys_user u on t.user_id = u.user_id
- </sql>
- <select id="selectQpTaskList" parameterType="com.zd.airbottle.domain.vo.QpTaskVO" resultMap="QpTaskResult">
- <include refid="selectQpTaskListVo"/>
- <where>
- <if test="searchValue != null and searchValue != ''">
- and ( t.user_name like concat('%', #{searchValue}, '%')
- or t.phone like concat('%', #{searchValue}, '%')
- or t.location like concat('%', #{searchValue}, '%') )
- </if>
- <if test="location != null and location != ''">and t.location like concat('%', #{location}, '%')</if>
- <if test="locationId != null ">and t.location_id = #{locationId}</if>
- <if test="userId != null ">and t.user_id = #{userId}</if>
- <if test="userName != null and userName != ''">and t.user_name like concat('%', #{userName}, '%')</if>
- <if test="phone != null and phone != ''">and t.phone = #{phone}</if>
- <if test="deptId != null ">and t.dept_id = #{deptId}</if>
- <if test="deptName != null and deptName != ''">and t.dept_name like concat('%', #{deptName}, '%')</if>
- <if test="type != null ">and t.type = #{type}</if>
- <if test="createTime != null">and
- DATE_FORMAT(t.create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d')
- </if>
- <if test="startTime != null and startTime != ''"><!-- 开始时间检索 -->
- AND DATE_FORMAT(t.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
- AND DATE_FORMAT(t.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- <if test="ids !=null">
- AND t.id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- </where>
- order by create_time desc
- </select>
- <select id="selectQpTaskById" resultMap="QpTaskResult">
- <include refid="selectQpTaskListVo"/>
- where id = #{id}
- </select>
- <insert id="insertQpTask" parameterType="com.zd.airbottle.domain.QpTask" useGeneratedKeys="true" keyProperty="id">
- insert into qp_task
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="location != null">location,</if>
- <if test="locationId != null">location_id,</if>
- <if test="userId != null">user_id,</if>
- <if test="userName != null">user_name,</if>
- <if test="phone != null">phone,</if>
- <if test="deptId != null">dept_id,</if>
- <if test="deptName != null">dept_name,</if>
- <if test="type != null">type,</if>
- <if test="createTime != null">create_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="location != null">#{location},</if>
- <if test="locationId != null">#{locationId},</if>
- <if test="userId != null">#{userId},</if>
- <if test="userName != null">#{userName},</if>
- <if test="phone != null">#{phone},</if>
- <if test="deptId != null">#{deptId},</if>
- <if test="deptName != null">#{deptName},</if>
- <if test="type != null">#{type},</if>
- <if test="createTime != null">#{createTime},</if>
- </trim>
- </insert>
- <update id="updateQpTask" parameterType="com.zd.airbottle.domain.QpTask">
- update qp_task
- <trim prefix="SET" suffixOverrides=",">
- <if test="location != null">location = #{location},</if>
- <if test="locationId != null">location_id = #{locationId},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="userName != null">user_name = #{userName},</if>
- <if test="phone != null">phone = #{phone},</if>
- <if test="deptId != null">dept_id = #{deptId},</if>
- <if test="deptName != null">dept_name = #{deptName},</if>
- <if test="type != null">type = #{type},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteQpTaskById">
- delete
- from qp_task
- where id = #{id}
- </delete>
- <delete id="deleteQpTaskByIds">
- delete from qp_task where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!-- 小程序待办事项时间分组 -->
- <select id="selectQpTaskListOrderByDate" parameterType="com.zd.airbottle.domain.vo.QpTaskVO"
- resultMap="QpTaskResult">
- select create_time createTimeApp, create_time as strTime
- from (select date_format(ta.create_time, '%Y-%m-%d') create_time
- from qp_task ta,
- qp_task_detail td
- where ta.id = td.task_id
- and td.is_dispose = 0
- and td.dispose_userid is null
- and td.supplier_id = #{companyId}
- GROUP BY date_format(ta.create_time, '%Y-%m-%d')
- UNION ALL
- select date_format(bs.create_time, '%Y-%m-%d') create_time
- from qp_bottle_storage bs,
- qp_task_detail td
- where bs.air_status = 1
- and bs.rejection_userid is null
- and bs.task_detail_id = td.id
- and td.supplier_id = #{companyId}
- GROUP BY date_format(bs.create_time, '%Y-%m-%d')
- UNION ALL
- select date_format(bso.create_time, '%Y-%m-%d') create_time
- from qp_bottle_storage_out bso,
- qp_bottle_storage bs,
- qp_task_detail td
- where bso.storage_id = bs.id
- and bs.task_detail_id = td.id
- and bso.out_status = 0
- and td.supplier_id = #{companyId}
- GROUP BY date_format(bso.create_time, '%Y-%m-%d')) t
- GROUP BY t.create_time
- order by t.create_time desc
- </select>
- <!-- 小程序供气回收记录时间分组 -->
- <select id="selectQpTaskListOrderByDateReclaim" parameterType="com.zd.airbottle.domain.vo.QpTaskVO"
- resultMap="QpTaskResult">
- select create_time createTimeApp,
- create_time
- from (
- select date_format(ta.create_time,'%Y-%m-%d') create_time from qp_task ta,qp_task_detail td
- where ta.id=td.task_id
- <if test="companyId !=null ">and td.supplier_id=#{companyId}</if>
- <if test="remarkStatus==0 ">and td.is_dispose=0</if> <!-- 未处理-->
- <if test="remarkStatus==1 ">and td.is_dispose=1</if> <!-- 已处理-->
- GROUP BY date_format(ta.create_time,'%Y-%m-%d')
- UNION ALL
- select date_format(bs.create_time,'%Y-%m-%d') create_time from qp_bottle_storage bs,qp_task_detail td
- where bs.task_detail_id=td.id
- <if test="companyId !=null ">and td.supplier_id=#{companyId}</if>
- <if test="remarkStatus==0 ">and bs.air_status=1 and rejection_userid is null</if> <!-- 未处理-->
- <if test="remarkStatus==1 ">and bs.air_status=1 and rejection_userid is not null</if> <!-- 已处理-->
- GROUP BY date_format(bs.create_time,'%Y-%m-%d')
- UNION ALL
- select date_format(bso.create_time,'%Y-%m-%d') create_time from qp_bottle_storage_out bso,qp_bottle_storage
- bs,qp_task_detail td
- where bso.storage_id=bs.id and bs.task_detail_id=td.id and bso.out_status = 0
- <if test="companyId !=null ">and td.supplier_id=#{companyId}</if>
- <if test="remarkStatus==0 ">and bso.out_status=0</if> <!-- 未处理-->
- <if test="remarkStatus==1 ">and (bso.out_status=2 or bso.out_status=1)</if> <!-- 已处理-->
- GROUP BY date_format(bso.create_time,'%Y-%m-%d')
- ) t GROUP BY t.create_time order by t.create_time desc
- </select>
- <select id="getApplyList" resultType="com.zd.airbottle.domain.QpTask">
- <include refid="selectQpTaskVo"/>
- <where>
- type=1
- <if test="applyName != null and applyName != ''">
- and ( location like concat('%', #{applyName}, '%')
- or user_name like concat('%', #{applyName}, '%')
- or phone like concat('%', #{applyName}, '%')
- )
- </if>
- <if test="applyTime != null">and DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(#{applyTime},'%Y-%m-%d')
- </if>
- </where>
- order by create_time desc
- </select>
- <!-- 实验室信息关联查询 -->
- <select id="selectQpTaskBySubjectRelation" parameterType="com.zd.airbottle.domain.vo.QpTaskVO"
- resultMap="QpTaskResult">
- select
- ta.id,ta.create_time,
- (select f.name
- from lab_build_floor f
- where f.type = 1
- and f.id = (
- select f.parent_id
- from lab_build_floor f
- where f.id =
- (select bfl.build_id
- from lab_build_floor_layout bfl
- where bfl.sub_id = ta.location_id)))
- campus,
- (select f.`name`
- from lab_build_floor f
- where f.type = 2
- and f.id =
- (select bfl.build_id
- from lab_build_floor_layout bfl
- where bfl.sub_id = ta.location_id))
- building,
- (select bfl.room_num
- from lab_build_floor_layout bfl
- where bfl.sub_id = ta.location_id)
- room
- from qp_task ta where 1=1
- <if test="id != null">and ta.id = #{id}</if>
- <if test="createTime != null">and date_format(ta.create_time,'%Y-%m-%d') = date_format(
- #{createTime},'%Y-%m-%d')
- </if>
- <if test="companyId != null">and (ta.id in (select td.task_id from qp_task_detail td where
- td.supplier_id=#{companyId}))
- </if>
- <if test="isDispose != null">and (ta.id in (select td.task_id from qp_task_detail td where
- td.is_dispose=#{isDispose}
- <if test="companyId != null">
- and td.supplier_id=#{companyId}) )
- </if>
- </if>
- </select>
- <!-- 气瓶使用记录 按照实验室分组 -->
- <select id="selectUseRecord" parameterType="com.zd.airbottle.domain.vo.QpTaskVO" resultMap="QpTaskResult">
- select
- ta.location,ta.location_id,
- (select l.room room from lab_subject s,lab_subject_layout l where s.layout_id =l.id and s.id=ta.location_id)
- room
- from qp_bottle_storage bs
- left JOIN qp_task ta on ta.id = bs.task_id
- left join qp_task_detail td on td.task_id=ta.id
- left JOIN qp_use_record ur on ur.storage_id=bs.id
- where bs.air_status=0 and (bs.storage_status=1 or bs.storage_status=2 )
- <if test="companyId != null">td.supplier_id=#{companyId}</if>
- <if test="userId != null">and ta.user_id=#{userId}</if>
- GROUP BY ta.location,ta.location_id
- </select>
- <!-- 查询实验室下的气瓶使用信息 -->
- <select id="selectUseRecordBySubjectId" parameterType="com.zd.airbottle.domain.vo.QpTaskVO"
- resultMap="QpAirGoodsConfigRelationVo">
- select
- bs.id,qtd.task_id,qtd.bottle_number,qab.air_name,bs.id bottle_storage_id,
- qps.company_name,qab.air_constituents,agc.name specValue,ta.location,
- bs.current_pressure pressure,agc.name configName,
- (select u.back_time from qp_use_record u where id=(select max(id) from qp_use_record where storage_id=bs.id ) )
- back_time,
- (select u.use_time from qp_use_record u where id=(select max(id) from qp_use_record where storage_id=bs.id ) )
- use_time
- from qp_bottle_storage bs
- INNER JOIN qp_task ta on ta.id = bs.task_id
- inner join qp_task_detail qtd on qtd.task_id =ta.id and qtd.id=bs.task_detail_id
- inner join qp_air_bottle_config abc on abc.id=qtd.air_bottle_config_id
- INNER JOIN qp_air_bottle qab on qab.id=abc.bottle_id
- INNER JOIN qp_supplier qps on qps.id = qab.supplier_id
- inner join qp_air_goods_config agc on agc.id=abc.config_id
- where bs.air_status=0 and (bs.storage_status=1 or bs.storage_status=2) /**已入库 、闲置、使用中***/
- <if test="locationId != null">and ta.location_id = #{locationId}</if>
- <if test="userId != null">and ta.user_id = #{userId}</if>
- order by bs.create_time desc
- </select>
- <!--获取当前登录用户的申请记录 -->
- <select id="selectQpTaskListCount" parameterType="com.zd.airbottle.domain.vo.QpTaskVO" resultMap="QpTaskResult">
- <include refid="selectQpTaskListVo"/>
- <where>
- <if test="userId != null ">and t.user_id = #{userId}</if>
- </where>
- order by create_time desc
- </select>
- <!-- 查询某个实验室配置的气瓶数量信息-->
- <select id="selectSubjectDetail" resultType="java.util.Map">
- select id, subject_id subjectId, bottle_total bottleTotal, bottle_user_total bottleUserTotal
- from lab_qp_subject_relation
- where subject_id = #{subjectId}
- </select>
- <select id="getByIds" resultType="com.zd.airbottle.domain.QpTask">
- <include refid="selectQpTaskListVo"/>
- <where>
- <if test="list != null and list.size>0">
- id in
- <foreach item="id" collection="list" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </where>
- </select>
- </mapper>
|