BomMapper.xml 12 KB

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