sfd
2025-05-26 2a64b537e8e3bce9ce030585a3da17d48379c0ad
aps-modules/aps-job/src/main/resources/mapper/job/ApsWorkOrderJobMapper.xml
@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aps.job.mapper.ApsWorkOrderJobMapper">
    
    <resultMap type="ApsWorkOrderJob" id="ApsWorkOrderJobResult">
    <resultMap type="com.aps.job.domain.ApsWorkOrderJob" id="ApsWorkOrderJobResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="order_id"    />
        <result property="docNo"    column="doc_no"    />
@@ -35,18 +35,26 @@
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="processStatus"    column="process_status"    />
        <result property="stdOp"    column="std_op"    />
        <result property="opStatus"    column="op_status"    />
        <result property="nextOpName"    column="next_op_name"    />
        <result property="lowOrderCode"    column="low_order_code"    />
        <result property="orderCreateTime"    column="order_create_time"    />
        <result property="approveOn"    column="approve_on"    />
        <result property="startWorkDate"    column="start_work_date"    />
    </resultMap>
    <sql id="selectApsWorkOrderJobVo">
        select id, order_id, doc_no, mainitem_code, mainitem_figure, customer_name, business_type, demand_type,
               doc_status, item_code, item_figure, item_figure_version, pruduct_qty, work_qty, op_num, work_center,
               dept, start_date, complete_date, next_dept, is_hold_release, is_out_source, org, page_num, page_index,
               del_flag, create_by, create_time, update_by, update_time , process_status,org_code
               del_flag, create_by, create_time, update_by, update_time , process_status,org_code, std_op, op_status, next_op_name,
               low_order_code, order_create_time, approve_on, start_work_date
        from aps_work_order_job
    </sql>
    <select id="selectApsWorkOrderJobList" parameterType="ApsWorkOrderJob" resultMap="ApsWorkOrderJobResult">
    <select id="selectApsWorkOrderJobList" parameterType="com.aps.job.domain.ApsWorkOrderJob" resultMap="ApsWorkOrderJobResult">
        <include refid="selectApsWorkOrderJobVo"/>
        <where>  
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
@@ -76,6 +84,44 @@
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="processStatus != null  and processStatus != ''"> and process_status = #{processStatus}</if>
            <if test="delFlag != null  and delFlag != ''"> and del_flag = #{delFlag}</if>
            <if test="opStatus != null  and opStatus != ''"> and op_status = #{opStatus}</if>
            <if test="nextOpName != null  and nextOpName != ''"> and next_op_name = #{nextOpName}</if>
        </where>
    </select>
    <select id="selectApsWorkOrderJobListDocNoNotNull" parameterType="com.aps.job.domain.ApsWorkOrderJob" resultMap="ApsWorkOrderJobResult">
        <include refid="selectApsWorkOrderJobVo"/>
        <where>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="docNo != null  and docNo != ''"> and doc_no = #{docNo}</if>
            <if test="mainitemCode != null  and mainitemCode != ''"> and mainitem_code = #{mainitemCode}</if>
            <if test="mainitemFigure != null  and mainitemFigure != ''"> and mainitem_figure = #{mainitemFigure}</if>
            <if test="customerName != null  and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
            <if test="businessType != null "> and business_type = #{businessType}</if>
            <if test="demandType != null  and demandType != ''"> and demand_type = #{demandType}</if>
            <if test="docStatus != null "> and doc_status = #{docStatus}</if>
            <if test="itemCode != null  and itemCode != ''"> and item_code = #{itemCode}</if>
            <if test="itemFigure != null  and itemFigure != ''"> and item_figure = #{itemFigure}</if>
            <if test="itemFigureVersion != null  and itemFigureVersion != ''"> and item_figure_version = #{itemFigureVersion}</if>
            <if test="pruductQty != null "> and pruduct_qty = #{pruductQty}</if>
            <if test="workQty != null "> and work_qty = #{workQty}</if>
            <if test="opNum != null  and opNum != ''"> and op_num = #{opNum}</if>
            <if test="workCenter != null "> and work_center = #{workCenter}</if>
            <if test="dept != null  and dept != ''"> and dept = #{dept}</if>
            <if test="startDate != null  and startDate != ''"> and start_date = #{startDate}</if>
            <if test="completeDate != null  and completeDate != ''"> and complete_date = #{completeDate}</if>
            <if test="nextDept != null  and nextDept != ''"> and next_dept = #{nextDept}</if>
            <if test="isHoldRelease != null "> and is_hold_release = #{isHoldRelease}</if>
            <if test="isOutSource != null  and isOutSource != ''"> and is_out_source = #{isOutSource}</if>
            <if test="org != null  and org != ''"> and org = #{org}</if>
            <if test="pageNum != null "> and page_num = #{pageNum}</if>
            <if test="pageIndex != null "> and page_index = #{pageIndex}</if>
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="processStatus != null  and processStatus != ''"> and process_status = #{processStatus}</if>
            <if test="delFlag != null  and delFlag != ''"> and del_flag = #{delFlag}</if>
            <if test="opStatus != null  and opStatus != ''"> and op_status = #{opStatus}</if>
            <if test="nextOpName != null  and nextOpName != ''"> and next_op_name = #{nextOpName}</if>
            and doc_no is not null
        </where>
    </select>
    
@@ -84,7 +130,7 @@
        where id = #{id}
    </select>
    <insert id="insertApsWorkOrderJob" parameterType="ApsWorkOrderJob" useGeneratedKeys="true" keyProperty="id">
    <insert id="insertApsWorkOrderJob" parameterType="com.aps.job.domain.ApsWorkOrderJob" useGeneratedKeys="true" keyProperty="id">
        insert into aps_work_order_job
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
@@ -118,6 +164,9 @@
            <if test="updateTime != null">update_time,</if>
            <if test="orgCode != null">org_code,</if>
            <if test="processStatus != null">process_status,</if>
            <if test="stdOp != null">std_op,</if>
            <if test="opStatus != null">op_status,</if>
            <if test="nextOpName != null">next_op_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
@@ -151,10 +200,13 @@
            <if test="updateTime != null">#{updateTime},</if>
            <if test="orgCode != null">#{orgCode},</if>
            <if test="processStatus != null">#{processStatus},</if>
            <if test="stdOp != null">#{stdOp},</if>
            <if test="opStatus != null">#{opStatus},</if>
            <if test="nextOpName != null">#{nextOpName},</if>
         </trim>
    </insert>
    <update id="updateApsWorkOrderJob" parameterType="ApsWorkOrderJob">
    <update id="updateApsWorkOrderJob" parameterType="com.aps.job.domain.ApsWorkOrderJob">
        update aps_work_order_job
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
@@ -188,6 +240,9 @@
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="orgCode != null"> org_code= #{orgCode},</if>
            <if test="processStatus != null"> process_status= #{processStatus},</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>
        </trim>
        where id = #{id}
    </update>
@@ -206,6 +261,7 @@
    <insert id="batchInsertApsWorkOrderJob" parameterType="java.util.List">
        insert into aps_work_order_job
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id,
            order_id,
            doc_no,
            mainitem_code,
@@ -236,11 +292,19 @@
            update_by,
            update_time,
            org_code,
            process_status
            process_status,
            std_op,
            op_status,
            next_op_name,
            low_order_code,
            order_create_time,
            approve_on,
            start_work_date
        </trim>
        values
        <foreach collection="list" item="job" separator=",">
            (
            #{job.id},
            #{job.orderId},
            #{job.docNo},
            #{job.mainitemCode},
@@ -271,7 +335,14 @@
            #{job.updateBy},
            #{job.updateTime},
            #{job.orgCode},
            #{job.processStatus}
            #{job.processStatus},
            #{job.stdOp},
            #{job.opStatus},
            #{job.nextOpName},
            #{job.lowOrderCode},
            #{job.orderCreateTime},
            #{job.approveOn},
            #{job.startWorkDate}
            )
        </foreach>
    </insert>
@@ -281,4 +352,122 @@
            #{id}
        </foreach>
    </delete>
    <update id="updateApsWorkOrderJobPrccessStatus" parameterType="map">
        update aps_work_order_job
        set process_status = #{status}
        where doc_no in
        <foreach item="docNo" collection="docNos" open="(" separator="," close=")">
            #{docNo}
        </foreach>
    </update>
    <delete id="deleteAllPartPlan" >
        delete from aps_part_plan where del_flag in ('0','1')
    </delete>
    <insert id="batchInsertPartPlan">
        insert into aps_part_plan
        (
            document_number,main_part_number,main_part_drawing_number,
            customer,business_type,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,next_process_deparment,
            is_suspended,is_outsourcing,account,
            id,create_time,del_flag,plant,order_status,std_op,op_status,next_op_name
        )
        select
            doc_no,mainitem_code,mainitem_figure,
            customer_name,business_type,demand_type,
            doc_status,item_code,item_figure,
            item_figure_version,pruduct_qty,work_qty,
            op_num,work_center,dept,
            start_date,complete_date,next_dept,
            is_hold_release,is_out_source,org_code,
            order_id,now(),'0',org_code,doc_status,std_op,op_status,next_op_name
        from aps_work_order_job
        where ( doc_status in (0,1,2,4) and is_hold_release='0'
                and (item_code like 'M01%' or item_code like 'M02%'or item_code like 'M05%' or item_code like 'M10%'
                    or item_code like 'M14%'or item_code like 'M15%' or item_code like 'F%' or item_code like 'Z%'
                )
        );
    </insert>
    <delete id="deleteAllPlatePlan" >
        delete from aps_plate_plan where del_flag in ('0','1')
    </delete>
    <insert id="batchInsertPlatePlan">
        insert into aps_plate_plan
        (
            document_number,main_part_number,main_part_drawing_number,
            customer,business_type,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,next_process_deparment,
            is_suspended,is_outsourcing,account,
            id,create_time,del_flag,plant,order_status,std_op,op_status,next_op_name,
            professional_affiliation,order_create_time,approve_on,start_work_date,low_order_code
        )
        select
            doc_no,mainitem_code,mainitem_figure,
            customer_name,business_type,demand_type,
            doc_status,item_code,item_figure,
            item_figure_version,pruduct_qty,work_qty,
            op_num,work_center,dept,
            start_date,complete_date,next_dept,
            is_hold_release,is_out_source,org_code,
            cast(order_id as bigint) as id,now(),'0',org_code,doc_status,std_op,op_status,next_op_name,
            (case when low_order_code='0' then 'main' else 'sub' end ) as professional_affiliation,
            order_create_time,
            approve_on,
            start_work_date,
            low_order_code
        from aps_work_order_job
        where ( doc_status in (0,1,2,4) and is_hold_release='0'
                and (item_code like 'M03%' or item_code like 'M04%'or item_code like 'A75%')
              );
    </insert>
    <delete id="deleteAllGasPiping" >
        delete from aps_gas_piping_plan where del_flag in ('0','1')
    </delete>
    <insert id="batchInsertGasPiping">
        insert into aps_gas_piping_plan
        (
            document_number,main_part_number,main_part_drawing_number,
            customer,business_type,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,next_process_deparment,
            is_suspended,is_outsourcing,account,
            id,create_time,del_flag,plant,order_status,std_op,op_status,next_op_name,plan_type,
            order_create_time,
            approve_on,
            start_work_date,
            low_order_code
        )
        select
            doc_no,mainitem_code,mainitem_figure,
            customer_name,business_type,demand_type,
            doc_status,item_code,item_figure,
            item_figure_version,pruduct_qty,work_qty,
            op_num,work_center,dept,
            start_date,complete_date,next_dept,
            is_hold_release,is_out_source,org_code,
            order_id,now(),'0',org_code,doc_status,std_op,op_status,next_op_name,
            case when substr(item_code,0,4)='A65' then 'gas' else  'piping' end as plan_type,
            order_create_time,
            approve_on,
            start_work_date,
            low_order_code
        from aps_work_order_job
        where ( doc_status in (0,1,2,4) and is_hold_release='0'
            and (item_code like 'A65%' or item_code like 'W%'));
    </insert>
    <delete id="deleteAllWorkOrderJob" >
        delete from aps_work_order_job where del_flag in ('0','1')
    </delete>
</mapper>