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.

2060 lines
86 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
11 months ago
11 months ago
11 months ago
2 years ago
2 years ago
11 months ago
11 months ago
11 months 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
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
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
2 years ago
1 year ago
1 year ago
11 months ago
9 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
11 months ago
10 months ago
10 months ago
2 years 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.RoutingManagementMapper">
  4. <!-- 材料信息列表 -->
  5. <select id="routingManagementSearch" parameterType="com.spring.modules.part.vo.RoutingHeaderVo" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  6. SELECT
  7. a.site,
  8. a.part_no,
  9. b.part_desc as partDesc,
  10. a.routing_revision,
  11. a.routing_type,
  12. a.note_text,
  13. a.phase_in_date,
  14. a.phase_out_date,
  15. a.create_date,
  16. a.create_by,
  17. a.update_date,
  18. a.update_by,
  19. b.um_id as printUnit,
  20. c.um_name as printUnitName,
  21. b.ifs_part_no,
  22. b.plm_part_no
  23. FROM plm_routing_header as a
  24. left join part as b on a.site = b.site and a.part_no = b.part_no
  25. left join um as c on b.um_id = c.um_id
  26. <where>
  27. a.site = #{query.site}
  28. AND b.show_in_query_flag = 'Y'
  29. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  30. AND b.plm_part_no like #{query.plmPartNo}
  31. </if>
  32. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  33. AND b.ifs_part_no like #{query.ifsPartNo}
  34. </if>
  35. <if test = "query.partDesc != null and query.partDesc != ''">
  36. AND b.part_desc like #{query.partDesc}
  37. </if>
  38. <if test = "query.routingType != null and query.routingType != ''">
  39. AND a.routing_type = #{query.routingType}
  40. </if>
  41. <if test = "query.routingRevision != null and query.routingRevision != ''">
  42. AND a.routing_revision like #{query.routingRevision}
  43. </if>
  44. </where>
  45. </select>
  46. <!-- 查询物料清单 -->
  47. <select id="queryPartList" parameterType="PartInformationEntity" resultType="RoutingAllFieldEntity">
  48. SELECT
  49. a.site,
  50. a.part_no,
  51. a.part_desc,
  52. a.spec,
  53. a.um_id as printUnit,
  54. b.um_name as printUnitName,
  55. a.part_type,
  56. a.plm_part_no,
  57. a.ifs_part_no
  58. FROM part as a
  59. left join um as b on a.um_id = b.um_id
  60. <where>
  61. a.site = #{query.site}
  62. and a.part_type in ('Manufactured', 'Manufactured Recipe')
  63. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  64. <if test = "query.partNo != null and query.partNo != ''">
  65. AND a.part_no like #{query.partNo}
  66. </if>
  67. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  68. AND a.plm_part_no like #{query.plmPartNo}
  69. </if>
  70. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  71. AND a.ifs_part_no like #{query.ifsPartNo}
  72. </if>
  73. <if test = "query.partDesc != null and query.partDesc != ''">
  74. AND a.part_desc like #{query.partDesc}
  75. </if>
  76. <if test = "query.status != null and query.status != ''">
  77. AND a.status = #{query.status}
  78. </if>
  79. </where>
  80. </select>
  81. <!-- 查出可创建Routing的物料 -->
  82. <select id="queryPartListRouting" parameterType="PartInformationEntity" resultType="RoutingAllFieldEntity">
  83. SELECT
  84. a.site,
  85. a.part_no,
  86. a.part_desc,
  87. a.spec,
  88. a.um_id as printUnit,
  89. b.um_name as printUnitName,
  90. a.part_type,
  91. a.plm_part_no,
  92. a.ifs_part_no
  93. FROM part as a
  94. left join um as b on a.um_id = b.um_id
  95. <where>
  96. a.site = #{query.site} and a.active = 'Y' and a.show_in_query_flag = 'Y'
  97. and a.part_type in ('Manufactured', 'Manufactured Recipe')
  98. <if test = "query.partNo != null and query.partNo != ''">
  99. AND a.part_no like #{query.partNo}
  100. </if>
  101. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  102. AND a.plm_part_no like #{query.plmPartNo}
  103. </if>
  104. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  105. AND a.ifs_part_no like #{query.ifsPartNo}
  106. </if>
  107. <if test = "query.partDesc != null and query.partDesc != ''">
  108. AND a.part_desc like #{query.partDesc}
  109. </if>
  110. <if test = "query.status != null and query.status != ''">
  111. AND a.status = #{query.status}
  112. </if>
  113. </where>
  114. </select>
  115. <!-- 新增Routing主表内容 -->
  116. <insert id="saveRoutingHeader" parameterType="RoutingHeaderEntity">
  117. INSERT INTO plm_routing_header
  118. (site, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date, create_date, create_by, official_flag)
  119. VALUES
  120. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{noteText}, #{phaseInDate}, #{phaseOutDate}, getDate(), #{createBy}, #{officialFlag})
  121. </insert>
  122. <!-- routing明细新增 -->
  123. <insert id="routingDetailSave" parameterType="RoutingDetailEntity">
  124. INSERT INTO plm_routing_detail
  125. (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)
  126. VALUES
  127. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{alternativeDescription}, #{fixedLeadTimeDay}, #{fixedLeadTimeHour}, #{variableLeadTimeDay}, #{variableLeadTimeHour}, #{forStdLotByDay}, #{forLotByDay}, #{minLotQty}, #{detailNoteText}, getDate(), #{createBy}, #{status}, #{officialFlag})
  128. </insert>
  129. <!-- 新增Routing子明细表内容 -->
  130. <insert id="saveRoutingComponent" parameterType="RoutingComponentEntity" useGeneratedKeys="true" keyProperty="operationId">
  131. INSERT INTO plm_routing_component
  132. (site, part_no, routing_revision, routing_type, alternative_no, operation_name, operation_no, efficiency_factor, mach_run_factor, mach_setup_time, run_time_code, labor_run_factor, labor_setup_time, crew_size, setup_crew_size, outside_op_item, machine_no, work_center_no, labor_class_no, setup_labor_class_no, overlap, note_text, create_date, create_by, ifs_row_id, ifs_row_version)
  133. VALUES
  134. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{operationName}, #{operationNo}, #{efficiencyFactor}, #{machRunFactor}, #{machSetupTime}, #{runTimeCode}, #{laborRunFactor}, #{laborSetupTime}, #{crewSize}, #{setupCrewSize}, #{outsideOpItem}, #{machineNo}, #{workCenterNo}, #{laborClassNo}, #{setupLaborClassNo}, #{overlap}, #{noteText}, getDate(), #{createBy}, #{ifsRowId}, #{ifsRowVersion})
  135. </insert>
  136. <!-- 新增Routing子明细表内容 -->
  137. <insert id="saveRoutingComponents">
  138. insert into plm_routing_component
  139. (site, part_no, routing_revision, routing_type, alternative_no, operation_name, operation_no, efficiency_factor, mach_run_factor, mach_setup_time, run_time_code, labor_run_factor, labor_setup_time, crew_size, setup_crew_size, outside_op_item, machine_no, work_center_no, labor_class_no, setup_labor_class_no, overlap, note_text, create_date, create_by, ifs_row_id, ifs_row_version) VALUES
  140. <foreach collection="list" item="item" index="index" separator=",">
  141. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.operationName}, #{item.operationNo}, #{item.efficiencyFactor}, #{item.machRunFactor}, #{item.machSetupTime}, #{item.runTimeCode}, #{item.laborRunFactor}, #{item.laborSetupTime}, #{item.crewSize}, #{item.setupCrewSize}, #{item.outsideOpItem}, #{item.machineNo}, #{item.workCenterNo}, #{item.laborClassNo}, #{item.setupLaborClassNo}, #{item.overlap}, #{item.noteText}, getDate(), #{item.createBy}, #{item.ifsRowId}, #{item.ifsRowVersion})
  142. </foreach>
  143. </insert>
  144. <!-- 查routing明细 -->
  145. <select id="queryRoutingDetail" parameterType="RoutingHeaderEntity" resultType="RoutingDetailEntity">
  146. SELECT
  147. site,
  148. part_no,
  149. routing_type,
  150. routing_revision,
  151. alternative_no,
  152. alternative_description,
  153. rout_template_id,
  154. plan_date,
  155. fixed_lead_time_day,
  156. fixed_lead_time_hour,
  157. variable_lead_time_day,
  158. variable_lead_time_hour,
  159. for_std_lot_by_day,
  160. for_lot_by_day,
  161. min_lot_qty,
  162. note_text as detailNoteText,
  163. status,
  164. official_flag
  165. FROM plm_routing_detail
  166. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  167. </select>
  168. <!-- 查routing明细对象 -->
  169. <select id="queryDetailDataByNo" parameterType="RoutingDetailEntity" resultType="RoutingDetailEntity">
  170. SELECT
  171. site,
  172. part_no,
  173. routing_type,
  174. routing_revision,
  175. alternative_no,
  176. alternative_description,
  177. rout_template_id,
  178. plan_date,
  179. fixed_lead_time_day,
  180. fixed_lead_time_hour,
  181. variable_lead_time_day,
  182. variable_lead_time_hour,
  183. for_std_lot_by_day,
  184. for_lot_by_day,
  185. min_lot_qty,
  186. note_text as detailNoteText,
  187. status,
  188. official_flag
  189. FROM plm_routing_detail
  190. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  191. </select>
  192. <!-- 查routing子明细 -->
  193. <select id="queryRoutingComponent" parameterType="RoutingDetailEntity" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  194. SELECT
  195. a.site,
  196. a.part_no,
  197. a.routing_type,
  198. a.routing_revision,
  199. a.alternative_no,
  200. a.operation_id,
  201. a.operation_no,
  202. a.operation_name,
  203. a.efficiency_factor,
  204. a.mach_run_factor,
  205. a.mach_setup_time,
  206. a.run_time_code,
  207. case when a.run_time_code = 'Units/Hour' then '单位/小时'
  208. when a.run_time_code = 'Hours/Unit' then '小时/单位'
  209. when a.run_time_code = 'Hours' then '小时'
  210. else '' end as runTimeCodeDesc,
  211. a.labor_run_factor,
  212. a.labor_setup_time,
  213. a.crew_size,
  214. a.setup_crew_size,
  215. a.outside_op_item,
  216. a.machine_no,
  217. a.work_center_no,
  218. b.work_center_desc,
  219. b.work_center_type,
  220. a.labor_class_no,
  221. dbo.get_labor_class_desc(a.site, a.labor_class_no) as laborClassDesc,
  222. a.setup_labor_class_no,
  223. dbo.get_labor_class_desc(a.site, a.setup_labor_class_no) as setupLaborClassDesc,
  224. a.overlap,
  225. a.note_text,
  226. a.ifs_row_id,
  227. a.ifs_row_version
  228. FROM plm_routing_component as a
  229. LEFT JOIN work_center as b on a.site = b.site and a.work_center_no = b.work_center_no
  230. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo}
  231. order by a.operation_no
  232. </select>
  233. <!-- routing主表编辑 -->
  234. <update id="updateRoutingHeader" parameterType="RoutingAllFieldEntity">
  235. update plm_routing_header
  236. set phase_in_date = #{phaseInDate},
  237. phase_out_date = #{phaseOutDate},
  238. note_text = #{noteText},
  239. update_date = getDate(),
  240. update_by = #{updateBy}
  241. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  242. </update>
  243. <!-- routing明细表编辑 -->
  244. <update id="updateRoutingDetail" parameterType="RoutingDetailEntity">
  245. update plm_routing_detail
  246. set alternative_description = #{alternativeDescription},
  247. rout_template_id = #{routTemplateId},
  248. plan_date = #{planDate},
  249. fixed_lead_time_day = #{fixedLeadTimeDay},
  250. fixed_lead_time_hour = #{fixedLeadTimeHour},
  251. variable_lead_time_day = #{variableLeadTimeDay},
  252. variable_lead_time_hour = #{variableLeadTimeHour},
  253. for_std_lot_by_day = #{forStdLotByDay},
  254. for_lot_by_day = #{forLotByDay},
  255. min_lot_qty = #{minLotQty},
  256. note_text = #{detailNoteText},
  257. update_date = getDate(),
  258. update_by = #{updateBy},
  259. status = #{status}
  260. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  261. </update>
  262. <!-- 删除routing子明细 -->
  263. <delete id="deleteRoutingComponent" parameterType="RoutingAllFieldEntity">
  264. delete from plm_routing_component
  265. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  266. </delete>
  267. <!-- 删除替代 -->
  268. <delete id="routingDetailDelete" parameterType="RoutingDetailEntity">
  269. delete from plm_routing_detail
  270. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  271. </delete>
  272. <!-- routing主表查重 -->
  273. <select id="checkRoutingOnlyOne" parameterType="RoutingAllFieldEntity" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  274. SELECT
  275. site,
  276. part_no,
  277. dbo.get_part_name(site, part_no) as partDesc,
  278. routing_type,
  279. routing_revision,
  280. phase_in_date,
  281. phase_out_date,
  282. note_text,
  283. official_flag
  284. FROM plm_routing_header
  285. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  286. </select>
  287. <!-- routing明细查重 -->
  288. <select id="checkRoutingDetailOnlyOne" parameterType="RoutingDetailEntity" resultType="RoutingDetailEntity">
  289. SELECT
  290. site,
  291. part_no,
  292. routing_type,
  293. routing_revision,
  294. alternative_no,
  295. alternative_description,
  296. rout_template_id,
  297. plan_date,
  298. fixed_lead_time_day,
  299. fixed_lead_time_hour,
  300. variable_lead_time_day,
  301. variable_lead_time_hour,
  302. for_std_lot_by_day,
  303. for_lot_by_day,
  304. min_lot_qty,
  305. note_text as detailNoteText,
  306. row_key,
  307. row_version,
  308. status,
  309. official_flag
  310. FROM plm_routing_detail
  311. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  312. </select>
  313. <!-- 批量删除子明细物料 -->
  314. <delete id="deleteRoutingComponents" parameterType="RoutingComponentEntity">
  315. delete from plm_routing_component
  316. where site = #{site}
  317. and part_no = #{partNo}
  318. and routing_revision = #{routingRevision}
  319. and routing_type = #{routingType}
  320. and alternative_no = #{alternativeNo}
  321. and operation_id = #{operationId}
  322. </delete>
  323. <!-- 删除routing子明细 -->
  324. <delete id="deleteRoutingComponentByPartNo" parameterType="RoutingHeaderEntity">
  325. delete from plm_routing_component
  326. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  327. </delete>
  328. <!-- 删除routing明细 -->
  329. <delete id="deleteRoutingDetailByPartNo" parameterType="RoutingHeaderEntity">
  330. delete from plm_routing_detail
  331. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  332. </delete>
  333. <!-- 删除routing主记录 -->
  334. <delete id="deleteRoutingHeaderByPartNo" parameterType="RoutingHeaderEntity">
  335. delete from plm_routing_header
  336. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  337. </delete>
  338. <!-- routing明细查重 -->
  339. <select id="checkRoutingComponentOnlyOne" parameterType="RoutingComponentEntity" resultType="RoutingComponentEntity">
  340. SELECT
  341. site,
  342. part_no,
  343. routing_type,
  344. routing_revision,
  345. alternative_no,
  346. operation_id,
  347. operation_no
  348. FROM plm_routing_component
  349. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_no = #{operationNo}
  350. </select>
  351. <!-- 修改routing子明细 -->
  352. <update id="updateRoutingComponent" parameterType="RoutingComponentEntity">
  353. update plm_routing_component
  354. set efficiency_factor = #{efficiencyFactor},
  355. mach_run_factor = #{machRunFactor},
  356. mach_setup_time = #{machSetupTime},
  357. run_time_code = #{runTimeCode},
  358. labor_run_factor = #{laborRunFactor},
  359. labor_setup_time = #{laborSetupTime},
  360. crew_size = #{crewSize},
  361. setup_crew_size = #{setupCrewSize},
  362. outside_op_item = #{outsideOpItem},
  363. machine_no = #{machineNo},
  364. work_center_no = #{workCenterNo},
  365. labor_class_no = #{laborClassNo},
  366. setup_labor_class_no = #{setupLaborClassNo},
  367. overlap = #{overlap},
  368. note_text = #{noteText},
  369. update_date = getDate(),
  370. update_by = #{updateBy},
  371. operation_no = #{operationNo},
  372. operation_name = #{operationName},
  373. ifs_row_id = #{ifsRowId},
  374. ifs_row_version = #{ifsRowVersion}
  375. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  376. </update>
  377. <!-- 查询工序清单 -->
  378. <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity">
  379. SELECT
  380. site,
  381. operation_id,
  382. operation_name,
  383. work_center_no
  384. FROM dbo.operation
  385. <where>
  386. site = #{site}
  387. <if test = "operationId != null and operationId != ''">
  388. AND operation_id like #{operationId}
  389. </if>
  390. <if test = "operationName != null and operationName != ''">
  391. AND operation_name like #{operationName}
  392. </if>
  393. </where>
  394. </select>
  395. <!-- 修改替代状态 -->
  396. <update id="updateAlternativeStatus" parameterType="RoutingDetailEntity">
  397. update plm_routing_detail
  398. set status = #{status},
  399. update_date = getDate(),
  400. update_by = #{updateBy}
  401. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  402. </update>
  403. <!-- 判断是否已有该物料的 routing -->
  404. <select id="queryPartRouting" parameterType="RoutingAllFieldEntity" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  405. SELECT top 1
  406. site,
  407. part_no,
  408. routing_type,
  409. routing_revision,
  410. phase_in_date,
  411. phase_out_date,
  412. note_text,
  413. official_flag
  414. FROM plm_routing_header
  415. WHERE site = #{site} and part_no = #{partNo} and routing_type = #{routingType} order by routing_revision desc
  416. </select>
  417. <!-- 判断该 routing 是否有 Buildable Obsolete 状态的替代 -->
  418. <select id="queryAlternativeStatus" parameterType="RoutingHeaderEntity" resultType="com.spring.modules.part.vo.RoutingDetailVo">
  419. SELECT
  420. site,
  421. part_no,
  422. routing_revision,
  423. routing_type,
  424. alternative_no,
  425. status
  426. FROM plm_routing_detail
  427. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and (status = 'Buildable' or status = 'Obsolete')
  428. </select>
  429. <!-- 判断该 routing 是否有正式的替代 -->
  430. <select id="queryOfficialRoutingDetail" parameterType="RoutingHeaderEntity" resultType="com.spring.modules.part.vo.RoutingDetailVo">
  431. SELECT
  432. site,
  433. part_no,
  434. routing_revision,
  435. routing_type,
  436. alternative_no,
  437. status,
  438. official_flag
  439. FROM plm_routing_detail
  440. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and official_flag = 'Y'
  441. </select>
  442. <!-- 判断 routing 是否存在子料 -->
  443. <select id="queryComponentPart" parameterType="RoutingHeaderEntity" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  444. SELECT
  445. site,
  446. part_no,
  447. routing_revision,
  448. routing_type,
  449. alternative_no,
  450. operation_id
  451. FROM plm_routing_component
  452. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  453. </select>
  454. <!-- 判断工序是否被引用 -->
  455. <select id="checkOperatorIsUse" parameterType="RoutingComponentEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  456. SELECT
  457. site,
  458. part_no,
  459. eng_chg_level,
  460. bom_type,
  461. alternative_no,
  462. component_part
  463. FROM plm_bom_component
  464. WHERE site = #{site} and part_no = #{partNo} and operation_no = #{operationNo}
  465. </select>
  466. <!-- 获取ifs header 对象-->
  467. <select id="getRoutingHeader" parameterType="RoutingDetailEntity" resultType="RoutingIfsHeader">
  468. SELECT
  469. site as contract,
  470. part_no,
  471. routing_revision,
  472. routing_type,
  473. phase_in_date,
  474. phase_out_date,
  475. note_text,
  476. 'add' as histType
  477. FROM plm_routing_header
  478. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  479. </select>
  480. <!-- 获取ifs component 对象-->
  481. <select id="getRoutingComponent" parameterType="RoutingDetailEntity" resultType="RoutingIfsItem">
  482. SELECT
  483. site as contract,
  484. part_no,
  485. routing_revision,
  486. routing_type,
  487. alternative_no,
  488. operation_id,
  489. operation_no,
  490. operation_name as operationDesc,
  491. work_center_no,
  492. efficiency_factor,
  493. mach_setup_time,
  494. mach_run_factor,
  495. run_time_code,
  496. labor_run_factor,
  497. labor_setup_time,
  498. crew_size,
  499. setup_crew_size,
  500. machine_no,
  501. note_text,
  502. case when outside_op_item is null then '' else outside_op_item end as outsideOpItem,
  503. labor_class_no,
  504. setup_labor_class_no,
  505. case when overlap is null then '' else overlap end as overlap,
  506. ifs_row_id,
  507. ifs_row_version
  508. FROM plm_routing_component
  509. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  510. </select>
  511. <!-- 获取ifs component 对象-->
  512. <select id="searchRoutingTools" parameterType="RoutingToolEntity" resultType="com.spring.modules.part.vo.RoutingToolVo">
  513. SELECT
  514. a.id,
  515. a.site,
  516. a.part_no,
  517. a.routing_revision,
  518. a.routing_type,
  519. a.alternative_no,
  520. dbo.plm_get_alternativeDesc(a.site, a.part_no, a.routing_revision, a.routing_type, a.alternative_no) as alternativeDescription,
  521. a.operation_id,
  522. b.operation_no,
  523. b.operation_name,
  524. a.tool_id,
  525. dbo.plm_get_toolDesc(a.site, a.tool_id) as toolDescription,
  526. a.tool_qty,
  527. a.remark,
  528. a.create_date,
  529. a.create_by,
  530. a.update_date,
  531. a.update_by,
  532. a.ifs_row_id,
  533. a.ifs_row_version
  534. FROM routing_tool as a
  535. left join plm_routing_component as b on a.operation_id = b.operation_id
  536. WHERE a.site = #{site} and a.part_no = #{partNo} and a.routing_revision = #{routingRevision} and a.routing_type = #{routingType}
  537. ORDER BY a.alternative_no, b.operation_no, a.tool_id
  538. </select>
  539. <!-- 新增 routingTools -->
  540. <insert id="routingToolSave" parameterType="com.spring.modules.part.vo.RoutingToolVo" keyProperty="id" useGeneratedKeys="true">
  541. INSERT INTO routing_tool
  542. (site, part_no, routing_revision, routing_type, alternative_no, operation_id, tool_id, tool_qty, remark, create_date, create_by)
  543. VALUES
  544. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{operationId}, #{toolId}, #{toolQty}, #{remark}, getDate(), #{createBy})
  545. </insert>
  546. <!-- 根据替代查询工序列表 -->
  547. <select id="queryOperationListByAlternative" parameterType="OperationEntity" resultType="OperationEntity">
  548. SELECT
  549. site,
  550. part_no,
  551. routing_revision,
  552. routing_type,
  553. alternative_no,
  554. operation_id,
  555. operation_no,
  556. operation_name
  557. FROM plm_routing_component
  558. <where>
  559. site = #{site} and routing_type = #{routingType} and
  560. alternative_no = #{alternativeNo}
  561. <if test="operationNo != null and operationNo != ''">
  562. AND operation_no = #{operationNo}
  563. </if>
  564. <if test="routingRevision != null and routingRevision != ''">
  565. AND routing_revision = #{routingRevision}
  566. </if>
  567. <if test="partNo != null and partNo != ''">
  568. AND part_no = #{partNo}
  569. </if>
  570. <if test="operationName != null and operationName != ''">
  571. AND operation_name like #{operationName}
  572. </if>
  573. </where>
  574. </select>
  575. <!-- 根据替代查询工序列表 -->
  576. <select id="queryAlternativeListByPartNo" parameterType="AlternativeEntity" resultType="AlternativeEntity">
  577. SELECT
  578. site,
  579. part_no,
  580. routing_revision,
  581. routing_type,
  582. alternative_no,
  583. alternative_description
  584. FROM plm_routing_detail
  585. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  586. </select>
  587. <!-- 编辑 routingTools(以 id 为主键定位,支持修改 tool_id) -->
  588. <update id="routingToolEdit" parameterType="RoutingToolEntity">
  589. update routing_tool
  590. set tool_id = #{toolId},
  591. tool_qty = #{toolQty},
  592. remark = #{remark},
  593. update_date = getDate(),
  594. update_by = #{updateBy}
  595. where id = #{id}
  596. </update>
  597. <!-- 删除 routingTools -->
  598. <delete id="deleteRoutingTool" parameterType="RoutingToolEntity">
  599. delete from routing_tool
  600. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId} and tool_id = #{toolId}
  601. </delete>
  602. <select id="routingAllInfoSearch" parameterType="com.spring.modules.part.vo.RoutingHeaderVo" resultType="com.spring.modules.part.vo.RoutingInfoVo">
  603. select
  604. a.site,
  605. a.part_no,
  606. e.part_desc partDesc,
  607. dbo.get_um_name(e.um_id) printUnitName,
  608. a.routing_revision,
  609. a.routing_type,
  610. a.phase_in_date,
  611. a.phase_out_date,
  612. a.note_text,
  613. b.alternative_no,
  614. b.alternative_description,
  615. b.rout_template_id,
  616. b.plan_date,
  617. b.fixed_lead_time_day,
  618. b.fixed_lead_time_hour,
  619. b.variable_lead_time_day,
  620. b.variable_lead_time_hour,
  621. b.for_std_lot_by_day,
  622. b.for_lot_by_day,
  623. b.min_lot_qty,
  624. b.note_text alternativeNoteText,
  625. b.status,
  626. c.operation_no,
  627. c.efficiency_factor,
  628. c.mach_run_factor,
  629. c.mach_setup_time,
  630. c.run_time_code,
  631. case when c.run_time_code = 'Units/Hour' then '单位/小时'
  632. when c.run_time_code = 'Hours/Unit' then '小时/单位'
  633. when c.run_time_code = 'Hours' then '小时'
  634. else '' end as runTimeCodeDesc,
  635. c.labor_run_factor,
  636. c.labor_setup_time,
  637. c.crew_size,
  638. c.setup_crew_size,
  639. c.outside_op_item,
  640. c.machine_no,
  641. c.work_center_no,
  642. dbo.get_workCenter_desc(a.site,c.work_center_no) workCenterDesc,
  643. c.labor_class_no,
  644. g.level_desc laborClassDesc,
  645. c.setup_labor_class_no,
  646. j.level_desc setupLaborClassDesc,
  647. c.overlap,
  648. c.operation_name,
  649. c.operation_id,
  650. c.note_text operationNoteText,
  651. d.tool_id,
  652. f.tool_description toolDescription,
  653. d.tool_qty,
  654. d.remark,
  655. e.plm_part_no,
  656. e.ifs_part_no
  657. from plm_routing_header a
  658. LEFT JOIN part e on a.site = e.site AND a.part_no = e.part_no
  659. LEFT JOIN plm_routing_detail 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
  660. LEFT JOIN plm_routing_component c on a.site = c.site AND a.part_no =c.part_no AND a.routing_revision = c.routing_revision and a.routing_type = c.routing_type and b.alternative_no = c.alternative_no
  661. LEFT JOIN routing_tool d on a.site = d.site AND a.part_no =d.part_no AND a.routing_revision = d.routing_revision and a.routing_type = d.routing_type and c.alternative_no = d.alternative_no and c.operation_id = d.operation_id
  662. LEFT JOIN tool_header f on a.site = f.site AND d.tool_id =f.tool_id
  663. LEFT JOIN labor_class g on a.site = g.site AND c.labor_class_no = g.level_id
  664. LEFT JOIN labor_class j on a.site = j.site AND c.setup_labor_class_no = j.level_id
  665. <where>
  666. a.site = #{query.site}
  667. AND e.show_in_query_flag = 'Y'
  668. <if test = "query.partNo != null and query.partNo != ''">
  669. AND a.part_no like #{query.partNo}
  670. </if>
  671. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  672. AND e.plm_part_no like #{query.plmPartNo}
  673. </if>
  674. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  675. AND e.ifs_part_no like #{query.ifsPartNo}
  676. </if>
  677. <if test = "query.partDesc != null and query.partDesc != ''">
  678. AND e.part_desc like #{query.partDesc}
  679. </if>
  680. </where>
  681. </select>
  682. <!-- 获取routing header 对象-->
  683. <select id="queryRoutingHeader" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  684. SELECT
  685. site,
  686. part_no,
  687. routing_revision,
  688. routing_type,
  689. note_text,
  690. phase_in_date,
  691. phase_out_date,
  692. row_version,
  693. row_key,
  694. official_flag
  695. FROM plm_routing_header
  696. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  697. </select>
  698. <!-- routing主表编辑 -->
  699. <update id="updateInDate" parameterType="RoutingHeaderEntity">
  700. update plm_routing_header
  701. set phase_out_date = #{phaseOutDate},
  702. update_date = getDate(),
  703. update_by = #{createBy}
  704. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  705. </update>
  706. <!-- 根据RoutingType查询-->
  707. <select id="selectRoutingHeaderByType" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  708. SELECT
  709. site,
  710. part_no,
  711. routing_revision,
  712. routing_type,
  713. note_text,
  714. phase_in_date,
  715. phase_out_date,
  716. row_version,
  717. row_key,
  718. official_flag
  719. FROM plm_routing_header
  720. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} order by routing_revision desc
  721. </select>
  722. <!-- 校验日期是否冲突-->
  723. <select id="queryHeaderPhaseDate" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  724. SELECT
  725. site,
  726. part_no,
  727. routing_revision,
  728. routing_type,
  729. note_text,
  730. phase_in_date,
  731. phase_out_date,
  732. row_version,
  733. row_key,
  734. official_flag
  735. FROM plm_routing_header
  736. <where>
  737. site = #{site} and part_no = #{partNo} and routing_type = #{routingType}
  738. <if test = "phaseOutDate == null">
  739. and phase_in_date >= #{phaseInDate}
  740. </if>
  741. <if test = "phaseOutDate != null">
  742. and #{phaseInDate} >= phase_in_date and phase_out_date >= #{phaseOutDate}
  743. </if>
  744. </where>
  745. </select>
  746. <!-- 将上一个版本的失效日期改为当前生效日期减一 -->
  747. <update id="updatePhaseOutDate" parameterType="RoutingHeaderEntity">
  748. update plm_routing_header
  749. set phase_out_date = #{phaseOutDate},
  750. update_date = getDate(),
  751. update_by = #{createBy}
  752. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  753. </update>
  754. <!-- 查routing子明细 -->
  755. <select id="queryComponent" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity">
  756. SELECT
  757. site,
  758. part_no,
  759. routing_type,
  760. routing_revision,
  761. alternative_no,
  762. operation_id,
  763. operation_no,
  764. operation_name,
  765. efficiency_factor,
  766. mach_run_factor,
  767. mach_setup_time,
  768. run_time_code,
  769. labor_run_factor,
  770. labor_setup_time,
  771. crew_size,
  772. setup_crew_size,
  773. outside_op_item,
  774. machine_no,
  775. work_center_no,
  776. labor_class_no,
  777. setup_labor_class_no,
  778. overlap,
  779. note_text,
  780. ifs_row_id,
  781. ifs_row_version
  782. FROM plm_routing_component
  783. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  784. </select>
  785. <!-- 判断替代是否为正式 -->
  786. <select id="queryRoutingDetailOfficialFlag" parameterType="RoutingComponentEntity" resultType="RoutingDetailEntity">
  787. SELECT
  788. site,
  789. part_no,
  790. routing_type,
  791. routing_revision,
  792. alternative_no,
  793. alternative_description,
  794. rout_template_id,
  795. plan_date,
  796. fixed_lead_time_day,
  797. fixed_lead_time_hour,
  798. variable_lead_time_day,
  799. variable_lead_time_hour,
  800. for_std_lot_by_day,
  801. for_lot_by_day,
  802. min_lot_qty,
  803. note_text as detailNoteText,
  804. status,
  805. official_flag
  806. FROM plm_routing_detail
  807. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  808. </select>
  809. <!-- 获取该routing的全部Tool -->
  810. <select id="getRoutingToolByHeader" parameterType="RoutingHeaderEntity" resultType="RoutingToolEntity">
  811. SELECT
  812. id,
  813. site,
  814. part_no,
  815. routing_type,
  816. routing_revision,
  817. alternative_no,
  818. operation_id,
  819. tool_id,
  820. tool_qty,
  821. remark
  822. FROM routing_tool
  823. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  824. </select>
  825. <!-- 批量新增routingTool -->
  826. <insert id="saveRoutingTool">
  827. insert into routing_tool
  828. (site, part_no, routing_revision, routing_type, alternative_no, operation_id, tool_id, tool_qty, remark, create_date, create_by, ifs_row_id, ifs_row_version) VALUES
  829. <foreach collection="list" item="item" index="index" separator=",">
  830. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.operationId}, #{item.toolId}, #{item.toolQty}, #{item.remark}, getDate(), #{item.createBy}, #{item.ifsRowId}, #{item.ifsRowVersion})
  831. </foreach>
  832. </insert>
  833. <!-- 获取该routing的全部guideLine -->
  834. <select id="getGuideLineByHeader" parameterType="RoutingHeaderEntity" resultType="WorkGuidelineEntity">
  835. SELECT
  836. site,
  837. part_no,
  838. routing_type,
  839. routing_revision,
  840. alternative_no,
  841. id,
  842. guideline_seq,
  843. guideline_desc,
  844. guideline_text,
  845. guideline_type,
  846. sign_off_required,
  847. inspection_sign_off_required,
  848. operation_id
  849. FROM plm_routing_work_guide
  850. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  851. </select>
  852. <!-- 批量新增guideLine -->
  853. <insert id="saveGuideLine">
  854. insert into plm_routing_work_guide
  855. (site, part_no, routing_revision, routing_type, alternative_no, guideline_seq, guideline_desc, guideline_text, guideline_type, sign_off_required, inspection_sign_off_required, operation_id, create_date, create_by, ifs_row_id, ifs_row_version) VALUES
  856. <foreach collection="list" item="item" index="index" separator=",">
  857. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.guidelineSeq}, #{item.guidelineDesc}, #{item.guidelineText}, #{item.guidelineType}, #{item.signOffRequired}, #{item.inspectionSignOffRequired}, #{item.operationId}, getDate(), #{item.createBy}, #{item.ifsRowId}, #{item.ifsRowVersion})
  858. </foreach>
  859. </insert>
  860. <!-- 获取该工序的Tool -->
  861. <select id="getRoutingToolByOperation" parameterType="RoutingComponentEntity" resultType="RoutingToolEntity">
  862. SELECT
  863. id,
  864. site,
  865. part_no,
  866. routing_type,
  867. routing_revision,
  868. alternative_no,
  869. operation_id,
  870. tool_id,
  871. tool_qty,
  872. remark
  873. FROM routing_tool
  874. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  875. </select>
  876. <!-- 获取该工序的Tool(ifs) -->
  877. <select id="getRoutingToolByOperationToIfs" resultType="RoutingIfsTool">
  878. SELECT
  879. a.id,
  880. a.site as contract,
  881. a.part_no,
  882. a.routing_type,
  883. a.routing_revision,
  884. a.alternative_no,
  885. a.operation_id,
  886. b.operation_no,
  887. a.tool_id,
  888. a.tool_qty as toolQuantity,
  889. a.remark as noteText,
  890. b.ifs_row_id,
  891. b.ifs_row_version
  892. FROM routing_tool as a
  893. left join plm_routing_component as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision and a.alternative_no = b.alternative_no and a.operation_id = b.operation_id
  894. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo} and a.operation_id = #{operationId}
  895. </select>
  896. <!-- 修改工序Tool的 rowKey rowRevision -->
  897. <update id="updateIfsToolRowKeyAndRevision" parameterType="com.spring.modules.part.entity.APIEntity.RoutingIfsTool">
  898. update routing_tool
  899. set ifs_row_id = #{ifsRowId},
  900. ifs_row_version = #{ifsRowVersion}
  901. where id = #{id}
  902. </update>
  903. <!-- 修改工序Tool的 rowKey rowRevision -->
  904. <update id="updateIfsToolRowKeyAndRevision2" parameterType="com.spring.modules.part.entity.APIEntity.RoutingIfsTool">
  905. update
  906. a
  907. set a.ifs_row_id = #{ifsRowId},
  908. a.ifs_row_version = #{ifsRowVersion} from
  909. routing_tool a, plm_routing_component b
  910. where 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 and a.alternative_no = b.alternative_no
  911. and a.operation_id = b.operation_id
  912. and a.site = #{contract} and a.part_no = #{partNo} and a.routing_revision = #{routingRevision} and a.routing_type = #{routingType} and a.alternative_no = #{alternativeNo}
  913. and a.tool_id = #{toolId} and b.operation_no = #{operationNo}
  914. </update>
  915. <!-- 获取该替代的全部guideLine -->
  916. <select id="getGuideLineByOperation" parameterType="RoutingComponentEntity" resultType="WorkGuidelineEntity">
  917. SELECT
  918. site,
  919. part_no,
  920. routing_type,
  921. routing_revision,
  922. alternative_no,
  923. id,
  924. guideline_seq,
  925. guideline_desc,
  926. guideline_text,
  927. guideline_type,
  928. sign_off_required,
  929. inspection_sign_off_required,
  930. operation_id
  931. FROM plm_routing_work_guide
  932. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  933. </select>
  934. <!-- 修改工序Guideline的 rowKey rowRevision -->
  935. <update id="updateIfsGuidelineRowKeyAndRevision" parameterType="com.spring.modules.part.entity.APIEntity.RoutingIfsGuideLine">
  936. update plm_routing_work_guide
  937. set ifs_row_id = #{ifsRowId},
  938. ifs_row_version = #{ifsRowVersion}
  939. where id = #{id}
  940. </update>
  941. <!-- 修改工序Guideline的 rowKey rowRevision -->
  942. <update id="updateIfsGuidelineRowKeyAndRevision2" parameterType="com.spring.modules.part.entity.APIEntity.RoutingIfsGuideLine">
  943. update
  944. a
  945. set a.ifs_row_id = #{ifsRowId},
  946. a.ifs_row_version = #{ifsRowVersion} from
  947. plm_routing_work_guide a, plm_routing_component b
  948. where 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 and a.alternative_no = b.alternative_no
  949. and a.operation_id = b.operation_id
  950. and a.site = #{contract} and a.part_no = #{partNo} and a.routing_revision = #{routingRevision} and a.routing_type = #{routingType} and a.alternative_no = #{alternativeNo} and a.guideline_seq = #{guidelineSeq} and b.operation_no = #{operationNo}
  951. </update>
  952. <!-- 获取该工序的Tool(ifs) -->
  953. <select id="getRoutingGuidelineByOperationToIfs" resultType="com.spring.modules.part.entity.APIEntity.RoutingIfsGuideLine">
  954. SELECT
  955. a.id,
  956. a.site as contract,
  957. a.part_no,
  958. a.routing_type,
  959. a.routing_revision,
  960. a.alternative_no,
  961. a.operation_id,
  962. b.operation_no,
  963. a.guideline_seq,
  964. a.guideline_desc,
  965. a.guideline_text,
  966. a.guideline_type as operWorkGuideType,
  967. a.sign_off_required as signOffReq,
  968. a.inspection_sign_off_required as inspectSignOffReq,
  969. b.ifs_row_id,
  970. b.ifs_row_version
  971. FROM plm_routing_work_guide as a
  972. left join plm_routing_component as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision and a.alternative_no = b.alternative_no and a.operation_id = b.operation_id
  973. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo} and a.operation_id = #{operationId}
  974. </select>
  975. <!-- 根据工序删除RoutingTool -->
  976. <delete id="deleteRoutingToolByOperation" parameterType="RoutingComponentEntity">
  977. delete from routing_tool
  978. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  979. </delete>
  980. <!-- 根据工序删除guideLine -->
  981. <delete id="deleteGuideLineByOperation" parameterType="RoutingComponentEntity">
  982. delete from plm_routing_work_guide
  983. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  984. </delete>
  985. <!-- 根据替代删除RoutingTool -->
  986. <delete id="deleteRoutingToolByAlternative" parameterType="RoutingDetailEntity">
  987. delete from routing_tool
  988. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  989. </delete>
  990. <!-- 根据替代删除guideLine -->
  991. <delete id="deleteGuideLineByAlternative" parameterType="RoutingDetailEntity">
  992. delete from plm_routing_work_guide
  993. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  994. </delete>
  995. <select id="queryRoutingDetailList" resultType="com.spring.modules.quotation.entity.QuoteRoutingHeader">
  996. SELECT
  997. site,
  998. part_no,
  999. routing_type,
  1000. routing_revision as version,
  1001. alternative_no
  1002. FROM plm_routing_detail
  1003. where site = #{site} and part_no = #{partNo}
  1004. </select>
  1005. <!-- 查询最大工序号 -->
  1006. <select id="queryMaxOperationNo" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity">
  1007. SELECT top 1
  1008. site,
  1009. part_no,
  1010. routing_revision,
  1011. routing_type,
  1012. alternative_no,
  1013. operation_no
  1014. FROM plm_routing_component
  1015. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  1016. order by operation_no desc
  1017. </select>
  1018. <!-- 修改工序的 rowKey rowRevision -->
  1019. <update id="updateIfsRowKeyAndRevision" parameterType="com.spring.modules.part.entity.APIEntity.RoutingIfsItem">
  1020. update plm_routing_component
  1021. set ifs_row_id = #{ifsRowId},
  1022. ifs_row_version = #{ifsRowVersion}
  1023. where site = #{contract} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  1024. </update>
  1025. <!-- 修改工序的 rowKey rowRevision -->
  1026. <update id="updateIfsRowKeyAndRevision2" parameterType="com.spring.modules.part.entity.APIEntity.RoutingIfsItem">
  1027. update plm_routing_component
  1028. set ifs_row_id = #{ifsRowId},
  1029. ifs_row_version = #{ifsRowVersion}
  1030. where site = #{contract} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_no = #{operationNo}
  1031. </update>
  1032. <!-- 修改工具的 rowKey rowRevision -->
  1033. <update id="updateRoutingToolIfsRow" parameterType="com.spring.modules.part.vo.RoutingToolVo">
  1034. update routing_tool
  1035. set ifs_row_id = #{ifsRowId},
  1036. ifs_row_version = #{ifsRowVersion}
  1037. where id = #{id}
  1038. </update>
  1039. <update id="updateRoutingHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.RoutingDetailVo">
  1040. update plm_routing_header
  1041. set official_flag = 'Y'
  1042. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  1043. </update>
  1044. <update id="updateRoutingDetailOfficialFlag" parameterType="com.spring.modules.part.vo.RoutingDetailVo">
  1045. update plm_routing_detail
  1046. set official_flag = 'Y'
  1047. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  1048. </update>
  1049. <!-- 根据routing的替代查Tool -->
  1050. <select id="getRoutingToolByAlternative" parameterType="com.spring.modules.part.vo.RoutingDetailVo" resultType="RoutingIfsTool">
  1051. SELECT
  1052. a.id,
  1053. a.site as contract,
  1054. a.part_no,
  1055. a.routing_type,
  1056. a.routing_revision,
  1057. a.alternative_no,
  1058. a.operation_id,
  1059. b.operation_no,
  1060. a.tool_id,
  1061. a.tool_qty as toolQuantity,
  1062. a.remark as noteText,
  1063. b.ifs_row_id,
  1064. b.ifs_row_version
  1065. FROM routing_tool as a
  1066. left join plm_routing_component as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision and a.alternative_no = b.alternative_no and a.operation_id = b.operation_id
  1067. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo}
  1068. </select>
  1069. <!-- 根据routing的替代查guideLine -->
  1070. <select id="getGuideLineByAlternative" parameterType="com.spring.modules.part.vo.RoutingDetailVo" resultType="RoutingIfsGuideLine">
  1071. SELECT
  1072. a.site as contract,
  1073. a.part_no,
  1074. a.routing_type,
  1075. a.routing_revision,
  1076. a.alternative_no,
  1077. a.id,
  1078. a.guideline_seq,
  1079. a.guideline_desc,
  1080. a.guideline_text,
  1081. a.guideline_type as operWorkGuideType,
  1082. a.sign_off_required as signOffReq,
  1083. a.inspection_sign_off_required as inspectSignOffReq,
  1084. a.operation_id,
  1085. b.ifs_row_id,
  1086. b.ifs_row_version
  1087. FROM plm_routing_work_guide as a
  1088. left join plm_routing_component as b on a.operation_id = b.operation_id
  1089. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo}
  1090. </select>
  1091. <!-- 获取Tool(ifs),以 id 为主键查询,确保 tool_id 修改后仍能正确定位记录 -->
  1092. <select id="getRoutingToolToIfs" parameterType="RoutingToolEntity" resultType="RoutingIfsTool">
  1093. SELECT
  1094. id,
  1095. site as contract,
  1096. part_no,
  1097. routing_type,
  1098. routing_revision,
  1099. alternative_no,
  1100. operation_id,
  1101. tool_id,
  1102. tool_qty as toolQuantity,
  1103. remark as noteText,
  1104. ifs_row_id,
  1105. ifs_row_version
  1106. FROM routing_tool
  1107. where id = #{id}
  1108. </select>
  1109. <!-- 修改工序的 rowKey rowRevision -->
  1110. <update id="updateRoutingComponentIfsRow" parameterType="RoutingComponentEntity">
  1111. update plm_routing_component
  1112. set ifs_row_id = #{ifsRowId},
  1113. ifs_row_version = #{ifsRowVersion}
  1114. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  1115. </update>
  1116. <!-- 获取工序(ifs) -->
  1117. <select id="getRoutingComponentToIfs" parameterType="RoutingComponentEntity" resultType="RoutingIfsItem">
  1118. SELECT
  1119. site as contract,
  1120. part_no,
  1121. routing_type,
  1122. routing_revision,
  1123. alternative_no,
  1124. operation_id,
  1125. operation_no,
  1126. efficiency_factor,
  1127. mach_run_factor,
  1128. mach_setup_time,
  1129. run_time_code,
  1130. labor_run_factor,
  1131. labor_setup_time,
  1132. crew_size,
  1133. setup_crew_size,
  1134. outside_op_item,
  1135. machine_no,
  1136. work_center_no,
  1137. labor_class_no,
  1138. setup_labor_class_no,
  1139. overlap,
  1140. note_text,
  1141. operation_name as operationDesc,
  1142. ifs_row_id,
  1143. ifs_row_version
  1144. FROM plm_routing_component
  1145. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  1146. </select>
  1147. <select id="getPLMLocations" resultType="LocationInformationEntity">
  1148. select
  1149. site,
  1150. location_id,
  1151. location_name,
  1152. warehouse_id,
  1153. active,
  1154. location_type,
  1155. ifs_row_version
  1156. from location
  1157. where site in
  1158. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1159. #{item}
  1160. </foreach>
  1161. </select>
  1162. <!-- 批量删除 -->
  1163. <delete id="syncDeleteLocation" parameterType="java.util.List">
  1164. DELETE FROM location WHERE
  1165. <foreach item="item" index="index" collection="list" open="(" separator=") OR (" close=")">
  1166. location_id = #{item.locationId} AND site = #{item.site}
  1167. </foreach>
  1168. </delete>
  1169. <!-- 批量新增 -->
  1170. <insert id="syncSaveLocation">
  1171. INSERT INTO location (site, location_id, location_name, warehouse_id, active, location_type, ifs_row_version)
  1172. VALUES
  1173. <foreach item="item" collection="list" separator=",">
  1174. (#{item.site}, #{item.locationId}, #{item.locationName}, #{item.warehouseId}, #{item.active}, #{item.locationType}, #{item.ifsRowVersion})
  1175. </foreach>
  1176. </insert>
  1177. <!-- 批量更新 -->
  1178. <update id="syncUpdateLocation" parameterType="java.util.List">
  1179. UPDATE location
  1180. SET
  1181. location_name = CASE location_id
  1182. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1183. WHEN #{item.locationId} THEN #{item.locationName}
  1184. </foreach>
  1185. ELSE location_name
  1186. END,
  1187. active = CASE location_id
  1188. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1189. WHEN #{item.locationId} THEN #{item.active}
  1190. </foreach>
  1191. ELSE active
  1192. END,
  1193. warehouse_id = CASE location_id
  1194. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1195. WHEN #{item.locationId} THEN #{item.warehouseId}
  1196. </foreach>
  1197. ELSE warehouse_id
  1198. END,
  1199. location_type = CASE location_id
  1200. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1201. WHEN #{item.locationId} THEN #{item.locationType}
  1202. </foreach>
  1203. ELSE location_type
  1204. END,
  1205. ifs_row_version = CASE location_id
  1206. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1207. WHEN #{item.locationId} THEN #{item.ifsRowVersion}
  1208. </foreach>
  1209. ELSE ifs_row_version
  1210. END
  1211. WHERE location_id IN
  1212. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1213. #{item.locationId}
  1214. </foreach>
  1215. AND site = #{list[0].site}
  1216. </update>
  1217. <!-- &lt;!&ndash; 批量更新 &ndash;&gt;-->
  1218. <!-- <update id="syncUpdateLocation" parameterType="LocationInformationEntity">-->
  1219. <!-- UPDATE location SET-->
  1220. <!-- location_name = #{locationName},-->
  1221. <!-- active = #{active},-->
  1222. <!-- warehouse_id = #{warehouseId},-->
  1223. <!-- location_type = #{locationType},-->
  1224. <!-- ifs_row_version = #{ifsRowVersion}-->
  1225. <!-- WHERE location_id = #{locationId} AND site = #{site}-->
  1226. <!-- </update>-->
  1227. <select id="getPLMLaborClasss" resultType="PersonnelLevel">
  1228. select
  1229. site,
  1230. level_id,
  1231. level_desc,
  1232. level_cost,
  1233. active,
  1234. ifs_row_version
  1235. from labor_class
  1236. where site in
  1237. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1238. #{item}
  1239. </foreach>
  1240. </select>
  1241. <!-- 批量删除 -->
  1242. <delete id="syncDeleteLaborClass" parameterType="java.util.List">
  1243. DELETE FROM labor_class WHERE
  1244. <foreach item="item" index="index" collection="list" open="(" separator=") OR (" close=")">
  1245. level_id = #{item.levelId} AND site = #{item.site}
  1246. </foreach>
  1247. </delete>
  1248. <!-- 批量新增 -->
  1249. <insert id="syncSaveLaborClass">
  1250. INSERT INTO labor_class (site, level_id, level_desc, level_cost, active, ifs_row_version, show_in_query_flag)
  1251. VALUES
  1252. <foreach item="item" collection="list" separator=",">
  1253. (#{item.site}, #{item.levelId}, #{item.levelDesc}, #{item.levelCost}, #{item.active}, #{item.ifsRowVersion}, #{item.showInQueryFlag})
  1254. </foreach>
  1255. </insert>
  1256. <!-- 批量更新 -->
  1257. <update id="syncUpdateLaborClass" parameterType="java.util.List">
  1258. UPDATE labor_class
  1259. SET
  1260. level_desc = CASE level_id
  1261. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1262. WHEN #{item.levelId} THEN #{item.levelDesc}
  1263. </foreach>
  1264. ELSE level_desc
  1265. END,
  1266. active = CASE level_id
  1267. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1268. WHEN #{item.levelId} THEN #{item.active}
  1269. </foreach>
  1270. ELSE active
  1271. END,
  1272. level_cost = CASE level_id
  1273. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1274. WHEN #{item.levelId} THEN #{item.levelCost,jdbcType=DECIMAL}
  1275. </foreach>
  1276. ELSE level_cost
  1277. END,
  1278. show_in_query_flag = CASE level_id
  1279. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1280. WHEN #{item.levelId} THEN #{item.showInQueryFlag}
  1281. </foreach>
  1282. ELSE show_in_query_flag
  1283. END,
  1284. ifs_row_version = CASE level_id
  1285. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1286. WHEN #{item.levelId} THEN #{item.ifsRowVersion}
  1287. </foreach>
  1288. ELSE ifs_row_version
  1289. END
  1290. WHERE level_id IN
  1291. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1292. #{item.levelId}
  1293. </foreach>
  1294. AND site = #{list[0].site}
  1295. </update>
  1296. <!-- &lt;!&ndash; 批量更新 &ndash;&gt;-->
  1297. <!-- <update id="syncUpdateLaborClass" parameterType="PersonnelLevel">-->
  1298. <!-- UPDATE labor_class SET-->
  1299. <!-- level_desc = #{levelDesc},-->
  1300. <!-- active = #{active},-->
  1301. <!-- level_cost = #{levelCost},-->
  1302. <!-- ifs_row_version = #{ifsRowVersion}-->
  1303. <!-- WHERE level_id = #{levelId} AND site = #{site}-->
  1304. <!-- </update>-->
  1305. <select id="getPLMWorkCenters" resultType="WorkCenter">
  1306. select
  1307. site,
  1308. work_center_no,
  1309. work_center_desc,
  1310. work_center_type_db,
  1311. work_center_type,
  1312. average_capacity,
  1313. efficiency,
  1314. utilization,
  1315. capacity_type_db,
  1316. capacity_type,
  1317. um_id,
  1318. active,
  1319. remark,
  1320. pro_line_no,
  1321. can_create_new_roll_flag,
  1322. need_setup_flag,
  1323. ifs_row_version
  1324. from work_center
  1325. where site in
  1326. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1327. #{item}
  1328. </foreach>
  1329. </select>
  1330. <!-- 批量删除 -->
  1331. <delete id="syncDeleteWorkCenter" parameterType="java.util.List">
  1332. DELETE FROM work_center WHERE
  1333. <foreach item="item" index="index" collection="list" open="(" separator=") OR (" close=")">
  1334. work_center_no = #{item.workCenterNo} AND site = #{item.site}
  1335. </foreach>
  1336. </delete>
  1337. <!-- 批量新增 -->
  1338. <insert id="syncSaveWorkCenter">
  1339. INSERT INTO work_center (site, work_center_no, work_center_desc, work_center_type_db, work_center_type, average_capacity, efficiency, utilization, capacity_type_db, capacity_type,
  1340. um_id, active, remark, pro_line_no, can_create_new_roll_flag, need_setup_flag, ifs_row_version, show_in_query_flag)
  1341. VALUES
  1342. <foreach item="item" collection="list" separator=",">
  1343. (#{item.site}, #{item.workCenterNo}, #{item.workCenterDesc}, #{item.workCenterTypeDB}, #{item.workCenterType}, #{item.averageCapacity,jdbcType=DECIMAL}, #{item.efficiency,jdbcType=DECIMAL}, #{item.utilization,jdbcType=DECIMAL}, #{item.capacityTypeDB}, #{item.capacityType},
  1344. #{item.umId}, #{item.active}, #{item.remark}, #{item.proLineNo}, #{item.canCreateNewRollFlag}, #{item.needSetupFlag}, #{item.ifsRowVersion}, #{item.showInQueryFlag})
  1345. </foreach>
  1346. </insert>
  1347. <!-- 批量更新 -->
  1348. <update id="syncUpdateWorkCenter" parameterType="java.util.List">
  1349. UPDATE work_center
  1350. SET
  1351. work_center_desc = CASE work_center_no
  1352. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1353. WHEN #{item.workCenterNo} THEN #{item.workCenterDesc}
  1354. </foreach>
  1355. ELSE work_center_desc
  1356. END,
  1357. work_center_type_db = CASE work_center_no
  1358. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1359. WHEN #{item.workCenterNo} THEN #{item.workCenterTypeDB}
  1360. </foreach>
  1361. ELSE work_center_type_db
  1362. END,
  1363. work_center_type = CASE work_center_no
  1364. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1365. WHEN #{item.workCenterNo} THEN #{item.workCenterType}
  1366. </foreach>
  1367. ELSE work_center_type
  1368. END,
  1369. average_capacity = CASE work_center_no
  1370. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1371. WHEN #{item.workCenterNo} THEN #{item.averageCapacity,jdbcType=DECIMAL}
  1372. </foreach>
  1373. ELSE average_capacity
  1374. END,
  1375. efficiency = CASE work_center_no
  1376. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1377. WHEN #{item.workCenterNo} THEN #{item.efficiency,jdbcType=DECIMAL}
  1378. </foreach>
  1379. ELSE efficiency
  1380. END,
  1381. utilization = CASE work_center_no
  1382. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1383. WHEN #{item.workCenterNo} THEN #{item.utilization,jdbcType=DECIMAL}
  1384. </foreach>
  1385. ELSE utilization
  1386. END,
  1387. capacity_type_db = CASE work_center_no
  1388. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1389. WHEN #{item.workCenterNo} THEN #{item.capacityTypeDB}
  1390. </foreach>
  1391. ELSE capacity_type_db
  1392. END,
  1393. capacity_type = CASE work_center_no
  1394. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1395. WHEN #{item.workCenterNo} THEN #{item.capacityType}
  1396. </foreach>
  1397. ELSE capacity_type
  1398. END,
  1399. um_id = CASE work_center_no
  1400. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1401. WHEN #{item.workCenterNo} THEN #{item.umId}
  1402. </foreach>
  1403. ELSE um_id
  1404. END,
  1405. active = CASE work_center_no
  1406. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1407. WHEN #{item.workCenterNo} THEN #{item.active}
  1408. </foreach>
  1409. ELSE active
  1410. END,
  1411. show_in_query_flag = CASE work_center_no
  1412. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1413. WHEN #{item.workCenterNo} THEN #{item.showInQueryFlag}
  1414. </foreach>
  1415. ELSE show_in_query_flag
  1416. END,
  1417. remark = CASE work_center_no
  1418. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1419. WHEN #{item.workCenterNo} THEN #{item.remark}
  1420. </foreach>
  1421. ELSE remark
  1422. END,
  1423. pro_line_no = CASE work_center_no
  1424. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1425. WHEN #{item.workCenterNo} THEN #{item.proLineNo}
  1426. </foreach>
  1427. ELSE pro_line_no
  1428. END,
  1429. can_create_new_roll_flag = CASE work_center_no
  1430. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1431. WHEN #{item.workCenterNo} THEN #{item.canCreateNewRollFlag}
  1432. </foreach>
  1433. ELSE can_create_new_roll_flag
  1434. END,
  1435. need_setup_flag = CASE work_center_no
  1436. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1437. WHEN #{item.workCenterNo} THEN #{item.needSetupFlag}
  1438. </foreach>
  1439. ELSE need_setup_flag
  1440. END,
  1441. ifs_row_version = CASE work_center_no
  1442. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1443. WHEN #{item.workCenterNo} THEN #{item.ifsRowVersion}
  1444. </foreach>
  1445. ELSE ifs_row_version
  1446. END
  1447. WHERE work_center_no IN
  1448. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1449. #{item.workCenterNo}
  1450. </foreach>
  1451. AND site = #{list[0].site}
  1452. </update>
  1453. <select id="getPLMWorkCenterCosts" resultType="WorkCenterCost">
  1454. select
  1455. site,
  1456. work_center_no,
  1457. item_no,
  1458. unit_cost,
  1459. overhead1_cost,
  1460. overhead2_cost,
  1461. um_id,
  1462. begin_date,
  1463. end_date,
  1464. remark,
  1465. current_work_center_cost,
  1466. ifs_row_id,
  1467. ifs_row_version,
  1468. cost_set,
  1469. cost_set_desc,
  1470. wc_rate,
  1471. wc_cost_code,
  1472. overhead1_fac,
  1473. overhead2_fac,
  1474. overhead1_appl,
  1475. overhead2_appl
  1476. from work_center_cost
  1477. where site in
  1478. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1479. #{item}
  1480. </foreach>
  1481. </select>
  1482. <!-- 批量新增 -->
  1483. <insert id="syncSaveWorkCenterCost">
  1484. INSERT INTO work_center_cost (site, work_center_no, item_no, unit_cost, overhead1_cost, overhead2_cost, um_id, begin_date, end_date, remark,
  1485. ifs_row_id, ifs_row_version, cost_set, cost_set_desc, wc_rate, wc_cost_code, overhead1_fac, overhead2_fac, overhead1_appl, overhead2_appl)
  1486. VALUES
  1487. <foreach item="item" collection="list" separator=",">
  1488. (#{item.site}, #{item.workCenterNo}, #{item.itemNo,jdbcType=FLOAT}, #{item.unitCost,jdbcType=FLOAT}, #{item.overhead1Cost,jdbcType=FLOAT}, #{item.overhead2Cost,jdbcType=FLOAT}, #{item.umId}, #{item.beginDate,jdbcType=DATE}, #{item.endDate,jdbcType=DATE}, #{item.remark},
  1489. #{item.ifsRowId}, #{item.ifsRowVersion}, #{item.costSet}, #{item.costSetDesc}, #{item.wcRate}, #{item.wcCostCode}, #{item.overhead1Fac}, #{item.overhead2Fac}, #{item.overhead1Appl}, #{item.overhead2Appl})
  1490. </foreach>
  1491. </insert>
  1492. <!-- 批量更新 -->
  1493. <update id="syncUpdateWorkCenterCost" parameterType="java.util.List">
  1494. UPDATE work_center_cost
  1495. SET
  1496. item_no = CASE ifs_row_id
  1497. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1498. WHEN #{item.ifsRowId} THEN #{item.itemNo,jdbcType=FLOAT}
  1499. </foreach>
  1500. ELSE item_no
  1501. END,
  1502. unit_cost = CASE ifs_row_id
  1503. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1504. WHEN #{item.ifsRowId} THEN #{item.unitCost,jdbcType=FLOAT}
  1505. </foreach>
  1506. ELSE unit_cost
  1507. END,
  1508. overhead1_cost = CASE ifs_row_id
  1509. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1510. WHEN #{item.ifsRowId} THEN #{item.overhead1Cost,jdbcType=FLOAT}
  1511. </foreach>
  1512. ELSE overhead1_cost
  1513. END,
  1514. overhead2_cost = CASE ifs_row_id
  1515. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1516. WHEN #{item.ifsRowId} THEN #{item.overhead2Cost,jdbcType=FLOAT}
  1517. </foreach>
  1518. ELSE overhead2_cost
  1519. END,
  1520. um_id = CASE ifs_row_id
  1521. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1522. WHEN #{item.ifsRowId} THEN #{item.umId}
  1523. </foreach>
  1524. ELSE um_id
  1525. END,
  1526. begin_date = CASE ifs_row_id
  1527. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1528. WHEN #{item.ifsRowId} THEN #{item.beginDate}
  1529. </foreach>
  1530. ELSE begin_date
  1531. END,
  1532. end_date = CASE ifs_row_id
  1533. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1534. WHEN #{item.ifsRowId} THEN #{item.endDate}
  1535. </foreach>
  1536. ELSE end_date
  1537. END,
  1538. remark = CASE ifs_row_id
  1539. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1540. WHEN #{item.ifsRowId} THEN #{item.remark}
  1541. </foreach>
  1542. ELSE remark
  1543. END,
  1544. ifs_row_version = CASE ifs_row_id
  1545. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1546. WHEN #{item.ifsRowId} THEN #{item.ifsRowVersion}
  1547. </foreach>
  1548. ELSE ifs_row_version
  1549. END,
  1550. cost_set = CASE ifs_row_id
  1551. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1552. WHEN #{item.ifsRowId} THEN #{item.costSet}
  1553. </foreach>
  1554. ELSE cost_set
  1555. END,
  1556. cost_set_desc = CASE ifs_row_id
  1557. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1558. WHEN #{item.ifsRowId} THEN #{item.costSetDesc}
  1559. </foreach>
  1560. ELSE cost_set_desc
  1561. END,
  1562. wc_rate = CASE ifs_row_id
  1563. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1564. WHEN #{item.ifsRowId} THEN #{item.wcRate}
  1565. </foreach>
  1566. ELSE wc_rate
  1567. END,
  1568. wc_cost_code = CASE ifs_row_id
  1569. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1570. WHEN #{item.ifsRowId} THEN #{item.wcCostCode}
  1571. </foreach>
  1572. ELSE wc_cost_code
  1573. END,
  1574. overhead1_fac = CASE ifs_row_id
  1575. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1576. WHEN #{item.ifsRowId} THEN #{item.overhead1Fac}
  1577. </foreach>
  1578. ELSE overhead1_fac
  1579. END,
  1580. overhead2_fac = CASE ifs_row_id
  1581. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1582. WHEN #{item.ifsRowId} THEN #{item.overhead2Fac}
  1583. </foreach>
  1584. ELSE overhead2_fac
  1585. END,
  1586. overhead1_appl = CASE ifs_row_id
  1587. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1588. WHEN #{item.ifsRowId} THEN #{item.overhead1Appl}
  1589. </foreach>
  1590. ELSE overhead1_appl
  1591. END,
  1592. overhead2_appl = CASE ifs_row_id
  1593. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1594. WHEN #{item.ifsRowId} THEN #{item.overhead2Appl}
  1595. </foreach>
  1596. ELSE overhead2_appl
  1597. END
  1598. WHERE ifs_row_id IN
  1599. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1600. #{item.ifsRowId}
  1601. </foreach>
  1602. </update>
  1603. <select id="getRoutingComponentRowKeyAndVersion" resultType="RoutingComponentEntity">
  1604. select
  1605. site,
  1606. part_no,
  1607. routing_revision,
  1608. routing_type,
  1609. alternative_no,
  1610. operation_no,
  1611. operation_name,
  1612. operation_id,
  1613. ifs_row_id,
  1614. ifs_row_version
  1615. from plm_routing_component
  1616. where operation_id = #{operationId}
  1617. </select>
  1618. <select id="getMaxLocationRowVersion" resultType="java.lang.String">
  1619. select
  1620. isnull(max(ifs_row_version),'')
  1621. from location
  1622. </select>
  1623. <select id="getMaxLaborClassRowVersion" resultType="java.lang.String">
  1624. select
  1625. isnull(max(ifs_row_version),'')
  1626. from labor_class
  1627. </select>
  1628. <select id="getMaxWorkCenterRowVersion" resultType="java.lang.String">
  1629. select
  1630. isnull(max(ifs_row_version),'')
  1631. from work_center
  1632. </select>
  1633. <select id="getMaxWorkCenterCostRowVersion" resultType="java.lang.String">
  1634. select
  1635. isnull(max(ifs_row_version),'')
  1636. from work_center_cost
  1637. </select>
  1638. <select id="selectRoutingHeaderByPartNo" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  1639. SELECT
  1640. site,
  1641. part_no,
  1642. routing_revision,
  1643. routing_type,
  1644. note_text,
  1645. phase_in_date,
  1646. phase_out_date,
  1647. official_flag
  1648. FROM plm_routing_header
  1649. where site = #{site} and part_no = #{partNo} and phase_out_date is null
  1650. </select>
  1651. <select id="selectRoutingDetailByPartNo" resultType="com.spring.modules.part.vo.RoutingDetailVo">
  1652. SELECT
  1653. a.site,
  1654. a.part_no,
  1655. a.routing_type,
  1656. a.routing_revision,
  1657. a.alternative_no,
  1658. a.alternative_description,
  1659. a.rout_template_id,
  1660. a.plan_date,
  1661. a.fixed_lead_time_day,
  1662. a.fixed_lead_time_hour,
  1663. a.variable_lead_time_day,
  1664. a.variable_lead_time_hour,
  1665. a.for_std_lot_by_day,
  1666. a.for_lot_by_day,
  1667. a.min_lot_qty,
  1668. a.note_text as detailNoteText,
  1669. 'Tentative' as status,
  1670. a.official_flag
  1671. FROM plm_routing_detail as a
  1672. inner join plm_routing_header as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision
  1673. where a.site = #{site} and a.part_no = #{partNo} and b.phase_out_date is null
  1674. </select>
  1675. <select id="selectRoutingComponentByPartNo" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  1676. SELECT
  1677. a.site,
  1678. a.part_no,
  1679. a.routing_type,
  1680. a.routing_revision,
  1681. a.alternative_no,
  1682. a.operation_id,
  1683. a.operation_no,
  1684. a.operation_name,
  1685. a.efficiency_factor,
  1686. a.mach_run_factor,
  1687. a.mach_setup_time,
  1688. a.run_time_code,
  1689. a.labor_run_factor,
  1690. a.labor_setup_time,
  1691. a.crew_size,
  1692. a.setup_crew_size,
  1693. a.outside_op_item,
  1694. a.machine_no,
  1695. a.work_center_no,
  1696. a.labor_class_no,
  1697. a.setup_labor_class_no,
  1698. a.overlap,
  1699. a.note_text
  1700. FROM plm_routing_component as a
  1701. inner join plm_routing_header as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision
  1702. where a.site = #{site} and a.part_no = #{partNo} and b.phase_out_date is null
  1703. </select>
  1704. <insert id="saveRoutingHeaderList">
  1705. INSERT INTO plm_routing_header
  1706. (site, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date, create_date, create_by, official_flag) VALUES
  1707. <foreach collection="list" item="item" index="index" separator=",">
  1708. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.noteText}, #{item.phaseInDate}, #{item.phaseOutDate}, getDate(), #{item.createBy}, #{item.officialFlag})
  1709. </foreach>
  1710. </insert>
  1711. <insert id="saveRoutingDetailList">
  1712. INSERT INTO plm_routing_detail
  1713. (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
  1714. <foreach collection="list" item="item" index="index" separator=",">
  1715. (#{item.site}, #{item.partNo}, #{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})
  1716. </foreach>
  1717. </insert>
  1718. <select id="selectRoutingToolByPartNo" resultType="RoutingToolEntity">
  1719. SELECT
  1720. a.site,
  1721. a.part_no,
  1722. a.routing_type,
  1723. a.routing_revision,
  1724. a.alternative_no,
  1725. a.operation_id,
  1726. a.tool_id,
  1727. a.tool_qty,
  1728. a.remark
  1729. FROM routing_tool as a
  1730. inner join plm_routing_header as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision
  1731. where a.site = #{site} and a.part_no = #{partNo} and b.phase_out_date is null
  1732. </select>
  1733. <select id="selectRoutingGuidelineByPartNo" resultType="WorkGuidelineEntity">
  1734. SELECT
  1735. a.site,
  1736. a.part_no,
  1737. a.routing_type,
  1738. a.routing_revision,
  1739. a.alternative_no,
  1740. a.guideline_seq,
  1741. a.guideline_desc,
  1742. a.guideline_text,
  1743. a.guideline_type,
  1744. a.sign_off_required,
  1745. a.inspection_sign_off_required,
  1746. a.operation_id
  1747. FROM plm_routing_work_guide as a
  1748. inner join plm_routing_header as b on a.site = b.site and a.part_no = b.part_no and a.routing_type = b.routing_type and a.routing_revision = b.routing_revision
  1749. where a.site = #{site} and a.part_no = #{partNo} and b.phase_out_date is null
  1750. </select>
  1751. <!-- 查工具列表 -->
  1752. <select id="queryToolList" parameterType="ToolHeader" resultType="ToolHeader">
  1753. SELECT
  1754. site,
  1755. tool_id,
  1756. tool_description
  1757. FROM tool_header
  1758. <where>
  1759. site = #{query.site} and active = 'Y'
  1760. <if test = "query.toolId != null and query.toolId != ''">
  1761. AND tool_id like #{query.toolId}
  1762. </if>
  1763. <if test = "query.toolDescription != null and query.toolDescription != ''">
  1764. AND tool_description like #{query.toolDescription}
  1765. </if>
  1766. </where>
  1767. </select>
  1768. <!-- 清空加工中心成本数据 -->
  1769. <delete id="deleteWorkCenterCostAll">
  1770. TRUNCATE TABLE work_center_cost
  1771. </delete>
  1772. <!-- 通过加工中心查人员等级 -->
  1773. <select id="queryLaborClassByWorkCenterNo" resultType="com.spring.modules.base.entity.PersonnelLevel">
  1774. select
  1775. site,
  1776. level_id,
  1777. level_desc
  1778. from labor_class
  1779. where site = #{site} and level_id = #{levelId}
  1780. </select>
  1781. <select id="routingManagementSearchAny" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  1782. SELECT
  1783. a.site,
  1784. a.part_no,
  1785. b.part_desc as partDesc,
  1786. a.routing_revision,
  1787. a.routing_type,
  1788. a.note_text,
  1789. a.phase_in_date,
  1790. a.phase_out_date,
  1791. a.create_date,
  1792. a.create_by,
  1793. a.update_date,
  1794. a.update_by,
  1795. b.um_id as printUnit,
  1796. c.um_name as printUnitName,
  1797. b.ifs_part_no,
  1798. b.plm_part_no
  1799. FROM plm_routing_header as a
  1800. left join part as b on a.site = b.site and a.part_no = b.part_no
  1801. left join um as c on b.um_id = c.um_id
  1802. <if test="params.whereClause != null and params.whereClause != ''">
  1803. WHERE ${params.whereClause}
  1804. </if>
  1805. <if test="params.orderClause != null and params.orderClause != ''">
  1806. ORDER BY ${params.orderClause}
  1807. </if>
  1808. <if test="params.orderClause == null or params.orderClause == ''">
  1809. order by a.part_no
  1810. </if>
  1811. </select>
  1812. <select id="routingAllInfoSearchAny" resultType="com.spring.modules.part.vo.RoutingInfoVo">
  1813. select
  1814. a.site,
  1815. a.part_no,
  1816. e.part_desc partDesc,
  1817. dbo.get_um_name(e.um_id) printUnitName,
  1818. a.routing_revision,
  1819. a.routing_type,
  1820. a.phase_in_date,
  1821. a.phase_out_date,
  1822. a.note_text,
  1823. b.alternative_no,
  1824. b.alternative_description,
  1825. b.rout_template_id,
  1826. b.plan_date,
  1827. b.fixed_lead_time_day,
  1828. b.fixed_lead_time_hour,
  1829. b.variable_lead_time_day,
  1830. b.variable_lead_time_hour,
  1831. b.for_std_lot_by_day,
  1832. b.for_lot_by_day,
  1833. b.min_lot_qty,
  1834. b.note_text alternativeNoteText,
  1835. b.status,
  1836. c.operation_no,
  1837. c.efficiency_factor,
  1838. c.mach_run_factor,
  1839. c.mach_setup_time,
  1840. c.run_time_code,
  1841. case when c.run_time_code = 'Units/Hour' then '单位/小时'
  1842. when c.run_time_code = 'Hours/Unit' then '小时/单位'
  1843. when c.run_time_code = 'Hours' then '小时'
  1844. else '' end as runTimeCodeDesc,
  1845. c.labor_run_factor,
  1846. c.labor_setup_time,
  1847. c.crew_size,
  1848. c.setup_crew_size,
  1849. c.outside_op_item,
  1850. c.machine_no,
  1851. c.work_center_no,
  1852. dbo.get_workCenter_desc(a.site,c.work_center_no) workCenterDesc,
  1853. c.labor_class_no,
  1854. g.level_desc laborClassDesc,
  1855. c.setup_labor_class_no,
  1856. j.level_desc setupLaborClassDesc,
  1857. c.overlap,
  1858. c.operation_name,
  1859. c.operation_id,
  1860. c.note_text operationNoteText,
  1861. d.tool_id,
  1862. f.tool_description toolDescription,
  1863. d.tool_qty,
  1864. d.remark,
  1865. e.plm_part_no,
  1866. e.ifs_part_no
  1867. from plm_routing_header a
  1868. LEFT JOIN part e on a.site = e.site AND a.part_no = e.part_no
  1869. LEFT JOIN plm_routing_detail 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
  1870. LEFT JOIN plm_routing_component c on a.site = c.site AND a.part_no =c.part_no AND a.routing_revision = c.routing_revision and a.routing_type = c.routing_type and b.alternative_no = c.alternative_no
  1871. LEFT JOIN routing_tool d on a.site = d.site AND a.part_no =d.part_no AND a.routing_revision = d.routing_revision and a.routing_type = d.routing_type and c.alternative_no = d.alternative_no and c.operation_id = d.operation_id
  1872. LEFT JOIN tool_header f on a.site = f.site AND d.tool_id =f.tool_id
  1873. LEFT JOIN labor_class g on a.site = g.site AND c.labor_class_no = g.level_id
  1874. LEFT JOIN labor_class j on a.site = j.site AND c.setup_labor_class_no = j.level_id
  1875. <if test="params.whereClause != null and params.whereClause != ''">
  1876. WHERE ${params.whereClause}
  1877. </if>
  1878. <if test="params.orderClause != null and params.orderClause != ''">
  1879. ORDER BY ${params.orderClause}
  1880. </if>
  1881. <if test="params.orderClause == null or params.orderClause == ''">
  1882. order by a.part_no
  1883. </if>
  1884. </select>
  1885. <select id="queryRoutingToolsByOperationIds" resultType="com.spring.modules.part.vo.RoutingToolVo">
  1886. <trim prefix="(" suffix=")">
  1887. <foreach collection="list" item="item" separator=" UNION ALL ">
  1888. SELECT tool_id FROM routing_tool
  1889. WHERE site = #{item.site}
  1890. AND part_no = #{item.partNo}
  1891. AND routing_revision = #{item.routingRevision}
  1892. AND routing_type = #{item.routingType}
  1893. AND operation_id = #{item.operationId}
  1894. </foreach>
  1895. </trim>
  1896. </select>
  1897. <insert id="copyComponentPart">
  1898. insert into plm_routing_component_copy
  1899. (site, user_name, operation_name, operation_no, efficiency_factor, mach_run_factor, mach_setup_time, run_time_code, labor_run_factor, labor_setup_time, crew_size, setup_crew_size, outside_op_item, machine_no, work_center_no, labor_class_no, setup_labor_class_no, overlap, note_text)
  1900. VALUES
  1901. (#{site}, #{updateBy}, #{operationName}, #{operationNo}, #{efficiencyFactor}, #{machRunFactor}, #{machSetupTime}, #{runTimeCode}, #{laborRunFactor}, #{laborSetupTime}, #{crewSize}, #{setupCrewSize}, #{outsideOpItem}, #{machineNo}, #{workCenterNo}, #{laborClassNo}, #{setupLaborClassNo}, #{overlap}, #{noteText})
  1902. </insert>
  1903. <select id="getCopyComponentList" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  1904. SELECT
  1905. a.id,
  1906. a.site,
  1907. a.operation_no,
  1908. a.operation_name,
  1909. a.efficiency_factor,
  1910. a.mach_run_factor,
  1911. a.mach_setup_time,
  1912. a.run_time_code,
  1913. case when a.run_time_code = 'Units/Hour' then '单位/小时'
  1914. when a.run_time_code = 'Hours/Unit' then '小时/单位'
  1915. when a.run_time_code = 'Hours' then '小时'
  1916. else '' end as runTimeCodeDesc,
  1917. a.labor_run_factor,
  1918. a.labor_setup_time,
  1919. a.crew_size,
  1920. a.setup_crew_size,
  1921. a.outside_op_item,
  1922. a.machine_no,
  1923. a.work_center_no,
  1924. b.work_center_desc,
  1925. b.work_center_type,
  1926. a.labor_class_no,
  1927. dbo.get_labor_class_desc(a.site, a.labor_class_no) as laborClassDesc,
  1928. a.setup_labor_class_no,
  1929. dbo.get_labor_class_desc(a.site, a.setup_labor_class_no) as setupLaborClassDesc,
  1930. a.overlap,
  1931. a.note_text
  1932. FROM plm_routing_component_copy as a
  1933. LEFT JOIN work_center as b on a.site = b.site and a.work_center_no = b.work_center_no
  1934. where a.site = #{site} and a.user_name = #{userName}
  1935. </select>
  1936. <delete id="deletePasteBarList">
  1937. delete from plm_routing_component_copy
  1938. where id = #{id}
  1939. </delete>
  1940. <delete id="cleanPasteBarByUser">
  1941. delete from plm_routing_component_copy
  1942. where site = #{site} and user_name = #{updateBy}
  1943. </delete>
  1944. <update id="updateRoutingDetailStatus">
  1945. update plm_routing_detail
  1946. set status = #{status}, update_date = getdate()
  1947. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  1948. </update>
  1949. </mapper>