AmsSalePlanMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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.AmsSalePlanMapper">
  4. <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.AmsSalePlan">
  5. <id column="PLAN_ID" jdbcType="DECIMAL" property="planId" />
  6. <result column="PLAN_DATE" jdbcType="TIMESTAMP" property="planDate" />
  7. <result column="PLAN_NAME" jdbcType="VARCHAR" property="planName" />
  8. <result column="SALE_AREA_ID" jdbcType="DECIMAL" property="saleAreaId" />
  9. <result column="INSERT_USERNAME" jdbcType="VARCHAR" property="insertUsername" />
  10. <result column="INSERT_TIME" jdbcType="TIMESTAMP" property="insertTime" />
  11. <result column="UPDATE_USERNAME" jdbcType="VARCHAR" property="updateUsername" />
  12. <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
  13. <result column="INSERT_UPDATE_REMARK" jdbcType="VARCHAR" property="insertUpdateRemark" />
  14. <result column="DELETED" jdbcType="DECIMAL" property="deleted" />
  15. </resultMap>
  16. <sql id="columns">
  17. PLAN_ID, PLAN_DATE, PLAN_NAME, SALE_AREA_ID, INSERT_USERNAME, INSERT_TIME, UPDATE_USERNAME,
  18. UPDATE_TIME, INSERT_UPDATE_REMARK, DELETED
  19. </sql>
  20. <sql id="columns_alias">
  21. t.PLAN_ID, t.PLAN_DATE, t.PLAN_NAME, t.SALE_AREA_ID, t.INSERT_USERNAME, t.INSERT_TIME,
  22. t.UPDATE_USERNAME, t.UPDATE_TIME, t.INSERT_UPDATE_REMARK, t.DELETED
  23. </sql>
  24. <sql id="select">
  25. SELECT <include refid="columns"/> FROM AMS_SALE_PLAN
  26. </sql>
  27. <sql id="select_alias">
  28. SELECT <include refid="columns_alias"/> FROM AMS_SALE_PLAN t
  29. </sql>
  30. <sql id="where">
  31. <where>
  32. <if test="planId != null">
  33. and PLAN_ID = #{planId}
  34. </if>
  35. <if test="planDate != null">
  36. and TO_CHAR(PLAN_DATE,'yyyy-MM-dd') = #{planDate}
  37. </if>
  38. <if test="planName != null and planName != ''">
  39. and PLAN_NAME = #{planName}
  40. </if>
  41. <if test="saleAreaId != null">
  42. and SALE_AREA_ID = #{saleAreaId}
  43. </if>
  44. <if test="insertUsername != null and insertUsername != ''">
  45. and INSERT_USERNAME = #{insertUsername}
  46. </if>
  47. <if test="insertTime != null">
  48. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  49. </if>
  50. <if test="updateUsername != null and updateUsername != ''">
  51. and UPDATE_USERNAME = #{updateUsername}
  52. </if>
  53. <if test="updateTime != null">
  54. and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
  55. </if>
  56. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  57. and INSERT_UPDATE_REMARK = #{insertUpdateRemark}
  58. </if>
  59. <if test="deleted != null">
  60. and DELETED = #{deleted}
  61. </if>
  62. </where>
  63. </sql>
  64. <sql id="whereLike">
  65. <where>
  66. <if test="planId != null">
  67. and PLAN_ID = #{planId}
  68. </if>
  69. <if test="planDate != null">
  70. and TO_CHAR(PLAN_DATE,'yyyy-MM-dd') = #{planDate}
  71. </if>
  72. <if test="planName != null and planName != ''">
  73. and PLAN_NAME LIKE '%${planName}%'
  74. </if>
  75. <if test="saleAreaId != null">
  76. and SALE_AREA_ID = #{saleAreaId}
  77. </if>
  78. <if test="insertUsername != null and insertUsername != ''">
  79. and INSERT_USERNAME LIKE '%${insertUsername}%'
  80. </if>
  81. <if test="insertTime != null">
  82. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  83. </if>
  84. <if test="updateUsername != null and updateUsername != ''">
  85. and UPDATE_USERNAME LIKE '%${updateUsername}%'
  86. </if>
  87. <if test="updateTime != null">
  88. and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
  89. </if>
  90. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  91. and INSERT_UPDATE_REMARK LIKE '%${insertUpdateRemark}%'
  92. </if>
  93. <if test="deleted != null">
  94. and DELETED = #{deleted}
  95. </if>
  96. </where>
  97. </sql>
  98. <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
  99. delete from AMS_SALE_PLAN
  100. where PLAN_ID = #{planId,jdbcType=DECIMAL}
  101. </delete>
  102. <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
  103. delete from AMS_SALE_PLAN
  104. where 1!=1
  105. <if test="planDate != null">
  106. or TO_CHAR(PLAN_DATE,'yyyy-MM-dd') = '#{planDate}'
  107. </if>
  108. <if test="planName != null and planName != ''">
  109. or PLAN_NAME = #{planName}
  110. </if>
  111. <if test="saleAreaId != null">
  112. or SALE_AREA_ID = #{saleAreaId}
  113. </if>
  114. <if test="insertUsername != null and insertUsername != ''">
  115. or INSERT_USERNAME = #{insertUsername}
  116. </if>
  117. <if test="insertTime != null">
  118. or TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = '#{insertTime}'
  119. </if>
  120. <if test="updateUsername != null and updateUsername != ''">
  121. or UPDATE_USERNAME = #{updateUsername}
  122. </if>
  123. <if test="updateTime != null">
  124. or TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = '#{updateTime}'
  125. </if>
  126. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  127. or INSERT_UPDATE_REMARK = #{insertUpdateRemark}
  128. </if>
  129. <if test="deleted != null">
  130. or DELETED = #{deleted}
  131. </if>
  132. </delete>
  133. <insert id="insert" parameterType="com.steerinfo.dil.model.AmsSalePlan">
  134. insert into AMS_SALE_PLAN (PLAN_ID, PLAN_DATE, PLAN_NAME,
  135. SALE_AREA_ID, INSERT_USERNAME, INSERT_TIME,
  136. UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK,
  137. DELETED)
  138. values (#{planId,jdbcType=DECIMAL}, #{planDate,jdbcType=TIMESTAMP}, #{planName,jdbcType=VARCHAR},
  139. #{saleAreaId,jdbcType=DECIMAL}, #{insertUsername,jdbcType=VARCHAR}, #{insertTime,jdbcType=TIMESTAMP},
  140. #{updateUsername,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{insertUpdateRemark,jdbcType=VARCHAR},
  141. #{deleted,jdbcType=DECIMAL})
  142. </insert>
  143. <insert id="insertSelective" parameterType="com.steerinfo.dil.model.AmsSalePlan">
  144. insert into AMS_SALE_PLAN
  145. <trim prefix="(" suffix=")" suffixOverrides=",">
  146. <if test="planId != null">
  147. PLAN_ID,
  148. </if>
  149. <if test="planDate != null">
  150. PLAN_DATE,
  151. </if>
  152. <if test="planName != null">
  153. PLAN_NAME,
  154. </if>
  155. <if test="saleAreaId != null">
  156. SALE_AREA_ID,
  157. </if>
  158. <if test="insertUsername != null">
  159. INSERT_USERNAME,
  160. </if>
  161. <if test="insertTime != null">
  162. INSERT_TIME,
  163. </if>
  164. <if test="updateUsername != null">
  165. UPDATE_USERNAME,
  166. </if>
  167. <if test="updateTime != null">
  168. UPDATE_TIME,
  169. </if>
  170. <if test="insertUpdateRemark != null">
  171. INSERT_UPDATE_REMARK,
  172. </if>
  173. <if test="deleted != null">
  174. DELETED,
  175. </if>
  176. </trim>
  177. <trim prefix="values (" suffix=")" suffixOverrides=",">
  178. <if test="planId != null">
  179. #{planId,jdbcType=DECIMAL},
  180. </if>
  181. <if test="planDate != null">
  182. #{planDate,jdbcType=TIMESTAMP},
  183. </if>
  184. <if test="planName != null">
  185. #{planName,jdbcType=VARCHAR},
  186. </if>
  187. <if test="saleAreaId != null">
  188. #{saleAreaId,jdbcType=DECIMAL},
  189. </if>
  190. <if test="insertUsername != null">
  191. #{insertUsername,jdbcType=VARCHAR},
  192. </if>
  193. <if test="insertTime != null">
  194. #{insertTime,jdbcType=TIMESTAMP},
  195. </if>
  196. <if test="updateUsername != null">
  197. #{updateUsername,jdbcType=VARCHAR},
  198. </if>
  199. <if test="updateTime != null">
  200. #{updateTime,jdbcType=TIMESTAMP},
  201. </if>
  202. <if test="insertUpdateRemark != null">
  203. #{insertUpdateRemark,jdbcType=VARCHAR},
  204. </if>
  205. <if test="deleted != null">
  206. #{deleted,jdbcType=DECIMAL},
  207. </if>
  208. </trim>
  209. </insert>
  210. <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.AmsSalePlan">
  211. update AMS_SALE_PLAN
  212. set PLAN_DATE = #{planDate,jdbcType=TIMESTAMP},
  213. PLAN_NAME = #{planName,jdbcType=VARCHAR},
  214. SALE_AREA_ID = #{saleAreaId,jdbcType=DECIMAL},
  215. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  216. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  217. UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
  218. UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
  219. INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
  220. DELETED = #{deleted,jdbcType=DECIMAL}
  221. where PLAN_ID = #{planId,jdbcType=DECIMAL}
  222. </update>
  223. <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.AmsSalePlan">
  224. update AMS_SALE_PLAN
  225. <set>
  226. <if test="planDate != null">
  227. PLAN_DATE = #{planDate,jdbcType=TIMESTAMP},
  228. </if>
  229. <if test="planName != null">
  230. PLAN_NAME = #{planName,jdbcType=VARCHAR},
  231. </if>
  232. <if test="saleAreaId != null">
  233. SALE_AREA_ID = #{saleAreaId,jdbcType=DECIMAL},
  234. </if>
  235. <if test="insertUsername != null">
  236. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  237. </if>
  238. <if test="insertTime != null">
  239. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  240. </if>
  241. <if test="updateUsername != null">
  242. UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
  243. </if>
  244. <if test="updateTime != null">
  245. UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
  246. </if>
  247. <if test="insertUpdateRemark != null">
  248. INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
  249. </if>
  250. <if test="deleted != null">
  251. DELETED = #{deleted,jdbcType=DECIMAL},
  252. </if>
  253. </set>
  254. where PLAN_ID = #{planId,jdbcType=DECIMAL}
  255. </update>
  256. <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
  257. <include refid="select"/>
  258. where PLAN_ID = #{planId,jdbcType=DECIMAL}
  259. </select>
  260. <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  261. <include refid="select"/>
  262. <include refid="where"/>
  263. </select>
  264. <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  265. <include refid="select"/>
  266. <include refid="whereLike"/>
  267. </select>
  268. <insert id="batchInsert" parameterType="java.util.List">
  269. insert into AMS_SALE_PLAN
  270. (PLAN_ID,
  271. PLAN_DATE, PLAN_NAME, SALE_AREA_ID,
  272. INSERT_USERNAME, INSERT_TIME,
  273. UPDATE_USERNAME, UPDATE_TIME,
  274. INSERT_UPDATE_REMARK, DELETED)
  275. ( <foreach collection="list" item="item" separator="union all">
  276. select
  277. #{item.planId,jdbcType=DECIMAL},
  278. #{item.planDate,jdbcType=TIMESTAMP}, #{item.planName,jdbcType=VARCHAR}, #{item.saleAreaId,jdbcType=DECIMAL},
  279. #{item.insertUsername,jdbcType=VARCHAR}, #{item.insertTime,jdbcType=TIMESTAMP},
  280. #{item.updateUsername,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
  281. #{item.insertUpdateRemark,jdbcType=VARCHAR}, #{item.deleted,jdbcType=DECIMAL} from dual
  282. </foreach> )
  283. </insert>
  284. <update id="batchUpdate" parameterType="java.util.List">
  285. update AMS_SALE_PLAN
  286. set
  287. PLAN_ID=
  288. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  289. when #{item.planId,jdbcType=DECIMAL} then #{item.planId,jdbcType=DECIMAL}
  290. </foreach>
  291. ,PLAN_DATE=
  292. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  293. when #{item.planId,jdbcType=DECIMAL} then #{item.planDate,jdbcType=TIMESTAMP}
  294. </foreach>
  295. ,PLAN_NAME=
  296. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  297. when #{item.planId,jdbcType=DECIMAL} then #{item.planName,jdbcType=VARCHAR}
  298. </foreach>
  299. ,SALE_AREA_ID=
  300. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  301. when #{item.planId,jdbcType=DECIMAL} then #{item.saleAreaId,jdbcType=DECIMAL}
  302. </foreach>
  303. ,INSERT_USERNAME=
  304. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  305. when #{item.planId,jdbcType=DECIMAL} then #{item.insertUsername,jdbcType=VARCHAR}
  306. </foreach>
  307. ,INSERT_TIME=
  308. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  309. when #{item.planId,jdbcType=DECIMAL} then #{item.insertTime,jdbcType=TIMESTAMP}
  310. </foreach>
  311. ,UPDATE_USERNAME=
  312. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  313. when #{item.planId,jdbcType=DECIMAL} then #{item.updateUsername,jdbcType=VARCHAR}
  314. </foreach>
  315. ,UPDATE_TIME=
  316. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  317. when #{item.planId,jdbcType=DECIMAL} then #{item.updateTime,jdbcType=TIMESTAMP}
  318. </foreach>
  319. ,INSERT_UPDATE_REMARK=
  320. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  321. when #{item.planId,jdbcType=DECIMAL} then #{item.insertUpdateRemark,jdbcType=VARCHAR}
  322. </foreach>
  323. ,DELETED=
  324. <foreach collection="list" item="item" index="index" separator=" " open="case PLAN_ID" close="end">
  325. when #{item.planId,jdbcType=DECIMAL} then #{item.deleted,jdbcType=DECIMAL}
  326. </foreach>
  327. where PLAN_ID in
  328. <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
  329. #{item.planId,jdbcType=DECIMAL}
  330. </foreach>
  331. </update>
  332. <delete id="batchDelete" parameterType="java.util.List">
  333. delete from AMS_SALE_PLAN
  334. where PLAN_ID in
  335. <foreach collection="list" item="id" open="(" close=")" separator=",">
  336. #{id}
  337. </foreach>
  338. </delete>
  339. <!-- 友情提示!!!-->
  340. <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
  341. <select id="getSalePlanInfo" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  342. select * from(
  343. select a_s_plan.PLAN_ID "planId",
  344. a_s_plan.PLAN_DATE "planDate",
  345. r_s_area.AREA_NAME "areaName",
  346. a_s_plan.INSERT_USERNAME "insertUsername",
  347. a_s_plan.INSERT_TIME "insertTime",
  348. a_s_plan.INSERT_UPDATE_REMARK "insertUpdateRemark"
  349. from AMS_SALE_PLAN a_s_plan
  350. left join RMS_SALE_AREA r_s_area
  351. on a_s_plan.SALE_AREA_ID=r_s_area.AREA_ID
  352. where a_s_plan.DELETED=0)
  353. <where>
  354. <if test="planDate != null">
  355. and
  356. <foreach collection="planDate" item="item" open="(" separator="or" close=")">
  357. "planDate" like '%${item}%'
  358. </foreach>
  359. </if>
  360. <if test="areaName != null">
  361. and
  362. <foreach collection="areaName" item="item" open="(" separator="or" close=")">
  363. "areaName" like '%${item}%'
  364. </foreach>
  365. </if>
  366. <if test="insertUsername != null">
  367. and
  368. <foreach collection="insertUsername" item="item" open="(" separator="or" close=")">
  369. "insertUsername" like '%${item}%'
  370. </foreach>
  371. </if>
  372. <if test="insertTime != null">
  373. and
  374. <foreach collection="insertTime" item="item" open="(" separator="or" close=")">
  375. "insertTime" like '%${item}%'
  376. </foreach>
  377. </if>
  378. <if test="insertUpdateRemark != null">
  379. and
  380. <foreach collection="insertUpdateRemark" item="item" open="(" separator="or" close=")">
  381. "insertUpdateRemark" like '%${item}%'
  382. </foreach>
  383. </if>
  384. <include refid="orderBy"></include>
  385. </where>
  386. </select>
  387. <sql id="orderBy">
  388. <if test="orderField != null and orderField != ''">
  389. order by "${orderField}"
  390. <if test="orderType != null and orderType != ''">
  391. ${orderType}
  392. </if>
  393. </if>
  394. </sql>
  395. <select id="selectMaxId" resultType="java.math.BigDecimal">
  396. select max(PLAN_ID) from AMS_SALE_PLAN
  397. </select>
  398. <select id="getMaterialName" resultType="java.util.LinkedHashMap">
  399. select
  400. MATERIAL_ID "id",
  401. MATERIAL_ID "value",
  402. MATERIAL_NAME "label"
  403. from RMS_MATERIAL
  404. where MATERIAL_CODE like '0801%'
  405. and rownum &lt; 20
  406. </select>
  407. <select id="getAreaName" resultType="java.util.LinkedHashMap">
  408. select
  409. AREA_ID "id",
  410. AREA_ID "value",
  411. AREA_NAME "label"
  412. from RMS_SALE_AREA
  413. </select>
  414. <select id="selectByPlanId" parameterType="java.math.BigDecimal" resultType="java.util.LinkedHashMap">
  415. select
  416. a_s_plan.PLAN_DATE "planDate",
  417. r_s_area.AREA_NAME "areaName",
  418. a_s_plan.INSERT_USERNAME "insertUsername",
  419. a_s_plan.INSERT_TIME "insertTime",
  420. a_s_plan.INSERT_UPDATE_REMARK "insertUpdateRemark"
  421. from AMS_SALE_PLAN a_s_plan
  422. left join RMS_SALE_AREA r_s_area
  423. on a_s_plan.SALE_AREA_ID=r_s_area.AREA_ID
  424. where a_s_plan.PLAN_ID = #{planId}
  425. </select>
  426. <select id="getAreaNameByAreaId" parameterType="java.math.BigDecimal" resultType="String">
  427. select r_s_area.AREA_NAME "areaName" from RMS_SALE_AREA r_s_area where r_s_area.AREA_ID = #{areaId}
  428. </select>
  429. <!-- 查询所有钢材物资 -->
  430. <select id="getAllSteelMaterialMes" parameterType="java.util.Map" resultType="java.util.Map">
  431. SELECT
  432. RM.MATERIAL_ID "materialId",
  433. RM.MATERIAL_CODE "materialCode",
  434. RM.MATERIAL_NAME "materialName",
  435. CONCAT(CONCAT(RM.MATERIAL_SPECIFICATION, '('), CONCAT(RM.MATERIAL_MODEL, ')')) "Specification"
  436. FROM RMS_MATERIAL RM
  437. WHERE RM.MATERIAL_CODE LIKE '0801%'
  438. </select>
  439. </mapper>