PointsServiceImpl.java
4.86 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
package com.huaheng.pc.config.points.service;
import com.aliyun.oss.ServiceException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.points.domain.Points;
import com.huaheng.pc.config.points.mapper.PointsMapper;
import org.apache.commons.collections.ListUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 货架 服务层实现
*
* @author ricard
* @date 2019-12-26
*/
@Service
public class PointsServiceImpl extends ServiceImpl<PointsMapper,Points> implements PointsService{
@Resource
private PointsMapper pointsMapper;
@Resource
private ContainerService containerService;
@Override
public int updateAll() {
return pointsMapper.updateAll();
}
@Override
public AjaxResult detectShelf() {
//查找为空的货架
List<Container> containers =containerService.selectListShelf(ShiroUtils.getWarehouseCode());
List<String> stringList = new ArrayList<>();
for(Container item : containers){
stringList.add(item.getGoodsShelfNo());
}
Integer flag = 1;
//修改空货架状态
flag = pointsMapper.updateIsEmpty(stringList, QuantityConstant.POINTS_SOME);
if(flag < 1){
return AjaxResult.error("修改空货架状态失败");
}
//查找所以货架
LambdaQueryWrapper<Points> pointsLamb = Wrappers.lambdaQuery();
pointsLamb.eq(Points::getWarehouseCode,ShiroUtils.getWarehouseCode());
List<Points> pointsList = this.list(pointsLamb);
//去重
List<String> list =new ArrayList<>();
for(Points item : pointsList){
list.add(item.getGoodsShelfNo());
}
List<String> list1 = ListUtils.subtract(list,stringList);
//修改非空货架
flag = pointsMapper.updateIsEmpty(list1,QuantityConstant.POINTS_EMPTY);
if(flag < 1){
return AjaxResult.error("修改空货架状态失败");
}
return AjaxResult.success("成功");
}
@Override
public Points selectEntity(Points points){
LambdaQueryWrapper<Points> pointsLamb = Wrappers.lambdaQuery();
pointsLamb.eq(StringUtils.isNotEmpty(points.getGoodsShelfNo()),Points::getGoodsShelfNo,points.getGoodsShelfNo());
pointsLamb.eq(StringUtils.isNotEmpty(points.getWarehouseCode()),Points::getWarehouseCode,points.getWarehouseCode());
pointsLamb.eq(StringUtils.isNotNull(points.getIsLocked()),Points::getIsLocked,points.getIsLocked());
pointsLamb.last("limit 1");
return this.getOne(pointsLamb);
}
@Override
public Points selectEntityV(Points points){
LambdaQueryWrapper<Points> pointsLamb = Wrappers.lambdaQuery();
pointsLamb.eq(StringUtils.isNotEmpty(points.getGoodsShelfNo()),Points::getGoodsShelfNo,points.getGoodsShelfNo());
pointsLamb.eq(StringUtils.isNotEmpty(points.getWarehouseCode()),Points::getWarehouseCode,points.getWarehouseCode());
pointsLamb.ge(StringUtils.isNotNull(points.getIsLocked()),Points::getIsLocked,points.getIsLocked());
pointsLamb.last("limit 1");
return this.getOne(pointsLamb);
}
@Override
public List<Map<String, Object>> selectShlfno(String warehouseCode) {
LambdaQueryWrapper<Points> pointsLamb = Wrappers.lambdaQuery();
pointsLamb.eq(StringUtils.isNotEmpty(warehouseCode),Points::getWarehouseCode,warehouseCode);
pointsLamb.orderByAsc(Points::getGoodsShelfNo);
return this.listMaps(pointsLamb);
}
@Override
@Transactional
public void updateContainerCommon(Integer[] ids,int status){
for(int a=0;a<ids.length-1;a++){
Points points=this.getById(ids[a]);
points.setCommon(status);
this.updateById(points);
//修改容器属性
Container container = new Container();
container.setGoodsShelfNo(points.getGoodsShelfNo());
List<Container> containerList = containerService.selectListEntityByEqual(container);
for (Container item : containerList) {
item.setCommon(status);
if (!containerService.updateById(item)) {
throw new ServiceException("修改容器属性失败");
}
}
}
}
}