TCcvalueMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.chinaitop.depot.intelligent.grainsituation.mapper.TCcvalueMapper" >
  4. <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.grainsituation.model.TCcvalue" >
  5. <result column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="org_id" property="orgId" jdbcType="VARCHAR" />
  7. <result column="v_cc_code" property="vCcCode" jdbcType="VARCHAR" />
  8. <result column="z_zd_code" property="zZdCode" jdbcType="VARCHAR" />
  9. <result column="v_cf_code" property="vCfCode" jdbcType="VARCHAR" />
  10. <result column="v_max" property="vMax" jdbcType="INTEGER" />
  11. <result column="v_min" property="vMin" jdbcType="INTEGER" />
  12. <result column="v_avg" property="vAvg" jdbcType="DECIMAL" />
  13. <result column="v_update_time" property="vUpdateTime" jdbcType="TIMESTAMP" />
  14. <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
  15. </resultMap>
  16. <sql id="Example_Where_Clause" >
  17. <where >
  18. <foreach collection="oredCriteria" item="criteria" separator="or" >
  19. <if test="criteria.valid" >
  20. <trim prefix="(" suffix=")" prefixOverrides="and" >
  21. <foreach collection="criteria.criteria" item="criterion" >
  22. <choose >
  23. <when test="criterion.noValue" >
  24. and ${criterion.condition}
  25. </when>
  26. <when test="criterion.singleValue" >
  27. and ${criterion.condition} #{criterion.value}
  28. </when>
  29. <when test="criterion.betweenValue" >
  30. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  31. </when>
  32. <when test="criterion.listValue" >
  33. and ${criterion.condition}
  34. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  35. #{listItem}
  36. </foreach>
  37. </when>
  38. </choose>
  39. </foreach>
  40. </trim>
  41. </if>
  42. </foreach>
  43. </where>
  44. </sql>
  45. <sql id="Update_By_Example_Where_Clause" >
  46. <where >
  47. <foreach collection="example.oredCriteria" item="criteria" separator="or" >
  48. <if test="criteria.valid" >
  49. <trim prefix="(" suffix=")" prefixOverrides="and" >
  50. <foreach collection="criteria.criteria" item="criterion" >
  51. <choose >
  52. <when test="criterion.noValue" >
  53. and ${criterion.condition}
  54. </when>
  55. <when test="criterion.singleValue" >
  56. and ${criterion.condition} #{criterion.value}
  57. </when>
  58. <when test="criterion.betweenValue" >
  59. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  60. </when>
  61. <when test="criterion.listValue" >
  62. and ${criterion.condition}
  63. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  64. #{listItem}
  65. </foreach>
  66. </when>
  67. </choose>
  68. </foreach>
  69. </trim>
  70. </if>
  71. </foreach>
  72. </where>
  73. </sql>
  74. <sql id="Base_Column_List" >
  75. id, org_id, v_cc_code, z_zd_code, v_cf_code, v_max, v_min, v_avg, v_update_time,
  76. data_source
  77. </sql>
  78. <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcvalueExample" >
  79. select
  80. <if test="distinct" >
  81. distinct
  82. </if>
  83. <include refid="Base_Column_List" />
  84. from t_ccvalue
  85. <if test="_parameter != null" >
  86. <include refid="Example_Where_Clause" />
  87. </if>
  88. <if test="orderByClause != null" >
  89. order by ${orderByClause}
  90. </if>
  91. </select>
  92. <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcvalueExample" >
  93. delete from t_ccvalue
  94. <if test="_parameter != null" >
  95. <include refid="Example_Where_Clause" />
  96. </if>
  97. </delete>
  98. <insert id="insert" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcvalue" >
  99. insert into t_ccvalue (id, org_id, v_cc_code,
  100. z_zd_code, v_cf_code, v_max,
  101. v_min, v_avg, v_update_time,
  102. data_source,hcjcdh)
  103. values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{vCcCode,jdbcType=VARCHAR},
  104. #{zZdCode,jdbcType=VARCHAR}, #{vCfCode,jdbcType=VARCHAR}, #{vMax,jdbcType=INTEGER},
  105. #{vMin,jdbcType=INTEGER}, #{vAvg,jdbcType=DECIMAL}, #{vUpdateTime,jdbcType=TIMESTAMP},
  106. #{dataSource,jdbcType=VARCHAR}, #{hcjcdh,jdbcType=VARCHAR})
  107. </insert>
  108. <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcvalue" >
  109. insert into t_ccvalue
  110. <trim prefix="(" suffix=")" suffixOverrides="," >
  111. <if test="id != null" >
  112. id,
  113. </if>
  114. <if test="orgId != null" >
  115. org_id,
  116. </if>
  117. <if test="vCcCode != null" >
  118. v_cc_code,
  119. </if>
  120. <if test="zZdCode != null" >
  121. z_zd_code,
  122. </if>
  123. <if test="vCfCode != null" >
  124. v_cf_code,
  125. </if>
  126. <if test="vMax != null" >
  127. v_max,
  128. </if>
  129. <if test="vMin != null" >
  130. v_min,
  131. </if>
  132. <if test="vAvg != null" >
  133. v_avg,
  134. </if>
  135. <if test="vUpdateTime != null" >
  136. v_update_time,
  137. </if>
  138. <if test="dataSource != null" >
  139. data_source,
  140. </if>
  141. </trim>
  142. <trim prefix="values (" suffix=")" suffixOverrides="," >
  143. <if test="id != null" >
  144. #{id,jdbcType=VARCHAR},
  145. </if>
  146. <if test="orgId != null" >
  147. #{orgId,jdbcType=VARCHAR},
  148. </if>
  149. <if test="vCcCode != null" >
  150. #{vCcCode,jdbcType=VARCHAR},
  151. </if>
  152. <if test="zZdCode != null" >
  153. #{zZdCode,jdbcType=VARCHAR},
  154. </if>
  155. <if test="vCfCode != null" >
  156. #{vCfCode,jdbcType=VARCHAR},
  157. </if>
  158. <if test="vMax != null" >
  159. #{vMax,jdbcType=INTEGER},
  160. </if>
  161. <if test="vMin != null" >
  162. #{vMin,jdbcType=INTEGER},
  163. </if>
  164. <if test="vAvg != null" >
  165. #{vAvg,jdbcType=DECIMAL},
  166. </if>
  167. <if test="vUpdateTime != null" >
  168. #{vUpdateTime,jdbcType=TIMESTAMP},
  169. </if>
  170. <if test="dataSource != null" >
  171. #{dataSource,jdbcType=VARCHAR},
  172. </if>
  173. </trim>
  174. </insert>
  175. <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TCcvalueExample" resultType="java.lang.Integer" >
  176. select count(*) from t_ccvalue
  177. <if test="_parameter != null" >
  178. <include refid="Example_Where_Clause" />
  179. </if>
  180. </select>
  181. <update id="updateByExampleSelective" parameterType="map" >
  182. update t_ccvalue
  183. <set >
  184. <if test="record.id != null" >
  185. id = #{record.id,jdbcType=VARCHAR},
  186. </if>
  187. <if test="record.orgId != null" >
  188. org_id = #{record.orgId,jdbcType=VARCHAR},
  189. </if>
  190. <if test="record.vCcCode != null" >
  191. v_cc_code = #{record.vCcCode,jdbcType=VARCHAR},
  192. </if>
  193. <if test="record.zZdCode != null" >
  194. z_zd_code = #{record.zZdCode,jdbcType=VARCHAR},
  195. </if>
  196. <if test="record.vCfCode != null" >
  197. v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
  198. </if>
  199. <if test="record.vMax != null" >
  200. v_max = #{record.vMax,jdbcType=INTEGER},
  201. </if>
  202. <if test="record.vMin != null" >
  203. v_min = #{record.vMin,jdbcType=INTEGER},
  204. </if>
  205. <if test="record.vAvg != null" >
  206. v_avg = #{record.vAvg,jdbcType=DECIMAL},
  207. </if>
  208. <if test="record.vUpdateTime != null" >
  209. v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
  210. </if>
  211. <if test="record.dataSource != null" >
  212. data_source = #{record.dataSource,jdbcType=VARCHAR},
  213. </if>
  214. </set>
  215. <if test="_parameter != null" >
  216. <include refid="Update_By_Example_Where_Clause" />
  217. </if>
  218. </update>
  219. <update id="updateByExample" parameterType="map" >
  220. update t_ccvalue
  221. set id = #{record.id,jdbcType=VARCHAR},
  222. org_id = #{record.orgId,jdbcType=VARCHAR},
  223. v_cc_code = #{record.vCcCode,jdbcType=VARCHAR},
  224. z_zd_code = #{record.zZdCode,jdbcType=VARCHAR},
  225. v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
  226. v_max = #{record.vMax,jdbcType=INTEGER},
  227. v_min = #{record.vMin,jdbcType=INTEGER},
  228. v_avg = #{record.vAvg,jdbcType=DECIMAL},
  229. v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
  230. data_source = #{record.dataSource,jdbcType=VARCHAR}
  231. <if test="_parameter != null" >
  232. <include refid="Update_By_Example_Where_Clause" />
  233. </if>
  234. </update>
  235. <insert id="insertBatch" parameterType="java.util.List">
  236. insert into t_ccvalue (id, org_id, v_cc_code,
  237. z_zd_code, v_cf_code, v_max,
  238. v_min, v_avg, v_update_time,
  239. data_source,hcjcdh)
  240. values
  241. <foreach collection="list" item="cc" index="index" separator=",">
  242. (#{cc.id,jdbcType=VARCHAR}, #{cc.orgId,jdbcType=VARCHAR}, #{cc.vCcCode,jdbcType=VARCHAR},
  243. #{cc.zZdCode,jdbcType=VARCHAR}, #{cc.vCfCode,jdbcType=VARCHAR}, #{cc.vMax,jdbcType=INTEGER},
  244. #{cc.vMin,jdbcType=INTEGER}, #{cc.vAvg,jdbcType=DECIMAL}, #{cc.vUpdateTime,jdbcType=TIMESTAMP},
  245. #{cc.dataSource,jdbcType=VARCHAR}, #{cc.hcjcdh,jdbcType=VARCHAR})
  246. </foreach>
  247. </insert>
  248. <select id="getByCfCode" resultType="java.util.Map" parameterType="java.util.Map">
  249. SELECT
  250. v_cf_code AS vCfCode,
  251. v_max AS max,
  252. v_min AS min,
  253. v_avg AS avg,
  254. v_update_time AS vUpdateTime
  255. FROM
  256. t_ccvalue
  257. <where>
  258. <if test="vCfCode != null">
  259. v_cf_code = #{vCfCode}
  260. </if>
  261. <if test="searchStartDate != null and test=searchEndDate != null">
  262. AND v_update_time BETWEEN #{searchStartDate} AND #{searchEndDate}
  263. </if>
  264. </where>
  265. GROUP BY vUpdateTime
  266. ORDER BY vUpdateTime asc
  267. </select>
  268. <select id="getByCfCodes" parameterType="java.util.Map" resultType="java.util.Map">
  269. SELECT
  270. a.*
  271. FROM
  272. (
  273. SELECT
  274. v_cf_code AS vCfCode,
  275. v_max AS max,
  276. v_min AS min,
  277. v_avg AS avg,
  278. v_update_time AS vUpdateTime
  279. FROM
  280. t_ccvalue
  281. ORDER BY
  282. vUpdateTime DESC
  283. ) a
  284. WHERE 1=1
  285. <if test="orgId != null">
  286. AND a.orgId = #{orgId}
  287. </if>
  288. GROUP BY
  289. a.vCfCode;
  290. </select>
  291. <select id="getOneByCfCode" resultMap="BaseResultMap" parameterType="java.util.Map">
  292. SELECT
  293. *
  294. FROM
  295. t_ccvalue
  296. <where>
  297. <if test="orgId != null">
  298. org_id = #{orgId} and
  299. </if>
  300. <if test="vCfCode != null">
  301. v_cf_code = #{vCfCode}
  302. </if>
  303. </where>
  304. GROUP BY v_update_time
  305. ORDER BY v_update_time DESC LIMIT 0,1
  306. </select>
  307. <select id="getJcd" parameterType="java.util.Map" resultType="java.util.Map">
  308. SELECT
  309. concat(credit_code,LPAD(org_id, 3, 0),LPAD(#{vcfcode}, 4, 0),DATE_FORMAT(STR_TO_DATE(#{updateTime},'%Y-%m-%d %H:%i:%s'),'%Y%m%d%H%i'),'00000') jcd
  310. FROM
  311. org_info
  312. <where>
  313. <if test="orgId != null">
  314. org_id = #{orgId}
  315. </if>
  316. </where>
  317. </select>
  318. </mapper>