FmsTaskpickMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.yunfeiyun.agmp.fms.mapper.FmsTaskpickMapper">
  6. <sql id="selectFmsTaskpickVo">
  7. select taskpickId, taskId, pickArea, pickWeight, pickDate, pickRemark, pickNo from FmsTaskpick
  8. </sql>
  9. <select id="selectFmsTaskpickList" parameterType="FmsTaskPickListReqVo" resultType="FmsTaskPickListResVo">
  10. 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,
  11. su.userName as taskManagername
  12. FROM
  13. FmsTask t
  14. LEFT JOIN FmsCrop c ON t.cropId = c.cropId
  15. LEFT JOIN FmsLand l ON t.landId = l.landId
  16. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  17. LEFT JOIN FmsPlan p ON t.planId = p.planId
  18. LEFT JOIN FmsTaskpick i ON t.taskId = i.taskId
  19. LEFT JOIN FmsTaskrcd s ON t.taskId = s.taskId and s.taskrcdAuditstatus = 2
  20. LEFT JOIN SysUser su on su.userId = t.taskManager
  21. LEFT JOIN
  22. (select * from SysRes where resMediatype = '1' and resBiztype = 'CROP')
  23. r on r.resBusId = c.cropId
  24. <where>
  25. <if test="cropId != null and cropId != ''">and t.cropId = #{cropId}</if>
  26. <if test="landId != null and landId != ''">and t.landId = #{landId}</if>
  27. <if test="blockId != null and blockId != ''">and t.blockId = #{blockId}</if>
  28. <if test="planId != null and planId != ''">and t.planId = #{planId}</if>
  29. <if test="taskId != null and taskId != ''">and t.taskId = #{taskId}</if>
  30. <if test="taskNo != null and taskNo != ''">and t.taskNo like concat('%', #{taskNo}, '%')</if>
  31. <if test="planNo != null and planNo != ''">and p.planNo like concat('%', #{planNo}, '%')</if>
  32. <if test="pickNo != null and pickNo != ''">and i.pickNo like concat('%', #{pickNo}, '%')</if>
  33. <if test="taskManagername != null and taskManagername !=''">and t.taskManagername like concat('%', #{taskManagername}, '%')</if>
  34. <if test="taskStatus != null and taskStatus != ''">and t.taskStatus = #{taskStatus}</if>
  35. <if test="taskAudittype != null and taskAudittype != ''">and t.taskAudittype = #{taskAudittype}</if>
  36. <if test="taskPlanstartdate != null and taskPlanstartdate != '' and taskPlanenddate != null and taskPlanenddate != ''">
  37. and t.taskPlanstartdate between #{taskPlanstartdate} and #{taskPlanenddate}
  38. </if>
  39. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  40. AND t.blockId in
  41. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  42. #{item}
  43. </foreach>
  44. </if>
  45. and t.tid = #{tid}
  46. and t.taskType = -1
  47. </where>
  48. </select>
  49. <select id="selectFmsTaskPickStockList" parameterType="String" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsTaskPickStockListResVo">
  50. SELECT
  51. t.cropId,c.cropName,c.cropType,sum(tp.pickWeight) as pickWeight
  52. FROM
  53. FmsTaskpick tp
  54. LEFT JOIN FmsTask t on t.taskId = tp.taskId
  55. LEFT JOIN FmsCrop c on c.cropId = t.cropId
  56. <where>
  57. t.cropId is not null
  58. and tp.tid = #{tid}
  59. <if test="cropName != null and cropName != ''">and c.cropName like CONCAT("%",#{cropName},"%")</if>
  60. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  61. AND t.blockId in
  62. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  63. #{item}
  64. </foreach>
  65. </if>
  66. </where>
  67. GROUP BY t.cropId,c.cropName,c.cropType
  68. </select>
  69. <select id="selectFmsTaskPickStockListStat" parameterType="FmsTaskPickListReqVo" resultType="FmsTaskPickStockListResVo">
  70. SELECT
  71. t.cropId,c.cropName,c.cropType,sum(tp.pickWeight) as pickWeight
  72. FROM
  73. FmsTaskpick tp
  74. LEFT JOIN FmsTask t on t.taskId = tp.taskId
  75. LEFT JOIN FmsTaskrcd r on r.taskId = t.taskId
  76. LEFT JOIN FmsCrop c on c.cropId = t.cropId
  77. <where>
  78. t.cropId is not null
  79. and tp.tid = #{tid}
  80. <if test="taskStatus != null and taskStatus != ''">and t.taskStatus = #{taskStatus}</if>
  81. <if test="landId != null and landId != ''">and t.landId = #{landId}</if>
  82. <if test="blockId != null and blockId != ''">and t.blockId = #{blockId}</if>
  83. <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
  84. and t.blockId in
  85. <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
  86. #{blockId}
  87. </foreach>
  88. </if>
  89. </where>
  90. GROUP BY t.cropId,c.cropName,c.cropType
  91. </select>
  92. <select id="selectSumPickWeightListGroupByCropName" parameterType="String" resultType="FmsTaskPickStockListResVo">
  93. select sum(tp.pickWeight) pickWeight, cropName
  94. from FmsTaskpick tp
  95. left join FmsTask t on t.taskId = tp.taskId
  96. left join FmsCrop c on t.cropId = c.cropId
  97. where
  98. t.taskStatus = '3'
  99. and tp.tid = #{tid}
  100. <if test="landId != null and landId != ''">
  101. and t.landId = #{landId}
  102. </if>
  103. <if test="startDate != null and startDate != ''">
  104. and t.taskCompletedate >= #{startDate}
  105. </if>
  106. <if test="endDate != null and endDate != ''">
  107. and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}
  108. </if>
  109. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  110. AND t.landId in
  111. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  112. #{item}
  113. </foreach>
  114. </if>
  115. group by c.cropName
  116. </select>
  117. <select id="selectSumPickWeightListGroupByLandId" parameterType="String" resultType="FmsTaskPickStockListResVo">
  118. select sum(tp.pickWeight) pickWeight, l.landName, l.landId
  119. from FmsTaskpick tp
  120. left join FmsTask t on t.taskId = tp.taskId
  121. left join FmsCrop c on t.cropId = c.cropId
  122. left join FmsLand l on l.landId = t.landId
  123. where
  124. t.taskStatus = '3'
  125. and l.landId is not null
  126. and tp.tid = #{tid}
  127. <if test="landId != null and landId != ''">
  128. and t.landId = #{landId}
  129. </if>
  130. <if test="startDate != null and startDate != ''">
  131. and t.taskCompletedate >= #{startDate}
  132. </if>
  133. <if test="endDate != null and endDate != ''">
  134. and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}
  135. </if>
  136. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  137. AND t.landId in
  138. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  139. #{item}
  140. </foreach>
  141. </if>
  142. group by l.landId
  143. </select>
  144. <select id="selectSumPickWeightListGroupByBlockId" parameterType="String" resultType="FmsTaskPickStockListResVo">
  145. select sum(tp.pickWeight) pickWeight, b.blockName, b.blockId
  146. from FmsTaskpick tp
  147. left join FmsTask t on t.taskId = tp.taskId
  148. left join FmsCrop c on t.cropId = c.cropId
  149. left join FmsBlock b on b.blockId = t.blockId
  150. where
  151. t.taskStatus = '3'
  152. and b.blockId is not null
  153. and tp.tid = #{tid}
  154. <if test="landId != null and landId != ''">
  155. and t.landId = #{landId}
  156. </if>
  157. <if test="startDate != null and startDate != ''">
  158. and t.taskCompletedate >= #{startDate}
  159. </if>
  160. <if test="endDate != null and endDate != ''">
  161. and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}
  162. </if>
  163. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  164. AND t.landId in
  165. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  166. #{item}
  167. </foreach>
  168. </if>
  169. group by b.blockId
  170. </select>
  171. <select id="selectFmsTaskPickStockDetailList" parameterType="FmsTaskPickStockDetailReqVo" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsTaskPickStockDetailResVo">
  172. SELECT
  173. tp.pickNo,
  174. p.planNo,
  175. l.landName,
  176. b.blockName,
  177. p.planArea,
  178. t.taskCompletedate,
  179. tp.pickWeight
  180. FROM
  181. FmsTaskpick tp
  182. LEFT JOIN FmsTask t on t.taskId = tp.taskId
  183. LEFT JOIN FmsPlan p on p.planId = t.planId
  184. LEFT JOIN FmsLand l on l.landId = t.landId
  185. LEFT JOIN FmsBlock b on b.blockId = t.blockId
  186. LEFT JOIN FmsTaskrcd r on r.taskId = t.taskId and r.taskrcdAuditstatus = '2'
  187. <where>
  188. t.cropId = #{cropId}
  189. and
  190. t.tid = #{tid}
  191. <if test="landId !=null and landId != ''">and t.landId = #{landId}</if>
  192. <if test="blockId !=null and blockId != ''">and t.blockId = #{blockId}</if>
  193. <if test="planNo !=null and planNo != ''">and p.planNo = #{planNo}</if>
  194. <if test="pickNo !=null and pickNo != ''">and tp.pickNo = #{pickNo}</if>
  195. <if test="taskCompletedatestart !=null and taskCompletedatestart != '' and taskCompletedateend !=null and taskCompletedateend != ''">and t.taskCompletedate between #{taskCompletedatestart} and #{taskCompletedateend}</if>
  196. </where>
  197. </select>
  198. <select id="selectFmsTaskpickByTaskpickId" parameterType="String" resultType="FmsTaskpick">
  199. <include refid="selectFmsTaskpickVo"/>
  200. where taskpickId = #{taskpickId} and tid = #{tid}
  201. </select>
  202. <select id="selectFmsTaskpickByTaskId" parameterType="String" resultType="FmsTaskpick">
  203. <include refid="selectFmsTaskpickVo"/>
  204. where taskId = #{taskId} and tid = #{tid}
  205. </select>
  206. <select id="selectFmsTaskpickByPlanId" parameterType="String" resultType="FmsTaskPickListResVo">
  207. select tp.*, t.taskManagername, t.taskCompletedate
  208. from FmsTaskpick tp
  209. left join FmsTask t on tp.taskId = t.taskId
  210. where
  211. t.taskStatus = '3'
  212. and
  213. t.planId = #{planId} and t.tid = #{tid}
  214. </select>
  215. <select id="selectFmsTaskpickExcelVoList"
  216. resultType="com.yunfeiyun.agmp.fms.domain.vo.FmsTaskpickExcelVo">
  217. SELECT
  218. ft.taskNo,
  219. fl.landName,
  220. fb.blockName,
  221. fc.cropName,
  222. fc.cropType,
  223. ft.taskPlanstartdate,
  224. ft.taskPlanenddate,
  225. ftp.pickWeight,
  226. ftr.taskrcdCost,
  227. sum(fta.taskassetInvestmentAmount) as taskassetInvestmentAmount,
  228. sum(ftm.taskmachInvestmentAmount) as taskmachInvestmentAmount,
  229. ft.taskAudittype,
  230. ft.taskStatus,
  231. ft.taskCreateddate,
  232. su.userName as taskManagername
  233. FROM
  234. FmsTask ft
  235. LEFT JOIN FmsBlock fb ON fb.blockId = ft.blockId
  236. LEFT JOIN FmsLand fl ON fb.landId = fl.landId
  237. LEFT JOIN FmsCrop fc on fc.cropId = ft.cropId
  238. LEFT JOIN FmsTaskpick ftp on ftp.taskId = ft.taskId
  239. LEFT JOIN (select taskId,taskrcdId,taskrcdCost from FmsTaskrcd) ftr on ftr.taskId = ft.taskId
  240. LEFT JOIN FmsTaskasset fta on fta.taskrcdId = ftr.taskrcdId
  241. LEFT JOIN FmsTaskmachine ftm on ftm.taskrcdId = ftr.taskrcdId
  242. LEFT JOIN FmsPlan fp on fp.planId = ft.planId
  243. LEFT JOIN SysUser su on su.userId = ft.taskManager
  244. <where>
  245. <if test="cropId != null and cropId != ''">and ft.cropId = #{cropId}</if>
  246. <if test="landId != null and landId != ''">and ft.landId = #{landId}</if>
  247. <if test="blockId != null and blockId != ''">and ft.blockId = #{blockId}</if>
  248. <if test="planId != null and planId != ''">and ft.planId = #{planId}</if>
  249. <if test="taskId != null and taskId != ''">and ft.taskId = #{taskId}</if>
  250. <if test="taskNo != null and taskNo != ''">and ft.taskNo like concat('%', #{taskNo}, '%')</if>
  251. <if test="planNo != null and planNo != ''">and fp.planNo like concat('%', #{planNo}, '%')</if>
  252. <if test="pickNo != null and pickNo != ''">and ftp.pickNo like concat('%', #{pickNo}, '%')</if>
  253. <if test="taskManagername != null and taskManagername !=''">and ft.taskManagername like concat('%', #{taskManagername}, '%')</if>
  254. <if test="taskStatus != null and taskStatus != ''">and ft.taskStatus = #{taskStatus}</if>
  255. <if test="taskAudittype != null and taskAudittype != ''">and ft.taskAudittype = #{taskAudittype}</if>
  256. <if test="taskPlanstartdate != null and taskPlanstartdate != '' and taskPlanenddate != null and taskPlanenddate != ''">
  257. and ft.taskPlanstartdate between #{taskPlanstartdate} and #{taskPlanenddate}
  258. </if>
  259. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  260. AND ft.blockId in
  261. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  262. #{item}
  263. </foreach>
  264. </if>
  265. and ft.tid = #{tid}
  266. and ft.taskType = -1
  267. </where>
  268. group by ft.taskId
  269. order by ft.taskCreateddate desc
  270. </select>
  271. <insert id="insertFmsTaskpick" parameterType="FmsTaskpick">
  272. insert into FmsTaskpick
  273. <trim prefix="(" suffix=")" suffixOverrides=",">
  274. <if test="taskpickId != null">taskpickId,</if>
  275. <if test="taskId != null">taskId,</if>
  276. <if test="pickArea != null">pickArea,</if>
  277. <if test="pickWeight != null">pickWeight,</if>
  278. <if test="pickDate != null">pickDate,</if>
  279. <if test="pickRemark != null">pickRemark,</if>
  280. <if test="pickNo != null">pickNo,</if>
  281. <if test="tid != null">tid,</if>
  282. </trim>
  283. <trim prefix="values (" suffix=")" suffixOverrides=",">
  284. <if test="taskpickId != null">#{taskpickId},</if>
  285. <if test="taskId != null">#{taskId},</if>
  286. <if test="pickArea != null">#{pickArea},</if>
  287. <if test="pickWeight != null">#{pickWeight},</if>
  288. <if test="pickDate != null">#{pickDate},</if>
  289. <if test="pickRemark != null">#{pickRemark},</if>
  290. <if test="pickNo != null">#{pickNo},</if>
  291. <if test="tid != null">#{tid},</if>
  292. </trim>
  293. </insert>
  294. <update id="updateFmsTaskpick" parameterType="FmsTaskpick">
  295. update FmsTaskpick
  296. <trim prefix="SET" suffixOverrides=",">
  297. <if test="taskId != null">taskId = #{taskId},</if>
  298. <if test="pickArea != null">pickArea = #{pickArea},</if>
  299. <if test="pickWeight != null">pickWeight = #{pickWeight},</if>
  300. <if test="pickDate != null">pickDate = #{pickDate},</if>
  301. <if test="pickRemark != null">pickRemark = #{pickRemark},</if>
  302. <if test="pickNo != null">pickNo = #{pickNo},</if>
  303. <if test="pickChangestatus != null">pickChangestatus = #{pickChangestatus},</if>
  304. <if test="tid != null">tid = #{tid},</if>
  305. </trim>
  306. where
  307. taskpickId = #{taskpickId} and tid = #{tid}
  308. </update>
  309. <delete id="deleteFmsTaskpickByTaskpickId" parameterType="String">
  310. delete from FmsTaskpick
  311. where
  312. taskpickId = #{taskpickId} and tid = #{tid}
  313. </delete>
  314. <delete id="deleteFmsTaskpickByTaskpickIds" parameterType="String">
  315. delete from FmsTaskpick
  316. where
  317. taskpickId in
  318. <foreach item="taskpickId" collection="array" open="(" separator="," close=")">
  319. #{taskpickId}
  320. </foreach>
  321. and tid = #{tid}
  322. </delete>
  323. </mapper>