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.

1835 lines
75 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
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. 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 = #{query.partNo}
  66. </if>
  67. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  68. AND a.plm_part_no = #{query.plmPartNo}
  69. </if>
  70. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  71. AND a.ifs_part_no = #{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 = #{query.partNo}
  100. </if>
  101. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  102. AND a.plm_part_no = #{query.plmPartNo}
  103. </if>
  104. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  105. AND a.ifs_part_no = #{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_id = #{operationId}
  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. </select>
  538. <!-- 新增 routingTools -->
  539. <insert id="routingToolSave" parameterType="com.spring.modules.part.vo.RoutingToolVo" keyProperty="id" useGeneratedKeys="true">
  540. INSERT INTO routing_tool
  541. (site, part_no, routing_revision, routing_type, alternative_no, operation_id, tool_id, tool_qty, remark, create_date, create_by)
  542. VALUES
  543. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{operationId}, #{toolId}, #{toolQty}, #{remark}, getDate(), #{createBy})
  544. </insert>
  545. <!-- 根据替代查询工序列表 -->
  546. <select id="queryOperationListByAlternative" parameterType="OperationEntity" resultType="OperationEntity">
  547. SELECT
  548. site,
  549. part_no,
  550. routing_revision,
  551. routing_type,
  552. alternative_no,
  553. operation_id,
  554. operation_no,
  555. operation_name
  556. FROM plm_routing_component
  557. <where>
  558. site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  559. <if test = "operationNo != null and operationNo != ''">
  560. AND operation_no = #{operationNo}
  561. </if>
  562. <if test = "operationName != null and operationName != ''">
  563. AND operation_name like #{operationName}
  564. </if>
  565. </where>
  566. </select>
  567. <!-- 根据替代查询工序列表 -->
  568. <select id="queryAlternativeListByPartNo" parameterType="AlternativeEntity" resultType="AlternativeEntity">
  569. SELECT
  570. site,
  571. part_no,
  572. routing_revision,
  573. routing_type,
  574. alternative_no,
  575. alternative_description
  576. FROM plm_routing_detail
  577. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  578. </select>
  579. <!-- 编辑 routingTools -->
  580. <update id="routingToolEdit" parameterType="RoutingToolEntity">
  581. update routing_tool
  582. set tool_qty = #{toolQty},
  583. remark = #{remark},
  584. update_date = getDate(),
  585. update_by = #{updateBy}
  586. 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}
  587. </update>
  588. <!-- 删除 routingTools -->
  589. <delete id="deleteRoutingTool" parameterType="RoutingToolEntity">
  590. delete from routing_tool
  591. 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}
  592. </delete>
  593. <select id="routingAllInfoSearch" parameterType="com.spring.modules.part.vo.RoutingHeaderVo" resultType="com.spring.modules.part.vo.RoutingInfoVo">
  594. select
  595. a.site,
  596. a.part_no,
  597. e.part_desc partDesc,
  598. dbo.get_um_name(e.um_id) printUnitName,
  599. a.routing_revision,
  600. a.routing_type,
  601. a.phase_in_date,
  602. a.phase_out_date,
  603. a.note_text,
  604. b.alternative_no,
  605. b.alternative_description,
  606. b.rout_template_id,
  607. b.plan_date,
  608. b.fixed_lead_time_day,
  609. b.fixed_lead_time_hour,
  610. b.variable_lead_time_day,
  611. b.variable_lead_time_hour,
  612. b.for_std_lot_by_day,
  613. b.for_lot_by_day,
  614. b.min_lot_qty,
  615. b.note_text alternativeNoteText,
  616. b.status,
  617. c.operation_no,
  618. c.efficiency_factor,
  619. c.mach_run_factor,
  620. c.mach_setup_time,
  621. c.run_time_code,
  622. case when c.run_time_code = 'Units/Hour' then '单位/小时'
  623. when c.run_time_code = 'Hours/Unit' then '小时/单位'
  624. when c.run_time_code = 'Hours' then '小时'
  625. else '' end as runTimeCodeDesc,
  626. c.labor_run_factor,
  627. c.labor_setup_time,
  628. c.crew_size,
  629. c.setup_crew_size,
  630. c.outside_op_item,
  631. c.machine_no,
  632. c.work_center_no,
  633. dbo.get_workCenter_desc(a.site,c.work_center_no) workCenterDesc,
  634. c.labor_class_no,
  635. g.level_desc laborClassDesc,
  636. c.setup_labor_class_no,
  637. j.level_desc setupLaborClassDesc,
  638. c.overlap,
  639. c.operation_name,
  640. c.operation_id,
  641. c.note_text operationNoteText,
  642. d.tool_id,
  643. f.tool_description toolDescription,
  644. d.tool_qty,
  645. d.remark,
  646. e.plm_part_no,
  647. e.ifs_part_no
  648. from plm_routing_header a
  649. LEFT JOIN part e on a.site = e.site AND a.part_no = e.part_no
  650. 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
  651. 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
  652. 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
  653. LEFT JOIN tool_header f on a.site = f.site AND d.tool_id =f.tool_id
  654. LEFT JOIN labor_class g on a.site = g.site AND c.labor_class_no = g.level_id
  655. LEFT JOIN labor_class j on a.site = j.site AND c.setup_labor_class_no = j.level_id
  656. <where>
  657. a.site = #{query.site}
  658. AND e.show_in_query_flag = 'Y'
  659. <if test = "query.partNo != null and query.partNo != ''">
  660. AND a.part_no like #{query.partNo}
  661. </if>
  662. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  663. AND e.plm_part_no = #{query.plmPartNo}
  664. </if>
  665. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  666. AND e.ifs_part_no = #{query.ifsPartNo}
  667. </if>
  668. <if test = "query.partDesc != null and query.partDesc != ''">
  669. AND e.part_desc like #{query.partDesc}
  670. </if>
  671. </where>
  672. </select>
  673. <!-- 获取routing header 对象-->
  674. <select id="queryRoutingHeader" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  675. SELECT
  676. site,
  677. part_no,
  678. routing_revision,
  679. routing_type,
  680. note_text,
  681. phase_in_date,
  682. phase_out_date,
  683. row_version,
  684. row_key,
  685. official_flag
  686. FROM plm_routing_header
  687. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  688. </select>
  689. <!-- routing主表编辑 -->
  690. <update id="updateInDate" parameterType="RoutingHeaderEntity">
  691. update plm_routing_header
  692. set phase_out_date = #{phaseOutDate},
  693. update_date = getDate(),
  694. update_by = #{createBy}
  695. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  696. </update>
  697. <!-- 根据RoutingType查询-->
  698. <select id="selectRoutingHeaderByType" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  699. SELECT
  700. site,
  701. part_no,
  702. routing_revision,
  703. routing_type,
  704. note_text,
  705. phase_in_date,
  706. phase_out_date,
  707. row_version,
  708. row_key,
  709. official_flag
  710. FROM plm_routing_header
  711. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} order by routing_revision desc
  712. </select>
  713. <!-- 校验日期是否冲突-->
  714. <select id="queryHeaderPhaseDate" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  715. SELECT
  716. site,
  717. part_no,
  718. routing_revision,
  719. routing_type,
  720. note_text,
  721. phase_in_date,
  722. phase_out_date,
  723. row_version,
  724. row_key,
  725. official_flag
  726. FROM plm_routing_header
  727. <where>
  728. site = #{site} and part_no = #{partNo} and routing_type = #{routingType}
  729. <if test = "phaseOutDate == null">
  730. and phase_in_date >= #{phaseInDate}
  731. </if>
  732. <if test = "phaseOutDate != null">
  733. and #{phaseInDate} >= phase_in_date and phase_out_date >= #{phaseOutDate}
  734. </if>
  735. </where>
  736. </select>
  737. <!-- 将上一个版本的失效日期改为当前生效日期减一 -->
  738. <update id="updatePhaseOutDate" parameterType="RoutingHeaderEntity">
  739. update plm_routing_header
  740. set phase_out_date = #{phaseOutDate},
  741. update_date = getDate(),
  742. update_by = #{createBy}
  743. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  744. </update>
  745. <!-- 查routing子明细 -->
  746. <select id="queryComponent" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity">
  747. SELECT
  748. site,
  749. part_no,
  750. routing_type,
  751. routing_revision,
  752. alternative_no,
  753. operation_id,
  754. operation_no,
  755. operation_name,
  756. efficiency_factor,
  757. mach_run_factor,
  758. mach_setup_time,
  759. run_time_code,
  760. labor_run_factor,
  761. labor_setup_time,
  762. crew_size,
  763. setup_crew_size,
  764. outside_op_item,
  765. machine_no,
  766. work_center_no,
  767. labor_class_no,
  768. setup_labor_class_no,
  769. overlap,
  770. note_text,
  771. ifs_row_id,
  772. ifs_row_version
  773. FROM plm_routing_component
  774. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  775. </select>
  776. <!-- 判断替代是否为正式 -->
  777. <select id="queryRoutingDetailOfficialFlag" parameterType="RoutingComponentEntity" resultType="RoutingDetailEntity">
  778. SELECT
  779. site,
  780. part_no,
  781. routing_type,
  782. routing_revision,
  783. alternative_no,
  784. alternative_description,
  785. rout_template_id,
  786. plan_date,
  787. fixed_lead_time_day,
  788. fixed_lead_time_hour,
  789. variable_lead_time_day,
  790. variable_lead_time_hour,
  791. for_std_lot_by_day,
  792. for_lot_by_day,
  793. min_lot_qty,
  794. note_text as detailNoteText,
  795. status,
  796. official_flag
  797. FROM plm_routing_detail
  798. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  799. </select>
  800. <!-- 获取该routing的全部Tool -->
  801. <select id="getRoutingToolByHeader" parameterType="RoutingHeaderEntity" resultType="RoutingToolEntity">
  802. SELECT
  803. id,
  804. site,
  805. part_no,
  806. routing_type,
  807. routing_revision,
  808. alternative_no,
  809. operation_id,
  810. tool_id,
  811. tool_qty,
  812. remark
  813. FROM routing_tool
  814. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  815. </select>
  816. <!-- 批量新增routingTool -->
  817. <insert id="saveRoutingTool">
  818. insert into routing_tool
  819. (site, part_no, routing_revision, routing_type, alternative_no, operation_id, tool_id, tool_qty, remark, create_date, create_by) VALUES
  820. <foreach collection="list" item="item" index="index" separator=",">
  821. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.operationId}, #{item.toolId}, #{item.toolQty}, #{item.remark}, getDate(), #{item.createBy})
  822. </foreach>
  823. </insert>
  824. <!-- 获取该routing的全部guideLine -->
  825. <select id="getGuideLineByHeader" parameterType="RoutingHeaderEntity" resultType="WorkGuidelineEntity">
  826. SELECT
  827. site,
  828. part_no,
  829. routing_type,
  830. routing_revision,
  831. alternative_no,
  832. id,
  833. guideline_seq,
  834. guideline_desc,
  835. guideline_text,
  836. guideline_type,
  837. sign_off_required,
  838. inspection_sign_off_required,
  839. operation_id
  840. FROM plm_routing_work_guide
  841. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  842. </select>
  843. <!-- 批量新增guideLine -->
  844. <insert id="saveGuideLine">
  845. insert into plm_routing_work_guide
  846. (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
  847. <foreach collection="list" item="item" index="index" separator=",">
  848. (#{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})
  849. </foreach>
  850. </insert>
  851. <!-- 获取该工序的Tool -->
  852. <select id="getRoutingToolByOperation" parameterType="RoutingComponentEntity" resultType="RoutingToolEntity">
  853. SELECT
  854. id,
  855. site,
  856. part_no,
  857. routing_type,
  858. routing_revision,
  859. alternative_no,
  860. operation_id,
  861. tool_id,
  862. tool_qty,
  863. remark
  864. FROM routing_tool
  865. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  866. </select>
  867. <!-- 获取该工序的Tool(ifs) -->
  868. <select id="getRoutingToolByOperationToIfs" resultType="RoutingIfsTool">
  869. SELECT
  870. a.id,
  871. a.site as contract,
  872. a.part_no,
  873. a.routing_type,
  874. a.routing_revision,
  875. a.alternative_no,
  876. a.operation_id,
  877. b.operation_no,
  878. a.tool_id,
  879. a.tool_qty as toolQuantity,
  880. a.remark as noteText,
  881. b.ifs_row_id,
  882. b.ifs_row_version
  883. FROM routing_tool as a
  884. 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
  885. 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}
  886. </select>
  887. <!-- 修改工序Tool的 rowKey rowRevision -->
  888. <update id="updateIfsToolRowKeyAndRevision" parameterType="RoutingIfsTool">
  889. update routing_tool
  890. set ifs_row_id = #{ifsRowId},
  891. ifs_row_version = #{ifsRowVersion}
  892. where id = #{id}
  893. </update>
  894. <!-- 获取该替代的全部guideLine -->
  895. <select id="getGuideLineByOperation" parameterType="RoutingComponentEntity" resultType="WorkGuidelineEntity">
  896. SELECT
  897. site,
  898. part_no,
  899. routing_type,
  900. routing_revision,
  901. alternative_no,
  902. id,
  903. guideline_seq,
  904. guideline_desc,
  905. guideline_text,
  906. guideline_type,
  907. sign_off_required,
  908. inspection_sign_off_required,
  909. operation_id
  910. FROM plm_routing_work_guide
  911. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  912. </select>
  913. <!-- 修改工序Guideline的 rowKey rowRevision -->
  914. <update id="updateIfsGuidelineRowKeyAndRevision" parameterType="RoutingIfsGuideLine">
  915. update plm_routing_work_guide
  916. set ifs_row_id = #{ifsRowId},
  917. ifs_row_version = #{ifsRowVersion}
  918. where id = #{id}
  919. </update>
  920. <!-- 获取该工序的Tool(ifs) -->
  921. <select id="getRoutingGuidelineByOperationToIfs" resultType="RoutingIfsGuideLine">
  922. SELECT
  923. a.id,
  924. a.site as contract,
  925. a.part_no,
  926. a.routing_type,
  927. a.routing_revision,
  928. a.alternative_no,
  929. a.operation_id,
  930. b.operation_no,
  931. a.guideline_seq,
  932. a.guideline_desc,
  933. a.guideline_text,
  934. a.guideline_type as operWorkGuideType,
  935. a.sign_off_required as signOffReq,
  936. a.inspection_sign_off_required as inspectSignOffReq,
  937. b.ifs_row_id,
  938. b.ifs_row_version
  939. FROM plm_routing_work_guide as a
  940. 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
  941. 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}
  942. </select>
  943. <!-- 根据工序删除RoutingTool -->
  944. <delete id="deleteRoutingToolByOperation" parameterType="RoutingComponentEntity">
  945. delete from routing_tool
  946. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  947. </delete>
  948. <!-- 根据工序删除guideLine -->
  949. <delete id="deleteGuideLineByOperation" parameterType="RoutingComponentEntity">
  950. delete from plm_routing_work_guide
  951. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  952. </delete>
  953. <!-- 根据替代删除RoutingTool -->
  954. <delete id="deleteRoutingToolByAlternative" parameterType="RoutingDetailEntity">
  955. delete from routing_tool
  956. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  957. </delete>
  958. <!-- 根据替代删除guideLine -->
  959. <delete id="deleteGuideLineByAlternative" parameterType="RoutingDetailEntity">
  960. delete from plm_routing_work_guide
  961. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  962. </delete>
  963. <select id="queryRoutingDetailList" resultType="com.spring.modules.quotation.entity.QuoteRoutingHeader">
  964. SELECT
  965. site,
  966. part_no,
  967. routing_type,
  968. routing_revision as version,
  969. alternative_no
  970. FROM plm_routing_detail
  971. where site = #{site} and part_no = #{partNo}
  972. </select>
  973. <!-- 查询最大工序号 -->
  974. <select id="queryMaxOperationNo" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity">
  975. SELECT top 1
  976. site,
  977. part_no,
  978. routing_revision,
  979. routing_type,
  980. alternative_no,
  981. operation_no
  982. FROM plm_routing_component
  983. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  984. order by operation_no desc
  985. </select>
  986. <!-- 修改工序的 rowKey rowRevision -->
  987. <update id="updateIfsRowKeyAndRevision" parameterType="RoutingIfsItem">
  988. update plm_routing_component
  989. set ifs_row_id = #{ifsRowId},
  990. ifs_row_version = #{ifsRowVersion}
  991. where site = #{contract} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  992. </update>
  993. <!-- 修改工具的 rowKey rowRevision -->
  994. <update id="updateRoutingToolIfsRow" parameterType="com.spring.modules.part.vo.RoutingToolVo">
  995. update routing_tool
  996. set ifs_row_id = #{ifsRowId},
  997. ifs_row_version = #{ifsRowVersion}
  998. where id = #{id}
  999. </update>
  1000. <update id="updateRoutingHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.RoutingDetailVo">
  1001. update plm_routing_header
  1002. set official_flag = 'Y'
  1003. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  1004. </update>
  1005. <update id="updateRoutingDetailOfficialFlag" parameterType="com.spring.modules.part.vo.RoutingDetailVo">
  1006. update plm_routing_detail
  1007. set official_flag = 'Y'
  1008. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  1009. </update>
  1010. <!-- 根据routing的替代查Tool -->
  1011. <select id="getRoutingToolByAlternative" parameterType="com.spring.modules.part.vo.RoutingDetailVo" resultType="RoutingIfsTool">
  1012. SELECT
  1013. a.id,
  1014. a.site as contract,
  1015. a.part_no,
  1016. a.routing_type,
  1017. a.routing_revision,
  1018. a.alternative_no,
  1019. a.operation_id,
  1020. b.operation_no,
  1021. a.tool_id,
  1022. a.tool_qty as toolQuantity,
  1023. a.remark as noteText,
  1024. b.ifs_row_id,
  1025. b.ifs_row_version
  1026. FROM routing_tool as a
  1027. 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
  1028. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo}
  1029. </select>
  1030. <!-- 根据routing的替代查guideLine -->
  1031. <select id="getGuideLineByAlternative" parameterType="com.spring.modules.part.vo.RoutingDetailVo" resultType="RoutingIfsGuideLine">
  1032. SELECT
  1033. a.site as contract,
  1034. a.part_no,
  1035. a.routing_type,
  1036. a.routing_revision,
  1037. a.alternative_no,
  1038. a.id,
  1039. a.guideline_seq,
  1040. a.guideline_desc,
  1041. a.guideline_text,
  1042. a.guideline_type as operWorkGuideType,
  1043. a.sign_off_required as signOffReq,
  1044. a.inspection_sign_off_required as inspectSignOffReq,
  1045. a.operation_id,
  1046. b.ifs_row_id,
  1047. b.ifs_row_version
  1048. FROM plm_routing_work_guide as a
  1049. left join plm_routing_component as b on a.operation_id = b.operation_id
  1050. where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo}
  1051. </select>
  1052. <!-- 获取Tool(ifs) -->
  1053. <select id="getRoutingToolToIfs" parameterType="RoutingToolEntity" resultType="RoutingIfsTool">
  1054. SELECT
  1055. id,
  1056. site as contract,
  1057. part_no,
  1058. routing_type,
  1059. routing_revision,
  1060. alternative_no,
  1061. operation_id,
  1062. tool_id,
  1063. tool_qty as toolQuantity,
  1064. remark as noteText,
  1065. ifs_row_id,
  1066. ifs_row_version
  1067. FROM routing_tool
  1068. 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}
  1069. </select>
  1070. <!-- 修改工序的 rowKey rowRevision -->
  1071. <update id="updateRoutingComponentIfsRow" parameterType="RoutingComponentEntity">
  1072. update plm_routing_component
  1073. set ifs_row_id = #{ifsRowId},
  1074. ifs_row_version = #{ifsRowVersion}
  1075. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  1076. </update>
  1077. <!-- 获取工序(ifs) -->
  1078. <select id="getRoutingComponentToIfs" parameterType="RoutingComponentEntity" resultType="RoutingIfsItem">
  1079. SELECT
  1080. site as contract,
  1081. part_no,
  1082. routing_type,
  1083. routing_revision,
  1084. alternative_no,
  1085. operation_id,
  1086. operation_no,
  1087. efficiency_factor,
  1088. mach_run_factor,
  1089. mach_setup_time,
  1090. run_time_code,
  1091. labor_run_factor,
  1092. labor_setup_time,
  1093. crew_size,
  1094. setup_crew_size,
  1095. outside_op_item,
  1096. machine_no,
  1097. work_center_no,
  1098. labor_class_no,
  1099. setup_labor_class_no,
  1100. overlap,
  1101. note_text,
  1102. operation_name as operationDesc,
  1103. ifs_row_id,
  1104. ifs_row_version
  1105. FROM plm_routing_component
  1106. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  1107. </select>
  1108. <select id="getPLMLocations" resultType="LocationInformationEntity">
  1109. select
  1110. site,
  1111. location_id,
  1112. location_name,
  1113. warehouse_id,
  1114. active,
  1115. location_type,
  1116. ifs_row_version
  1117. from location
  1118. where site in
  1119. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1120. #{item}
  1121. </foreach>
  1122. </select>
  1123. <!-- 批量删除 -->
  1124. <delete id="syncDeleteLocation" parameterType="java.util.List">
  1125. DELETE FROM location WHERE
  1126. <foreach item="item" index="index" collection="list" open="(" separator=") OR (" close=")">
  1127. location_id = #{item.locationId} AND site = #{item.site}
  1128. </foreach>
  1129. </delete>
  1130. <!-- 批量新增 -->
  1131. <insert id="syncSaveLocation">
  1132. INSERT INTO location (site, location_id, location_name, warehouse_id, active, location_type, ifs_row_version)
  1133. VALUES
  1134. <foreach item="item" collection="list" separator=",">
  1135. (#{item.site}, #{item.locationId}, #{item.locationName}, #{item.warehouseId}, #{item.active}, #{item.locationType}, #{item.ifsRowVersion})
  1136. </foreach>
  1137. </insert>
  1138. <!-- 批量更新 -->
  1139. <update id="syncUpdateLocation" parameterType="java.util.List">
  1140. UPDATE location
  1141. SET
  1142. location_name = CASE location_id
  1143. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1144. WHEN #{item.locationId} THEN #{item.locationName}
  1145. </foreach>
  1146. ELSE location_name
  1147. END,
  1148. active = CASE location_id
  1149. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1150. WHEN #{item.locationId} THEN #{item.active}
  1151. </foreach>
  1152. ELSE active
  1153. END,
  1154. warehouse_id = CASE location_id
  1155. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1156. WHEN #{item.locationId} THEN #{item.warehouseId}
  1157. </foreach>
  1158. ELSE warehouse_id
  1159. END,
  1160. location_type = CASE location_id
  1161. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1162. WHEN #{item.locationId} THEN #{item.locationType}
  1163. </foreach>
  1164. ELSE location_type
  1165. END,
  1166. ifs_row_version = CASE location_id
  1167. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1168. WHEN #{item.locationId} THEN #{item.ifsRowVersion}
  1169. </foreach>
  1170. ELSE ifs_row_version
  1171. END
  1172. WHERE location_id IN
  1173. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1174. #{item.locationId}
  1175. </foreach>
  1176. AND site = #{list[0].site}
  1177. </update>
  1178. <!-- &lt;!&ndash; 批量更新 &ndash;&gt;-->
  1179. <!-- <update id="syncUpdateLocation" parameterType="LocationInformationEntity">-->
  1180. <!-- UPDATE location SET-->
  1181. <!-- location_name = #{locationName},-->
  1182. <!-- active = #{active},-->
  1183. <!-- warehouse_id = #{warehouseId},-->
  1184. <!-- location_type = #{locationType},-->
  1185. <!-- ifs_row_version = #{ifsRowVersion}-->
  1186. <!-- WHERE location_id = #{locationId} AND site = #{site}-->
  1187. <!-- </update>-->
  1188. <select id="getPLMLaborClasss" resultType="PersonnelLevel">
  1189. select
  1190. site,
  1191. level_id,
  1192. level_desc,
  1193. level_cost,
  1194. active,
  1195. ifs_row_version
  1196. from labor_class
  1197. where site in
  1198. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1199. #{item}
  1200. </foreach>
  1201. </select>
  1202. <!-- 批量删除 -->
  1203. <delete id="syncDeleteLaborClass" parameterType="java.util.List">
  1204. DELETE FROM labor_class WHERE
  1205. <foreach item="item" index="index" collection="list" open="(" separator=") OR (" close=")">
  1206. level_id = #{item.levelId} AND site = #{item.site}
  1207. </foreach>
  1208. </delete>
  1209. <!-- 批量新增 -->
  1210. <insert id="syncSaveLaborClass">
  1211. INSERT INTO labor_class (site, level_id, level_desc, level_cost, active, ifs_row_version)
  1212. VALUES
  1213. <foreach item="item" collection="list" separator=",">
  1214. (#{item.site}, #{item.levelId}, #{item.levelDesc}, #{item.levelCost}, #{item.active}, #{item.ifsRowVersion})
  1215. </foreach>
  1216. </insert>
  1217. <!-- 批量更新 -->
  1218. <update id="syncUpdateLaborClass" parameterType="java.util.List">
  1219. UPDATE labor_class
  1220. SET
  1221. level_desc = CASE level_id
  1222. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1223. WHEN #{item.levelId} THEN #{item.levelDesc}
  1224. </foreach>
  1225. ELSE level_desc
  1226. END,
  1227. active = CASE level_id
  1228. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1229. WHEN #{item.levelId} THEN #{item.active}
  1230. </foreach>
  1231. ELSE active
  1232. END,
  1233. level_cost = CASE level_id
  1234. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1235. WHEN #{item.levelId} THEN #{item.levelCost,jdbcType=DECIMAL}
  1236. </foreach>
  1237. ELSE level_cost
  1238. END,
  1239. ifs_row_version = CASE level_id
  1240. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1241. WHEN #{item.levelId} THEN #{item.ifsRowVersion}
  1242. </foreach>
  1243. ELSE ifs_row_version
  1244. END
  1245. WHERE level_id IN
  1246. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1247. #{item.levelId}
  1248. </foreach>
  1249. AND site = #{list[0].site}
  1250. </update>
  1251. <!-- &lt;!&ndash; 批量更新 &ndash;&gt;-->
  1252. <!-- <update id="syncUpdateLaborClass" parameterType="PersonnelLevel">-->
  1253. <!-- UPDATE labor_class SET-->
  1254. <!-- level_desc = #{levelDesc},-->
  1255. <!-- active = #{active},-->
  1256. <!-- level_cost = #{levelCost},-->
  1257. <!-- ifs_row_version = #{ifsRowVersion}-->
  1258. <!-- WHERE level_id = #{levelId} AND site = #{site}-->
  1259. <!-- </update>-->
  1260. <select id="getPLMWorkCenters" resultType="WorkCenter">
  1261. select
  1262. site,
  1263. work_center_no,
  1264. work_center_desc,
  1265. work_center_type_db,
  1266. work_center_type,
  1267. average_capacity,
  1268. efficiency,
  1269. utilization,
  1270. capacity_type_db,
  1271. capacity_type,
  1272. um_id,
  1273. active,
  1274. remark,
  1275. pro_line_no,
  1276. can_create_new_roll_flag,
  1277. need_setup_flag,
  1278. ifs_row_version
  1279. from work_center
  1280. where site in
  1281. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1282. #{item}
  1283. </foreach>
  1284. </select>
  1285. <!-- 批量删除 -->
  1286. <delete id="syncDeleteWorkCenter" parameterType="java.util.List">
  1287. DELETE FROM work_center WHERE
  1288. <foreach item="item" index="index" collection="list" open="(" separator=") OR (" close=")">
  1289. work_center_no = #{item.workCenterNo} AND site = #{item.site}
  1290. </foreach>
  1291. </delete>
  1292. <!-- 批量新增 -->
  1293. <insert id="syncSaveWorkCenter">
  1294. 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,
  1295. um_id, active, remark, pro_line_no, can_create_new_roll_flag, need_setup_flag, ifs_row_version)
  1296. VALUES
  1297. <foreach item="item" collection="list" separator=",">
  1298. (#{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},
  1299. #{item.umId}, #{item.active}, #{item.remark}, #{item.proLineNo}, #{item.canCreateNewRollFlag}, #{item.needSetupFlag}, #{item.ifsRowVersion})
  1300. </foreach>
  1301. </insert>
  1302. <!-- 批量更新 -->
  1303. <update id="syncUpdateWorkCenter" parameterType="java.util.List">
  1304. UPDATE work_center
  1305. SET
  1306. work_center_desc = CASE work_center_no
  1307. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1308. WHEN #{item.workCenterNo} THEN #{item.workCenterDesc}
  1309. </foreach>
  1310. ELSE work_center_desc
  1311. END,
  1312. work_center_type_db = CASE work_center_no
  1313. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1314. WHEN #{item.workCenterNo} THEN #{item.workCenterTypeDB}
  1315. </foreach>
  1316. ELSE work_center_type_db
  1317. END,
  1318. work_center_type = CASE work_center_no
  1319. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1320. WHEN #{item.workCenterNo} THEN #{item.workCenterType}
  1321. </foreach>
  1322. ELSE work_center_type
  1323. END,
  1324. average_capacity = CASE work_center_no
  1325. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1326. WHEN #{item.workCenterNo} THEN #{item.averageCapacity,jdbcType=DECIMAL}
  1327. </foreach>
  1328. ELSE average_capacity
  1329. END,
  1330. efficiency = CASE work_center_no
  1331. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1332. WHEN #{item.workCenterNo} THEN #{item.efficiency,jdbcType=DECIMAL}
  1333. </foreach>
  1334. ELSE efficiency
  1335. END,
  1336. utilization = CASE work_center_no
  1337. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1338. WHEN #{item.workCenterNo} THEN #{item.utilization,jdbcType=DECIMAL}
  1339. </foreach>
  1340. ELSE utilization
  1341. END,
  1342. capacity_type_db = CASE work_center_no
  1343. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1344. WHEN #{item.workCenterNo} THEN #{item.capacityTypeDB}
  1345. </foreach>
  1346. ELSE capacity_type_db
  1347. END,
  1348. capacity_type = CASE work_center_no
  1349. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1350. WHEN #{item.workCenterNo} THEN #{item.capacityType}
  1351. </foreach>
  1352. ELSE capacity_type
  1353. END,
  1354. um_id = CASE work_center_no
  1355. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1356. WHEN #{item.workCenterNo} THEN #{item.umId}
  1357. </foreach>
  1358. ELSE um_id
  1359. END,
  1360. active = CASE work_center_no
  1361. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1362. WHEN #{item.workCenterNo} THEN #{item.active}
  1363. </foreach>
  1364. ELSE active
  1365. END,
  1366. remark = CASE work_center_no
  1367. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1368. WHEN #{item.workCenterNo} THEN #{item.remark}
  1369. </foreach>
  1370. ELSE remark
  1371. END,
  1372. pro_line_no = CASE work_center_no
  1373. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1374. WHEN #{item.workCenterNo} THEN #{item.proLineNo}
  1375. </foreach>
  1376. ELSE pro_line_no
  1377. END,
  1378. can_create_new_roll_flag = CASE work_center_no
  1379. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1380. WHEN #{item.workCenterNo} THEN #{item.canCreateNewRollFlag}
  1381. </foreach>
  1382. ELSE can_create_new_roll_flag
  1383. END,
  1384. need_setup_flag = CASE work_center_no
  1385. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1386. WHEN #{item.workCenterNo} THEN #{item.needSetupFlag}
  1387. </foreach>
  1388. ELSE need_setup_flag
  1389. END,
  1390. ifs_row_version = CASE work_center_no
  1391. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1392. WHEN #{item.workCenterNo} THEN #{item.ifsRowVersion}
  1393. </foreach>
  1394. ELSE ifs_row_version
  1395. END
  1396. WHERE work_center_no IN
  1397. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1398. #{item.workCenterNo}
  1399. </foreach>
  1400. AND site = #{list[0].site}
  1401. </update>
  1402. <select id="getPLMWorkCenterCosts" resultType="WorkCenterCost">
  1403. select
  1404. site,
  1405. work_center_no,
  1406. item_no,
  1407. unit_cost,
  1408. overhead1_cost,
  1409. overhead2_cost,
  1410. um_id,
  1411. begin_date,
  1412. end_date,
  1413. remark,
  1414. current_work_center_cost,
  1415. ifs_row_id,
  1416. ifs_row_version,
  1417. cost_set,
  1418. cost_set_desc,
  1419. wc_rate,
  1420. wc_cost_code,
  1421. overhead1_fac,
  1422. overhead2_fac,
  1423. overhead1_appl,
  1424. overhead2_appl
  1425. from work_center_cost
  1426. where site in
  1427. <foreach collection="arr" close=")" open="(" item="item" separator=",">
  1428. #{item}
  1429. </foreach>
  1430. </select>
  1431. <!-- 批量新增 -->
  1432. <insert id="syncSaveWorkCenterCost">
  1433. INSERT INTO work_center_cost (site, work_center_no, item_no, unit_cost, overhead1_cost, overhead2_cost, um_id, begin_date, end_date, remark,
  1434. 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)
  1435. VALUES
  1436. <foreach item="item" collection="list" separator=",">
  1437. (#{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},
  1438. #{item.currentWorkCenterCost,jdbcType=DECIMAL}, #{item.ifsRowId}, #{item.ifsRowVersion}, #{item.costSet}, #{item.costSetDesc}, #{item.wcRate}, #{item.wcCostCode}, #{item.overhead1Fac}, #{item.overhead2Fac}, #{item.overhead1Appl}, #{item.overhead2Appl})
  1439. </foreach>
  1440. </insert>
  1441. <!-- 批量更新 -->
  1442. <update id="syncUpdateWorkCenterCost" parameterType="java.util.List">
  1443. UPDATE work_center_cost
  1444. SET
  1445. item_no = CASE ifs_row_id
  1446. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1447. WHEN #{item.ifsRowId} THEN #{item.itemNo,jdbcType=FLOAT}
  1448. </foreach>
  1449. ELSE item_no
  1450. END,
  1451. unit_cost = CASE ifs_row_id
  1452. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1453. WHEN #{item.ifsRowId} THEN #{item.unitCost,jdbcType=FLOAT}
  1454. </foreach>
  1455. ELSE unit_cost
  1456. END,
  1457. overhead1_cost = CASE ifs_row_id
  1458. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1459. WHEN #{item.ifsRowId} THEN #{item.overhead1Cost,jdbcType=FLOAT}
  1460. </foreach>
  1461. ELSE overhead1_cost
  1462. END,
  1463. overhead2_cost = CASE ifs_row_id
  1464. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1465. WHEN #{item.ifsRowId} THEN #{item.overhead2Cost,jdbcType=FLOAT}
  1466. </foreach>
  1467. ELSE overhead2_cost
  1468. END,
  1469. um_id = CASE ifs_row_id
  1470. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1471. WHEN #{item.ifsRowId} THEN #{item.umId}
  1472. </foreach>
  1473. ELSE um_id
  1474. END,
  1475. begin_date = CASE ifs_row_id
  1476. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1477. WHEN #{item.ifsRowId} THEN #{item.beginDate}
  1478. </foreach>
  1479. ELSE begin_date
  1480. END,
  1481. end_date = CASE ifs_row_id
  1482. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1483. WHEN #{item.ifsRowId} THEN #{item.endDate}
  1484. </foreach>
  1485. ELSE end_date
  1486. END,
  1487. remark = CASE ifs_row_id
  1488. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1489. WHEN #{item.ifsRowId} THEN #{item.remark}
  1490. </foreach>
  1491. ELSE remark
  1492. END,
  1493. current_work_center_cost = CASE ifs_row_id
  1494. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1495. WHEN #{item.ifsRowId} THEN #{item.currentWorkCenterCost}
  1496. </foreach>
  1497. ELSE current_work_center_cost
  1498. END,
  1499. ifs_row_version = CASE ifs_row_id
  1500. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1501. WHEN #{item.ifsRowId} THEN #{item.ifsRowVersion}
  1502. </foreach>
  1503. ELSE ifs_row_version
  1504. END,
  1505. cost_set = CASE ifs_row_id
  1506. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1507. WHEN #{item.ifsRowId} THEN #{item.costSet}
  1508. </foreach>
  1509. ELSE cost_set
  1510. END,
  1511. cost_set_desc = CASE ifs_row_id
  1512. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1513. WHEN #{item.ifsRowId} THEN #{item.costSetDesc}
  1514. </foreach>
  1515. ELSE cost_set_desc
  1516. END,
  1517. wc_rate = CASE ifs_row_id
  1518. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1519. WHEN #{item.ifsRowId} THEN #{item.wcRate}
  1520. </foreach>
  1521. ELSE wc_rate
  1522. END,
  1523. wc_cost_code = CASE ifs_row_id
  1524. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1525. WHEN #{item.ifsRowId} THEN #{item.wcCostCode}
  1526. </foreach>
  1527. ELSE wc_cost_code
  1528. END,
  1529. overhead1_fac = CASE ifs_row_id
  1530. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1531. WHEN #{item.ifsRowId} THEN #{item.overhead1Fac}
  1532. </foreach>
  1533. ELSE overhead1_fac
  1534. END,
  1535. overhead2_fac = CASE ifs_row_id
  1536. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1537. WHEN #{item.ifsRowId} THEN #{item.overhead2Fac}
  1538. </foreach>
  1539. ELSE overhead2_fac
  1540. END,
  1541. overhead1_appl = CASE ifs_row_id
  1542. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1543. WHEN #{item.ifsRowId} THEN #{item.overhead1Appl}
  1544. </foreach>
  1545. ELSE overhead1_appl
  1546. END,
  1547. overhead2_appl = CASE ifs_row_id
  1548. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  1549. WHEN #{item.ifsRowId} THEN #{item.overhead2Appl}
  1550. </foreach>
  1551. ELSE overhead2_appl
  1552. END
  1553. WHERE ifs_row_id IN
  1554. <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
  1555. #{item.ifsRowId}
  1556. </foreach>
  1557. </update>
  1558. <select id="getRoutingComponentRowKeyAndVersion" resultType="RoutingComponentEntity">
  1559. select
  1560. site,
  1561. part_no,
  1562. routing_revision,
  1563. routing_type,
  1564. alternative_no,
  1565. operation_no,
  1566. operation_name,
  1567. operation_id,
  1568. ifs_row_id,
  1569. ifs_row_version
  1570. from plm_routing_component
  1571. where operation_id = #{operationId}
  1572. </select>
  1573. <select id="getMaxLocationRowVersion" resultType="java.lang.String">
  1574. select
  1575. isnull(max(ifs_row_version),'')
  1576. from location
  1577. </select>
  1578. <select id="getMaxLaborClassRowVersion" resultType="java.lang.String">
  1579. select
  1580. isnull(max(ifs_row_version),'')
  1581. from labor_class
  1582. </select>
  1583. <select id="getMaxWorkCenterRowVersion" resultType="java.lang.String">
  1584. select
  1585. isnull(max(ifs_row_version),'')
  1586. from work_center
  1587. </select>
  1588. <select id="getMaxWorkCenterCostRowVersion" resultType="java.lang.String">
  1589. select
  1590. isnull(max(ifs_row_version),'')
  1591. from work_center_cost
  1592. </select>
  1593. <select id="selectRoutingHeaderByPartNo" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  1594. SELECT
  1595. site,
  1596. part_no,
  1597. routing_revision,
  1598. routing_type,
  1599. note_text,
  1600. phase_in_date,
  1601. phase_out_date,
  1602. official_flag
  1603. FROM plm_routing_header
  1604. where site = #{site} and part_no = #{partNo}
  1605. </select>
  1606. <select id="selectRoutingDetailByPartNo" resultType="com.spring.modules.part.vo.RoutingDetailVo">
  1607. SELECT
  1608. site,
  1609. part_no,
  1610. routing_type,
  1611. routing_revision,
  1612. alternative_no,
  1613. alternative_description,
  1614. rout_template_id,
  1615. plan_date,
  1616. fixed_lead_time_day,
  1617. fixed_lead_time_hour,
  1618. variable_lead_time_day,
  1619. variable_lead_time_hour,
  1620. for_std_lot_by_day,
  1621. for_lot_by_day,
  1622. min_lot_qty,
  1623. note_text as detailNoteText,
  1624. 'Tentative' as status,
  1625. official_flag
  1626. FROM plm_routing_detail
  1627. where site = #{site} and part_no = #{partNo}
  1628. </select>
  1629. <select id="selectRoutingComponentByPartNo" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  1630. SELECT
  1631. site,
  1632. part_no,
  1633. routing_type,
  1634. routing_revision,
  1635. alternative_no,
  1636. operation_id,
  1637. operation_no,
  1638. operation_name,
  1639. efficiency_factor,
  1640. mach_run_factor,
  1641. mach_setup_time,
  1642. run_time_code,
  1643. labor_run_factor,
  1644. labor_setup_time,
  1645. crew_size,
  1646. setup_crew_size,
  1647. outside_op_item,
  1648. machine_no,
  1649. work_center_no,
  1650. labor_class_no,
  1651. setup_labor_class_no,
  1652. overlap,
  1653. note_text
  1654. FROM plm_routing_component
  1655. where site = #{site} and part_no = #{partNo}
  1656. </select>
  1657. <insert id="saveRoutingHeaderList">
  1658. INSERT INTO plm_routing_header
  1659. (site, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date, create_date, create_by, official_flag) VALUES
  1660. <foreach collection="list" item="item" index="index" separator=",">
  1661. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.noteText}, #{item.phaseInDate}, #{item.phaseOutDate}, getDate(), #{item.createBy}, #{item.officialFlag})
  1662. </foreach>
  1663. </insert>
  1664. <insert id="saveRoutingDetailList">
  1665. INSERT INTO plm_routing_detail
  1666. (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
  1667. <foreach collection="list" item="item" index="index" separator=",">
  1668. (#{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})
  1669. </foreach>
  1670. </insert>
  1671. <select id="selectRoutingToolByPartNo" resultType="RoutingToolEntity">
  1672. SELECT
  1673. site,
  1674. part_no,
  1675. routing_type,
  1676. routing_revision,
  1677. alternative_no,
  1678. operation_id,
  1679. tool_id,
  1680. tool_qty,
  1681. remark
  1682. FROM routing_tool
  1683. where site = #{site} and part_no = #{partNo}
  1684. </select>
  1685. <select id="selectRoutingGuidelineByPartNo" resultType="WorkGuidelineEntity">
  1686. SELECT
  1687. site,
  1688. part_no,
  1689. routing_type,
  1690. routing_revision,
  1691. alternative_no,
  1692. guideline_seq,
  1693. guideline_desc,
  1694. guideline_text,
  1695. guideline_type,
  1696. sign_off_required,
  1697. inspection_sign_off_required,
  1698. operation_id
  1699. FROM plm_routing_work_guide
  1700. where site = #{site} and part_no = #{partNo}
  1701. </select>
  1702. <!-- 查工具列表 -->
  1703. <select id="queryToolList" parameterType="ToolHeader" resultType="ToolHeader">
  1704. SELECT
  1705. site,
  1706. tool_id,
  1707. tool_description
  1708. FROM tool_header
  1709. <where>
  1710. site = #{query.site} and active = 'Y'
  1711. <if test = "query.toolId != null and query.toolId != ''">
  1712. AND tool_id like #{query.toolId}
  1713. </if>
  1714. <if test = "query.toolDescription != null and query.toolDescription != ''">
  1715. AND tool_description like #{query.toolDescription}
  1716. </if>
  1717. </where>
  1718. </select>
  1719. <!-- 清空加工中心成本数据 -->
  1720. <delete id="deleteWorkCenterCostAll">
  1721. TRUNCATE TABLE work_center_cost
  1722. </delete>
  1723. <!-- 通过加工中心查人员等级 -->
  1724. <select id="queryLaborClassByWorkCenterNo" resultType="com.spring.modules.base.entity.PersonnelLevel">
  1725. select
  1726. site,
  1727. level_id,
  1728. level_desc
  1729. from labor_class
  1730. where site = #{site} and level_id = #{levelId}
  1731. </select>
  1732. </mapper>