BomMapper.xml 10 KB

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