FmsCropMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.FmsCropMapper">
  6. <sql id="selectFmsCropVo">
  7. select cropId, cropName, cropType, cropMaintype, cropRcmdstatus, cropRemark, cropCreator, cropCreateddate, cropInitialvalue,tid,cropProduction from FmsCrop
  8. </sql>
  9. <sql id="selectFmsCropHasResVo">
  10. select c.*,
  11. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') cropPreview,
  12. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') resIds
  13. from FmsCrop c
  14. </sql>
  15. <select id="selectFmsCropList" parameterType="FmsCrop" resultType="FmsCropResVo">
  16. SELECT
  17. cropId,
  18. cropName,
  19. cropType,
  20. cropMaintype,
  21. cropRcmdstatus,
  22. cropRemark,
  23. cropCreator,
  24. cropCreateddate,
  25. cropInitialvalue,
  26. cropProduction,
  27. tid,
  28. ( SELECT count( 1 ) FROM FmsPeriod p WHERE p.cropId = c.cropId ) count,
  29. ( SELECT sum( periodDays ) FROM FmsPeriod p WHERE p.cropId = c.cropId ) periodDays,
  30. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') cropPreview,
  31. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP') resIds,
  32. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP_VIDEO') cropVideo,
  33. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = c.cropId and r.resBiztype = 'CROP_VIDEO') videoIds
  34. FROM
  35. FmsCrop c
  36. <where>
  37. tid = #{tid}
  38. <if test="cropName != null and cropName != ''"> and c.cropName = #{cropName}</if>
  39. <if test="cropType != null and cropType != ''"> and c.cropType = #{cropType}</if>
  40. <if test="cropMaintype != null and cropMaintype != ''"> and c.cropMaintype = #{cropMaintype}</if>
  41. <if test="cropRcmdstatus != null and cropRcmdstatus != ''"> and c.cropRcmdstatus = #{cropRcmdstatus}</if>
  42. <if test="cropRemark != null and cropRemark != ''"> and c.cropRemark = #{cropRemark}</if>
  43. </where>
  44. order by c.cropCreateddate desc
  45. </select>
  46. <select id="selectFmsCropByCropId" parameterType="String" resultType="FmsCrop">
  47. <include refid="selectFmsCropHasResVo"/>
  48. <where>
  49. cropId = #{cropId}
  50. and tid = #{tid}
  51. </where>
  52. </select>
  53. <select id="selectFmsCropNameByCropMaintype" parameterType="String" resultType="FmsCrop">
  54. select cropName from FmsCrop
  55. where cropRcmdstatus = '0'
  56. <if test="cropMaintype != null and cropMaintype != ''"> and cropMaintype = #{cropMaintype}</if>
  57. and tid = #{tid}
  58. group by cropName
  59. </select>
  60. <select id="selectFmsCropNameByBlockId" parameterType="String" resultType="FmsBlockCropDto">
  61. SELECT c.cropName, c.cropType, p.blockId, r.resUrl as cropPreview
  62. FROM FmsPlan p
  63. LEFT JOIN FmsCrop c ON p.cropId = c.cropId
  64. left join SysRes r on r.resBusId = c.cropId and r.resBiztype = 'CROP'
  65. where p.blockId in
  66. <foreach item="blockId" collection="array" open="(" separator="," close=")">
  67. #{blockId}
  68. </foreach>
  69. and p.planStatus != '2'
  70. and p.tid = #{tid}
  71. </select>
  72. <insert id="insertFmsCrop" parameterType="FmsCrop">
  73. insert into FmsCrop
  74. <trim prefix="(" suffix=")" suffixOverrides=",">
  75. <if test="cropId != null">cropId,</if>
  76. <if test="cropName != null">cropName,</if>
  77. <if test="cropType != null">cropType,</if>
  78. <if test="cropMaintype != null">cropMaintype,</if>
  79. <if test="cropRcmdstatus != null">cropRcmdstatus,</if>
  80. <if test="cropRemark != null">cropRemark,</if>
  81. <if test="cropCreator != null">cropCreator,</if>
  82. <if test="cropCreateddate != null">cropCreateddate,</if>
  83. <if test="cropInitialvalue != null">cropInitialvalue,</if>
  84. <if test="cropProduction != null">cropProduction,</if>
  85. <if test="tid != null">tid,</if>
  86. </trim>
  87. <trim prefix="values (" suffix=")" suffixOverrides=",">
  88. <if test="cropId != null">#{cropId},</if>
  89. <if test="cropName != null">#{cropName},</if>
  90. <if test="cropType != null">#{cropType},</if>
  91. <if test="cropMaintype != null">#{cropMaintype},</if>
  92. <if test="cropRcmdstatus != null">#{cropRcmdstatus},</if>
  93. <if test="cropRemark != null">#{cropRemark},</if>
  94. <if test="cropCreator != null">#{cropCreator},</if>
  95. <if test="cropCreateddate != null">#{cropCreateddate},</if>
  96. <if test="cropInitialvalue != null">#{cropInitialvalue},</if>
  97. <if test="cropProduction != null">#{cropProduction},</if>
  98. <if test="tid != null">#{tid},</if>
  99. </trim>
  100. </insert>
  101. <update id="updateFmsCrop" parameterType="FmsCrop">
  102. update FmsCrop
  103. <trim prefix="SET" suffixOverrides=",">
  104. <if test="cropName != null">cropName = #{cropName},</if>
  105. <if test="cropType != null">cropType = #{cropType},</if>
  106. <if test="cropMaintype != null">cropMaintype = #{cropMaintype},</if>
  107. <if test="cropRcmdstatus != null">cropRcmdstatus = #{cropRcmdstatus},</if>
  108. <if test="cropRemark != null">cropRemark = #{cropRemark},</if>
  109. <if test="cropCreator != null">cropCreator = #{cropCreator},</if>
  110. <if test="cropCreateddate != null">cropCreateddate = #{cropCreateddate},</if>
  111. <if test="cropInitialvalue != null">cropInitialvalue = #{cropInitialvalue},</if>
  112. <if test="cropProduction != null">cropProduction = #{cropProduction},</if>
  113. <if test="tid != null">tid = #{tid},</if>
  114. </trim>
  115. where cropId = #{cropId} and tid = #{tid}
  116. </update>
  117. <delete id="deleteFmsCropByCropId" parameterType="String">
  118. delete from FmsCrop where cropId = #{cropId}
  119. and tid = #{tid}
  120. </delete>
  121. <delete id="deleteFmsCropByCropIds" parameterType="String">
  122. delete from FmsCrop where cropId in
  123. <foreach item="cropId" collection="array" open="(" separator="," close=")">
  124. #{cropId}
  125. </foreach>
  126. and tid = #{tid}
  127. </delete>
  128. <select id="selectFmsCropListByCropIds" resultType="com.yunfeiyun.agmp.fms.domain.FmsCrop">
  129. <include refid="selectFmsCropVo"/>
  130. <where>
  131. tid = #{tid}
  132. <if test="cropIds != null and cropIds.size() != 0">
  133. and cropId in
  134. <foreach collection="cropIds" item="item" open="(" separator="," close=")">
  135. #{item}
  136. </foreach>
  137. </if>
  138. </where>
  139. </select>
  140. </mapper>