FmsMachMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.FmsMachMapper">
  6. <sql id="selectFmsMachVo">
  7. select machId, machType, machName, machNo, machBrand, machSpec, machBuydate, machUsestatus, machOwnername, machOwnermobile from FmsMach
  8. </sql>
  9. <select id="selectFmsMachList" parameterType="FmsMachListReqVo" resultType="FmsMach">
  10. <include refid="selectFmsMachVo"/>
  11. <where>
  12. machSystype = '0'
  13. <if test="machType != null and machType != ''"> and machType = #{machType}</if>
  14. <if test="machName != null and machName != ''"> and machName like concat('%', #{machName}, '%')</if>
  15. <if test="machBrand != null and machBrand != ''"> and machBrand like concat('%', #{machBrand}, '%')</if>
  16. <if test="machUsestatus != null and machUsestatus != ''"> and machUsestatus = #{machUsestatus}</if>
  17. <if test="tid != null and tid !='' and tid != '-1'">
  18. and tid = #{tid}
  19. </if>
  20. </where>
  21. ORDER BY machId DESC
  22. </select>
  23. <select id="selectFmsMachByMachId" parameterType="String" resultType="FmsMach">
  24. <include refid="selectFmsMachVo"/>
  25. where machId = #{machId} and machSystype = '0'
  26. <if test="tid != null and tid !='' and tid != '-1'">
  27. and tid = #{tid}
  28. </if>
  29. </select>
  30. <select id="selectFmsMachByMachNo" parameterType="String" resultType="FmsMach">
  31. <include refid="selectFmsMachVo"/>
  32. where machNo = #{machNo} and machSystype = '0'
  33. <if test="tid != null and tid !='' and tid != '-1'">
  34. and tid = #{tid}
  35. </if>
  36. </select>
  37. <select id="selectFmsMachRecordList" parameterType="FmsMachRecordListReqVo" resultType="FmsMachRecordListResVo">
  38. SELECT ma.machName, ma.machType, p.planNo, t.taskId, t.taskNo, c.cropName, c.cropType, c.cropMaintype, m.taskmachUsedcount,
  39. ma.machNo, ma.machSpec, tc.taskrcdId, tc.taskrcdCompletedate, t.taskManager, u.userName AS taskManagername,
  40. t.taskType
  41. FROM FmsTaskmachine AS m
  42. JOIN FmsTaskrcd AS tc ON m.taskrcdId = tc.taskrcdId AND tc.taskrcdAuditstatus = #{taskrcdAuditstatus}
  43. JOIN FmsTask AS t ON tc.taskId = t.taskId
  44. JOIN FmsCrop AS c ON t.cropId = c.cropId
  45. JOIN FmsMach AS ma ON m.machId = ma.machId
  46. JOIN SysUser AS u ON t.taskManager = u.userId
  47. JOIN FmsPlan AS p ON p.planId = t.planId
  48. <where>
  49. machSystype = '0'
  50. <if test="machType != null and machType != ''"> and machType = #{machType}</if>
  51. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  52. <if test="machName != null and machName != ''"> and machName like concat('%', #{machName}, '%')</if>
  53. <if test="planNo != null and planNo != ''"> and p.planNo like concat('%', #{planNo}, '%')</if>
  54. <if test="taskNo != null and taskNo != ''"> and t.taskNo like concat('%', #{taskNo}, '%')</if>
  55. <if test="cropName != null and cropName != ''"> and c.cropName like concat('%', #{cropName}, '%')</if>
  56. <if test="taskManagername != null and taskManagername != ''"> and u.userName like concat('%', #{taskManagername}, '%')</if>
  57. <if test="startDate != null and startDate != ''">
  58. and tc.taskrcdCompletedate >= #{startDate}
  59. </if>
  60. <if test="endDate != null and endDate != ''">
  61. and tc.taskrcdCompletedate <![CDATA[ <= ]]> #{endDate}
  62. </if>
  63. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  64. AND t.blockId in
  65. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  66. #{item}
  67. </foreach>
  68. </if>
  69. <if test="tid != null and tid !='' and tid != '-1'">
  70. and m.tid = #{tid}
  71. </if>
  72. </where>
  73. ORDER BY tc.taskrcdCompletedate DESC
  74. </select>
  75. <select id="selectFmsMachRecordExcelVoList"
  76. resultType="com.yunfeiyun.agmp.fms.domain.vo.FmsMachRecordExcelVo">
  77. SELECT
  78. ma.machName,
  79. ma.machType,
  80. t.taskNo,
  81. c.cropName,
  82. c.cropType,
  83. m.taskmachUsedcount,
  84. ma.machNo,
  85. ma.machSpec,
  86. tc.taskrcdCompletedate,
  87. m.taskmachInvestmentAmount,
  88. u.userName AS taskManagername
  89. FROM
  90. FmsTaskmachine AS m
  91. JOIN FmsTaskrcd AS tc ON m.taskrcdId = tc.taskrcdId
  92. JOIN FmsTask AS t ON tc.taskId = t.taskId
  93. JOIN FmsCrop AS c ON t.cropId = c.cropId
  94. JOIN FmsMach AS ma ON m.machId = ma.machId
  95. JOIN SysUser AS u ON t.taskManager = u.userId
  96. JOIN FmsPlan AS p ON p.planId = t.planId
  97. <where>
  98. tc.taskrcdAuditstatus = '2' and machSystype = '0'
  99. <if test="machType != null and machType != ''"> and machType = #{machType}</if>
  100. <if test="blockId != null and blockId != ''"> and t.blockId = #{blockId}</if>
  101. <if test="machName != null and machName != ''"> and machName like concat('%', #{machName}, '%')</if>
  102. <if test="planNo != null and planNo != ''"> and p.planNo like concat('%', #{planNo}, '%')</if>
  103. <if test="taskNo != null and taskNo != ''"> and t.taskNo like concat('%', #{taskNo}, '%')</if>
  104. <if test="cropName != null and cropName != ''"> and c.cropName like concat('%', #{cropName}, '%')</if>
  105. <if test="taskManagername != null and taskManagername != ''"> and u.userName like concat('%', #{taskManagername}, '%')</if>
  106. <if test="startDate != null and startDate != ''">
  107. and tc.taskrcdCompletedate >= #{startDate}
  108. </if>
  109. <if test="endDate != null and endDate != ''">
  110. and tc.taskrcdCompletedate <![CDATA[ <= ]]> #{endDate}
  111. </if>
  112. <if test="dataFilter == true and blockIds != null and blockIds.size() > 0">
  113. AND t.blockId in
  114. <foreach collection="blockIds" item="item" open="(" separator="," close=")">
  115. #{item}
  116. </foreach>
  117. </if>
  118. <if test="tid != null and tid !='' and tid != '-1'">
  119. and m.tid = #{tid}
  120. </if>
  121. </where>
  122. ORDER BY tc.taskrcdCompletedate DESC
  123. </select>
  124. <select id="selectFmsMachExcelVoList" resultType="com.yunfeiyun.agmp.fms.domain.vo.FmsMachExcelVo">
  125. select machId, machType, machName, machNo, machBrand, machSpec, machBuydate, machUsestatus, machOwnername, machOwnermobile from FmsMach
  126. <where>
  127. machSystype = '0'
  128. <if test="machType != null and machType != ''"> and machType = #{machType}</if>
  129. <if test="machName != null and machName != ''"> and machName like concat('%', #{machName}, '%')</if>
  130. <if test="machBrand != null and machBrand != ''"> and machBrand like concat('%', #{machBrand}, '%')</if>
  131. <if test="machUsestatus != null and machUsestatus != ''"> and machUsestatus = #{machUsestatus}</if>
  132. <if test="tid != null and tid !='' and tid != '-1'">
  133. and tid = #{tid}
  134. </if>
  135. </where>
  136. ORDER BY machId DESC
  137. </select>
  138. <select id="selectFmsMachTypeStat" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsMachTypeStatResVo">
  139. SELECT
  140. machType,
  141. IFNULL( count( machType ), 0 ) AS num
  142. FROM FmsMach
  143. <where>
  144. machSystype = '0' and tid = #{tid}
  145. </where>
  146. GROUP BY machType
  147. </select>
  148. <select id="selectFmsMachSum" resultType="BigDecimal">
  149. select count(1) count from FmsMach
  150. <where>
  151. machSystype = '0'
  152. <if test="tid != null and tid !='' and tid != '-1'">
  153. and tid = #{tid}
  154. </if>
  155. </where>
  156. </select>
  157. <insert id="insertFmsMach" parameterType="FmsMach">
  158. insert into FmsMach
  159. <trim prefix="(" suffix=")" suffixOverrides=",">
  160. <if test="machId != null">machId,</if>
  161. <if test="machType != null">machType,</if>
  162. <if test="machName != null">machName,</if>
  163. <if test="machNo != null">machNo,</if>
  164. <if test="machBrand != null">machBrand,</if>
  165. <if test="machSpec != null">machSpec,</if>
  166. <if test="machBuydate != null">machBuydate,</if>
  167. <if test="machUsestatus != null">machUsestatus,</if>
  168. <if test="machOwnername != null">machOwnername,</if>
  169. <if test="machOwnermobile != null">machOwnermobile,</if>
  170. machSystype,
  171. tid
  172. </trim>
  173. <trim prefix="values (" suffix=")" suffixOverrides=",">
  174. <if test="machId != null">#{machId},</if>
  175. <if test="machType != null">#{machType},</if>
  176. <if test="machName != null">#{machName},</if>
  177. <if test="machNo != null">#{machNo},</if>
  178. <if test="machBrand != null">#{machBrand},</if>
  179. <if test="machSpec != null">#{machSpec},</if>
  180. <if test="machBuydate != null">#{machBuydate},</if>
  181. <if test="machUsestatus != null">#{machUsestatus},</if>
  182. <if test="machOwnername != null">#{machOwnername},</if>
  183. <if test="machOwnermobile != null">#{machOwnermobile},</if>
  184. '0',
  185. #{tid}
  186. </trim>
  187. </insert>
  188. <update id="updateFmsMach" parameterType="FmsMach">
  189. update FmsMach
  190. <trim prefix="SET" suffixOverrides=",">
  191. <if test="machType != null">machType = #{machType},</if>
  192. <if test="machName != null">machName = #{machName},</if>
  193. <if test="machNo != null">machNo = #{machNo},</if>
  194. <if test="machBrand != null">machBrand = #{machBrand},</if>
  195. <if test="machSpec != null">machSpec = #{machSpec},</if>
  196. <if test="machBuydate != null">machBuydate = #{machBuydate},</if>
  197. <if test="machUsestatus != null">machUsestatus = #{machUsestatus},</if>
  198. <if test="machOwnername != null">machOwnername = #{machOwnername},</if>
  199. <if test="machOwnermobile != null">machOwnermobile = #{machOwnermobile},</if>
  200. <if test="tid != null">tid = #{tid},</if>
  201. </trim>
  202. where machId = #{machId} and machSystype = '0' and tid = #{tid}
  203. </update>
  204. <delete id="deleteFmsMachByMachId" parameterType="String">
  205. delete from FmsMach where machId = #{machId} and machSystype = '0' and tid = #{tid}
  206. </delete>
  207. <delete id="deleteFmsMachByMachIds" parameterType="String">
  208. delete from FmsMach where machSystype = '0' and tid = #{tid} and machId in
  209. <foreach item="machId" collection="array" open="(" separator="," close=")">
  210. #{machId}
  211. </foreach>
  212. </delete>
  213. </mapper>