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.

2708 lines
108 KiB

3 years ago
3 years ago
1 year ago
1 year 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
3 years ago
3 years ago
1 year ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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
2 years 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
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
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.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, application_desc, product_category)
  1048. values
  1049. (#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource}, #{buNo}, #{virtualPartNo}, #{applicationDesc}, #{productCategory})
  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. b.application_desc as applicationDesc,
  1290. b.product_category as productCategory
  1291. FROM part as a
  1292. LEFT JOIN plm_project_part as b on a.site = b.site and (a.part_no = b.test_part_no or a.part_no = b.final_part_no)
  1293. LEFT JOIN plm_project_info as c on b.site = c.site and b.project_id = c.project_id
  1294. 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
  1295. where a.site = #{site} and a.part_no = #{testPartNo} and c.customer_id = #{customerId} and b.project_id = #{projectId}
  1296. </select>
  1297. <!-- 新增项目物料 -->
  1298. <insert id="saveCustomerPartInfo" parameterType="PartInformationEntity">
  1299. insert into plm_customer_part_info
  1300. (site, customer_no, part_no, customer_part_no, create_date, create_by)
  1301. values
  1302. (#{site}, #{customerNo}, #{partNo}, #{customerPartNo}, getDate(), #{createBy})
  1303. </insert>
  1304. <!-- 获取当前项目不包含的物料 -->
  1305. <select id="getProjectPartList1" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
  1306. select distinct
  1307. a.site,
  1308. a.test_part_no,
  1309. c.part_desc,
  1310. a.bu_no,
  1311. <!-- dbo.plm_get_bu_desc(a.site,a.bu_no) buDesc,-->
  1312. c.ifs_part_no as finalPartNo,
  1313. c.plm_part_no,
  1314. dbo.get_customer_part_no(a.site, a.test_part_no, #{query.customerId}, 'ProjectPart') as customer_part_no
  1315. from plm_project_part a
  1316. 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
  1317. and a.test_part_no = b.project_id and b.site = #{query.site} and b.project_id = #{query.projectId}
  1318. left join part as c on a.site = c.site and a.test_part_no = c.part_no
  1319. <!-- 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}-->
  1320. where a.site = #{query.site} and b.site is null and c.show_in_query_flag = 'Y'
  1321. and c.part_no not in
  1322. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  1323. #{item}
  1324. </foreach>
  1325. <if test = "query.partNo != null and query.partNo != ''">
  1326. AND c.part_no like #{query.partNo}
  1327. </if>
  1328. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  1329. AND c.plm_part_no like #{query.plmPartNo}
  1330. </if>
  1331. <if test = "query.finalPartNo != null and query.finalPartNo != ''">
  1332. AND c.ifs_part_no like #{query.finalPartNo}
  1333. </if>
  1334. <if test = "query.partDesc != null and query.partDesc != ''">
  1335. AND c.part_desc like #{query.partDesc}
  1336. </if>
  1337. </select>
  1338. <!-- <select id="getProjectPartList1" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">-->
  1339. <!-- SELECT DISTINCT-->
  1340. <!-- a.site,-->
  1341. <!-- a.test_part_no AS part_no,-->
  1342. <!-- c.part_desc,-->
  1343. <!-- a.bu_no,-->
  1344. <!-- dbo.plm_get_bu_desc (a.site, a.bu_no) AS buDesc,-->
  1345. <!-- c.ifs_part_no AS finalPartNo,-->
  1346. <!-- c.plm_part_no-->
  1347. <!-- FROM-->
  1348. <!-- plm_project_part a-->
  1349. <!-- LEFT JOIN plm_project_part b ON a.site = b.site-->
  1350. <!-- AND a.test_part_no = b.test_part_no-->
  1351. <!-- AND b.site = #{query.site}-->
  1352. <!-- AND b.project_id = #{query.projectId}-->
  1353. <!-- LEFT JOIN part c ON a.site = c.site-->
  1354. <!-- AND a.test_part_no = c.part_no-->
  1355. <!-- where b.test_part_no IS NULL and c.show_in_query_flag = 'Y'-->
  1356. <!-- 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})-->
  1357. <!-- <if test = "query.partNo != null and query.partNo != ''">-->
  1358. <!-- AND c.part_no like #{query.partNo}-->
  1359. <!-- </if>-->
  1360. <!-- <if test = "query.plmPartNo != null and query.plmPartNo != ''">-->
  1361. <!-- AND c.plm_part_no like #{query.plmPartNo}-->
  1362. <!-- </if>-->
  1363. <!-- <if test = "query.finalPartNo != null and query.finalPartNo != ''">-->
  1364. <!-- AND c.ifs_part_no like #{query.finalPartNo}-->
  1365. <!-- </if>-->
  1366. <!-- <if test = "query.partDesc != null and query.partDesc != ''">-->
  1367. <!-- AND c.part_desc like #{query.partDesc}-->
  1368. <!-- </if>-->
  1369. <!-- </select>-->
  1370. <!-- 获取当前项目所包含的物料 -->
  1371. <select id="getProjectPartList2" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
  1372. SELECT
  1373. a.site,
  1374. b.part_no,
  1375. b.part_desc,
  1376. d.customer_part_no
  1377. FROM plm_project_part a
  1378. LEFT JOIN part b ON a.site = b.site and a.test_part_no = b.part_no
  1379. LEFT JOIN plm_project_info as c on a.site = c.site and a.project_id = c.project_id
  1380. 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
  1381. WHERE a.site = #{site} and a.project_id = #{projectId}
  1382. </select>
  1383. <!-- 获取当前项目不包含的物料 -->
  1384. <select id="getProjectPartList3" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
  1385. SELECT
  1386. a.site,
  1387. a.part_no,
  1388. a.part_desc,
  1389. a.ifs_part_no as finalPartNo,
  1390. a.status,
  1391. a.temporary_part_flag,
  1392. a.show_in_query_flag,
  1393. a.plm_part_no,
  1394. d.customer_part_no
  1395. FROM part as a
  1396. left join plm_project_part as b on a.site = b.site and a.plm_part_no = b.test_part_no and b.project_id = #{query.projectId}
  1397. left join plm_project_part as c on a.site = c.site and a.ifs_part_no = c.test_part_no and b.project_id = #{query.projectId}
  1398. left join plm_customer_part_info as d on a.site = d.site and d.customer_no = #{query.customerId}
  1399. and (d.part_no = a.ifs_part_no or d.part_no = a.plm_part_no)
  1400. where a.site = #{query.site}
  1401. <!-- and a.active = 'Y'-->
  1402. and a.show_in_query_flag = 'Y'
  1403. and b.test_part_no is null
  1404. and c.test_part_no is null
  1405. and a.part_no not in
  1406. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  1407. #{item}
  1408. </foreach>
  1409. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  1410. AND a.plm_part_no like #{query.plmPartNo}
  1411. </if>
  1412. <if test = "query.finalPartNo != null and query.finalPartNo != ''">
  1413. AND a.ifs_part_no like #{query.finalPartNo}
  1414. </if>
  1415. <if test = "query.partDesc != null and query.partDesc != ''">
  1416. AND a.part_desc like #{query.partDesc}
  1417. </if>
  1418. </select>
  1419. <!-- 新增项目物料 -->
  1420. <insert id="addProjectPart">
  1421. insert into plm_project_part
  1422. (site, project_id, test_part_no, create_date, create_by, part_no_source, bu_no, final_part_no, virtual_part_no, application_desc, product_category)
  1423. VALUES
  1424. <foreach collection="list" item="item" index="index" separator=",">
  1425. (#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource}, #{item.buNo}, #{item.finalPartNo}, #{item.virtualPartNo}, #{item.applicationDesc}, #{item.productCategory})
  1426. </foreach>
  1427. </insert>
  1428. <!-- 新增项目物料 -->
  1429. <insert id="addCustomerPartInfo">
  1430. insert into plm_customer_part_info
  1431. (site, customer_no, part_no, customer_part_no, create_date, create_by) VALUES
  1432. <foreach collection="list" item="item" index="index" separator=",">
  1433. (#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
  1434. </foreach>
  1435. </insert>
  1436. <!-- 获取当前项目所包含的物料 -->
  1437. <select id="getChangeRecordByPartNo" resultType="com.spring.modules.change.vo.ChangeRequestVo" parameterType="PlmProjectPartData">
  1438. SELECT
  1439. a.site,
  1440. a.change_no,
  1441. a.applicant_id,
  1442. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  1443. u.department_no as applicationDepartmentId,
  1444. dbo.get_department_name(a.site, u.department_no) as applicationDepartmentName,
  1445. a.apply_date,
  1446. a.ecn_type,
  1447. a.change_impact,
  1448. a.change_impact_desc,
  1449. a.ecn_stage,
  1450. a.change_type,
  1451. a.tp_engineer_id,
  1452. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  1453. a.change_phase_in_date,
  1454. a.df_is_product,
  1455. a.printing,
  1456. a.manufacturing_cost_is_change,
  1457. a.change_request_desc,
  1458. a.is_re_quote,
  1459. a.ul_certification_requirements,
  1460. a.ul_continue_to_meet_demand,
  1461. a.gp_certification_requirements,
  1462. a.gp_continue_to_meet_demand,
  1463. a.create_date,
  1464. a.create_by,
  1465. a.update_date,
  1466. a.update_by,
  1467. a.industrial_engineer_id,
  1468. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  1469. a.change_status,
  1470. a.cqc_operator_id,
  1471. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  1472. a.fai_operator_id,
  1473. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  1474. d.node_id,
  1475. d.node_name,
  1476. d.create_by as createBy2
  1477. FROM plm_change_request as a
  1478. LEFT JOIN sys_user as u on a.site = u.site and a.applicant_id = u.username
  1479. LEFT JOIN plm_change_request_detail as b on a.site = b.site and a.change_no = b.change_no
  1480. LEFT JOIN plm_project_part as c on b.site = c.site and b.part_no = c.final_part_no
  1481. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
  1482. 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
  1483. WHERE a.site = #{site} and c.project_id = #{projectId}
  1484. </select>
  1485. <!-- 获取当前项目所包含的物料 -->
  1486. <select id="getChangeRecordByPartNo2" resultType="com.spring.modules.change.vo.ChangeRequestVo" parameterType="PlmProjectPartData">
  1487. SELECT
  1488. a.site,
  1489. a.change_no,
  1490. a.applicant_id,
  1491. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  1492. u.department_no as applicationDepartmentId,
  1493. dbo.get_department_name(a.site, u.department_no) as applicationDepartmentName,
  1494. a.apply_date,
  1495. a.ecn_type,
  1496. a.change_impact,
  1497. a.change_impact_desc,
  1498. a.ecn_stage,
  1499. a.change_type,
  1500. a.tp_engineer_id,
  1501. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  1502. a.change_phase_in_date,
  1503. a.df_is_product,
  1504. a.printing,
  1505. a.manufacturing_cost_is_change,
  1506. a.change_request_desc,
  1507. a.is_re_quote,
  1508. a.ul_certification_requirements,
  1509. a.ul_continue_to_meet_demand,
  1510. a.gp_certification_requirements,
  1511. a.gp_continue_to_meet_demand,
  1512. a.create_date,
  1513. a.create_by,
  1514. a.update_date,
  1515. a.update_by,
  1516. a.industrial_engineer_id,
  1517. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  1518. a.change_status,
  1519. a.cqc_operator_id,
  1520. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  1521. a.fai_operator_id,
  1522. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  1523. d.node_id,
  1524. d.node_name,
  1525. d.create_by as createBy2
  1526. FROM plm_change_request as a
  1527. LEFT JOIN sys_user as u on a.site = u.site and a.applicant_id = u.username
  1528. LEFT JOIN plm_change_request_detail as b on a.site = b.site and a.change_no = b.change_no
  1529. LEFT JOIN plm_project_part as c on b.site = c.site and b.part_no = c.final_part_no
  1530. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
  1531. 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
  1532. WHERE a.site = #{site} and c.project_id = #{projectId} and c.final_part_no = #{finalPartNo}
  1533. </select>
  1534. <!-- 查询Bom替代 -->
  1535. <select id="queryBomAlternativeList" resultType="com.spring.modules.part.vo.BomDetailVo" parameterType="PartInformationEntity">
  1536. SELECT
  1537. a.site,
  1538. a.part_no,
  1539. a.alternative_no,
  1540. a.alternative_description,
  1541. a.bom_type,
  1542. a.eng_chg_level,
  1543. a.min_lot_qty,
  1544. a.default_flag,
  1545. a.note_text,
  1546. a.create_date,
  1547. a.create_by,
  1548. a.update_date,
  1549. a.update_by,
  1550. a.status,
  1551. a.official_flag,
  1552. b.eff_phase_in_date,
  1553. b.eff_phase_out_date,
  1554. b.note_text as bomHeaderNoteText,
  1555. b.eng_revision
  1556. FROM plm_bom_detail as a
  1557. 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
  1558. WHERE a.site = #{site} and a.part_no = #{partNo}
  1559. </select>
  1560. <!-- 查询Bom替代 -->
  1561. <select id="queryRecipeAlternativeList" resultType="com.spring.modules.part.vo.RecipeDetailVo" parameterType="PartInformationEntity">
  1562. SELECT
  1563. a.site,
  1564. a.part_no,
  1565. a.alternative_no,
  1566. a.alternative_description,
  1567. a.bom_type,
  1568. a.eng_chg_level,
  1569. a.min_lot_qty,
  1570. a.default_flag,
  1571. a.note_text,
  1572. a.create_date,
  1573. a.create_by,
  1574. a.update_date,
  1575. a.update_by,
  1576. a.status,
  1577. a.official_flag,
  1578. b.eff_phase_in_date,
  1579. b.eff_phase_out_date,
  1580. b.note_text as bomHeaderNoteText,
  1581. b.eng_revision
  1582. FROM plm_recipe_detail as a
  1583. 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
  1584. WHERE a.site = #{site} and a.part_no = #{partNo}
  1585. </select>
  1586. <!-- 查询Routing替代 -->
  1587. <select id="queryRoutingAlternativeList" resultType="RoutingDetailEntity" parameterType="PartInformationEntity">
  1588. SELECT
  1589. a.site,
  1590. a.part_no,
  1591. a.routing_type,
  1592. a.routing_revision,
  1593. a.alternative_no,
  1594. a.alternative_description,
  1595. a.rout_template_id,
  1596. a.plan_date,
  1597. a.fixed_lead_time_day,
  1598. a.fixed_lead_time_hour,
  1599. a.variable_lead_time_day,
  1600. a.variable_lead_time_hour,
  1601. a.for_std_lot_by_day,
  1602. a.for_lot_by_day,
  1603. a.min_lot_qty,
  1604. a.note_text,
  1605. a.status,
  1606. a.official_flag
  1607. FROM plm_routing_detail as a
  1608. 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
  1609. where a.site = #{site} and a.part_no = #{partNo}
  1610. </select>
  1611. <!-- &lt;!&ndash; 获取 component 对象&ndash;&gt;-->
  1612. <!-- <select id="getComponentPart" parameterType="com.spring.modules.part.vo.BomDetailVo" resultType="com.spring.modules.part.vo.PartInformationVo">-->
  1613. <!-- SELECT-->
  1614. <!-- a.site,-->
  1615. <!-- a.component_part as partNo,-->
  1616. <!-- a.eng_chg_level,-->
  1617. <!-- a.bom_type,-->
  1618. <!-- a.alternative_no,-->
  1619. <!-- b.alternative_description,-->
  1620. <!-- d.status-->
  1621. <!-- FROM plm_bom_component as a-->
  1622. <!-- 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-->
  1623. <!-- 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-->
  1624. <!-- LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no-->
  1625. <!-- WHERE c.site = #{site} and c.part_no = #{partNo} and c.bom_type = 'Manufacturing' and c.eff_phase_out_date is null-->
  1626. <!-- </select>-->
  1627. <!-- 获取 component 对象-->
  1628. <select id="getComponentPart" parameterType="com.spring.modules.part.vo.BomDetailVo" resultType="com.spring.modules.part.vo.PartInformationVo">
  1629. SELECT
  1630. a.site,
  1631. a.component_part as partNo,
  1632. a.eng_chg_level,
  1633. a.bom_type,
  1634. a.alternative_no,
  1635. b.alternative_description,
  1636. d.status
  1637. FROM plm_bom_component as a
  1638. 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
  1639. LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no
  1640. 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}
  1641. </select>
  1642. <select id="getPartRevision" parameterType="PartInformationEntity" resultType="PartRevisionEntity">
  1643. SELECT
  1644. site,
  1645. part_no,
  1646. eng_chg_level,
  1647. eff_phase_in_date,
  1648. eff_phase_out_date,
  1649. revision_text,
  1650. product_status,
  1651. repair_status,
  1652. eng_revision,
  1653. create_date,
  1654. create_by,
  1655. update_date,
  1656. update_by
  1657. FROM part_revision
  1658. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = 1
  1659. </select>
  1660. <!-- 根据物料编码删除 BOM Header -->
  1661. <delete id="deleteBomHeaderByPartNo" parameterType="PartInformationEntity">
  1662. delete from plm_bom_header
  1663. where site = #{site} and part_no = #{partNo}
  1664. </delete>
  1665. <!-- 根据物料编码删除 BOM Detail -->
  1666. <delete id="deleteBomDetailByPartNo" parameterType="PartInformationEntity">
  1667. delete from plm_bom_detail
  1668. where site = #{site} and part_no = #{partNo}
  1669. </delete>
  1670. <!-- 根据物料编码删除 BOM Component -->
  1671. <delete id="deleteBomComponentByPartNo" parameterType="PartInformationEntity">
  1672. delete from plm_bom_component
  1673. where site = #{site} and part_no = #{partNo}
  1674. </delete>
  1675. <!-- 根据物料编码删除 Recipe Header -->
  1676. <delete id="deleteRecipeHeaderByPartNo" parameterType="PartInformationEntity">
  1677. delete from plm_recipe_header
  1678. where site = #{site} and part_no = #{partNo}
  1679. </delete>
  1680. <!-- 根据物料编码删除 Recipe Detail -->
  1681. <delete id="deleteRecipeDetailByPartNo" parameterType="PartInformationEntity">
  1682. delete from plm_recipe_detail
  1683. where site = #{site} and part_no = #{partNo}
  1684. </delete>
  1685. <!-- 根据物料编码删除 Recipe Component -->
  1686. <delete id="deleteRecipeComponentByPartNo" parameterType="PartInformationEntity">
  1687. delete from plm_recipe_component
  1688. where site = #{site} and part_no = #{partNo}
  1689. </delete>
  1690. <!-- 根据物料编码删除 BOM 副产品成本分配 -->
  1691. <delete id="deleteBomManufStructCostDistribByPartNo" parameterType="PartInformationEntity">
  1692. delete from plm_bom_manuf_struct_cost_distrib
  1693. where site = #{site} and part_no = #{partNo}
  1694. </delete>
  1695. <!-- 根据物料编码删除 Routing Header -->
  1696. <delete id="deleteRoutingHeaderByPartNo" parameterType="PartInformationEntity">
  1697. delete from plm_routing_header
  1698. where site = #{site} and part_no = #{partNo}
  1699. </delete>
  1700. <!-- 根据物料编码删除 Routing Detail -->
  1701. <delete id="deleteRoutingDetailByPartNo" parameterType="PartInformationEntity">
  1702. delete from plm_routing_detail
  1703. where site = #{site} and part_no = #{partNo}
  1704. </delete>
  1705. <!-- 根据物料编码删除 Routing Component -->
  1706. <delete id="deleteRoutingComponentByPartNo" parameterType="PartInformationEntity">
  1707. delete from plm_routing_component
  1708. where site = #{site} and part_no = #{partNo}
  1709. </delete>
  1710. <!-- 根据物料编码删除 Routing Tool -->
  1711. <delete id="deleteRoutingToolByPartNo" parameterType="PartInformationEntity">
  1712. delete from routing_tool
  1713. where site = #{site} and part_no = #{partNo}
  1714. </delete>
  1715. <!-- 根据物料编码删除 Routing GuideLine -->
  1716. <delete id="deleteRoutingGuideLineByPartNo" parameterType="PartInformationEntity">
  1717. delete from plm_routing_work_guide
  1718. where site = #{site} and part_no = #{partNo}
  1719. </delete>
  1720. <!-- 新增物料版本 -->
  1721. <insert id="saveRevisions">
  1722. insert into part_revision
  1723. (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
  1724. <foreach collection="list" item="item" index="index" separator=",">
  1725. (#{item.site}, #{item.partNo}, #{item.engChgLevel},CONVERT(datetime2, #{item.effPhaseInDate, jdbcType=TIMESTAMP}),
  1726. CONVERT(datetime2, #{item.effPhaseOutDate, jdbcType=TIMESTAMP}), #{item.revisionText}, #{item.productStatus}, #{item.repairStatus}, #{item.engRevision}, getDate(), #{item.createBy})
  1727. </foreach>
  1728. </insert>
  1729. <!-- 创建 IFS 物料的 BOM 替代 -->
  1730. <insert id="saveIfsBomAlternatives">
  1731. insert into plm_bom_detail
  1732. (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
  1733. <foreach collection="list" item="item" index="index" separator=",">
  1734. (#{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})
  1735. </foreach>
  1736. </insert>
  1737. <!-- 创建 IFS 物料的 Recipe 替代 -->
  1738. <insert id="saveIfsRecipeAlternatives">
  1739. insert into plm_recipe_detail
  1740. (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
  1741. <foreach collection="list" item="item" index="index" separator=",">
  1742. (#{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})
  1743. </foreach>
  1744. </insert>
  1745. <!-- 创建 IFS 物料的 Routing 替代 -->
  1746. <insert id="saveIfsRoutingAlternatives">
  1747. insert into plm_routing_detail
  1748. (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
  1749. <foreach collection="list" item="item" index="index" separator=",">
  1750. (#{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})
  1751. </foreach>
  1752. </insert>
  1753. <!-- 查询代理商列表 -->
  1754. <select id="getPartAgents" resultType="com.spring.modules.part.vo.AgentInformationVo" parameterType="PartInformationEntity">
  1755. SELECT
  1756. site,
  1757. part_no,
  1758. agent_id
  1759. FROM part_agent
  1760. where site = #{site} and part_no = #{partNo}
  1761. </select>
  1762. <!-- 查询制造商列表 -->
  1763. <select id="getPartManufacturers" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="PartInformationEntity">
  1764. SELECT
  1765. site,
  1766. part_no,
  1767. manufacturer_id
  1768. FROM part_manufacturer
  1769. where site = #{site} and part_no = #{partNo}
  1770. </select>
  1771. <!-- 查询默认库位列表 -->
  1772. <select id="getPartDefaultLocations" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="PartInformationEntity">
  1773. SELECT
  1774. site,
  1775. part_no,
  1776. location_id
  1777. FROM plm_part_location
  1778. where site = #{site} and part_no = #{partNo}
  1779. </select>
  1780. <!-- 查询文件列表 -->
  1781. <select id="getPartFiles" resultType="SysOssEntity" parameterType="PartInformationEntity">
  1782. SELECT
  1783. id,
  1784. url,
  1785. create_date,
  1786. file_name,
  1787. new_file_name,
  1788. create_by,
  1789. order_ref1,
  1790. order_ref2,
  1791. order_ref3,
  1792. file_type,
  1793. file_suffix,
  1794. file_type_code,
  1795. file_remark
  1796. FROM sys_oss
  1797. where order_ref1 = #{site} and order_ref2 = #{plmPartNo} and order_ref3 = 'inventoryPart'
  1798. </select>
  1799. <!-- 新增物料代理商 -->
  1800. <insert id="savePartAgent">
  1801. insert into part_agent
  1802. (site, part_no, agent_id) VALUES
  1803. <foreach collection="list" item="item" index="index" separator=",">
  1804. (#{item.site}, #{item.partNo}, #{item.agentId})
  1805. </foreach>
  1806. </insert>
  1807. <!-- 新增物料制造商 -->
  1808. <insert id="savePartManufacturer">
  1809. insert into part_manufacturer
  1810. (site, part_no, manufacturer_id) VALUES
  1811. <foreach collection="list" item="item" index="index" separator=",">
  1812. (#{item.site}, #{item.partNo}, #{item.manufacturerId})
  1813. </foreach>
  1814. </insert>
  1815. <!-- 新增物料制造商 -->
  1816. <insert id="savePartDefaultLocation">
  1817. insert into plm_part_location
  1818. (site, part_no, location_id) VALUES
  1819. <foreach collection="list" item="item" index="index" separator=",">
  1820. (#{item.site}, #{item.partNo}, #{item.locationId})
  1821. </foreach>
  1822. </insert>
  1823. <!-- 新增物料文件 -->
  1824. <insert id="savePartFile">
  1825. insert into sys_oss
  1826. (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
  1827. <foreach collection="list" item="item" index="index" separator=",">
  1828. (#{item.url}, #{item.createDate}, #{item.fileName}, #{item.newFileName}, #{item.createBy}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.fileType}, #{item.fileSuffix}, #{item.fileTypeCode}, #{item.fileRemark})
  1829. </foreach>
  1830. </insert>
  1831. <!-- 下一个物料编码 -->
  1832. <select id="getNextPartNo2" resultType="string" parameterType="com.spring.modules.part.vo.PartInformationVo">
  1833. select dbo.get_next_part_code(#{ifsPartNo})
  1834. </select>
  1835. <select id="checkPartLocationType" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  1836. SELECT
  1837. a.site,
  1838. a.part_no,
  1839. a.location_id,
  1840. b.location_type
  1841. FROM plm_part_location as a
  1842. left join location as b on a.site = b.site and a.location_id = b.location_id
  1843. WHERE a.part_no = #{partNo} and a.site = #{site} and b.location_type = #{locationType}
  1844. </select>
  1845. <select id="checkPartLocationType2" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
  1846. SELECT
  1847. a.site,
  1848. a.part_no,
  1849. a.location_id,
  1850. b.location_type
  1851. FROM plm_part_location as a
  1852. left join location as b on a.site = b.site and a.location_id = b.location_id
  1853. WHERE a.part_no = #{partNo} and a.site = #{site} and b.location_type in ('Picking', 'Floor stock', 'Production line')
  1854. </select>
  1855. <!-- 修改物料版本 -->
  1856. <update id="updateRevisionOutDate">
  1857. UPDATE part_revision
  1858. SET eff_phase_out_date = #{effPhaseOutDate}
  1859. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  1860. </update>
  1861. <select id="getModelHeader" resultType="PartSubPropertiesValueHeaderData">
  1862. SELECT
  1863. #{ifsPartNo} as partNo,
  1864. Site,
  1865. CodeNo,
  1866. SubCodeSeqNo,
  1867. SubCodeDesc,
  1868. RecordType
  1869. FROM PartSubPropertiesValueHeader
  1870. where site = #{site} and RecordType = #{recordType} and PartNo = #{partNo} and CodeNo = #{codeNo}
  1871. </select>
  1872. <select id="getModelDetail" resultType="PartSubPropertiesValueData">
  1873. SELECT
  1874. #{ifsPartNo} as partNo,
  1875. Site,
  1876. CodeNo,
  1877. SubCodeSeqNo,
  1878. SubCodeDesc,
  1879. ItemNo,
  1880. PropertiesItemNo,
  1881. TextValue,
  1882. NumValue,
  1883. RecordType,
  1884. order_id
  1885. FROM PartSubPropertiesValue
  1886. where site = #{site} and RecordType = #{recordType} and PartNo = #{partNo} and CodeNo = #{codeNo}
  1887. </select>
  1888. <select id="getPartPropertyList" resultType="PartIfsInventoryProperty">
  1889. SELECT
  1890. a.PartNo as partNo,
  1891. a.Site as contract,
  1892. a.CodeNo as engAttribute,
  1893. a.PropertiesItemNo as characteristicCode,
  1894. isnull(a.TextValue, '') as attrValueAlpha,
  1895. ISNULL(CONVERT(VARCHAR(20), a.NumValue, 1), '') as attrValueNumeric,
  1896. case when b.ValueType_DB = 'T' then 'Alpha' when b.ValueType_DB = 'N' then 'Numeric' else '' end as characteristicType,
  1897. '' as unitMeas
  1898. FROM PartSubPropertiesValue as a
  1899. left join plm_properties_item as b on a.site = b.site and a.PropertiesItemNo = b.ItemNo and a.RecordType = b.ItemType
  1900. where a.site = #{site} and a.RecordType = #{recordType} and a.PartNo = #{partNo} and a.CodeNo = #{codeNo}
  1901. </select>
  1902. <select id="getMasterPartPropertyList" resultType="PartIfsCatalogProperty">
  1903. SELECT
  1904. 'PartCatalog' as luName,
  1905. ('PART_NO=' + a.PartNo + '^') as keyRef,
  1906. a.CodeNo as technicalClass,
  1907. a.PropertiesItemNo as attribute,
  1908. isnull(a.TextValue, '') as valueText,
  1909. ISNULL(CONVERT(VARCHAR(20), a.NumValue, 1), '') as valueNo,
  1910. case when b.ValueType_DB = 'T' then 'Alpha' when b.ValueType_DB = 'N' then 'Numeric' else '' end as attributeType,
  1911. '' as lowerLimit,
  1912. '' as upperLimit,
  1913. '' as info
  1914. FROM PartSubPropertiesValue as a
  1915. left join plm_properties_item as b on a.site = b.site and a.PropertiesItemNo = b.ItemNo and a.RecordType = b.ItemType
  1916. where a.site = #{site} and a.PartNo = #{partNo} and a.CodeNo = #{codeNo} and a.RecordType = #{recordType}
  1917. </select>
  1918. <insert id="savePartModelHeaders">
  1919. insert into PartSubPropertiesValueHeader
  1920. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType) VALUES
  1921. <foreach collection="list" item="item" index="index" separator=",">
  1922. (#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.recordType})
  1923. </foreach>
  1924. </insert>
  1925. <insert id="savePartModelDetails">
  1926. insert into PartSubPropertiesValue
  1927. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id) VALUES
  1928. <foreach collection="list" item="item" index="index" separator=",">
  1929. (#{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})
  1930. </foreach>
  1931. </insert>
  1932. <select id="queryPart" resultType="com.spring.modules.part.entity.PartInformationEntity">
  1933. select top 100 site,
  1934. part_no,
  1935. part_desc,
  1936. spec,
  1937. part_type_db,
  1938. dbo.get_part_unitCost(site, part_no) as standardCost,
  1939. status,
  1940. configuration_id,
  1941. um_id
  1942. from part
  1943. where site = #{site}
  1944. and part_no = #{partNo}
  1945. and active = 'Y'
  1946. and show_in_query_flag = 'Y'
  1947. </select>
  1948. <!-- 单独的方法 修改项目物料的BU、应用描述、产品类别 -->
  1949. <update id="updateProjectPartBuNo" parameterType="com.spring.modules.part.vo.PartInformationVo">
  1950. UPDATE plm_project_part
  1951. SET bu_no = #{buNo},
  1952. application_desc = #{applicationDesc},
  1953. product_category = #{productCategory},
  1954. update_date = getDate(),
  1955. update_by = #{updateBy}
  1956. WHERE site = #{site}
  1957. AND project_id = #{projectId}
  1958. AND (test_part_no = #{partNo} OR final_part_no = #{partNo})
  1959. </update>
  1960. <!-- 修改项目物料的客户料号相关信息 -->
  1961. <update id="updateProjectCustomerPartNo" parameterType="PartInformationEntity">
  1962. UPDATE plm_customer_part_info
  1963. SET customer_part_no = #{customerPartNo}
  1964. WHERE site = #{site} AND customer_no = #{customerNo} AND part_no = #{partNo}
  1965. </update>
  1966. <select id="queryPartByPartNo" resultType="com.spring.modules.part.entity.PartInformationEntity">
  1967. select p.site,
  1968. p.part_no,
  1969. p.part_desc,
  1970. p.spec,
  1971. p.part_type_db,
  1972. dbo.get_part_unitCost(p.site, p.part_no) as standardCost,
  1973. p.status,
  1974. p.um_id,
  1975. p.ifs_part_no,
  1976. p.configuration_id
  1977. from part p
  1978. where active = 'Y'
  1979. and show_in_query_flag = 'Y'
  1980. <if test="params.site != null and params.site != ''">
  1981. and p.site = #{params.site}
  1982. </if>
  1983. <if test="params.partNo != null and params.partNo != ''">
  1984. and p.part_no like #{params.partNo}
  1985. </if>
  1986. <if test="params.partDesc != null and params.partDesc != ''">
  1987. and p.part_desc like #{params.partDesc}
  1988. </if>
  1989. <if test="params.ifsPartNo != null and params.ifsPartNo != ''">
  1990. and p.ifs_part_no like #{params.ifsPartNo}
  1991. </if>
  1992. </select>
  1993. <!-- 查询文件ID -->
  1994. <select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
  1995. SELECT id, file_name
  1996. FROM sys_oss
  1997. WHERE order_ref2 = #{orderRef2}
  1998. </select>
  1999. <select id="getFileData" resultType="SysOssEntity">
  2000. select
  2001. url,
  2002. file_name,
  2003. new_file_name
  2004. from sys_oss
  2005. where id = #{id}
  2006. </select>
  2007. <select id="getTblBaseData" resultType="TblBaseDataEntity">
  2008. select
  2009. id,
  2010. site,
  2011. first_type,
  2012. second_type,
  2013. base_data,
  2014. base_desc,
  2015. status,
  2016. sort_no,
  2017. remark
  2018. from tbl_base_data
  2019. where first_type = #{firstType}
  2020. </select>
  2021. <delete id="delProjectPartByPartNo">
  2022. delete from plm_project_part
  2023. where site = #{site} and test_part_no = #{partNo}
  2024. </delete>
  2025. <select id="getMaxPartRevision" resultType="com.spring.modules.part.vo.PartRevisionVo">
  2026. SELECT
  2027. site,
  2028. part_no,
  2029. eng_chg_level,
  2030. eff_phase_in_date,
  2031. eff_phase_out_date,
  2032. revision_text,
  2033. product_status,
  2034. repair_status,
  2035. eng_revision
  2036. FROM part_revision
  2037. WHERE part_no = #{partNo} and site = #{site}
  2038. order by eng_chg_level desc
  2039. </select>
  2040. <!-- 查询物料的revision列表 -->
  2041. <select id="queryPartUnitCostList" resultType="InventoryPartUnitCostSumEntity" parameterType="InventoryPartUnitCostSumEntity">
  2042. SELECT
  2043. site,
  2044. part_no,
  2045. configuration_id,
  2046. inventory_value,
  2047. lot_batch_no,
  2048. serial_no
  2049. FROM inventory_part_unit_cost_sum
  2050. WHERE site = #{site} and part_no = #{partNo} and configuration_id = #{configurationId}
  2051. </select>
  2052. <select id="getMaxUnitValueRowVersion" resultType="java.lang.String">
  2053. select
  2054. isnull(max(ifs_row_version),'')
  2055. from inventory_part_unit_cost_sum
  2056. </select>
  2057. <select id="getPLMUnitValues" resultType="InventoryPartUnitCostSumEntity">
  2058. select
  2059. site,
  2060. part_no,
  2061. configuration_id,
  2062. inventory_value,
  2063. lot_batch_no,
  2064. serial_no,
  2065. ifs_row_version
  2066. from inventory_part_unit_cost_sum
  2067. where site in
  2068. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  2069. #{item}
  2070. </foreach>
  2071. </select>
  2072. <!-- 批量新增 -->
  2073. <insert id="syncSaveUnitValue">
  2074. INSERT INTO inventory_part_unit_cost_sum (site, part_no, configuration_id, inventory_value, lot_batch_no, serial_no, ifs_row_version)
  2075. VALUES
  2076. <foreach item="item" collection="list" separator=",">
  2077. (#{item.site}, #{item.partNo}, #{item.configurationId}, #{item.inventoryValue}, #{item.lotBatchNo}, #{item.serialNo}, #{item.ifsRowVersion})
  2078. </foreach>
  2079. </insert>
  2080. <!-- 批量更新 -->
  2081. <update id="syncUpdateUnitValue" parameterType="java.util.List">
  2082. UPDATE inventory_part_unit_cost_sum
  2083. SET
  2084. inventory_value = CASE
  2085. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2086. WHEN part_no = #{item.partNo} THEN #{item.inventoryValue}
  2087. </foreach>
  2088. ELSE inventory_value
  2089. END,
  2090. lot_batch_no = CASE
  2091. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2092. WHEN part_no = #{item.partNo} THEN #{item.lotBatchNo}
  2093. </foreach>
  2094. ELSE lot_batch_no
  2095. END,
  2096. serial_no = CASE
  2097. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2098. WHEN part_no = #{item.partNo} THEN #{item.serialNo}
  2099. </foreach>
  2100. ELSE serial_no
  2101. END,
  2102. ifs_row_version = CASE
  2103. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  2104. WHEN part_no = #{item.partNo} THEN #{item.ifsRowVersion}
  2105. </foreach>
  2106. ELSE ifs_row_version
  2107. END
  2108. WHERE part_no IN
  2109. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  2110. #{item.partNo}
  2111. </foreach>
  2112. AND site = #{list[0].site}
  2113. </update>
  2114. <select id="getItemListByCodeNo" resultType="PartSubPropertiesValueData">
  2115. select
  2116. #{site} as site,
  2117. #{codeNo} as CodeNo,
  2118. 1 as SubCodeSeqNo,
  2119. a.Code_Desc as SubCodeDesc,
  2120. b.seq_No as ItemNo,
  2121. b.properties_item_no as PropertiesItemNo,
  2122. case when c.ValueType_DB = 'T' then c.DefaultValue else null end as TextValue,
  2123. case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end as NumValue,
  2124. #{recordType} as RecordType,
  2125. c.ItemDesc as ItemDesc,
  2126. c.ValueType,
  2127. c.ValueType_DB,
  2128. c.ValueChooseFlag
  2129. from plm_properties_model_header a
  2130. 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
  2131. left join plm_properties_item c on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
  2132. where a.Code_No = #{codeNo} and a.site = #{site} AND B.SITE IS NOT NULL AND A.function_type = #{recordType}
  2133. </select>
  2134. <!-- 获取当前项目不包含的物料 -->
  2135. <select id="getItemExclusionAlreadyExists" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
  2136. SELECT
  2137. site,
  2138. ItemNo as PropertiesItemNo,
  2139. ItemDesc,
  2140. ValueType,
  2141. ValueType_DB,
  2142. ValueChooseFlag,
  2143. itemType as RecordType
  2144. FROM plm_properties_item
  2145. where site = #{query.site} and itemType = #{query.recordType}
  2146. and ItemNo not in
  2147. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  2148. #{item}
  2149. </foreach>
  2150. <if test = "query.propertiesItemNo != null and query.propertiesItemNo != ''">
  2151. AND ItemNo like #{query.propertiesItemNo}
  2152. </if>
  2153. <if test = "query.itemDesc != null and query.itemDesc != ''">
  2154. AND ItemDesc like #{query.itemDesc}
  2155. </if>
  2156. </select>
  2157. <select id="getProjectCustomerPartNo" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.vo.PartInformationVo">
  2158. select
  2159. site,
  2160. customer_no,
  2161. part_no,
  2162. customer_part_no,
  2163. create_date,
  2164. create_by,
  2165. update_date,
  2166. update_by
  2167. from plm_customer_part_info
  2168. where site = #{site} and part_no = #{partNo} and customer_no = #{customerNo}
  2169. </select>
  2170. <!-- 新增BOM header -->
  2171. <insert id="saveBomHeaders">
  2172. insert into plm_bom_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. <!-- 新增Recipe header -->
  2179. <insert id="saveRecipeHeaders">
  2180. insert into plm_recipe_header
  2181. (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
  2182. <foreach collection="list" item="item" index="index" separator=",">
  2183. (#{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})
  2184. </foreach>
  2185. </insert>
  2186. <select id="getMasterPartModal" resultType="PartSubPropertiesValueHeaderData">
  2187. SELECT
  2188. PartNo,
  2189. Site,
  2190. CodeNo,
  2191. SubCodeSeqNo,
  2192. SubCodeDesc,
  2193. RecordType
  2194. FROM PartSubPropertiesValueHeader
  2195. where PartNo = #{partNo} and Site = #{site} and RecordType = #{recordType}
  2196. </select>
  2197. <select id="locationInformationSearch" parameterType="com.spring.modules.part.vo.LocationInformationVo" resultType="com.spring.modules.part.vo.LocationInformationVo">
  2198. SELECT
  2199. site,
  2200. location_id,
  2201. location_name,
  2202. warehouse_id,
  2203. active,
  2204. location_type
  2205. FROM location
  2206. where site = #{query.site}
  2207. <if test = "query.locationId != null and query.locationId != ''">
  2208. AND location_id like #{query.locationId}
  2209. </if>
  2210. <if test = "query.locationName != null and query.locationName != ''">
  2211. AND location_name like #{query.locationName}
  2212. </if>
  2213. <if test = "query.warehouseId != null and query.warehouseId != ''">
  2214. AND warehouse_id like #{query.warehouseId}
  2215. </if>
  2216. <if test = "query.locationType != null and query.locationType != ''">
  2217. AND location_type = #{query.locationType}
  2218. </if>
  2219. </select>
  2220. <insert id="savePartSubPropertiesValues">
  2221. insert into PartSubPropertiesValue
  2222. (site, PartNo, CodeNo, SubCodeSeqNo, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType) VALUES
  2223. <foreach collection="list" item="item" index="index" separator=",">
  2224. (#{item.site}, #{item.partNo}, #{item.codeNo}, #{item.subCodeSeqNo, jdbcType=FLOAT}, #{item.itemNo, jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue, jdbcType=FLOAT}, #{item.recordType})
  2225. </foreach>
  2226. </insert>
  2227. <select id="getUnitValuesByPartNo" resultType="com.spring.modules.part.entity.InventoryPartUnitCostSumEntity">
  2228. select
  2229. site,
  2230. part_no,
  2231. configuration_id,
  2232. inventory_value,
  2233. lot_batch_no,
  2234. serial_no,
  2235. ifs_row_version
  2236. from inventory_part_unit_cost_sum
  2237. where site = #{site} and part_no = #{partNo} and configuration_id = #{configurationId}
  2238. </select>
  2239. <select id="queryOfficialPartList" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.entity.BomAllFieldEntity">
  2240. SELECT
  2241. a.site,
  2242. a.part_no,
  2243. a.part_desc,
  2244. a.spec,
  2245. a.um_id as printUnit,
  2246. b.um_name as printUnitName,
  2247. a.part_type,
  2248. a.family_id,
  2249. c.family_name,
  2250. a.part_status,
  2251. d.part_status_desc,
  2252. a.plm_part_no,
  2253. a.ifs_part_no
  2254. FROM part as a
  2255. left join um as b on a.um_id = b.um_id
  2256. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  2257. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  2258. <where>
  2259. a.site = #{query.site} and a.active = 'Y' and a.status = 'Y'
  2260. AND a.show_in_query_flag = 'Y'
  2261. <if test = "query.partNo != null and query.partNo != ''">
  2262. AND a.part_no like #{query.partNo}
  2263. </if>
  2264. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  2265. AND a.plm_part_no like #{query.plmPartNo}
  2266. </if>
  2267. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  2268. AND a.ifs_part_no like #{query.ifsPartNo}
  2269. </if>
  2270. <if test = "query.partDesc != null and query.partDesc != ''">
  2271. AND a.part_desc like #{query.partDesc}
  2272. </if>
  2273. </where>
  2274. </select>
  2275. <select id="partInformationSearchAny" resultType="com.spring.modules.part.vo.PartInformationVo">
  2276. SELECT
  2277. site,
  2278. part_no,
  2279. part_desc,
  2280. spec,
  2281. part_type_db,
  2282. part_type,
  2283. family_id,
  2284. dbo.get_family_name(site, family_id) as familyName,
  2285. group_id,
  2286. dbo.get_group_name(site, group_id) as groupName,
  2287. um_id,
  2288. dbo.get_um_name(um_id) as umName,
  2289. weight_net,
  2290. uom_for_weight_net,
  2291. volume_net,
  2292. uom_for_volume_net,
  2293. lot_tracking_code,
  2294. active,
  2295. case when active = 'Y' then '启用' when active = 'N' then '停用' else '' end as activeDesc,
  2296. product_group_id1,
  2297. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  2298. product_group_id2,
  2299. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  2300. product_group_id3,
  2301. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  2302. product_group_id4,
  2303. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  2304. comm_group3,
  2305. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  2306. erp_part_no,
  2307. code_no,
  2308. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  2309. manufacturer_id,
  2310. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  2311. agent_id,
  2312. dbo.split_agent_id(site, agent_id) as agentName,
  2313. type_designation,
  2314. hazard_code,
  2315. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  2316. asset_class,
  2317. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  2318. dim_quality,
  2319. abc_class,
  2320. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  2321. frequency_class,
  2322. lifecycle_stage,
  2323. country_of_origin,
  2324. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  2325. manufacturing_lead_time,
  2326. expected_lead_time,
  2327. region_of_origin,
  2328. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  2329. customs_stat_no,
  2330. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  2331. durability_day,
  2332. intrastat_conv_factor,
  2333. part_status,
  2334. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  2335. configuration_id,
  2336. estimated_material_cost,
  2337. inventory_valuation_method,
  2338. part_cost_group_id,
  2339. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  2340. inventory_part_cost_level,
  2341. invoice_consideration,
  2342. zero_cost_flag,
  2343. planning_method,
  2344. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  2345. safety_stock,
  2346. min_order_qty,
  2347. max_order_qty,
  2348. mul_order_qty,
  2349. safety_lead_time,
  2350. shrinkage_fac,
  2351. std_order_qty,
  2352. cum_lead_time,
  2353. back_flush_part,
  2354. by_prod_as_supply_in_mrp_db,
  2355. unprotected_lead_time,
  2356. issue_type,
  2357. mrp_control_flag_db,
  2358. fixed_lead_time_day,
  2359. over_reporting,
  2360. use_theoretical_density_db,
  2361. variable_lead_time_day,
  2362. over_report_tolerance,
  2363. fixed_lead_time_hour,
  2364. density,
  2365. variable_lead_time_hour,
  2366. remark,
  2367. status,
  2368. create_date,
  2369. create_by,
  2370. update_date,
  2371. update_by,
  2372. plm_part_no,
  2373. ifs_part_no,
  2374. --drawing_no,
  2375. show_in_query_flag,
  2376. temporary_part_flag,
  2377. dbo.get_ifHas_peifang(site,part_no) as ifHasPeifang,
  2378. case when status = 'Y' then '正式物料' else '临时物料' end as statusDesc
  2379. FROM part
  2380. <if test="query.whereClause != null and query.whereClause != ''">
  2381. WHERE ${query.whereClause}
  2382. </if>
  2383. <if test="query.orderClause != null and query.orderClause != ''">
  2384. ORDER BY ${query.orderClause}
  2385. </if>
  2386. <if test="query.orderClause == null or query.orderClause == ''">
  2387. order by part_no
  2388. </if>
  2389. </select>
  2390. <select id="partAllInfoSearchAny" resultType="com.spring.modules.part.vo.PartInformationVo">
  2391. SELECT
  2392. site,
  2393. part_no,
  2394. part_desc,
  2395. spec,
  2396. part_type_db,
  2397. part_type,
  2398. family_id,
  2399. dbo.get_family_name(site, family_id) as familyName,
  2400. group_id,
  2401. dbo.get_group_name(site, group_id) as groupName,
  2402. um_id,
  2403. dbo.get_um_name(um_id) as umName,
  2404. weight_net,
  2405. uom_for_weight_net,
  2406. volume_net,
  2407. uom_for_volume_net,
  2408. lot_tracking_code,
  2409. active,
  2410. product_group_id1,
  2411. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  2412. product_group_id2,
  2413. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  2414. product_group_id3,
  2415. dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
  2416. product_group_id4,
  2417. dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
  2418. comm_group3,
  2419. dbo.get_product_group_name(site, comm_group3, '5') as commGroup3Desc,
  2420. erp_part_no,
  2421. code_no,
  2422. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  2423. manufacturer_id,
  2424. dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
  2425. agent_id,
  2426. dbo.split_agent_id(site, agent_id) as agentName,
  2427. type_designation,
  2428. hazard_code,
  2429. dbo.get_hazard_name(site, hazard_code) as hazardDesc,
  2430. asset_class,
  2431. dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
  2432. dim_quality,
  2433. abc_class,
  2434. dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
  2435. frequency_class,
  2436. lifecycle_stage,
  2437. country_of_origin,
  2438. dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
  2439. manufacturing_lead_time,
  2440. expected_lead_time,
  2441. region_of_origin,
  2442. dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
  2443. customs_stat_no,
  2444. dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
  2445. durability_day,
  2446. intrastat_conv_factor,
  2447. supply_code,
  2448. part_status,
  2449. dbo.get_part_status_name(site, part_status) as partStatusDesc,
  2450. configuration_id,
  2451. estimated_material_cost,
  2452. inventory_valuation_method,
  2453. part_cost_group_id,
  2454. dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
  2455. inventory_part_cost_level,
  2456. invoice_consideration,
  2457. zero_cost_flag,
  2458. planning_method,
  2459. dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
  2460. safety_stock,
  2461. min_order_qty,
  2462. max_order_qty,
  2463. mul_order_qty,
  2464. safety_lead_time,
  2465. shrinkage_fac,
  2466. std_order_qty,
  2467. cum_lead_time,
  2468. back_flush_part,
  2469. by_prod_as_supply_in_mrp_db,
  2470. unprotected_lead_time,
  2471. issue_type,
  2472. mrp_control_flag_db,
  2473. fixed_lead_time_day,
  2474. over_reporting,
  2475. use_theoretical_density_db,
  2476. variable_lead_time_day,
  2477. over_report_tolerance,
  2478. fixed_lead_time_hour,
  2479. density,
  2480. variable_lead_time_hour,
  2481. create_date,
  2482. create_by,
  2483. update_date,
  2484. update_by,
  2485. plm_part_no,
  2486. ifs_part_no
  2487. FROM part
  2488. <if test="query.whereClause != null and query.whereClause != ''">
  2489. WHERE ${query.whereClause}
  2490. </if>
  2491. <if test="query.orderClause != null and query.orderClause != ''">
  2492. ORDER BY ${query.orderClause}
  2493. </if>
  2494. <if test="query.orderClause == null or query.orderClause == ''">
  2495. order by part_no
  2496. </if>
  2497. </select>
  2498. <update id="updateFromPartStatusAndIfsPart">
  2499. UPDATE part
  2500. SET status = 'Y',
  2501. ifs_part_no = #{ifsPartNo},
  2502. show_in_query_flag = 'N'
  2503. WHERE site = #{site} AND part_no = #{partNo}
  2504. </update>
  2505. <select id="getProjectPartByPartNo" resultType="com.spring.modules.part.vo.PartInformationVo">
  2506. SELECT
  2507. site,
  2508. project_id,
  2509. test_part_no as partNo,
  2510. bu_no
  2511. FROM plm_project_part
  2512. WHERE site = #{site} and (test_part_no = #{partNo} or final_part_no = #{partNo})
  2513. </select>
  2514. <insert id="batchSaveProjectPart">
  2515. insert into plm_project_part
  2516. (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)
  2517. values
  2518. <foreach collection="list" item="item" index="index" separator=",">
  2519. (#{item.site}, #{item.projectId}, #{item.partNo}, #{item.baseNo}, #{item.revNo}, #{item.partNoSource}, #{item.buNo}, #{item.virtualPartNo}, getDate(), #{item.createBy}, #{item.finalPartNo})
  2520. </foreach>
  2521. </insert>
  2522. <select id="getProjectCustomerPartByPartNo" resultType="com.spring.modules.part.vo.PartInformationVo">
  2523. select
  2524. site,
  2525. customer_no,
  2526. customer_part_no
  2527. from plm_customer_part_info
  2528. where site = #{site} and part_no = #{partNo}
  2529. </select>
  2530. <insert id="batchSaveCustomerPart">
  2531. insert into plm_customer_part_info
  2532. (site, customer_no, part_no, customer_part_no, create_date, create_by)
  2533. values
  2534. <foreach collection="list" item="item" index="index" separator=",">
  2535. (#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
  2536. </foreach>
  2537. </insert>
  2538. <delete id="deleteProjectPart">
  2539. delete from plm_project_part
  2540. where site = #{site} and project_id = #{projectId} and test_part_no = #{testPartNo}
  2541. </delete>
  2542. <delete id="deleteCustomerPart">
  2543. delete from plm_customer_part_info
  2544. where site = #{site} and customer_no = #{customerNo} and part_no = #{testPartNo}
  2545. </delete>
  2546. <delete id="deletePartRevisionByPartNo">
  2547. delete from part_revision
  2548. where site = #{site} and part_no = #{partNo}
  2549. </delete>
  2550. </mapper>