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.

873 lines
36 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
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years 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. FROM plm_routing_header as a
  22. left join part as b on a.site = b.site and a.part_no = b.part_no
  23. <where>
  24. a.site = #{query.site}
  25. <if test = "query.partNo != null and query.partNo != ''">
  26. AND a.part_no like #{query.partNo}
  27. </if>
  28. <if test = "query.partDesc != null and query.partDesc != ''">
  29. AND dbo.get_part_name(a.site, a.part_no) like #{query.partDesc}
  30. </if>
  31. </where>
  32. </select>
  33. <!-- 查询物料清单 -->
  34. <select id="queryPartList" parameterType="PartInformationEntity" resultType="RoutingAllFieldEntity">
  35. SELECT
  36. site,
  37. part_no,
  38. part_desc,
  39. spec,
  40. um_id as printUnit,
  41. dbo.get_um_name(um_id) as printUnitName,
  42. part_type
  43. FROM part
  44. <where>
  45. site = #{site} and active = 'Y'
  46. <if test = "partNo != null and partNo != ''">
  47. AND part_no = #{partNo}
  48. </if>
  49. <if test = "partDesc != null and partDesc != ''">
  50. AND part_desc like #{partDesc}
  51. </if>
  52. <if test = "status != null and status != ''">
  53. AND status = #{status}
  54. </if>
  55. </where>
  56. </select>
  57. <!-- 新增Routing主表内容 -->
  58. <insert id="saveRoutingHeader" parameterType="RoutingHeaderEntity">
  59. INSERT INTO plm_routing_header
  60. (site, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date, create_date, create_by)
  61. VALUES
  62. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{noteText}, #{phaseInDate}, #{phaseOutDate}, getDate(), #{createBy})
  63. </insert>
  64. <!-- routing明细新增 -->
  65. <insert id="routingDetailSave" parameterType="RoutingDetailEntity">
  66. INSERT INTO plm_routing_detail
  67. (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)
  68. VALUES
  69. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{alternativeDescription}, #{fixedLeadTimeDay}, #{fixedLeadTimeHour}, #{variableLeadTimeDay}, #{variableLeadTimeHour}, #{forStdLotByDay}, #{forLotByDay}, #{minLotQty}, #{detailNoteText}, getDate(), #{createBy}, #{status}, #{officialFlag})
  70. </insert>
  71. <!-- 新增Routing子明细表内容 -->
  72. <insert id="saveRoutingComponent" parameterType="RoutingComponentEntity" useGeneratedKeys="true" keyProperty="operationId">
  73. INSERT INTO plm_routing_component
  74. (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)
  75. VALUES
  76. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{operationName}, #{operationNo}, #{efficiencyFactor}, #{machRunFactor}, #{machSetupTime}, #{runTimeCode}, #{laborRunFactor}, #{laborSetupTime}, #{crewSize}, #{setupCrewSize}, #{outsideOpItem}, #{machineNo}, #{workCenterNo}, #{laborClassNo}, #{setupLaborClassNo}, #{overlap}, #{noteText}, getDate(), #{createBy})
  77. </insert>
  78. <!-- 查routing明细 -->
  79. <select id="queryRoutingDetail" parameterType="RoutingHeaderEntity" resultType="RoutingDetailEntity">
  80. SELECT
  81. site,
  82. part_no,
  83. routing_type,
  84. routing_revision,
  85. alternative_no,
  86. alternative_description,
  87. rout_template_id,
  88. plan_date,
  89. fixed_lead_time_day,
  90. fixed_lead_time_hour,
  91. variable_lead_time_day,
  92. variable_lead_time_hour,
  93. for_std_lot_by_day,
  94. for_lot_by_day,
  95. min_lot_qty,
  96. note_text as detailNoteText,
  97. status,
  98. official_flag
  99. FROM plm_routing_detail
  100. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  101. </select>
  102. <!-- 查routing明细对象 -->
  103. <select id="queryDetailDataByNo" parameterType="RoutingDetailEntity" resultType="RoutingDetailEntity">
  104. SELECT
  105. site,
  106. part_no,
  107. routing_type,
  108. routing_revision,
  109. alternative_no,
  110. alternative_description,
  111. rout_template_id,
  112. plan_date,
  113. fixed_lead_time_day,
  114. fixed_lead_time_hour,
  115. variable_lead_time_day,
  116. variable_lead_time_hour,
  117. for_std_lot_by_day,
  118. for_lot_by_day,
  119. min_lot_qty,
  120. note_text as detailNoteText,
  121. status,
  122. official_flag
  123. FROM plm_routing_detail
  124. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  125. </select>
  126. <!-- 查routing子明细 -->
  127. <select id="queryRoutingComponent" parameterType="RoutingDetailEntity" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  128. SELECT
  129. site,
  130. part_no,
  131. routing_type,
  132. routing_revision,
  133. alternative_no,
  134. operation_id,
  135. operation_no,
  136. operation_name,
  137. efficiency_factor,
  138. mach_run_factor,
  139. mach_setup_time,
  140. run_time_code,
  141. labor_run_factor,
  142. labor_setup_time,
  143. crew_size,
  144. setup_crew_size,
  145. outside_op_item,
  146. machine_no,
  147. work_center_no,
  148. dbo.get_workCenter_desc(site, work_center_no) as workCenterDesc,
  149. labor_class_no,
  150. dbo.get_labor_class_desc(site, labor_class_no) as laborClassDesc,
  151. setup_labor_class_no,
  152. dbo.get_labor_class_desc(site, setup_labor_class_no) as setupLaborClassDesc,
  153. overlap,
  154. note_text
  155. FROM plm_routing_component
  156. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  157. order by operation_no
  158. </select>
  159. <!-- routing主表编辑 -->
  160. <update id="updateRoutingHeader" parameterType="RoutingAllFieldEntity">
  161. update plm_routing_header
  162. set phase_in_date = #{phaseInDate},
  163. phase_out_date = #{phaseOutDate},
  164. note_text = #{noteText},
  165. update_date = getDate(),
  166. update_by = #{updateBy}
  167. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  168. </update>
  169. <!-- routing明细表编辑 -->
  170. <update id="updateRoutingDetail" parameterType="RoutingDetailEntity">
  171. update plm_routing_detail
  172. set alternative_description = #{alternativeDescription},
  173. rout_template_id = #{routTemplateId},
  174. plan_date = #{planDate},
  175. fixed_lead_time_day = #{fixedLeadTimeDay},
  176. fixed_lead_time_hour = #{fixedLeadTimeHour},
  177. variable_lead_time_day = #{variableLeadTimeDay},
  178. variable_lead_time_hour = #{variableLeadTimeHour},
  179. for_std_lot_by_day = #{forStdLotByDay},
  180. for_lot_by_day = #{forLotByDay},
  181. min_lot_qty = #{minLotQty},
  182. note_text = #{detailNoteText},
  183. update_date = getDate(),
  184. update_by = #{updateBy},
  185. status = #{status}
  186. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  187. </update>
  188. <!-- 删除routing子明细 -->
  189. <delete id="deleteRoutingComponent" parameterType="RoutingAllFieldEntity">
  190. delete from plm_routing_component
  191. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  192. </delete>
  193. <!-- 删除替代 -->
  194. <delete id="routingDetailDelete" parameterType="RoutingDetailEntity">
  195. delete from plm_routing_detail
  196. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  197. </delete>
  198. <!-- routing主表查重 -->
  199. <select id="checkRoutingOnlyOne" parameterType="RoutingAllFieldEntity" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  200. SELECT
  201. site,
  202. part_no,
  203. dbo.get_part_name(site, part_no) as partDesc,
  204. routing_type,
  205. routing_revision,
  206. phase_in_date,
  207. phase_out_date,
  208. note_text,
  209. official_flag
  210. FROM plm_routing_header
  211. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  212. </select>
  213. <!-- routing明细查重 -->
  214. <select id="checkRoutingDetailOnlyOne" parameterType="RoutingDetailEntity" resultType="RoutingDetailEntity">
  215. SELECT
  216. site,
  217. part_no,
  218. routing_type,
  219. routing_revision,
  220. alternative_no,
  221. alternative_description,
  222. rout_template_id,
  223. plan_date,
  224. fixed_lead_time_day,
  225. fixed_lead_time_hour,
  226. variable_lead_time_day,
  227. variable_lead_time_hour,
  228. for_std_lot_by_day,
  229. for_lot_by_day,
  230. min_lot_qty,
  231. note_text as detailNoteText,
  232. row_key,
  233. row_version,
  234. status,
  235. official_flag
  236. FROM plm_routing_detail
  237. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  238. </select>
  239. <!-- 批量删除子明细物料 -->
  240. <delete id="deleteRoutingComponents" parameterType="RoutingComponentEntity">
  241. delete from plm_routing_component
  242. where site = #{site}
  243. and part_no = #{partNo}
  244. and routing_revision = #{routingRevision}
  245. and routing_type = #{routingType}
  246. and alternative_no = #{alternativeNo}
  247. and operation_id = #{operationId}
  248. </delete>
  249. <!-- 删除routing子明细 -->
  250. <delete id="deleteRoutingComponentByPartNo" parameterType="RoutingHeaderEntity">
  251. delete from plm_routing_component
  252. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  253. </delete>
  254. <!-- 删除routing明细 -->
  255. <delete id="deleteRoutingDetailByPartNo" parameterType="RoutingHeaderEntity">
  256. delete from plm_routing_detail
  257. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  258. </delete>
  259. <!-- 删除routing主记录 -->
  260. <delete id="deleteRoutingHeaderByPartNo" parameterType="RoutingHeaderEntity">
  261. delete from plm_routing_header
  262. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  263. </delete>
  264. <!-- routing明细查重 -->
  265. <select id="checkRoutingComponentOnlyOne" parameterType="RoutingComponentEntity" resultType="RoutingComponentEntity">
  266. SELECT
  267. site,
  268. part_no,
  269. routing_type,
  270. routing_revision,
  271. alternative_no,
  272. operation_id,
  273. operation_no
  274. FROM plm_routing_component
  275. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_name = #{operationName} and operation_no = #{operationNo}
  276. </select>
  277. <!-- 修改routing子明细 -->
  278. <update id="updateRoutingComponent" parameterType="RoutingComponentEntity">
  279. update plm_routing_component
  280. set efficiency_factor = #{efficiencyFactor},
  281. mach_run_factor = #{machRunFactor},
  282. mach_setup_time = #{machSetupTime},
  283. run_time_code = #{runTimeCode},
  284. labor_run_factor = #{laborRunFactor},
  285. labor_setup_time = #{laborSetupTime},
  286. crew_size = #{crewSize},
  287. setup_crew_size = #{setupCrewSize},
  288. outside_op_item = #{outsideOpItem},
  289. machine_no = #{machineNo},
  290. work_center_no = #{workCenterNo},
  291. labor_class_no = #{laborClassNo},
  292. setup_labor_class_no = #{setupLaborClassNo},
  293. overlap = #{overlap},
  294. note_text = #{noteText},
  295. update_date = getDate(),
  296. update_by = #{updateBy},
  297. operation_no = #{operationNo},
  298. operation_name = #{operationName}
  299. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  300. </update>
  301. <!-- 查询工序清单 -->
  302. <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity">
  303. SELECT
  304. site,
  305. operation_id,
  306. operation_name,
  307. work_center_no
  308. FROM dbo.operation
  309. <where>
  310. site = #{site}
  311. <if test = "operationId != null and operationId != ''">
  312. AND operation_id like #{operationId}
  313. </if>
  314. <if test = "operationName != null and operationName != ''">
  315. AND operation_name like #{operationName}
  316. </if>
  317. </where>
  318. </select>
  319. <!-- 修改替代状态 -->
  320. <update id="updateAlternativeStatus" parameterType="RoutingDetailEntity">
  321. update plm_routing_detail
  322. set status = #{status},
  323. update_date = getDate(),
  324. update_by = #{updateBy}
  325. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  326. </update>
  327. <!-- 判断是否已有该物料的 routing -->
  328. <select id="queryPartRouting" parameterType="RoutingAllFieldEntity" resultType="com.spring.modules.part.vo.RoutingHeaderVo">
  329. SELECT top 1
  330. site,
  331. part_no,
  332. routing_type,
  333. routing_revision,
  334. phase_in_date,
  335. phase_out_date,
  336. note_text,
  337. official_flag
  338. FROM plm_routing_header
  339. WHERE site = #{site} and part_no = #{partNo} and routing_type = #{routingType} order by routing_revision desc
  340. </select>
  341. <!-- 判断该 routing 是否有 Buildable Obsolete 状态的替代 -->
  342. <select id="queryAlternativeStatus" parameterType="RoutingHeaderEntity" resultType="com.spring.modules.part.vo.RoutingDetailVo">
  343. SELECT
  344. site,
  345. part_no,
  346. routing_revision,
  347. routing_type,
  348. alternative_no,
  349. status
  350. FROM plm_routing_detail
  351. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and (status = 'Buildable' or status = 'Obsolete')
  352. </select>
  353. <!-- 判断 routing 是否存在子料 -->
  354. <select id="queryComponentPart" parameterType="RoutingHeaderEntity" resultType="com.spring.modules.part.vo.RoutingComponentVo">
  355. SELECT
  356. site,
  357. part_no,
  358. routing_revision,
  359. routing_type,
  360. alternative_no,
  361. operation_id
  362. FROM plm_routing_component
  363. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  364. </select>
  365. <!-- 判断工序是否被引用 -->
  366. <select id="checkOperatorIsUse" parameterType="RoutingComponentEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  367. SELECT
  368. site,
  369. part_no,
  370. eng_chg_level,
  371. bom_type,
  372. alternative_no,
  373. component_part
  374. FROM plm_bom_component
  375. WHERE site = #{site} and part_no = #{partNo} and operation_id = #{operationId}
  376. </select>
  377. <!-- 获取ifs header 对象-->
  378. <select id="getRoutingHeader" parameterType="RoutingDetailEntity" resultType="RoutingIfsHeader">
  379. SELECT
  380. site as contract,
  381. part_no,
  382. routing_revision,
  383. routing_type,
  384. phase_in_date,
  385. phase_out_date,
  386. note_text,
  387. 'add' as histType
  388. FROM plm_routing_header
  389. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  390. </select>
  391. <!-- 获取ifs component 对象-->
  392. <select id="getRoutingComponent" parameterType="RoutingDetailEntity" resultType="RoutingIfsItem">
  393. SELECT
  394. site as contract,
  395. part_no,
  396. routing_revision,
  397. routing_type,
  398. alternative_no,
  399. operation_id,
  400. operation_no,
  401. operation_name as operationDesc,
  402. work_center_no,
  403. efficiency_factor,
  404. mach_setup_time,
  405. mach_run_factor,
  406. run_time_code,
  407. labor_run_factor,
  408. labor_setup_time,
  409. crew_size,
  410. setup_crew_size,
  411. machine_no,
  412. note_text,
  413. outside_op_item,
  414. labor_class_no,
  415. setup_labor_class_no,
  416. case when overlap is null then '' else overlap end
  417. FROM plm_routing_component
  418. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  419. </select>
  420. <!-- 获取ifs component 对象-->
  421. <select id="searchRoutingTools" parameterType="RoutingToolEntity" resultType="com.spring.modules.part.vo.RoutingToolVo">
  422. SELECT
  423. a.site,
  424. a.part_no,
  425. a.routing_revision,
  426. a.routing_type,
  427. a.alternative_no,
  428. dbo.plm_get_alternativeDesc(a.site, a.part_no, a.routing_revision, a.routing_type, a.alternative_no) as alternativeDescription,
  429. a.operation_id,
  430. b.operation_no,
  431. b.operation_name,
  432. a.tool_id,
  433. dbo.plm_get_toolDesc(a.site, a.tool_id) as toolDescription,
  434. a.tool_qty,
  435. a.remark,
  436. a.create_date,
  437. a.create_by,
  438. a.update_date,
  439. a.update_by
  440. FROM routing_tool as a
  441. left join plm_routing_component as b on a.operation_id = b.operation_id
  442. WHERE a.site = #{site} and a.part_no = #{partNo} and a.routing_revision = #{routingRevision} and a.routing_type = #{routingType}
  443. </select>
  444. <!-- 新增 routingTools -->
  445. <insert id="routingToolSave" parameterType="RoutingToolEntity">
  446. INSERT INTO routing_tool
  447. (site, part_no, routing_revision, routing_type, alternative_no, operation_id, tool_id, tool_qty, remark, create_date, create_by)
  448. VALUES
  449. (#{site}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{operationId}, #{toolId}, #{toolQty}, #{remark}, getDate(), #{createBy})
  450. </insert>
  451. <!-- 根据替代查询工序列表 -->
  452. <select id="queryOperationListByAlternative" parameterType="OperationEntity" resultType="OperationEntity">
  453. SELECT
  454. site,
  455. part_no,
  456. routing_revision,
  457. routing_type,
  458. alternative_no,
  459. operation_id,
  460. operation_no,
  461. operation_name
  462. FROM plm_routing_component
  463. <where>
  464. site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  465. <if test = "operationNo != null and operationNo != ''">
  466. AND operation_no = #{operationNo}
  467. </if>
  468. <if test = "operationName != null and operationName != ''">
  469. AND operation_name like #{operationName}
  470. </if>
  471. </where>
  472. </select>
  473. <!-- 根据替代查询工序列表 -->
  474. <select id="queryAlternativeListByPartNo" parameterType="AlternativeEntity" resultType="AlternativeEntity">
  475. SELECT
  476. site,
  477. part_no,
  478. routing_revision,
  479. routing_type,
  480. alternative_no,
  481. alternative_description
  482. FROM plm_routing_detail
  483. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  484. </select>
  485. <!-- 编辑 routingTools -->
  486. <update id="routingToolEdit" parameterType="RoutingToolEntity">
  487. update routing_tool
  488. set tool_qty = #{toolQty},
  489. remark = #{remark},
  490. update_date = getDate(),
  491. update_by = #{updateBy}
  492. 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}
  493. </update>
  494. <!-- 删除 routingTools -->
  495. <delete id="deleteRoutingTool" parameterType="RoutingToolEntity">
  496. delete from routing_tool
  497. 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}
  498. </delete>
  499. <select id="routingAllInfoSearch" parameterType="com.spring.modules.part.vo.RoutingHeaderVo" resultType="com.spring.modules.part.vo.RoutingInfoVo">
  500. select
  501. a.site,
  502. a.part_no,
  503. e.part_desc partDesc,
  504. dbo.get_um_name(e.um_id) printUnitName,
  505. a.routing_revision,
  506. a.routing_type,
  507. a.phase_in_date,
  508. a.phase_out_date,
  509. a.note_text,
  510. b.alternative_no,
  511. b.alternative_description,
  512. b.rout_template_id,
  513. b.plan_date,
  514. b.fixed_lead_time_day,
  515. b.fixed_lead_time_hour,
  516. b.variable_lead_time_day,
  517. b.variable_lead_time_hour,
  518. b.for_std_lot_by_day,
  519. b.for_lot_by_day,
  520. b.min_lot_qty,
  521. b.note_text alternativeNoteText,
  522. b.status,
  523. c.operation_no,
  524. c.efficiency_factor,
  525. c.mach_run_factor,
  526. c.mach_setup_time,
  527. c.run_time_code,
  528. c.labor_run_factor,
  529. c.labor_setup_time,
  530. c.crew_size,
  531. c.setup_crew_size,
  532. c.outside_op_item,
  533. c.machine_no,
  534. c.work_center_no,
  535. dbo.get_workCenter_desc(a.site,c.work_center_no) workCenterDesc,
  536. c.labor_class_no,
  537. g.level_desc laborClassDesc,
  538. c.setup_labor_class_no,
  539. j.level_desc setupLaborClassDesc,
  540. c.overlap,
  541. c.operation_name,
  542. c.operation_id,
  543. c.note_text operationNoteText,
  544. d.tool_id,
  545. f.tool_description toolDescription,
  546. d.tool_qty,
  547. d.remark
  548. from plm_routing_header a
  549. LEFT JOIN part e on a.site = e.site AND a.part_no =e.part_no
  550. 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
  551. 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
  552. 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
  553. LEFT JOIN tool_header f on a.site = f.site AND d.tool_id =f.tool_id
  554. LEFT JOIN plm_admin_level g on a.site = g.site AND c.labor_class_no = g.level_id
  555. LEFT JOIN plm_admin_level j on a.site = j.site AND c.setup_labor_class_no = j.level_id
  556. <where>
  557. a.site = #{query.site}
  558. <if test = "query.partNo != null and query.partNo != ''">
  559. AND a.part_no like #{query.partNo}
  560. </if>
  561. <if test = "query.partDesc != null and query.partDesc != ''">
  562. AND e.part_desc like #{query.partDesc}
  563. </if>
  564. </where>
  565. </select>
  566. <!-- 获取routing header 对象-->
  567. <select id="queryRoutingHeader" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  568. SELECT
  569. site,
  570. part_no,
  571. routing_revision,
  572. routing_type,
  573. note_text,
  574. phase_in_date,
  575. phase_out_date,
  576. row_version,
  577. row_key,
  578. official_flag
  579. FROM plm_routing_header
  580. WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  581. </select>
  582. <!-- routing主表编辑 -->
  583. <update id="updateInDate" parameterType="RoutingHeaderEntity">
  584. update plm_routing_header
  585. set phase_out_date = #{phaseOutDate},
  586. update_date = getDate(),
  587. update_by = #{createBy}
  588. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType}
  589. </update>
  590. <!-- 根据RoutingType查询-->
  591. <select id="selectRoutingHeaderByType" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  592. SELECT
  593. site,
  594. part_no,
  595. routing_revision,
  596. routing_type,
  597. note_text,
  598. phase_in_date,
  599. phase_out_date,
  600. row_version,
  601. row_key,
  602. official_flag
  603. FROM plm_routing_header
  604. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} order by routing_revision desc
  605. </select>
  606. <!-- 校验日期是否冲突-->
  607. <select id="queryHeaderPhaseDate" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity">
  608. SELECT
  609. site,
  610. part_no,
  611. routing_revision,
  612. routing_type,
  613. note_text,
  614. phase_in_date,
  615. phase_out_date,
  616. row_version,
  617. row_key,
  618. official_flag
  619. FROM plm_routing_header
  620. <where>
  621. site = #{site} and part_no = #{partNo} and routing_type = #{routingType}
  622. <if test = "phaseOutDate == null">
  623. and phase_in_date >= #{phaseInDate}
  624. </if>
  625. <if test = "phaseOutDate != null">
  626. and #{phaseInDate} >= phase_in_date and phase_out_date >= #{phaseOutDate}
  627. </if>
  628. </where>
  629. </select>
  630. <!-- 将上一个版本的失效日期改为当前生效日期减一 -->
  631. <update id="updatePhaseOutDate" parameterType="RoutingHeaderEntity">
  632. update plm_routing_header
  633. set phase_out_date = #{phaseOutDate},
  634. update_date = getDate(),
  635. update_by = #{createBy}
  636. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  637. </update>
  638. <!-- 查routing子明细 -->
  639. <select id="queryComponent" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity">
  640. SELECT
  641. site,
  642. part_no,
  643. routing_type,
  644. routing_revision,
  645. alternative_no,
  646. operation_id,
  647. operation_no,
  648. operation_name,
  649. efficiency_factor,
  650. mach_run_factor,
  651. mach_setup_time,
  652. run_time_code,
  653. labor_run_factor,
  654. labor_setup_time,
  655. crew_size,
  656. setup_crew_size,
  657. outside_op_item,
  658. machine_no,
  659. work_center_no,
  660. labor_class_no,
  661. setup_labor_class_no,
  662. overlap,
  663. note_text
  664. FROM plm_routing_component
  665. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  666. </select>
  667. <!-- 判断替代是否为正式 -->
  668. <select id="queryRoutingDetailOfficialFlag" parameterType="RoutingComponentEntity" resultType="RoutingDetailEntity">
  669. SELECT
  670. site,
  671. part_no,
  672. routing_type,
  673. routing_revision,
  674. alternative_no,
  675. alternative_description,
  676. rout_template_id,
  677. plan_date,
  678. fixed_lead_time_day,
  679. fixed_lead_time_hour,
  680. variable_lead_time_day,
  681. variable_lead_time_hour,
  682. for_std_lot_by_day,
  683. for_lot_by_day,
  684. min_lot_qty,
  685. note_text as detailNoteText,
  686. status,
  687. official_flag
  688. FROM plm_routing_detail
  689. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo}
  690. </select>
  691. <!-- 获取该routing的全部Tool -->
  692. <select id="getRoutingToolByHeader" parameterType="RoutingHeaderEntity" resultType="RoutingToolEntity">
  693. SELECT
  694. site,
  695. part_no,
  696. routing_type,
  697. routing_revision,
  698. alternative_no,
  699. operation_id,
  700. tool_id,
  701. tool_qty,
  702. remark
  703. FROM routing_tool
  704. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  705. </select>
  706. <!-- 批量新增routingTool -->
  707. <insert id="saveRoutingTool">
  708. insert into routing_tool
  709. (site, part_no, routing_revision, routing_type, alternative_no, operation_id, tool_id, tool_qty, remark, create_date, create_by) VALUES
  710. <foreach collection="list" item="item" index="index" separator=",">
  711. (#{item.site}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.operationId}, #{item.toolId}, #{item.toolQty}, #{item.remark}, getDate(), #{item.createBy})
  712. </foreach>
  713. </insert>
  714. <!-- 获取该routing的全部guideLine -->
  715. <select id="getGuideLineByHeader" parameterType="RoutingHeaderEntity" resultType="WorkGuidelineEntity">
  716. SELECT
  717. site,
  718. part_no,
  719. routing_type,
  720. routing_revision,
  721. alternative_no,
  722. id,
  723. guideline_seq,
  724. guideline_desc,
  725. guideline_text,
  726. guideline_type,
  727. sign_off_required,
  728. inspection_sign_off_required,
  729. operation_id
  730. FROM plm_routing_work_guide
  731. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision}
  732. </select>
  733. <!-- 批量新增guideLine -->
  734. <insert id="saveGuideLine">
  735. insert into plm_routing_work_guide
  736. (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
  737. <foreach collection="list" item="item" index="index" separator=",">
  738. (#{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})
  739. </foreach>
  740. </insert>
  741. <!-- 获取该工序的Tool -->
  742. <select id="getRoutingToolByOperation" parameterType="RoutingComponentEntity" resultType="RoutingToolEntity">
  743. SELECT
  744. site,
  745. part_no,
  746. routing_type,
  747. routing_revision,
  748. alternative_no,
  749. operation_id,
  750. tool_id,
  751. tool_qty,
  752. remark
  753. FROM routing_tool
  754. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  755. </select>
  756. <!-- 获取该替代的全部guideLine -->
  757. <select id="getGuideLineByOperation" parameterType="RoutingComponentEntity" resultType="WorkGuidelineEntity">
  758. SELECT
  759. site,
  760. part_no,
  761. routing_type,
  762. routing_revision,
  763. alternative_no,
  764. id,
  765. guideline_seq,
  766. guideline_desc,
  767. guideline_text,
  768. guideline_type,
  769. sign_off_required,
  770. inspection_sign_off_required,
  771. operation_id
  772. FROM plm_routing_work_guide
  773. where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  774. </select>
  775. <!-- 根据工序删除RoutingTool -->
  776. <delete id="deleteRoutingToolByOperation" parameterType="RoutingComponentEntity">
  777. delete from routing_tool
  778. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  779. </delete>
  780. <!-- 根据工序删除guideLine -->
  781. <delete id="deleteGuideLineByOperation" parameterType="RoutingComponentEntity">
  782. delete from plm_routing_work_guide
  783. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId}
  784. </delete>
  785. <!-- 根据替代删除RoutingTool -->
  786. <delete id="deleteRoutingToolByAlternative" parameterType="RoutingDetailEntity">
  787. delete from routing_tool
  788. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  789. </delete>
  790. <!-- 根据替代删除guideLine -->
  791. <delete id="deleteGuideLineByAlternative" parameterType="RoutingDetailEntity">
  792. delete from plm_routing_work_guide
  793. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  794. </delete>
  795. <select id="queryRoutingDetailList" resultType="com.spring.modules.quotation.entity.QuoteRoutingHeader">
  796. SELECT
  797. site,
  798. part_no,
  799. routing_type,
  800. routing_revision as version,
  801. alternative_no
  802. FROM plm_routing_detail
  803. where site = #{site} and part_no = #{partNo}
  804. </select>
  805. <!-- 查询最大工序号 -->
  806. <select id="queryMaxOperationNo" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity">
  807. SELECT top 1
  808. site,
  809. part_no,
  810. routing_revision,
  811. routing_type,
  812. alternative_no,
  813. operation_no
  814. FROM plm_routing_component
  815. where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
  816. order by operation_no desc
  817. </select>
  818. </mapper>