|
|
|
|
@ -10,16 +10,17 @@ import com.zhehekeji.web.mapper.CheckSummaryMapper;
|
|
|
|
|
import com.zhehekeji.web.mapper.EmptyCheckMapper;
|
|
|
|
|
import com.zhehekeji.web.mapper.StockMapper;
|
|
|
|
|
import com.zhehekeji.web.pojo.empty.EmptyCheckSearch;
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.CheckStatus;
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.RowColumnStatus;
|
|
|
|
|
import com.zhehekeji.web.service.client.ECTransmission;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@ -173,15 +174,182 @@ public class EmptyCheckService {
|
|
|
|
|
emptyCheck.setStreetId(street.getId());
|
|
|
|
|
emptyCheck.setSide(ecTransmission.getSide());
|
|
|
|
|
emptyCheck.setDirection(ecTransmission.getDirection());
|
|
|
|
|
//0:未知 1:空 2:非空
|
|
|
|
|
if(ecTransmission.getIsEmpty().equals("N")){
|
|
|
|
|
emptyCheck.setEmptyStatus(3);
|
|
|
|
|
}else {
|
|
|
|
|
emptyCheck.setEmptyStatus(1);
|
|
|
|
|
}else {
|
|
|
|
|
emptyCheck.setEmptyStatus(2);
|
|
|
|
|
}
|
|
|
|
|
emptyCheck.setRow(ecTransmission.getRow());
|
|
|
|
|
emptyCheck.setColumn(ecTransmission.getColumn());
|
|
|
|
|
emptyCheckMapper.insert(emptyCheck);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CheckStatus emptyStatusByRowColumn(RowColumnStatus rowColumnStatus){
|
|
|
|
|
CheckStatus checkStatus = new CheckStatus();
|
|
|
|
|
checkStatus.setColumnStart(rowColumnStatus.getColumnStart());
|
|
|
|
|
checkStatus.setColumnEnd(rowColumnStatus.getColumnEnd());
|
|
|
|
|
checkStatus.setRowStart(rowColumnStatus.getRowStart());
|
|
|
|
|
checkStatus.setRowEnd(rowColumnStatus.getRowEnd());
|
|
|
|
|
//checkStatus.setShelveId(rowColumnStatus.getShelveId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<EmptyCheck>stockList = new ArrayList<>();
|
|
|
|
|
//默认全部盘点正确
|
|
|
|
|
Map<String,Integer> rowTabStatus = new LinkedHashMap<>();
|
|
|
|
|
int columns = 0;
|
|
|
|
|
int rows = 0;
|
|
|
|
|
for(String rowTab: rowColumnStatus.getRowTabs()){
|
|
|
|
|
rows = getMax(rowTab,rows);
|
|
|
|
|
rowTabStatus.put(rowTab,0);
|
|
|
|
|
}
|
|
|
|
|
Map<String,Integer> columnTabStatus = new LinkedHashMap<>();
|
|
|
|
|
for(String column:rowColumnStatus.getColumnTabs()){
|
|
|
|
|
columns = getMax(column,columns);
|
|
|
|
|
columnTabStatus.put(column,0);
|
|
|
|
|
}
|
|
|
|
|
Map<String,Integer> columnTabCorrectCount = new LinkedHashMap<>();
|
|
|
|
|
Map<String,Integer> rowTabCorrectCount = new LinkedHashMap<>();
|
|
|
|
|
List<EmptyCheck> stocks = emptyCheckMapper.selectList(new QueryWrapper<EmptyCheck>().select("empty_status","`row`","`column`").eq("`street_id`",rowColumnStatus.getStreetId()).eq("direction",rowColumnStatus.getDirection()).eq("side",rowColumnStatus.getSide()));
|
|
|
|
|
if(CollectionUtils.isEmpty(stocks)){
|
|
|
|
|
stockInit(rowColumnStatus.getRowStart(), rowColumnStatus.getRowEnd(), rowColumnStatus.getColumnStart(), rowColumnStatus.getColumnEnd(), null,stocks);
|
|
|
|
|
checkStatus.setEmptyStatus(stocks);
|
|
|
|
|
checkStatus.setRowTabStatus(rowTabStatus);
|
|
|
|
|
checkStatus.setColumnTabStatus(columnTabStatus);
|
|
|
|
|
return checkStatus;
|
|
|
|
|
}
|
|
|
|
|
for(EmptyCheck emptyCheck: stocks){
|
|
|
|
|
if(emptyCheck.getEmptyStatus() == null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(emptyCheck.getColumn()>= rowColumnStatus.getColumnStart() && emptyCheck.getColumn()<= rowColumnStatus.getColumnEnd() && emptyCheck.getRow() >= rowColumnStatus.getRowStart() && emptyCheck.getRow()<= rowColumnStatus.getRowEnd()){
|
|
|
|
|
stockList.add(emptyCheck);
|
|
|
|
|
}
|
|
|
|
|
if(!CollectionUtils.isEmpty(rowColumnStatus.getRowTabs())){
|
|
|
|
|
for(String rowTab: rowColumnStatus.getRowTabs()){
|
|
|
|
|
if(isRowColumnInTab(emptyCheck,rowTab,true)){
|
|
|
|
|
tabStatus(emptyCheck,rowTabStatus,rowTab);
|
|
|
|
|
|
|
|
|
|
// if(emptyCheck.getEmptyStatus() != 0 && emptyCheck.getEmptyStatus() != 1){
|
|
|
|
|
// if(rowTabCorrectCount.get(rowTab) == null){
|
|
|
|
|
// rowTabCorrectCount.put(rowTab,1);
|
|
|
|
|
// }else {
|
|
|
|
|
// int c = rowTabCorrectCount.get(rowTab);
|
|
|
|
|
// rowTabCorrectCount.put(rowTab,c+1);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!CollectionUtils.isEmpty(rowColumnStatus.getColumnTabs())){
|
|
|
|
|
for(String columnTab: rowColumnStatus.getColumnTabs()){
|
|
|
|
|
if(isRowColumnInTab(emptyCheck,columnTab,false)){
|
|
|
|
|
tabStatus(emptyCheck,columnTabStatus,columnTab);
|
|
|
|
|
// if(emptyCheck.getEmptyStatus() != 0 && emptyCheck.getEmptyStatus() != 1){
|
|
|
|
|
// if(columnTabCorrectCount.get(columnTab) == null){
|
|
|
|
|
// columnTabCorrectCount.put(columnTab,1);
|
|
|
|
|
// }else {
|
|
|
|
|
// int c = columnTabCorrectCount.get(columnTab);
|
|
|
|
|
// columnTabCorrectCount.put(columnTab,c+1);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// for(Map.Entry<String,Integer> entry: rowTabCorrectCount.entrySet()){
|
|
|
|
|
// String [] strings = entry.getKey().split(" - ");
|
|
|
|
|
// Integer tabStart = Integer.valueOf(strings[0]);
|
|
|
|
|
// Integer tabEnd = Integer.valueOf(strings[1]);
|
|
|
|
|
// int counts = (tabEnd- tabStart + 1) * rows;
|
|
|
|
|
// if(counts == entry.getValue()){
|
|
|
|
|
// rowTabStatus.put(entry.getKey(),2);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// for(Map.Entry<String,Integer> entry: columnTabCorrectCount.entrySet()){
|
|
|
|
|
// String [] strings = entry.getKey().split(" - ");
|
|
|
|
|
// Integer tabStart = Integer.valueOf(strings[0]);
|
|
|
|
|
// Integer tabEnd = Integer.valueOf(strings[1]);
|
|
|
|
|
// int counts = (tabEnd- tabStart + 1) * rows;
|
|
|
|
|
// if(counts == entry.getValue()){
|
|
|
|
|
// columnTabStatus.put(entry.getKey(),2);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
checkStatus.setColumnTabStatus(columnTabStatus);
|
|
|
|
|
checkStatus.setRowTabStatus(rowTabStatus);
|
|
|
|
|
checkStatus.setEmptyStatus(stockInit(rowColumnStatus.getRowStart(), rowColumnStatus.getRowEnd(), rowColumnStatus.getColumnStart(), rowColumnStatus.getColumnEnd(), null,stockList));
|
|
|
|
|
return checkStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<EmptyCheck> stockInit(Integer rowStart, Integer rowEnd,Integer columnStart,Integer columnEnd,String shelveId,List<EmptyCheck> readyList){
|
|
|
|
|
Map<Integer,Map<Integer,Boolean>> map = new HashMap<>();
|
|
|
|
|
readyList.forEach(stock -> {
|
|
|
|
|
if(map.get(stock.getRow()) == null){
|
|
|
|
|
Map<Integer,Boolean> columnMap = new HashMap<>();
|
|
|
|
|
columnMap.put(stock.getColumn(),true);
|
|
|
|
|
map.put(stock.getRow(),columnMap);
|
|
|
|
|
}else {
|
|
|
|
|
Map<Integer,Boolean> columnMap = map.get(stock.getRow());
|
|
|
|
|
if(columnMap.get(stock.getColumn()) == null){
|
|
|
|
|
columnMap.put(stock.getColumn(),true);
|
|
|
|
|
}
|
|
|
|
|
map.put(stock.getRow(),columnMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
for(int i = rowStart;i<=rowEnd;i++){
|
|
|
|
|
Map<Integer,Boolean> columnMap = map.get(i);
|
|
|
|
|
for(int j = columnStart;j<=columnEnd;j++){
|
|
|
|
|
if(columnMap == null || columnMap.get(j) == null){
|
|
|
|
|
EmptyCheck emptyCheck = new EmptyCheck();
|
|
|
|
|
emptyCheck.setColumn(j);
|
|
|
|
|
emptyCheck.setRow(i);
|
|
|
|
|
emptyCheck.setEmptyStatus(0);
|
|
|
|
|
//stock.setShelveId(shelveId);
|
|
|
|
|
readyList.add(emptyCheck);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return readyList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//0:未知 1:空 2:非空
|
|
|
|
|
//未知 > 空 > 非空
|
|
|
|
|
private void tabStatus(EmptyCheck stock,Map<String,Integer> tabStatus,String tab){
|
|
|
|
|
if(tabStatus.get(tab) == null){
|
|
|
|
|
tabStatus.put(tab,stock.getEmptyStatus());
|
|
|
|
|
}else {
|
|
|
|
|
Integer status = tabStatus.get(tab);
|
|
|
|
|
if(stock.getEmptyStatus() == 0){
|
|
|
|
|
//未知为最优先状态
|
|
|
|
|
tabStatus.put(tab,0);
|
|
|
|
|
}else if(stock.getEmptyStatus() == 1 && status != 0) {
|
|
|
|
|
tabStatus.put(tab, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean isRowColumnInTab(EmptyCheck stock,String tab,Boolean isRow){
|
|
|
|
|
String [] strings = tab.split(" - ");
|
|
|
|
|
Integer tabStart = Integer.valueOf(strings[0]);
|
|
|
|
|
Integer tabEnd = Integer.valueOf(strings[1]);
|
|
|
|
|
if(isRow){
|
|
|
|
|
return stock.getRow() >= tabStart && stock.getRow() <= tabEnd;
|
|
|
|
|
}else {
|
|
|
|
|
return stock.getColumn() >= tabStart && stock.getColumn() <= tabEnd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getMax(String tab,Integer max){
|
|
|
|
|
String [] strings = tab.split(" - ");
|
|
|
|
|
Integer tabStart = Integer.valueOf(strings[0]);
|
|
|
|
|
Integer tabEnd = Integer.valueOf(strings[1]);
|
|
|
|
|
int a = tabStart > tabEnd ? tabStart : tabEnd;
|
|
|
|
|
a = max > a ? max : a;
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|