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.

2699 lines
107 KiB

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