springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
@@ -23,7 +23,12 @@
  @Select("select cage,round(100-(21-sum(if(state>0,1,state)))/21*100) as cell,21-sum(if(state>0,1,state)) as state from (select cage,cell,max(state) as state from storage_cage group by cage,cell) as cages group by cage")
  List<StorageCage> selectAll();
  @Select("Select cage,sum(case when number=0 or number is null then 1 else 0 end) as cell,100-sum(case when number=0 or number is null then 1 else 0 end)/count(id)*100 as width from storage_cage group by cage")
  // @Select("Select cage,sum(case when number=0 or number is null then 1 else 0 end) as cell,100-sum(case when number=0 or number is null then 1 else 0 end)/count(id)*100 as width from storage_cage group by cage")
  // List<StorageCage> selectAlls();
  // 查询每个笼子的使用情况
  // @Select("Select a.cage,sum(case when a.number=0 or a.number is null then 1 else 0 end)-b.cells as cell,100+b.cells-sum(case when a.number=0 or a.number is null then 1 else 0 end)/count(a.id)*100 as width from storage_cage a left join (select `cage_numbers`.`cage` AS `cages`,count(`a`.`shelf_rack`) AS `cells` from ((select 1 AS `cage` union all select 2 AS `2` union all select 3 AS `3` union all select 4 AS `4`) `cage_numbers` left join `out_task` `a` on((((case when (`a`.`shelf_rack` between 1 and 40) then 1 when (`a`.`shelf_rack` between 41 and 80) then 2 when (`a`.`shelf_rack` between 81 and 120) then 3 when (`a`.`shelf_rack` between 121 and 160) then 4 else NULL end) = `cage_numbers`.`cage`) and (`a`.`task_state` = 0)))) group by `cage_numbers`.`cage` order by `cage_numbers`.`cage`) as b on a.cage=b.cages group by a.cage;")
  // List<StorageCage> selectAlls();
  @Select("Select a.cage, GREATEST(sum(case when  a.number is null and disabled=0 then 1 else 0 end),0) as cell,LEAST(100-sum(case when  a.number is null and disabled=0 then 1 else 0 end)/count(a.id)*100,100) as width from storage_cage a left join (select `cage_numbers`.`cage` AS `cages`,count(`a`.`shelf_rack`) AS `cells` from ((select 1 AS `cage` union all select 2 AS `2` union all select 3 AS `3` union all select 4 AS `4`) `cage_numbers` left join `out_task` `a` on((((case when (`a`.`shelf_rack` between 1 and 40) then 1 when (`a`.`shelf_rack` between 41 and 80) then 2 when (`a`.`shelf_rack` between 81 and 120) then 3 when (`a`.`shelf_rack` between 121 and 160) then 4 else NULL end) = `cage_numbers`.`cage`) and (`a`.`task_state` = 0)))) group by `cage_numbers`.`cage` order by `cage_numbers`.`cage`) as b on a.cage=b.cages group by a.cage;")
  List<StorageCage> selectAlls();
  // 查询10-6笼内层格子状态
@@ -235,11 +240,11 @@
  Short SelectOutingQueueCount(String frameNo);
  // 查询理片笼内信息
  @Select("select * from storage_cage")
  @Select("select *,b.customer from storage_cage a left join flowcard b on a.flowcard=b.flowcard")
  List<StorageCage> SelectStorageCageInfo();
  // 删除格子内玻璃信息
  @Update("update storage_cage set films=null,width=4300,glasswidth=null,glassheight=null,glasswidthmm=null,glassheightmm=null,thickness=null,glasstype=null,number=null,glass_id=null,flowcard=null,mateid=null where cell=#{cell}")
  @Update("update storage_cage set films=null,width=4300,glasswidth=null,glassheight=null,glasswidthmm=null,glassheightmm=null,thickness=null,glasstype=null,number=null,glass_id=null,flowcard=null,mateid=null,tier=null where cell=#{cell}")
  void DeleteStroageCageByCell(Integer cell);
  // 修改格子玻璃数量
@@ -247,7 +252,7 @@
  void updateStroageCageByCell(Integer cell, Integer num);
  // 计算格子内剩余宽度
  @Update("update storage_cage set width=4300-if(glasswidth is null,0,glasswidth+300)*number where cell=#{cell}")
  @Update("update storage_cage set width=4300-if(glasswidth is null,0,glasswidth)*number-(number*300)+300 where cell=#{cell}")
  void UpdateStroageCageWidthByCell(Integer cell);
  // 根据任务类型获取任务
@@ -261,26 +266,29 @@
  // 根据格子查询玻璃信息
  @Select("select * from storage_cage where cell=#{cell}")
  StorageCage SelectStorageByCell(String cell);
  //根据玻璃类型查询玻璃信息
  @Select("select a.shelf_rack as cage,a.load_rack as cell,b.mateid,b.width as glasswidth,b.height as glassheight,b.thickness,b.films,a.tier from storage_task a left join glassinfo b on a.glasstype=b.glasstype where a.id=#{id} limit 1")
  StorageCage SelectStorageByCellGlass(Integer id);
  // 手动完成任务
  @Select("update storage_task set task_state=1 where id=#{id}")
  @Select("update storage_task set task_state=#{state} where id=#{id}")
  void FinishTask(Integer id, int state);
  //人工匹配测量查询
  @Select("select gi.* from glassinfo gi inner join flowcard fc on gi.flowcard=fc.flowcard where fc.state!=2 and fc.orderstate=1 and position(#{width} in gi.width) and position(#{height} in gi.height) and position(#{thickness} in gi.thickness) and position(#{films} in gi.films) group by gi.id")
  List<GlassInfo> SelectGlassInfo(String width, String height, String thickness, String films);
  @Select("select gi.* from glassinfo gi inner join flowcard fc on gi.flowcard=fc.flowcard where fc.state!=2 and fc.orderstate=1 and position(#{width} in gi.width) and position(#{height} in gi.height) and position(#{thickness} in gi.thickness) and position(#{films} in gi.films) and position(#{tier} in gi.tier) group by gi.id")
  List<GlassInfo> SelectGlassInfo(String width, String height, String thickness, String films,String tier);
  // @Select("select b.* from flowcard a left join glassinfo b on a.flowcard=b.flowcard INNER JOIN measuresetting c where a.orderstate=1 and a.state!=2 and b.width BETWEEN  #{width} - c.errorwidth AND #{width} + c.errorwidth and b.height BETWEEN  #{height} - c.errorheight AND #{height} + c.errorheight and b.films=#{films} and b.thickness=#{thickness}")
  // List<GlassInfo> SelectGlassInfo(String width, String height, String thickness, String films);
  @Update("update storage_cage set glasstype=#{glassInfo.glasstype},mateid=#{glassInfo.mateid},glass_id=#{glassInfo.glassid},flowcard=#{glassInfo.flowcard},glasswidth=#{glassInfo.width},glassheight=#{glassInfo.height},thickness=#{glassInfo.thickness},films=#{glassInfo.films},number=0 where cell=#{cell}")
  @Update("update storage_cage set glasstype=#{glassInfo.glasstype},mateid=#{glassInfo.mateid},glass_id=#{glassInfo.glassid},flowcard=#{glassInfo.flowcard},glasswidth=#{glassInfo.width},glassheight=#{glassInfo.height},thickness=#{glassInfo.thickness},films=#{glassInfo.films},number=0,tier=#{glassInfo.tier} where cell=#{cell}")
  void StorageCageAddGlass(String cell, GlassInfo glassInfo);
  @Select("select * from flowcard where state!=2")
  @Select("select id,flowcard,Customer,totaltier,line,state,method,starttime,orderstate from flowcard where state!=2")
  List<Flowcard> SelectOrderTask();
  // @Select("select gi.*,sum(sc.number) as cageno from glassinfo gi left join storage_cage sc on gi.glasstype=sc.glasstype where gi.flowcard=#{flowcard} group by gi.id order by gi.mateid,gi.tier")
  // List<GlassInfo> SelectOrderView(String flowcard);
  @Select("select gi.id, gi.glasstype, gi.mateid, gi.glassid, gi.tier, gi.films, gi.width, gi.height, gi.thickness, gi.number, gi.finishnumber, gi.sumtier, gi.measurenumber,sum(sc.number) as cageno,IFNULL(c.orderstate,0) as orderstate from  glassinfo gi left join storage_cage sc on gi.glasstype=sc.glasstype left join flowcard c on gi.flowcard=c.flowcard where gi.flowcard=#{flowcard} group by gi.id order by gi.mateid,gi.tier")
  @Select("select gi.id,gi.customer, gi.glasstype, gi.mateid, gi.glassid, gi.tier, gi.films, gi.width, gi.height, gi.thickness, gi.number, gi.finishnumber, gi.sumtier, gi.measurenumber,sum(sc.number) as cageno,IFNULL(c.orderstate,0) as orderstate from  glassinfo gi left join storage_cage sc on gi.glasstype=sc.glasstype left join flowcard c on gi.flowcard=c.flowcard where gi.flowcard=#{flowcard} group by gi.id,orderstate order by gi.mateid,gi.tier")
  List<GlassInfo> SelectOrderView(String flowcard);
@@ -304,34 +312,48 @@
  // int deleteGlassinfo(String flowcard);
  @Update("Update  flowcard set state=2, flowcard=CONCAT('已删除', #{flowcard}),orderstate=0  where flowcard=#{flowcard}")
  int deleteFlowcard(String flowcard);
  //查询当前笼子是否还有该订单的玻璃
  @Select("select count(*) from storage_cage where flowcard=#{flowcard}")
  int selectflowcardCage(String flowcard);
  //修改出片队列状态
  @Update("Update out_task set task_state=#{state} where id=#{id}")
  int UpdateOutTask(Integer id, Integer state);
  //删除出片队列
  @Delete("DELETE from out_task  where id=#{id}")
  int DeleteOutTask(Integer id);
  @Update("Update  glassinfo set flowcard=CONCAT('已删除', #{flowcard}) where flowcard=#{flowcard}")
  int deleteGlassinfo(String flowcard);
  //人工匹配修改一条
  @Update("update queue set glassid=concat(#{flowcard},'-',#{tier}),flowcard=#{flowcard},glasswidth=#{width},glassheight=#{height},glasstype=#{glasstype},thickness=#{thickness},mateid=#{mateid},state=1 where state<=0")
  void UpdateQueue(String flowcard, double width, double height, Integer glasstype, Double thickness, Integer tier,int mateid);
  //人工匹配新增一条
  @Insert("INSERT INTO queue (flowcard,glassid,glasswidth,glassheight,glasstype,thickness,mateid,state) VALUES (#{flowcard},concat(#{flowcard},'-',#{tier}),#{width},#{height},#{glasstype},#{thickness},#{mateid},1)")
  @Insert("INSERT INTO queue (flowcard,glassid,glasswidth,glassheight,glasstype,thickness,mateid,state,time) VALUES (#{flowcard},concat(#{flowcard},'-',#{tier}),#{width},#{height},#{glasstype},#{thickness},#{mateid},1,NOW())")
  int AddQueue(String flowcard, double width, double height, Integer glasstype, Double thickness, Integer tier,int mateid); 
  //判断测量表是否有可更改的数据
  @Select("select count(*) from queue where state<1")
  int SelectQueue();
  @Update("update glassinfo set finishnumber=ifnull(finishnumber,0)+1 where flowcard=#{flowcard} and mateid=#{mateid} and tier=#{geTier}")
  void AddGlassNo(String flowcard, Integer mateid, Integer geTier);
  @Update("update glassinfo set finishnumber=ifnull(finishnumber,0)-1 where glasstype=#{glasstype}")
  void OutGlassNo(Integer glasstype);
  // 添加出片队列
  @Insert("INSERT INTO glassinfo (`flowcard`, `glasstype`, `mateid`, `glassid`, `tier`, `films`, `width`, `height`, `thickness`, `number`, `finishnumber`, `sumtier`, `measurenumber`)"
  @Insert("INSERT INTO glassinfo (`flowcard`, `glasstype`, `mateid`, `glassid`, `tier`, `films`, `width`, `height`, `thickness`, `number`, `finishnumber`, `sumtier`, `measurenumber`,Customer)"
      +
      " VALUES (#{flowcard}, #{glasstype}, #{mateid}, #{glassid}, #{tier}, #{films}, #{width}, #{height}, #{thickness}, #{number}, 0, #{sumtier}, 0)")
      " VALUES (#{flowcard}, #{glasstype}, #{mateid}, #{glassid}, #{tier}, #{films}, CASE WHEN #{width} > #{height} THEN #{width} ELSE #{height} END, CASE WHEN #{height} > #{width} THEN #{width} ELSE #{height} END, #{thickness}, #{number}, 0, #{sumtier}, 0, #{Customer})")
  void AddGlassinfo(String flowcard, Integer glasstype, Integer mateid, String glassid, Integer tier, String films,
      Double width, Double height, Double thickness, Integer number, Integer sumtier);
      Double width, Double height, Double thickness, Integer number, Integer sumtier,String Customer);
  // 最大玻璃类型
  @Select("select max(glasstype)+1 from glassinfo")
  Integer SelectMaxType();
    // 最大玻璃类型
    @Select("select glasstype from glassinfo where CONCAT(width,'_',height,'_',thickness,'_',films,'_',flowcard)=#{key} limit 1")
    @Select("select glasstype from glassinfo where CONCAT(width,'_',height,'_',thickness,'_',films,'_',flowcard,'_',mateid)=#{key} limit 1")
    Integer SelectMaxTypes(String key);
    //查询所有玻璃膜系和厚度
  @Select("select films,thickness from glassinfo GROUP BY films,thickness")
  @Select("select films,thickness from flowcard a left join glassinfo b on a.flowcard=b.flowcard where orderstate=1 GROUP BY films,thickness")
  List<GlassInfo> SelectMeasure();
  @Select("select*from measuresetting")
  MeasureSetting SelectMeasureSetting();
@@ -348,15 +370,15 @@
  List<Map> Selecttiersum();
  // 查询笼内玻璃信息
  @Select("select * from storage_cage where cage=#{cage} order by id desc")
  @Select("select DISTINCT * from storage_cage where cage=#{cage} order by id desc")
  List<StorageCage> SelectStorageCageByCage(Integer cage);
  // 添加出片队列
  @Insert("INSERT INTO flowcard(`flowcard`, `totaltier`, `number`, `line`, `state`, `method`, `starttime`) "
                    +" select #{flowcard}, 0, #{number}, 0, 0, 0, now() where 0=( select count(*) from flowcard where flowcard=#{flowcard});")
  void InsertFlowcard(String flowcard, Integer number);
  @Insert("INSERT INTO flowcard(`flowcard`, `totaltier`, `number`, `line`, `state`, `method`, `starttime`,Customer) "
                    +" select #{flowcard}, 0, #{number}, 0, 0, 0, now(),#{Customer} where 0=( select count(*) from flowcard where flowcard=#{flowcard});")
  void InsertFlowcard(String flowcard, Integer number,String Customer);
    @Delete("DELETE FROM queue WHERE id = (SELECT id FROM ( SELECT id FROM queue WHERE glassid = #{glassId} ORDER BY time ASC LIMIT 1) AS temp);")
    @Delete("DELETE FROM queue WHERE id = (SELECT id FROM ( SELECT id FROM queue WHERE state = 2 ORDER BY time ASC LIMIT 1) AS temp);")
    void DeletequeueByGlassid(String glassId);
    @Select("select count(*) from flowcard where line=#{line} and state=1 and flowcard!=#{flowcard}")
@@ -364,4 +386,17 @@
  //修改测量设定膜系和厚度
    @Update("UPDATE measuresetting SET `films` = #{films}, `thickness` = #{thickness} WHERE `id` = 1;")
    int SaveMeasure(String films, Integer thickness);
    //查询出片队列数据
    @Select("SELECT a.id,a.flowcard,customer,a.mateid,a.tier,b.films,b.thickness,b.width,b.height,a.task_state as state,shelf_rack as cell FROM `out_task` a left join glassinfo b on a.glasstype=b.glasstype where task_state!=1 ORDER BY task_state")
    List<Map>SelectOutTask();
     //查询出片记录数据
     @Select(" select DISTINCT a.id,a.flowcard,customer,a.mateid,a.tier,b.films,b.thickness,b.width,b.height,a.task_state as state,a.shelf_rack as cell from storage_task a left join glassinfo b on a.glasstype=b.glasstype where task_type=1 ORDER BY a.id desc LIMIT 6;")
     List<Map>SelectOutLog();
     //查询扫码数据
     @Select("select*from glassinfo a where a.flowcard=#{flowcard} and a.mateid=#{mateid} and a.tier=#{tier} LIMIT 1")
     GlassInfo SelectCodeGlass(String flowcard,Integer mateid,Integer tier);
     //查询出片队列的玻璃信息
     @Select("select shelf_rack from out_task where id=#{id}")
     int SelectOutTaskId(Integer id);
}