You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1216 lines
51 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
2 years ago
​
2 years ago
​
2 years ago
​
​
​
​
2 years ago
​
2 years ago
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
1 year ago
1 year ago
​
1 year ago
1 year ago
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
1 year ago
1 year ago
1 year ago
​
​
​
1 year ago
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
2 years ago
​
2 years ago
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
  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.xujie.sys.modules.part.mapper.PartInformationMapper">
  4. <!-- 材料信息列表 -->
  5. <select id="partInformationSearch" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
  6. SELECT
  7. a.id,
  8. a.site,
  9. a.part_no,
  10. a.part_desc,
  11. a.umid2 as umId2,
  12. um.UMName as umName,
  13. a.spec,
  14. a.created_by as createBy,
  15. a.creation_date as createDate,
  16. a.active,
  17. case when a.active = 'Y' then '是' when a.active = 'N' then '否' else '' end as activeDesc,
  18. a.remark,
  19. a.part_type2,
  20. case when a.part_type2 = 'Manufactured' then '成品' when a.part_type2 = 'Manufactured Recipe' then '半成品' when a.part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
  21. a.sourceBu as buNo,
  22. a.product_group_id1,
  23. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id1, '1') as productGroupName1,
  24. a.product_group_id2,
  25. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id2, '2') as productGroupName2,
  26. a.product_group_id3,
  27. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id3, '3') as productGroupName3,
  28. a.FamilyID as familyID,
  29. pf.family_name as familyName,
  30. a.part_desce_en,
  31. a.code_no,
  32. dbo.get_code_desc(a.site, a.sourceBu, a.code_no, 'IP') as codeDesc,
  33. dbo.get_bu_desc(a.site, a.sourceBu) as buDesc,
  34. a.update_by,
  35. a.update_date,
  36. a.standard_cost,
  37. a.standard_cost_currency,
  38. a.actual_cost,
  39. a.actual_cost_currency,
  40. a.template_no,
  41. pbt.template_name
  42. FROM part as a
  43. LEFT JOIN UM as um on a.site = um.site and a.umid2 = um.UMID
  44. LEFT JOIN part_family as pf on a.site = pf.site and a.sourceBu = pf.bu_no and a.FamilyID = pf.family_id
  45. LEFT JOIN plm_bom_template as pbt on a.site = pbt.site and a.template_no = pbt.template_no
  46. <where>
  47. a.site in (select site from eam_access_site where username = #{query.userName})
  48. and (a.site + '-' + a.sourceBu) in (select * from dbo.query_bu(#{query.userName}))
  49. <if test="query.queryType != null and query.queryType != ''">
  50. AND a.part_no like #{query.queryType} + '%'
  51. </if>
  52. <if test="query.buNo != null and query.buNo != ''">
  53. AND a.sourceBu = #{query.buNo}
  54. </if>
  55. <if test = "query.partNo != null and query.partNo != ''">
  56. AND a.part_no like '%' + #{query.partNo} + '%'
  57. </if>
  58. <if test = "query.partDesc != null and query.partDesc != ''">
  59. AND a.part_desc like '%' + #{query.partDesc} + '%'
  60. </if>
  61. <if test="query.startDate != null">
  62. AND a.creation_date >= #{query.startDate}
  63. </if>
  64. <if test="query.endDate != null">
  65. AND #{query.endDate} >= a.creation_date
  66. </if>
  67. <if test="query.partNos != null and query.partNos.size() > 0">
  68. AND a.part_no IN
  69. <foreach collection="query.partNos" item="partNo" open="(" separator="," close=")">
  70. #{partNo}
  71. </foreach>
  72. </if>
  73. </where>
  74. </select>
  75. <select id="partInformationHsCode" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
  76. SELECT
  77. a.id,
  78. a.site,
  79. a.part_no,
  80. a.part_desc,
  81. a.umid2 as umId2,
  82. dbo.qc_get_um_name(a.site, a.umid2) as umName,
  83. a.spec,
  84. a.created_by as createBy,
  85. a.creation_date as createDate,
  86. a.active,
  87. case when a.active = 'Y' then '是' when a.active = 'N' then '否' else '' end as activeDesc,
  88. a.remark,
  89. a.part_type2,
  90. case when a.part_type2 = 'Manufactured' then '成品' when a.part_type2 = 'Manufactured Recipe' then '半成品' when a.part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
  91. a.sourceBu as buNo,
  92. a.product_group_id1,
  93. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id1, '1') as productGroupName1,
  94. a.product_group_id2,
  95. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id2, '2') as productGroupName2,
  96. a.product_group_id3,
  97. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id3, '3') as productGroupName3,
  98. a.FamilyID as familyID,
  99. dbo.get_family_name(a.site, a.sourceBu, a.FamilyID) as familyName,
  100. a.part_desce_en,
  101. a.code_no,
  102. dbo.get_code_desc(a.site, a.sourceBu, a.code_no, 'IP') as codeDesc,
  103. dbo.get_bu_desc(a.site, a.sourceBu) as buDesc,
  104. a.update_by,
  105. a.update_date,
  106. a.standard_cost,
  107. a.standard_cost_currency,
  108. a.actual_cost,
  109. a.actual_cost_currency,
  110. a.hsCode, a.hsCodeDesc,
  111. a.packageNo,a.sku,a.box_length as boxLength,a.box_width as boxWidth,a.box_height as boxHeight
  112. FROM part a
  113. left join ecss_hsCode h on a.hsCodeDesc=h.hsCodeDesc and a.site=h.site
  114. <where>
  115. (a.site + '-' + a.sourceBu) in (select * from dbo.query_bu(#{query.userName}))
  116. <if test="query.queryType != null and query.queryType != ''">
  117. AND a.part_no like #{query.queryType} + '%'
  118. </if>
  119. <if test="query.buNo != null and query.buNo != ''">
  120. AND a.sourceBu = #{query.buNo}
  121. </if>
  122. <if test = "query.partNo != null and query.partNo != ''">
  123. AND a.part_no like '%' + #{query.partNo} + '%'
  124. </if>
  125. <if test = "query.partDesc != null and query.partDesc != ''">
  126. AND a.part_desc like '%' + #{query.partDesc} + '%'
  127. </if>
  128. <if test = "query.sku != null and query.sku != ''">
  129. AND a.sku like '%' + #{query.sku} + '%'
  130. </if>
  131. <if test="query.startDate != null">
  132. AND a.creation_date >= #{query.startDate}
  133. </if>
  134. <if test="query.endDate != null">
  135. AND #{query.endDate} >= a.creation_date
  136. </if>
  137. </where>
  138. </select>
  139. <!-- 检查材料属性 -->
  140. <select id="checkValueHeaderData" resultType="PartSubPropertiesValueHeaderData">
  141. SELECT
  142. site,
  143. bu_no,
  144. part_no,
  145. code_no,
  146. sub_code_seq_no,
  147. sub_code_desc,
  148. record_type
  149. from part_sub_properties_value_header
  150. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and code_no = #{codeNo} and record_type = #{recordType}
  151. <if test="brand != null and brand != ''">
  152. and ISNULL(brand,'无') = ISNULL(#{brand},'无')
  153. </if>
  154. </select>
  155. <!-- 删除材料属性 -->
  156. <delete id="deletePartSubPropertiesValueHeader">
  157. delete from part_sub_properties_value_header
  158. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType}
  159. <if test="brand != null and brand != ''">
  160. and ISNULL(brand,'无') = ISNULL(#{brand},'无')
  161. </if>
  162. </delete>
  163. <!-- 删除材料属性值 -->
  164. <delete id="deletePartSubPropertiesValue">
  165. delete from part_sub_properties_value
  166. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType}
  167. <if test="brand != null and brand != ''">
  168. and ISNULL(brand,'无') = ISNULL(#{brand},'无')
  169. </if>
  170. </delete>
  171. <!-- 新增材料属性 -->
  172. <insert id="savePartSubPropertiesValueHeader">
  173. insert into part_sub_properties_value_header
  174. (part_no, site, bu_no, code_no, brand, sub_code_seq_no, sub_code_desc, record_type)
  175. select
  176. #{partNo},
  177. #{site},
  178. #{buNo},
  179. #{codeNo},
  180. #{brand,jdbcType=NVARCHAR},
  181. 1,
  182. code_desc,
  183. #{recordType}
  184. from plm_properties_model_header
  185. where code_no = #{codeNo} and site = #{site} and bu_no = #{buNo} and function_type = #{recordType}
  186. </insert>
  187. <!-- 新增材料属性值 -->
  188. <insert id="savePartSubPropertiesValue">
  189. insert into part_sub_properties_value
  190. (part_no, site, bu_no, code_no, brand, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
  191. select
  192. #{partNo},
  193. #{site},
  194. #{buNo},
  195. #{codeNo},
  196. #{brand,jdbcType=NVARCHAR},
  197. 1,
  198. a.code_desc,
  199. b.seq_No,
  200. b.properties_item_no,
  201. case when c.value_type_db = 'T' then c.default_value else null end,
  202. case when c.value_type_db = 'N' and c.default_value != '' then c.default_value else null end,
  203. #{recordType}
  204. from plm_properties_model_header a
  205. left join plm_properties_model_detail b on a.code_no = b.code_no and a.site = b.site and a.bu_no = b.bu_no and a.function_type = b.function_type
  206. left join plm_properties_item c on b.properties_item_no = c.item_no and b.site = c.site and b.bu_no = c.bu_no and a.function_type = c.item_type
  207. where a.code_no = #{codeNo} and a.site = #{site} and a.bu_no = #{buNo} AND B.site IS NOT NULL AND A.function_type = #{recordType}
  208. </insert>
  209. <select id="getItemModal" resultType="PartSubPropertiesValueData">
  210. SELECT
  211. a.part_no,
  212. a.site,
  213. a.bu_no,
  214. a.code_no,
  215. a.sub_code_seq_no,
  216. a.sub_code_desc,
  217. a.item_no,
  218. a.properties_item_no,
  219. a.text_value,
  220. a.num_value,
  221. a.record_type,
  222. b.item_desc as itemDesc,
  223. b.value_type,
  224. b.value_type_db,
  225. b.value_choose_flag
  226. FROM part_sub_properties_value as a
  227. left join plm_properties_item as b on a.properties_item_no = b.item_no and a.site = b.site and a.bu_no = b.bu_no and a.record_type = b.item_type
  228. where a.site = #{site} and a.bu_no = #{buNo} and record_type = #{recordType} and a.part_no = #{partNo} and a.code_no = #{codeNo}
  229. order by a.properties_item_no
  230. </select>
  231. <select id="getTempItemModal" resultType="com.xujie.sys.modules.part.entity.CopyTempItemValue">
  232. SELECT
  233. a.id,
  234. a.part_no,
  235. a.site,
  236. a.bu_no,
  237. a.code_no,
  238. a.sub_code_seq_no,
  239. a.sub_code_desc,
  240. a.item_no,
  241. a.properties_item_no,
  242. a.text_value,
  243. a.num_value,
  244. a.record_type,
  245. a.tree_id,
  246. b.item_desc as itemDesc,
  247. b.value_type,
  248. b.value_type_db,
  249. b.value_choose_flag
  250. FROM plm_copy_temp_item_value as a
  251. left join plm_properties_item as b on a.properties_item_no = b.item_no and a.site = b.site and a.bu_no = b.bu_no and a.record_type = b.item_type
  252. where a.tree_id = #{treeId}
  253. </select>
  254. <!-- 获取属性可选值 -->
  255. <select id="getAvailableValueList" resultType="com.xujie.sys.modules.part.entity.PlmPropertiesItemAvailableData">
  256. select
  257. itemNo,
  258. valueNo,
  259. availableValue
  260. from plm_properties_item_available
  261. where itemNo = #{propertiesItemNo} and site = #{site} and bu_no = #{buNo} and itemType = #{recordType}
  262. </select>
  263. <select id="getAvailableValueList2" resultType="com.xujie.sys.modules.part.entity.PlmPropertiesItemAvailableData" parameterType="com.xujie.sys.modules.part.entity.CopyTempItemValue">
  264. select
  265. itemNo,
  266. valueNo,
  267. availableValue
  268. from plm_properties_item_available
  269. where itemNo = #{propertiesItemNo} and site = #{site} and bu_no = #{buNo} and itemType = #{recordType}
  270. </select>
  271. <!-- 编辑属性值 -->
  272. <update id="savePartItemValue" >
  273. update part_sub_properties_value
  274. set text_value = #{textValue},
  275. num_value = #{numValue, jdbcType=DOUBLE}
  276. where properties_item_no = #{propertiesItemNo} and site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and record_type = #{recordType}
  277. </update>
  278. <!-- 查询代理商列表 -->
  279. <select id="getAgentList" resultType="AgentInformationEntity" parameterType="AgentInformationEntity">
  280. SELECT
  281. site,
  282. bu_no,
  283. agent_id,
  284. agent_name
  285. FROM agent
  286. <where>
  287. site = #{site} and bu_no = #{buNo}
  288. <if test = "agentId != null and agentId != ''">
  289. AND agent_id LIKE '%' + #{agentId} + '%'
  290. </if>
  291. <if test = "agentName != null and agentName != ''">
  292. AND agent_name LIKE '%' + #{deptName} + '%'
  293. </if>
  294. </where>
  295. </select>
  296. <!-- 查询代理商列表 -->
  297. <select id="getPartAgent" resultType="com.xujie.sys.modules.part.vo.AgentInformationVo" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
  298. SELECT
  299. a.site,
  300. a.bu_no,
  301. a.part_no,
  302. a.agent_id,
  303. b.agent_name,
  304. b.active,
  305. b.create_date,
  306. b.create_by,
  307. b.update_date,
  308. b.update_by
  309. FROM part_agent as a
  310. left join agent as b on a.site = b.site and a.bu_no = b.bu_no and a.agent_id = b.agent_id
  311. where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
  312. </select>
  313. <!-- 获取当前物料不包含的代理商 -->
  314. <select id="getAgentList1" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
  315. SELECT
  316. a.site,
  317. a.bu_no,
  318. a.agent_id,
  319. a.agent_name,
  320. a.active,
  321. a.create_date,
  322. a.create_by,
  323. a.update_date,
  324. a.update_by
  325. FROM agent as a
  326. left join part_agent as b on a.site = b.site and a.bu_no = b.bu_no and a.agent_id = b.agent_id and b.part_no = #{partNo}
  327. where a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
  328. </select>
  329. <!-- 获取当前物料所包含的代理商 -->
  330. <select id="getAgentList2" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
  331. SELECT
  332. a.site,
  333. a.bu_no,
  334. a.agent_id,
  335. b.agent_name,
  336. b.active,
  337. b.create_date,
  338. b.create_by,
  339. b.update_date,
  340. b.update_by
  341. FROM part_agent a
  342. LEFT JOIN agent b ON a.agent_id = b.agent_id and a.site = b.site and a.bu_no = b.bu_no
  343. WHERE a.part_no = #{partNo} and a.site = #{site} and a.bu_no = #{buNo}
  344. </select>
  345. <!-- 获取当前物料所包含的代理商 -->
  346. <select id="selectAgentByPartNo" resultType="com.xujie.sys.modules.part.vo.AgentInformationVo" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
  347. SELECT
  348. site,
  349. agent_id
  350. FROM part_agent
  351. WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and agent_id = #{agentId}
  352. </select>
  353. <!-- 新增物料代理商 -->
  354. <insert id="addPartAgent" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
  355. insert into part_agent (site, part_no, agent_id, bu_no)
  356. values (#{site}, #{partNo}, #{agentId}, #{buNo})
  357. </insert>
  358. <!-- 删除物料代理商 -->
  359. <delete id="deletePartAgent" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
  360. delete from part_agent
  361. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and agent_id = #{agentId}
  362. </delete>
  363. <!-- 获取当前物料不包含的代理商 -->
  364. <select id="getAgentListBy" resultType="AgentInformationEntity" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
  365. SELECT
  366. a.site,
  367. a.bu_no,
  368. a.agent_id,
  369. a.agent_name,
  370. a.active,
  371. a.create_date,
  372. a.create_by,
  373. a.update_date,
  374. a.update_by
  375. FROM agent as a
  376. left join part_agent as b on a.site = b.site and a.bu_no = b.bu_no and a.agent_id = b.agent_id and b.part_no = #{partNo}
  377. <where>
  378. a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
  379. <if test = "agentId != null and agentId != ''">
  380. AND a.agent_id LIKE '%' + #{agentId} + '%'
  381. </if>
  382. <if test = "agentName != null and agentName != ''">
  383. AND a.agent_name LIKE '%' + #{agentName} + '%'
  384. </if>
  385. </where>
  386. </select>
  387. <!-- 删除物料代理商 -->
  388. <delete id="deleteAgent" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
  389. delete from part_agent
  390. where part_no = #{partNo} and site = #{site} and agent_id = #{agentId} and bu_no = #{buNo}
  391. </delete>
  392. <!-- 查询制造商列表 -->
  393. <select id="getPartManufacturer" resultType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
  394. SELECT
  395. a.site,
  396. a.bu_no,
  397. a.part_no,
  398. a.manufacturer_id,
  399. b.manufacturer_name,
  400. b.active,
  401. b.create_date,
  402. b.create_by,
  403. b.update_date,
  404. b.update_by
  405. FROM part_manufacturer as a
  406. left join manufacturer as b on a.site = b.site and a.bu_no = b.bu_no and a.manufacturer_id = b.manufacturer_id
  407. where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
  408. </select>
  409. <!-- 获取当前物料不包含的制造商 -->
  410. <select id="getManufacturerList1" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
  411. SELECT
  412. a.site,
  413. a.bu_no,
  414. a.manufacturer_id,
  415. a.manufacturer_name,
  416. a.active,
  417. a.create_date,
  418. a.create_by,
  419. a.update_date,
  420. a.update_by
  421. FROM manufacturer as a
  422. left join part_manufacturer as b on a.site = b.site and a.bu_no = b.bu_no and a.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
  423. where a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
  424. </select>
  425. <!-- 获取当前物料所包含的制造商 -->
  426. <select id="getManufacturerList2" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
  427. SELECT
  428. a.site,
  429. a.bu_no,
  430. a.manufacturer_id,
  431. b.manufacturer_name,
  432. b.active,
  433. b.create_date,
  434. b.create_by,
  435. b.update_date,
  436. b.update_by
  437. FROM part_manufacturer a
  438. LEFT JOIN manufacturer b ON a.manufacturer_id = b.manufacturer_id and a.site = b.site and a.bu_no = b.bu_no
  439. WHERE a.part_no = #{partNo} and a.site = #{site} and a.bu_no = #{buNo}
  440. </select>
  441. <!-- 获取当前物料所包含的制造商 -->
  442. <select id="selectManufacturerByPartNo" resultType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
  443. SELECT
  444. site,
  445. bu_no,
  446. manufacturer_id
  447. FROM part_manufacturer
  448. WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and manufacturer_id = #{manufacturerId}
  449. </select>
  450. <!-- 新增物料制造商 -->
  451. <insert id="addPartManufacturer" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
  452. insert into part_manufacturer (site, part_no, manufacturer_id, bu_no)
  453. values (#{site}, #{partNo}, #{manufacturerId}, #{buNo})
  454. </insert>
  455. <!-- 删除物料制造商 -->
  456. <delete id="deletePartManufacturer" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
  457. delete from part_manufacturer
  458. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and manufacturer_id = #{manufacturerId}
  459. </delete>
  460. <!-- 删除物料制造商 -->
  461. <delete id="deleteManufacturer">
  462. delete from part_manufacturer
  463. where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId} and bu_no = #{buNo}
  464. </delete>
  465. <!-- 获取当前物料不包含的制造商 -->
  466. <select id="getManufacturerListBy" resultType="ManufacturerInformationEntity" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
  467. SELECT
  468. a.site,
  469. a.manufacturer_id,
  470. a.manufacturer_name,
  471. a.active,
  472. a.create_date,
  473. a.create_by,
  474. a.update_date,
  475. a.update_by
  476. FROM manufacturer as a
  477. left join part_manufacturer as b on a.site = b.site and a.bu_no = b.bu_no and a.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
  478. <where>
  479. a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
  480. <if test = "manufacturerId != null and manufacturerId != ''">
  481. AND a.manufacturer_id LIKE '%' + #{manufacturerId} + '%'
  482. </if>
  483. <if test = "manufacturerName != null and manufacturerName != ''">
  484. AND a.manufacturer_name LIKE '%' + #{manufacturerName} + '%'
  485. </if>
  486. </where>
  487. </select>
  488. <update id="commitItemValue" parameterType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  489. UPDATE part_sub_properties_value
  490. SET text_value = #{textValue},
  491. num_value = #{numValue, jdbcType=DECIMAL}
  492. WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo} and record_type = #{recordType}
  493. </update>
  494. <update id="commitTempItemValue" parameterType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  495. UPDATE plm_copy_temp_item_value
  496. SET text_value = #{textValue},
  497. num_value = #{numValue, jdbcType=DECIMAL}
  498. WHERE id = #{id}
  499. </update>
  500. <!-- 删除属性值 -->
  501. <delete id="deleteItem" parameterType="PartSubPropertiesValueData">
  502. delete from part_sub_properties_value
  503. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo}
  504. </delete>
  505. <select id="getItemLists" resultType="PropertiesItemData" parameterType="PartSubPropertiesValueData">
  506. SELECT
  507. a.item_no as itNo,
  508. a.item_desc
  509. FROM plm_properties_item a
  510. LEFT JOIN part_sub_properties_value b on b.record_type = #{recordType} and b.code_no = #{codeNo} and b.part_no = #{partNo} and b.properties_item_no = a.item_No and a.site = b.site and a.bu_no = b.bu_no
  511. <where>
  512. a.item_type = #{recordType}
  513. and a.site = #{site} and a.bu_no = #{buNo}
  514. AND b.code_no is null
  515. <if test = "propertiesItemNo != null and propertiesItemNo != ''">
  516. AND a.item_no LIKE #{propertiesItemNo}
  517. </if>
  518. <if test = "itemDesc != null and itemDesc != ''">
  519. AND a.item_desc LIKE #{itemDesc}
  520. </if>
  521. </where>
  522. order by a.item_no
  523. </select>
  524. <select id="getModelItemLists" resultType="PropertiesItemData" parameterType="PartSubPropertiesValueData">
  525. select
  526. a.properties_item_no as itNo,
  527. b.item_desc,
  528. a.item_no,
  529. a.part_no,
  530. a.site,
  531. a.bu_no,
  532. a.code_no,
  533. a.sub_code_seq_no,
  534. a.record_type
  535. from part_sub_properties_value a
  536. left join plm_properties_item b on a.properties_item_no = b.item_no and a.record_type = b.item_type and a.site = b.site and a.bu_no = b.bu_no
  537. where a.code_no = #{codeNo} and a.record_type = #{recordType} and a.site = #{site} and a.part_no = #{partNo} and a.bu_no = #{buNo}
  538. order by a.properties_item_no
  539. </select>
  540. <select id="checkPartItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
  541. select
  542. site,
  543. bu_no,
  544. part_no,
  545. code_no,
  546. sub_code_seq_no,
  547. item_no,
  548. properties_item_no,
  549. record_type
  550. from part_sub_properties_value
  551. where code_no = #{codeNo} and record_type = #{recordType} and site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and properties_item_no = #{itNo}
  552. </select>
  553. <select id="checkItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
  554. SELECT
  555. item_desc
  556. FROM plm_properties_item
  557. where item_type = #{recordType} and item_no = #{itNo} and site = #{site}
  558. </select>
  559. <select id="getModalDetailSeqNo" resultType="double" parameterType="PartSubPropertiesValueData">
  560. SELECT
  561. isnull(max(item_no),0) + 1
  562. from part_sub_properties_value
  563. where record_type = #{recordType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and sub_code_seq_no = #{subCodeSeqNo}
  564. </select>
  565. <insert id="addPartItem" parameterType="PartSubPropertiesValueData">
  566. insert into part_sub_properties_value
  567. (part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
  568. values (#{partNo}, #{site}, #{buNo}, #{codeNo}, #{subCodeSeqNo,jdbcType=FLOAT}, #{codeDesc}, #{itemNo, jdbcType=FLOAT}, #{itNo}, #{textValue}, #{numValue, jdbcType=FLOAT}, #{recordType})
  569. </insert>
  570. <update id="updatePartItemValue" parameterType="PartSubPropertiesValueData">
  571. UPDATE part_sub_properties_value
  572. SET text_value = #{textValue},
  573. num_value = #{numValue, jdbcType=FLOAT}
  574. WHERE part_no = #{partNo}
  575. AND site = #{site}
  576. AND bu_no = #{buNo}
  577. AND record_type = #{recordType}
  578. AND code_no = #{codeNo}
  579. AND sub_code_seq_no = #{subCodeSeqNo}
  580. AND item_no = #{itemNo}
  581. </update>
  582. <delete id="deletePartItem" parameterType="PartSubPropertiesValueData">
  583. delete from part_sub_properties_value
  584. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo}
  585. </delete>
  586. <select id="queryCodeNo" parameterType="com.xujie.sys.modules.part.entity.PartInformationEntity" resultType="PartSubPropertiesValueData">
  587. SELECT
  588. part_no,
  589. site,
  590. bu_no,
  591. code_no,
  592. sub_code_seq_no,
  593. sub_code_desc,
  594. record_type
  595. FROM part_sub_properties_value_header
  596. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and sub_code_seq_no = 1 and record_type = 'IP'
  597. </select>
  598. <!-- 获取当前物料不包含的库位 -->
  599. <select id="getLocationList1" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
  600. SELECT
  601. a.site,
  602. a.bu_no,
  603. a.location_id,
  604. a.location_name,
  605. a.warehouse_id,
  606. a.active,
  607. a.created_date as createDate,
  608. a.created_by as createBy,
  609. a.update_date,
  610. a.update_by,
  611. a.location_type
  612. FROM location as a
  613. left join part_location as b on a.site = b.site and a.bu_no = b.bu_no and a.location_id = b.location_id and b.part_no = #{partNo}
  614. where a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
  615. </select>
  616. <!-- 获取当前物料所包含的库位 -->
  617. <select id="getLocationList2" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
  618. SELECT
  619. a.site,
  620. a.bu_no,
  621. a.location_id,
  622. b.location_name,
  623. b.warehouse_id,
  624. b.active,
  625. b.created_date as createDate,
  626. b.created_by as createBy,
  627. b.update_date,
  628. b.update_by,
  629. b.location_type
  630. FROM part_location a
  631. LEFT JOIN location b ON a.location_id = b.location_id and a.site = b.site and a.bu_no = b.bu_no
  632. WHERE a.part_no = #{partNo} and a.site = #{site} and a.bu_no = #{buNo}
  633. </select>
  634. <!-- 获取当前物料不包含的库位 -->
  635. <select id="getLocationListBy" resultType="LocationInformationEntity" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
  636. SELECT
  637. a.id,
  638. a.site,
  639. a.bu_no,
  640. a.location_id,
  641. a.location_name,
  642. a.warehouse_id,
  643. a.active,
  644. a.created_date as createDate,
  645. a.created_by as createBy,
  646. a.update_date,
  647. a.update_by,
  648. a.version
  649. FROM location as a
  650. left join part_location as b on a.site = b.site and a.bu_no = b.bu_no and a.location_id = b.location_id and b.part_no = #{partNo}
  651. <where>
  652. a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
  653. <if test = "locationId != null and locationId != ''">
  654. AND a.location_id LIKE '%' + #{locationId} + '%'
  655. </if>
  656. <if test = "locationName != null and locationName != ''">
  657. AND a.location_name LIKE '%' + #{locationName} + '%'
  658. </if>
  659. </where>
  660. </select>
  661. <!-- 查询库位列表 -->
  662. <select id="getDefaultLocation" resultType="com.xujie.sys.modules.part.vo.LocationInformationVo" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
  663. SELECT
  664. a.site,
  665. a.bu_no,
  666. a.part_no,
  667. a.location_id,
  668. b.location_name,
  669. b.warehouse_id,
  670. b.active,
  671. b.created_date as createDate,
  672. b.created_by as createBy,
  673. b.update_date,
  674. b.update_by,
  675. b.delflag,
  676. b.version,
  677. b.keeper
  678. FROM part_location as a
  679. left join location as b on a.site = b.site and a.bu_no = b.bu_no and a.location_id = b.location_id
  680. where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
  681. </select>
  682. <!-- 获取当前物料所包含的库位 -->
  683. <select id="selectLocationByPartNo" resultType="com.xujie.sys.modules.part.vo.LocationInformationVo" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
  684. SELECT
  685. site,
  686. bu_no,
  687. location_id
  688. FROM part_location
  689. WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and location_id = #{locationId}
  690. </select>
  691. <!-- 新增物料库位 -->
  692. <insert id="addDefaultLocation" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
  693. insert into part_location (site, part_no, location_id, bu_no)
  694. values (#{site}, #{partNo}, #{locationId}, #{buNo})
  695. </insert>
  696. <!-- 删除物料库位 -->
  697. <delete id="deleteDefaultLocation" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
  698. delete from part_location
  699. where part_no = #{partNo} and site = #{site} and location_id = #{locationId} and bu_no = #{buNo}
  700. </delete>
  701. <!-- 删除代理商 -->
  702. <delete id="deleteAgentByPartNo" parameterType="PartInformationEntity">
  703. delete from part_agent
  704. where part_no = #{partNo} and site = #{site}
  705. </delete>
  706. <!-- 删除制造商商 -->
  707. <delete id="deleteManufacturerByPartNo" parameterType="PartInformationEntity">
  708. delete from part_manufacturer
  709. where part_no = #{partNo} and site = #{site}
  710. </delete>
  711. <!-- 删除代理商 -->
  712. <delete id="deleteLocationByPartNo" parameterType="PartInformationEntity">
  713. delete from part_location
  714. where part_no = #{partNo} and site = #{site} and bu_no = #{buNo}
  715. </delete>
  716. <!-- 获取当前物料所包含的库位 -->
  717. <select id="getFromPartLocation" resultType="com.xujie.sys.modules.part.vo.LocationInformationVo" parameterType="PartInformationEntity">
  718. SELECT
  719. site,
  720. bu_no,
  721. part_no,
  722. location_id
  723. FROM part_location
  724. WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo}
  725. </select>
  726. <!-- 新增项目物料 -->
  727. <insert id="saveProjectPart" parameterType="PartInformationEntity">
  728. insert into plm_project_part
  729. (site, project_id, test_part_no, base_no, rev_no, part_no_source)
  730. values
  731. (#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource})
  732. </insert>
  733. <!-- 修改项目物料finalPart -->
  734. <update id="updateProjectFinalPart" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
  735. UPDATE plm_project_part
  736. SET final_part_no = #{ifsPartNo},
  737. update_date = getDate(),
  738. update_by = #{updateBy}
  739. WHERE site = #{site} and test_part_no = #{partNo}
  740. </update>
  741. <!-- 新增项目物料 -->
  742. <insert id="saveCustomerPartInfo" parameterType="PartInformationEntity">
  743. insert into plm_customer_part_info
  744. (site, customer_no, part_no, customer_part_no, create_date, create_by)
  745. values
  746. (#{site}, #{customerNo}, #{partNo}, #{customerPartNo}, getDate(), #{createBy})
  747. </insert>
  748. <!-- 新增项目物料 -->
  749. <insert id="addProjectPart">
  750. insert into plm_project_part
  751. (site, project_id, test_part_no, create_date, create_by, part_no_source) VALUES
  752. <foreach collection="list" item="item" index="index" separator=",">
  753. (#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource})
  754. </foreach>
  755. </insert>
  756. <!-- 新增项目物料 -->
  757. <insert id="addCustomerPartInfo">
  758. insert into plm_customer_part_info
  759. (site, customer_no, part_no, customer_part_no, create_date, create_by) VALUES
  760. <foreach collection="list" item="item" index="index" separator=",">
  761. (#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
  762. </foreach>
  763. </insert>
  764. <!-- 查询Routing替代 -->
  765. <select id="queryRoutingAlternativeList" resultType="RoutingDetailEntity" parameterType="PartInformationEntity">
  766. SELECT
  767. a.site,
  768. a.part_no,
  769. a.routing_type,
  770. a.routing_revision,
  771. a.alternative_no,
  772. a.alternative_description,
  773. a.rout_template_id,
  774. a.plan_date,
  775. a.fixed_lead_time_day,
  776. a.fixed_lead_time_hour,
  777. a.variable_lead_time_day,
  778. a.variable_lead_time_hour,
  779. a.for_std_lot_by_day,
  780. a.for_lot_by_day,
  781. a.min_lot_qty,
  782. a.note_text,
  783. a.status,
  784. a.official_flag
  785. FROM plm_routing_detail as a
  786. LEFT JOIN plm_routing_header as b on a.site = b.site and a.part_no = b.part_no and a.routing_revision = b.routing_revision and a.routing_type = b.routing_type
  787. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = 'Manufacturing' and b.phase_out_date is null
  788. </select>
  789. <!-- 根据物料编码删除 BOM Header -->
  790. <delete id="deleteBomHeaderByPartNo" parameterType="PartInformationEntity">
  791. delete from plm_bom_header
  792. where site = #{site} and part_no = #{partNo}
  793. </delete>
  794. <!-- 根据物料编码删除 BOM Detail -->
  795. <delete id="deleteBomDetailByPartNo" parameterType="PartInformationEntity">
  796. delete from plm_bom_detail
  797. where site = #{site} and part_no = #{partNo}
  798. </delete>
  799. <!-- 根据物料编码删除 BOM Component -->
  800. <delete id="deleteBomComponentByPartNo" parameterType="PartInformationEntity">
  801. delete from plm_bom_component
  802. where site = #{site} and part_no = #{partNo}
  803. </delete>
  804. <!-- 根据物料编码删除 BOM 副产品成本分配 -->
  805. <delete id="deleteBomManufStructCostDistribByPartNo" parameterType="PartInformationEntity">
  806. delete from plm_bom_manuf_struct_cost_distrib
  807. where site = #{site} and part_no = #{partNo}
  808. </delete>
  809. <!-- 根据物料编码删除 Routing Header -->
  810. <delete id="deleteRoutingHeaderByPartNo" parameterType="PartInformationEntity">
  811. delete from plm_routing_header
  812. where site = #{site} and part_no = #{partNo}
  813. </delete>
  814. <!-- 根据物料编码删除 Routing Detail -->
  815. <delete id="deleteRoutingDetailByPartNo" parameterType="PartInformationEntity">
  816. delete from plm_routing_detail
  817. where site = #{site} and part_no = #{partNo}
  818. </delete>
  819. <!-- 根据物料编码删除 Routing Component -->
  820. <delete id="deleteRoutingComponentByPartNo" parameterType="PartInformationEntity">
  821. delete from plm_routing_component
  822. where site = #{site} and part_no = #{partNo}
  823. </delete>
  824. <!-- 根据物料编码删除 Routing Tool -->
  825. <delete id="deleteRoutingToolByPartNo" parameterType="PartInformationEntity">
  826. delete from routing_tool
  827. where site = #{site} and part_no = #{partNo}
  828. </delete>
  829. <!-- 根据物料编码删除 Routing GuideLine -->
  830. <delete id="deleteRoutingGuideLineByPartNo" parameterType="PartInformationEntity">
  831. delete from plm_routing_work_guide
  832. where site = #{site} and part_no = #{partNo}
  833. </delete>
  834. <delete id="deletePartItemByPart"
  835. parameterType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  836. delete from part_sub_properties_value
  837. where site = #{site} and part_no = #{partNo} and code_no = #{codeNo} and record_type = 'IP' and bu_no = #{buNo}
  838. </delete>
  839. <delete id="deletePartItems" parameterType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  840. delete from part_sub_properties_value
  841. where site = #{site} and part_no = #{partNo} and code_no = #{codeNo} and record_type = 'IP' and bu_no = #{buNo}
  842. </delete>
  843. <!-- 新增物料制造商 -->
  844. <insert id="savePartDefaultLocation">
  845. insert into part_location
  846. (site, part_no, location_id, bu_no) VALUES
  847. <foreach collection="list" item="item" index="index" separator=",">
  848. (#{item.site}, #{item.partNo}, #{item.locationId}, #{item.buNo})
  849. </foreach>
  850. </insert>
  851. <!-- 下一个物料编码 -->
  852. <select id="getNextPartNo2" resultType="string" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
  853. select dbo.get_next_part_code(#{site}, #{buNo}, #{queryType})
  854. </select>
  855. <select id="handleQueryPart" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
  856. select p.id,
  857. p.site,
  858. part_no,
  859. part_desc,
  860. umid2 as umId2,
  861. dbo.qc_get_um_name(p.site, umid2) as umName,
  862. sourceBu as buNo,
  863. dbo.get_bu_desc(p.site, sourceBu) as buDesc,
  864. part_type2,
  865. case
  866. when part_type2 = 'Manufactured' then '成品'
  867. when part_type2 = 'Manufactured Recipe' then '半成品'
  868. when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc
  869. from part p
  870. left join BU b on p.sourceBu = b.bu_no and p.site = b.site
  871. where
  872. p.site in (select site from eam_access_site where username = #{userName})
  873. and (p.site + '-' + sourceBu) in (select * from dbo.query_bu(#{userName}))
  874. and p.active = 'Y'
  875. <if test="buId != null">
  876. and b.id = #{buId}
  877. </if>
  878. <if test = "partNo != null and partNo != ''">
  879. AND part_no like #{partNo}
  880. </if>
  881. <if test = "partDesc != null and partDesc != ''">
  882. AND part_desc like #{partDesc}
  883. </if>
  884. </select>
  885. <select id="handleQueryPartByPage" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
  886. select p.id,
  887. p.site,
  888. part_no,
  889. part_desc,
  890. umid2 as umId2,
  891. dbo.qc_get_um_name(p.site, umid2) as umName,
  892. sourceBu as buNo,
  893. dbo.get_bu_desc(p.site, sourceBu) as buDesc,
  894. part_type2,
  895. case
  896. when part_type2 = 'Manufactured' then '成品'
  897. when part_type2 = 'Manufactured Recipe' then '半成品'
  898. when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc
  899. from part p
  900. left join BU b on p.sourceBu = b.bu_no and p.site = b.site
  901. where
  902. p.site in (select site from eam_access_site where username = #{params.userName})
  903. and (p.site + '-' + sourceBu) in (select * from dbo.query_bu(#{params.userName}))
  904. and p.active = 'Y'
  905. <if test="params.buId != null">
  906. and b.id = #{params.buId}
  907. </if>
  908. <if test = "params.partNo != null and params.partNo != ''">
  909. AND part_no like #{params.partNo}
  910. </if>
  911. <if test = "params.partDesc != null and params.partDesc != ''">
  912. AND part_desc like #{params.partDesc}
  913. </if>
  914. </select>
  915. <!-- 查routing子明细 -->
  916. <select id="getRoutingOperationId" resultType="RoutingComponentEntity">
  917. SELECT
  918. site,
  919. bu_no,
  920. part_no,
  921. routing_type,
  922. routing_revision,
  923. alternative_no,
  924. operation_id,
  925. operation_no,
  926. operation_name
  927. FROM plm_routing_component
  928. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_no = #{operationNo}
  929. </select>
  930. <select id="getTblBaseData" parameterType="TblBaseData" resultType="TblBaseData">
  931. SELECT
  932. id,
  933. site,
  934. type,
  935. base_data,
  936. base_desc,
  937. status,
  938. remark,
  939. third_type,
  940. second_type,
  941. page_control
  942. FROM tbl_base_data
  943. where site = #{site} and type = #{type} and third_type = #{thirdType} and second_type = #{secondType}
  944. </select>
  945. <insert id="saveTblBaseData" parameterType="TblBaseData">
  946. insert into tbl_base_data
  947. (site, type, base_data, base_desc, status, remark, third_type, second_type, page_control)
  948. values
  949. (#{site}, #{type}, #{baseData}, #{baseDesc}, #{status}, #{remark}, #{thirdType}, #{secondType}, #{pageControl})
  950. </insert>
  951. <update id="updateTblBaseData" parameterType="TblBaseData">
  952. UPDATE tbl_base_data
  953. SET base_data = #{baseData}
  954. WHERE site = #{site} and type = #{type} and third_type = #{thirdType} and second_type = #{secondType}
  955. </update>
  956. <insert id="savePartSubPropertiesValueByPartNo">
  957. insert into part_sub_properties_value
  958. (part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
  959. select
  960. #{partNo},
  961. site,
  962. bu_no,
  963. code_no,
  964. 1,
  965. sub_code_desc,
  966. item_no,
  967. properties_item_no,
  968. text_value,
  969. num_value,
  970. record_type
  971. from part_sub_properties_value
  972. where site = #{site} and bu_no = #{buNo} and part_no = #{basePartNo}
  973. </insert>
  974. <select id="getPreviousPartNo" parameterType="TblBaseData" resultType="string">
  975. SELECT
  976. base_data
  977. FROM tbl_base_data
  978. where site = #{site} and type = #{type} and third_type = #{thirdType} and second_type = #{secondType}
  979. </select>
  980. <!-- 新增材料属性值 -->
  981. <insert id="savePartModelDetails">
  982. insert into part_sub_properties_value
  983. (part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type) VALUES
  984. <foreach collection="list" item="item" index="index" separator=",">
  985. (#{item.partNo}, #{item.site}, #{item.buNo}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.itemNo,jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue,jdbcType=FLOAT}, #{item.recordType})
  986. </foreach>
  987. </insert>
  988. <insert id="saveTempPartModelDetails">
  989. insert into plm_copy_temp_item_value
  990. (part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type, tree_id, create_date, create_by) VALUES
  991. <foreach collection="list" item="item" index="index" separator=",">
  992. (#{item.partNo}, #{item.site}, #{item.buNo}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.itemNo,jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue,jdbcType=FLOAT}, #{item.recordType}, #{item.treeId,jdbcType=BIGINT}, getDate(), #{item.createBy})
  993. </foreach>
  994. </insert>
  995. <select id="getPartAgents" resultType="com.xujie.sys.modules.part.vo.AgentInformationVo" parameterType="PartInformationEntity">
  996. SELECT
  997. site,
  998. bu_no,
  999. part_no,
  1000. agent_id
  1001. FROM part_agent
  1002. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo}
  1003. </select>
  1004. <insert id="savePartAgent">
  1005. insert into part_agent
  1006. (site, bu_no, part_no, agent_id) VALUES
  1007. <foreach collection="list" item="item" index="index" separator=",">
  1008. (#{item.site}, #{item.buNo}, #{item.partNo}, #{item.agentId})
  1009. </foreach>
  1010. </insert>
  1011. <select id="getPartManufacturers" resultType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo" parameterType="PartInformationEntity">
  1012. SELECT
  1013. site,
  1014. bu_no,
  1015. part_no,
  1016. manufacturer_id
  1017. FROM part_manufacturer
  1018. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo}
  1019. </select>
  1020. <select id="partInfoByMainPart" resultType="com.xujie.sys.modules.part.entity.PartNodeVo"
  1021. parameterType="com.xujie.sys.modules.part.entity.PartNodeVo">
  1022. select
  1023. qbi.site,
  1024. qbi.part_no,
  1025. qbi.node_name,
  1026. qbi.node_id,
  1027. qbi.eng_chg_level,
  1028. qbi.routing_revision,
  1029. p.part_type2 as partType2,
  1030. p.sourceBu as buNo,
  1031. p.part_desc,
  1032. p.code_no,
  1033. pmh.code_desc,
  1034. p.umid2 as umId2,
  1035. um.UMName as umName,
  1036. p.remark,
  1037. p.FamilyID as familyID,
  1038. pf.family_name as familyName,
  1039. p.product_group_id1,
  1040. p.product_group_id2,
  1041. p.product_group_id3,
  1042. dbo.get_product_group_name(p.site, p.sourceBu, p.product_group_id1, '1') as productGroupName1,
  1043. dbo.get_product_group_name(p.site, p.sourceBu, p.product_group_id2, '2') as productGroupName2,
  1044. dbo.get_product_group_name(p.site, p.sourceBu, p.product_group_id3, '3') as productGroupName3,
  1045. p.template_no,
  1046. pbt.template_name
  1047. from plm_quickly_bom_Info as qbi
  1048. left join part as p on qbi.part_no = p.part_no and p.site = qbi.site
  1049. left join plm_properties_model_header as pmh on p.code_no = pmh.code_no and pmh.site = p.site and pmh.function_type = 'IP'
  1050. left join UM as um on p.site = um.site and p.umid2 = um.UMID
  1051. left join part_family as pf on p.site = pf.site and p.FamilyID = pf.family_id and p.sourceBu = pf.bu_no
  1052. left join plm_bom_template as pbt on p.site = pbt.site and p.template_no = pbt.template_no
  1053. where qbi.site = #{site} and qbi.main_part = #{partNo}
  1054. order by qbi.id
  1055. </select>
  1056. <select id="getCopyRowData" resultType="com.xujie.sys.modules.part.vo.PartInformationVo"
  1057. parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
  1058. SELECT
  1059. a.id,
  1060. a.site,
  1061. a.part_no,
  1062. a.part_desc,
  1063. a.umid2 as umId2,
  1064. um.UMName as umName,
  1065. a.sourceBu as buNo,
  1066. a.part_type2,
  1067. a.FamilyID as familyID,
  1068. a.code_no,
  1069. case when a.part_type2 = 'Manufactured' then '成品' when a.part_type2 = 'Manufactured Recipe' then '半成品' when a.part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
  1070. a.product_group_id1,
  1071. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id1, '1') as productGroupName1,
  1072. a.product_group_id2,
  1073. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id2, '2') as productGroupName2,
  1074. a.product_group_id3
  1075. FROM part as a
  1076. LEFT JOIN UM as um on a.site = um.site and a.umid2 = um.UMID
  1077. <where>
  1078. a.site = #{site}
  1079. <if test="partNo != null and partNo != ''">
  1080. and a.part_no like '%' + #{partNo} + '%'
  1081. </if>
  1082. <if test="partDesc != null and partDesc !=''">
  1083. and a.part_desc like '%' + #{partDesc} + '%'
  1084. </if>
  1085. </where>
  1086. </select>
  1087. <insert id="savePartManufacturer">
  1088. insert into part_manufacturer
  1089. (site, bu_no, part_no, manufacturer_id) VALUES
  1090. <foreach collection="list" item="item" index="index" separator=",">
  1091. (#{item.site}, #{item.buNo}, #{item.partNo}, #{item.manufacturerId})
  1092. </foreach>
  1093. </insert>
  1094. <insert id="addPartItems">
  1095. insert into part_sub_properties_value
  1096. (part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type) values
  1097. <foreach collection="list" item="item" separator=",">
  1098. (#{item.partNo}, #{item.site}, #{item.buNo}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.codeDesc}, #{item.itemNo, jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue, jdbcType=FLOAT}, #{item.recordType})
  1099. </foreach>
  1100. </insert>
  1101. <update id="savePartHSCode">
  1102. update Part set hsCode=#{hsCode},hsCodeDesc=#{hsCodeDesc},packageNo=#{packageNo}
  1103. where site = #{site} and part_no = #{partNo}
  1104. </update>
  1105. <update id="batchUpdateCodeNo">
  1106. update part set
  1107. code_no = case
  1108. <foreach collection="list" item="item">
  1109. when site = #{item.site} and part_no = #{item.partNo} then #{item.codeNo}
  1110. </foreach>
  1111. end
  1112. where
  1113. <foreach collection="list" item="item" separator=" or ">
  1114. (site = #{item.site} and part_no = #{item.partNo})
  1115. </foreach>
  1116. </update>
  1117. <update id="updateFamilyId" parameterType="com.xujie.sys.modules.part.entity.BomComponentEntity">
  1118. update part set
  1119. FamilyID = #{familyID}
  1120. where site = #{site} and part_no = #{componentPart}
  1121. </update>
  1122. <!-- 更新物料单位 -->
  1123. <update id="updatePrintUnit" parameterType="com.xujie.sys.modules.part.entity.BomComponentEntity">
  1124. update part set
  1125. umid2 = #{printUnit}
  1126. where site = #{site} and part_no = #{componentPart}
  1127. </update>
  1128. </mapper>