11月1日学习进度

leapssisbird / 2025-01-20 / 原文

package com.leap.mes.mapper;

import com.leap.mes.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author leap
* @description 针对表【workinfo】的数据库操作Mapper
* @createDate 2024-10-09 21:25:02
*/

@Mapper
public interface WorkInfoMapper  {

   /* @Insert("""
        <script>
            INSERT INTO worker (id , name, team_name, position) 
            VALUES 
            <foreach collection="workers" item="worker" separator=",">
                (#{worker.id},#{worker.name}, #{worker.team_name}, #{worker.position})
            </foreach>
        </script>
    """)
    void addWorker(@Param("workers") List<Worker> workers);*/

    @Select("select * from zl")
    List<Zl> getZl();

    @Update("update zl set status = #{status} where general_order = #{scjh.generalOrder} and division_order = #{scjh.divisionOrder} and subordinate_order = #{scjh.subordinateOrder} and product_name = #{scjh.productName} and batch = #{scjh.batch}")
    void updateZlStatus(@Param("status") String status, @Param("scjh") Scjh scjh);
    @Update("update zl set total_process = #{totalProcess} where general_order = #{zl.generalOrder} and division_order = #{zl.divisionOrder} and subordinate_order = #{zl.subordinateOrder} and product_name = #{zl.productName} and batch = #{zl.batch}")
    void updateZlTotalProcess(@Param("totalProcess")String totalProcess, @Param("zl") Zl zl);

    @Update("UPDATE zl SET current_process = #{process}  WHERE general_order = #{generalOrder} AND division_order = #{divisionOrder} AND subordinate_order = #{subordinateOrder} AND product_name = #{productName} AND batch = #{batch}")
    void updateZlCurrentProcess(WorkInfo workInfo);

    @Select("select * from team")
    List<Team> getTeam();

    @Insert("insert into scjh (general_order,division_order,subordinate_order,product_name,batch,liucheng,quantity,next_team,start_time,end_time,status) " +
            "values(#{generalOrder},#{divisionOrder},#{subordinateOrder},#{productName},#{batch},#{liucheng},#{quantity},#{nextTeam},#{startTime},#{endTime},#{status})")
    void addScjh(Scjh scjh);

    @Select("select * from scjh")
    List<Scjh> getScjh();
    @Update("update scjh set status=#{status} where general_order = #{workInfo.generalOrder} and division_order = #{workInfo.divisionOrder} and subordinate_order = #{workInfo.subordinateOrder} and product_name = #{workInfo.productName} and batch = #{workInfo.batch} and next_team=#{workInfo.teamName}")
    void updateScjhStatus(@Param("status") String status, @Param("workInfo") WorkInfo workInfo);
    @Select("select name from worker where id = #{id}")
    String getName(String id);
    @Select("select * from worker where team_name = #{teamName}")
    List<Worker> getWorker(String teamName);
    @Select("select * from worker where id = #{id}")
    Worker getWorkerById(String id);
    @Select("select process from team where team_name = #{teamName}")
    String getProcess(String teamName);

    @Insert("insert into workinfo (general_order,division_order,subordinate_order,product_name,batch,team_name,process,id,name,quantity,status) " +
            "values(#{generalOrder},#{divisionOrder},#{subordinateOrder},#{productName},#{batch},#{teamName},#{process},#{id},#{name},#{quantity},#{status})")
    void addWorkInfo(WorkInfo workInfo);

    @Select("select * from workinfo where id = #{id} and status != '已完成' ")
    List<WorkInfo> getWorkInfo( String id);
    @Select("select * from workinfo")
    List<WorkInfo> getAllWorkInfo();

    @Update("update workinfo set status = #{status} where id = #{id} and status = '未领取' ")
    void updateWorkInfoStatus(@Param("status") String status, @Param("id") String id);

    @Update("update workinfo set start_time=#{startTime},end_time=#{endTime},status = #{status},die_id = #{dieId},machine_id = #{machineId},material_id = #{materialId},lose = #{lose},waste = #{waste},qualified = #{qualified} where id = #{id} and general_order = #{generalOrder} and division_order = #{divisionOrder} and subordinate_order = #{subordinateOrder} and product_name = #{productName} and batch = #{batch} ")
    void updateWorkInfo(WorkInfo workInfo);

    @Select("SELECT s.*, " +
            "(SELECT COUNT(*) FROM workinfo w " +
            "WHERE w.general_order = s.general_order " +
            "AND w.division_order = s.division_order " +
            "AND w.subordinate_order = s.subordinate_order " +
            "AND w.status = '已完成') as completed_processes, " +
            "(SELECT COUNT(*) FROM workinfo w " +
            "WHERE w.general_order = s.general_order " +
            "AND w.division_order = s.division_order " +
            "AND w.subordinate_order = s.subordinate_order) as total_processes, " +
            "(SELECT COUNT(*) FROM workinfo w " +
            "WHERE w.general_order = s.general_order " +
            "AND w.division_order = s.division_order " +
            "AND w.subordinate_order = s.subordinate_order " +
            "AND w.status = '进行中') as in_progress_count, " +
            "CASE WHEN EXISTS (SELECT 1 FROM workinfo w " +
            "WHERE w.general_order = s.general_order " +
            "AND w.division_order = s.division_order " +
            "AND w.subordinate_order = s.subordinate_order) " +
            "THEN 1 ELSE 0 END as is_assigned " +
            "FROM scjh s " +
            "ORDER BY s.general_order")
    List<Scjh> getMonitorData();

    @Select("SELECT w.*, s.liucheng " +
            "FROM workinfo w " +
            "LEFT JOIN scjh s ON w.general_order = s.general_order " +
            "AND w.division_order = s.division_order " +
            "AND w.subordinate_order = s.subordinate_order " +
            "WHERE w.general_order = #{generalOrder} " +
            "ORDER BY w.process")
    List<WorkInfo> getOrderProgress(@Param("generalOrder") String generalOrder);


    @Select("select process from team")
    List<String> getAllProcess();

}