ZengTao
2024-03-18 e76f203f76b934d2f49dcea89649b2f616878056
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.example.springboot.mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import com.example.springboot.entity.GlassInfo;
import com.example.springboot.entity.StorageCage;
 
@Mapper
@Repository
public interface AlbaniaMapper  {
    //判断笼内是否有合适的类型空格
    @Select("select id from storage_cage where glasstype=#{glasstype} and width>=#{width}+#{widths} and state=0  order by id limit 1")
    int SelectCage(int glasstype,Double width,int widths);
    //判断笼内没有玻璃的空格
    @Select("select id from storage_cage where number=0 and cage>#{cage} and cage<#{cage2} order by id limit 1")
    int SelectNewCell(int cage,int cage2);
    //增加玻璃数
    @Update("update storage_cage set number=number+1,width=width-glasswidth where id=#{id}")
    void UpdateCageNumberAdd(int id);
    //减少玻璃数
    @Update("update storage_cage set number=number-1,width=width+glasswidth where id=#{id}")
    void UpdateCageNumberOut(int id);
    //增加任务记录
    @Insert("INSERT INTO `albania`.`storage_task`(`task_type`, `task_state`, `shelf_rack`, `load_rack`,start_time,glass_id,glasstype,flowcard,mateid,tier) VALUES (#{tasktype},#{taskstate},#{shelfrack},#{loadrack},now(),#{glassid},#{glasstype},#{flowcard},#{mateid},#{tier});")
    void Inserttask(int tasktype, int taskstate, int shelfrack, int loadrack, String glassid, int glasstype,String flowcard,int mateid,int tier);
    //新增一条笼子数据
    @Update("UPDATE `albania`.`storage_cage` SET `glass_id` =#{glassid}, `width` =width-#{glasswidth}, `glasswidth` =#{glasswidth}, `glassheight` =#{glassheight}, `glasswidthmm` =#{glasswidthmm}, `glassheightmm` = #{glassheightmm},  `state` = #{state}, `glasstype` = #{glasstype}, `number` = #{number} WHERE `id` =#{id};")
    void AddCage(int id,String glassid,Double glasswidth,Double glassheight,Double glasswidthmm,Double glassheightmm,int state,int glasstype,int number);
    //获取进片数据
    @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where state=0 limit 1")
    GlassInfo SelectGlass();
    //一号线查询任务
    @Select("select * from v_cagerelease1 where mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid);")
    GlassInfo SelectOutGlass1();
    //二号线查询任务
    @Select("select * from v_cagerelease2 where mateid not in(select mateid from v_cagerelease2 where surplus=0 group by mateid)LIMIT 1;")
    GlassInfo SelectOutGlass2();
    //流程卡任务查询
    @Select("select G.flowcard,G.glasstype,G.number,G.mateid,G.tier,G.starttime,G.finishnumber,IF((G.number-G.finishnumber-ku.KuCount)<0,G.number,ku.KuCount) as 'surplus',G.totaltier as id from (select Gfd.flowcard,Ggf.glasstype,Ggf.number,Ggf.mateid,Ggf.tier,Ggf.finishnumber,Gfd.starttime,Gfd.totaltier  from flowcard as Gfd LEFT JOIN glassinfo as Ggf on Gfd.flowcard=Ggf.flowcard where Gfd.state=1 and Gfd.line=#{line}) as G left join (select glasstype,sum(number) AS KuCount from storage_cage where flowcard is not null group by glasstype) as ku on G.glasstype=ku.glasstype where G.mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid)order by `g`.`starttime`,`g`.`mateid`,`g`.`finishnumber`,`g`.`tier`LIMIT 1;")
    GlassInfo SelectOutGlass(int line);
    //获取该类型在库存的位置
    @Select("select * from storage_cage where glasstype=#{glasstype} and number>0 limit 1")
    StorageCage SelectCageGlass(int glasstype);
    //发送出片后增加已发数量
    @Update("update glassinfo set finishnumber=finishnumber+1 where flowcard=#{flowcard} and mateid=#{mateid} and tier=#{tier};")
    void AddFinishNumber(String flowcard,int mateid,int tier);
    
 
}