SaleLogMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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.steerinfo.dil.mapper.SaleLogMapper">
  4. <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.SaleLog">
  5. <id column="RESULT_ID" jdbcType="DECIMAL" property="resultId" />
  6. <result column="ORDER_ID" jdbcType="DECIMAL" property="orderId" />
  7. <result column="SALE_ORDER_ID" jdbcType="DECIMAL" property="saleOrderId" />
  8. <result column="DESCRIPTION" jdbcType="VARCHAR" property="description" />
  9. <result column="OPRATION_TYPE" jdbcType="VARCHAR" property="oprationType" />
  10. <result column="JSON_DATA" jdbcType="VARCHAR" property="jsonData" />
  11. <result column="INSERT_TIME" jdbcType="TIMESTAMP" property="insertTime" />
  12. <result column="INSERT_USERNAME" jdbcType="VARCHAR" property="insertUsername" />
  13. </resultMap>
  14. <sql id="columns">
  15. RESULT_ID, ORDER_ID, SALE_ORDER_ID, DESCRIPTION, OPRATION_TYPE, JSON_DATA, INSERT_TIME,
  16. INSERT_USERNAME
  17. </sql>
  18. <sql id="columns_alias">
  19. t.RESULT_ID, t.ORDER_ID, t.SALE_ORDER_ID, t.DESCRIPTION, t.OPRATION_TYPE, t.JSON_DATA,
  20. t.INSERT_TIME, t.INSERT_USERNAME
  21. </sql>
  22. <sql id="select">
  23. SELECT <include refid="columns"/> FROM SALE_LOG
  24. </sql>
  25. <sql id="select_alias">
  26. SELECT <include refid="columns_alias"/> FROM SALE_LOG t
  27. </sql>
  28. <sql id="where">
  29. <where>
  30. <if test="resultId != null">
  31. and RESULT_ID = #{resultId}
  32. </if>
  33. <if test="orderId != null">
  34. and ORDER_ID = #{orderId}
  35. </if>
  36. <if test="saleOrderId != null">
  37. and SALE_ORDER_ID = #{saleOrderId}
  38. </if>
  39. <if test="description != null and description != ''">
  40. and DESCRIPTION = #{description}
  41. </if>
  42. <if test="oprationType != null and oprationType != ''">
  43. and OPRATION_TYPE = #{oprationType}
  44. </if>
  45. <if test="jsonData != null and jsonData != ''">
  46. and JSON_DATA = #{jsonData}
  47. </if>
  48. <if test="insertTime != null">
  49. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  50. </if>
  51. <if test="insertUsername != null and insertUsername != ''">
  52. and INSERT_USERNAME = #{insertUsername}
  53. </if>
  54. </where>
  55. </sql>
  56. <sql id="whereLike">
  57. <where>
  58. <if test="resultId != null">
  59. and RESULT_ID = #{resultId}
  60. </if>
  61. <if test="orderId != null">
  62. and ORDER_ID = #{orderId}
  63. </if>
  64. <if test="saleOrderId != null">
  65. and SALE_ORDER_ID = #{saleOrderId}
  66. </if>
  67. <if test="description != null and description != ''">
  68. and DESCRIPTION LIKE '%${description}%'
  69. </if>
  70. <if test="oprationType != null and oprationType != ''">
  71. and OPRATION_TYPE LIKE '%${oprationType}%'
  72. </if>
  73. <if test="jsonData != null and jsonData != ''">
  74. and JSON_DATA LIKE '%${jsonData}%'
  75. </if>
  76. <if test="insertTime != null">
  77. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  78. </if>
  79. <if test="insertUsername != null and insertUsername != ''">
  80. and INSERT_USERNAME LIKE '%${insertUsername}%'
  81. </if>
  82. </where>
  83. </sql>
  84. <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
  85. delete from SALE_LOG
  86. where RESULT_ID = #{resultId,jdbcType=DECIMAL}
  87. </delete>
  88. <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
  89. delete from SALE_LOG
  90. where 1!=1
  91. <if test="orderId != null">
  92. or ORDER_ID = #{orderId}
  93. </if>
  94. <if test="saleOrderId != null">
  95. or SALE_ORDER_ID = #{saleOrderId}
  96. </if>
  97. <if test="description != null and description != ''">
  98. or DESCRIPTION = #{description}
  99. </if>
  100. <if test="oprationType != null and oprationType != ''">
  101. or OPRATION_TYPE = #{oprationType}
  102. </if>
  103. <if test="jsonData != null and jsonData != ''">
  104. or JSON_DATA = #{jsonData}
  105. </if>
  106. <if test="insertTime != null">
  107. or TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = '#{insertTime}'
  108. </if>
  109. <if test="insertUsername != null and insertUsername != ''">
  110. or INSERT_USERNAME = #{insertUsername}
  111. </if>
  112. </delete>
  113. <insert id="insert" parameterType="com.steerinfo.dil.model.SaleLog">
  114. insert into SALE_LOG (RESULT_ID, ORDER_ID, SALE_ORDER_ID,
  115. DESCRIPTION, OPRATION_TYPE, JSON_DATA,
  116. INSERT_TIME, INSERT_USERNAME)
  117. values (#{resultId,jdbcType=DECIMAL}, #{orderId,jdbcType=DECIMAL}, #{saleOrderId,jdbcType=DECIMAL},
  118. #{description,jdbcType=VARCHAR}, #{oprationType,jdbcType=VARCHAR}, #{jsonData,jdbcType=VARCHAR},
  119. #{insertTime,jdbcType=TIMESTAMP}, #{insertUsername,jdbcType=VARCHAR})
  120. </insert>
  121. <insert id="insertSelective" parameterType="com.steerinfo.dil.model.SaleLog">
  122. insert into SALE_LOG
  123. <trim prefix="(" suffix=")" suffixOverrides=",">
  124. <if test="resultId != null">
  125. RESULT_ID,
  126. </if>
  127. <if test="orderId != null">
  128. ORDER_ID,
  129. </if>
  130. <if test="saleOrderId != null">
  131. SALE_ORDER_ID,
  132. </if>
  133. <if test="description != null">
  134. DESCRIPTION,
  135. </if>
  136. <if test="oprationType != null">
  137. OPRATION_TYPE,
  138. </if>
  139. <if test="jsonData != null">
  140. JSON_DATA,
  141. </if>
  142. <if test="insertTime != null">
  143. INSERT_TIME,
  144. </if>
  145. <if test="insertUsername != null">
  146. INSERT_USERNAME,
  147. </if>
  148. </trim>
  149. <trim prefix="values (" suffix=")" suffixOverrides=",">
  150. <if test="resultId != null">
  151. #{resultId,jdbcType=DECIMAL},
  152. </if>
  153. <if test="orderId != null">
  154. #{orderId,jdbcType=DECIMAL},
  155. </if>
  156. <if test="saleOrderId != null">
  157. #{saleOrderId,jdbcType=DECIMAL},
  158. </if>
  159. <if test="description != null">
  160. #{description,jdbcType=VARCHAR},
  161. </if>
  162. <if test="oprationType != null">
  163. #{oprationType,jdbcType=VARCHAR},
  164. </if>
  165. <if test="jsonData != null">
  166. #{jsonData,jdbcType=VARCHAR},
  167. </if>
  168. <if test="insertTime != null">
  169. #{insertTime,jdbcType=TIMESTAMP},
  170. </if>
  171. <if test="insertUsername != null">
  172. #{insertUsername,jdbcType=VARCHAR},
  173. </if>
  174. </trim>
  175. </insert>
  176. <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.SaleLog">
  177. update SALE_LOG
  178. set ORDER_ID = #{orderId,jdbcType=DECIMAL},
  179. SALE_ORDER_ID = #{saleOrderId,jdbcType=DECIMAL},
  180. DESCRIPTION = #{description,jdbcType=VARCHAR},
  181. OPRATION_TYPE = #{oprationType,jdbcType=VARCHAR},
  182. JSON_DATA = #{jsonData,jdbcType=VARCHAR},
  183. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  184. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR}
  185. where RESULT_ID = #{resultId,jdbcType=DECIMAL}
  186. </update>
  187. <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.SaleLog">
  188. update SALE_LOG
  189. <set>
  190. <if test="orderId != null">
  191. ORDER_ID = #{orderId,jdbcType=DECIMAL},
  192. </if>
  193. <if test="saleOrderId != null">
  194. SALE_ORDER_ID = #{saleOrderId,jdbcType=DECIMAL},
  195. </if>
  196. <if test="description != null">
  197. DESCRIPTION = #{description,jdbcType=VARCHAR},
  198. </if>
  199. <if test="oprationType != null">
  200. OPRATION_TYPE = #{oprationType,jdbcType=VARCHAR},
  201. </if>
  202. <if test="jsonData != null">
  203. JSON_DATA = #{jsonData,jdbcType=VARCHAR},
  204. </if>
  205. <if test="insertTime != null">
  206. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  207. </if>
  208. <if test="insertUsername != null">
  209. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  210. </if>
  211. </set>
  212. where RESULT_ID = #{resultId,jdbcType=DECIMAL}
  213. </update>
  214. <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
  215. <include refid="select"/>
  216. where RESULT_ID = #{resultId,jdbcType=DECIMAL}
  217. </select>
  218. <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  219. <include refid="select"/>
  220. <include refid="where"/>
  221. </select>
  222. <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  223. <include refid="select"/>
  224. <include refid="whereLike"/>
  225. </select>
  226. <insert id="batchInsert" parameterType="java.util.List">
  227. insert into SALE_LOG
  228. (RESULT_ID,
  229. ORDER_ID, SALE_ORDER_ID, DESCRIPTION,
  230. OPRATION_TYPE, JSON_DATA, INSERT_TIME,
  231. INSERT_USERNAME)
  232. ( <foreach collection="list" item="item" separator="union all">
  233. select
  234. #{item.resultId,jdbcType=DECIMAL},
  235. #{item.orderId,jdbcType=DECIMAL}, #{item.saleOrderId,jdbcType=DECIMAL}, #{item.description,jdbcType=VARCHAR},
  236. #{item.oprationType,jdbcType=VARCHAR}, #{item.jsonData,jdbcType=VARCHAR}, #{item.insertTime,jdbcType=TIMESTAMP},
  237. #{item.insertUsername,jdbcType=VARCHAR} from dual
  238. </foreach> )
  239. </insert>
  240. <update id="batchUpdate" parameterType="java.util.List">
  241. update SALE_LOG
  242. set
  243. RESULT_ID=
  244. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  245. when #{item.resultId,jdbcType=DECIMAL} then #{item.resultId,jdbcType=DECIMAL}
  246. </foreach>
  247. ,ORDER_ID=
  248. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  249. when #{item.resultId,jdbcType=DECIMAL} then #{item.orderId,jdbcType=DECIMAL}
  250. </foreach>
  251. ,SALE_ORDER_ID=
  252. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  253. when #{item.resultId,jdbcType=DECIMAL} then #{item.saleOrderId,jdbcType=DECIMAL}
  254. </foreach>
  255. ,DESCRIPTION=
  256. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  257. when #{item.resultId,jdbcType=DECIMAL} then #{item.description,jdbcType=VARCHAR}
  258. </foreach>
  259. ,OPRATION_TYPE=
  260. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  261. when #{item.resultId,jdbcType=DECIMAL} then #{item.oprationType,jdbcType=VARCHAR}
  262. </foreach>
  263. ,JSON_DATA=
  264. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  265. when #{item.resultId,jdbcType=DECIMAL} then #{item.jsonData,jdbcType=VARCHAR}
  266. </foreach>
  267. ,INSERT_TIME=
  268. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  269. when #{item.resultId,jdbcType=DECIMAL} then #{item.insertTime,jdbcType=TIMESTAMP}
  270. </foreach>
  271. ,INSERT_USERNAME=
  272. <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
  273. when #{item.resultId,jdbcType=DECIMAL} then #{item.insertUsername,jdbcType=VARCHAR}
  274. </foreach>
  275. where RESULT_ID in
  276. <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
  277. #{item.resultId,jdbcType=DECIMAL}
  278. </foreach>
  279. </update>
  280. <delete id="batchDelete" parameterType="java.util.List">
  281. delete from SALE_LOG
  282. where RESULT_ID in
  283. <foreach collection="list" item="id" open="(" close=")" separator=",">
  284. #{id}
  285. </foreach>
  286. </delete>
  287. <!-- 友情提示!!!-->
  288. <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
  289. <select id="selectAllLog" resultType="java.util.Map">
  290. SELECT
  291. OO .ORDER_NUMBER "orderNumber",
  292. ASO .SALE_NUMBER "saleNumber",
  293. RC .CAPACITY_NUMBER "capacityNumber",
  294. SL .DESCRIPTION "description",
  295. SL .OPRATION_TYPE "operationType",
  296. SL .INSERT_USERNAME "insertUserName",
  297. SL .INSERT_TIME "insertTime"
  298. FROM SALE_LOG SL
  299. LEFT JOIN OMSTRUCK_ORDER OO ON OO .ORDER_ID =SL .ORDER_ID
  300. LEFT JOIN AMS_SALE_ORDER ASO ON ASO .SALE_ORDER_ID = SL .SALE_ORDER_ID
  301. LEFT JOIN RMS_CAPACITY RC ON RC .CAPACITY_ID=OO .CAPACITY_ID
  302. <where>
  303. <if test="con!=null and con!=''.toString()">
  304. OO .ORDER_NUMBER || ASO .SALE_NUMBER || RC .CAPACITY_NUMBER || SL .DESCRIPTION
  305. LIKE CONCAT('%',CONCAT(#{con},'%'))
  306. </if>
  307. <if test="orderId!=null ">
  308. AND SL .ORDER_ID = #{orderId}
  309. </if>
  310. <if test="saleOrderId!=null ">
  311. AND SL .SALE_ORDER_ID = #{saleOrderId}
  312. </if>
  313. <if test="operationType!=null">
  314. AND SL .OPRATION_TYPE in
  315. <foreach collection="operationType" item="item" open="(" separator="," close=")" >
  316. #{item}
  317. </foreach>
  318. </if>
  319. <if test="capacityNumber!=null">
  320. AND RC .CAPACITY_NUMBER in
  321. <foreach collection="capacityNumber" item="item" open="(" separator="," close=")" >
  322. #{item}
  323. </foreach>
  324. </if>
  325. </where>
  326. </select>
  327. <select id="getUserNameById" resultType="java.lang.String">
  328. SELECT USER_NAME FROM SSO.SYS_USER
  329. WHERE USER_ID = #{userId}
  330. FETCH NEXT 1 ROWS ONLY
  331. </select>
  332. <select id="getOrderIds" resultType="java.math.BigDecimal">
  333. SELECT DISTINCT ORDER_ID FROM OMSTRUCK_ORDER WHERE ORDER_NUMBER = #{orderNumber}
  334. </select>
  335. <select id="getOrderIdByTotal" resultType="java.math.BigDecimal">
  336. SELECT ORDER_ID FROM TMSTRUCK_TOTAL_RESULT
  337. WHERE RESULT_TOTAL_ID = #{totalResultId}
  338. FETCH NEXT 1 ROWS ONLY
  339. </select>
  340. </mapper>