FmsPlanMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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.FmsPlanMapper">
  6. <sql id="selectFmsPlanVo">
  7. select planId, planNo, landId, blockId, cropId, planArea, planPlanstartdate, planPlanenddate, planStartdate, planEnddate, planStatus, planRemark, planCreator, planCreateddate, planModifier, planModifieddate, planPeriodname from FmsPlan
  8. </sql>
  9. <select id="selectFmsPlanList" parameterType="FmsPlan" resultType="FmsPlan">
  10. <include refid="selectFmsPlanVo"/>
  11. <where>
  12. tid = #{tid}
  13. <if test="planNo != null and planNo != ''"> and planNo = #{planNo}</if>
  14. <if test="landId != null and landId != ''"> and landId = #{landId}</if>
  15. <if test="blockId != null and blockId != ''"> and blockId = #{blockId}</if>
  16. <if test="cropId != null and cropId != ''"> and cropId = #{cropId}</if>
  17. <if test="planArea != null "> and planArea = #{planArea}</if>
  18. <if test="planPlanstartdate != null and planPlanstartdate != ''"> and planPlanstartdate = #{planPlanstartdate}</if>
  19. <if test="planPlanenddate != null and planPlanenddate != ''"> and planPlanenddate = #{planPlanenddate}</if>
  20. <if test="planStartdate != null and planStartdate != ''"> and planStartdate = #{planStartdate}</if>
  21. <if test="planEnddate != null and planEnddate != ''"> and planEnddate = #{planEnddate}</if>
  22. <if test="planStatus != null and planStatus != ''">
  23. and
  24. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  25. <if test="items != null and items != ''">
  26. planStatus = #{items}
  27. </if>
  28. </foreach>
  29. </if>
  30. <if test="planRemark != null and planRemark != ''"> and planRemark = #{planRemark}</if>
  31. <if test="planCreator != null and planCreator != ''"> and planCreator = #{planCreator}</if>
  32. <if test="planCreateddate != null and planCreateddate != ''"> and planCreateddate = #{planCreateddate}</if>
  33. <if test="planModifier != null and planModifier != ''"> and planModifier = #{planModifier}</if>
  34. <if test="planModifieddate != null and planModifieddate != ''"> and planModifieddate = #{planModifieddate}</if>
  35. <if test="planPeriodname != null and planPeriodname != ''"> and planPeriodname = #{planPeriodname}</if>
  36. </where>
  37. </select>
  38. <select id="selectFmsPlanNoList" parameterType="FmsPlan" resultType="FmsPlan">
  39. select
  40. planId,
  41. planNo
  42. from FmsPlan
  43. <where>
  44. tid = #{tid}
  45. </where>
  46. order by planNo desc
  47. </select>
  48. <select id="selectCountFmsPlanByBlockId" parameterType="String" resultType="int">
  49. select count(1) from FmsPlan where blockId = #{blockId}
  50. <if test="tid != null and tid !='' and tid != '-1'">and tid = #{tid}</if>
  51. </select>
  52. <select id="selectCountFmsPlan" parameterType="FmsPlanReqVo" resultType="int">
  53. select count(1) from FmsPlan
  54. <where>
  55. <if test="planNo != null and planNo != ''"> and planNo = #{planNo}</if>
  56. <if test="landId != null and landId != ''"> and landId = #{landId}</if>
  57. <if test="blockId != null and blockId != ''"> and blockId = #{blockId}</if>
  58. <if test="cropId != null and cropId != ''"> and cropId = #{cropId}</if>
  59. <if test="planStatus != null and planStatus != ''">
  60. and
  61. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  62. <if test="items != null and items != ''">
  63. planStatus = #{items}
  64. </if>
  65. </foreach>
  66. </if>
  67. <if test="tid != null and tid !='' and tid != '-1'">and tid = #{tid}</if>
  68. </where>
  69. </select>
  70. <select id="selectPlanList" parameterType="FmsPlanReqVo" resultType="FmsPlanResVo">
  71. SELECT p.*,c.cropName, c.cropType, c.cropMaintype, l.landName, b.blockName,
  72. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') cropPreview,
  73. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') resIds,
  74. (select sum(tp.pickWeight) from FmsTaskpick tp left join FmsTask f on tp.taskId = f.taskId where f.planId = p.planId) pickWeightSum
  75. from FmsPlan p
  76. LEFT JOIN FmsCrop c ON p.cropId = c.cropId
  77. LEFT JOIN FmsLand l ON p.landId = l.landId
  78. LEFT JOIN FmsBlock b ON p.blockId = b.blockId
  79. <where>
  80. <if test="planNo != null and planNo != ''"> and p.planNo = #{planNo}</if>
  81. <if test="landId != null and landId != ''"> and p.landId = #{landId}</if>
  82. <if test="blockId != null and blockId != ''"> and p.blockId = #{blockId}</if>
  83. <if test="cropId != null and cropId != ''"> and p.cropId = #{cropId}</if>
  84. <if test="cropName != null and cropName != ''"> and c.cropName = #{cropName}</if>
  85. <if test="planStatus != null and planStatus != ''">
  86. and
  87. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  88. <if test="items != null and items != ''">
  89. p.planStatus = #{items}
  90. </if>
  91. </foreach>
  92. </if>
  93. <if test="startDate != null and startDate != ''">
  94. and p.planPlanenddate >= #{startDate}
  95. </if>
  96. <if test=" endDate != null and endDate != ''">
  97. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  98. </if>
  99. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  100. AND b.blockId in
  101. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  102. #{item}
  103. </foreach>
  104. </if>
  105. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  106. </where>
  107. order by p.planNo desc
  108. </select>
  109. <select id="selectPlanListScheduler" parameterType="FmsPlanReqVo" resultType="FmsPlan">
  110. SELECT p.* from FmsPlan p
  111. <where>
  112. <if test="planNo != null and planNo != ''"> and p.planNo = #{planNo}</if>
  113. <if test="landId != null and landId != ''"> and p.landId = #{landId}</if>
  114. <if test="blockId != null and blockId != ''"> and p.blockId = #{blockId}</if>
  115. <if test="cropId != null and cropId != ''"> and p.cropId = #{cropId}</if>
  116. <if test="planStatus != null and planStatus != ''">
  117. and
  118. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  119. <if test="items != null and items != ''">
  120. p.planStatus = #{items}
  121. </if>
  122. </foreach>
  123. </if>
  124. <if test="startDate != null and startDate != ''">
  125. and p.planPlanenddate >= #{startDate}
  126. </if>
  127. <if test=" endDate != null and endDate != ''">
  128. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  129. </if>
  130. <if test=" nowDate != null and nowDate != ''">
  131. <if test="updateType != null and updateType == '0'.toString()">
  132. and p.planPlanstartdate <![CDATA[ <= ]]> #{nowDate}
  133. </if>
  134. <if test="updateType != null and updateType == '1'.toString()">
  135. and p.planPlanenddate <![CDATA[ < ]]> #{nowDate}
  136. </if>
  137. </if>
  138. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  139. </where>
  140. </select>
  141. <select id="selectFmsPlanByPlanId" parameterType="String" resultType="FmsPlanResVo">
  142. select p.*, c.cropName, c.cropType, c.cropMaintype, fb.blockName, fl.landName
  143. from FmsPlan p
  144. LEFT JOIN FmsCrop c ON p.cropId = c.cropId
  145. LEFT JOIN FmsBlock fb on fb.blockId = p.blockId
  146. LEFT JOIN FmsLand fl on fl.landId = p.landId
  147. where p.planId = #{planId}
  148. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  149. </select>
  150. <select id="selectFmsPlanRecordByPlanId" parameterType="String" resultType="FmsPlanResVo">
  151. select p.*, c.cropName, c.cropType, c.cropMaintype, l.landName, b.blockName,
  152. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') cropPreview,
  153. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') resIds
  154. from FmsPlan p
  155. LEFT JOIN FmsCrop c ON p.cropId = c.cropId
  156. LEFT JOIN FmsLand l ON l.landId = p.landId
  157. LEFT JOIN FmsBlock b ON b.blockId = p.blockId
  158. where planId = #{planId}
  159. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  160. </select>
  161. <select id="selectSumPlanArea" parameterType="FmsPlanReqVo" resultType="BigDecimal">
  162. SELECT sum(p.planArea) FROM FmsPlan p
  163. <where>
  164. <if test="planStatus != null and planStatus != ''">
  165. and
  166. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  167. <if test="items != null and items != ''">
  168. p.planStatus = #{items}
  169. </if>
  170. </foreach>
  171. </if>
  172. <if test="landId != null and landId != ''">
  173. and p.landId = #{landId}
  174. </if>
  175. <if test="blockId != null and blockId != ''">
  176. and p.blockId = #{blockId}
  177. </if>
  178. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  179. AND p.blockId in
  180. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  181. #{item}
  182. </foreach>
  183. </if>
  184. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  185. </where>
  186. </select>
  187. <select id="selectPlanByCropName" parameterType="FmsPlanReqVo" resultType="FmsPlanResVo">
  188. SELECT c.cropName,sum(p.planArea) planArea FROM FmsPlan p
  189. LEFT JOIN FmsLand l ON p.landId = l.landId
  190. LEFT JOIN FmsCrop c ON p.cropId = c.cropId
  191. LEFT JOIN FmsBlock b on b.blockId = p.blockId
  192. <where>
  193. <if test="planStatus != null and planStatus != ''">
  194. and
  195. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  196. <if test="items != null and items != ''">
  197. p.planStatus = #{items}
  198. </if>
  199. </foreach>
  200. </if>
  201. <if test="landId != null and landId != ''">
  202. and p.landId = #{landId}
  203. </if>
  204. <if test="blockId != null and blockId != ''">
  205. and p.blockId = #{blockId}
  206. </if>
  207. <if test="startDate != null and startDate != ''">
  208. and p.planPlanenddate >= #{startDate}
  209. </if>
  210. <if test="endDate != null and endDate != ''">
  211. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  212. </if>
  213. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  214. AND l.landId in
  215. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  216. #{item}
  217. </foreach>
  218. </if>
  219. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  220. </where>
  221. GROUP BY c.cropName
  222. </select>
  223. <select id="selectPlanByCropNameAndType" parameterType="FmsPlanReqVo" resultType="FmsPlanResVo">
  224. SELECT c.cropName, c.cropType,
  225. sum(p.planArea) planArea
  226. FROM FmsPlan p
  227. LEFT JOIN FmsLand l ON p.landId = l.landId
  228. LEFT JOIN FmsCrop c ON p.cropId = c.cropId
  229. <where>
  230. <if test="planStatus != null and planStatus != ''">
  231. and
  232. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  233. <if test="items != null and items != ''">
  234. p.planStatus = #{items}
  235. </if>
  236. </foreach>
  237. </if>
  238. <if test="landId != null and landId != ''">
  239. and p.landId = #{landId}
  240. </if>
  241. <if test="blockId != null and blockId != ''">
  242. and p.blockId = #{blockId}
  243. </if>
  244. <if test="startDate != null and startDate != ''">
  245. and p.planPlanenddate >= #{startDate}
  246. </if>
  247. <if test="endDate != null and endDate != ''">
  248. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  249. </if>
  250. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  251. </where>
  252. GROUP BY c.cropName, c.cropType
  253. </select>
  254. <select id="selectPlanByLandId" parameterType="FmsPlanReqVo" resultType="FmsPlanResVo">
  255. SELECT l.landId, l.landName, sum(p.planArea) planArea FROM FmsPlan p
  256. LEFT JOIN FmsLand l ON p.landId = l.landId
  257. <where>
  258. l.landId is not null
  259. <if test="planStatus != null and planStatus != ''">
  260. and
  261. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  262. <if test="items != null and items != ''">
  263. p.planStatus = #{items}
  264. </if>
  265. </foreach>
  266. </if>
  267. <if test="landId != null and landId != ''">
  268. and p.landId = #{landId}
  269. </if>
  270. <if test="blockId != null and blockId != ''">
  271. and p.blockId = #{blockId}
  272. </if>
  273. <if test="startDate != null and startDate != ''">
  274. and p.planPlanenddate >= #{startDate}
  275. </if>
  276. <if test="endDate != null and endDate != ''">
  277. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  278. </if>
  279. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  280. AND l.landId in
  281. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  282. #{item}
  283. </foreach>
  284. </if>
  285. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  286. </where>
  287. GROUP BY l.landId
  288. </select>
  289. <select id="selectPlanByBlockId" parameterType="FmsPlanReqVo" resultType="FmsPlanResVo">
  290. SELECT b.blockId, b.blockName, sum(p.planArea) planArea FROM FmsPlan p
  291. LEFT JOIN FmsBlock b on b.blockId = p.blockId
  292. <where>
  293. b.blockId is not null
  294. <if test="planStatus != null and planStatus != ''">
  295. and
  296. <foreach collection="planStatus.split(',')" item="items" open="(" separator="or" close=")">
  297. <if test="items != null and items != ''">
  298. p.planStatus = #{items}
  299. </if>
  300. </foreach>
  301. </if>
  302. <if test="landId != null and landId != ''">
  303. and p.landId = #{landId}
  304. </if>
  305. <if test="blockId != null and blockId != ''">
  306. and p.blockId = #{blockId}
  307. </if>
  308. <if test="startDate != null and startDate != ''">
  309. and p.planPlanenddate >= #{startDate}
  310. </if>
  311. <if test="endDate != null and endDate != ''">
  312. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  313. </if>
  314. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  315. <if test="dataFilter == true and landIds != null and landIds.size() > 0">
  316. AND l.landId in
  317. <foreach collection="landIds" item="item" open="(" separator="," close=")">
  318. #{item}
  319. </foreach>
  320. </if>
  321. </where>
  322. GROUP BY b.blockId
  323. </select>
  324. <insert id="insertFmsPlan" parameterType="FmsPlan">
  325. insert into FmsPlan
  326. <trim prefix="(" suffix=")" suffixOverrides=",">
  327. <if test="planId != null">planId,</if>
  328. <if test="planNo != null">planNo,</if>
  329. <if test="landId != null">landId,</if>
  330. <if test="blockId != null">blockId,</if>
  331. <if test="cropId != null">cropId,</if>
  332. <if test="planArea != null">planArea,</if>
  333. <if test="planPlanstartdate != null">planPlanstartdate,</if>
  334. <if test="planPlanenddate != null">planPlanenddate,</if>
  335. <if test="planStartdate != null">planStartdate,</if>
  336. <if test="planEnddate != null">planEnddate,</if>
  337. <if test="planStatus != null">planStatus,</if>
  338. <if test="planRemark != null">planRemark,</if>
  339. <if test="planCreator != null">planCreator,</if>
  340. <if test="planCreateddate != null">planCreateddate,</if>
  341. <if test="planModifier != null">planModifier,</if>
  342. <if test="planModifieddate != null">planModifieddate,</if>
  343. <if test="planPeriodname != null">planPeriodname,</if>
  344. <if test="tid != null">tid,</if>
  345. </trim>
  346. <trim prefix="values (" suffix=")" suffixOverrides=",">
  347. <if test="planId != null">#{planId},</if>
  348. <if test="planNo != null">#{planNo},</if>
  349. <if test="landId != null">#{landId},</if>
  350. <if test="blockId != null">#{blockId},</if>
  351. <if test="cropId != null">#{cropId},</if>
  352. <if test="planArea != null">#{planArea},</if>
  353. <if test="planPlanstartdate != null">#{planPlanstartdate},</if>
  354. <if test="planPlanenddate != null">#{planPlanenddate},</if>
  355. <if test="planStartdate != null">#{planStartdate},</if>
  356. <if test="planEnddate != null">#{planEnddate},</if>
  357. <if test="planStatus != null">#{planStatusArray},</if>
  358. <if test="planRemark != null">#{planRemark},</if>
  359. <if test="planCreator != null">#{planCreator},</if>
  360. <if test="planCreateddate != null">#{planCreateddate},</if>
  361. <if test="planModifier != null">#{planModifier},</if>
  362. <if test="planModifieddate != null">#{planModifieddate},</if>
  363. <if test="planPeriodname != null">#{planPeriodname},</if>
  364. <if test="tid != null">#{tid},</if>
  365. </trim>
  366. </insert>
  367. <update id="updateFmsPlan" parameterType="FmsPlan">
  368. update FmsPlan
  369. <trim prefix="SET" suffixOverrides=",">
  370. <if test="planNo != null">planNo = #{planNo},</if>
  371. <if test="landId != null">landId = #{landId},</if>
  372. <if test="blockId != null">blockId = #{blockId},</if>
  373. <if test="cropId != null">cropId = #{cropId},</if>
  374. <if test="planArea != null">planArea = #{planArea},</if>
  375. <if test="planPlanstartdate != null">planPlanstartdate = #{planPlanstartdate},</if>
  376. <if test="planPlanenddate != null">planPlanenddate = #{planPlanenddate},</if>
  377. <if test="planStartdate != null">planStartdate = #{planStartdate},</if>
  378. <if test="planEnddate != null">planEnddate = #{planEnddate},</if>
  379. <if test="planStatus != null">planStatus = #{planStatusArray},</if>
  380. <if test="planRemark != null">planRemark = #{planRemark},</if>
  381. <if test="planCreator != null">planCreator = #{planCreator},</if>
  382. <if test="planCreateddate != null">planCreateddate = #{planCreateddate},</if>
  383. <if test="planModifier != null">planModifier = #{planModifier},</if>
  384. <if test="planModifieddate != null">planModifieddate = #{planModifieddate},</if>
  385. <if test="planPeriodname != null">planPeriodname = #{planPeriodname},</if>
  386. </trim>
  387. where planId = #{planId}
  388. <if test="tid != null and tid !='' and tid != '-1'">and tid = #{tid}</if>
  389. </update>
  390. <update id="updateFmsPlanBatch" parameterType="FmsPlan">
  391. <foreach collection="list" item="fmsPlan" separator=";">
  392. update FmsPlan
  393. <trim prefix="SET" suffixOverrides=",">
  394. <if test="fmsPlan.planNo != null">planNo = #{fmsPlan.planNo},</if>
  395. <if test="fmsPlan.landId != null">landId = #{fmsPlan.landId},</if>
  396. <if test="fmsPlan.blockId != null">blockId = #{fmsPlan.blockId},</if>
  397. <if test="fmsPlan.cropId != null">cropId = #{fmsPlan.cropId},</if>
  398. <if test="fmsPlan.planArea != null">planArea = #{fmsPlan.planArea},</if>
  399. <if test="fmsPlan.planPlanstartdate != null">planPlanstartdate = #{fmsPlan.planPlanstartdate},</if>
  400. <if test="fmsPlan.planPlanenddate != null">planPlanenddate = #{fmsPlan.planPlanenddate},</if>
  401. <if test="fmsPlan.planStartdate != null">planStartdate = #{fmsPlan.planStartdate},</if>
  402. <if test="fmsPlan.planEnddate != null">planEnddate = #{fmsPlan.planEnddate},</if>
  403. <if test="fmsPlan.planStatus != null">planStatus = #{fmsPlan.planStatus},</if>
  404. <if test="fmsPlan.planRemark != null">planRemark = #{fmsPlan.planRemark},</if>
  405. <if test="fmsPlan.planCreator != null">planCreator = #{fmsPlan.planCreator},</if>
  406. <if test="fmsPlan.planCreateddate != null">planCreateddate = #{fmsPlan.planCreateddate},</if>
  407. <if test="fmsPlan.planModifier != null">planModifier = #{fmsPlan.planModifier},</if>
  408. <if test="fmsPlan.planModifieddate != null">planModifieddate = #{fmsPlan.planModifieddate},</if>
  409. <if test="fmsPlan.planPeriodname != null">planPeriodname = #{fmsPlan.planPeriodname},</if>
  410. <if test="fmsPlan.tid != null">tid = #{fmsPlan.tid},</if>
  411. </trim>
  412. where planId = #{fmsPlan.planId}
  413. <if test="fmsPlan.tid != null and fmsPlan.tid !='' and fmsPlan.tid != '-1'">and tid = #{fmsPlan.tid}</if>
  414. </foreach>
  415. </update>
  416. <delete id="deleteFmsPlanByPlanId" parameterType="String">
  417. delete from FmsPlan
  418. where
  419. planId = #{planId}
  420. <if test="tid != null and tid !='' and tid != '-1'">and tid = #{tid}</if>
  421. </delete>
  422. <delete id="deleteFmsPlanByPlanIds" parameterType="String">
  423. delete from FmsPlan where planId in
  424. <foreach item="planId" collection="array" open="(" separator="," close=")">
  425. #{planId}
  426. </foreach>
  427. <if test="tid != null and tid !='' and tid != '-1'">and tid = #{tid}</if>
  428. </delete>
  429. <select id="selectPlanListByWarnScheduler" resultType="FmsPlanByWarnSchedulerDto">
  430. SELECT p.planId,p.landId, pe.periodId, pe.periodName, pe.periodRemark, p.planPlanstartdate, p.planPlanenddate,p.tid,
  431. p.planEnddate, pe.periodDays, pe.periodSeq
  432. FROM FmsPlan AS p
  433. JOIN FmsCrop AS c ON p.cropId = c.cropId
  434. JOIN FmsPeriod AS pe ON p.cropId = pe.cropId
  435. <where>
  436. p.planStatus = 1
  437. <if test="planEnddate != null and planEnddate != ''">
  438. and p.planEnddate >= #{planEnddate} OR p.planEnddate IS NULL
  439. </if>
  440. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  441. </where>
  442. ORDER BY p.planId, pe.periodId, pe.periodSeq
  443. </select>
  444. <select id="selectPlanListOfTaskStatus" parameterType="String" resultType="FmsPlanListOfTaskStatusResVo">
  445. SELECT p.planId, p.blockId, p.cropId, p.landId, p.planNo, p.planPeriodname, c.cropName, c.cropType, b.blockName,p.planplanstartdate,p.planPlanenddate,
  446. (SELECT count(1) FROM FmsTask t WHERE t.taskStatus <![CDATA[ < ]]> 2 and t.planId = p.planId and t.taskManager = #{userId}) taskCount,
  447. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') cropPreview
  448. FROM FmsPlan p
  449. LEFT JOIN FmsCrop c on c.cropId = p.cropId
  450. LEFT JOIN FmsBlock b on b.blockId = p.blockId
  451. <where>
  452. <if test="landId != null and landId != ''">
  453. and p.landId = #{landId}
  454. </if>
  455. <if test="tid != null and tid !='' and tid != '-1'">and p.tid = #{tid}</if>
  456. and p.planStatus != '2'
  457. </where>
  458. </select>
  459. <select id="selectBlockManagerByPlanId" resultType="java.lang.String">
  460. SELECT
  461. fb.blockManager
  462. FROM
  463. FmsPlan fp
  464. LEFT JOIN FmsBlock fb on fb.blockId = fp.blockId
  465. where fp.planId = #{planId}
  466. <if test="tid != null and tid !='' and tid != '-1'">and fp.tid = #{tid}</if>
  467. </select>
  468. <select id="selectCropPlanAreaTop" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsCropPlanAreaResVo">
  469. SELECT
  470. sum( planArea ) planArea,
  471. cropId
  472. FROM
  473. FmsPlan
  474. <where>
  475. tid = #{tid}
  476. <if test="blockIds != null and blockIds.size() != 0">
  477. and blockId in
  478. <foreach collection="blockIds" item="item" index="index" open="(" separator="," close=")">
  479. #{item}
  480. </foreach>
  481. </if>
  482. </where>
  483. GROUP BY cropId
  484. ORDER BY sum( planArea ) DESC
  485. </select>
  486. <select id="selectFmsPlanCropResVoList" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsPlanCropResVo">
  487. select
  488. p.*,
  489. c.cropId,
  490. c.cropName,
  491. c.cropType,
  492. c.cropMaintype,
  493. c.tid
  494. from
  495. FmsPlan p
  496. LEFT JOIN
  497. (select * from FmsCrop where tid = #{tid}) c on p.cropId = c.cropId
  498. <where>
  499. p.tid = #{tid}
  500. <if test="planNo != null and planNo != ''"> and p.planNo = #{planNo}</if>
  501. <if test="landId != null and landId != ''"> and p.landId = #{landId}</if>
  502. <if test="blockId != null and blockId != ''"> and p.blockId = #{blockId}</if>
  503. <if test="cropId != null and cropId != ''"> and p.cropId = #{cropId}</if>
  504. <if test="cropName != null and cropName != ''"> and c.cropName = #{cropName}</if>
  505. <if test="planStatus != null and planStatus != ''">
  506. and p.planStatus = #{planStatus}
  507. </if>
  508. <if test="startDate != null and startDate != ''">
  509. and p.planPlanenddate >= #{startDate}
  510. </if>
  511. <if test=" endDate != null and endDate != ''">
  512. and p.planPlanstartdate <![CDATA[ <= ]]> #{endDate}
  513. </if>
  514. <if test="blockIds != null and blockIds.size() > 0">
  515. AND p.blockId in
  516. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  517. #{item}
  518. </foreach>
  519. </if>
  520. <if test="planStatusArray != null and planStatusArray.size() > 0">
  521. AND p.planStatus in
  522. <foreach collection="planStatusArray" index="index" item="item" open="(" separator="," close=")">
  523. #{item}
  524. </foreach>
  525. </if>
  526. </where>
  527. </select>
  528. </mapper>