BomMapper.xml 10 KB

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