|
|
|
@ -7,10 +7,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
import com.zhehekeji.web.entity.Stock;
|
|
|
|
import com.zhehekeji.web.config.ConfigProperties;
|
|
|
|
import com.zhehekeji.web.entity.CheckLog;
|
|
|
|
import com.zhehekeji.web.entity.*;
|
|
|
|
import com.zhehekeji.web.entity.StockLog;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.entity.Street;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.mapper.CheckLogMapper;
|
|
|
|
import com.zhehekeji.web.mapper.CheckLogMapper;
|
|
|
|
import com.zhehekeji.web.mapper.StockLogMapper;
|
|
|
|
import com.zhehekeji.web.mapper.StockLogMapper;
|
|
|
|
import com.zhehekeji.web.mapper.StockMapper;
|
|
|
|
import com.zhehekeji.web.mapper.StockMapper;
|
|
|
|
@ -20,9 +18,14 @@ import com.zhehekeji.web.pojo.stock.*;
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.web.client.ResourceAccessException;
|
|
|
|
|
|
|
|
import org.springframework.web.client.RestClientException;
|
|
|
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@ -45,6 +48,9 @@ public class StockService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private StreetMapper streetMapper;
|
|
|
|
private StreetMapper streetMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
ConfigProperties configProperties;
|
|
|
|
|
|
|
|
|
|
|
|
public void importExcel(MultipartFile file) {
|
|
|
|
public void importExcel(MultipartFile file) {
|
|
|
|
log.info("import excel stock");
|
|
|
|
log.info("import excel stock");
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
@ -74,6 +80,7 @@ public class StockService {
|
|
|
|
List<Stock> stocks = stockMapper.selectList(new QueryWrapper<Stock>().eq("street_id", streetId).orderByAsc("`direction`", "`side`", "`row`", "`column`"));
|
|
|
|
List<Stock> stocks = stockMapper.selectList(new QueryWrapper<Stock>().eq("street_id", streetId).orderByAsc("`direction`", "`side`", "`row`", "`column`"));
|
|
|
|
return stocks;
|
|
|
|
return stocks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Stock> list() {
|
|
|
|
public List<Stock> list() {
|
|
|
|
|
|
|
|
|
|
|
|
//List<String> shelves = streetService.check(street);
|
|
|
|
//List<String> shelves = streetService.check(street);
|
|
|
|
@ -112,11 +119,15 @@ public class StockService {
|
|
|
|
columnTabStatus.put(column, 0);
|
|
|
|
columnTabStatus.put(column, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取全部盘点内容
|
|
|
|
//获取全部盘点内容
|
|
|
|
List<Stock> stocks = stockMapper.selectList(new QueryWrapper<Stock>().select("status", "`row`", "`column`")
|
|
|
|
List<Stock> stocks = stockMapper.selectList(new QueryWrapper<Stock>()
|
|
|
|
|
|
|
|
.select("status", "`row`", "`column`", "export_Time")
|
|
|
|
.eq("`street_id`", rowColumnStatus.getStreetId())
|
|
|
|
.eq("`street_id`", rowColumnStatus.getStreetId())
|
|
|
|
.eq("direction", rowColumnStatus.getDirection())
|
|
|
|
.eq("direction", rowColumnStatus.getDirection())
|
|
|
|
.eq("side", rowColumnStatus.getSide()));
|
|
|
|
.eq("side", rowColumnStatus.getSide())
|
|
|
|
|
|
|
|
.orderByDesc("export_Time"));
|
|
|
|
|
|
|
|
Set<String> seen = new HashSet<>();
|
|
|
|
Map<Integer, Map<Integer, Stock>> stocksMap = stocks.stream()
|
|
|
|
Map<Integer, Map<Integer, Stock>> stocksMap = stocks.stream()
|
|
|
|
|
|
|
|
.filter(f -> seen.add(f.getRow() + "-" + f.getColumn()))
|
|
|
|
//修改盘点范围值
|
|
|
|
//修改盘点范围值
|
|
|
|
.peek(stock -> {
|
|
|
|
.peek(stock -> {
|
|
|
|
|
|
|
|
|
|
|
|
@ -124,11 +135,11 @@ public class StockService {
|
|
|
|
String[] strings = entry.getKey().split(" - ");
|
|
|
|
String[] strings = entry.getKey().split(" - ");
|
|
|
|
if (stock.getRow() >= Integer.parseInt(strings[0]) && stock.getRow() <= Integer.parseInt(strings[1])) {
|
|
|
|
if (stock.getRow() >= Integer.parseInt(strings[0]) && stock.getRow() <= Integer.parseInt(strings[1])) {
|
|
|
|
//若存在则先绿3
|
|
|
|
//若存在则先绿3
|
|
|
|
if(entry.getValue() == 0) entry.setValue(3);
|
|
|
|
if (entry.getValue() == 0) entry.setValue(3);
|
|
|
|
//存在异常爆红2
|
|
|
|
//存在异常爆红2
|
|
|
|
if (stock.getStatus() == 1 ) {
|
|
|
|
if (stock.getStatus() == 1) {
|
|
|
|
entry.setValue(2);
|
|
|
|
entry.setValue(2);
|
|
|
|
}else if(entry.getValue() != 2 && stock.getStatus() == 0 ){//存在不爆红且未盘点
|
|
|
|
} else if (entry.getValue() != 2 && stock.getStatus() == 0) {//存在不爆红且未盘点
|
|
|
|
entry.setValue(1);
|
|
|
|
entry.setValue(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -137,11 +148,11 @@ public class StockService {
|
|
|
|
String[] strings = entry.getKey().split(" - ");
|
|
|
|
String[] strings = entry.getKey().split(" - ");
|
|
|
|
if (stock.getColumn() >= Integer.parseInt(strings[0]) && stock.getColumn() <= Integer.parseInt(strings[1])) {
|
|
|
|
if (stock.getColumn() >= Integer.parseInt(strings[0]) && stock.getColumn() <= Integer.parseInt(strings[1])) {
|
|
|
|
//若存在则先绿3
|
|
|
|
//若存在则先绿3
|
|
|
|
if(entry.getValue() == 0) entry.setValue(3);
|
|
|
|
if (entry.getValue() == 0) entry.setValue(3);
|
|
|
|
//存在异常爆红2
|
|
|
|
//存在异常爆红2
|
|
|
|
if (stock.getStatus() == 1 ) {
|
|
|
|
if (stock.getStatus() == 1) {
|
|
|
|
entry.setValue(2);
|
|
|
|
entry.setValue(2);
|
|
|
|
}else if(entry.getValue() != 2 && stock.getStatus() == 0 ){//存在不爆红且未盘点黄色1
|
|
|
|
} else if (entry.getValue() != 2 && stock.getStatus() == 0) {//存在不爆红且未盘点黄色1
|
|
|
|
entry.setValue(1);
|
|
|
|
entry.setValue(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -149,9 +160,9 @@ public class StockService {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
//若未盘点修改为-1
|
|
|
|
//若未盘点修改为-1
|
|
|
|
.peek(stock -> {
|
|
|
|
.peek(stock -> {
|
|
|
|
if (stock.getStatus() == 0){
|
|
|
|
if (stock.getStatus() == 0) {
|
|
|
|
stock.setViewStatus(-1);
|
|
|
|
stock.setViewStatus(-1);
|
|
|
|
}else stock.setViewStatus(stock.getStatus());
|
|
|
|
} else stock.setViewStatus(stock.getStatus());
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.collect(Collectors.groupingBy(Stock::getColumn, Collectors.toMap(Stock::getRow, v -> v)));
|
|
|
|
.collect(Collectors.groupingBy(Stock::getColumn, Collectors.toMap(Stock::getRow, v -> v)));
|
|
|
|
//赋值
|
|
|
|
//赋值
|
|
|
|
@ -165,7 +176,7 @@ public class StockService {
|
|
|
|
stock.setViewStatus(0);
|
|
|
|
stock.setViewStatus(0);
|
|
|
|
//stock.setShelveId(shelveId);
|
|
|
|
//stock.setShelveId(shelveId);
|
|
|
|
stockList.add(stock);
|
|
|
|
stockList.add(stock);
|
|
|
|
}else stockList.add(stocksMap.get(j).get(i));
|
|
|
|
} else stockList.add(stocksMap.get(j).get(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -174,6 +185,7 @@ public class StockService {
|
|
|
|
checkStatus.setStocks(stockList);
|
|
|
|
checkStatus.setStocks(stockList);
|
|
|
|
return checkStatus;
|
|
|
|
return checkStatus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CheckStatus statusByRowColumn(RowColumnStatus rowColumnStatus) {
|
|
|
|
public CheckStatus statusByRowColumn(RowColumnStatus rowColumnStatus) {
|
|
|
|
CheckStatus checkStatus = new CheckStatus();
|
|
|
|
CheckStatus checkStatus = new CheckStatus();
|
|
|
|
checkStatus.setColumnStart(rowColumnStatus.getColumnStart());
|
|
|
|
checkStatus.setColumnStart(rowColumnStatus.getColumnStart());
|
|
|
|
@ -473,12 +485,44 @@ public class StockService {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stock.getReply() == 1) {
|
|
|
|
|
|
|
|
uploadResultsWMS(stock, stockCheck.getOk());
|
|
|
|
|
|
|
|
}
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
checkLog(stock);
|
|
|
|
checkLog(stock);
|
|
|
|
return stock;
|
|
|
|
return stock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void uploadResultsWMS(Stock stock, Integer stockStatus) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResponseEntity<String> body = null;
|
|
|
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
|
|
String url = configProperties.getUploadResultsApiUrl();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UploadCheckResults uploadCheckResults = new UploadCheckResults();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//String url = "http://127.0.0.1:8083"+"/visionCompute";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uploadCheckResults.setWcsTaskId(stock.getCheckNum().split("_")[1]);
|
|
|
|
|
|
|
|
uploadCheckResults.setWmsTaskId(stock.getTaskWMSId());
|
|
|
|
|
|
|
|
uploadCheckResults.setPalno(stock.getWmsCode());
|
|
|
|
|
|
|
|
uploadCheckResults.setFlag(stockStatus == 1 ? 1 : 0);
|
|
|
|
|
|
|
|
uploadCheckResults.setAddre(stock.getAddre());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String jsonString = gson.toJson(algorithmPojo);
|
|
|
|
|
|
|
|
body = restTemplate.postForEntity(url, uploadCheckResults, String.class);
|
|
|
|
|
|
|
|
JSONObject.parseObject(body.getBody(), UploadCheckResults.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(body);
|
|
|
|
|
|
|
|
} catch (RestClientException e) {
|
|
|
|
|
|
|
|
log.error("上传结果失败", e);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CheckLogMapper checkLogMapper;
|
|
|
|
private CheckLogMapper checkLogMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@ -497,12 +541,12 @@ public class StockService {
|
|
|
|
checkLog.setCode(stock.getCode());
|
|
|
|
checkLog.setCode(stock.getCode());
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
checkLog.setExportTime(stock.getExportTime());
|
|
|
|
checkLog.setExportTime(stock.getExportTime());
|
|
|
|
checkLogMapper.update(checkLog,new UpdateWrapper<CheckLog>()
|
|
|
|
checkLogMapper.update(checkLog, new UpdateWrapper<CheckLog>()
|
|
|
|
.eq("check_num",stock.getCheckNum())
|
|
|
|
.eq("check_num", stock.getCheckNum())
|
|
|
|
.eq("`column`",stock.getColumn())
|
|
|
|
.eq("`column`", stock.getColumn())
|
|
|
|
.eq("`row`",stock.getRow())
|
|
|
|
.eq("`row`", stock.getRow())
|
|
|
|
.eq("direction",stock.getDirection())
|
|
|
|
.eq("direction", stock.getDirection())
|
|
|
|
.eq("side",stock.getSide()));
|
|
|
|
.eq("side", stock.getSide()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -532,7 +576,7 @@ public class StockService {
|
|
|
|
stock.setStatus(3);
|
|
|
|
stock.setStatus(3);
|
|
|
|
List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().eq("status", "0"));
|
|
|
|
List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().eq("status", "0"));
|
|
|
|
stockMapper.update(stock, new QueryWrapper<Stock>().eq("status", "0"));
|
|
|
|
stockMapper.update(stock, new QueryWrapper<Stock>().eq("status", "0"));
|
|
|
|
for (Stock s:stockList){
|
|
|
|
for (Stock s : stockList) {
|
|
|
|
StockCheck stockCheck = new StockCheck();
|
|
|
|
StockCheck stockCheck = new StockCheck();
|
|
|
|
stockCheck.setColumn(s.getColumn());
|
|
|
|
stockCheck.setColumn(s.getColumn());
|
|
|
|
stockCheck.setStreetId(s.getStreetId());
|
|
|
|
stockCheck.setStreetId(s.getStreetId());
|
|
|
|
|