wuyouming666
2023-09-07 0b6ddf2bf0d6c70867611b730ac445a242a89931
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.example.springboot.controller;
 
import com.example.springboot.common.Result;
import com.example.springboot.component.S7control;
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.ArrayList;
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 glasswidth=cageout.getGlassWidth();
         //判断玻璃内外片
         if(tier==2){
             //判断玻璃可直接出片时
                return Result.success("执行出片");  
         }
         else{  
            //获取格子的玻璃数量
           int state= spianMapper.selectGlassState(cage,cell);
            //判断内片是否需要调拨
            if(state==0){
             return Result.success("状态为0,直接出片");  
             }else{
              //玻璃需要调拨时,判断属于哪个半区的笼子
               if(cage<6){
                StorageCage cagecell= spianMapper.selectGlassCage(cage,glasswidth,0,6);
                //获取调拨位置进行调拨
                List<String> adddresslist=new ArrayList<>();
                adddresslist.add("DB105.6");
                adddresslist.add("DB105.8");
                adddresslist.add("DB105.10");
                adddresslist.add("DB105.14");
                List<Short> datas=new ArrayList<>();
                 datas.add((short)0);
                datas.add((short)0);
                datas.add((short)0);
                datas.add((short)0);
                S7control.getinstance().WriteWord(adddresslist, datas);
                return Result.success(cagecell);  //调拨位置的参数内容
                //判断调拨结束后再次出片
               }else{
                StorageCage cagecell= spianMapper.selectGlassCage(cage,glasswidth,5,11);
                //获取调拨位置进行调拨
                StorageCage ca=cagecell;
                return Result.success(cagecell);  //调拨位置的参数内容 
                //判断调拨结束后再次出片
                
               }
               
             }
        }
    
}
 
   @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);
            }else{
                //返回不可进片
            }
            
             
        }         
        return Result.success("不可进片");      
      
    }
    
 
    @PostMapping("/save")
    public Result save(@RequestBody StorageCage spian){
        spianservice.Save(spian);
        return Result.success();
    }
 
 
 
 
 
}