|
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
136
137
138
139
140
141
142
143
144
145
146
147
|
@Override
public PointPosition getPositionByPositionName(String code, String warehouseCode) {
PointPosition one = this.getOne(new LambdaQueryWrapper<PointPosition>()
.eq(PointPosition::getPositionName,code)
.last("LIMIT 1"));
return one;
}
@Override
public void updateStatus(String point, String status, String warehouseCode) {
if (StringUtils.isNotEmpty(point)) {
this.update(new LambdaUpdateWrapper<PointPosition>()
.eq(PointPosition::getPositionName, point)
.eq(PointPosition::getWarehouseCode, QuantityConstant.WAREHOUSE_CS)
.set(PointPosition::getStatus, status));
}
}
@Override
public void setContainerCode(String positionName, String containerCode, String warehouseCode) {
if(StringUtils.isNotEmpty(positionName)){
this.update(new LambdaUpdateWrapper<PointPosition>()
.eq(PointPosition::getPositionName, positionName)
.eq(PointPosition::getWarehouseCode, QuantityConstant.WAREHOUSE_CS)
.set(PointPosition::getContainerCode, containerCode));
}
}
@Override
public AjaxResult<List<PointPosition>> insertPointPosition(String pointPositionType, Integer quantity) {
List<PointPosition> containerList = new ArrayList<>();
List<PointPosition> containers =new ArrayList<>();
Integer number = getNumber(pointPositionType);
for(int i=0; i<quantity; i++) {
number++;
PointPosition container = new PointPosition();
if(pointPositionType.equals("A")){
container.setPositionName(String.format("%s%01d", pointPositionType, number));
}
if(pointPositionType.equals("P")){
container.setPositionName(String.format("%s%04d", pointPositionType, number));
}
if(pointPositionType.equals("H")){
container.setPositionName(String.format("%s%04d", pointPositionType, number));
}
container.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY);
container.setCreated(new Date());
container.setUpdated(new Date());
container.setEnable("1");
container.setWarehouseCode(ShiroUtils.getWarehouseCode());
containers.add(container);
if( i>0 && (i%1000==0 || i == quantity-1)){
this.saveBatch(containers);
containers = new ArrayList<>();
}
}
return AjaxResult.success(containers);
}
@Override
public boolean clearShelfByPositionName(String positionName) {
LambdaUpdateWrapper<PointPosition> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.eq(PointPosition::getPositionName,positionName)
.set(PointPosition::getStatus,QuantityConstant.STATUS_CONTAINER_EMPTY)
.set(PointPosition::getShelfNo,null);
return this.update(updateWrapper);
}
@Override
public boolean fillShelfByPositionName(String positionName,String shelfNo) {
LambdaUpdateWrapper<PointPosition> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.eq(PointPosition::getPositionName,positionName)
.set(PointPosition::getStatus,QuantityConstant.STATUS_CONTAINER_SOME)
.set(PointPosition::getShelfNo,shelfNo);
return this.update(updateWrapper);
}
private Integer getNumber(String type) {
if(type.equals("A")){
PointPosition pointPosition=getPointPositionByPositionName(type);
//如果指定类型的最后的code存在,那么 code = 容器类型 + (排序号 + 1)
if (pointPosition != null && pointPosition.getPositionName() != null) {
Integer number = Integer.valueOf(pointPosition.getPositionName().substring(1, pointPosition.getPositionName().length()));
return number;
} else {
return 0;
}
}
if(type.equals("P")){
PointPosition pointPosition=getPointPositionByPositionName(type);
//如果指定类型的最后的code存在,那么 code = 容器类型 + (排序号 + 1)
if (pointPosition != null && pointPosition.getPositionName() != null) {
Integer number = Integer.valueOf(pointPosition.getPositionName().substring( pointPosition.getPositionName().length()-4, pointPosition.getPositionName().length()));
return number;
} else {
return 0;
}
}
if(type.equals("H")){
PointPosition pointPosition=getPointPositionByPositionName(type);
//如果指定类型的最后的code存在,那么 code = 容器类型 + (排序号 + 1)
if (pointPosition != null && pointPosition.getPositionName() != null) {
Integer number = Integer.valueOf(pointPosition.getPositionName().substring( pointPosition.getPositionName().length()-4, pointPosition.getPositionName().length()));
return number;
} else {
return 0;
}
}
return 0;
}
public PointPosition getPointPositionByPositionName(String positionName) {
PointPosition one = this.getOne(new LambdaQueryWrapper<PointPosition>()
.eq(PointPosition::getPositionName, positionName)
.last("LIMIT 1"));
return one;
}
|