chenlu
2025-11-28 189add7a28d273861f9e54c81fb0330da4327ca0
north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
@@ -24,9 +24,10 @@
        od.product_name,
        r.technology_number,
        ogd.glass_address,
        ogd.glass_child,
        r.patch_num,
        od.width,
        od.height,
        ogd.child_width as width,
        ogd.child_height as height,
        od.shape,
        r.patch_type,
        r.patch_reason,
@@ -37,13 +38,13 @@
        r.quality_inspector,
        r.patch_processes,
        r.reviewer,
        date(r.create_time) as create_time,
        r.create_time as create_time,
        date(r.update_time) as update_time,
        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS glassNumber
        from pp.patch_log 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
        left join (select * from sd.order_glass_detail group by order_id,order_number,technology_number) as ogd
        on r.order_id = ogd.order_id and r.order_sort = ogd.order_number and r.technology_number=ogd.technology_number
        <where>
            date(r.create_time)>=#{startDate} and date(r.create_time) &lt;= #{endDate}
            and o.create_order>0
@@ -81,10 +82,10 @@
                and r.quality_inspector regexp #{patchLog.qualityInspector}
            </if>
            <if test="patchLog.width != null and patchLog.width != ''">
                and od.width regexp #{patchLog.width}
                and ogd.child_width regexp REGEXP_REPLACE(#{patchLog.width},'\\.0+$','')
            </if>
            <if test="patchLog.height != null and patchLog.height != ''">
                and od.height regexp #{patchLog.height}
                and ogd.child_height regexp REGEXP_REPLACE(#{patchLog.height},'\\.0+$','')
            </if>
            <if test="patchLog.shape != null and patchLog.shape != ''">
                and od.shape regexp #{patchLog.shape}
@@ -95,8 +96,11 @@
            <if test="patchLog.glassAddress != null and patchLog.glassAddress != ''">
                and ogd.glass_address regexp #{patchLog.glassAddress}
            </if>
            <if test="patchLog.glassChild != null and patchLog.glassChild != ''">
                and ogd.glass_child regexp #{patchLog.glassChild}
            </if>
            <if test="patchLog.responsibleTeam != null and patchLog.responsibleTeam != ''">
                and r.responsible_team regexp #{patchLog.responsibleTeam}
                and r.responsible_team like concat('%', #{patchLog.responsibleTeam}, '%')
            </if>
            <if test="patchLog.responsibleEquipment != null and patchLog.responsibleEquipment != ''">
                and r.responsible_equipment regexp #{patchLog.responsibleEquipment}
@@ -120,7 +124,7 @@
                and r.patch_processes regexp #{patchLog.patchProcesses}
            </if>
            <if test="patchLog.reviewer != null and patchLog.reviewer != ''">
                and r.reviewer regexp #{patchLog.reviewer}
                and r.reviewer like concat('%', #{patchLog.reviewer}, '%')
            </if>
        </where>
         order by r.review_status,r.id desc
@@ -133,8 +137,8 @@
        from (select r.id as id
        from pp.patch_log 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
        left join (select * from sd.order_glass_detail group by order_id,order_number,technology_number) as ogd
        on r.order_id = ogd.order_id and r.order_sort = ogd.order_number and r.technology_number=ogd.technology_number
        <where>
            date(r.create_time)>=#{startDate} and date(r.create_time) &lt;= #{endDate}
            <if test="patchLog.patchId != null and patchLog.patchId != ''">
@@ -171,10 +175,10 @@
                and r.quality_inspector regexp #{patchLog.qualityInspector}
            </if>
            <if test="patchLog.width != null and patchLog.width != ''">
                and od.width regexp #{patchLog.width}
                and ogd.child_width regexp REGEXP_REPLACE(#{patchLog.width},'\\.0+$','')
            </if>
            <if test="patchLog.height != null and patchLog.height != ''">
                and od.height regexp #{patchLog.height}
                and ogd.child_height regexp REGEXP_REPLACE(#{patchLog.height},'\\.0+$','')
            </if>
            <if test="patchLog.shape != null and patchLog.shape != ''">
                and od.shape regexp #{patchLog.shape}
@@ -185,8 +189,11 @@
            <if test="patchLog.glassAddress != null and patchLog.glassAddress != ''">
                and ogd.glass_address regexp #{patchLog.glassAddress}
            </if>
            <if test="patchLog.glassChild != null and patchLog.glassChild != ''">
                and ogd.glass_child regexp #{patchLog.glassChild}
            </if>
            <if test="patchLog.responsibleTeam != null and patchLog.responsibleTeam != ''">
                and r.responsible_team regexp #{patchLog.responsibleTeam}
                and r.responsible_team like concat('%', #{patchLog.responsibleTeam}, '%')
            </if>
            <if test="patchLog.responsibleEquipment != null and patchLog.responsibleEquipment != ''">
                and r.responsible_equipment regexp #{patchLog.responsibleEquipment}
@@ -210,7 +217,7 @@
                and r.patch_processes regexp #{patchLog.patchProcesses}
            </if>
            <if test="patchLog.reviewer != null and patchLog.reviewer != ''">
                and r.reviewer regexp #{patchLog.reviewer}
                and r.reviewer like concat('%', #{patchLog.reviewer}, '%')
            </if>
        </where>
        ) as zu
@@ -220,7 +227,11 @@
    <select id="getMaximum" >
        select count(*) from pp.patch_log where  date(create_time)=CURDATE()
        SELECT IFNULL(patch_id,'00')
        FROM patch_log
        WHERE DATE(create_time) = CURDATE()
        ORDER BY create_time DESC
            LIMIT 1;
    </select>
@@ -282,8 +293,8 @@
               dd.technology_number as technologyNumber,
               ogd.glass_address as glassAddress,
               dd.breakage_quantity-dd.quantity as patchNum,
               od.width,
               od.height,
                ogd.child_width as width,
                ogd.child_height as height,
               od.shape,
               dd.responsible_process as responsibleProcess,
               rw.this_process as patchProcesses,
@@ -295,18 +306,22 @@
               dd.responsible_equipment as responsibleEquipment,
               dd.responsible_team as responsibleTeam,
               ROUND((dd.breakage_quantity-dd.quantity) * od.width * od.height / 1000000, 2) as patchArea,
               rw.quality_inspector as qualityInspector
               rw.quality_inspector as qualityInspector,
               ogd.glass_child as glassChild,
               if(dd.responsible_process=rw.this_process,2,dd.quality_ins_status) as qualityInsStatus,
               if(dd.quality_ins_status=1,1,2) as orderBy,
               dd.responsible_personnel as responsiblePersonnel
        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 rw on dd.reporting_work_id = rw.reporting_work_id
                 left join sd.`order` o on rw.order_id = o.order_id
                 left join sd.order_detail od on rw.order_id = od.order_id and dd.order_number = od.order_number
                 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
                 left join (select * from sd.order_glass_detail group by order_id,order_number,technology_number) as ogd
                           on rw.order_id = ogd.order_id and dd.order_number = ogd.order_number and rwd.technology_number=ogd.technology_number
        <where>  dd.breakage_quantity-dd.quantity>0 and dd.available=0 and (dd.responsible_process=rw.this_process or (dd.quality_ins_status!=1)) and rw.reviewed_state!=-1
                and o.create_order>0
        <where>  dd.breakage_quantity-dd.quantity>0 and dd.available=0 and rw.reviewed_state!=-1 /*(dd.responsible_process=rw.this_process or (dd.quality_ins_status!=1)) and */
                and o.create_order>0 and dd.patch_status=0
            <if test="patchLogAddDTO.orderId != null and patchLogAddDTO.orderId != ''">
                and o.order_id regexp #{patchLogAddDTO.orderId}
            </if>
@@ -338,10 +353,10 @@
                and rw.quality_inspector regexp #{patchLogAddDTO.qualityInspector}
            </if>
            <if test="patchLogAddDTO.width != null and patchLogAddDTO.width != ''">
                and od.width regexp #{patchLogAddDTO.width}
                and ogd.child_width regexp REGEXP_REPLACE(#{patchLogAddDTO.width},'\\.0+$','')
            </if>
            <if test="patchLogAddDTO.height != null and patchLogAddDTO.height != ''">
                and od.height regexp #{patchLogAddDTO.height}
                and ogd.child_height regexp REGEXP_REPLACE(#{patchLogAddDTO.height},'\\.0+$','')
            </if>
            <if test="patchLogAddDTO.shape != null and patchLogAddDTO.shape != ''">
                and od.shape regexp #{patchLogAddDTO.shape}
@@ -349,8 +364,11 @@
            <if test="patchLogAddDTO.glassAddress != null and patchLogAddDTO.glassAddress != ''">
                and ogd.glass_address regexp #{patchLogAddDTO.glassAddress}
            </if>
            <if test="patchLogAddDTO.glassChild != null and patchLogAddDTO.glassChild != ''">
                and ogd.glass_child regexp #{patchLogAddDTO.glassChild}
            </if>
            <if test="patchLogAddDTO.responsibleTeam != null and patchLogAddDTO.responsibleTeam != ''">
                and dd.responsible_team regexp #{patchLogAddDTO.responsibleTeam}
                and dd.responsible_team like concat('%', #{patchLogAddDTO.responsibleTeam}, '%')
            </if>
            <if test="patchLogAddDTO.responsibleEquipment != null and patchLogAddDTO.responsibleEquipment != ''">
                and dd.responsible_equipment regexp #{patchLogAddDTO.responsibleEquipment}
@@ -368,7 +386,7 @@
                and dd.breakage_reason regexp #{patchLogAddDTO.patchReason}
            </if>
        </where>
        order by dd.id desc
        order by orderBy desc,dd.id desc
    </select>
    <delete id="deleteReplenishMp">
@@ -407,5 +425,53 @@
        update pp.patch_log set reviewer=null,review_status=0,update_time=now() where id=#{patchLog.id}
    </update>
    <select id="selectProjectCount">
        SELECT COUNT(*)
        FROM patch_log
        WHERE process_id= #{processId} and patch_id=#{patchId} and technology_number = #{technologyNumber}
          and project_no IS not NULL;
    </select>
    <select id="exportReplenishMp">
        select
        r.id,
        r.review_status,
        r.reporting_work_id,
        r.patch_id,
        r.process_id,
        r.order_id,
        r.order_sort,
        o.project,
        o.batch,
        od.building_number,
        od.product_name,
        r.technology_number,
        ogd.glass_address,
        ogd.glass_child,
        r.patch_num,
        ogd.child_width as width,
        ogd.child_height as height,
        od.shape,
        r.patch_type,
        r.patch_reason,
        r.responsible_team,
        r.responsible_personnel,
        r.responsible_equipment,
        r.patch_area,
        r.quality_inspector,
        r.patch_processes,
        r.reviewer,
        r.create_time as create_time,
        date(r.update_time) as update_time,
        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS glassNumber
        from pp.patch_log 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,technology_number) as ogd
        on r.order_id = ogd.order_id and r.order_sort = ogd.order_number and r.technology_number=ogd.technology_number
        <where>
            date(r.create_time)>=#{dates[0]} and date(r.create_time) &lt;= #{dates[1]}
            and o.create_order>0
        </where>
        order by r.review_status,r.id desc
    </select>
</mapper>