hongjli
2025-05-16 7cd52b112a2e7da06aa8cfebf19a337be858762f
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aps.core.mapper.ApsPlatePlanMapper">
    
    <resultMap type="ApsPlatePlan" id="ApsPlatePlanResult">
    <resultMap type="com.aps.core.domain.ApsPlatePlan" id="ApsPlatePlanResult">
        <result property="id"    column="id"    />
        <result property="masterPlanner"    column="master_planner"    />
        <result property="weekDay"    column="week_day"    />
@@ -40,13 +40,33 @@
        <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 from aps_plate_plan
        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="ApsPlatePlan" resultMap="ApsPlatePlanResult">
    <select id="selectApsPlatePlanList" parameterType="com.aps.core.domain.ApsPlatePlan" resultMap="ApsPlatePlanResult">
        <include refid="selectApsPlatePlanVo"/>
        <where>  
            <if test="masterPlanner != null  and masterPlanner != ''"> and master_planner like '%'|| #{masterPlanner}|| '%'</if>
@@ -84,6 +104,10 @@
            <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>
@@ -93,7 +117,7 @@
        where id = #{id}
    </select>
    <insert id="insertApsPlatePlan" parameterType="ApsPlatePlan">
    <insert id="insertApsPlatePlan" parameterType="com.aps.core.domain.ApsPlatePlan">
        insert into aps_plate_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
@@ -131,6 +155,11 @@
            <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=",">
@@ -169,11 +198,16 @@
            <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="ApsPlatePlan">
    <update id="updateApsPlatePlan" parameterType="com.aps.core.domain.ApsPlatePlan">
        update aps_plate_plan
        <trim prefix="SET" suffixOverrides=",">
            <if test="masterPlanner != null">master_planner = #{masterPlanner},</if>
@@ -210,6 +244,11 @@
            <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>
@@ -227,9 +266,9 @@
    <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)
            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
            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>
@@ -237,4 +276,66 @@
        update  aps_plate_plan  set del_flag='1' where del_flag ='0'
    </update>
    <select id="selectPlatePlanByPlantMajor" parameterType="com.aps.core.domain.ApsPlatePlan" resultMap="ApsPlatePlanResult">
        select  id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity,require_id,
        unmatched_quantity,version, production_base,plan_end_day,order_create_time,low_order_code
        from aps_plate_plan
        <where>
            <if test="plant != null "> and plant = #{plant} </if>
            <if test="professionalAffiliation != null "> and professional_affiliation = 'main' </if>
              and del_flag='0'
        </where>
        order by document_number asc,id asc
    </select>
    <select id="selectUnMatchPlateSubPlan" parameterType="com.aps.core.domain.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.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.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.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.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>