FmsTaskMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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.FmsTaskMapper">
  6. <sql id="selectFmsTaskVo">
  7. select taskId, taskNo,taskVisible, planId, blockId, landId, cropId, taskCreatetype, taskType, taskContent, taskPlanstartdate, taskPlanenddate, taskAudittype, taskStatus, taskManager, taskCreator, taskCreateddate, taskCompletedate, taskModifieddate, taskCompletereason, taskAuditor, tid from FmsTask
  8. </sql>
  9. <select id="selectFmsTaskList" parameterType="FmsTask" resultType="FmsTask">
  10. <include refid="selectFmsTaskVo"/>
  11. <where>
  12. tid = #{tid}
  13. <if test="taskNo != null and taskNo != ''"> and taskNo = #{taskNo}</if>
  14. <if test="planId != null and planId != ''"> and planId = #{planId}</if>
  15. <if test="blockId != null and blockId != ''"> and blockId = #{blockId}</if>
  16. <if test="landId != null and landId != ''"> and landId = #{landId}</if>
  17. <if test="cropId != null and cropId != ''"> and cropId = #{cropId}</if>
  18. <if test="taskCreatetype != null and taskCreatetype != ''"> and taskCreatetype = #{taskCreatetype}</if>
  19. <if test="taskType != null and taskType != ''"> and taskType = #{taskType}</if>
  20. <if test="taskContent != null and taskContent != ''"> and taskContent = #{taskContent}</if>
  21. <if test="taskPlanstartdate != null and taskPlanstartdate != ''"> and taskPlanstartdate = #{taskPlanstartdate}</if>
  22. <if test="taskPlanenddate != null and taskPlanenddate != ''"> and taskPlanenddate = #{taskPlanenddate}</if>
  23. <if test="taskAudittype != null and taskAudittype != ''"> and taskAudittype = #{taskAudittype}</if>
  24. <if test="taskManager != null and taskManager != ''"> and taskManager = #{taskManager}</if>
  25. <if test="taskCreator != null and taskCreator != ''"> and taskCreator = #{taskCreator}</if>
  26. <if test="taskCreateddate != null and taskCreateddate != ''"> and taskCreateddate = #{taskCreateddate}</if>
  27. <if test="taskCompletedate != null and taskCompletedate != ''"> and taskCompletedate = #{taskCompletedate}</if>
  28. <if test="taskModifieddate != null and taskModifieddate != ''"> and taskModifieddate = #{taskModifieddate}</if>
  29. <if test="taskVisible != null and taskVisible != ''">and taskVisible = #{taskVisible}</if>
  30. <if test="startDate != null and startDate != ''">
  31. and taskPlanstartdate >= #{startDate}
  32. </if>
  33. <if test="endDate != null and endDate != ''">
  34. and taskPlanenddate <![CDATA[ <= ]]> #{endDate}
  35. </if>
  36. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  37. AND t.blockId in
  38. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  39. #{item}
  40. </foreach>
  41. </if>
  42. <if test="taskVisible != null and taskVisible != ''">and taskVisible = #{taskVisible}</if>
  43. </where>
  44. </select>
  45. <select id="selectTaskList" parameterType="FmsTaskListReqVo" resultType="FmsTaskResVo">
  46. select t.*, c.cropName, c.cropType, l.landName, b.blockName, p.planNo, p.planArea,s.taskrcdHour,
  47. s.taskrcdId,
  48. t.taskVisible
  49. from FmsTask t
  50. LEFT JOIN FmsCrop c on t.cropId = c.cropId
  51. LEFT JOIN FmsLand l ON t.landId = l.landId
  52. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  53. LEFT JOIN FmsPlan p ON t.planId = p.planId
  54. LEFT JOIN FmsTaskrcd s ON t.taskId = s.taskId and s.taskrcdAuditstatus = 2
  55. <where>
  56. t.tid = #{tid}
  57. <if test="taskNo != null and taskNo != ''"> and t.taskNo = #{taskNo}</if>
  58. <if test="planNo != null and planNo != ''"> and p.planNo = #{planNo}</if>
  59. <if test="planId != null and planId != ''"> and t.planId = #{planId}</if>
  60. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  61. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  62. <if test="cropId != null and cropId != ''"> and t.cropId = #{cropId}</if>
  63. <if test="taskAuditstatus != null and taskAuditstatus != ''">
  64. and
  65. <foreach collection="taskAuditstatus.split(',')" item="items" open="(" separator="or" close=")">
  66. <if test="items != null and items != ''">
  67. t.taskStatus = #{items}
  68. </if>
  69. </foreach>
  70. </if>
  71. <if test="taskAudittype != null and taskAudittype != ''"> and t.taskAudittype = #{taskAudittype}</if>
  72. <if test="cropName != null and cropName != ''"> and c.cropName = #{cropName}</if>
  73. <if test="taskCreatetype != null and taskCreatetype != ''"> and t.taskCreatetype = #{taskCreatetype}</if>
  74. <if test="queryAllTask == false">
  75. <if test="taskType != null and taskType != ''"> and t.taskType = #{taskType}</if>
  76. <if test="taskType == null || taskType == ''">and t.taskType >= 0</if>
  77. </if>
  78. <if test="taskManager != null and taskManager != ''"> and t.taskManager = #{taskManager}</if>
  79. <if test="startDate != null and startDate != ''">
  80. and t.taskPlanstartdate >= #{startDate}
  81. </if>
  82. <if test="endDate != null and endDate != ''">
  83. and t.taskPlanenddate <![CDATA[ <= ]]> #{endDate}
  84. </if>
  85. <if test="taskAuditor != null and taskAuditor !=''">
  86. and t.taskAuditor = #{taskAuditor}
  87. </if>
  88. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  89. AND t.blockId in
  90. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  91. #{item}
  92. </foreach>
  93. </if>
  94. <if test="taskVisible != null and taskVisible != ''">and t.taskVisible = #{taskVisible}</if>
  95. </where>
  96. </select>
  97. <select id="selectTaskListAll" parameterType="FmsTaskListReqVo" resultType="FmsTaskResVo">
  98. select t.*, c.cropName, c.cropType, l.landName, b.blockName, p.planNo, p.planArea,s.taskrcdHour
  99. from FmsTask t
  100. LEFT JOIN FmsCrop c on t.cropId = c.cropId
  101. LEFT JOIN FmsLand l ON t.landId = l.landId
  102. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  103. LEFT JOIN FmsPlan p ON t.planId = p.planId
  104. LEFT JOIN FmsTaskrcd s ON t.taskId = s.taskId and s.taskrcdAuditstatus = 2
  105. <where>
  106. t.tid = #{tid}
  107. <if test="taskNo != null and taskNo != ''"> and t.taskNo = #{taskNo}</if>
  108. <if test="planId != null and planId != ''"> and t.planId = #{planId}</if>
  109. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  110. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  111. <if test="cropId != null and cropId != ''"> and t.cropId = #{cropId}</if>
  112. <if test="taskAuditstatus != null and taskAuditstatus != ''"> and t.taskStatus = #{taskAuditstatus}</if>
  113. <if test="taskAudittype != null and taskAudittype != ''"> and t.taskAudittype = #{taskAudittype}</if>
  114. <if test="cropName != null and cropName != ''"> and c.cropName = #{cropName}</if>
  115. <if test="taskCreatetype != null and taskCreatetype != ''"> and t.taskCreatetype = #{taskCreatetype}</if>
  116. <if test="taskType != null and taskType != ''">
  117. and t.taskType in
  118. <foreach collection="taskType.split(',')" item="items" open="(" separator="," close=")">
  119. <if test="items != null and items != ''">
  120. #{items}
  121. </if>
  122. </foreach>
  123. </if>
  124. <if test="taskManager != null and taskManager != ''"> and t.taskManager = #{taskManager}</if>
  125. <if test="startDate != null and startDate != ''">
  126. and t.taskPlanenddate >= #{startDate}
  127. </if>
  128. <if test="endDate != null and endDate != ''">
  129. and t.taskPlanstartdate <![CDATA[ <= ]]> #{endDate}
  130. </if>
  131. <if test="taskAuditor != null and taskAuditor !=''">
  132. and t.taskAuditor = #{taskAuditor}
  133. </if>
  134. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  135. AND t.blockId in
  136. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  137. #{item}
  138. </foreach>
  139. </if>
  140. <if test="taskVisible != null and taskVisible != ''">and t.taskVisible = #{taskVisible}</if>
  141. </where>
  142. </select>
  143. <select id="selectTaskListScreenData" parameterType="FmsTaskListReqVo" resultType="FmsTaskResVo">
  144. select t.*, c.cropName, c.cropType, l.landName, b.blockName
  145. from FmsTask t
  146. LEFT JOIN FmsCrop c on t.cropId = c.cropId
  147. LEFT JOIN FmsLand l ON t.landId = l.landId
  148. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  149. <where>
  150. t.tid = #{tid}
  151. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  152. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  153. <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
  154. and t.blockId in
  155. <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
  156. #{blockId}
  157. </foreach>
  158. </if>
  159. <if test="taskVisible != null and taskVisible != ''">and t.taskVisible = #{taskVisible}</if>
  160. </where>
  161. order by taskCreateddate desc limit 10
  162. </select>
  163. <select id="selectAllTaskList" parameterType="FmsTaskListReqVo" resultType="FmsTaskMessageResVo">
  164. select t.*, c.cropName, c.cropType, l.landName, b.blockName, p.planNo, p.planArea,tp.taskpatrolWay,tp.taskpatrolAddress
  165. from FmsTask t
  166. LEFT JOIN FmsCrop c on t.cropId = c.cropId
  167. LEFT JOIN FmsLand l ON t.landId = l.landId
  168. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  169. LEFT JOIN FmsPlan p ON t.planId = p.planId
  170. LEFT JOIN FmsTaskpatrol tp on tp.taskId = t.taskId
  171. <where>
  172. t.tid = #{tid}
  173. <if test="taskNo != null and taskNo != ''"> and t.taskNo = #{taskNo}</if>
  174. <if test="planId != null and planId != ''"> and t.planId = #{planId}</if>
  175. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  176. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  177. <if test="cropId != null and cropId != ''"> and t.cropId = #{cropId}</if>
  178. <if test="taskAuditstatus != null and taskAuditstatus != ''"> and t.taskStatus = #{taskAuditstatus}</if>
  179. <if test="cropName != null and cropName != ''"> and c.cropName = #{cropName}</if>
  180. <if test="taskCreatetype != null and taskCreatetype != ''"> and t.taskCreatetype = #{taskCreatetype}</if>
  181. <if test="taskType != null and taskType != ''"> and t.taskType = #{taskType}</if>
  182. <if test="taskManager != null and taskManager != ''"> and t.taskManager = #{taskManager}</if>
  183. <if test="startDate != null and startDate != ''">
  184. and t.taskPlanenddate >= #{startDate}
  185. </if>
  186. <if test="endDate != null and endDate != ''">
  187. and t.taskPlanstartdate <![CDATA[ <= ]]> #{endDate}
  188. </if>
  189. <if test="taskAuditor != null and taskAuditor !=''">
  190. and t.taskAuditor = #{taskAuditor}
  191. </if>
  192. <if test="dataFilter == true and blockIds != null and blockIds.size()>0 and landIds !=null and landIds.size()>0">
  193. AND (
  194. t.blockId in
  195. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  196. #{item}
  197. </foreach>
  198. or
  199. t.landId in
  200. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  201. #{item}
  202. </foreach>
  203. )
  204. </if>
  205. <if test="taskVisible != null and taskVisible != ''">and t.taskVisible = #{taskVisible}</if>
  206. </where>
  207. </select>
  208. <select id="selectFmsTaskByTaskId" parameterType="String" resultType="FmsTask">
  209. <include refid="selectFmsTaskVo"/>
  210. where
  211. taskId = #{taskId}
  212. and tid = #{tid}
  213. </select>
  214. <select id="selectCountFmsTaskByPlanId" parameterType="String" resultType="int">
  215. select count(1) from FmsTask
  216. where
  217. planId = #{planId}
  218. and tid = #{tid}
  219. </select>
  220. <select id="selectCountFmsTask" parameterType="FmsTaskListReqVo" resultType="int">
  221. select count(1) from FmsTask
  222. <where>
  223. tid = #{tid}
  224. <if test="taskAuditstatus != null and taskAuditstatus != ''">
  225. and
  226. <foreach collection="taskAuditstatus.split(',')" item="items" open="(" separator="or" close=")">
  227. <if test="items != null and items != ''">
  228. taskStatus = #{items}
  229. </if>
  230. </foreach>
  231. </if>
  232. <if test="startDate != null and startDate != ''"> and taskCompletedate <![CDATA[ >= ]]> #{startDate}</if>
  233. <if test="endDate != null and endDate != ''"> and taskCompletedate <![CDATA[ <= ]]> #{endDate}</if>
  234. <if test="taskManager != null and taskManager != ''"> and taskManager = #{taskManager}</if>
  235. <if test="landId != null and landId != ''"> and landId = #{landId}</if>
  236. <if test="taskVisible != null and taskVisible != ''">and taskVisible = #{taskVisible}</if>
  237. </where>
  238. </select>
  239. <select id="selectCountFmsTaskByType" parameterType="FmsTaskListReqVo" resultType="FmsTaskTypeCountResVo">
  240. SELECT count(taskType) count, taskType FROM FmsTask
  241. <where>
  242. tid = #{tid}
  243. <if test="taskAuditstatus != null and taskAuditstatus != ''"> and taskStatus = #{taskAuditstatus}</if>
  244. <if test="landId != null and landId != ''"> and landId = #{landId}</if>
  245. <if test="taskAudittype != null and taskAudittype != ''">
  246. and
  247. <foreach collection="taskAudittype.split(',')" item="items" open="(" separator="or" close=")">
  248. <if test="items != null and items != ''">
  249. taskAudittype = #{items}
  250. </if>
  251. </foreach>
  252. </if>
  253. <if test="startDate != null and startDate != ''"> and taskCreateddate <![CDATA[ >= ]]> #{startDate}</if>
  254. <if test="endDate != null and endDate != ''"> and taskCreateddate <![CDATA[ <= ]]> #{endDate}</if>
  255. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  256. AND blockId in
  257. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  258. #{item}
  259. </foreach>
  260. </if>
  261. <if test="taskVisible != null and taskVisible != ''">and taskVisible = #{taskVisible}</if>
  262. and taskType >=0
  263. </where>
  264. GROUP BY taskType
  265. order by count desc;
  266. </select>
  267. <select id="selectCountFmsTaskByTypeBoard" parameterType="FmsTaskListReqVo" resultType="FmsTaskTypeCountResVo">
  268. SELECT count(taskType) count, taskType FROM FmsTask
  269. <where>
  270. tid = #{tid}
  271. <if test="taskAuditstatus != null and taskAuditstatus != ''"> and taskStatus = #{taskAuditstatus}</if>
  272. <if test="landId != null and landId != ''"> and landId = #{landId}</if>
  273. <if test="planId != null and planId != ''"> and planId = #{planId}</if>
  274. <if test="blockId != null and blockId != ''"> and blockId = #{blockId}</if>
  275. <if test="taskManager != null and taskManager != ''"> and taskManager = #{taskManager}</if>
  276. <if test="taskVisible != null and taskVisible != ''">and taskVisible = #{taskVisible}</if>
  277. <if test="taskAudittype != null and taskAudittype != ''">
  278. and
  279. <foreach collection="taskAudittype.split(',')" item="items" open="(" separator="or" close=")">
  280. <if test="items != null and items != ''">
  281. taskAudittype = #{items}
  282. </if>
  283. </foreach>
  284. </if>
  285. <if test="startDate != null and startDate != ''">
  286. and taskPlanstartdate >= #{startDate}
  287. </if>
  288. <if test="endDate != null and endDate != ''">
  289. and taskPlanstartdate <![CDATA[ <= ]]> #{endDate}
  290. </if>
  291. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  292. AND blockId in
  293. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  294. #{item}
  295. </foreach>
  296. </if>
  297. <if test="taskVisible != null and taskVisible != ''">and taskVisible = #{taskVisible}</if>
  298. </where>
  299. GROUP BY taskType
  300. </select>
  301. <select id="selectSumTaskrcdHour" parameterType="FmsTaskListReqVo" resultType="FmsTaskSumTaskrcdHourResVo">
  302. select sum(tb1.taskrcdHour) taskrcdHour,t.taskType
  303. from FmsTask t
  304. left join
  305. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '1' or tr.taskrcdAuditstatus = '2') tb1
  306. on tb1.taskId = t.taskId
  307. where t.taskType >= 0 and tb1.taskrcdAuditstatus = '2' and t.tid = #{tid}
  308. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  309. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  310. <if test="startDate != null and startDate != ''"> and t.taskCompletedate <![CDATA[ >= ]]> #{startDate}</if>
  311. <if test="endDate != null and endDate != ''"> and t.taskCompletedate <![CDATA[ <= ]]> #{endDate}</if>
  312. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  313. AND t.landId in
  314. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  315. #{item}
  316. </foreach>
  317. </if>
  318. <if test="taskVisible != null and taskVisible != ''">and t.taskVisible = #{taskVisible}</if>
  319. group by t.taskType
  320. </select>
  321. <select id="selectInfoByTaskId" parameterType="String" resultType="FmsTaskResVo">
  322. select t.*, c.cropName, c.cropType, l.landName, b.blockName, p.planNo, p.planArea, u.userName taskCreatorName
  323. from FmsTask t
  324. LEFT JOIN FmsCrop c on t.cropId = c.cropId
  325. LEFT JOIN FmsLand l ON t.landId = l.landId
  326. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  327. LEFT JOIN FmsPlan p ON t.planId = p.planId
  328. LEFT JOIN SysUser u ON t.taskCreator = u.userId
  329. where
  330. t.taskId = #{taskId}
  331. and t.tid = #{tid}
  332. </select>
  333. <select id="getInfoByPlanId" parameterType="String" resultType="FmsTaskResVo">
  334. select t.*, tb1.taskrcdId
  335. from FmsTask t
  336. left join
  337. (select tr.* from FmsTaskrcd tr where taskrcdAuditstatus = '1' or taskrcdAuditstatus = '2') tb1
  338. on tb1.taskId = t.taskId
  339. where
  340. t.taskType >= 0
  341. and t.taskStatus = '3'
  342. and t.planId = #{planId}
  343. and t.tid = #{tid}
  344. </select>
  345. <insert id="insertFmsTask" parameterType="FmsTask">
  346. insert into FmsTask
  347. <trim suffixOverrides="," suffix=")" prefix="(">
  348. <if test="taskId != null">taskId,</if>
  349. <if test="taskNo != null">taskNo,</if>
  350. <if test="planId != null">planId,</if>
  351. <if test="blockId != null">blockId,</if>
  352. <if test="landId != null">landId,</if>
  353. <if test="cropId != null">cropId,</if>
  354. <if test="taskCreatetype != null">taskCreatetype,</if>
  355. <if test="taskType != null">taskType,</if>
  356. <if test="taskContent != null">taskContent,</if>
  357. <if test="taskPlanstartdate != null">taskPlanstartdate,</if>
  358. <if test="taskPlanenddate != null">taskPlanenddate,</if>
  359. <if test="taskAudittype != null">taskAudittype,</if>
  360. <if test="taskStatus != null">taskStatus,</if>
  361. <if test="taskManager != null">taskManager,</if>
  362. <if test="taskCreator != null">taskCreator,</if>
  363. <if test="taskCreateddate != null">taskCreateddate,</if>
  364. <if test="taskCompletedate != null">taskCompletedate,</if>
  365. <if test="taskModifieddate != null">taskModifieddate,</if>
  366. <if test="taskCompletereason != null">taskCompletereason,</if>
  367. <if test="taskAuditor != null">taskAuditor,</if>
  368. <if test="taskVisible != null">taskVisible,</if>
  369. <if test="tid != null">tid,</if>
  370. </trim>
  371. <trim suffixOverrides="," suffix=")" prefix="values (">
  372. <if test="taskId != null">#{taskId},</if>
  373. <if test="taskNo != null">#{taskNo},</if>
  374. <if test="planId != null">#{planId},</if>
  375. <if test="blockId != null">#{blockId},</if>
  376. <if test="landId != null">#{landId},</if>
  377. <if test="cropId != null">#{cropId},</if>
  378. <if test="taskCreatetype != null">#{taskCreatetype},</if>
  379. <if test="taskType != null">#{taskType},</if>
  380. <if test="taskContent != null">#{taskContent},</if>
  381. <if test="taskPlanstartdate != null">#{taskPlanstartdate},</if>
  382. <if test="taskPlanenddate != null">#{taskPlanenddate},</if>
  383. <if test="taskAudittype != null">#{taskAudittype},</if>
  384. <if test="taskStatus != null">#{taskStatus},</if>
  385. <if test="taskManager != null">#{taskManager},</if>
  386. <if test="taskCreator != null">#{taskCreator},</if>
  387. <if test="taskCreateddate != null">#{taskCreateddate},</if>
  388. <if test="taskCompletedate != null">#{taskCompletedate},</if>
  389. <if test="taskModifieddate != null">#{taskModifieddate},</if>
  390. <if test="taskCompletereason != null">#{taskCompletereason},</if>
  391. <if test="taskAuditor != null">#{taskAuditor},</if>
  392. <if test="taskVisible != null">#{taskVisible},</if>
  393. <if test="tid != null">#{tid},</if>
  394. </trim>
  395. </insert>
  396. <update id="updateFmsTask" parameterType="FmsTask">
  397. update FmsTask
  398. <trim prefix="SET" suffixOverrides=",">
  399. <if test="taskNo != null">taskNo = #{taskNo},</if>
  400. <if test="planId != null">planId = #{planId},</if>
  401. <if test="blockId != null">blockId = #{blockId},</if>
  402. <if test="landId != null">landId = #{landId},</if>
  403. <if test="cropId != null">cropId = #{cropId},</if>
  404. <if test="taskCreatetype != null">taskCreatetype = #{taskCreatetype},</if>
  405. <if test="taskType != null">taskType = #{taskType},</if>
  406. <if test="taskStatus != null">taskStatus = #{taskStatus},</if>
  407. <if test="taskContent != null">taskContent = #{taskContent},</if>
  408. <if test="taskPlanstartdate != null">taskPlanstartdate = #{taskPlanstartdate},</if>
  409. <if test="taskPlanenddate != null">taskPlanenddate = #{taskPlanenddate},</if>
  410. <if test="taskAudittype != null">taskAudittype = #{taskAudittype},</if>
  411. <if test="taskManager != null">taskManager = #{taskManager},</if>
  412. <if test="taskVisible != null">taskVisible = #{taskVisible},</if>
  413. <if test="taskCreator != null">taskCreator = #{taskCreator},</if>
  414. <if test="taskCreateddate != null">taskCreateddate = #{taskCreateddate},</if>
  415. <if test="taskCompletedate != null">taskCompletedate = #{taskCompletedate},</if>
  416. <if test="taskModifieddate != null">taskModifieddate = #{taskModifieddate},</if>
  417. <if test="taskCompletereason != null">taskCompletereason = #{taskCompletereason},</if>
  418. <if test="taskAuditor != null">taskAuditor = #{taskAuditor},</if>
  419. <if test="tid != null">tid = #{tid},</if>
  420. </trim>
  421. where taskId = #{taskId}
  422. and tid = #{tid}
  423. </update>
  424. <delete id="deleteFmsTaskByTaskId" parameterType="String">
  425. delete from FmsTask
  426. where
  427. taskId = #{taskId}
  428. and tid = #{tid}
  429. </delete>
  430. <delete id="deleteFmsTaskByTaskIds" parameterType="String">
  431. delete from FmsTask
  432. where
  433. taskId in
  434. <foreach item="taskId" collection="array" open="(" separator="," close=")">
  435. #{taskId}
  436. </foreach>
  437. and tid = #{tid}
  438. </delete>
  439. <select id="selectTaskCountOfTaskStatus" parameterType="String" resultType="int">
  440. SELECT count(1) taskCount
  441. FROM FmsTask t
  442. WHERE t.taskStatus <![CDATA[ < ]]> 2
  443. <if test="landId != null and landId != ''">
  444. and t.landId = #{landId}
  445. </if>
  446. <if test="taskManager != null and taskManager != ''">
  447. and t.taskManager = #{taskManager}
  448. </if>
  449. <if test="taskVisible != null and taskVisible != ''">
  450. and t.taskVisible = #{taskVisible}
  451. </if>
  452. and t.tid = #{tid}
  453. </select>
  454. <select id="selectTaskListOfTaskStatus" parameterType="String" resultType="FmsTaskMessageResVo">
  455. select t.*, c.cropName, c.cropType, l.landName, b.blockName, p.planNo, p.planArea,tp.taskpatrolWay,tp.taskpatrolAddress
  456. from FmsTask t
  457. LEFT JOIN FmsCrop c on t.cropId = c.cropId
  458. LEFT JOIN FmsLand l ON t.landId = l.landId
  459. LEFT JOIN FmsBlock b ON t.blockId = b.blockId
  460. LEFT JOIN FmsPlan p ON t.planId = p.planId
  461. LEFT JOIN FmsTaskpatrol tp on tp.taskId = t.taskId
  462. WHERE
  463. t.taskStatus <![CDATA[ < ]]> 2
  464. and t.tid = #{tid}
  465. <if test="landId != null and landId != ''">
  466. and t.landId = #{landId}
  467. </if>
  468. <if test="taskManager != null and taskManager != ''">
  469. and t.taskManager =#{taskManager}
  470. </if>
  471. <if test="taskVisible != null and taskVisible != ''">
  472. and t.taskVisible = #{taskVisible}
  473. </if>
  474. </select>
  475. <!-- 溯源统计页面使用:成本占比(农资,农机,人工费用) -->
  476. <select id="selectSumTaskrcdMoney" parameterType="SelectOfTssStatReqVo" resultType="map">
  477. select IFNULL(sum(tb1.taskrcdCost),0) rgSum
  478. ,IFNULL(sum(tb1.taskrcdAssetInvestment),0) nzSum
  479. ,IFNULL(sum(tb1.taskrcdMachineInvestment),0) njSum
  480. from FmsTask t
  481. left join
  482. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  483. on tb1.taskId = t.taskId
  484. where left(t.taskCompletedate,4)=#{startTime}
  485. and t.tid = #{tid}
  486. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  487. <if test="taskVisible != null and taskVisible != ''">
  488. and t.taskVisible = #{taskVisible}
  489. </if>
  490. </select>
  491. <select id="selectSumTaskrcdMoneyByLandId" parameterType="SelectOfTssStatReqVo" resultType="map">
  492. select IFNULL(sum(tb1.taskrcdCost),0) rgSum,
  493. IFNULL(sum(tb1.taskrcdAssetInvestment),0) nzSum,
  494. IFNULL(sum(tb1.taskrcdMachineInvestment),0) njSum,
  495. l.landId, l.landName
  496. from FmsTask t
  497. left join (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1 on tb1.taskId = t.taskId
  498. left join FmsLand l on l.landId = t.landId
  499. where left(t.taskCompletedate,4)=#{startTime} and t.tid = #{tid}
  500. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  501. <if test="taskVisible != null and taskVisible != ''">
  502. and t.taskVisible = #{taskVisible}
  503. </if>
  504. GROUP BY l.landId
  505. </select>
  506. <select id="selectSumTaskrcdMoneyByBlockId" parameterType="SelectOfTssStatReqVo" resultType="map">
  507. select IFNULL(sum(tb1.taskrcdCost),0) rgSum,
  508. IFNULL(sum(tb1.taskrcdAssetInvestment),0) nzSum,
  509. IFNULL(sum(tb1.taskrcdMachineInvestment),0) njSum,
  510. b.blockId, b.blockName
  511. from FmsTask t
  512. left join
  513. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  514. on tb1.taskId = t.taskId
  515. left join FmsBlock b on b.blockId = t.blockId
  516. where left(t.taskCompletedate,4)=#{startTime}
  517. and t.tid = #{tid}
  518. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  519. <if test="taskVisible != null and taskVisible != ''">
  520. and t.taskVisible = #{taskVisible}
  521. </if>
  522. GROUP BY b.blockId
  523. </select>
  524. <!-- 溯源统计页面使用:年度分析-每月(人工) -->
  525. <select id="selectPayMonthByRg" parameterType="SelectOfTssStatReqVo" resultType="map">
  526. SELECT left(tb1.taskrcdSubmitdate,7) month
  527. ,IFNULL(sum(tb1.taskrcdCost),0) money
  528. from FmsTask t
  529. left join
  530. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  531. on tb1.taskId = t.taskId
  532. where left(tb1.taskrcdSubmitdate,4)=#{startTime}
  533. and t.tid = #{tid}
  534. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  535. <if test="taskVisible != null and taskVisible != ''">
  536. and t.taskVisible = #{taskVisible}
  537. </if>
  538. GROUP BY left(tb1.taskrcdSubmitdate,7)
  539. order by tb1.taskrcdSubmitdate
  540. </select>
  541. <!-- 溯源统计页面使用:成本占比-明细(人工) -->
  542. <select id="selectPayByRg" parameterType="SelectOfTssStatReqVo" resultType="SpmPayOfTssStatResVo">
  543. select tb1.taskrcdCost money,
  544. tb1.taskrcdSubmitdate time,
  545. '用工费用' typeName
  546. from FmsTask t
  547. left join
  548. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  549. on tb1.taskId = t.taskId
  550. <where>
  551. and left(t.taskCompletedate,4)=#{startTime}
  552. and tb1.taskrcdCost>0
  553. and t.tid = #{tid}
  554. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  555. <if test="taskVisible != null and taskVisible != ''">
  556. and t.taskVisible = #{taskVisible}
  557. </if>
  558. </where>
  559. order by tb1.taskrcdSubmitdate desc
  560. </select>
  561. <!-- 溯源统计页面使用:年度分析-每月(农资) -->
  562. <select id="selectPayMonthByNz" parameterType="SelectOfTssStatReqVo" resultType="map">
  563. SELECT left(tb1.taskrcdSubmitdate,7) month
  564. ,IFNULL(sum(tb1.taskrcdAssetInvestment),0) money
  565. from FmsTask t
  566. left join
  567. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  568. on tb1.taskId = t.taskId
  569. where left(tb1.taskrcdSubmitdate,4)=#{startTime}
  570. and t.tid = #{tid}
  571. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  572. <if test="taskVisible != null and taskVisible != ''">
  573. and t.taskVisible = #{taskVisible}
  574. </if>
  575. GROUP BY left(tb1.taskrcdSubmitdate,7)
  576. order by tb1.taskrcdSubmitdate
  577. </select>
  578. <!-- 溯源统计页面使用:成本占比-明细(农资) -->
  579. <select id="selectPayByNz" parameterType="SelectOfTssStatReqVo" resultType="SpmPayOfTssStatResVo">
  580. select tb1.taskrcdAssetInvestment money,
  581. tb1.taskrcdSubmitdate time,
  582. '农资费用' typeName
  583. from FmsTask t
  584. left join
  585. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  586. on tb1.taskId = t.taskId
  587. where left(t.taskCompletedate,4)=#{startTime} and tb1.taskrcdAssetInvestment>0
  588. and t.tid = #{tid}
  589. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  590. <if test="taskVisible != null and taskVisible != ''">
  591. and t.taskVisible = #{taskVisible}
  592. </if>
  593. order by tb1.taskrcdSubmitdate desc
  594. </select>
  595. <!-- 溯源统计页面使用:年度分析-每月(农机) -->
  596. <select id="selectPayMonthByNj" parameterType="SelectOfTssStatReqVo" resultType="map">
  597. SELECT left(tb1.taskrcdSubmitdate,7) month
  598. ,IFNULL(sum(tb1.taskrcdMachineInvestment),0) money
  599. from FmsTask t
  600. left join
  601. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  602. on tb1.taskId = t.taskId
  603. where left(tb1.taskrcdSubmitdate,4)=#{startTime}
  604. and t.tid = #{tid}
  605. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  606. <if test="taskVisible != null and taskVisible != ''">
  607. and t.taskVisible = #{taskVisible}
  608. </if>
  609. GROUP BY left(tb1.taskrcdSubmitdate,7)
  610. order by tb1.taskrcdSubmitdate
  611. </select>
  612. <!-- 溯源统计页面使用:成本占比-明细(农机) -->
  613. <select id="selectPayByNj" parameterType="SelectOfTssStatReqVo" resultType="SpmPayOfTssStatResVo">
  614. select tb1.taskrcdMachineInvestment money,
  615. tb1.taskrcdSubmitdate time,
  616. '农机费用' typeName
  617. from FmsTask t
  618. left join
  619. (select tr.* from FmsTaskrcd tr where tr.taskrcdAuditstatus = '2') tb1
  620. on tb1.taskId = t.taskId
  621. <where>
  622. and left(t.taskCompletedate,4)=#{startTime}
  623. and tb1.taskrcdMachineInvestment>0
  624. and t.tid = #{tid}
  625. <if test="landId != null and landId != ''"> and t.landId = #{landId}</if>
  626. <if test="taskVisible != null and taskVisible != ''">
  627. and t.taskVisible = #{taskVisible}
  628. </if>
  629. </where>
  630. order by tb1.taskrcdSubmitdate desc
  631. </select>
  632. <select id="selectFmsTaskExcelVoList" resultType="com.yunfeiyun.agmp.fms.domain.vo.FmsTaskExcelVo">
  633. SELECT
  634. ft.taskNo,
  635. ft.taskType,
  636. fl.landName,
  637. fb.blockName,
  638. fc.cropName,
  639. ft.taskPlanstartdate,
  640. ft.taskPlanenddate,
  641. ft.taskCreateddate,
  642. ftr.taskrcdCost,
  643. sum(ftm.taskmachInvestmentAmount) as taskmachInvestmentAmount,
  644. sum(fta.taskassetInvestmentAmount) as taskassetInvestmentAmount,
  645. ft.taskAudittype,
  646. ft.taskStatus,
  647. su.userName as taskManagername
  648. FROM
  649. FmsTask ft
  650. LEFT JOIN FmsLand fl ON fl.landId = ft.landId
  651. LEFT JOIN FmsBlock fb on fb.blockId = ft.blockId
  652. LEFT JOIN FmsPlan fp on fp.planId = ft.planId
  653. LEFT JOIn FmsCrop fc on fc.cropId = fp.cropId
  654. LEfT JOIn (select taskId,taskrcdId,taskrcdCost from FmsTaskrcd where taskrcdAuditstatus = '2') ftr on ftr.taskId = ft.taskId
  655. LEFT JOIN FmsTaskmachine ftm on ftm.taskrcdId = ftr.taskrcdId
  656. LEFT JOIN FmsTaskasset fta on fta.taskrcdId = ftr.taskrcdId
  657. LEFT JOIN SysUser su on su.userId = ft.taskManager
  658. <where>
  659. ft.tid = #{tid}
  660. <if test="taskNo != null and taskNo != ''"> and ft.taskNo = #{taskNo}</if>
  661. <if test="planId != null and planId != ''"> and ft.planId = #{planId}</if>
  662. <if test="planNo != null and planNo != ''"> and fp.planNo = #{planNo}</if>
  663. <if test="blockId != null and blockId != ''"> and ft.blockId = #{blockId}</if>
  664. <if test="landId != null and landId != ''"> and ft.landId = #{landId}</if>
  665. <if test="cropId != null and cropId != ''"> and ft.cropId = #{cropId}</if>
  666. <if test="taskAuditstatus != null and taskAuditstatus != ''"> and ft.taskStatus = #{taskAuditstatus}</if>
  667. <if test="taskAudittype != null and taskAudittype != ''"> and ft.taskAudittype = #{taskAudittype}</if>
  668. <if test="cropName != null and cropName != ''"> and fc.cropName = #{cropName}</if>
  669. <if test="taskCreatetype != null and taskCreatetype != ''"> and ft.taskCreatetype = #{taskCreatetype}</if>
  670. <if test="taskType != null and taskType != ''"> and ft.taskType = #{taskType}</if>
  671. <if test="taskType == null || taskType == ''">and ft.taskType >= 0</if>
  672. <if test="taskManager != null and taskManager != ''"> and ft.taskManager = #{taskManager}</if>
  673. <if test="taskVisible != null and taskVisible != ''">and ft.taskVisible = #{taskVisible}</if>
  674. <if test="startDate != null and startDate != ''">
  675. and ft.taskPlanenddate >= #{startDate}
  676. </if>
  677. <if test="endDate != null and endDate != ''">
  678. and ft.taskPlanstartdate <![CDATA[ <= ]]> #{endDate}
  679. </if>
  680. <if test="taskAuditor != null and taskAuditor !=''">
  681. and ft.taskAuditor = #{taskAuditor}
  682. </if>
  683. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  684. AND ft.blockId in
  685. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  686. #{item}
  687. </foreach>
  688. </if>
  689. </where>
  690. GROUP BY ft.taskId
  691. order by taskCreateddate desc
  692. </select>
  693. </mapper>