| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?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.yunfeiyun.agmp.fms.mapper.FmsTaskpickMapper">
- <sql id="selectFmsTaskpickVo">
- select taskpickId, taskId, pickArea, pickWeight, pickDate, pickRemark, pickNo from FmsTaskpick
- </sql>
- <select id="selectFmsTaskpickList" parameterType="FmsTaskPickListReqVo" resultType="FmsTaskPickListResVo">
- SELECT c.cropName, c.cropType, t.taskNo, t.taskId,r.resUrl as cropPreview, p.planNo, l.landName, b.blockName, p.planArea, i.pickWeight, i.pickNo, t.taskPlanstartdate, t.taskPlanenddate, s.taskrcdHour, t.taskCreateddate, t.taskAudittype, t.taskStatus, t.taskContent, t.taskAuditor,
- su.userName as taskManagername
- FROM
- FmsTask t
- LEFT JOIN FmsCrop c ON t.cropId = c.cropId
- LEFT JOIN FmsLand l ON t.landId = l.landId
- LEFT JOIN FmsBlock b ON t.blockId = b.blockId
- LEFT JOIN FmsPlan p ON t.planId = p.planId
- LEFT JOIN FmsTaskpick i ON t.taskId = i.taskId
- LEFT JOIN FmsTaskrcd s ON t.taskId = s.taskId and s.taskrcdAuditstatus = 2
- LEFT JOIN SysUser su on su.userId = t.taskManager
- LEFT JOIN
- (select * from SysRes where resMediatype = '1' and resBiztype = 'CROP')
- r on r.resBusId = c.cropId
- <where>
- <if test="cropId != null and cropId != ''">and t.cropId = #{cropId}</if>
- <if test="landId != null and landId != ''">and t.landId = #{landId}</if>
- <if test="blockId != null and blockId != ''">and t.blockId = #{blockId}</if>
- <if test="planId != null and planId != ''">and t.planId = #{planId}</if>
- <if test="taskId != null and taskId != ''">and t.taskId = #{taskId}</if>
- <if test="taskNo != null and taskNo != ''">and t.taskNo like concat('%', #{taskNo}, '%')</if>
- <if test="planNo != null and planNo != ''">and p.planNo like concat('%', #{planNo}, '%')</if>
- <if test="pickNo != null and pickNo != ''">and i.pickNo like concat('%', #{pickNo}, '%')</if>
- <if test="taskManagername != null and taskManagername !=''">and t.taskManagername like concat('%', #{taskManagername}, '%')</if>
- <if test="taskStatus != null and taskStatus != ''">and t.taskStatus = #{taskStatus}</if>
- <if test="taskAudittype != null and taskAudittype != ''">and t.taskAudittype = #{taskAudittype}</if>
- <if test="taskPlanstartdate != null and taskPlanstartdate != '' and taskPlanenddate != null and taskPlanenddate != ''">
- and t.taskPlanstartdate between #{taskPlanstartdate} and #{taskPlanenddate}
- </if>
- <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
- AND t.blockId in
- <foreach collection="blockIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- and t.tid = #{tid}
- and t.taskType = -1
- </where>
- </select>
- <select id="selectFmsTaskPickStockList" parameterType="String" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsTaskPickStockListResVo">
- SELECT
- t.cropId,c.cropName,c.cropType,sum(tp.pickWeight) as pickWeight
- FROM
- FmsTaskpick tp
- LEFT JOIN FmsTask t on t.taskId = tp.taskId
- LEFT JOIN FmsCrop c on c.cropId = t.cropId
- <where>
- t.cropId is not null
- and tp.tid = #{tid}
- <if test="cropName != null and cropName != ''">and c.cropName like CONCAT("%",#{cropName},"%")</if>
- <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
- AND t.blockId in
- <foreach collection="blockIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY t.cropId,c.cropName,c.cropType
- </select>
- <select id="selectFmsTaskPickStockListStat" parameterType="FmsTaskPickListReqVo" resultType="FmsTaskPickStockListResVo">
- SELECT
- t.cropId,c.cropName,c.cropType,sum(tp.pickWeight) as pickWeight
- FROM
- FmsTaskpick tp
- LEFT JOIN FmsTask t on t.taskId = tp.taskId
- LEFT JOIN FmsTaskrcd r on r.taskId = t.taskId
- LEFT JOIN FmsCrop c on c.cropId = t.cropId
- <where>
- t.cropId is not null
- and tp.tid = #{tid}
- <if test="taskStatus != null and taskStatus != ''">and t.taskStatus = #{taskStatus}</if>
- <if test="landId != null and landId != ''">and t.landId = #{landId}</if>
- <if test="blockId != null and blockId != ''">and t.blockId = #{blockId}</if>
- <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
- and t.blockId in
- <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
- #{blockId}
- </foreach>
- </if>
- </where>
- GROUP BY t.cropId,c.cropName,c.cropType
- </select>
- <select id="selectSumPickWeightListGroupByCropName" parameterType="String" resultType="FmsTaskPickStockListResVo">
- select sum(tp.pickWeight) pickWeight, cropName
- from FmsTaskpick tp
- left join FmsTask t on t.taskId = tp.taskId
- left join FmsCrop c on t.cropId = c.cropId
- where
- t.taskStatus = '3'
- and tp.tid = #{tid}
- <if test="landId != null and landId != ''">
- and t.landId = #{landId}
- </if>
- <if test="startDate != null and startDate != ''">
- and t.taskCompletedate >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}
- </if>
- <if test="dataFilter == true and landIds != null and landIds.size() > 0">
- AND t.landId in
- <foreach collection="landIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by c.cropName
- </select>
- <select id="selectSumPickWeightListGroupByLandId" parameterType="String" resultType="FmsTaskPickStockListResVo">
- select sum(tp.pickWeight) pickWeight, l.landName, l.landId
- from FmsTaskpick tp
- left join FmsTask t on t.taskId = tp.taskId
- left join FmsCrop c on t.cropId = c.cropId
- left join FmsLand l on l.landId = t.landId
- where
- t.taskStatus = '3'
- and l.landId is not null
- and tp.tid = #{tid}
- <if test="landId != null and landId != ''">
- and t.landId = #{landId}
- </if>
- <if test="startDate != null and startDate != ''">
- and t.taskCompletedate >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}
- </if>
- <if test="dataFilter == true and landIds != null and landIds.size() > 0">
- AND t.landId in
- <foreach collection="landIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by l.landId
- </select>
- <select id="selectSumPickWeightListGroupByBlockId" parameterType="String" resultType="FmsTaskPickStockListResVo">
- select sum(tp.pickWeight) pickWeight, b.blockName, b.blockId
- from FmsTaskpick tp
- left join FmsTask t on t.taskId = tp.taskId
- left join FmsCrop c on t.cropId = c.cropId
- left join FmsBlock b on b.blockId = t.blockId
- where
- t.taskStatus = '3'
- and b.blockId is not null
- and tp.tid = #{tid}
- <if test="landId != null and landId != ''">
- and t.landId = #{landId}
- </if>
- <if test="startDate != null and startDate != ''">
- and t.taskCompletedate >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}
- </if>
- <if test="dataFilter == true and landIds != null and landIds.size() > 0">
- AND t.landId in
- <foreach collection="landIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by b.blockId
- </select>
- <select id="selectFmsTaskPickStockDetailList" parameterType="FmsTaskPickStockDetailReqVo" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsTaskPickStockDetailResVo">
- SELECT
- tp.pickNo,
- p.planNo,
- l.landName,
- b.blockName,
- p.planArea,
- t.taskCompletedate,
- tp.pickWeight
- FROM
- FmsTaskpick tp
- LEFT JOIN FmsTask t on t.taskId = tp.taskId
- LEFT JOIN FmsPlan p on p.planId = t.planId
- LEFT JOIN FmsLand l on l.landId = t.landId
- LEFT JOIN FmsBlock b on b.blockId = t.blockId
- LEFT JOIN FmsTaskrcd r on r.taskId = t.taskId and r.taskrcdAuditstatus = '2'
- <where>
- t.cropId = #{cropId}
- and
- t.tid = #{tid}
- <if test="landId !=null and landId != ''">and t.landId = #{landId}</if>
- <if test="blockId !=null and blockId != ''">and t.blockId = #{blockId}</if>
- <if test="planNo !=null and planNo != ''">and p.planNo = #{planNo}</if>
- <if test="pickNo !=null and pickNo != ''">and tp.pickNo = #{pickNo}</if>
- <if test="taskCompletedatestart !=null and taskCompletedatestart != '' and taskCompletedateend !=null and taskCompletedateend != ''">and t.taskCompletedate between #{taskCompletedatestart} and #{taskCompletedateend}</if>
- </where>
- </select>
- <select id="selectFmsTaskpickByTaskpickId" parameterType="String" resultType="FmsTaskpick">
- <include refid="selectFmsTaskpickVo"/>
- where taskpickId = #{taskpickId} and tid = #{tid}
- </select>
- <select id="selectFmsTaskpickByTaskId" parameterType="String" resultType="FmsTaskpick">
- <include refid="selectFmsTaskpickVo"/>
- where taskId = #{taskId} and tid = #{tid}
- </select>
- <select id="selectFmsTaskpickByPlanId" parameterType="String" resultType="FmsTaskPickListResVo">
- select tp.*, t.taskManagername, t.taskCompletedate
- from FmsTaskpick tp
- left join FmsTask t on tp.taskId = t.taskId
- where
- t.taskStatus = '3'
- and
- t.planId = #{planId} and t.tid = #{tid}
- </select>
- <select id="selectFmsTaskpickExcelVoList"
- resultType="com.yunfeiyun.agmp.fms.domain.vo.FmsTaskpickExcelVo">
- SELECT
- ft.taskNo,
- fl.landName,
- fb.blockName,
- fc.cropName,
- fc.cropType,
- ft.taskPlanstartdate,
- ft.taskPlanenddate,
- ftp.pickWeight,
- ftr.taskrcdCost,
- sum(fta.taskassetInvestmentAmount) as taskassetInvestmentAmount,
- sum(ftm.taskmachInvestmentAmount) as taskmachInvestmentAmount,
- ft.taskAudittype,
- ft.taskStatus,
- ft.taskCreateddate,
- su.userName as taskManagername
- FROM
- FmsTask ft
- LEFT JOIN FmsBlock fb ON fb.blockId = ft.blockId
- LEFT JOIN FmsLand fl ON fb.landId = fl.landId
- LEFT JOIN FmsCrop fc on fc.cropId = ft.cropId
- LEFT JOIN FmsTaskpick ftp on ftp.taskId = ft.taskId
- LEFT JOIN (select taskId,taskrcdId,taskrcdCost from FmsTaskrcd) ftr on ftr.taskId = ft.taskId
- LEFT JOIN FmsTaskasset fta on fta.taskrcdId = ftr.taskrcdId
- LEFT JOIN FmsTaskmachine ftm on ftm.taskrcdId = ftr.taskrcdId
- LEFT JOIN FmsPlan fp on fp.planId = ft.planId
- LEFT JOIN SysUser su on su.userId = ft.taskManager
- <where>
- <if test="cropId != null and cropId != ''">and ft.cropId = #{cropId}</if>
- <if test="landId != null and landId != ''">and ft.landId = #{landId}</if>
- <if test="blockId != null and blockId != ''">and ft.blockId = #{blockId}</if>
- <if test="planId != null and planId != ''">and ft.planId = #{planId}</if>
- <if test="taskId != null and taskId != ''">and ft.taskId = #{taskId}</if>
- <if test="taskNo != null and taskNo != ''">and ft.taskNo like concat('%', #{taskNo}, '%')</if>
- <if test="planNo != null and planNo != ''">and fp.planNo like concat('%', #{planNo}, '%')</if>
- <if test="pickNo != null and pickNo != ''">and ftp.pickNo like concat('%', #{pickNo}, '%')</if>
- <if test="taskManagername != null and taskManagername !=''">and ft.taskManagername like concat('%', #{taskManagername}, '%')</if>
- <if test="taskStatus != null and taskStatus != ''">and ft.taskStatus = #{taskStatus}</if>
- <if test="taskAudittype != null and taskAudittype != ''">and ft.taskAudittype = #{taskAudittype}</if>
- <if test="taskPlanstartdate != null and taskPlanstartdate != '' and taskPlanenddate != null and taskPlanenddate != ''">
- and ft.taskPlanstartdate between #{taskPlanstartdate} and #{taskPlanenddate}
- </if>
- <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
- AND ft.blockId in
- <foreach collection="blockIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- and ft.tid = #{tid}
- and ft.taskType = -1
- </where>
- group by ft.taskId
- order by ft.taskCreateddate desc
- </select>
- <insert id="insertFmsTaskpick" parameterType="FmsTaskpick">
- insert into FmsTaskpick
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="taskpickId != null">taskpickId,</if>
- <if test="taskId != null">taskId,</if>
- <if test="pickArea != null">pickArea,</if>
- <if test="pickWeight != null">pickWeight,</if>
- <if test="pickDate != null">pickDate,</if>
- <if test="pickRemark != null">pickRemark,</if>
- <if test="pickNo != null">pickNo,</if>
- <if test="tid != null">tid,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="taskpickId != null">#{taskpickId},</if>
- <if test="taskId != null">#{taskId},</if>
- <if test="pickArea != null">#{pickArea},</if>
- <if test="pickWeight != null">#{pickWeight},</if>
- <if test="pickDate != null">#{pickDate},</if>
- <if test="pickRemark != null">#{pickRemark},</if>
- <if test="pickNo != null">#{pickNo},</if>
- <if test="tid != null">#{tid},</if>
- </trim>
- </insert>
- <update id="updateFmsTaskpick" parameterType="FmsTaskpick">
- update FmsTaskpick
- <trim prefix="SET" suffixOverrides=",">
- <if test="taskId != null">taskId = #{taskId},</if>
- <if test="pickArea != null">pickArea = #{pickArea},</if>
- <if test="pickWeight != null">pickWeight = #{pickWeight},</if>
- <if test="pickDate != null">pickDate = #{pickDate},</if>
- <if test="pickRemark != null">pickRemark = #{pickRemark},</if>
- <if test="pickNo != null">pickNo = #{pickNo},</if>
- <if test="pickChangestatus != null">pickChangestatus = #{pickChangestatus},</if>
- <if test="tid != null">tid = #{tid},</if>
- </trim>
- where
- taskpickId = #{taskpickId} and tid = #{tid}
- </update>
- <delete id="deleteFmsTaskpickByTaskpickId" parameterType="String">
- delete from FmsTaskpick
- where
- taskpickId = #{taskpickId} and tid = #{tid}
- </delete>
- <delete id="deleteFmsTaskpickByTaskpickIds" parameterType="String">
- delete from FmsTaskpick
- where
- taskpickId in
- <foreach item="taskpickId" collection="array" open="(" separator="," close=")">
- #{taskpickId}
- </foreach>
- and tid = #{tid}
- </delete>
- </mapper>
|