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.

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