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.

2695 lines
107 KiB

2 years ago
2 years ago
10 months ago
9 months ago
1 year ago
1 year 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
2 years ago
2 years ago
10 months ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
9 months ago
1 year ago
1 year ago
8 months ago
1 year ago
9 months ago
9 months ago
9 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
12 months ago
1 year ago
2 years ago
1 year ago
12 months ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year 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
11 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
10 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.spring.modules.part.mapper.PartInformationMapper">
  4. <!-- 材料信息列表 -->
  5. <select id="partInformationSearch" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.vo.PartInformationVo">
  6. SELECT
  7. site,
  8. part_no,
  9. part_desc,
  10. spec,
  11. part_type_db,
  12. part_type,
  13. family_id,
  14. dbo.get_family_name(site, family_id) as familyName,
  15. group_id,
  16. dbo.get_group_name(site, group_id) as groupName,
  17. um_id,
  18. dbo.get_um_name(um_id) as umName,
  19. weight_net,
  20. uom_for_weight_net,
  21. volume_net,
  22. uom_for_volume_net,
  23. lot_tracking_code,
  24. active,
  25. case when active = 'Y' then '启用' when active = 'N' then '停用' else '' end as activeDesc,
  26. product_group_id1,
  27. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  28. product_group_id2,
  29. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  30. product_group_id3,
  31. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  32. product_group_id4,
  33. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  34. comm_group3,
  35. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  36. erp_part_no,
  37. code_no,
  38. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  39. manufacturer_id,
  40. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  41. agent_id,
  42. dbo.split_agent_id(site, agent_id) as agentName,
  43. type_designation,
  44. hazard_code,
  45. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  46. asset_class,
  47. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  48. dim_quality,
  49. abc_class,
  50. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  51. frequency_class,
  52. lifecycle_stage,
  53. country_of_origin,
  54. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  55. manufacturing_lead_time,
  56. expected_lead_time,
  57. region_of_origin,
  58. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  59. customs_stat_no,
  60. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  61. durability_day,
  62. intrastat_conv_factor,
  63. supply_code,
  64. part_status,
  65. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  66. configuration_id,
  67. estimated_material_cost,
  68. inventory_valuation_method,
  69. part_cost_group_id,
  70. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  71. inventory_part_cost_level,
  72. invoice_consideration,
  73. zero_cost_flag,
  74. planning_method,
  75. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  76. safety_stock,
  77. min_order_qty,
  78. max_order_qty,
  79. mul_order_qty,
  80. safety_lead_time,
  81. shrinkage_fac,
  82. std_order_qty,
  83. cum_lead_time,
  84. back_flush_part,
  85. by_prod_as_supply_in_mrp_db,
  86. unprotected_lead_time,
  87. issue_type,
  88. mrp_control_flag_db,
  89. fixed_lead_time_day,
  90. over_reporting,
  91. use_theoretical_density_db,
  92. variable_lead_time_day,
  93. over_report_tolerance,
  94. fixed_lead_time_hour,
  95. density,
  96. variable_lead_time_hour,
  97. remark,
  98. status,
  99. create_date,
  100. create_by,
  101. update_date,
  102. update_by,
  103. plm_part_no,
  104. ifs_part_no,
  105. show_in_query_flag,
  106. temporary_part_flag,
  107. dbo.get_ifHas_peifang(site,part_no) as ifHasPeifang,
  108. dbo.get_ifHas_BOM(site,part_no) as ifHasBom,
  109. case when status = 'Y' then '正式物料' else '临时物料' end as statusDesc
  110. FROM part
  111. <where>
  112. site = #{query.site}
  113. AND show_in_query_flag = 'Y'
  114. <if test = "query.active != null and query.active != ''">
  115. AND active = #{query.active}
  116. </if>
  117. <if test = "query.partNo != null and query.partNo != ''">
  118. AND part_no like #{query.partNo}
  119. </if>
  120. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  121. AND ifs_part_no like #{query.ifsPartNo}
  122. </if>
  123. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  124. AND plm_part_no like #{query.plmPartNo}
  125. </if>
  126. <if test = "query.partDesc != null and query.partDesc != ''">
  127. AND part_desc like #{query.partDesc}
  128. </if>
  129. <if test = "query.spec != null and query.spec != ''">
  130. AND spec like #{query.spec}
  131. </if>
  132. <if test="query.startDate != null ">
  133. AND create_date >= #{query.startDate}
  134. </if>
  135. <if test="query.endDate != null ">
  136. AND #{query.endDate} >= create_date
  137. </if>
  138. <if test = 'query.status != null and query.status != "" and query.status == "Y"'>
  139. AND status = 'Y'
  140. </if>
  141. <if test = 'query.status != null and query.status != "" and query.status == "N"'>
  142. AND status <![CDATA[<>]]> 'Y'
  143. </if>
  144. <if test = "query.partType != null and query.partType != ''">
  145. AND part_type = #{query.partType}
  146. </if>
  147. </where>
  148. </select>
  149. <!-- 检查材料属性 -->
  150. <select id="checkValueHeaderData" resultType="PartSubPropertiesValueHeaderData">
  151. SELECT
  152. PartNo,
  153. Site,
  154. CodeNo,
  155. SubCodeSeqNo,
  156. SubCodeDesc,
  157. RecordType
  158. from PartSubPropertiesValueHeader
  159. where PartNo = #{partNo} and site = #{site} and CodeNo = #{codeNo} and RecordType = #{recordType}
  160. </select>
  161. <!-- 删除材料属性 -->
  162. <delete id="deletePartSubPropertiesValueHeader">
  163. delete from PartSubPropertiesValueHeader
  164. where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType}
  165. </delete>
  166. <!-- 删除材料属性值 -->
  167. <delete id="deletePartSubPropertiesValue">
  168. delete from PartSubPropertiesValue
  169. where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType}
  170. </delete>
  171. <!-- 新增材料属性 -->
  172. <insert id="savePartSubPropertiesValueHeader">
  173. insert into PartSubPropertiesValueHeader
  174. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
  175. select
  176. #{partNo},
  177. #{site},
  178. #{codeNo},
  179. 1,
  180. Code_Desc,
  181. #{recordType}
  182. from plm_properties_model_header
  183. where Code_No = #{codeNo} and site = #{site} and function_type = #{recordType}
  184. </insert>
  185. <!-- 新增材料属性值 -->
  186. <insert id="savePartSubPropertiesValue">
  187. insert into PartSubPropertiesValue (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
  188. select
  189. #{partNo},
  190. #{site},
  191. #{codeNo},
  192. 1,
  193. a.Code_Desc,
  194. b.seq_No,
  195. b.properties_item_no,
  196. case when c.ValueType_DB = 'T' then c.DefaultValue else null end,
  197. case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end,
  198. #{recordType}
  199. from plm_properties_model_header a
  200. left join plm_properties_model_detail b on a.Code_No = b.Code_No and a.site = b.site and a.function_type = b.function_type
  201. left join plm_properties_item c on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
  202. where a.Code_No = #{codeNo} and a.site = #{site} AND B.SITE IS NOT NULL AND A.function_type = #{recordType}
  203. </insert>
  204. <select id="getItemModal" resultType="PartSubPropertiesValueData">
  205. SELECT
  206. a.PartNo,
  207. a.Site,
  208. a.CodeNo,
  209. a.SubCodeSeqNo,
  210. a.SubCodeDesc,
  211. a.ItemNo,
  212. a.PropertiesItemNo,
  213. a.TextValue,
  214. a.NumValue,
  215. a.RecordType,
  216. b.ItemDesc as ItemDesc,
  217. b.ValueType,
  218. b.ValueType_DB,
  219. b.ValueChooseFlag
  220. FROM PartSubPropertiesValue as a
  221. left join plm_properties_item as b on a.PropertiesItemNo = b.ItemNo and a.site = b.site and a.RecordType = b.ItemType
  222. where a.site = #{site} and RecordType = #{recordType} and a.PartNo = #{partNo,jdbcType=VARCHAR}
  223. </select>
  224. <!-- 获取属性可选值 -->
  225. <select id="getAvailableValueList" resultType="PlmPropertiesItemAvailableData">
  226. select
  227. ItemNo,
  228. ValueNo,
  229. AvailableValue
  230. from plm_properties_item_available
  231. where itemNo = #{propertiesItemNo} and site = #{site} and ItemType = #{recordType}
  232. </select>
  233. <!--工具专用的方法-->
  234. <select id="getAvailableValueListForTool" resultType="PlmPropertiesItemAvailableData">
  235. select ItemNo, ValueNo, AvailableValue
  236. from plm_properties_item_available
  237. where itemNo = #{propertiesItemNo}
  238. and site = '*'
  239. and ItemType = #{recordType}
  240. </select>
  241. <!-- 编辑属性值 -->
  242. <update id="savePartItemValue" >
  243. update PartSubPropertiesValue
  244. set TextValue = #{textValue},
  245. NumValue = #{numValue, jdbcType=DOUBLE}
  246. where PropertiesItemNo = #{propertiesItemNo} and site = #{site} and PartNo = #{partNo} and RecordType = #{recordType}
  247. </update>
  248. <!-- 查询代理商列表 -->
  249. <select id="getAgentList" resultType="AgentInformationEntity" parameterType="AgentInformationEntity">
  250. SELECT
  251. site,
  252. agent_id,
  253. agent_name
  254. FROM agent
  255. <where>
  256. site = #{site}
  257. <if test = "agentId != null and agentId != ''">
  258. AND agent_id LIKE #{agentId}
  259. </if>
  260. <if test = "agentName != null and agentName != ''">
  261. AND agent_name LIKE #{deptName}
  262. </if>
  263. </where>
  264. </select>
  265. <!-- 查询代理商列表 -->
  266. <select id="getPartAgent" resultType="com.spring.modules.part.vo.AgentInformationVo" parameterType="com.spring.modules.part.vo.AgentInformationVo">
  267. SELECT
  268. a.site,
  269. a.part_no,
  270. a.agent_id,
  271. b.agent_name,
  272. b.active,
  273. case when b.active = 'Y' then '启用' when b.active = 'N' then '停用' else '' end as activeDesc,
  274. b.create_date,
  275. b.create_by,
  276. b.update_date,
  277. b.update_by
  278. FROM part_agent as a
  279. left join agent as b on a.site = b.site and a.agent_id = b.agent_id
  280. where a.site = #{site} and a.part_no = #{partNo}
  281. </select>
  282. <!-- 获取当前物料不包含的代理商 -->
  283. <select id="getAgentList1" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
  284. SELECT
  285. a.site,
  286. a.agent_id,
  287. a.agent_name,
  288. a.active,
  289. a.create_date,
  290. a.create_by,
  291. a.update_date,
  292. a.update_by
  293. FROM agent as a
  294. left join part_agent as b on a.site = b.site and a.agent_id = b.agent_id and b.part_no = #{partNo}
  295. where a.site = #{site} and b.part_no is null
  296. </select>
  297. <!-- 获取当前物料所包含的代理商 -->
  298. <select id="getAgentList2" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
  299. SELECT
  300. a.site,
  301. a.agent_id,
  302. b.agent_name,
  303. b.active,
  304. b.create_date,
  305. b.create_by,
  306. b.update_date,
  307. b.update_by
  308. FROM part_agent a
  309. LEFT JOIN agent b ON a.agent_id = b.agent_id and a.site = b.site
  310. WHERE a.part_no = #{partNo} and a.site = #{site}
  311. </select>
  312. <!-- 获取当前物料所包含的代理商 -->
  313. <select id="selectAgentByPartNo" resultType="com.spring.modules.part.vo.AgentInformationVo" parameterType="com.spring.modules.part.vo.AgentInformationVo">
  314. SELECT
  315. site,
  316. agent_id
  317. FROM part_agent
  318. WHERE part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
  319. </select>
  320. <!-- 新增物料代理商 -->
  321. <insert id="addPartAgent" parameterType="com.spring.modules.part.vo.AgentInformationVo">
  322. insert into part_agent (site, part_no, agent_id)
  323. values (#{site}, #{partNo}, #{agentId})
  324. </insert>
  325. <!-- 删除物料代理商 -->
  326. <delete id="deletePartAgent" parameterType="com.spring.modules.part.vo.AgentInformationVo">
  327. delete from part_agent
  328. where part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
  329. </delete>
  330. <!-- 获取当前物料不包含的代理商 -->
  331. <select id="getAgentListBy" resultType="AgentInformationEntity" parameterType="com.spring.modules.part.vo.AgentInformationVo">
  332. SELECT
  333. a.site,
  334. a.agent_id,
  335. a.agent_name,
  336. a.active,
  337. a.create_date,
  338. a.create_by,
  339. a.update_date,
  340. a.update_by
  341. FROM agent as a
  342. left join part_agent as b on a.site = b.site and a.agent_id = b.agent_id and b.part_no = #{partNo}
  343. <where>
  344. a.site = #{site} and b.part_no is null
  345. <if test = "agentId != null and agentId != ''">
  346. AND a.agent_id LIKE #{agentId}
  347. </if>
  348. <if test = "agentName != null and agentName != ''">
  349. AND a.agent_name LIKE #{agentName}
  350. </if>
  351. </where>
  352. </select>
  353. <!-- 删除物料代理商 -->
  354. <delete id="deleteAgent" parameterType="com.spring.modules.part.vo.AgentInformationVo">
  355. delete from part_agent
  356. where part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
  357. </delete>
  358. <!-- 查询制造商列表 -->
  359. <select id="getManufacturerList" resultType="ManufacturerInformationEntity" parameterType="ManufacturerInformationEntity">
  360. SELECT
  361. site,
  362. manufacturer_id,
  363. manufacturer_name
  364. FROM manufacturer
  365. <where>
  366. site = #{site}
  367. <if test = "manufacturerId != null and manufacturerId != ''">
  368. AND manufacturer_id LIKE #{manufacturerId}
  369. </if>
  370. <if test = "manufacturerName != null and manufacturerName != ''">
  371. AND manufacturer_name LIKE #{manufacturerName}
  372. </if>
  373. </where>
  374. </select>
  375. <!-- 查询制造商列表 -->
  376. <select id="getPartManufacturer" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
  377. SELECT
  378. a.site,
  379. a.part_no,
  380. a.manufacturer_id,
  381. b.manufacturer_name,
  382. b.active,
  383. case when b.active = 'Y' then '启用' when b.active = 'N' then '停用' else '' end as activeDesc,
  384. b.create_date,
  385. b.create_by,
  386. b.update_date,
  387. b.update_by
  388. FROM part_manufacturer as a
  389. left join manufacturer as b on a.site = b.site and a.manufacturer_id = b.manufacturer_id
  390. where a.site = #{site} and a.part_no = #{partNo}
  391. </select>
  392. <!-- 获取当前物料不包含的制造商 -->
  393. <select id="getManufacturerList1" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
  394. SELECT
  395. a.site,
  396. a.manufacturer_id,
  397. a.manufacturer_name,
  398. a.active,
  399. a.create_date,
  400. a.create_by,
  401. a.update_date,
  402. a.update_by
  403. FROM manufacturer as a
  404. left join part_manufacturer as b on a.site = b.site and a.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
  405. where a.site = #{site} and b.part_no is null
  406. </select>
  407. <!-- 获取当前物料所包含的制造商 -->
  408. <select id="getManufacturerList2" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
  409. SELECT
  410. a.site,
  411. a.manufacturer_id,
  412. b.manufacturer_name,
  413. b.active,
  414. b.create_date,
  415. b.create_by,
  416. b.update_date,
  417. b.update_by
  418. FROM part_manufacturer a
  419. LEFT JOIN manufacturer b ON a.manufacturer_id = b.manufacturer_id and a.site = b.site
  420. WHERE a.part_no = #{partNo} and a.site = #{site}
  421. </select>
  422. <!-- 获取当前物料所包含的制造商 -->
  423. <select id="selectManufacturerByPartNo" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
  424. SELECT
  425. site,
  426. manufacturer_id
  427. FROM part_manufacturer
  428. WHERE part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
  429. </select>
  430. <!-- 新增物料制造商 -->
  431. <insert id="addPartManufacturer" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
  432. insert into part_manufacturer (site, part_no, manufacturer_id)
  433. values (#{site}, #{partNo}, #{manufacturerId})
  434. </insert>
  435. <!-- 删除物料制造商 -->
  436. <delete id="deletePartManufacturer" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
  437. delete from part_manufacturer
  438. where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
  439. </delete>
  440. <!-- 删除物料制造商 -->
  441. <delete id="deleteManufacturer">
  442. delete from part_manufacturer
  443. where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
  444. </delete>
  445. <!-- 获取当前物料不包含的制造商 -->
  446. <select id="getManufacturerListBy" resultType="ManufacturerInformationEntity" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
  447. SELECT
  448. a.site,
  449. a.manufacturer_id,
  450. a.manufacturer_name,
  451. a.active,
  452. a.create_date,
  453. a.create_by,
  454. a.update_date,
  455. a.update_by
  456. FROM manufacturer as a
  457. left join part_manufacturer as b on a.site = b.site and a.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
  458. <where>
  459. a.site = #{site} and b.part_no is null
  460. <if test = "manufacturerId != null and manufacturerId != ''">
  461. AND a.manufacturer_id LIKE #{manufacturerId}
  462. </if>
  463. <if test = "manufacturerName != null and manufacturerName != ''">
  464. AND a.manufacturer_name LIKE #{manufacturerName}
  465. </if>
  466. </where>
  467. </select>
  468. <update id="commitItemValue" parameterType="PartSubPropertiesValueData">
  469. UPDATE PartSubPropertiesValue
  470. SET TextValue = #{textValue},
  471. NumValue = #{numValue,jdbcType=DECIMAL}
  472. WHERE PartNo = #{partNo} and Site = #{site} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo} and RecordType = #{recordType}
  473. </update>
  474. <!-- 删除属性值 -->
  475. <delete id="deleteItem" parameterType="PartSubPropertiesValueData">
  476. delete from PartSubPropertiesValue
  477. where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo}
  478. </delete>
  479. <select id="getItemLists" resultType="PlmPropertiesItemData" parameterType="PartSubPropertiesValueData">
  480. SELECT
  481. a.itemNo as itNo,
  482. a.ItemDesc,
  483. a.ValueType_DB as valueTypeDb
  484. FROM plm_properties_item a
  485. LEFT JOIN PartSubPropertiesValue b on b.recordType = #{recordType} and b.codeNo = #{codeNo} and b.PartNo = #{partNo} and b.PropertiesItemNo = a.ItemNo and a.site = b.site
  486. <where>
  487. a.ItemType = #{recordType}
  488. and a.site = #{site}
  489. AND b.codeNo is null
  490. <if test = "propertiesItemNo != null and propertiesItemNo != ''">
  491. AND a.ItemNo LIKE #{propertiesItemNo}
  492. </if>
  493. <if test = "itemDesc != null and itemDesc != ''">
  494. AND a.ItemDesc LIKE #{itemDesc}
  495. </if>
  496. </where>
  497. </select>
  498. <select id="getModelItemLists" resultType="PlmPropertiesItemData" parameterType="PartSubPropertiesValueData">
  499. select
  500. a.PropertiesItemNo as itNo,
  501. b.ItemDesc,
  502. a.ItemNo,
  503. a.PartNo,
  504. a.Site,
  505. a.CodeNo,
  506. a.SubCodeSeqNo,
  507. a.recordType,
  508. b.ValueType_DB as valueTypeDb
  509. from PartSubPropertiesValue a
  510. left join plm_properties_item b on a.PropertiesItemNo = b.ItemNo and a.recordType = b.ItemType and a.site = b.site
  511. where a.codeNo = #{codeNo} and a.recordType = #{recordType} and a.site = #{site} and a.PartNo = #{partNo}
  512. </select>
  513. <select id="checkPartItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
  514. select
  515. site,
  516. PartNo,
  517. CodeNo,
  518. SubCodeSeqNo,
  519. itemNo,
  520. PropertiesItemNo,
  521. RecordType
  522. from PartSubPropertiesValue
  523. where codeNo = #{codeNo} and recordType = #{recordType} and site = #{site} and PartNo = #{partNo} and PropertiesItemNo = #{itNo}
  524. </select>
  525. <select id="checkItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
  526. SELECT
  527. ItemDesc
  528. FROM plm_properties_item
  529. where itemType = #{recordType} and itemNo = #{itNo} and site = #{site}
  530. </select>
  531. <select id="getModalDetailSeqNo" resultType="double" parameterType="PartSubPropertiesValueData">
  532. SELECT
  533. isnull(max(itemNo),0) + 1
  534. from PartSubPropertiesValue
  535. where RecordType = #{recordType} and CodeNo = #{codeNo} and site = #{site} and PartNo = #{partNo} and SubCodeSeqNo = #{subCodeSeqNo}
  536. </select>
  537. <insert id="addPartItem" parameterType="PartSubPropertiesValueData">
  538. insert into PartSubPropertiesValue
  539. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
  540. values (#{partNo}, #{site}, #{codeNo}, #{subCodeSeqNo,jdbcType=FLOAT}, #{codeDesc}, #{itemNo, jdbcType=FLOAT}, #{itNo}, #{textValue}, #{numValue, jdbcType=FLOAT}, #{recordType})
  541. </insert>
  542. <delete id="deletePartItem" parameterType="PartSubPropertiesValueData">
  543. delete from PartSubPropertiesValue
  544. where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo}
  545. </delete>
  546. <select id="queryCodeNo" parameterType="com.spring.modules.part.vo.MasterPartInformationVo" resultType="PartSubPropertiesValueData">
  547. SELECT
  548. PartNo,
  549. Site,
  550. CodeNo,
  551. SubCodeSeqNo,
  552. SubCodeDesc,
  553. RecordType
  554. FROM PartSubPropertiesValueHeader
  555. where PartNo = #{partNo} and Site = #{site} and SubCodeSeqNo = 1 and RecordType = 'IP'
  556. </select>
  557. <!-- 获取当前物料不包含的库位 -->
  558. <select id="getLocationList1" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
  559. SELECT
  560. a.site,
  561. a.location_id,
  562. a.location_name,
  563. a.warehouse_id,
  564. a.active,
  565. a.create_date,
  566. a.create_by,
  567. a.update_date,
  568. a.update_by,
  569. a.location_type
  570. FROM location as a
  571. left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{query.partNo}
  572. where a.site = #{query.site} and b.part_no is null
  573. </select>
  574. <!-- 获取当前物料所包含的库位 -->
  575. <select id="getLocationList2" resultType="LocationInformationEntity" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  576. SELECT
  577. a.site,
  578. a.location_id,
  579. b.location_name,
  580. b.warehouse_id,
  581. b.active,
  582. b.create_date,
  583. b.create_by,
  584. b.update_date,
  585. b.update_by,
  586. b.location_type
  587. FROM plm_part_location a
  588. LEFT JOIN location b ON a.location_id = b.location_id and a.site = b.site
  589. WHERE a.part_no = #{partNo} and a.site = #{site}
  590. </select>
  591. <!-- 获取当前物料不包含的库位 -->
  592. <select id="getLocationListBy" resultType="LocationInformationEntity" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  593. SELECT
  594. a.site,
  595. a.location_id,
  596. a.location_name,
  597. a.warehouse_id,
  598. a.active,
  599. a.create_date,
  600. a.create_by,
  601. a.update_date,
  602. a.update_by,
  603. a.location_type
  604. FROM location as a
  605. left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{query.partNo}
  606. <where>
  607. a.site = #{query.site} and b.part_no is null
  608. <if test = "query.locationId != null and query.locationId != ''">
  609. AND a.location_id LIKE #{query.locationId}
  610. </if>
  611. <if test = "query.locationName != null and query.locationName != ''">
  612. AND a.location_name LIKE #{query.locationName}
  613. </if>
  614. </where>
  615. </select>
  616. <!-- 查询库位列表 -->
  617. <select id="getDefaultLocation" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  618. SELECT
  619. a.site,
  620. a.part_no,
  621. a.location_id,
  622. b.location_name,
  623. b.warehouse_id,
  624. b.active,
  625. case when b.active = 'Y' then '启用' when b.active = 'N' then '停用' else '' end as activeDesc,
  626. b.create_date,
  627. b.create_by,
  628. b.update_date,
  629. b.update_by,
  630. b.location_type
  631. FROM plm_part_location as a
  632. left join location as b on a.site = b.site and a.location_id = b.location_id
  633. where a.site = #{site} and a.part_no = #{partNo}
  634. </select>
  635. <!-- 获取当前物料所包含的库位 -->
  636. <select id="selectLocationByPartNo" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  637. SELECT
  638. site,
  639. location_id
  640. FROM plm_part_location
  641. WHERE part_no = #{partNo} and site = #{site} and location_id = #{locationId}
  642. </select>
  643. <!-- 新增物料库位 -->
  644. <insert id="addDefaultLocation" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  645. insert into plm_part_location (site, part_no, location_id)
  646. values (#{site}, #{partNo}, #{locationId})
  647. </insert>
  648. <!-- 删除物料库位 -->
  649. <delete id="deleteDefaultLocation" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  650. delete from plm_part_location
  651. where part_no = #{partNo} and site = #{site} and location_id = #{locationId}
  652. </delete>
  653. <!-- 删除代理商 -->
  654. <delete id="deleteAgentByPartNo" parameterType="PartInformationEntity">
  655. delete from part_agent
  656. where part_no = #{partNo} and site = #{site}
  657. </delete>
  658. <!-- 删除制造商商 -->
  659. <delete id="deleteManufacturerByPartNo" parameterType="PartInformationEntity">
  660. delete from part_manufacturer
  661. where part_no = #{partNo} and site = #{site}
  662. </delete>
  663. <!-- 删除代理商 -->
  664. <delete id="deleteLocationByPartNo" parameterType="PartInformationEntity">
  665. delete from plm_part_location
  666. where part_no = #{partNo} and site = #{site}
  667. </delete>
  668. <select id="partAllInfoSearch" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.vo.PartInformationVo">
  669. SELECT
  670. site,
  671. part_no,
  672. part_desc,
  673. spec,
  674. part_type_db,
  675. part_type,
  676. family_id,
  677. dbo.get_family_name(site, family_id) as familyName,
  678. group_id,
  679. dbo.get_group_name(site, group_id) as groupName,
  680. um_id,
  681. dbo.get_um_name(um_id) as umName,
  682. weight_net,
  683. uom_for_weight_net,
  684. volume_net,
  685. uom_for_volume_net,
  686. lot_tracking_code,
  687. active,
  688. remark,
  689. product_group_id1,
  690. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  691. product_group_id2,
  692. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  693. product_group_id3,
  694. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  695. product_group_id4,
  696. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  697. comm_group3,
  698. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  699. erp_part_no,
  700. code_no,
  701. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  702. manufacturer_id,
  703. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  704. agent_id,
  705. dbo.split_agent_id(site, agent_id) as agentName,
  706. type_designation,
  707. hazard_code,
  708. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  709. asset_class,
  710. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  711. dim_quality,
  712. abc_class,
  713. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  714. frequency_class,
  715. lifecycle_stage,
  716. country_of_origin,
  717. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  718. manufacturing_lead_time,
  719. expected_lead_time,
  720. region_of_origin,
  721. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  722. customs_stat_no,
  723. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  724. durability_day,
  725. intrastat_conv_factor,
  726. part_status,
  727. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  728. configuration_id,
  729. estimated_material_cost,
  730. inventory_valuation_method,
  731. part_cost_group_id,
  732. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  733. inventory_part_cost_level,
  734. invoice_consideration,
  735. zero_cost_flag,
  736. planning_method,
  737. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  738. safety_stock,
  739. min_order_qty,
  740. max_order_qty,
  741. mul_order_qty,
  742. safety_lead_time,
  743. shrinkage_fac,
  744. std_order_qty,
  745. cum_lead_time,
  746. back_flush_part,
  747. by_prod_as_supply_in_mrp_db,
  748. unprotected_lead_time,
  749. issue_type,
  750. mrp_control_flag_db,
  751. fixed_lead_time_day,
  752. over_reporting,
  753. use_theoretical_density_db,
  754. variable_lead_time_day,
  755. over_report_tolerance,
  756. fixed_lead_time_hour,
  757. density,
  758. variable_lead_time_hour,
  759. create_date,
  760. create_by,
  761. update_date,
  762. update_by,
  763. plm_part_no,
  764. ifs_part_no
  765. FROM part
  766. <where>
  767. site = #{query.site} and show_in_query_flag = 'Y'
  768. <if test = "query.partNo != null and query.partNo != ''">
  769. AND part_no like #{query.partNo}
  770. </if>
  771. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  772. AND plm_part_no like #{query.plmPartNo}
  773. </if>
  774. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  775. AND ifs_part_no like #{query.ifsPartNo}
  776. </if>
  777. <if test = "query.erpPartNo != null and query.erpPartNo != ''">
  778. AND erp_part_no like #{query.erpPartNo}
  779. </if>
  780. <if test = "query.partDesc != null and query.partDesc != ''">
  781. AND part_desc like #{query.partDesc}
  782. </if>
  783. <if test = "query.spec != null and query.spec != ''">
  784. AND spec like #{query.spec}
  785. </if>
  786. <if test="query.startDate != null ">
  787. AND required_completion_date >= #{query.startDate}
  788. </if>
  789. <if test="query.endDate != null ">
  790. AND #{query.endDate} >= required_completion_date
  791. </if>
  792. </where>
  793. </select>
  794. <!-- 根据物料编码查 masterPart 属性 -->
  795. <select id="queryMasterField" resultType="com.spring.modules.part.vo.MasterPartInformationVo" parameterType="PartInformationEntity">
  796. SELECT
  797. part_no,
  798. part_desc,
  799. weight_net,
  800. uom_for_weight_net,
  801. volume_net,
  802. uom_for_volume_net,
  803. um_id,
  804. dbo.get_um_name(um_id) as umName
  805. FROM part_catalog
  806. WHERE part_no = #{partNo}
  807. </select>
  808. <!-- 物料状态改为Y -->
  809. <update id="updatePartStatus" parameterType="PartInformationEntity">
  810. UPDATE part
  811. SET status = #{status},
  812. update_date = #{updateDate},
  813. update_by = #{updateBy}
  814. WHERE part_no = #{partNo} and Site = #{site}
  815. </update>
  816. <!-- 查询物料的revision列表 -->
  817. <select id="queryPartRevisionList" resultType="PartRevisionEntity" parameterType="PartRevisionEntity">
  818. SELECT
  819. site,
  820. part_no,
  821. eng_chg_level,
  822. eff_phase_in_date,
  823. eff_phase_out_date,
  824. revision_text,
  825. product_status,
  826. repair_status,
  827. eng_revision,
  828. create_date,
  829. create_by,
  830. update_date,
  831. update_by
  832. FROM part_revision
  833. WHERE site = #{site} and part_no = #{partNo}
  834. </select>
  835. <!-- 查询物料的revision列表 -->
  836. <select id="getPartRevisionList" resultType="PartIfsInventoryRevision" parameterType="PartInformationEntity">
  837. SELECT
  838. site as contract,
  839. part_no,
  840. eng_chg_level,
  841. eff_phase_in_date,
  842. eff_phase_out_date,
  843. revision_text,
  844. product_status,
  845. repair_status,
  846. eng_revision
  847. FROM part_revision
  848. WHERE site = #{site} and part_no = #{partNo}
  849. </select>
  850. <!-- 修改物料版本 -->
  851. <update id="updateRevision" parameterType="PartRevisionEntity">
  852. UPDATE part_revision
  853. SET eff_phase_in_date = #{effPhaseInDate},
  854. eff_phase_out_date = #{effPhaseOutDate},
  855. revision_text = #{revisionText},
  856. eng_revision = #{engRevision},
  857. update_date = getDate(),
  858. update_by = #{updateBy}
  859. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  860. </update>
  861. <!-- 获取当前物料所包含的库位 -->
  862. <select id="getPartLocationList" resultType="PartIfsInventoryLocation" parameterType="PartInformationEntity">
  863. SELECT
  864. a.site as contract,
  865. a.part_no,
  866. a.location_id as locationNo,
  867. b.location_type as locationType
  868. FROM plm_part_location as a
  869. left join location as b on a.site = b.site and a.location_id = b.location_id
  870. WHERE a.part_no = #{partNo} and a.site = #{site}
  871. </select>
  872. <!-- 获取物料的所有bomHeader -->
  873. <select id="getBomHeader" resultType="BomIfsHeader" parameterType="PartInformationEntity">
  874. SELECT
  875. site as contract,
  876. part_no,
  877. eng_chg_level,
  878. bom_type,
  879. eff_phase_in_date,
  880. eff_phase_out_date,
  881. note_text,
  882. create_date
  883. FROM plm_bom_header
  884. WHERE site = #{site} and part_no = #{partNo}
  885. </select>
  886. <!-- 获取header的所有detail -->
  887. <select id="getBomDetail" resultType="BomIfsAlternative" parameterType="BomIfsHeader">
  888. SELECT
  889. site as contract,
  890. part_no,
  891. eng_chg_level,
  892. bom_type,
  893. alternative_no,
  894. alternative_description as alternativeDesc,
  895. note_text
  896. FROM plm_bom_detail
  897. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  898. </select>
  899. <!-- 获取 detail 的所有 component -->
  900. <select id="getBomComponent" resultType="BomIfsItem" parameterType="BomIfsAlternative">
  901. SELECT
  902. site as contract,
  903. part_no,
  904. eng_chg_level,
  905. bom_type,
  906. alternative_no,
  907. line_item_no,
  908. line_sequence,
  909. component_part,
  910. qty_per_assembly,
  911. issue_type,
  912. component_scrap,
  913. shrinkage_factor
  914. FROM plm_bom_component
  915. WHERE site = #{contract} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  916. </select>
  917. <!-- 物料的bom状态改为Y -->
  918. <update id="updateBomOfficialFlag" parameterType="PartInformationEntity">
  919. UPDATE plm_bom_header
  920. SET official_flag = #{status}
  921. WHERE part_no = #{partNo} and Site = #{site}
  922. </update>
  923. <!-- 查询版本 -->
  924. <select id="queryRevision" resultType="PartRevisionEntity" parameterType="PartRevisionEntity">
  925. SELECT
  926. site,
  927. part_no,
  928. eng_chg_level,
  929. eff_phase_in_date,
  930. eff_phase_out_date,
  931. revision_text,
  932. product_status,
  933. repair_status,
  934. eng_revision,
  935. create_date,
  936. create_by,
  937. update_date,
  938. update_by
  939. FROM part_revision
  940. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  941. </select>
  942. <!-- 新增物料版本 -->
  943. <insert id="saveRevision" parameterType="PartRevisionEntity">
  944. insert into part_revision (site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by)
  945. values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{revisionText}, #{productStatus}, #{repairStatus}, #{engRevision}, getDate(), #{createBy})
  946. </insert>
  947. <!-- 修改当前物料版本的bom -->
  948. <update id="updateBomHeaderByRevision" parameterType="PartRevisionEntity">
  949. UPDATE plm_bom_header
  950. SET note_text = #{revisionText},
  951. eff_phase_in_date = #{effPhaseInDate},
  952. eff_phase_out_date = #{effPhaseOutDate},
  953. eng_revision = #{engRevision}
  954. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  955. </update>
  956. <!-- 查询版本 -->
  957. <select id="queryBomAlternative" resultType="BomDetailEntity" parameterType="PartRevisionEntity">
  958. SELECT
  959. site,
  960. part_no,
  961. alternative_no,
  962. alternative_description,
  963. bom_type,
  964. eng_chg_level,
  965. min_lot_qty,
  966. default_flag,
  967. note_text,
  968. create_date,
  969. create_by,
  970. update_date,
  971. update_by,
  972. status,
  973. official_flag
  974. FROM plm_bom_detail
  975. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  976. </select>
  977. <!-- 删除revision -->
  978. <delete id="deleteRevision" parameterType="PartRevisionEntity">
  979. delete from part_revision
  980. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  981. </delete>
  982. <!-- 删除该版本下的bomDetail -->
  983. <delete id="deleteBomDetail" parameterType="PartRevisionEntity">
  984. delete from plm_bom_detail
  985. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  986. </delete>
  987. <!-- 删除该版本下的bomComponent -->
  988. <delete id="deleteBomComponent" parameterType="PartRevisionEntity">
  989. delete from plm_bom_component
  990. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  991. </delete>
  992. <!-- 删除该版本下的recipeDetail -->
  993. <delete id="deleteRecipeDetail" parameterType="PartRevisionEntity">
  994. delete from plm_recipe_detail
  995. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  996. </delete>
  997. <!-- 删除该版本下的recipeComponent -->
  998. <delete id="deleteRecipeComponent" parameterType="PartRevisionEntity">
  999. delete from plm_recipe_component
  1000. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  1001. </delete>
  1002. <!-- 删除该版本下的副产品成本分配数据 -->
  1003. <delete id="deleteManufStruct" parameterType="PartRevisionEntity">
  1004. delete from plm_bom_manuf_struct_cost_distrib
  1005. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  1006. </delete>
  1007. <!-- 获取当前物料所包含的版本 -->
  1008. <select id="getFromPartRevision" resultType="PartRevisionEntity">
  1009. SELECT
  1010. #{toSite} as site,
  1011. #{toPartNo} as partNo,
  1012. eng_chg_level,
  1013. eff_phase_in_date,
  1014. eff_phase_out_date,
  1015. revision_text,
  1016. product_status,
  1017. repair_status,
  1018. eng_revision,
  1019. #{createBy} as createBy
  1020. FROM part_revision
  1021. WHERE part_no = #{partNo} and site = #{site} and eff_phase_out_date is null
  1022. order by eng_chg_level
  1023. </select>
  1024. <!-- 获取当前物料所包含的版本 -->
  1025. <select id="getFromPartRevision2" resultType="PartRevisionEntity">
  1026. SELECT
  1027. site,
  1028. #{ifsPartNo} as partNo,
  1029. eng_chg_level,
  1030. eff_phase_in_date,
  1031. eff_phase_out_date,
  1032. revision_text,
  1033. product_status,
  1034. repair_status,
  1035. eng_revision,
  1036. #{createBy} as createBy
  1037. FROM part_revision
  1038. WHERE part_no = #{partNo} and site = #{site}
  1039. </select>
  1040. <!-- 新增项目物料 -->
  1041. <insert id="saveProjectPart" parameterType="com.spring.modules.part.vo.PartInformationVo">
  1042. insert into plm_project_part
  1043. (site, project_id, test_part_no, base_no, rev_no, part_no_source, bu_no, virtual_part_no)
  1044. values
  1045. (#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource}, #{buNo}, #{virtualPartNo})
  1046. </insert>
  1047. <!-- 修改项目物料finalPart -->
  1048. <update id="updateProjectFinalPart" parameterType="com.spring.modules.part.vo.PartInformationVo">
  1049. UPDATE plm_project_part
  1050. SET final_part_no = #{ifsPartNo},
  1051. update_date = getDate(),
  1052. update_by = #{updateBy},
  1053. virtual_part_no = #{ifsPartNo}
  1054. WHERE site = #{site} and test_part_no = #{partNo}
  1055. </update>
  1056. <update id="updateProjectFinalPart2">
  1057. UPDATE plm_project_part
  1058. SET final_part_no = #{ifsPartNo},
  1059. update_date = getDate(),
  1060. update_by = #{createBy},
  1061. virtual_part_no = #{ifsPartNo}
  1062. WHERE site = #{site} and test_part_no = #{partNo}
  1063. </update>
  1064. <!-- 查询编码对象 -->
  1065. <select id="getTranNoData" resultType="TransNoControlData" parameterType="string">
  1066. SELECT
  1067. Site,
  1068. TransType,
  1069. NextNumber,
  1070. AutoAuthorize,
  1071. AutoTransfer,
  1072. TypeDesc,
  1073. Length,
  1074. TransNo
  1075. FROM TransNoControl
  1076. WHERE site = #{site} and TransType = #{projectPartNo}
  1077. </select>
  1078. <!-- 材料信息列表 -->
  1079. <select id="getProjectPartRow" resultType="com.spring.modules.part.vo.PartInformationVo">
  1080. SELECT top 1
  1081. site,
  1082. part_no,
  1083. part_desc,
  1084. spec,
  1085. part_type_db,
  1086. part_type,
  1087. family_id,
  1088. dbo.get_family_name(site, family_id) as familyName,
  1089. group_id,
  1090. dbo.get_group_name(site, group_id) as groupName,
  1091. um_id,
  1092. dbo.get_um_name(um_id) as umName,
  1093. weight_net,
  1094. uom_for_weight_net,
  1095. volume_net,
  1096. uom_for_volume_net,
  1097. lot_tracking_code,
  1098. active,
  1099. product_group_id1,
  1100. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  1101. product_group_id2,
  1102. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  1103. product_group_id3,
  1104. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  1105. product_group_id4,
  1106. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  1107. comm_group3,
  1108. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  1109. erp_part_no,
  1110. code_no,
  1111. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  1112. manufacturer_id,
  1113. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  1114. agent_id,
  1115. dbo.split_agent_id(site, agent_id) as agentName,
  1116. type_designation,
  1117. hazard_code,
  1118. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  1119. asset_class,
  1120. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  1121. dim_quality,
  1122. abc_class,
  1123. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  1124. frequency_class,
  1125. lifecycle_stage,
  1126. country_of_origin,
  1127. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  1128. manufacturing_lead_time,
  1129. expected_lead_time,
  1130. region_of_origin,
  1131. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  1132. customs_stat_no,
  1133. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  1134. durability_day,
  1135. intrastat_conv_factor,
  1136. part_status,
  1137. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  1138. configuration_id,
  1139. estimated_material_cost,
  1140. inventory_valuation_method,
  1141. part_cost_group_id,
  1142. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  1143. inventory_part_cost_level,
  1144. invoice_consideration,
  1145. zero_cost_flag,
  1146. planning_method,
  1147. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  1148. safety_stock,
  1149. min_order_qty,
  1150. max_order_qty,
  1151. mul_order_qty,
  1152. safety_lead_time,
  1153. shrinkage_fac,
  1154. std_order_qty,
  1155. cum_lead_time,
  1156. back_flush_part,
  1157. by_prod_as_supply_in_mrp_db,
  1158. unprotected_lead_time,
  1159. issue_type,
  1160. mrp_control_flag_db,
  1161. fixed_lead_time_day,
  1162. over_reporting,
  1163. use_theoretical_density_db,
  1164. variable_lead_time_day,
  1165. over_report_tolerance,
  1166. fixed_lead_time_hour,
  1167. density,
  1168. variable_lead_time_hour,
  1169. remark,
  1170. status,
  1171. create_date,
  1172. create_by,
  1173. update_date,
  1174. update_by
  1175. FROM part
  1176. where site = #{site} and part_no like #{partNo} + '%'
  1177. order by create_date desc
  1178. </select>
  1179. <!-- 材料信息列表 -->
  1180. <select id="getProjectPartRow2" parameterType="PlmProjectPartData" resultType="com.spring.modules.part.vo.PartInformationVo">
  1181. SELECT
  1182. a.site,
  1183. a.part_no,
  1184. a.part_desc,
  1185. a.spec,
  1186. a.part_type_db,
  1187. a.part_type,
  1188. a.family_id,
  1189. dbo.get_family_name(a.site, a.family_id) as familyName,
  1190. a.group_id,
  1191. dbo.get_group_name(a.site, a.group_id) as groupName,
  1192. a.um_id,
  1193. dbo.get_um_name(a.um_id) as umName,
  1194. a.weight_net,
  1195. a.uom_for_weight_net,
  1196. a.volume_net,
  1197. a.uom_for_volume_net,
  1198. a.lot_tracking_code,
  1199. a.active,
  1200. a.product_group_id1,
  1201. dbo.get_product_group_name(a.site, a.product_group_id1, '1') as productGroupName1,
  1202. a.product_group_id2,
  1203. dbo.get_product_group_name(a.site, a.product_group_id2, '2') as productGroupName2,
  1204. a.product_group_id3,
  1205. dbo.get_product_group_name(a.site, a.product_group_id3, '3') as productGroupName3,
  1206. a.product_group_id4,
  1207. dbo.get_product_group_name(a.site, a.product_group_id4, '4') as productGroupName4,
  1208. a.comm_group3,
  1209. dbo.get_product_group_name(a.site, a.comm_group3, '5') as commGroup3Desc,
  1210. a.erp_part_no,
  1211. a.code_no,
  1212. dbo.get_code_desc(a.site, a.code_no, 'IP') as codeDesc,
  1213. a.manufacturer_id,
  1214. dbo.get_manufacturer_name(a.site, a.manufacturer_id) as manufacturerName,
  1215. a.agent_id,
  1216. dbo.split_agent_id(a.site, a.agent_id) as agentName,
  1217. a.type_designation,
  1218. a.hazard_code,
  1219. dbo.get_hazard_name(a.site, a.hazard_code) as hazardDesc,
  1220. a.asset_class,
  1221. dbo.get_assetClass_name(a.site, a.asset_class) as assetClassDesc,
  1222. a.dim_quality,
  1223. a.abc_class,
  1224. dbo.get_abcClass_name(a.site, a.abc_class) as abcClassDesc,
  1225. a.frequency_class,
  1226. a.lifecycle_stage,
  1227. a.country_of_origin,
  1228. dbo.get_country_of_origin_name(a.site, a.country_of_origin) as countryOfOriginDesc,
  1229. a.manufacturing_lead_time,
  1230. a.expected_lead_time,
  1231. a.region_of_origin,
  1232. dbo.get_region_of_origin_name(a.site, a.region_of_origin) as regionOfOriginDesc,
  1233. a.customs_stat_no,
  1234. dbo.get_customs_stat_name(a.site, a.customs_stat_no) as customsStatDesc,
  1235. a.durability_day,
  1236. a.intrastat_conv_factor,
  1237. a.supply_code,
  1238. a.part_status,
  1239. dbo.get_part_status_name(a.site, a.part_status) as partStatusDesc,
  1240. a.configuration_id,
  1241. a.estimated_material_cost,
  1242. a.inventory_valuation_method,
  1243. a.part_cost_group_id,
  1244. dbo.get_part_cost_group_name(a.site, a.part_cost_group_id) as partCostGroupDesc,
  1245. a.inventory_part_cost_level,
  1246. a.invoice_consideration,
  1247. a.zero_cost_flag,
  1248. a.planning_method,
  1249. dbo.get_planning_method_name(a.site, a.planning_method) as planningMethodDesc,
  1250. a.safety_stock,
  1251. a.min_order_qty,
  1252. a.max_order_qty,
  1253. a.mul_order_qty,
  1254. a.safety_lead_time,
  1255. a.shrinkage_fac,
  1256. a.std_order_qty,
  1257. a.cum_lead_time,
  1258. a.back_flush_part,
  1259. a.by_prod_as_supply_in_mrp_db,
  1260. a.unprotected_lead_time,
  1261. a.issue_type,
  1262. a.mrp_control_flag_db,
  1263. a.fixed_lead_time_day,
  1264. a.over_reporting,
  1265. a.use_theoretical_density_db,
  1266. a.variable_lead_time_day,
  1267. a.over_report_tolerance,
  1268. a.fixed_lead_time_hour,
  1269. a.density,
  1270. a.variable_lead_time_hour,
  1271. a.remark,
  1272. a.status,
  1273. a.create_date,
  1274. a.create_by,
  1275. a.update_date,
  1276. a.update_by,
  1277. d.customer_part_no,
  1278. b.bu_no,
  1279. dbo.plm_get_bu_desc(b.site,b.bu_no) buDesc,
  1280. a.plm_part_no,
  1281. a.ifs_part_no,
  1282. a.show_in_query_flag,
  1283. a.temporary_part_flag
  1284. FROM part as a
  1285. LEFT JOIN plm_project_part as b on a.site = b.site and a.part_no = b.test_part_no
  1286. LEFT JOIN plm_project_info as c on b.site = c.site and b.project_id = c.project_id
  1287. LEFT JOIN plm_customer_part_info as d on c.site = d.site and c.customer_id = d.customer_no and b.test_part_no = d.part_no
  1288. where a.site = #{site} and a.part_no = #{testPartNo} and c.customer_id = #{customerId} and b.project_id = #{projectId}
  1289. </select>
  1290. <!-- 新增项目物料 -->
  1291. <insert id="saveCustomerPartInfo" parameterType="PartInformationEntity">
  1292. insert into plm_customer_part_info
  1293. (site, customer_no, part_no, customer_part_no, create_date, create_by)
  1294. values
  1295. (#{site}, #{customerNo}, #{partNo}, #{customerPartNo}, getDate(), #{createBy})
  1296. </insert>
  1297. <!-- 获取当前项目不包含的物料 -->
  1298. <select id="getProjectPartList1" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
  1299. select distinct
  1300. a.site,
  1301. a.test_part_no,
  1302. c.part_desc,
  1303. a.bu_no,
  1304. <!-- dbo.plm_get_bu_desc(a.site,a.bu_no) buDesc,-->
  1305. c.ifs_part_no as finalPartNo,
  1306. c.plm_part_no,
  1307. dbo.get_customer_part_no(a.site, a.test_part_no, #{query.customerId}, 'ProjectPart') as customer_part_no
  1308. from plm_project_part a
  1309. left join plm_project_part b on a.site = b.site and a.bu_no = b.bu_no and a.project_id = b.project_id
  1310. and a.test_part_no = b.project_id and b.site = #{query.site} and b.project_id = #{query.projectId}
  1311. left join part as c on a.site = c.site and a.test_part_no = c.part_no
  1312. <!-- left join plm_customer_part_info as d on a.site = d.site and a.test_part_no = d.part_no and d.customer_no = #{query.customerId}-->
  1313. where a.site = #{query.site} and b.site is null and c.show_in_query_flag = 'Y'
  1314. and c.part_no not in
  1315. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  1316. #{item}
  1317. </foreach>
  1318. <if test = "query.partNo != null and query.partNo != ''">
  1319. AND c.part_no like #{query.partNo}
  1320. </if>
  1321. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  1322. AND c.plm_part_no like #{query.plmPartNo}
  1323. </if>
  1324. <if test = "query.finalPartNo != null and query.finalPartNo != ''">
  1325. AND c.ifs_part_no like #{query.finalPartNo}
  1326. </if>
  1327. <if test = "query.partDesc != null and query.partDesc != ''">
  1328. AND c.part_desc like #{query.partDesc}
  1329. </if>
  1330. </select>
  1331. <!-- <select id="getProjectPartList1" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">-->
  1332. <!-- SELECT DISTINCT-->
  1333. <!-- a.site,-->
  1334. <!-- a.test_part_no AS part_no,-->
  1335. <!-- c.part_desc,-->
  1336. <!-- a.bu_no,-->
  1337. <!-- dbo.plm_get_bu_desc (a.site, a.bu_no) AS buDesc,-->
  1338. <!-- c.ifs_part_no AS finalPartNo,-->
  1339. <!-- c.plm_part_no-->
  1340. <!-- FROM-->
  1341. <!-- plm_project_part a-->
  1342. <!-- LEFT JOIN plm_project_part b ON a.site = b.site-->
  1343. <!-- AND a.test_part_no = b.test_part_no-->
  1344. <!-- AND b.site = #{query.site}-->
  1345. <!-- AND b.project_id = #{query.projectId}-->
  1346. <!-- LEFT JOIN part c ON a.site = c.site-->
  1347. <!-- AND a.test_part_no = c.part_no-->
  1348. <!-- where b.test_part_no IS NULL and c.show_in_query_flag = 'Y'-->
  1349. <!-- AND A.test_part_no NOT IN (SELECT test_part_no FROM plm_project_part p WHERE P.site = #{query.site} AND P.project_id = #{query.projectId})-->
  1350. <!-- <if test = "query.partNo != null and query.partNo != ''">-->
  1351. <!-- AND c.part_no like #{query.partNo}-->
  1352. <!-- </if>-->
  1353. <!-- <if test = "query.plmPartNo != null and query.plmPartNo != ''">-->
  1354. <!-- AND c.plm_part_no like #{query.plmPartNo}-->
  1355. <!-- </if>-->
  1356. <!-- <if test = "query.finalPartNo != null and query.finalPartNo != ''">-->
  1357. <!-- AND c.ifs_part_no like #{query.finalPartNo}-->
  1358. <!-- </if>-->
  1359. <!-- <if test = "query.partDesc != null and query.partDesc != ''">-->
  1360. <!-- AND c.part_desc like #{query.partDesc}-->
  1361. <!-- </if>-->
  1362. <!-- </select>-->
  1363. <!-- 获取当前项目所包含的物料 -->
  1364. <select id="getProjectPartList2" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
  1365. SELECT
  1366. a.site,
  1367. b.part_no,
  1368. b.part_desc,
  1369. d.customer_part_no
  1370. FROM plm_project_part a
  1371. LEFT JOIN part b ON a.site = b.site and a.test_part_no = b.part_no
  1372. LEFT JOIN plm_project_info as c on a.site = c.site and a.project_id = c.project_id
  1373. LEFT JOIN plm_customer_part_info as d on c.site = d.site and c.customer_id = d.customer_no and a.test_part_no = d.part_no
  1374. WHERE a.site = #{site} and a.project_id = #{projectId}
  1375. </select>
  1376. <!-- 获取当前项目不包含的物料 -->
  1377. <select id="getProjectPartList3" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
  1378. SELECT
  1379. a.site,
  1380. a.part_no,
  1381. a.part_desc,
  1382. a.ifs_part_no as finalPartNo,
  1383. a.status,
  1384. a.temporary_part_flag,
  1385. a.show_in_query_flag,
  1386. a.plm_part_no,
  1387. d.customer_part_no
  1388. FROM part as a
  1389. left join plm_project_part as b on a.site = b.site and a.plm_part_no = b.test_part_no
  1390. left join plm_project_part as c on a.site = c.site and a.ifs_part_no = c.test_part_no
  1391. left join plm_customer_part_info as d on a.site = d.site and d.customer_no = #{query.customerId}
  1392. and (d.part_no = a.ifs_part_no or d.part_no = a.plm_part_no)
  1393. where a.site = #{query.site}
  1394. <!-- and a.active = 'Y'-->
  1395. and a.show_in_query_flag = 'Y'
  1396. and b.test_part_no is null
  1397. and c.test_part_no is null
  1398. and a.part_no not in
  1399. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  1400. #{item}
  1401. </foreach>
  1402. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  1403. AND a.plm_part_no like #{query.plmPartNo}
  1404. </if>
  1405. <if test = "query.finalPartNo != null and query.finalPartNo != ''">
  1406. AND a.ifs_part_no like #{query.finalPartNo}
  1407. </if>
  1408. <if test = "query.partDesc != null and query.partDesc != ''">
  1409. AND a.part_desc like #{query.partDesc}
  1410. </if>
  1411. </select>
  1412. <!-- 新增项目物料 -->
  1413. <insert id="addProjectPart">
  1414. insert into plm_project_part
  1415. (site, project_id, test_part_no, create_date, create_by, part_no_source, bu_no, final_part_no, virtual_part_no)
  1416. VALUES
  1417. <foreach collection="list" item="item" index="index" separator=",">
  1418. (#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource}, #{item.buNo}, #{item.finalPartNo}, #{item.virtualPartNo})
  1419. </foreach>
  1420. </insert>
  1421. <!-- 新增项目物料 -->
  1422. <insert id="addCustomerPartInfo">
  1423. insert into plm_customer_part_info
  1424. (site, customer_no, part_no, customer_part_no, create_date, create_by) VALUES
  1425. <foreach collection="list" item="item" index="index" separator=",">
  1426. (#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
  1427. </foreach>
  1428. </insert>
  1429. <!-- 获取当前项目所包含的物料 -->
  1430. <select id="getChangeRecordByPartNo" resultType="com.spring.modules.change.vo.ChangeRequestVo" parameterType="PlmProjectPartData">
  1431. SELECT
  1432. a.site,
  1433. a.change_no,
  1434. a.applicant_id,
  1435. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  1436. u.department_no as applicationDepartmentId,
  1437. dbo.get_department_name(a.site, u.department_no) as applicationDepartmentName,
  1438. a.apply_date,
  1439. a.ecn_type,
  1440. a.change_impact,
  1441. a.change_impact_desc,
  1442. a.ecn_stage,
  1443. a.change_type,
  1444. a.tp_engineer_id,
  1445. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  1446. a.change_phase_in_date,
  1447. a.df_is_product,
  1448. a.printing,
  1449. a.manufacturing_cost_is_change,
  1450. a.change_request_desc,
  1451. a.is_re_quote,
  1452. a.ul_certification_requirements,
  1453. a.ul_continue_to_meet_demand,
  1454. a.gp_certification_requirements,
  1455. a.gp_continue_to_meet_demand,
  1456. a.create_date,
  1457. a.create_by,
  1458. a.update_date,
  1459. a.update_by,
  1460. a.industrial_engineer_id,
  1461. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  1462. a.change_status,
  1463. a.cqc_operator_id,
  1464. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  1465. a.fai_operator_id,
  1466. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  1467. d.node_id,
  1468. d.node_name,
  1469. d.create_by as createBy2
  1470. FROM plm_change_request as a
  1471. LEFT JOIN sys_user as u on a.site = u.site and a.applicant_id = u.username
  1472. LEFT JOIN plm_change_request_detail as b on a.site = b.site and a.change_no = b.change_no
  1473. LEFT JOIN plm_project_part as c on b.site = c.site and b.part_no = c.final_part_no
  1474. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
  1475. left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
  1476. WHERE a.site = #{site} and c.project_id = #{projectId}
  1477. </select>
  1478. <!-- 获取当前项目所包含的物料 -->
  1479. <select id="getChangeRecordByPartNo2" resultType="com.spring.modules.change.vo.ChangeRequestVo" parameterType="PlmProjectPartData">
  1480. SELECT
  1481. a.site,
  1482. a.change_no,
  1483. a.applicant_id,
  1484. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  1485. u.department_no as applicationDepartmentId,
  1486. dbo.get_department_name(a.site, u.department_no) as applicationDepartmentName,
  1487. a.apply_date,
  1488. a.ecn_type,
  1489. a.change_impact,
  1490. a.change_impact_desc,
  1491. a.ecn_stage,
  1492. a.change_type,
  1493. a.tp_engineer_id,
  1494. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  1495. a.change_phase_in_date,
  1496. a.df_is_product,
  1497. a.printing,
  1498. a.manufacturing_cost_is_change,
  1499. a.change_request_desc,
  1500. a.is_re_quote,
  1501. a.ul_certification_requirements,
  1502. a.ul_continue_to_meet_demand,
  1503. a.gp_certification_requirements,
  1504. a.gp_continue_to_meet_demand,
  1505. a.create_date,
  1506. a.create_by,
  1507. a.update_date,
  1508. a.update_by,
  1509. a.industrial_engineer_id,
  1510. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  1511. a.change_status,
  1512. a.cqc_operator_id,
  1513. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  1514. a.fai_operator_id,
  1515. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  1516. d.node_id,
  1517. d.node_name,
  1518. d.create_by as createBy2
  1519. FROM plm_change_request as a
  1520. LEFT JOIN sys_user as u on a.site = u.site and a.applicant_id = u.username
  1521. LEFT JOIN plm_change_request_detail as b on a.site = b.site and a.change_no = b.change_no
  1522. LEFT JOIN plm_project_part as c on b.site = c.site and b.part_no = c.final_part_no
  1523. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
  1524. left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
  1525. WHERE a.site = #{site} and c.project_id = #{projectId} and c.final_part_no = #{finalPartNo}
  1526. </select>
  1527. <!-- 查询Bom替代 -->
  1528. <select id="queryBomAlternativeList" resultType="com.spring.modules.part.vo.BomDetailVo" parameterType="PartInformationEntity">
  1529. SELECT
  1530. a.site,
  1531. a.part_no,
  1532. a.alternative_no,
  1533. a.alternative_description,
  1534. a.bom_type,
  1535. a.eng_chg_level,
  1536. a.min_lot_qty,
  1537. a.default_flag,
  1538. a.note_text,
  1539. a.create_date,
  1540. a.create_by,
  1541. a.update_date,
  1542. a.update_by,
  1543. a.status,
  1544. a.official_flag,
  1545. b.eff_phase_in_date,
  1546. b.eff_phase_out_date,
  1547. b.note_text as bomHeaderNoteText,
  1548. b.eng_revision
  1549. FROM plm_bom_detail as a
  1550. LEFT JOIN plm_bom_header as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type
  1551. WHERE a.site = #{site} and a.part_no = #{partNo}
  1552. </select>
  1553. <!-- 查询Bom替代 -->
  1554. <select id="queryRecipeAlternativeList" resultType="com.spring.modules.part.vo.RecipeDetailVo" parameterType="PartInformationEntity">
  1555. SELECT
  1556. a.site,
  1557. a.part_no,
  1558. a.alternative_no,
  1559. a.alternative_description,
  1560. a.bom_type,
  1561. a.eng_chg_level,
  1562. a.min_lot_qty,
  1563. a.default_flag,
  1564. a.note_text,
  1565. a.create_date,
  1566. a.create_by,
  1567. a.update_date,
  1568. a.update_by,
  1569. a.status,
  1570. a.official_flag,
  1571. b.eff_phase_in_date,
  1572. b.eff_phase_out_date,
  1573. b.note_text as bomHeaderNoteText,
  1574. b.eng_revision
  1575. FROM plm_recipe_detail as a
  1576. LEFT JOIN plm_recipe_header as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type
  1577. WHERE a.site = #{site} and a.part_no = #{partNo}
  1578. </select>
  1579. <!-- 查询Routing替代 -->
  1580. <select id="queryRoutingAlternativeList" resultType="RoutingDetailEntity" parameterType="PartInformationEntity">
  1581. SELECT
  1582. a.site,
  1583. a.part_no,
  1584. a.routing_type,
  1585. a.routing_revision,
  1586. a.alternative_no,
  1587. a.alternative_description,
  1588. a.rout_template_id,
  1589. a.plan_date,
  1590. a.fixed_lead_time_day,
  1591. a.fixed_lead_time_hour,
  1592. a.variable_lead_time_day,
  1593. a.variable_lead_time_hour,
  1594. a.for_std_lot_by_day,
  1595. a.for_lot_by_day,
  1596. a.min_lot_qty,
  1597. a.note_text,
  1598. a.status,
  1599. a.official_flag
  1600. FROM plm_routing_detail as a
  1601. 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
  1602. where a.site = #{site} and a.part_no = #{partNo}
  1603. </select>
  1604. <!-- &lt;!&ndash; 获取 component 对象&ndash;&gt;-->
  1605. <!-- <select id="getComponentPart" parameterType="com.spring.modules.part.vo.BomDetailVo" resultType="com.spring.modules.part.vo.PartInformationVo">-->
  1606. <!-- SELECT-->
  1607. <!-- a.site,-->
  1608. <!-- a.component_part as partNo,-->
  1609. <!-- a.eng_chg_level,-->
  1610. <!-- a.bom_type,-->
  1611. <!-- a.alternative_no,-->
  1612. <!-- b.alternative_description,-->
  1613. <!-- d.status-->
  1614. <!-- FROM plm_bom_component as a-->
  1615. <!-- LEFT JOIN plm_bom_detail as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type and a.alternative_no = b.alternative_no-->
  1616. <!-- LEFT JOIN plm_bom_header as c on c.site = b.site and c.part_no = b.part_no and c.eng_chg_level = b.eng_chg_level and c.bom_type = b.bom_type-->
  1617. <!-- LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no-->
  1618. <!-- WHERE c.site = #{site} and c.part_no = #{partNo} and c.bom_type = 'Manufacturing' and c.eff_phase_out_date is null-->
  1619. <!-- </select>-->
  1620. <!-- 获取 component 对象-->
  1621. <select id="getComponentPart" parameterType="com.spring.modules.part.vo.BomDetailVo" resultType="com.spring.modules.part.vo.PartInformationVo">
  1622. SELECT
  1623. a.site,
  1624. a.component_part as partNo,
  1625. a.eng_chg_level,
  1626. a.bom_type,
  1627. a.alternative_no,
  1628. b.alternative_description,
  1629. d.status
  1630. FROM plm_bom_component as a
  1631. LEFT JOIN plm_bom_detail as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type and a.alternative_no = b.alternative_no
  1632. LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no
  1633. WHERE a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo}
  1634. </select>
  1635. <select id="getPartRevision" parameterType="PartInformationEntity" resultType="PartRevisionEntity">
  1636. SELECT
  1637. site,
  1638. part_no,
  1639. eng_chg_level,
  1640. eff_phase_in_date,
  1641. eff_phase_out_date,
  1642. revision_text,
  1643. product_status,
  1644. repair_status,
  1645. eng_revision,
  1646. create_date,
  1647. create_by,
  1648. update_date,
  1649. update_by
  1650. FROM part_revision
  1651. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = 1
  1652. </select>
  1653. <!-- 根据物料编码删除 BOM Header -->
  1654. <delete id="deleteBomHeaderByPartNo" parameterType="PartInformationEntity">
  1655. delete from plm_bom_header
  1656. where site = #{site} and part_no = #{partNo}
  1657. </delete>
  1658. <!-- 根据物料编码删除 BOM Detail -->
  1659. <delete id="deleteBomDetailByPartNo" parameterType="PartInformationEntity">
  1660. delete from plm_bom_detail
  1661. where site = #{site} and part_no = #{partNo}
  1662. </delete>
  1663. <!-- 根据物料编码删除 BOM Component -->
  1664. <delete id="deleteBomComponentByPartNo" parameterType="PartInformationEntity">
  1665. delete from plm_bom_component
  1666. where site = #{site} and part_no = #{partNo}
  1667. </delete>
  1668. <!-- 根据物料编码删除 Recipe Header -->
  1669. <delete id="deleteRecipeHeaderByPartNo" parameterType="PartInformationEntity">
  1670. delete from plm_recipe_header
  1671. where site = #{site} and part_no = #{partNo}
  1672. </delete>
  1673. <!-- 根据物料编码删除 Recipe Detail -->
  1674. <delete id="deleteRecipeDetailByPartNo" parameterType="PartInformationEntity">
  1675. delete from plm_recipe_detail
  1676. where site = #{site} and part_no = #{partNo}
  1677. </delete>
  1678. <!-- 根据物料编码删除 Recipe Component -->
  1679. <delete id="deleteRecipeComponentByPartNo" parameterType="PartInformationEntity">
  1680. delete from plm_recipe_component
  1681. where site = #{site} and part_no = #{partNo}
  1682. </delete>
  1683. <!-- 根据物料编码删除 BOM 副产品成本分配 -->
  1684. <delete id="deleteBomManufStructCostDistribByPartNo" parameterType="PartInformationEntity">
  1685. delete from plm_bom_manuf_struct_cost_distrib
  1686. where site = #{site} and part_no = #{partNo}
  1687. </delete>
  1688. <!-- 根据物料编码删除 Routing Header -->
  1689. <delete id="deleteRoutingHeaderByPartNo" parameterType="PartInformationEntity">
  1690. delete from plm_routing_header
  1691. where site = #{site} and part_no = #{partNo}
  1692. </delete>
  1693. <!-- 根据物料编码删除 Routing Detail -->
  1694. <delete id="deleteRoutingDetailByPartNo" parameterType="PartInformationEntity">
  1695. delete from plm_routing_detail
  1696. where site = #{site} and part_no = #{partNo}
  1697. </delete>
  1698. <!-- 根据物料编码删除 Routing Component -->
  1699. <delete id="deleteRoutingComponentByPartNo" parameterType="PartInformationEntity">
  1700. delete from plm_routing_component
  1701. where site = #{site} and part_no = #{partNo}
  1702. </delete>
  1703. <!-- 根据物料编码删除 Routing Tool -->
  1704. <delete id="deleteRoutingToolByPartNo" parameterType="PartInformationEntity">
  1705. delete from routing_tool
  1706. where site = #{site} and part_no = #{partNo}
  1707. </delete>
  1708. <!-- 根据物料编码删除 Routing GuideLine -->
  1709. <delete id="deleteRoutingGuideLineByPartNo" parameterType="PartInformationEntity">
  1710. delete from plm_routing_work_guide
  1711. where site = #{site} and part_no = #{partNo}
  1712. </delete>
  1713. <!-- 新增物料版本 -->
  1714. <insert id="saveRevisions">
  1715. insert into part_revision
  1716. (site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by) VALUES
  1717. <foreach collection="list" item="item" index="index" separator=",">
  1718. (#{item.site}, #{item.partNo}, #{item.engChgLevel},CONVERT(datetime2, #{item.effPhaseInDate, jdbcType=TIMESTAMP}),
  1719. CONVERT(datetime2, #{item.effPhaseOutDate, jdbcType=TIMESTAMP}), #{item.revisionText}, #{item.productStatus}, #{item.repairStatus}, #{item.engRevision}, getDate(), #{item.createBy})
  1720. </foreach>
  1721. </insert>
  1722. <!-- 创建 IFS 物料的 BOM 替代 -->
  1723. <insert id="saveIfsBomAlternatives">
  1724. insert into plm_bom_detail
  1725. (site, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by, official_flag) VALUES
  1726. <foreach collection="list" item="item" index="index" separator=",">
  1727. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.status}, #{item.minLotQty}, #{item.defaultFlag}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.officialFlag})
  1728. </foreach>
  1729. </insert>
  1730. <!-- 创建 IFS 物料的 Recipe 替代 -->
  1731. <insert id="saveIfsRecipeAlternatives">
  1732. insert into plm_recipe_detail
  1733. (site, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by, official_flag, display_weight_uom, display_volume_uom, reg_unit) VALUES
  1734. <foreach collection="list" item="item" index="index" separator=",">
  1735. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.status}, #{item.minLotQty}, #{item.defaultFlag}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.officialFlag}, #{item.displayWeightUom}, #{item.displayVolumeUom}, #{item.regUnit})
  1736. </foreach>
  1737. </insert>
  1738. <!-- 创建 IFS 物料的 Routing 替代 -->
  1739. <insert id="saveIfsRoutingAlternatives">
  1740. insert into plm_routing_detail
  1741. (site, part_no, routing_revision, routing_type, alternative_no, alternative_description, fixed_lead_time_day, fixed_lead_time_hour, variable_lead_time_day, variable_lead_time_hour, for_std_lot_by_day, for_lot_by_day, min_lot_qty, note_text, create_date, create_by, status, official_flag) VALUES
  1742. <foreach collection="list" item="item" index="index" separator=",">
  1743. (#{item.site}, #{item.ifsPartNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.fixedLeadTimeDay}, #{item.fixedLeadTimeHour}, #{item.variableLeadTimeDay}, #{item.variableLeadTimeHour}, #{item.forStdLotByDay}, #{item.forLotByDay}, #{item.minLotQty}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.status}, #{item.officialFlag})
  1744. </foreach>
  1745. </insert>
  1746. <!-- 查询代理商列表 -->
  1747. <select id="getPartAgents" resultType="com.spring.modules.part.vo.AgentInformationVo" parameterType="PartInformationEntity">
  1748. SELECT
  1749. site,
  1750. part_no,
  1751. agent_id
  1752. FROM part_agent
  1753. where site = #{site} and part_no = #{partNo}
  1754. </select>
  1755. <!-- 查询制造商列表 -->
  1756. <select id="getPartManufacturers" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="PartInformationEntity">
  1757. SELECT
  1758. site,
  1759. part_no,
  1760. manufacturer_id
  1761. FROM part_manufacturer
  1762. where site = #{site} and part_no = #{partNo}
  1763. </select>
  1764. <!-- 查询默认库位列表 -->
  1765. <select id="getPartDefaultLocations" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="PartInformationEntity">
  1766. SELECT
  1767. site,
  1768. part_no,
  1769. location_id
  1770. FROM plm_part_location
  1771. where site = #{site} and part_no = #{partNo}
  1772. </select>
  1773. <!-- 查询文件列表 -->
  1774. <select id="getPartFiles" resultType="SysOssEntity" parameterType="PartInformationEntity">
  1775. SELECT
  1776. id,
  1777. url,
  1778. create_date,
  1779. file_name,
  1780. new_file_name,
  1781. create_by,
  1782. order_ref1,
  1783. order_ref2,
  1784. order_ref3,
  1785. file_type,
  1786. file_suffix,
  1787. file_type_code,
  1788. file_remark
  1789. FROM sys_oss
  1790. where order_ref1 = #{site} and order_ref2 = #{partNo}
  1791. </select>
  1792. <!-- 新增物料代理商 -->
  1793. <insert id="savePartAgent">
  1794. insert into part_agent
  1795. (site, part_no, agent_id) VALUES
  1796. <foreach collection="list" item="item" index="index" separator=",">
  1797. (#{item.site}, #{item.partNo}, #{item.agentId})
  1798. </foreach>
  1799. </insert>
  1800. <!-- 新增物料制造商 -->
  1801. <insert id="savePartManufacturer">
  1802. insert into part_manufacturer
  1803. (site, part_no, manufacturer_id) VALUES
  1804. <foreach collection="list" item="item" index="index" separator=",">
  1805. (#{item.site}, #{item.partNo}, #{item.manufacturerId})
  1806. </foreach>
  1807. </insert>
  1808. <!-- 新增物料制造商 -->
  1809. <insert id="savePartDefaultLocation">
  1810. insert into plm_part_location
  1811. (site, part_no, location_id) VALUES
  1812. <foreach collection="list" item="item" index="index" separator=",">
  1813. (#{item.site}, #{item.partNo}, #{item.locationId})
  1814. </foreach>
  1815. </insert>
  1816. <!-- 新增物料文件 -->
  1817. <insert id="savePartFile">
  1818. insert into sys_oss
  1819. (url, create_date, file_name, new_file_name, create_by, order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code, file_remark) VALUES
  1820. <foreach collection="list" item="item" index="index" separator=",">
  1821. (#{item.url}, #{item.createDate}, #{item.fileName}, #{item.newFileName}, #{item.createBy}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.fileType}, #{item.fileSuffix}, #{item.fileTypeCode}, #{item.fileRemark})
  1822. </foreach>
  1823. </insert>
  1824. <!-- 下一个物料编码 -->
  1825. <select id="getNextPartNo2" resultType="string" parameterType="com.spring.modules.part.vo.PartInformationVo">
  1826. select dbo.get_next_part_code(#{ifsPartNo})
  1827. </select>
  1828. <select id="checkPartLocationType" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  1829. SELECT
  1830. a.site,
  1831. a.part_no,
  1832. a.location_id,
  1833. b.location_type
  1834. FROM plm_part_location as a
  1835. left join location as b on a.site = b.site and a.location_id = b.location_id
  1836. WHERE a.part_no = #{partNo} and a.site = #{site} and b.location_type = #{locationType}
  1837. </select>
  1838. <select id="checkPartLocationType2" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  1839. SELECT
  1840. a.site,
  1841. a.part_no,
  1842. a.location_id,
  1843. b.location_type
  1844. FROM plm_part_location as a
  1845. left join location as b on a.site = b.site and a.location_id = b.location_id
  1846. WHERE a.part_no = #{partNo} and a.site = #{site} and b.location_type in ('Picking', 'Floor stock', 'Production line')
  1847. </select>
  1848. <!-- 修改物料版本 -->
  1849. <update id="updateRevisionOutDate">
  1850. UPDATE part_revision
  1851. SET eff_phase_out_date = #{effPhaseOutDate}
  1852. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  1853. </update>
  1854. <select id="getModelHeader" resultType="PartSubPropertiesValueHeaderData">
  1855. SELECT
  1856. #{ifsPartNo} as partNo,
  1857. Site,
  1858. CodeNo,
  1859. SubCodeSeqNo,
  1860. SubCodeDesc,
  1861. RecordType
  1862. FROM PartSubPropertiesValueHeader
  1863. where site = #{site} and RecordType = #{recordType} and PartNo = #{partNo} and CodeNo = #{codeNo}
  1864. </select>
  1865. <select id="getModelDetail" resultType="PartSubPropertiesValueData">
  1866. SELECT
  1867. #{ifsPartNo} as partNo,
  1868. Site,
  1869. CodeNo,
  1870. SubCodeSeqNo,
  1871. SubCodeDesc,
  1872. ItemNo,
  1873. PropertiesItemNo,
  1874. TextValue,
  1875. NumValue,
  1876. RecordType,
  1877. order_id
  1878. FROM PartSubPropertiesValue
  1879. where site = #{site} and RecordType = #{recordType} and PartNo = #{partNo} and CodeNo = #{codeNo}
  1880. </select>
  1881. <select id="getPartPropertyList" resultType="PartIfsInventoryProperty">
  1882. SELECT
  1883. a.PartNo as partNo,
  1884. a.Site as contract,
  1885. a.CodeNo as engAttribute,
  1886. a.PropertiesItemNo as characteristicCode,
  1887. isnull(a.TextValue, '') as attrValueAlpha,
  1888. ISNULL(CONVERT(VARCHAR(20), a.NumValue, 1), '') as attrValueNumeric,
  1889. case when b.ValueType_DB = 'T' then 'Alpha' when b.ValueType_DB = 'N' then 'Numeric' else '' end as characteristicType,
  1890. '' as unitMeas
  1891. FROM PartSubPropertiesValue as a
  1892. left join plm_properties_item as b on a.site = b.site and a.PropertiesItemNo = b.ItemNo and a.RecordType = b.ItemType
  1893. where a.site = #{site} and a.RecordType = #{recordType} and a.PartNo = #{partNo} and a.CodeNo = #{codeNo}
  1894. </select>
  1895. <select id="getMasterPartPropertyList" resultType="PartIfsCatalogProperty">
  1896. SELECT
  1897. 'PartCatalog' as luName,
  1898. ('PART_NO=' + a.PartNo + '^') as keyRef,
  1899. a.CodeNo as technicalClass,
  1900. a.PropertiesItemNo as attribute,
  1901. isnull(a.TextValue, '') as valueText,
  1902. ISNULL(CONVERT(VARCHAR(20), a.NumValue, 1), '') as valueNo,
  1903. case when b.ValueType_DB = 'T' then 'Alpha' when b.ValueType_DB = 'N' then 'Numeric' else '' end as attributeType,
  1904. '' as lowerLimit,
  1905. '' as upperLimit,
  1906. '' as info
  1907. FROM PartSubPropertiesValue as a
  1908. left join plm_properties_item as b on a.site = b.site and a.PropertiesItemNo = b.ItemNo and a.RecordType = b.ItemType
  1909. where a.site = #{site} and a.PartNo = #{partNo} and a.CodeNo = #{codeNo} and a.RecordType = #{recordType}
  1910. </select>
  1911. <insert id="savePartModelHeaders">
  1912. insert into PartSubPropertiesValueHeader
  1913. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType) VALUES
  1914. <foreach collection="list" item="item" index="index" separator=",">
  1915. (#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.recordType})
  1916. </foreach>
  1917. </insert>
  1918. <insert id="savePartModelDetails">
  1919. insert into PartSubPropertiesValue
  1920. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id) VALUES
  1921. <foreach collection="list" item="item" index="index" separator=",">
  1922. (#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.itemNo,jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue,jdbcType=FLOAT}, #{item.recordType}, #{item.orderId})
  1923. </foreach>
  1924. </insert>
  1925. <select id="queryPart" resultType="com.spring.modules.part.entity.PartInformationEntity">
  1926. select top 100 site,
  1927. part_no,
  1928. part_desc,
  1929. spec,
  1930. part_type_db,
  1931. dbo.get_part_unitCost(site, part_no) as standardCost,
  1932. status,
  1933. configuration_id,
  1934. um_id
  1935. from part
  1936. where site = #{site}
  1937. and part_no = #{partNo}
  1938. and active = 'Y'
  1939. and show_in_query_flag = 'Y'
  1940. </select>
  1941. <!-- 单独的方法 修改项目物料的BU相关信息 -->
  1942. <update id="updateProjectPartBuNo" parameterType="PartInformationEntity">
  1943. UPDATE plm_project_part
  1944. SET bu_no = #{buNo}
  1945. WHERE site = #{site} AND project_id = #{projectId} AND test_part_no = #{partNo}
  1946. </update>
  1947. <!-- 修改项目物料的客户料号相关信息 -->
  1948. <update id="updateProjectCustomerPartNo" parameterType="PartInformationEntity">
  1949. UPDATE plm_customer_part_info
  1950. SET customer_part_no = #{customerPartNo}
  1951. WHERE site = #{site} AND customer_no = #{customerNo} AND part_no = #{partNo}
  1952. </update>
  1953. <select id="queryPartByPartNo" resultType="com.spring.modules.part.entity.PartInformationEntity">
  1954. select p.site,
  1955. p.part_no,
  1956. p.part_desc,
  1957. p.spec,
  1958. p.part_type_db,
  1959. dbo.get_part_unitCost(p.site, p.part_no) as standardCost,
  1960. p.status,
  1961. p.um_id,
  1962. p.ifs_part_no,
  1963. p.configuration_id
  1964. from part p
  1965. where active = 'Y'
  1966. and show_in_query_flag = 'Y'
  1967. <if test="params.site != null and params.site != ''">
  1968. and p.site = #{params.site}
  1969. </if>
  1970. <if test="params.partNo != null and params.partNo != ''">
  1971. and p.part_no like #{params.partNo}
  1972. </if>
  1973. <if test="params.partDesc != null and params.partDesc != ''">
  1974. and p.part_desc like #{params.partDesc}
  1975. </if>
  1976. <if test="params.ifsPartNo != null and params.ifsPartNo != ''">
  1977. and p.ifs_part_no like #{params.ifsPartNo}
  1978. </if>
  1979. </select>
  1980. <!-- 查询文件ID -->
  1981. <select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
  1982. SELECT id, file_name
  1983. FROM sys_oss
  1984. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  1985. </select>
  1986. <select id="getFileData" resultType="SysOssEntity">
  1987. select
  1988. url,
  1989. file_name,
  1990. new_file_name
  1991. from sys_oss
  1992. where id = #{id}
  1993. </select>
  1994. <select id="getTblBaseData" resultType="TblBaseDataEntity">
  1995. select
  1996. id,
  1997. site,
  1998. first_type,
  1999. second_type,
  2000. base_data,
  2001. base_desc,
  2002. status,
  2003. sort_no,
  2004. remark
  2005. from tbl_base_data
  2006. where first_type = #{firstType}
  2007. </select>
  2008. <delete id="delProjectPartByPartNo">
  2009. delete from plm_project_part
  2010. where site = #{site} and test_part_no = #{partNo}
  2011. </delete>
  2012. <select id="getMaxPartRevision" resultType="com.spring.modules.part.vo.PartRevisionVo">
  2013. SELECT
  2014. site,
  2015. part_no,
  2016. eng_chg_level,
  2017. eff_phase_in_date,
  2018. eff_phase_out_date,
  2019. revision_text,
  2020. product_status,
  2021. repair_status,
  2022. eng_revision
  2023. FROM part_revision
  2024. WHERE part_no = #{partNo} and site = #{site}
  2025. order by eng_chg_level desc
  2026. </select>
  2027. <!-- 查询物料的revision列表 -->
  2028. <select id="queryPartUnitCostList" resultType="InventoryPartUnitCostSumEntity" parameterType="InventoryPartUnitCostSumEntity">
  2029. SELECT
  2030. site,
  2031. part_no,
  2032. configuration_id,
  2033. inventory_value,
  2034. lot_batch_no,
  2035. serial_no
  2036. FROM inventory_part_unit_cost_sum
  2037. WHERE site = #{site} and part_no = #{partNo} and configuration_id = #{configurationId}
  2038. </select>
  2039. <select id="getMaxUnitValueRowVersion" resultType="java.lang.String">
  2040. select
  2041. isnull(max(ifs_row_version),'')
  2042. from inventory_part_unit_cost_sum
  2043. </select>
  2044. <select id="getPLMUnitValues" resultType="InventoryPartUnitCostSumEntity">
  2045. select
  2046. site,
  2047. part_no,
  2048. configuration_id,
  2049. inventory_value,
  2050. lot_batch_no,
  2051. serial_no,
  2052. ifs_row_version
  2053. from inventory_part_unit_cost_sum
  2054. where site in
  2055. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  2056. #{item}
  2057. </foreach>
  2058. </select>
  2059. <!-- 批量新增 -->
  2060. <insert id="syncSaveUnitValue">
  2061. INSERT INTO inventory_part_unit_cost_sum (site, part_no, configuration_id, inventory_value, lot_batch_no, serial_no, ifs_row_version)
  2062. VALUES
  2063. <foreach item="item" collection="list" separator=",">
  2064. (#{item.site}, #{item.partNo}, #{item.configurationId}, #{item.inventoryValue}, #{item.lotBatchNo}, #{item.serialNo}, #{item.ifsRowVersion})
  2065. </foreach>
  2066. </insert>
  2067. <!-- 批量更新 -->
  2068. <update id="syncUpdateUnitValue" parameterType="java.util.List">
  2069. UPDATE inventory_part_unit_cost_sum
  2070. SET
  2071. inventory_value = CASE
  2072. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2073. WHEN part_no = #{item.partNo} THEN #{item.inventoryValue}
  2074. </foreach>
  2075. ELSE inventory_value
  2076. END,
  2077. lot_batch_no = CASE
  2078. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2079. WHEN part_no = #{item.partNo} THEN #{item.lotBatchNo}
  2080. </foreach>
  2081. ELSE lot_batch_no
  2082. END,
  2083. serial_no = CASE
  2084. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2085. WHEN part_no = #{item.partNo} THEN #{item.serialNo}
  2086. </foreach>
  2087. ELSE serial_no
  2088. END,
  2089. ifs_row_version = CASE
  2090. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2091. WHEN part_no = #{item.partNo} THEN #{item.ifsRowVersion}
  2092. </foreach>
  2093. ELSE ifs_row_version
  2094. END
  2095. WHERE part_no IN
  2096. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  2097. #{item.partNo}
  2098. </foreach>
  2099. AND site = #{list[0].site}
  2100. </update>
  2101. <select id="getItemListByCodeNo" resultType="PartSubPropertiesValueData">
  2102. select
  2103. #{site} as site,
  2104. #{codeNo} as CodeNo,
  2105. 1 as SubCodeSeqNo,
  2106. a.Code_Desc as SubCodeDesc,
  2107. b.seq_No as ItemNo,
  2108. b.properties_item_no as PropertiesItemNo,
  2109. case when c.ValueType_DB = 'T' then c.DefaultValue else null end as TextValue,
  2110. case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end as NumValue,
  2111. #{recordType} as RecordType,
  2112. c.ItemDesc as ItemDesc,
  2113. c.ValueType,
  2114. c.ValueType_DB,
  2115. c.ValueChooseFlag
  2116. from plm_properties_model_header a
  2117. left join plm_properties_model_detail b on a.Code_No = b.Code_No and a.site = b.site and a.function_type = b.function_type
  2118. left join plm_properties_item c on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
  2119. where a.Code_No = #{codeNo} and a.site = #{site} AND B.SITE IS NOT NULL AND A.function_type = #{recordType}
  2120. </select>
  2121. <!-- 获取当前项目不包含的物料 -->
  2122. <select id="getItemExclusionAlreadyExists" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
  2123. SELECT
  2124. site,
  2125. ItemNo as PropertiesItemNo,
  2126. ItemDesc,
  2127. ValueType,
  2128. ValueType_DB,
  2129. ValueChooseFlag,
  2130. itemType as RecordType
  2131. FROM plm_properties_item
  2132. where site = #{query.site} and itemType = #{query.recordType}
  2133. and ItemNo not in
  2134. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  2135. #{item}
  2136. </foreach>
  2137. <if test = "query.propertiesItemNo != null and query.propertiesItemNo != ''">
  2138. AND ItemNo like #{query.propertiesItemNo}
  2139. </if>
  2140. <if test = "query.itemDesc != null and query.itemDesc != ''">
  2141. AND ItemDesc like #{query.itemDesc}
  2142. </if>
  2143. </select>
  2144. <select id="getProjectCustomerPartNo" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.vo.PartInformationVo">
  2145. select
  2146. site,
  2147. customer_no,
  2148. part_no,
  2149. customer_part_no,
  2150. create_date,
  2151. create_by,
  2152. update_date,
  2153. update_by
  2154. from plm_customer_part_info
  2155. where site = #{site} and part_no = #{partNo} and customer_no = #{customerNo}
  2156. </select>
  2157. <!-- 新增BOM header -->
  2158. <insert id="saveBomHeaders">
  2159. insert into plm_bom_header
  2160. (site, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, official_flag, create_date, create_by) VALUES
  2161. <foreach collection="list" item="item" index="index" separator=",">
  2162. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.noteText}, #{item.effPhaseInDate}, #{item.effPhaseOutDate}, #{item.engRevision}, #{item.typeFlag}, #{item.netWeight}, #{item.officialFlag}, getDate(), #{item.createBy})
  2163. </foreach>
  2164. </insert>
  2165. <!-- 新增Recipe header -->
  2166. <insert id="saveRecipeHeaders">
  2167. insert into plm_recipe_header
  2168. (site, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, official_flag, create_date, create_by) VALUES
  2169. <foreach collection="list" item="item" index="index" separator=",">
  2170. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.noteText}, #{item.effPhaseInDate}, #{item.effPhaseOutDate}, #{item.engRevision}, #{item.typeFlag}, #{item.netWeight}, #{item.officialFlag}, getDate(), #{item.createBy})
  2171. </foreach>
  2172. </insert>
  2173. <select id="getMasterPartModal" resultType="PartSubPropertiesValueHeaderData">
  2174. SELECT
  2175. PartNo,
  2176. Site,
  2177. CodeNo,
  2178. SubCodeSeqNo,
  2179. SubCodeDesc,
  2180. RecordType
  2181. FROM PartSubPropertiesValueHeader
  2182. where PartNo = #{partNo} and Site = #{site} and RecordType = #{recordType}
  2183. </select>
  2184. <select id="locationInformationSearch" parameterType="com.spring.modules.part.vo.LocationInformationVo" resultType="com.spring.modules.part.vo.LocationInformationVo">
  2185. SELECT
  2186. site,
  2187. location_id,
  2188. location_name,
  2189. warehouse_id,
  2190. active,
  2191. location_type
  2192. FROM location
  2193. where site = #{query.site}
  2194. <if test = "query.locationId != null and query.locationId != ''">
  2195. AND location_id like #{query.locationId}
  2196. </if>
  2197. <if test = "query.locationName != null and query.locationName != ''">
  2198. AND location_name like #{query.locationName}
  2199. </if>
  2200. <if test = "query.warehouseId != null and query.warehouseId != ''">
  2201. AND warehouse_id like #{query.warehouseId}
  2202. </if>
  2203. <if test = "query.locationType != null and query.locationType != ''">
  2204. AND location_type = #{query.locationType}
  2205. </if>
  2206. </select>
  2207. <insert id="savePartSubPropertiesValues">
  2208. insert into PartSubPropertiesValue
  2209. (site, PartNo, CodeNo, SubCodeSeqNo, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType) VALUES
  2210. <foreach collection="list" item="item" index="index" separator=",">
  2211. (#{item.site}, #{item.partNo}, #{item.codeNo}, #{item.subCodeSeqNo, jdbcType=FLOAT}, #{item.itemNo, jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue, jdbcType=FLOAT}, #{item.recordType})
  2212. </foreach>
  2213. </insert>
  2214. <select id="getUnitValuesByPartNo" resultType="com.spring.modules.part.entity.InventoryPartUnitCostSumEntity">
  2215. select
  2216. site,
  2217. part_no,
  2218. configuration_id,
  2219. inventory_value,
  2220. lot_batch_no,
  2221. serial_no,
  2222. ifs_row_version
  2223. from inventory_part_unit_cost_sum
  2224. where site = #{site} and part_no = #{partNo} and configuration_id = #{configurationId}
  2225. </select>
  2226. <select id="queryOfficialPartList" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.entity.BomAllFieldEntity">
  2227. SELECT
  2228. a.site,
  2229. a.part_no,
  2230. a.part_desc,
  2231. a.spec,
  2232. a.um_id as printUnit,
  2233. b.um_name as printUnitName,
  2234. a.part_type,
  2235. a.family_id,
  2236. c.family_name,
  2237. a.part_status,
  2238. d.part_status_desc,
  2239. a.plm_part_no,
  2240. a.ifs_part_no
  2241. FROM part as a
  2242. left join um as b on a.um_id = b.um_id
  2243. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  2244. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  2245. <where>
  2246. a.site = #{query.site} and a.active = 'Y' and a.status = 'Y'
  2247. AND a.show_in_query_flag = 'Y'
  2248. <if test = "query.partNo != null and query.partNo != ''">
  2249. AND a.part_no like #{query.partNo}
  2250. </if>
  2251. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  2252. AND a.plm_part_no like #{query.plmPartNo}
  2253. </if>
  2254. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  2255. AND a.ifs_part_no like #{query.ifsPartNo}
  2256. </if>
  2257. <if test = "query.partDesc != null and query.partDesc != ''">
  2258. AND a.part_desc like #{query.partDesc}
  2259. </if>
  2260. </where>
  2261. </select>
  2262. <select id="partInformationSearchAny" resultType="com.spring.modules.part.vo.PartInformationVo">
  2263. SELECT
  2264. site,
  2265. part_no,
  2266. part_desc,
  2267. spec,
  2268. part_type_db,
  2269. part_type,
  2270. family_id,
  2271. dbo.get_family_name(site, family_id) as familyName,
  2272. group_id,
  2273. dbo.get_group_name(site, group_id) as groupName,
  2274. um_id,
  2275. dbo.get_um_name(um_id) as umName,
  2276. weight_net,
  2277. uom_for_weight_net,
  2278. volume_net,
  2279. uom_for_volume_net,
  2280. lot_tracking_code,
  2281. active,
  2282. case when active = 'Y' then '启用' when active = 'N' then '停用' else '' end as activeDesc,
  2283. product_group_id1,
  2284. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  2285. product_group_id2,
  2286. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  2287. product_group_id3,
  2288. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  2289. product_group_id4,
  2290. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  2291. comm_group3,
  2292. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  2293. erp_part_no,
  2294. code_no,
  2295. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  2296. manufacturer_id,
  2297. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  2298. agent_id,
  2299. dbo.split_agent_id(site, agent_id) as agentName,
  2300. type_designation,
  2301. hazard_code,
  2302. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  2303. asset_class,
  2304. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  2305. dim_quality,
  2306. abc_class,
  2307. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  2308. frequency_class,
  2309. lifecycle_stage,
  2310. country_of_origin,
  2311. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  2312. manufacturing_lead_time,
  2313. expected_lead_time,
  2314. region_of_origin,
  2315. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  2316. customs_stat_no,
  2317. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  2318. durability_day,
  2319. intrastat_conv_factor,
  2320. part_status,
  2321. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  2322. configuration_id,
  2323. estimated_material_cost,
  2324. inventory_valuation_method,
  2325. part_cost_group_id,
  2326. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  2327. inventory_part_cost_level,
  2328. invoice_consideration,
  2329. zero_cost_flag,
  2330. planning_method,
  2331. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  2332. safety_stock,
  2333. min_order_qty,
  2334. max_order_qty,
  2335. mul_order_qty,
  2336. safety_lead_time,
  2337. shrinkage_fac,
  2338. std_order_qty,
  2339. cum_lead_time,
  2340. back_flush_part,
  2341. by_prod_as_supply_in_mrp_db,
  2342. unprotected_lead_time,
  2343. issue_type,
  2344. mrp_control_flag_db,
  2345. fixed_lead_time_day,
  2346. over_reporting,
  2347. use_theoretical_density_db,
  2348. variable_lead_time_day,
  2349. over_report_tolerance,
  2350. fixed_lead_time_hour,
  2351. density,
  2352. variable_lead_time_hour,
  2353. remark,
  2354. status,
  2355. create_date,
  2356. create_by,
  2357. update_date,
  2358. update_by,
  2359. plm_part_no,
  2360. ifs_part_no,
  2361. show_in_query_flag,
  2362. temporary_part_flag,
  2363. dbo.get_ifHas_peifang(site,part_no) as ifHasPeifang,
  2364. case when status = 'Y' then '正式物料' else '临时物料' end as statusDesc
  2365. FROM part
  2366. <if test="query.whereClause != null and query.whereClause != ''">
  2367. WHERE ${query.whereClause}
  2368. </if>
  2369. <if test="query.orderClause != null and query.orderClause != ''">
  2370. ORDER BY ${query.orderClause}
  2371. </if>
  2372. <if test="query.orderClause == null or query.orderClause == ''">
  2373. order by part_no
  2374. </if>
  2375. </select>
  2376. <select id="partAllInfoSearchAny" resultType="com.spring.modules.part.vo.PartInformationVo">
  2377. SELECT
  2378. site,
  2379. part_no,
  2380. part_desc,
  2381. spec,
  2382. part_type_db,
  2383. part_type,
  2384. family_id,
  2385. dbo.get_family_name(site, family_id) as familyName,
  2386. group_id,
  2387. dbo.get_group_name(site, group_id) as groupName,
  2388. um_id,
  2389. dbo.get_um_name(um_id) as umName,
  2390. weight_net,
  2391. uom_for_weight_net,
  2392. volume_net,
  2393. uom_for_volume_net,
  2394. lot_tracking_code,
  2395. active,
  2396. product_group_id1,
  2397. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  2398. product_group_id2,
  2399. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  2400. product_group_id3,
  2401. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  2402. product_group_id4,
  2403. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  2404. comm_group3,
  2405. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  2406. erp_part_no,
  2407. code_no,
  2408. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  2409. manufacturer_id,
  2410. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  2411. agent_id,
  2412. dbo.split_agent_id(site, agent_id) as agentName,
  2413. type_designation,
  2414. hazard_code,
  2415. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  2416. asset_class,
  2417. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  2418. dim_quality,
  2419. abc_class,
  2420. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  2421. frequency_class,
  2422. lifecycle_stage,
  2423. country_of_origin,
  2424. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  2425. manufacturing_lead_time,
  2426. expected_lead_time,
  2427. region_of_origin,
  2428. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  2429. customs_stat_no,
  2430. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  2431. durability_day,
  2432. intrastat_conv_factor,
  2433. supply_code,
  2434. part_status,
  2435. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  2436. configuration_id,
  2437. estimated_material_cost,
  2438. inventory_valuation_method,
  2439. part_cost_group_id,
  2440. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  2441. inventory_part_cost_level,
  2442. invoice_consideration,
  2443. zero_cost_flag,
  2444. planning_method,
  2445. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  2446. safety_stock,
  2447. min_order_qty,
  2448. max_order_qty,
  2449. mul_order_qty,
  2450. safety_lead_time,
  2451. shrinkage_fac,
  2452. std_order_qty,
  2453. cum_lead_time,
  2454. back_flush_part,
  2455. by_prod_as_supply_in_mrp_db,
  2456. unprotected_lead_time,
  2457. issue_type,
  2458. mrp_control_flag_db,
  2459. fixed_lead_time_day,
  2460. over_reporting,
  2461. use_theoretical_density_db,
  2462. variable_lead_time_day,
  2463. over_report_tolerance,
  2464. fixed_lead_time_hour,
  2465. density,
  2466. variable_lead_time_hour,
  2467. create_date,
  2468. create_by,
  2469. update_date,
  2470. update_by,
  2471. plm_part_no,
  2472. ifs_part_no
  2473. FROM part
  2474. <if test="query.whereClause != null and query.whereClause != ''">
  2475. WHERE ${query.whereClause}
  2476. </if>
  2477. <if test="query.orderClause != null and query.orderClause != ''">
  2478. ORDER BY ${query.orderClause}
  2479. </if>
  2480. <if test="query.orderClause == null or query.orderClause == ''">
  2481. order by part_no
  2482. </if>
  2483. </select>
  2484. <update id="updateFromPartStatusAndIfsPart">
  2485. UPDATE part
  2486. SET status = 'Y',
  2487. ifs_part_no = #{ifsPartNo},
  2488. show_in_query_flag = 'N'
  2489. WHERE site = #{site} AND part_no = #{partNo}
  2490. </update>
  2491. <select id="getProjectPartByPartNo" resultType="com.spring.modules.part.vo.PartInformationVo">
  2492. SELECT
  2493. site,
  2494. project_id,
  2495. test_part_no as partNo,
  2496. bu_no
  2497. FROM plm_project_part
  2498. WHERE site = #{site} and (test_part_no = #{partNo} or final_part_no = #{partNo})
  2499. </select>
  2500. <insert id="batchSaveProjectPart">
  2501. insert into plm_project_part
  2502. (site, project_id, test_part_no, base_no, rev_no, part_no_source, bu_no, virtual_part_no, create_date, create_by, final_part_no)
  2503. values
  2504. <foreach collection="list" item="item" index="index" separator=",">
  2505. (#{item.site}, #{item.projectId}, #{item.partNo}, #{item.baseNo}, #{item.revNo}, #{item.partNoSource}, #{item.buNo}, #{item.virtualPartNo}, getDate(), #{item.createBy}, #{item.finalPartNo})
  2506. </foreach>
  2507. </insert>
  2508. <select id="getProjectCustomerPartByPartNo" resultType="com.spring.modules.part.vo.PartInformationVo">
  2509. select
  2510. site,
  2511. customer_no,
  2512. customer_part_no
  2513. from plm_customer_part_info
  2514. where site = #{site} and part_no = #{partNo}
  2515. </select>
  2516. <insert id="batchSaveCustomerPart">
  2517. insert into plm_customer_part_info
  2518. (site, customer_no, part_no, customer_part_no, create_date, create_by)
  2519. values
  2520. <foreach collection="list" item="item" index="index" separator=",">
  2521. (#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
  2522. </foreach>
  2523. </insert>
  2524. <delete id="deleteProjectPart">
  2525. delete from plm_project_part
  2526. where site = #{site} and project_id = #{projectId} and test_part_no = #{testPartNo}
  2527. </delete>
  2528. <delete id="deleteCustomerPart">
  2529. delete from plm_customer_part_info
  2530. where site = #{site} and customer_no = #{customerNo} and part_no = #{testPartNo}
  2531. </delete>
  2532. <delete id="deletePartRevisionByPartNo">
  2533. delete from part_revision
  2534. where site = #{site} and part_no = #{partNo}
  2535. </delete>
  2536. </mapper>