BomMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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.usoftchina.saas.document.mapper.BomMapper" >
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Bom" >
  5. <id column="bo_id" property="id" jdbcType="INTEGER" />
  6. <result column="bo_motherid" property="bo_motherid" jdbcType="INTEGER" />
  7. <result column="bo_mothercode" property="bo_mothercode" jdbcType="VARCHAR" />
  8. <result column="bo_mothername" property="bo_mothername" jdbcType="VARCHAR" />
  9. <result column="bo_version" property="bo_version" jdbcType="VARCHAR" />
  10. <result column="bo_status" property="bo_status" jdbcType="VARCHAR" />
  11. <result column="bo_statuscode" property="bo_statuscode" jdbcType="VARCHAR" />
  12. <result column="bo_recorderid" property="bo_recorderid" jdbcType="INTEGER" />
  13. <result column="bo_recorder" property="bo_recorder" jdbcType="VARCHAR" />
  14. <result column="bo_recorddate" property="bo_recorddate" jdbcType="TIMESTAMP" />
  15. <result column="companyId" property="companyId" jdbcType="INTEGER" />
  16. <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
  17. <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
  18. <result column="bo_text1" property="bo_text1" jdbcType="VARCHAR" />
  19. <result column="bo_text2" property="bo_text2" jdbcType="VARCHAR" />
  20. <result column="bo_text3" property="bo_text3" jdbcType="VARCHAR" />
  21. <result column="bo_text4" property="bo_text4" jdbcType="VARCHAR" />
  22. <result column="bo_text5" property="bo_text5" jdbcType="VARCHAR" />
  23. <result column="pr_brand" property="pr_brand" jdbcType="VARCHAR" />
  24. <result column="pr_spec" property="pr_spec" jdbcType="VARCHAR" />
  25. <result column="pr_orispeccode" property="pr_orispeccode" jdbcType="VARCHAR" />
  26. </resultMap>
  27. <sql id="Base_Column_List" >
  28. bo_id, bo_motherid, bo_mothercode, bo_mothername, bo_version, bo_status, bo_statuscode,
  29. bo_recorderid, bo_recorder, bo_recorddate, companyId, updaterId, updateTime, bo_text1,
  30. bo_text2, bo_text3, bo_text4, bo_text5
  31. </sql>
  32. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  33. select
  34. <include refid="Base_Column_List" />
  35. from bom
  36. where bo_id = #{id}
  37. </select>
  38. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
  39. delete from bom
  40. where bo_id = #{id}
  41. </delete>
  42. <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Bom" >
  43. <selectKey resultType="java.lang.Long" keyProperty="id">
  44. SELECT LAST_INSERT_ID() AS ID
  45. </selectKey>
  46. insert into bom (bo_motherid, bo_mothercode,
  47. bo_mothername, bo_version, bo_status,
  48. bo_statuscode, bo_recorderid, bo_recorder,
  49. bo_recorddate, companyId, updaterId,
  50. updateTime, bo_text1, bo_text2,
  51. bo_text3, bo_text4, bo_text5
  52. )
  53. values (#{bo_motherid,jdbcType=INTEGER}, #{bo_mothercode,jdbcType=VARCHAR},
  54. #{bo_mothername,jdbcType=VARCHAR}, #{bo_version,jdbcType=VARCHAR}, #{bo_status,jdbcType=VARCHAR},
  55. #{bo_statuscode,jdbcType=VARCHAR}, #{bo_recorderid,jdbcType=INTEGER}, #{bo_recorder,jdbcType=VARCHAR},
  56. #{bo_recorddate,jdbcType=TIMESTAMP}, #{companyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER},
  57. #{updateTime,jdbcType=TIMESTAMP}, #{bo_text1,jdbcType=VARCHAR}, #{bo_text2,jdbcType=VARCHAR},
  58. #{bo_text3,jdbcType=VARCHAR}, #{bo_text4,jdbcType=VARCHAR}, #{bo_text5,jdbcType=VARCHAR}
  59. )
  60. </insert>
  61. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Bom" >
  62. <selectKey resultType="java.lang.Long" keyProperty="id">
  63. SELECT LAST_INSERT_ID() AS ID
  64. </selectKey>
  65. insert into bom
  66. <trim prefix="(" suffix=")" suffixOverrides="," >
  67. <if test="bo_motherid != null" >
  68. bo_motherid,
  69. </if>
  70. <if test="bo_mothercode != null" >
  71. bo_mothercode,
  72. </if>
  73. <if test="bo_mothername != null" >
  74. bo_mothername,
  75. </if>
  76. <if test="bo_version != null" >
  77. bo_version,
  78. </if>
  79. <if test="bo_status != null" >
  80. bo_status,
  81. </if>
  82. <if test="bo_statuscode != null" >
  83. bo_statuscode,
  84. </if>
  85. <if test="bo_recorderid != null" >
  86. bo_recorderid,
  87. </if>
  88. <if test="bo_recorder != null" >
  89. bo_recorder,
  90. </if>
  91. <if test="bo_recorddate != null" >
  92. bo_recorddate,
  93. </if>
  94. <if test="companyId != null" >
  95. companyId,
  96. </if>
  97. <if test="updaterId != null" >
  98. updaterId,
  99. </if>
  100. <if test="updateTime != null" >
  101. updateTime,
  102. </if>
  103. <if test="bo_text1 != null" >
  104. bo_text1,
  105. </if>
  106. <if test="bo_text2 != null" >
  107. bo_text2,
  108. </if>
  109. <if test="bo_text3 != null" >
  110. bo_text3,
  111. </if>
  112. <if test="bo_text4 != null" >
  113. bo_text4,
  114. </if>
  115. <if test="bo_text5 != null" >
  116. bo_text5,
  117. </if>
  118. </trim>
  119. <trim prefix="values (" suffix=")" suffixOverrides="," >
  120. <if test="bo_motherid != null" >
  121. #{bo_motherid,jdbcType=INTEGER},
  122. </if>
  123. <if test="bo_mothercode != null" >
  124. #{bo_mothercode,jdbcType=VARCHAR},
  125. </if>
  126. <if test="bo_mothername != null" >
  127. #{bo_mothername,jdbcType=VARCHAR},
  128. </if>
  129. <if test="bo_version != null" >
  130. #{bo_version,jdbcType=VARCHAR},
  131. </if>
  132. <if test="bo_status != null" >
  133. #{bo_status,jdbcType=VARCHAR},
  134. </if>
  135. <if test="bo_statuscode != null" >
  136. #{bo_statuscode,jdbcType=VARCHAR},
  137. </if>
  138. <if test="bo_recorderid != null" >
  139. #{bo_recorderid,jdbcType=INTEGER},
  140. </if>
  141. <if test="bo_recorder != null" >
  142. #{bo_recorder,jdbcType=VARCHAR},
  143. </if>
  144. <if test="bo_recorddate != null" >
  145. #{bo_recorddate,jdbcType=TIMESTAMP},
  146. </if>
  147. <if test="companyId != null" >
  148. #{companyId,jdbcType=INTEGER},
  149. </if>
  150. <if test="updaterId != null" >
  151. #{updaterId,jdbcType=INTEGER},
  152. </if>
  153. <if test="updateTime != null" >
  154. #{updateTime,jdbcType=TIMESTAMP},
  155. </if>
  156. <if test="bo_text1 != null" >
  157. #{bo_text1,jdbcType=VARCHAR},
  158. </if>
  159. <if test="bo_text2 != null" >
  160. #{bo_text2,jdbcType=VARCHAR},
  161. </if>
  162. <if test="bo_text3 != null" >
  163. #{bo_text3,jdbcType=VARCHAR},
  164. </if>
  165. <if test="bo_text4 != null" >
  166. #{bo_text4,jdbcType=VARCHAR},
  167. </if>
  168. <if test="bo_text5 != null" >
  169. #{bo_text5,jdbcType=VARCHAR},
  170. </if>
  171. </trim>
  172. </insert>
  173. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Bom" >
  174. update bom
  175. <set >
  176. <if test="bo_motherid != null" >
  177. bo_motherid = #{bo_motherid,jdbcType=INTEGER},
  178. </if>
  179. <if test="bo_mothercode != null" >
  180. bo_mothercode = #{bo_mothercode,jdbcType=VARCHAR},
  181. </if>
  182. <if test="bo_mothername != null" >
  183. bo_mothername = #{bo_mothername,jdbcType=VARCHAR},
  184. </if>
  185. <if test="bo_version != null" >
  186. bo_version = #{bo_version,jdbcType=VARCHAR},
  187. </if>
  188. <if test="bo_status != null" >
  189. bo_status = #{bo_status,jdbcType=VARCHAR},
  190. </if>
  191. <if test="bo_statuscode != null" >
  192. bo_statuscode = #{bo_statuscode,jdbcType=VARCHAR},
  193. </if>
  194. <if test="bo_recorderid != null" >
  195. bo_recorderid = #{bo_recorderid,jdbcType=INTEGER},
  196. </if>
  197. <if test="bo_recorder != null" >
  198. bo_recorder = #{bo_recorder,jdbcType=VARCHAR},
  199. </if>
  200. <if test="bo_recorddate != null" >
  201. bo_recorddate = #{bo_recorddate,jdbcType=TIMESTAMP},
  202. </if>
  203. <if test="companyId != null" >
  204. companyId = #{companyId,jdbcType=INTEGER},
  205. </if>
  206. <if test="updaterId != null" >
  207. updaterId = #{updaterId,jdbcType=INTEGER},
  208. </if>
  209. <if test="updateTime != null" >
  210. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  211. </if>
  212. <if test="bo_text1 != null" >
  213. bo_text1 = #{bo_text1,jdbcType=VARCHAR},
  214. </if>
  215. <if test="bo_text2 != null" >
  216. bo_text2 = #{bo_text2,jdbcType=VARCHAR},
  217. </if>
  218. <if test="bo_text3 != null" >
  219. bo_text3 = #{bo_text3,jdbcType=VARCHAR},
  220. </if>
  221. <if test="bo_text4 != null" >
  222. bo_text4 = #{bo_text4,jdbcType=VARCHAR},
  223. </if>
  224. <if test="bo_text5 != null" >
  225. bo_text5 = #{bo_text5,jdbcType=VARCHAR},
  226. </if>
  227. </set>
  228. where bo_id = #{id}
  229. </update>
  230. <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Bom" >
  231. update bom
  232. set bo_motherid = #{bo_motherid,jdbcType=INTEGER},
  233. bo_mothercode = #{bo_mothercode,jdbcType=VARCHAR},
  234. bo_mothername = #{bo_mothername,jdbcType=VARCHAR},
  235. bo_version = #{bo_version,jdbcType=VARCHAR},
  236. bo_status = #{bo_status,jdbcType=VARCHAR},
  237. bo_statuscode = #{bo_statuscode,jdbcType=VARCHAR},
  238. bo_recorderid = #{bo_recorderid,jdbcType=INTEGER},
  239. bo_recorder = #{bo_recorder,jdbcType=VARCHAR},
  240. bo_recorddate = #{bo_recorddate,jdbcType=TIMESTAMP},
  241. companyId = #{companyId,jdbcType=INTEGER},
  242. updaterId = #{updaterId,jdbcType=INTEGER},
  243. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  244. bo_text1 = #{bo_text1,jdbcType=VARCHAR},
  245. bo_text2 = #{bo_text2,jdbcType=VARCHAR},
  246. bo_text3 = #{bo_text3,jdbcType=VARCHAR},
  247. bo_text4 = #{bo_text4,jdbcType=VARCHAR},
  248. bo_text5 = #{bo_text5,jdbcType=VARCHAR}
  249. where bo_id = #{id}
  250. </update>
  251. <select id="validateCodeWhenInsert" resultType="int">
  252. select count(*) from BOM where BO_MOTHERCODE = #{code} and companyId =#{companyId}
  253. </select>
  254. <select id="validateCodeWhenUpdate" resultType="int" >
  255. select count(*) from BOM where BO_MOTHERCODE = #{code} and BO_ID != #{id} and companyId =#{companyId}
  256. </select>
  257. <select id="validCodeAndVersion" resultType="int">
  258. SELECT COUNT(*) FROM BOM WHERE BO_MOTHERCODE = #{code} and BO_VERSION=#{version} and COMPANYID=#{companyId}
  259. </select>
  260. <select id="getCodeById" resultType="string">
  261. SELECT BO_MOTHERCODE FROM BOM WHERE BO_ID = #{id} and COMPANYID = #{companyId}
  262. </select>
  263. <select id="getListData" resultMap="BaseResultMap">
  264. SELECT * FROM BOM LEFT JOIN PRODUCT ON PR_ID=BO_MOTHERID
  265. <where>
  266. <if test="condition!=null">
  267. ${condition}
  268. </if>
  269. <if test="companyId!=null">
  270. AND BOM.companyId = #{companyId}
  271. </if>
  272. </where>
  273. ORDER BY BO_ID DESC
  274. </select>
  275. </mapper>