TWarehousebillsCntritemsMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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.ruoyi.shipping.mapper.TWarehousebillsCntritemsMapper">
  6. <resultMap type="TWarehousebillsCntritems" id="TWarehousebillsCntritemsResult">
  7. <result property="fId" column="f_id" />
  8. <result property="fPid" column="f_pid" />
  9. <result property="fCntrno" column="f_cntrno" />
  10. <result property="fSealno" column="f_sealno" />
  11. <result property="fGoodsid" column="f_goodsid" />
  12. <result property="fPackageid" column="f_packageid" />
  13. <result property="fCntrid" column="f_cntrid" />
  14. <result property="fCntrcount" column="f_cntrcount" />
  15. <result property="fCntrweight" column="f_cntrweight" />
  16. <result property="fCntrstatus" column="f_cntrstatus" />
  17. <result property="fSoc" column="f_soc" />
  18. <result property="fTemperature" column="f_temperature" />
  19. <result property="fDraught" column="f_Draught" />
  20. <result property="fHumidity" column="f_Humidity" />
  21. <result property="fPrecooling" column="f_precooling" />
  22. <result property="fPlantakecntr" column="f_plantakecntr" />
  23. <result property="fIfdanger" column="f_IFDANGER" />
  24. <result property="fManual" column="f_manual" />
  25. <result property="createBy" column="create_by" />
  26. <result property="createTime" column="create_time" />
  27. <result property="updateBy" column="update_by" />
  28. <result property="updateTime" column="update_time" />
  29. <result property="remark" column="remark" />
  30. </resultMap>
  31. <sql id="selectTWarehousebillsCntritemsVo">
  32. select f_id, f_pid, f_cntrno, f_sealno, f_goodsid, f_packageid, f_cntrid, f_cntrcount, f_cntrweight, f_cntrstatus, f_soc, f_temperature, f_Draught, f_Humidity, f_precooling, f_plantakecntr, f_IFDANGER,f_manual, create_by, create_time, update_by, update_time, remark from t_warehousebills_cntritems
  33. </sql>
  34. <select id="selectTWarehousebillsCntritemsList" parameterType="TWarehousebillsCntritems" resultMap="TWarehousebillsCntritemsResult">
  35. SELECT
  36. tw.f_id,
  37. tw.f_pid,
  38. tw.f_cntrno,
  39. tw.f_sealno,
  40. tw.f_goodsid,
  41. tg.f_name goodsName,
  42. tw.f_packageid,
  43. sd.dict_label packageName,
  44. tw.f_cntrid,
  45. tc.f_no cntrName,
  46. tw.f_cntrcount,
  47. tw.f_cntrweight,
  48. tw.f_cntrstatus,
  49. tw.f_soc,
  50. tw.f_temperature,
  51. tw.f_Draught,
  52. tw.f_Humidity,
  53. tw.f_precooling,
  54. si.dict_label precoolingName,
  55. tw.f_plantakecntr,
  56. tw.f_IFDANGER,
  57. sc.dict_label ifdangerName,
  58. tw.create_by,
  59. tw.create_time,
  60. tw.update_by,
  61. tw.update_time,
  62. tw.remark,
  63. tw.f_manual
  64. FROM
  65. t_warehousebills_cntritems tw
  66. LEFT JOIN t_goods tg ON tg.f_id = tw.f_goodsid
  67. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_packageid AND sd.dict_type = 'f_packageid'
  68. LEFT JOIN t_cntr tc ON tc.f_id = tw.f_cntrid
  69. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_precooling AND si.dict_type = 'f_precooling'
  70. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_IFDANGER AND sc.dict_type = 'f_IFDANGER'
  71. <where>
  72. <if test="fPid != null "> and tw.f_pid = #{fPid}</if>
  73. <if test="fCntrno != null and fCntrno != ''"> and tw.f_cntrno = #{fCntrno}</if>
  74. <if test="fSealno != null and fSealno != ''"> and tw.f_sealno = #{fSealno}</if>
  75. <if test="fGoodsid != null "> and tw.f_goodsid = #{fGoodsid}</if>
  76. <if test="fPackageid != null and fPackageid != ''"> and tw.f_packageid = #{fPackageid}</if>
  77. <if test="fCntrid != null "> and tw.f_cntrid = #{fCntrid}</if>
  78. <if test="fCntrcount != null "> and tw.f_cntrcount = #{fCntrcount}</if>
  79. <if test="fCntrweight != null "> and tw.f_cntrweight = #{fCntrweight}</if>
  80. <if test="fCntrstatus != null and fCntrstatus != ''"> and tw.f_cntrstatus = #{fCntrstatus}</if>
  81. <if test="fSoc != null and fSoc != ''"> and tw.f_soc = #{fSoc}</if>
  82. <if test="fTemperature != null and fTemperature != ''"> and tw.f_temperature = #{fTemperature}</if>
  83. <if test="fDraught != null and fDraught != ''"> and tw.f_Draught = #{fDraught}</if>
  84. <if test="fHumidity != null and fHumidity != ''"> and tw.f_Humidity = #{fHumidity}</if>
  85. <if test="fPrecooling != null and fPrecooling != ''"> and tw.f_precooling = #{fPrecooling}</if>
  86. <if test="fPlantakecntr != null "> and tw.f_plantakecntr = #{fPlantakecntr}</if>
  87. <if test="fIfdanger != null and fIfdanger != ''"> and tw.f_IFDANGER = #{fIfdanger}</if>
  88. </where>
  89. </select>
  90. <select id="selectTWarehousebillsCntritemsById" parameterType="Long" resultMap="TWarehousebillsCntritemsResult">
  91. <include refid="selectTWarehousebillsCntritemsVo"/>
  92. where f_id = #{fId}
  93. </select>
  94. <select id="selectTWarehousebillsCntritemsByPId" parameterType="Long" resultMap="TWarehousebillsCntritemsResult">
  95. <include refid="selectTWarehousebillsCntritemsVo"/>
  96. where f_pid = #{fId}
  97. </select>
  98. <insert id="insertTWarehousebillsCntritems" parameterType="TWarehousebillsCntritems" useGeneratedKeys="true" keyProperty="fId">
  99. insert into t_warehousebills_cntritems
  100. <trim prefix="(" suffix=")" suffixOverrides=",">
  101. <if test="fPid != null">f_pid,</if>
  102. <if test="fCntrno != null and fCntrno != ''">f_cntrno,</if>
  103. <if test="fSealno != null and fSealno != ''">f_sealno,</if>
  104. <if test="fGoodsid != null">f_goodsid,</if>
  105. <if test="fPackageid != null and fPackageid != ''">f_packageid,</if>
  106. <if test="fCntrid != null">f_cntrid,</if>
  107. <if test="fCntrcount != null">f_cntrcount,</if>
  108. <if test="fCntrweight != null">f_cntrweight,</if>
  109. <if test="fCntrstatus != null">f_cntrstatus,</if>
  110. <if test="fSoc != null">f_soc,</if>
  111. <if test="fTemperature != null">f_temperature,</if>
  112. <if test="fDraught != null">f_Draught,</if>
  113. <if test="fHumidity != null">f_Humidity,</if>
  114. <if test="fPrecooling != null">f_precooling,</if>
  115. <if test="fPlantakecntr != null">f_plantakecntr,</if>
  116. <if test="fIfdanger != null">f_IFDANGER,</if>
  117. <if test="fManual != null">f_manual,</if>
  118. <if test="createBy != null">create_by,</if>
  119. <if test="createTime != null">create_time,</if>
  120. <if test="updateBy != null">update_by,</if>
  121. <if test="updateTime != null">update_time,</if>
  122. <if test="remark != null">remark,</if>
  123. </trim>
  124. <trim prefix="values (" suffix=")" suffixOverrides=",">
  125. <if test="fPid != null">#{fPid},</if>
  126. <if test="fCntrno != null and fCntrno != ''">#{fCntrno},</if>
  127. <if test="fSealno != null and fSealno != ''">#{fSealno},</if>
  128. <if test="fGoodsid != null">#{fGoodsid},</if>
  129. <if test="fPackageid != null and fPackageid != ''">#{fPackageid},</if>
  130. <if test="fCntrid != null">#{fCntrid},</if>
  131. <if test="fCntrcount != null">#{fCntrcount},</if>
  132. <if test="fCntrweight != null">#{fCntrweight},</if>
  133. <if test="fCntrstatus != null">#{fCntrstatus},</if>
  134. <if test="fSoc != null">#{fSoc},</if>
  135. <if test="fTemperature != null">#{fTemperature},</if>
  136. <if test="fDraught != null">#{fDraught},</if>
  137. <if test="fHumidity != null">#{fHumidity},</if>
  138. <if test="fPrecooling != null">#{fPrecooling},</if>
  139. <if test="fPlantakecntr != null">#{fPlantakecntr},</if>
  140. <if test="fIfdanger != null">#{fIfdanger},</if>
  141. <if test="fManual != null">#{fManual},</if>
  142. <if test="createBy != null">#{createBy},</if>
  143. <if test="createTime != null">#{createTime},</if>
  144. <if test="updateBy != null">#{updateBy},</if>
  145. <if test="updateTime != null">#{updateTime},</if>
  146. <if test="remark != null">#{remark},</if>
  147. </trim>
  148. </insert>
  149. <update id="updateTWarehousebillsCntritems" parameterType="TWarehousebillsCntritems">
  150. update t_warehousebills_cntritems
  151. <trim prefix="SET" suffixOverrides=",">
  152. <if test="fPid != null">f_pid = #{fPid},</if>
  153. <if test="fCntrno != null and fCntrno != ''">f_cntrno = #{fCntrno},</if>
  154. <if test="fSealno != null and fSealno != ''">f_sealno = #{fSealno},</if>
  155. <if test="fGoodsid != null">f_goodsid = #{fGoodsid},</if>
  156. <if test="fPackageid != null and fPackageid != ''">f_packageid = #{fPackageid},</if>
  157. <if test="fCntrid != null">f_cntrid = #{fCntrid},</if>
  158. <if test="fCntrcount != null">f_cntrcount = #{fCntrcount},</if>
  159. <if test="fCntrweight != null">f_cntrweight = #{fCntrweight},</if>
  160. <if test="fCntrstatus != null">f_cntrstatus = #{fCntrstatus},</if>
  161. <if test="fSoc != null">f_soc = #{fSoc},</if>
  162. <if test="fTemperature != null">f_temperature = #{fTemperature},</if>
  163. <if test="fDraught != null">f_Draught = #{fDraught},</if>
  164. <if test="fHumidity != null">f_Humidity = #{fHumidity},</if>
  165. <if test="fPrecooling != null">f_precooling = #{fPrecooling},</if>
  166. <if test="fPlantakecntr != null">f_plantakecntr = #{fPlantakecntr},</if>
  167. <if test="fIfdanger != null">f_IFDANGER = #{fIfdanger},</if>
  168. <if test="fManual != null">f_manual = #{fManual},</if>
  169. <if test="createBy != null">create_by = #{createBy},</if>
  170. <if test="createTime != null">create_time = #{createTime},</if>
  171. <if test="updateBy != null">update_by = #{updateBy},</if>
  172. <if test="updateTime != null">update_time = #{updateTime},</if>
  173. <if test="remark != null">remark = #{remark},</if>
  174. </trim>
  175. where f_id = #{fId}
  176. </update>
  177. <delete id="deleteTWarehousebillsCntritemsById" parameterType="Long">
  178. delete from t_warehousebills_cntritems where f_id = #{fId}
  179. </delete>
  180. <delete id="deleteTWarehousebillsCntritemsByIds" parameterType="String">
  181. delete from t_warehousebills_cntritems where f_id in
  182. <foreach item="fId" collection="array" open="(" separator="," close=")">
  183. #{fId}
  184. </foreach>
  185. </delete>
  186. <delete id="deleteTWarehousebillsCntritemsfPid" parameterType="Long">
  187. delete from t_warehousebills_cntritems where f_pid = #{fPid}
  188. </delete>
  189. <delete id="deleteTWarehousebillsCntritemsfPids" parameterType="String">
  190. delete from t_warehousebills_cntritems where f_pid in
  191. <foreach item="fPid" collection="array" open="(" separator="," close=")">
  192. #{fPid}
  193. </foreach>
  194. </delete>
  195. <select id="bookingSpace" resultType="map">
  196. SELECT
  197. CASE MONTH(tc.createTime) WHEN '1' THEN SUM(tc.number) ELSE 0 END AS January,
  198. CASE MONTH(tc.createTime) WHEN '2' THEN SUM(tc.number) ELSE 0 END AS February,
  199. CASE MONTH(tc.createTime) WHEN '3' THEN SUM(tc.number) ELSE 0 END AS March,
  200. CASE MONTH(tc.createTime) WHEN '4' THEN SUM(tc.number) ELSE 0 END AS April,
  201. CASE MONTH(tc.createTime) WHEN '5' THEN SUM(tc.number) ELSE 0 END AS May,
  202. CASE MONTH(tc.createTime) WHEN '6' THEN SUM(tc.number) ELSE 0 END AS June,
  203. CASE MONTH(tc.createTime) WHEN '7' THEN SUM(tc.number) ELSE 0 END AS July,
  204. CASE MONTH(tc.createTime) WHEN '8' THEN SUM(tc.number) ELSE 0 END AS August,
  205. CASE MONTH(tc.createTime) WHEN '9' THEN SUM(tc.number) ELSE 0 END AS September,
  206. CASE MONTH(tc.createTime) WHEN '10' THEN SUM(tc.number) ELSE 0 END AS October,
  207. CASE MONTH(tc.createTime) WHEN '11' THEN SUM(tc.number) ELSE 0 END AS November,
  208. CASE MONTH(tc.createTime) WHEN '12' THEN SUM(tc.number) ELSE 0 END AS December,
  209. tp.f_name corpName
  210. FROM
  211. (
  212. SELECT
  213. tc.f_cntrno fCntrno,
  214. tc.create_time createTime,
  215. tw.f_corpid fCorpid,
  216. tn.f_no,
  217. CASE
  218. WHEN SUBSTR(tn.f_no,1,2) = '20' THEN 1
  219. WHEN SUBSTR(tn.f_no,1,2) ='40' THEN 2
  220. ELSE 0
  221. END AS number
  222. FROM
  223. t_warehousebills_cntritems tc
  224. LEFT JOIN t_warehousebills tw ON tc.f_pid = tw.f_id
  225. LEFT JOIN t_cntrno tr ON tc.f_cntrno = tr.f_no
  226. LEFT JOIN t_cntr tn ON tr.f_typeid = tn.f_id
  227. WHERE tw.f_corpid IS NOT NULL
  228. AND tn.f_no IS NOT NULL
  229. AND YEAR(tc.create_time) = YEAR(NOW())
  230. )tc
  231. LEFT JOIN t_corps tp ON tc.fCorpid = tp.f_id
  232. GROUP BY tc.fCorpid
  233. ORDER BY CONVERT(tp.f_name USING gbk) asc
  234. LIMIT 10
  235. </select>
  236. <delete id="deleteTWarehousebillsCntritemOlder" parameterType="object">
  237. delete from t_warehousebills_cntritems where f_pid = #{fPid} and f_cntrno = #{fCntrno}
  238. </delete>
  239. </mapper>