wu
2023-09-05 933d18d5d5486743fd4ef0bae77c2ef24c39362a
提交
4个文件已添加
268 ■■■■■ 已修改文件
springboot-vue3/src/main/java/com/example/springboot/controller/SpianController.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/entity/StorageCage.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/controller/SpianController.java
New file
@@ -0,0 +1,96 @@
package com.example.springboot.controller;
import com.example.springboot.common.Result;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.mapper.SpianMapper;
import com.example.springboot.service.SpianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/spian")
public class SpianController {
    @Autowired
    SpianMapper spianMapper;
    @Autowired
    SpianService spianservice;
    //出片任务
@GetMapping("/all2")
    public Result selectdd(String orderid){
         StorageCage cageout=spianMapper.selectOut(orderid);
         //判断玻璃可直接出片时
         //玻璃内外片
         int cage =cageout.getCage();
         int cell =cageout.getCell();
         int tier =cageout.getTier();
         double width=cageout.getWidth();
         if(tier==2){
                return Result.success("执行出片");
         }
         else{
           int state= spianMapper.selectGlassState(cage,cell);
            //判断内片是否需要调拨
            if(state==0){
             return Result.success("状态为0,直接出片");
             }else{
              //玻璃需要调拨时
               return Result.success("状态为1,需要被调拨");
             }
        }
}
   @GetMapping("/all")
   //进片任务,传订单id
   //按订单优先进片
    public Result selectAll(String orderid){
        //return spianMapper.selectAll();
        int cage1;
        //String orderid="A001";
        //获取订单相关度最高的笼子排序
        List<StorageCage> storageCage=spianMapper.selectAll(orderid);
        for (StorageCage storageCage2 : storageCage) {
            //保存订单优先顺序笼子号
            cage1=storageCage2.getCage();
            //判断该笼子号相邻最大的空格数
            int cages=spianMapper.selectCage(cage1);
            //判断选中笼子是否有空格
            StorageCage cages1=spianMapper.selectCage1(cage1);
            if(cages>1 &&cages1.getTier()!=null){
                return Result.success(cages1);
            }
        }
        return Result.success("0");
    }
    @PostMapping("/save")
    public Result save(@RequestBody StorageCage spian){
        spianservice.Save(spian);
        return Result.success();
    }
}
springboot-vue3/src/main/java/com/example/springboot/entity/StorageCage.java
New file
@@ -0,0 +1,104 @@
package com.example.springboot.entity;
public class StorageCage {
    private Integer id;
    private String glassId;
    private Integer cage;
    private Integer cell;
    private Double width;
    private Double glasswidth;
    private Double glassheight;
    private String state;
    private Integer tier;
    private String orderId;
    public Integer id() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getId() {
        return id;
    }
    public String getGlassId() {
        return glassId;
    }
    public void setGlassId(String glassId) {
        this.glassId = glassId;
    }
     public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public Integer getCage() {
        return cage;
    }
    public void setGage(Integer cage) {
        this.cage = cage;
    }
    public void setCell(Integer cell) {
        this.cell = cell;
    }
    public Integer getCell() {
        return cell;
    }
    // public String getHeighth() {
    //     return height;
    // }
    // public void setHeight(String height) {
    //     this.height = height;
    // }
    public Double getWidth() {
        return width;
    }
    public void setWidth(Double width) {
        this.width = width;
    }
     public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
      public Integer getTier() {
        return tier;
    }
    public void setTier(Integer tier) {
        this.tier = tier;
    }
     public Double getGlassWidth() {
        return glasswidth;
    }
    public void setGlassWidth(Double glasswidth) {
        this.glasswidth = glasswidth;
    }
    public Double getGlassHeight() {
        return glassheight;
    }
    public void setGlassHeight(Double glassheight) {
        this.glassheight = glassheight;
    }
}
springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
New file
@@ -0,0 +1,47 @@
package com.example.springboot.mapper;
import org.apache.ibatis.annotations.*;
import com.example.springboot.common.Result;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.StorageTask;
import com.example.springboot.entity.StorageCage;
import java.util.List;
@Mapper
public interface SpianMapper {
    //判断相邻笼子是否有空格
    @Select("select COUNT(if(a.state1=0,cell,null))as cell from (select *,max(state)as state1 from storage_cage a  GROUP BY cage,cell)as a where (a.cage=#{cage1}-1 or a.cage=#{cage1}+1)and if(#{cage1}<6,a.cage>0 and a.cage<6,a.cage>5) GROUP BY cage ORDER BY cell desc LIMIT 1")
     int selectCage(int  cage1);
     //@Select("(select*from storage_cage as a  where a.state=0 and cage%2=0 ORDER BY id LIMIT 1)union (select a.* from storage_cage a inner join  (select cage,if(shu2=1,shu3,shu5) as gezi from ( select  cage, count(case when state1=1 and state2=0 then cell else null end)as shu1,  count(case when state1=0 then cell else null end) as shu2, min(case when state1=1 and state2=0 then cell else null end) as shu3, min(case when state1=0 then cell else null end) as shu4, min(case when state1=0 or state2=0 then cell else null end) as shu5 from  (select *,max(state) as state1,min(state) as state2 from storage_cage group by cage,cell) as a where  cage%2!=0  GROUP BY cage HAVING shu2>1 or (shu2=1 and shu1>0)  ) as sss limit 1)as b on a.cage=b.cage and a.cell=b.gezi and a.state=0 order by tier limit 1) ORDER BY id LIMIT 1;")
    //获取订单号排序的空订单笼子
     @Select("select cage,COUNT(if(order_id=#{glassid},order_id,null))as orderid from storage_cage where (order_id=#{glassid} or ''='') GROUP BY cage ORDER BY orderid desc; ")
     List<StorageCage> selectAll(String glassid);
     //判断该笼子是否有合适宽度空格
     @Select("select COUNT(*),cage,cell,tier from storage_cage where cage=#{cage1} and state=0 and width>=1500 ORDER BY cell,tier")
     StorageCage selectCage1(int  cage1);
    //@Update("update longzi set glass_id = #{glass_id}, width = #{width}, state = #{state} where cell = #{cell}")
    @Update("update longzi set glass_id =123, width =1600, state =1 where cell =24")
     void  update();
    @Insert("insert into storage_task(task_type,task_state,shelf_rack,load_rack)values(#{storage_task},#{task_state},#{shelf_rack},#{load_rack})")
     void insert(StorageTask storageTask);
    //出片任务查询
    @Select("select cage,cell,tier from storage_cage as a where a.order_id=#{orderId} and state=1 order by cage desc,tier desc,cell desc LIMIT 1")
     StorageCage selectOut(String  orderId);
    //判断出片为1时,是否可直接出片
    @Select("select state from storage_cage where cage=#{cage} and cell=#{cell} and tier=2;")
     int selectGlassState(int  cage,int cell);
     //判断
     @Select("select cage,cell,max(state)as shu from storage_cage where width>=#{width} and cage>#{cage1} and cage<#{cage2} GROUP BY cage,cell HAVING shu=0;")
     int selectGlassCage(double width,int cage1,int cage2);
    // @Insert("insert into user(name, date, address, user_no) values (#{name}, #{date}, #{address}, #{userNo})")
    // void insert (Spian spian);
}
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
New file
@@ -0,0 +1,21 @@
package com.example.springboot.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.mapper.SpianMapper;
@Service
public class SpianService {
    @Autowired
    private SpianMapper spianMapper;
    public void Save(StorageCage spian){
        if(spian.getId()==null){
            spianMapper.update();
        }else{
            spianMapper.update();
        }
    }
}