ZengTao
2024-05-13 c85904597bf93e0fbae321093a970dd973b0f64f
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
package com.example.springboot.service;
 
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.example.springboot.common.Result;
import com.example.springboot.entity.Out_slice;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.mapper.HomeMapper;
import com.example.springboot.mapper.SpianMapper;
 
@Service
public class OutSliceServive {
 
  @Autowired
  private HomeMapper homeMapper;
  @Autowired
  private SpianMapper spianMapper;
  @Autowired
  SpianService spianService;
  @Autowired
  StorageCageService storageCageService;
 
  public void AddOutSliceS(String[][] AluminumFrames) throws SQLException {
    // int sequence = homeMapper.SelectMaxSquence();
 
    // 添加到数据库
    // for (String[] item : AluminumFrames) {
    // if (item[1] == "true") {
    // Short state=0;
    // String position = jdbcConnections.SelectPositionByFrameBarcode(item[3]);
    // homeMapper.AddOutSliceS(item[0], item[2], item[3], item[4], item[5],
    // sequence, position,state );
    // sequence += 1;
    // }
    // }
  }
 
  // 查询出片队列
  public List<Out_slice> SelectProductionqueue() {
    List<Out_slice> listoutslice = homeMapper.SelectProductionqueue();
    // for (Out_slice out_slice : listoutslice) {
    // out_slice.setstorageCage(homeMapper.SelectStorageGlassById(out_slice.getGlassId()));
    // }
    return listoutslice;
  }
 
  // 完成出片任务
  public Result CompleteQueue(String id, String frameid, String glassid) {
    homeMapper.CompleteQueueByGlassId(glassid);
    Map<String, Object> map = new HashMap<>();
    map.put("message", "200");
    return Result.success(map);
  }
 
  // 确认后完成修改出片队列状态
  public void CompleteQueueByGlassId(String glassid) {
    homeMapper.CompleteQueueByGlassId(glassid);
    Out_slice outslice = homeMapper.SelectQueueByglassid(glassid);
    Short num = homeMapper.SelectCountByFrameNo(outslice.getBarCode());
    if (num == 0) {
      homeMapper.CompleteQueueByFrameNo(outslice.getBarCode());
    }
  }
 
  // 终止进片/出片
  public void StopTask(String glassid, int i) {
    if (i == 0) {// 进片终止
      homeMapper.UpdateTask(0,glassid);// 完成进片任务
      DeleteByGlassIDs(glassid);//删除进片任务
      homeMapper.UpdateOutSliceGlass(glassid);
    } else if(i==1) {// 出片终止
      homeMapper.UpdateTask(1,glassid);// 完成出片任务
      spianMapper.UpdataGlassCage(glassid, 0);// 清除出片格子玻璃信息
      homeMapper.UpdateOutSliceGlass(glassid);// 修改出片队列此玻璃状态为缺失
    }else{
      //清除进片
      homeMapper.UpdateTask(2,glassid);
      homeMapper.UpdateOutSliceGlass(glassid);
      //清除进出片玻璃id
      DeleteByGlassIDs(glassid);
    }
 
  }
 
  // 删除笼内玻璃还原宽度
  public void DeleteByGlassIDs(String glassid) {
    List<StorageCage> glassinfor = homeMapper.SelectStorageInfoByGlassId(glassid);
    for (StorageCage storageCage : glassinfor) {
      if (storageCage.getState().equals("2")||storageCage.getState().equals("1")) {
        homeMapper.UpdataCageWidth(storageCage.getGlassWidth(), storageCage.getCage(), storageCage.getCell());
      }
    }
    homeMapper.DeleteByGlassID(glassid);
    
  }
 
  //修改铝框确认状态
  public Result FrameStateUpdate(String frameno) {
    homeMapper.FrameStateUpdate(frameno);
    Map<String, Object> map = new HashMap<>();
    map.put("message", "200");
    return Result.success(map);
  }
  //查询当前铝框
  public Out_slice SelectCurrentFrame() {
    return homeMapper.SelectCurrentFrame();
  }
 
public Result CompleteQueueByFrameNo(String frameNo) {
  Map<String, Object> map = new HashMap<>();
  Short num= homeMapper.SelectOutingQueueCount(frameNo);
  if(num==0){
    homeMapper.CompleteQueueByFrameNo(frameNo);
    map.put("message", "200");
  }else{
    map.put("message", "300");
  }
  return Result.success(map);
}
 
}