<?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.aps.core.mapper.ApsPlatePlanMapper"> 
 | 
     
 | 
    <resultMap type="com.aps.core.domain.ApsPlate.ApsPlatePlan" id="ApsPlatePlanResult"> 
 | 
        <result property="id"    column="id"    /> 
 | 
        <result property="masterPlanner"    column="master_planner"    /> 
 | 
        <result property="weekDay"    column="week_day"    /> 
 | 
        <result property="weekCycle"    column="week_cycle"    /> 
 | 
        <result property="mainPartNumber"    column="main_part_number"    /> 
 | 
        <result property="mainPartDrawingNumber"    column="main_part_drawing_number"    /> 
 | 
        <result property="customer"    column="customer"    /> 
 | 
        <result property="businessType"    column="business_type"    /> 
 | 
        <result property="documentNumber"    column="document_number"    /> 
 | 
        <result property="requirementType"    column="requirement_type"    /> 
 | 
        <result property="documentStatus"    column="document_status"    /> 
 | 
        <result property="itemNumber"    column="item_number"    /> 
 | 
        <result property="drawingNo"    column="drawing_no"    /> 
 | 
        <result property="versionNumber"    column="version_number"    /> 
 | 
        <result property="productionQuantity"    column="production_quantity"    /> 
 | 
        <result property="goodProductsQuantity"    column="good_products_quantity"    /> 
 | 
        <result property="processNumber"    column="process_number"    /> 
 | 
        <result property="workCenter"    column="work_center"    /> 
 | 
        <result property="department"    column="department"    /> 
 | 
        <result property="planStartDay"    column="plan_start_day"    /> 
 | 
        <result property="planEndDay"    column="plan_end_day"    /> 
 | 
        <result property="standbyNumber"    column="standby_number"    /> 
 | 
        <result property="standbyName"    column="standby_name"    /> 
 | 
        <result property="standbyStock"    column="standby_stock"    /> 
 | 
        <result property="nextProcessDeparment"    column="next_process_deparment"    /> 
 | 
        <result property="isSuspended"    column="is_suspended"    /> 
 | 
        <result property="isOutsourcing"    column="is_outsourcing"    /> 
 | 
        <result property="account"    column="account"    /> 
 | 
        <result property="advancedMaterials"    column="advanced_materials"    /> 
 | 
        <result property="advancedDocumentNumber"    column="advanced_document_number"    /> 
 | 
        <result property="advancedRequirementDay"    column="advanced_requirement_day"    /> 
 | 
        <result property="isPlanComplete"    column="is_plan_complete"    /> 
 | 
        <result property="isStockComplete"    column="is_stock_complete"    /> 
 | 
        <result property="hasTurnback"    column="has_turnback"    /> 
 | 
        <result property="hasRisk"    column="has_risk"    /> 
 | 
        <result property="stdOp"    column="std_op"    /> 
 | 
        <result property="opStatus"    column="op_status"    /> 
 | 
        <result property="nextOpName"    column="next_op_name"    /> 
 | 
        <result property="unmatchedQuantity"    column="unmatched_quantity"    /> 
 | 
        <result property="productionBase"    column="production_base"    /> 
 | 
        <result property="orderCreateTime"    column="order_create_time"    /> 
 | 
        <result property="professionalAffiliation"    column="professional_affiliation"    /> 
 | 
        <result property="requireId"    column="require_id"    /> 
 | 
        <result property="version"    column="version"    /> 
 | 
        <result property="approveOn" column="approve_on"    /> 
 | 
        <result property="startWorkDate" column="start_work_date"    /> 
 | 
        <result property="lowOrderCode" column="low_order_code"    /> 
 | 
    </resultMap> 
 | 
  
 | 
    <sql id="selectApsPlatePlanVo"> 
 | 
        select id, master_planner, week_day, week_cycle, main_part_number, main_part_drawing_number, 
 | 
               customer, business_type, document_number, requirement_type, document_status, item_number, 
 | 
               drawing_no, version_number, production_quantity, good_products_quantity, process_number, 
 | 
               work_center, department, plan_start_day, plan_end_day, standby_number, standby_name, 
 | 
               standby_stock, next_process_deparment, is_suspended, is_outsourcing, account, advanced_materials, 
 | 
               advanced_document_number, advanced_requirement_day, is_plan_complete, is_stock_complete, 
 | 
               has_turnback, has_risk, std_op, op_status, next_op_name ,unmatched_quantity,professional_affiliation, 
 | 
                   require_id, version,production_base, order_create_time, approve_on, start_work_date, low_order_code 
 | 
        from aps_plate_plan 
 | 
    </sql> 
 | 
  
 | 
    <select id="selectApsPlatePlanList" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan" resultMap="ApsPlatePlanResult"> 
 | 
        <include refid="selectApsPlatePlanVo"/> 
 | 
        <where>   
 | 
            <if test="masterPlanner != null  and masterPlanner != ''"> and master_planner like '%'|| #{masterPlanner}|| '%'</if> 
 | 
            <if test="weekDay != null "> and week_day = #{weekDay}</if> 
 | 
            <if test="weekCycle != null  and weekCycle != ''"> and week_cycle like '%'||  #{weekCycle}|| '%' </if> 
 | 
            <if test="mainPartNumber != null  and mainPartNumber != ''"> and main_part_number like '%'|| #{mainPartNumber}  ||'%' </if> 
 | 
            <if test="mainPartDrawingNumber != null  and mainPartDrawingNumber != ''"> and main_part_drawing_number like  '%'|| #{mainPartDrawingNumber}|| '%'</if> 
 | 
            <if test="customer != null  and customer != ''"> and customer like  '%' || #{customer} || '%'</if> 
 | 
            <if test="businessType != null  and businessType != ''"> and business_type = #{businessType}</if> 
 | 
            <if test="documentNumber != null  and documentNumber != ''"> and document_number like '%'|| #{documentNumber}|| '%'</if> 
 | 
            <if test="requirementType != null  and requirementType != ''"> and requirement_type like   '%'|| #{requirementType}||'%' </if> 
 | 
            <if test="documentStatus != null  and documentStatus != ''"> and document_status = #{documentStatus}</if> 
 | 
            <if test="itemNumber != null  and itemNumber != ''"> and item_number like '%'|| #{itemNumber}|| '%'</if> 
 | 
            <if test="drawingNo != null  and drawingNo != ''"> and drawing_no like  '%'|| #{drawingNo}|| '%'</if> 
 | 
            <if test="versionNumber != null  and versionNumber != ''"> and version_number like  '%'|| #{versionNumber}|| '%'</if> 
 | 
            <if test="productionQuantity != null "> and production_quantity = #{productionQuantity}</if> 
 | 
            <if test="goodProductsQuantity != null "> and good_products_quantity = #{goodProductsQuantity}</if> 
 | 
            <if test="processNumber != null  and processNumber != ''"> and process_number like  '%'|| #{processNumber}||'%'</if> 
 | 
            <if test="workCenter != null  and workCenter != ''"> and work_center like  '%'|| #{workCenter}||'%'</if> 
 | 
            <if test="department != null  and department != ''"> and department like  '%'|| #{department}||'%'</if> 
 | 
            <if test="params.beginPlanStartDay != null and params.beginPlanStartDay != '' and params.endPlanStartDay != null and params.endPlanStartDay != ''"> and plan_start_day between #{params.beginPlanStartDay} and #{params.endPlanStartDay}</if> 
 | 
            <if test="params.beginPlanEndDay != null and params.beginPlanEndDay != '' and params.endPlanEndDay != null and params.endPlanEndDay != ''"> and plan_end_day between #{params.beginPlanEndDay} and #{params.endPlanEndDay}</if> 
 | 
            <if test="standbyNumber != null  and standbyNumber != ''"> and standby_number like  '%'|| #{standbyNumber}|| '%'</if> 
 | 
            <if test="standbyName != null  and standbyName != ''"> and standby_name like  '%'|| #{standbyName}||'%'</if> 
 | 
            <if test="standbyStock != null "> and standby_stock = #{standbyStock}</if> 
 | 
            <if test="nextProcessDeparment != null  and nextProcessDeparment != ''"> and next_process_deparment like   '%'|| #{nextProcessDeparment}|| '%'</if> 
 | 
            <if test="isSuspended != null "> and is_suspended = #{isSuspended}</if> 
 | 
            <if test="isOutsourcing != null  and isOutsourcing != ''"> and is_outsourcing like  '%'|| #{isOutsourcing}||'%'</if> 
 | 
            <if test="account != null  and account != ''"> and account like  '%'|| #{account}|| '%'</if> 
 | 
            <if test="advancedMaterials != null  and advancedMaterials != ''"> and advanced_materials like  '%'|| #{advancedMaterials}|| '%'</if> 
 | 
            <if test="advancedDocumentNumber != null  and advancedDocumentNumber != ''"> and advanced_document_number  '%'|| #{advancedDocumentNumber}|| '%'</if> 
 | 
            <if test="params.beginAdvancedRequirementDay != null and params.beginAdvancedRequirementDay != '' and params.endAdvancedRequirementDay != null and params.endAdvancedRequirementDay != ''"> and advanced_requirement_day between #{params.beginAdvancedRequirementDay} and #{params.endAdvancedRequirementDay}</if> 
 | 
            <if test="isPlanComplete != null "> and is_plan_complete = #{isPlanComplete}</if> 
 | 
            <if test="isStockComplete != null "> and is_stock_complete = #{isStockComplete}</if> 
 | 
            <if test="hasTurnback != null "> and has_turnback = #{hasTurnback}</if> 
 | 
            <if test="hasRisk != null "> and has_risk = #{hasRisk}</if> 
 | 
            <if test="plant != null "> and plant = #{plant}</if> 
 | 
            <if test="stdOp != null "> and std_op = #{stdOp}</if> 
 | 
            <if test="opStatus != null  and opStatus != ''"> and op_status = #{opStatus}</if> 
 | 
            <if test="nextOpName != null  and nextOpName != ''"> and next_op_name = #{nextOpName}</if> 
 | 
            <if test="lowOrderCode != null  and lowOrderCode != ''"> and low_order_code = #{lowOrderCode}</if> 
 | 
             and del_flag='0' 
 | 
        </where> 
 | 
    </select> 
 | 
     
 | 
    <select id="selectApsPlatePlanById" parameterType="String" resultMap="ApsPlatePlanResult"> 
 | 
        <include refid="selectApsPlatePlanVo"/> 
 | 
        where id = #{id} 
 | 
    </select> 
 | 
  
 | 
    <insert id="insertApsPlatePlan" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan"> 
 | 
        insert into aps_plate_plan 
 | 
        <trim prefix="(" suffix=")" suffixOverrides=","> 
 | 
            <if test="id != null and id != ''">id,</if> 
 | 
            <if test="masterPlanner != null">master_planner,</if> 
 | 
            <if test="weekDay != null">week_day,</if> 
 | 
            <if test="weekCycle != null">week_cycle,</if> 
 | 
            <if test="mainPartNumber != null">main_part_number,</if> 
 | 
            <if test="mainPartDrawingNumber != null">main_part_drawing_number,</if> 
 | 
            <if test="customer != null">customer,</if> 
 | 
            <if test="businessType != null">business_type,</if> 
 | 
            <if test="documentNumber != null">document_number,</if> 
 | 
            <if test="requirementType != null">requirement_type,</if> 
 | 
            <if test="documentStatus != null">document_status,</if> 
 | 
            <if test="itemNumber != null">item_number,</if> 
 | 
            <if test="drawingNo != null">drawing_no,</if> 
 | 
            <if test="versionNumber != null">version_number,</if> 
 | 
            <if test="productionQuantity != null">production_quantity,</if> 
 | 
            <if test="goodProductsQuantity != null">good_products_quantity,</if> 
 | 
            <if test="processNumber != null">process_number,</if> 
 | 
            <if test="workCenter != null">work_center,</if> 
 | 
            <if test="department != null">department,</if> 
 | 
            <if test="planStartDay != null">plan_start_day,</if> 
 | 
            <if test="planEndDay != null">plan_end_day,</if> 
 | 
            <if test="standbyNumber != null">standby_number,</if> 
 | 
            <if test="standbyName != null">standby_name,</if> 
 | 
            <if test="standbyStock != null">standby_stock,</if> 
 | 
            <if test="nextProcessDeparment != null">next_process_deparment,</if> 
 | 
            <if test="isSuspended != null">is_suspended,</if> 
 | 
            <if test="isOutsourcing != null">is_outsourcing,</if> 
 | 
            <if test="account != null">account,</if> 
 | 
            <if test="advancedMaterials != null">advanced_materials,</if> 
 | 
            <if test="advancedDocumentNumber != null">advanced_document_number,</if> 
 | 
            <if test="advancedRequirementDay != null">advanced_requirement_day,</if> 
 | 
            <if test="isPlanComplete != null">is_plan_complete,</if> 
 | 
            <if test="isStockComplete != null">is_stock_complete,</if> 
 | 
            <if test="hasTurnback != null">has_turnback,</if> 
 | 
            <if test="hasRisk != null">has_risk,</if> 
 | 
            <if test="stdOp != null">std_op,</if> 
 | 
            <if test="opStatus != null">op_status,</if> 
 | 
            <if test="nextOpName != null">next_op_name,</if> 
 | 
            <if test="unmatchedQuantity != null">unmatched_quantity,</if> 
 | 
            <if test="lowOrderCode != null">low_order_code,</if> 
 | 
            create_time, 
 | 
         </trim> 
 | 
        <trim prefix="values (" suffix=")" suffixOverrides=","> 
 | 
            <if test="id != null and id != ''">#{id},</if> 
 | 
            <if test="masterPlanner != null">#{masterPlanner},</if> 
 | 
            <if test="weekDay != null">#{weekDay},</if> 
 | 
            <if test="weekCycle != null">#{weekCycle},</if> 
 | 
            <if test="mainPartNumber != null">#{mainPartNumber},</if> 
 | 
            <if test="mainPartDrawingNumber != null">#{mainPartDrawingNumber},</if> 
 | 
            <if test="customer != null">#{customer},</if> 
 | 
            <if test="businessType != null">#{businessType},</if> 
 | 
            <if test="documentNumber != null">#{documentNumber},</if> 
 | 
            <if test="requirementType != null">#{requirementType},</if> 
 | 
            <if test="documentStatus != null">#{documentStatus},</if> 
 | 
            <if test="itemNumber != null">#{itemNumber},</if> 
 | 
            <if test="drawingNo != null">#{drawingNo},</if> 
 | 
            <if test="versionNumber != null">#{versionNumber},</if> 
 | 
            <if test="productionQuantity != null">#{productionQuantity},</if> 
 | 
            <if test="goodProductsQuantity != null">#{goodProductsQuantity},</if> 
 | 
            <if test="processNumber != null">#{processNumber},</if> 
 | 
            <if test="workCenter != null">#{workCenter},</if> 
 | 
            <if test="department != null">#{department},</if> 
 | 
            <if test="planStartDay != null">#{planStartDay},</if> 
 | 
            <if test="planEndDay != null">#{planEndDay},</if> 
 | 
            <if test="standbyNumber != null">#{standbyNumber},</if> 
 | 
            <if test="standbyName != null">#{standbyName},</if> 
 | 
            <if test="standbyStock != null">#{standbyStock},</if> 
 | 
            <if test="nextProcessDeparment != null">#{nextProcessDeparment},</if> 
 | 
            <if test="isSuspended != null">#{isSuspended},</if> 
 | 
            <if test="isOutsourcing != null">#{isOutsourcing},</if> 
 | 
            <if test="account != null">#{account},</if> 
 | 
            <if test="advancedMaterials != null">#{advancedMaterials},</if> 
 | 
            <if test="advancedDocumentNumber != null">#{advancedDocumentNumber},</if> 
 | 
            <if test="advancedRequirementDay != null">#{advancedRequirementDay},</if> 
 | 
            <if test="isPlanComplete != null">#{isPlanComplete},</if> 
 | 
            <if test="isStockComplete != null">#{isStockComplete},</if> 
 | 
            <if test="hasTurnback != null">#{hasTurnback},</if> 
 | 
            <if test="hasRisk != null">#{hasRisk},</if> 
 | 
            <if test="stdOp != null">#{stdOp},</if> 
 | 
            <if test="opStatus != null">#{opStatus},</if> 
 | 
            <if test="nextOpName != null">#{nextOpName},</if> 
 | 
            <if test="unmatchedQuantity != null">#{unmatchedQuantity},</if> 
 | 
            <if test="lowOrderCode != null">#{lowOrderCode},</if> 
 | 
            #{createTime}, 
 | 
         </trim> 
 | 
    </insert> 
 | 
  
 | 
    <update id="updateApsPlatePlan" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan"> 
 | 
        update aps_plate_plan 
 | 
        <trim prefix="SET" suffixOverrides=","> 
 | 
            <if test="masterPlanner != null">master_planner = #{masterPlanner},</if> 
 | 
            <if test="weekDay != null">week_day = #{weekDay},</if> 
 | 
            <if test="weekCycle != null">week_cycle = #{weekCycle},</if> 
 | 
            <if test="mainPartNumber != null">main_part_number = #{mainPartNumber},</if> 
 | 
            <if test="mainPartDrawingNumber != null">main_part_drawing_number = #{mainPartDrawingNumber},</if> 
 | 
            <if test="customer != null  and customer != ''">  and customer like  '%' || #{customer} || '%'  </if> 
 | 
            <if test="businessType != null  and businessType != ''"> and business_type = #{businessType}</if> 
 | 
            <if test="documentNumber != null  and documentNumber != ''"> and document_number  like  '%' || #{documentNumber} || '%'</if> 
 | 
            <if test="requirementType != null">requirement_type = #{requirementType},</if> 
 | 
            <if test="documentStatus != null">document_status = #{documentStatus},</if> 
 | 
            <if test="itemNumber != null">item_number = #{itemNumber},</if> 
 | 
            <if test="drawingNo != null">drawing_no = #{drawingNo},</if> 
 | 
            <if test="versionNumber != null">version_number = #{versionNumber},</if> 
 | 
            <if test="productionQuantity != null">production_quantity = #{productionQuantity},</if> 
 | 
            <if test="goodProductsQuantity != null">good_products_quantity = #{goodProductsQuantity},</if> 
 | 
            <if test="processNumber != null">process_number = #{processNumber},</if> 
 | 
            <if test="workCenter != null">work_center = #{workCenter},</if> 
 | 
            <if test="department != null">department = #{department},</if> 
 | 
            <if test="planStartDay != null">plan_start_day = #{planStartDay},</if> 
 | 
            <if test="planEndDay != null">plan_end_day = #{planEndDay},</if> 
 | 
            <if test="standbyNumber != null">standby_number = #{standbyNumber},</if> 
 | 
            <if test="standbyName != null">standby_name = #{standbyName},</if> 
 | 
            <if test="standbyStock != null">standby_stock = #{standbyStock},</if> 
 | 
            <if test="nextProcessDeparment != null">next_process_deparment = #{nextProcessDeparment},</if> 
 | 
            <if test="isSuspended != null">is_suspended = #{isSuspended},</if> 
 | 
            <if test="isOutsourcing != null">is_outsourcing = #{isOutsourcing},</if> 
 | 
            <if test="account != null">account = #{account},</if> 
 | 
            <if test="advancedMaterials != null">advanced_materials = #{advancedMaterials},</if> 
 | 
            <if test="advancedDocumentNumber != null">advanced_document_number = #{advancedDocumentNumber},</if> 
 | 
            <if test="advancedRequirementDay != null">advanced_requirement_day = #{advancedRequirementDay},</if> 
 | 
            <if test="isPlanComplete != null">is_plan_complete = #{isPlanComplete},</if> 
 | 
            <if test="isStockComplete != null">is_stock_complete = #{isStockComplete},</if> 
 | 
            <if test="hasTurnback != null">has_turnback = #{hasTurnback},</if> 
 | 
            <if test="hasRisk != null">has_risk = #{hasRisk},</if> 
 | 
            <if test="stdOp != null">std_op = #{stdOp},</if> 
 | 
            <if test="opStatus != null"> op_status= #{opStatus},</if> 
 | 
            <if test="nextOpName != null"> next_op_name= #{nextOpName},</if> 
 | 
            <if test="unmatchedQuantity != null"> unmatched_quantity = #{unmatchedQuantity},</if> 
 | 
            <if test="lowOrderCode != null"> low_order_code = #{lowOrderCode},</if> 
 | 
        </trim> 
 | 
        where id = #{id} 
 | 
    </update> 
 | 
  
 | 
    <delete id="deleteApsPlatePlanById" parameterType="String"> 
 | 
        delete from aps_plate_plan where id = #{id} 
 | 
    </delete> 
 | 
  
 | 
    <delete id="deleteApsPlatePlanByIds" parameterType="String"> 
 | 
        delete from aps_plate_plan where id in  
 | 
        <foreach item="id" collection="array" open="(" separator="," close=")"> 
 | 
            #{id} 
 | 
        </foreach> 
 | 
    </delete> 
 | 
  
 | 
    <insert id="insertPlatePlanFromTempByBatchNumber" parameterType="String"> 
 | 
        insert into aps_plate_plan( 
 | 
            id, master_planner, week_day, week_cycle, main_part_number, main_part_drawing_number, customer, business_type, document_number, requirement_type, document_status, item_number, drawing_no, version_number, production_quantity, good_products_quantity, process_number, work_center, department, plan_start_day, plan_end_day, standby_number, standby_name, standby_stock, next_process_deparment, is_suspended, is_outsourcing, account, advanced_materials, advanced_document_number, advanced_requirement_day, is_plan_complete, is_stock_complete, has_turnback, has_risk, std_op, op_status, next_op_name) 
 | 
        SELECT 
 | 
            id, master_planner, week_day, week_cycle, main_part_number, main_part_drawing_number, customer, business_type, document_number, requirement_type, document_status, item_number, drawing_no, version_number, production_quantity, good_products_quantity, process_number, work_center, department, plan_start_day, plan_end_day, standby_number, standby_name, standby_stock, next_process_deparment, is_suspended, is_outsourcing, account, advanced_materials, advanced_document_number, advanced_requirement_day, is_plan_complete, is_stock_complete, has_turnback, has_risk, std_op, op_status, next_op_name 
 | 
        from aps_plate_plan_temp 
 | 
        where batch_number = #{batch_number} 
 | 
    </insert> 
 | 
    <update id="removeAllPlatePlans" parameterType="String"> 
 | 
        update  aps_plate_plan  set del_flag='1' where del_flag ='0' 
 | 
    </update> 
 | 
  
 | 
    <select id="selectPlatePlanByPlantMajor" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan" resultMap="ApsPlatePlanResult"> 
 | 
        with rd as ( 
 | 
            select doc_no,require_date   from aps_plate_require_date where del_flag=0 
 | 
        ) 
 | 
        select 
 | 
            app.id,app.document_number,app.main_part_number,app.item_number,app.plant,app.professional_affiliation,app.production_quantity,app.require_id, 
 | 
            app.unmatched_quantity,app.version, app.production_base,app.order_create_time,app.low_order_code, 
 | 
            app.plan_end_day as orign_end_day, 
 | 
            COALESCE(rd.require_date,app.plan_end_day) as plan_end_day 
 | 
        from aps_plate_plan as  app 
 | 
        left join rd  on app.document_number=rd.doc_no 
 | 
        where app.del_flag='0'  and app.professional_affiliation = 'main' 
 | 
        <if test="plant != null "> and plant = #{plant} </if> 
 | 
        order by document_number ,id 
 | 
    </select> 
 | 
  
 | 
    <select id="selectUnMatchPlateSubPlan" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan" resultMap="ApsPlatePlanResult"> 
 | 
        select  id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity, 
 | 
             unmatched_quantity,version 
 | 
        from aps_plate_plan 
 | 
        where  del_flag='0' and professional_affiliation ='sub' and unmatched_quantity > 0 
 | 
        <if test="plant != null  and plant !='' "> and plant = #{plant}</if> 
 | 
        <if test="itemNumber != null  and itemNumber !='' "> and item_number = #{itemNumber}</if> 
 | 
        order by document_number asc,id asc 
 | 
        limit 1 
 | 
    </select> 
 | 
    <select id="selectUnMatchPlateSubPlanList" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan" resultMap="ApsPlatePlanResult"> 
 | 
        select  id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity, 
 | 
        unmatched_quantity,version 
 | 
        from aps_plate_plan 
 | 
        where  del_flag='0' and professional_affiliation ='sub' and unmatched_quantity > 0 
 | 
        <if test="plant != null  and plant !='' "> and plant = #{plant}</if> 
 | 
        <if test="itemNumber != null  and itemNumber !='' "> and item_number = #{itemNumber}</if> 
 | 
        order by document_number asc,id asc 
 | 
    </select> 
 | 
  
 | 
    <update id="updatePlanUnMatchQtyByVersion" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan"> 
 | 
        update aps_plate_plan 
 | 
        set unmatched_quantity=#{unmatchedQuantity},version=version+1 
 | 
        where id=#{id} and version=#{version} 
 | 
    </update> 
 | 
    <select id="selectPlateRedundantOrderList" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan" resultMap="ApsPlatePlanResult"> 
 | 
        select document_number, item_number, production_quantity, unmatched_quantity, plant, production_base, plan_start_day, plan_end_day, order_create_time 
 | 
        from aps_plate_plan where unmatched_quantity>0 and professional_affiliation='sub' and del_flag='0' 
 | 
        <if test="documentNumber != null and documentNumber != ''"> 
 | 
            and document_number like '%' || #{documentNumber} || '%' 
 | 
        </if> 
 | 
        <if test="itemNumber != null and itemNumber != ''"> 
 | 
            and item_number like '%' || #{itemNumber} || '%' 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <update id="initUnMatchQty" > 
 | 
        update aps_plate_plan 
 | 
            set unmatched_quantity=production_quantity, version=0,require_id=id 
 | 
        where   del_flag='0' and professional_affiliation !='0' 
 | 
    </update> 
 | 
    <update id="updatePlanUnMatchQtyAndVersion" parameterType="com.aps.core.domain.ApsPlate.ApsPlatePlan"> 
 | 
        update aps_plate_plan 
 | 
        set unmatched_quantity=#{unmatchedQuantity},version=#{version},update_time=now() 
 | 
        where id=#{id} 
 | 
    </update> 
 | 
  
 | 
    <select id="selectApsSubPlatePlan" resultType="com.alibaba.fastjson2.JSONObject"> 
 | 
        SELECT id,item_number as "itemNumber",document_number as "documentNumber",production_quantity as "unmatchedQuantity" FROM aps_plate_plan WHERE item_number in (SELECT item_number FROM aps_plate_plan WHERE professional_affiliation='sub'  GROUP BY item_number) order by item_number 
 | 
    </select> 
 | 
</mapper> 
 |