wu
2025-10-24 a325f9eda08af39cce45cba363e4247a1b7d5465
hangzhoumesParent/common/servicebase/src/main/resources/mapper/OptimizeProjectMapper.xml
@@ -10,7 +10,6 @@
        <result property="thickness" column="glass_thickness"/>
        <result property="layoutSequence" column="heat_layout_sort"/>
        <result property="state" column="state"/>
    </resultMap>
    <resultMap id="resultMap" type="com.mes.pp.entity.OptimizeProject">
@@ -19,8 +18,25 @@
        <result property="projectName" column="project_name"/>
        <result property="state" column="state"/>
        <result property="type" column="type"/>
        <result property="glassThickness" column="glass_thickness"/>
        <result property="glassType" column="glass_type"/>
        <result property="glassTotal" column="glass_total"/>
        <result property="glassTotalArea" column="glass_total_area"/>
    </resultMap>
    <resultMap id="progressResultMap" type="com.mes.pp.entity.dto.ProgressDTO">
        <!-- 玻璃信息表(a)字段映射 -->
        <result property="engineerId" column="engineer_id"/>    <!-- 玻璃No → a.engineer_id -->
        <result property="flowCardId" column="flow_card_id"/>     <!-- 流程卡号 → a.flow_card_id -->
        <result property="layer" column="layer"/>     <!-- 层号 → a.layer -->
        <result property="glassType" column="glass_type"/>      <!-- 玻璃名称 → a.glass_type -->
        <result property="width" column="width"/>                <!-- 宽 → a.width -->
        <result property="height" column="height"/>              <!-- 高 → a.height -->
        <result property="glassIdCount" column="glassIdCount"/>      <!-- 订单数量 → 统计的 glassIdCount -->
        <result property="cuttingCount" column="cuttingCount"/>       <!-- 切割报工数 → cuttingCount -->
        <result property="edgingCount" column="edgingCount"/>   <!-- 磨边报工数 → edgingCount -->
         <result property="temperingCount" column="temperingCount"/>
         <result property="insulatingCount" column="insulatingCount"/>
    </resultMap>
    <select id="saveProject" parameterType="com.mes.pp.entity.request.OptimizeRequest" resultMap="sequenceMap">
        select a.project_no,
               1                                            as glass_type,
@@ -36,27 +52,36 @@
    <select id="queryEngineer" parameterType="com.mes.pp.entity.OptimizeProject" resultMap="resultMap">
        select p.project_no,
               p.project_name
               p.project_name,
               p.glass_thickness,
               p.glass_type,
               p.glass_total,
               p.glass_total_area
        from pp.optimize_project p
        where p.state = 100
          and p.project_no not in (
            select es.project_no
            from north_glass_mes.engineer_scheduling es
            where es.project_no is not null
        )
          and p.project_no not in (select es.project_no
                                   from north_glass_mes.engineer_scheduling es
                                   where es.project_no is not null)
        order by p.id
    </select>
    <select id="engineerScheduling" parameterType="com.mes.pp.entity.request.OptimizeRequest" resultMap="resultMap">
        select es.project_no,
        es.project_name,
        es.type
        es.type,
        p.glass_thickness,
        p.glass_type,
        p.glass_total,
        p.glass_total_area,
        IFNULL(e.state,0) as state
        from north_glass_mes.engineer_scheduling es
        left join pp.optimize_project p on es.project_no=p.project_no
        left join north_glass_mes.engineering e on es.project_no=e.engineer_id
        where es.state = 100
        <if test="type != null and type != ''">
            and es.type = #{type}
        </if>
        order by es.id
        order by case when IFNULL(e.state, 0) = 1 then 0 else 1 end, es.id
    </select>
    <!-- 根据类型删除engineer_scheduling表中的数据 -->
@@ -93,5 +118,37 @@
            )
        </foreach>
    </insert>
    <select id="selectProgress" parameterType="com.mes.glassinfo.entity.GlassInfo" resultMap="progressResultMap">
        SELECT
        a.engineer_id,
        a.flow_card_id,
        a.layer,
        a.glass_type,
        a.thickness,
        a.filmsid,
        a.width,
        a.height,
        COUNT(a.glass_id) as glassIdCount,
        SUM(CASE WHEN d.working_procedure = '切割' AND d.type = 1 THEN 1 ELSE 0 END) as cuttingCount,
        SUM(CASE WHEN d.working_procedure = '磨边' AND d.type = 1 THEN 1 ELSE 0 END) as edgingCount,
        SUM(CASE WHEN d.working_procedure = '钢化' AND d.type = 1 THEN 1 ELSE 0 END) as temperingCount,
        SUM(CASE WHEN d.working_procedure = '中空' AND d.type = 1 THEN 1 ELSE 0 END) as insulatingCount
        FROM
        north_glass_mes.glass_info a
        LEFT JOIN
        north_glass_mes.damage d
        ON a.glass_id = d.glass_id
        AND a.engineer_id = d.engineer_id
        WHERE
        a.engineer_id = #{engineerId}
        GROUP BY
        a.engineer_id,
        a.flow_card_id,
        a.layer,
        a.glass_type,
        a.thickness,
        a.filmsid,
        a.width,
        a.height
    </select>
</mapper>