|
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.xujie.sys.modules.part.mapper.RoutingManagementMapper">
<!-- 材料信息列表 --> <select id="routingManagementSearch" parameterType="com.xujie.sys.modules.part.vo.RoutingHeaderVo" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo"> SELECT a.site, a.bu_no, a.part_no, dbo.qc_get_part_desc(a.site, a.bu_no, a.part_no) as partDesc, a.routing_revision, a.routing_type, a.note_text, a.phase_in_date, a.phase_out_date, a.create_date, a.create_by, a.update_date, a.update_by, b.umid as printUnit, dbo.qc_get_um_name(a.site, b.umid) as printUnitName FROM plm_routing_header as a left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no <where> a.site in (select site from eam_access_site where username = #{query.userName}) and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buNo != null and query.buNo != ''"> AND a.bu_no = #{query.buNo} </if> <if test = "query.partNo != null and query.partNo != ''"> AND a.part_no like '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.qc_get_part_desc(a.site, a.bu_no, a.part_no) like '%' + #{query.partDesc} + '%' </if> <if test = "query.routingType != null and query.routingType != ''"> AND a.routing_type like '%' + #{query.routingType} + '%' </if> <if test = "query.routingRevision != null and query.routingRevision != ''"> AND a.routing_revision like '%' + #{query.routingRevision} + '%' </if> </where> </select>
<!-- 查询物料清单 --> <select id="queryPartList" parameterType="PartInformationEntity" resultType="RoutingAllFieldEntity"> SELECT site, sourceBu as buNo, part_no, part_desc, spec, umid as printUnit, dbo.qc_get_um_name(site, umid) as printUnitName, part_type FROM part <where> site = #{query.site} and sourceBu = #{query.buNo} and part_type not in ('Purchased', 'Purchased (raw)') and active = 'Y' <if test = "query.partNo != null and query.partNo != ''"> AND part_no = #{query.partNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND part_desc like '%' + #{query.partDesc} + '%' </if> </where> </select>
<!-- 查出可创建Routing的物料 --> <select id="queryPartListRouting" parameterType="PartInformationEntity" resultType="RoutingAllFieldEntity"> SELECT site, sourceBu as buNo, part_no, part_desc, spec, umid as printUnit, dbo.qc_get_um_name(site, umid) as printUnitName, part_type FROM part <where> site = #{query.site} and sourceBu = #{query.buNo} and active = 'Y' and part_type not in ('Purchased', 'Purchased (raw)') <if test = "query.partNo != null and query.partNo != ''"> AND part_no like '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND part_desc like '%' + #{query.partDesc} + '%' </if> </where> </select>
<!-- 新增Routing主表内容 --> <insert id="saveRoutingHeader" parameterType="RoutingHeaderEntity"> INSERT INTO plm_routing_header (site, bu_no, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date, create_date, create_by) VALUES (#{site}, #{buNo}, #{partNo}, #{routingRevision}, #{routingType}, #{noteText}, #{phaseInDate}, #{phaseOutDate}, getDate(), #{createBy}) </insert>
<!-- routing明细新增 --> <insert id="routingDetailSave" parameterType="RoutingDetailEntity"> INSERT INTO plm_routing_detail (site, bu_no, 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) VALUES (#{site}, #{buNo}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{alternativeDescription}, #{fixedLeadTimeDay}, #{fixedLeadTimeHour}, #{variableLeadTimeDay}, #{variableLeadTimeHour}, #{forStdLotByDay}, #{forLotByDay}, #{minLotQty}, #{detailNoteText}, getDate(), #{createBy}, #{status}) </insert>
<!-- 新增Routing子明细表内容 --> <insert id="saveRoutingComponent" parameterType="RoutingComponentEntity" useGeneratedKeys="true" keyProperty="operationId"> INSERT INTO plm_routing_component (site, bu_no, 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, mach_cycle_time, labor_cycle_time) VALUES (#{site}, #{buNo}, #{partNo}, #{routingRevision}, #{routingType}, #{alternativeNo}, #{operationName}, #{operationNo}, #{efficiencyFactor}, #{machRunFactor}, #{machSetupTime}, #{runTimeCode}, #{laborRunFactor}, #{laborSetupTime}, #{crewSize,jdbcType=FLOAT}, #{setupCrewSize,jdbcType=FLOAT}, #{outsideOpItem}, #{machineNo}, #{workCenterNo}, #{laborClassNo}, #{setupLaborClassNo}, #{overlap}, #{noteText}, getDate(), #{createBy}, #{machCycleTime}, #{laborCycleTime}) </insert>
<!-- 查routing明细 --> <select id="queryRoutingDetail" parameterType="RoutingHeaderEntity" resultType="RoutingDetailEntity"> SELECT site, bu_no, part_no, routing_type, routing_revision, alternative_no, alternative_description, rout_template_id, plan_date, 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 as detailNoteText, status FROM plm_routing_detail where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} </select>
<!-- 查routing明细对象 --> <select id="queryDetailDataByNo" parameterType="RoutingDetailEntity" resultType="RoutingDetailEntity"> SELECT site, bu_no, part_no, routing_type, routing_revision, alternative_no, alternative_description, rout_template_id, plan_date, 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 as detailNoteText, status FROM plm_routing_detail where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} </select>
<!-- 查routing子明细 --> <select id="queryRoutingComponent" parameterType="RoutingDetailEntity" resultType="com.xujie.sys.modules.part.vo.RoutingComponentVo"> SELECT a.site, a.bu_no, a.part_no, a.routing_type, a.routing_revision, a.alternative_no, a.operation_id, a.operation_no, a.operation_name, a.efficiency_factor, a.mach_run_factor, a.mach_setup_time, a.run_time_code, case when a.run_time_code = 'Units/Hour' then '单位/小时' when a.run_time_code = 'Hours/Unit' then '小时/单位' when a.run_time_code = 'Hours' then '小时' else '' end as runTimeCodeDesc, a.labor_run_factor, a.labor_setup_time, a.crew_size, a.setup_crew_size, a.outside_op_item, a.machine_no, a.work_center_no, b.work_center_desc, b.work_center_type, a.labor_class_no, dbo.get_labor_class_desc(a.site, a.bu_no, a.labor_class_no) as laborClassDesc, a.setup_labor_class_no, dbo.get_labor_class_desc(a.site, a.bu_no, a.setup_labor_class_no) as setupLaborClassDesc, a.overlap, a.note_text, a.mach_cycle_time, a.labor_cycle_time FROM plm_routing_component as a LEFT JOIN work_center as b on a.site = b.site and a.bu_no = b.bu_no and a.work_center_no = b.work_center_no where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo} and a.routing_type = #{routingType} and a.routing_revision = #{routingRevision} and a.alternative_no = #{alternativeNo} order by a.operation_no </select>
<!-- routing主表编辑 --> <update id="updateRoutingHeader" parameterType="RoutingAllFieldEntity"> update plm_routing_header set phase_in_date = #{phaseInDate}, phase_out_date = #{phaseOutDate}, note_text = #{noteText}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </update>
<!-- routing明细表编辑 --> <update id="updateRoutingDetail" parameterType="RoutingDetailEntity"> update plm_routing_detail set alternative_description = #{alternativeDescription}, rout_template_id = #{routTemplateId}, plan_date = #{planDate}, fixed_lead_time_day = #{fixedLeadTimeDay}, fixed_lead_time_hour = #{fixedLeadTimeHour}, variable_lead_time_day = #{variableLeadTimeDay}, variable_lead_time_hour = #{variableLeadTimeHour}, for_std_lot_by_day = #{forStdLotByDay}, for_lot_by_day = #{forLotByDay}, min_lot_qty = #{minLotQty}, note_text = #{detailNoteText}, update_date = getDate(), update_by = #{updateBy}, status = #{status} where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} </update>
<!-- 删除routing子明细 --> <delete id="deleteRoutingComponent"> delete from plm_routing_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} </delete>
<!-- 删除替代 --> <delete id="routingDetailDelete" parameterType="RoutingDetailEntity"> delete from plm_routing_detail where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} </delete>
<!-- routing主表查重 --> <select id="checkRoutingOnlyOne" parameterType="RoutingAllFieldEntity" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo"> SELECT site, bu_no, part_no, dbo.qc_get_part_desc(site, bu_no, part_no) as partDesc, routing_type, routing_revision, phase_in_date, phase_out_date, note_text FROM plm_routing_header where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} </select>
<!-- routing明细查重 --> <select id="checkRoutingDetailOnlyOne" parameterType="RoutingDetailEntity" resultType="RoutingDetailEntity"> SELECT site, bu_no, part_no, routing_type, routing_revision, alternative_no, alternative_description, rout_template_id, plan_date, 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 as detailNoteText, status FROM plm_routing_detail where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} </select>
<!-- 批量删除子明细物料 --> <delete id="deleteRoutingComponents" parameterType="RoutingComponentEntity"> delete from plm_routing_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId} </delete>
<!-- 删除routing子明细 --> <delete id="deleteRoutingComponentByPartNo" parameterType="RoutingHeaderEntity"> delete from plm_routing_component where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </delete>
<!-- 删除routing明细 --> <delete id="deleteRoutingDetailByPartNo" parameterType="RoutingHeaderEntity"> delete from plm_routing_detail where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </delete>
<!-- 删除routing主记录 --> <delete id="deleteRoutingHeaderByPartNo" parameterType="RoutingHeaderEntity"> delete from plm_routing_header where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </delete>
<!-- routing明细查重 --> <select id="checkRoutingComponentOnlyOne" parameterType="RoutingComponentEntity" resultType="RoutingComponentEntity"> SELECT site, bu_no, part_no, routing_type, routing_revision, alternative_no, operation_id, operation_no FROM plm_routing_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_no = #{operationNo} </select>
<!-- 修改routing子明细 --> <update id="updateRoutingComponent" parameterType="RoutingComponentEntity"> update plm_routing_component set efficiency_factor = #{efficiencyFactor}, mach_run_factor = #{machRunFactor}, mach_setup_time = #{machSetupTime}, run_time_code = #{runTimeCode}, labor_run_factor = #{laborRunFactor}, labor_setup_time = #{laborSetupTime}, crew_size = #{crewSize,jdbcType=FLOAT}, setup_crew_size = #{setupCrewSize,jdbcType=FLOAT}, outside_op_item = #{outsideOpItem}, machine_no = #{machineNo}, work_center_no = #{workCenterNo}, labor_class_no = #{laborClassNo}, setup_labor_class_no = #{setupLaborClassNo}, overlap = #{overlap}, note_text = #{noteText}, update_date = getDate(), update_by = #{updateBy}, operation_no = #{operationNo}, operation_name = #{operationName}, mach_cycle_time = #{machCycleTime}, labor_cycle_time = #{laborCycleTime} where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} and operation_id = #{operationId} </update>
<!-- 判断是否已有该物料的 routing --> <select id="queryPartRouting" parameterType="RoutingAllFieldEntity" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo"> SELECT top 1 site, bu_no, part_no, routing_type, routing_revision, phase_in_date, phase_out_date, note_text FROM plm_routing_header WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} order by routing_revision desc </select>
<!-- 判断该 routing 是否有 Buildable Obsolete 状态的替代 --> <select id="queryAlternativeStatus" parameterType="RoutingHeaderEntity" resultType="com.xujie.sys.modules.part.vo.RoutingDetailVo"> SELECT site, part_no, routing_revision, routing_type, alternative_no, status FROM plm_routing_detail WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and (status = 'Buildable' or status = 'Obsolete') </select>
<!-- 判断 routing 是否存在子料 --> <select id="queryComponentPart" parameterType="RoutingHeaderEntity" resultType="com.xujie.sys.modules.part.vo.RoutingComponentVo"> SELECT site, part_no, routing_revision, routing_type, alternative_no, operation_id FROM plm_routing_component WHERE site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </select>
<!-- 判断工序是否被引用 --> <select id="checkOperatorIsUse" parameterType="RoutingComponentEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo"> SELECT site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, component_part FROM plm_bom_component WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and operation_id = #{operationId} </select>
<!-- 获取routing header 对象--> <select id="queryRoutingHeader" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity"> SELECT site, bu_no, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date FROM plm_routing_header WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </select>
<!-- 判断替代是否为正式 --> <select id="queryRoutingDetailOfficialFlag" parameterType="RoutingComponentEntity" resultType="RoutingDetailEntity"> SELECT site, part_no, routing_type, routing_revision, alternative_no, alternative_description, rout_template_id, plan_date, 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 as detailNoteText, status, official_flag FROM plm_routing_detail where site = #{site} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} </select>
<!-- 根据替代删除RoutingTool --> <delete id="deleteRoutingToolByAlternative" parameterType="RoutingDetailEntity"> delete from routing_tool where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} </delete>
<!-- 根据替代删除guideLine --> <delete id="deleteGuideLineByAlternative" parameterType="RoutingDetailEntity"> delete from plm_routing_work_guide where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} </delete>
<!-- 查询最大工序号 --> <select id="queryMaxOperationNo" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity"> SELECT top 1 site, bu_no, part_no, routing_revision, routing_type, alternative_no, operation_no FROM plm_routing_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} order by operation_no desc </select>
<!-- 查routing子明细 --> <select id="queryComponent" parameterType="RoutingDetailEntity" resultType="RoutingComponentEntity"> SELECT site, bu_no, part_no, routing_type, routing_revision, alternative_no, operation_id, operation_no, operation_name, 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, mach_cycle_time, labor_cycle_time FROM plm_routing_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} </select>
<!-- 修改替代状态 --> <update id="updateAlternativeStatus" parameterType="RoutingDetailEntity"> update plm_routing_detail set status = #{status}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo} </update>
<!-- 校验日期是否冲突--> <select id="queryHeaderPhaseDate" parameterType="RoutingHeaderEntity" resultType="RoutingHeaderEntity"> SELECT site, part_no, routing_revision, routing_type, note_text, phase_in_date, phase_out_date FROM plm_routing_header <where> site = #{site} and part_no = #{partNo} and routing_type = #{routingType} <if test = "phaseOutDate == null"> and phase_in_date >= #{phaseInDate} </if> <if test = "phaseOutDate != null"> and #{phaseInDate} >= phase_in_date and phase_out_date >= #{phaseOutDate} </if> </where> </select>
<!-- routing主表编辑 --> <update id="updateInDate" parameterType="RoutingHeaderEntity"> update plm_routing_header set phase_out_date = #{phaseOutDate}, update_date = getDate(), update_by = #{createBy} where site = #{site} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} </update>
<select id="getStandardRoutingOperationByProductGroupId" resultType="com.xujie.sys.modules.part.vo.RoutingComponentVo"> SELECT a.site, a.bu_no, b.operation_no, b.operation_name, b.work_center_no, dbo.get_workCenter_desc(a.site, a.bu_no, b.work_center_no) as workCenterDesc, b.labor_class_no, dbo.get_labor_class_desc(a.site, a.bu_no, b.labor_class_no) as laborClassDesc, b.setup_labor_class_no, dbo.get_labor_class_desc(a.site, a.bu_no, b.setup_labor_class_no) as setupLaborClassDesc, 'Units/Hour' as runTimeCode, 100 as efficiencyFactor, crew_size, setup_crew_size, 0 as machSetupTime, 0 as laborSetupTime FROM part_group_std_operations as a left join standard_routing_operation as b on a.operation_id = b.id where a.site = #{site} and a.bu_no = #{buNo} and a.product_group_id = #{productGroupId} </select>
<!-- 获取的商品组的属性 --> <select id="getPtmCondition" resultType="PgPtmConditionEntity"> SELECT site, bu_no, condition_id, condition_desc, seq_no, condition_desc, product_group_id FROM pg_ptm_condition where site = #{site} and bu_no = #{buNo} and product_group_id = #{productGroupId} </select>
<!-- 查维护的属性集 --> <select id="getConditionItemList" resultType="PtmConditionItemEntity"> SELECT id, site, bu_no, condition_id, item_no, text_value, num_value, record_type FROM ptm_condition_item where site = #{site} and bu_no = #{buNo} and condition_id = #{conditionId} </select>
<select id="getConditionOperationsInfo" resultType="com.xujie.sys.modules.part.vo.RoutingComponentVo"> SELECT a.site, a.bu_no, a.labor_run_factor, a.mach_run_factor, a.labor_cycle_time, a.mach_cycle_time, c.operation_no, c.operation_name FROM ptm_condition_process as a left join part_group_std_operations as b on a.part_group_std_operations_id = b.id left join standard_routing_operation as c on b.operation_id = c.id where a.condition_id = #{conditionId} </select>
</mapper>
|