AgvPortServiceImpl.java
4.27 KB
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
129
130
131
132
133
134
135
package com.huaheng.api.acs.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.api.acs.domain.AgvPort;
import com.huaheng.api.acs.mapper.AgvPortCsMapper;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 【请填写功能名称】 服务层实现
*
* @author huaheng
* @date 2022-07-27
*/
@Service
public class AgvPortServiceImpl extends ServiceImpl<AgvPortCsMapper, AgvPort> implements AgvPortService {
@Resource
private AgvPortCsMapper agvPortCsMapper;
@Override
public List<AgvPort> getListByContainerCode(String containerCode) {
LambdaQueryWrapper<AgvPort> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AgvPort::getContainerCode, containerCode);
return list(queryWrapper);
}
@Override
public AgvPort getByContainerCode(String containerCode) {
LambdaQueryWrapper<AgvPort> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AgvPort::getContainerCode, containerCode).orderByAsc(AgvPort::getType).last("limit 1");
return getOne(queryWrapper);
}
@Override
public boolean lockById(Long id) {
AgvPort agvPort = getById(id);
agvPort.setStatus("lock");
return updateById(agvPort);
}
@Override
public boolean unlockById(Long id) {
AgvPort agvPort = getById(id);
agvPort.setStatus("empty");
return updateById(agvPort);
}
@Override
public boolean clearContainerCodeById(Long id) {
AgvPort agvPort = getById(id);
agvPort.setContainerCode("");
return updateById(agvPort);
}
@Override
public boolean setContainerCodeById(Long id, String containerCode) {
AgvPort agvPort = getById(id);
agvPort.setContainerCode(containerCode);
return updateById(agvPort);
}
@Override
public boolean containerInPort(String containerCode) {
List list = getListByContainerCode(containerCode);
if(list == null || list.size() == 0){
return false;
}
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int addAgvPort(String startNum,String endNum,String name,String workStationId,String containerCode,String type,String area) {
List agvPorts = new ArrayList();
for(int i=Integer.valueOf(startNum);i<=Integer.valueOf(endNum);i++){
AgvPort agvPort=new AgvPort();
agvPort.setCode("Work"+" "+i);
agvPort.setName(name+""+i);
if(StringUtils.isNotEmpty(workStationId)){
agvPort.setWorkStationId(Long.valueOf(workStationId));
}
agvPort.setType(Long.valueOf(type));
agvPort.setArea(area);
agvPort.setStatus("empty");
agvPorts.add(agvPort);
}
return agvPortCsMapper.addList(agvPorts);
}
@Override
public AgvPort getAgvportByCode(String code) {
LambdaQueryWrapper<AgvPort> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(AgvPort::getCode, code).orderByAsc(AgvPort::getType).last("limit 1");
return this.getOne(queryWrapper);
}
@Override
public void updateStatus(String code, String status) {
if (StringUtils.isNotEmpty(code)) {
agvPortCsMapper.updateStatus(code, status);
}
}
@Override
public void setContainerCode(String code, String containerCode) {
if(StringUtils.isNotEmpty(code)){
agvPortCsMapper.setContainerCode(code,containerCode);
}
}
@Override
public AjaxResult<List<AgvPort>> insertAgvport(String portType, Integer quantity) {
return AjaxResult.success();
}
@Override
public boolean clearContainerCodeByCode(String code) {
return agvPortCsMapper.clearContainerCodeByCode(code);
}
@Override
public List<String> getSize2Code(Long id) {
return agvPortCsMapper.getSize2Code(id);
}
}