O
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.

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