chenlu
2025-11-28 189add7a28d273861f9e54c81fb0330da4327ca0
north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
@@ -21,7 +21,7 @@
        o.project,
        o.batch,
        od.product_name,
        ogd.technology_number,
        r.technology_number,
        ogd.glass_address,
        r.rework_num,
        od.width,
@@ -37,13 +37,94 @@
        r.rework_processes,
        r.reviewer,
        date(r.create_time) as create_time,
        date(r.update_time) as update_time
        date(r.update_time) as update_time,
        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS glassNumber,
        r.reporting_work_id
        from pp.rework r left join sd.order_detail od on r.order_id=od.order_id and r.order_sort=od.order_number
        left join sd.`order` o on r.order_id = o.order_id
        left join (select * from sd.order_glass_detail group by order_id,order_number) as ogd
        on r.order_id = ogd.order_id and r.order_sort = ogd.order_number
        <where>
            date(r.create_time)>=#{startDate} and date(r.create_time) &lt;= #{endDate}
            and o.create_order>0
            <if test="rework.reworkId != null and rework.reworkId != ''">
                and r.rework_id regexp #{rework.reworkId}
            </if>
            <if test="rework.reworkTeam != null and rework.reworkTeam != ''">
                and r.rework_team like concat('%', #{rework.reworkTeam}, '%')
            </if>
            <if test="rework.orderId != null and rework.orderId != ''">
                and r.order_id regexp #{rework.orderId}
            </if>
            <if test="rework.reportingWorkId != null and rework.reportingWorkId != ''">
                and r.reporting_work_id regexp #{rework.reportingWorkId}
            </if>
            <if test="rework.processId != null and rework.processId != ''">
                and r.process_id regexp #{rework.processId}
            </if>
            <if test="rework.project != null and rework.project != ''">
                and o.project regexp #{rework.project}
            </if>
            <if test="rework.batch != null and rework.batch != ''">
                and o.batch regexp #{rework.batch}
            </if>
            <if test="rework.orderSort != null and rework.orderSort != ''">
                and r.order_sort regexp #{rework.orderSort}
            </if>
            <if test="rework.buildingNumber != null and rework.buildingNumber != ''">
                and od.building_number regexp #{rework.buildingNumber}
            </if>
            <if test="rework.productName != null and rework.productName != ''">
                and od.product_name regexp #{rework.productName}
            </if>
            <if test="rework.technologyNumber != null and rework.technologyNumber != ''">
                and r.technology_number regexp #{rework.technologyNumber}
            </if>
            <if test="rework.qualityInspector != null and rework.qualityInspector != ''">
                and r.quality_inspector regexp #{rework.qualityInspector}
            </if>
            <if test="rework.width != null and rework.width != ''">
                and od.width regexp #{rework.width}
            </if>
            <if test="rework.height != null and rework.height != ''">
                and od.height regexp #{rework.height}
            </if>
            <if test="rework.shape != null and rework.shape != ''">
                and od.shape regexp #{rework.shape}
            </if>
            <if test="rework.reworkNum != null and rework.reworkNum != ''">
                and r.rework_num regexp #{rework.reworkNum}
            </if>
            <if test="rework.glassAddress != null and rework.glassAddress != ''">
                and ogd.glass_address regexp #{rework.glassAddress}
            </if>
            <if test="rework.responsibleTeam != null and rework.responsibleTeam != ''">
                and r.responsible_team like concat('%', #{rework.responsibleTeam}, '%')
            </if>
            <if test="rework.responsibleEquipment != null and rework.responsibleEquipment != ''">
                and r.responsible_equipment regexp #{rework.responsibleEquipment}
            </if>
            <if test="rework.responsiblePersonnel != null and rework.responsiblePersonnel != ''">
                and r.responsible_personnel regexp #{rework.responsiblePersonnel}
            </if>
            <if test="rework.reworkType != null and rework.reworkType != ''">
                and r.rework_type regexp #{rework.reworkType}
            </if>
            <if test="rework.reworkReason != null and rework.reworkReason != ''">
                and r.rework_reason regexp #{rework.reworkReason}
            </if>
            <if test="rework.reworkArea != null and rework.reworkArea != ''">
                and r.rework_area regexp #{rework.reworkArea}
            </if>
            <if test="rework.qualityInspector != null and rework.qualityInspector != ''">
                and r.quality_inspector regexp #{rework.qualityInspector}
            </if>
            <if test="rework.reworkProcesses != null and rework.reworkProcesses != ''">
                and r.rework_processes regexp #{rework.reworkProcesses}
            </if>
            <if test="rework.reviewer != null and rework.reviewer != ''">
                and r.reviewer like concat('%', #{rework.reviewer}, '%')
            </if>
        </where>
         order by r.review_status,r.id desc limit #{offset},#{pageSize};
    </select>
@@ -59,9 +140,87 @@
                                 on r.order_id = ogd.order_id and r.order_sort = ogd.order_number
        <where>
            date(r.create_time)>=#{startDate} and date(r.create_time) &lt;= #{endDate}
            and o.create_order>0
            <if test="rework.reworkId != null and rework.reworkId != ''">
                and r.rework_id regexp #{rework.reworkId}
            </if>
            <if test="rework.reworkTeam != null and rework.reworkTeam != ''">
                and r.rework_team like concat('%', #{rework.reworkTeam}, '%')
            </if>
            <if test="rework.orderId != null and rework.orderId != ''">
                and r.order_id regexp #{rework.orderId}
            </if>
            <if test="rework.reportingWorkId != null and rework.reportingWorkId != ''">
                and r.reporting_work_id regexp #{rework.reportingWorkId}
            </if>
            <if test="rework.processId != null and rework.processId != ''">
                and r.process_id regexp #{rework.processId}
            </if>
            <if test="rework.project != null and rework.project != ''">
                and o.project regexp #{rework.project}
            </if>
            <if test="rework.batch != null and rework.batch != ''">
                and o.batch regexp #{rework.batch}
            </if>
            <if test="rework.orderSort != null and rework.orderSort != ''">
                and r.order_sort regexp #{rework.orderSort}
            </if>
            <if test="rework.buildingNumber != null and rework.buildingNumber != ''">
                and od.building_number regexp #{rework.buildingNumber}
            </if>
            <if test="rework.productName != null and rework.productName != ''">
                and od.product_name regexp #{rework.productName}
            </if>
            <if test="rework.technologyNumber != null and rework.technologyNumber != ''">
                and r.technology_number regexp #{rework.technologyNumber}
            </if>
            <if test="rework.qualityInspector != null and rework.qualityInspector != ''">
                and r.quality_inspector regexp #{rework.qualityInspector}
            </if>
            <if test="rework.width != null and rework.width != ''">
                and od.width regexp #{rework.width}
            </if>
            <if test="rework.height != null and rework.height != ''">
                and od.height regexp #{rework.height}
            </if>
            <if test="rework.shape != null and rework.shape != ''">
                and od.shape regexp #{rework.shape}
            </if>
            <if test="rework.reworkNum != null and rework.reworkNum != ''">
                and r.rework_num regexp #{rework.reworkNum}
            </if>
            <if test="rework.glassAddress != null and rework.glassAddress != ''">
                and ogd.glass_address regexp #{rework.glassAddress}
            </if>
            <if test="rework.responsibleTeam != null and rework.responsibleTeam != ''">
                and r.responsible_team like concat('%', #{rework.responsibleTeam}, '%')
            </if>
            <if test="rework.responsibleEquipment != null and rework.responsibleEquipment != ''">
                and r.responsible_equipment regexp #{rework.responsibleEquipment}
            </if>
            <if test="rework.responsiblePersonnel != null and rework.responsiblePersonnel != ''">
                and r.responsible_personnel regexp #{rework.responsiblePersonnel}
            </if>
            <if test="rework.reworkType != null and rework.reworkType != ''">
                and r.rework_type regexp #{rework.reworkType}
            </if>
            <if test="rework.reworkReason != null and rework.reworkReason != ''">
                and r.rework_reason regexp #{rework.reworkReason}
            </if>
            <if test="rework.reworkArea != null and rework.reworkArea != ''">
                and r.rework_area regexp #{rework.reworkArea}
            </if>
            <if test="rework.qualityInspector != null and rework.qualityInspector != ''">
                and r.quality_inspector regexp #{rework.qualityInspector}
            </if>
            <if test="rework.reworkProcesses != null and rework.reworkProcesses != ''">
                and r.rework_processes regexp #{rework.reworkProcesses}
            </if>
            <if test="rework.reviewer != null and rework.reviewer != ''">
                and r.reviewer like concat('%', #{rework.reviewer}, '%')
            </if>
        </where>
              ) as zu
        limit #{offset},#{pageSize};
        ) as zu;
    </select>
    <select id="getSelectRework">
@@ -89,7 +248,8 @@
               ROUND((dd.breakage_quantity-dd.quantity) * od.width * od.height / 1000000, 2) as reworkArea,
               rw.quality_inspector as qualityInspector
        from pp.damage_details dd
                 left join   pp.reporting_work_detail rwd on dd.reporting_work_id = rwd.reporting_work_id and dd.order_number=rwd.order_number  and dd.technology_number=rwd.technology_number
                 left join   pp.reporting_work_detail rwd on dd.reporting_work_id = rwd.reporting_work_id and dd.order_number=rwd.order_number
                                                               and dd.technology_number=rwd.technology_number and rwd.review_status>0
                 left join pp.reporting_work rw on dd.reporting_work_id = rw.reporting_work_id
                 left join sd.`order` o on rw.order_id = o.order_id
@@ -97,8 +257,8 @@
                 left join (select * from sd.order_glass_detail group by order_id,order_number) as ogd
                           on rw.order_id = ogd.order_id and dd.order_number = ogd.order_number
        where  dd.breakage_quantity-dd.quantity>0 and dd.available=1 and dd.qualityIns_status=1 order by dd.id
        where  dd.breakage_quantity-dd.quantity>0 and dd.available=1 and o.create_order>0 and  rw.reviewed_state>=0
        order by dd.id desc
    </select>
@@ -129,7 +289,20 @@
        update pp.damage_details set quantity=quantity+#{rework.reworkNum} where id=#{rework.reviewer}
    </update>
    <delete id="deleteReworkMp">
        delete from pp.rework where rework_id=#{patchId}
    </delete>
    <update id="updateReworkDdMp">
        update pp.damage_details set patch_status=0,quantity=quantity-#{reworkNum}
        where reporting_work_id=#{reportingWorkId} and order_number=#{orderSort} and technology_number=#{technologyNumber}
              and breakage_type=#{reworkType} and breakage_reason=#{reworkReason}
    </update>
    <update id="updateReworkBgMp">
        update pp.reporting_work_detail set patch_status=0
        where reporting_work_id=#{reportingWorkId} and order_number=#{orderSort} and technology_number=#{technologyNumber}
    </update>