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.

1023 lines
42 KiB

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