Commit 0968732a zshaohui

呼叫空箱 功能提交

1 个父辈 104c4745
...@@ -148,7 +148,11 @@ public class DataCache { ...@@ -148,7 +148,11 @@ public class DataCache {
*/ */
public void updateCache(String cacheKey, Object value){ public void updateCache(String cacheKey, Object value){
cacheItemDao.updateCacheItem(cacheKey,value); cacheItemDao.updateCacheItem(cacheKey,value);
cacheMap.put(cacheKey,value); if(value == null){
cacheMap.remove(cacheKey);
} else {
cacheMap.put(cacheKey, value);
}
if(cacheKey.equals(Constants.CACHE_CodeRule)){ if(cacheKey.equals(Constants.CACHE_CodeRule)){
List<String> ruleList=(List<String>)value; List<String> ruleList=(List<String>)value;
codeResolve.updateBarcodeRuleList(ruleList); codeResolve.updateBarcodeRuleList(ruleList);
......
...@@ -24,4 +24,6 @@ public class WareHouseCodeDto implements Serializable { ...@@ -24,4 +24,6 @@ public class WareHouseCodeDto implements Serializable {
@ApiModelProperty("描述") @ApiModelProperty("描述")
private String description; private String description;
private boolean choose = false;
} }
...@@ -112,6 +112,9 @@ public class CodeController { ...@@ -112,6 +112,9 @@ public class CodeController {
for (WareHouseCode code : codes) { for (WareHouseCode code : codes) {
WareHouseCodeDto codeDto = codeMapper.toDto(code); WareHouseCodeDto codeDto = codeMapper.toDto(code);
codeDto.setId(code.getId()); codeDto.setId(code.getId());
if ("W10B".equals(code.getWareHouseCode())){
codeDto.setChoose(true);
}
codeDtos.add(codeDto); codeDtos.add(codeDto);
} }
return new PageData(codeDtos,codePageData.getTotalElements()); return new PageData(codeDtos,codePageData.getTotalElements());
......
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean;
import lombok.Data;
@Data
public class CallEmpty {
private String warehouseCode;
private String size;
private int needCount;
}
...@@ -14,6 +14,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos; ...@@ -14,6 +14,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType; import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.CallEmpty;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil;
...@@ -28,10 +29,15 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -28,10 +29,15 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -50,34 +56,78 @@ public class CallEmptyBoxController { ...@@ -50,34 +56,78 @@ public class CallEmptyBoxController {
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
static boolean isCall = false; public static final String CACHE_CALL_EMPTY = "CACHE_CALL_EMPTY";
@ApiOperation("呼叫空箱")
@RequestMapping("/uploadInfo")
@AnonymousAccess
public ResultBean uploadInfo(String warehouseCode, String size, Integer needCount) {
if (isCall){ ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
return ResultBean.newErrorResult(-1,"","有正在计算的出库任务");
} @PostConstruct
private void initCallEmptyBox() {
scheduledThreadPool.scheduleAtFixedRate(() -> {
callEmptyBox();
}, 30, 10, TimeUnit.SECONDS);
}
isCall = true;
if (StringUtils.isEmpty(warehouseCode)) {
isCall = false; @ApiOperation("呼叫空箱")
@RequestMapping("/uploadInfo")
//@AnonymousAccess
public ResultBean uploadInfo(String warehouseCode, String size, Integer needCount) {
log.info("收到呼叫空箱任务,库位为:"+warehouseCode+",尺寸为:"+size+",需求隔口数量为:"+needCount);
if (StringUtils.isEmpty(warehouseCode)) {
return ResultBean.newErrorResult(-1, "", "库别不能为空"); return ResultBean.newErrorResult(-1, "", "库别不能为空");
} }
if (StringUtils.isEmpty(size)) { if (StringUtils.isEmpty(size)) {
isCall = false;
return ResultBean.newErrorResult(-1, "", "尺寸不能为空"); return ResultBean.newErrorResult(-1, "", "尺寸不能为空");
} }
if (needCount == null || needCount == 0) { if (needCount == null || needCount == 0) {
isCall = false;
return ResultBean.newErrorResult(-1, "", "需求隔口数量不能为空"); return ResultBean.newErrorResult(-1, "", "需求隔口数量不能为空");
} }
CallEmpty cacheCallEmpty = dataCache.getCache(CACHE_CALL_EMPTY);
if (cacheCallEmpty != null){
return ResultBean.newErrorResult(-1,"","有正在执行的任务,库位为:"+warehouseCode+",尺寸为:"+size+",需求隔口数量为:"+needCount);
}
CallEmpty callEmpty = new CallEmpty();
callEmpty.setSize(size);
callEmpty.setNeedCount(needCount);
callEmpty.setWarehouseCode(warehouseCode);
dataCache.updateCache(CACHE_CALL_EMPTY,callEmpty);
return ResultBean.newOkResult("");
}
@ApiOperation("获取所有手动线任务")
@RequestMapping("/getManualTask")
//@AnonymousAccess
public ResultBean getManualTask() {
List<DataLog> resultList = new ArrayList<>();
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.isCheckOutTask() && !dataLog.isFinished() && !dataLog.isCancel()){
if (TaskCurrentLoc.Manual_FeedingInlet.equals(dataLog.getLoc())){
resultList.add(dataLog);
}
}
}
return ResultBean.newOkResult(resultList);
}
private void callEmptyBox() {
CallEmpty cacheCallEmpty = dataCache.getCache(CACHE_CALL_EMPTY);
if (cacheCallEmpty == null) {
return;
}
String size = cacheCallEmpty.getSize();
String warehouseCode = cacheCallEmpty.getWarehouseCode();
int needCount = cacheCallEmpty.getNeedCount();
//判断partNumber //判断partNumber
String box = ""; String box = "";
if ("7".equals(size)) { if ("7".equals(size)) {
...@@ -89,12 +139,11 @@ public class CallEmptyBoxController { ...@@ -89,12 +139,11 @@ public class CallEmptyBoxController {
} }
//判断有没有可用的料箱 //判断有没有可用的料箱
/*List<String> boxList = BinCacheUtil.getBoxList(warehouseCode, ""); List<String> boxList = BinCacheUtil.getBoxList(warehouseCode, "");
if (boxList == null || boxList.isEmpty()) { if (boxList == null || boxList.isEmpty()) {
log.info(warehouseCode + "未找到可用料箱"); log.info(warehouseCode + "未找到可用料箱");
isCall = false; return;
return ResultBean.newErrorResult(-1,"","没有可用的料箱"); }
}*/
//排除掉正在使用的仓位 //排除掉正在使用的仓位
Criteria c = Criteria.where("barcode").exists(true).and("enabled").is(true);//可用 Criteria c = Criteria.where("barcode").exists(true).and("enabled").is(true);//可用
...@@ -104,7 +153,7 @@ public class CallEmptyBoxController { ...@@ -104,7 +153,7 @@ public class CallEmptyBoxController {
} }
c.and("barcode.partNumber").regex(Pattern.compile(QueryHelp.escapeExprSpecialWord(box), Pattern.CASE_INSENSITIVE)); c.and("barcode.partNumber").regex(Pattern.compile(QueryHelp.escapeExprSpecialWord(box), Pattern.CASE_INSENSITIVE));
c.and("barcode.status").is(BARCODE_STATUS.IN_STORE); c.and("barcode.status").is(BARCODE_STATUS.IN_STORE);
//c.and("barcode.barcode").in(boxList); c.and("barcode.barcode").in(boxList);
List<String> storageIdList = new ArrayList<>(); List<String> storageIdList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) { for (Storage storage : dataCache.getAllStorage().values()) {
...@@ -116,23 +165,23 @@ public class CallEmptyBoxController { ...@@ -116,23 +165,23 @@ public class CallEmptyBoxController {
int count = 0; int count = 0;
boolean hasTask = false; boolean hasTask = false;
List<StoragePos> storagePosList = storagePosManager.findByQuery(new Query(c).with(Sort.by(Sort.Direction.DESC, "barcode.amount"))); List<StoragePos> storagePosList = storagePosManager.findByQuery(new Query(c).with(Sort.by(Sort.Direction.ASC, "barcode.amount")));
for (StoragePos pos : storagePosList) { for (StoragePos pos : storagePosList) {
if (count >= needCount){ if (count >= needCount) {
break; break;
} }
Barcode barcode = pos.getBarcode(); Barcode barcode = pos.getBarcode();
List<Barcode> subCodeList = barcode.getSubCodeList(); List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList == null || subCodeList.isEmpty()) { if (subCodeList == null || subCodeList.isEmpty()) {
if ("C07".equals(box)){ if ("C07".equals(box)) {
count += 6; count += 6;
} else { } else {
count += 1; count += 1;
} }
//生成出库任务 //生成出库任务
Storage storage = dataCache.getStorageById(pos.getStorageId()); Storage storage = dataCache.getStorageById(pos.getStorageId());
log.info("生成出库任务,料箱为:"+barcode.getBarcode()+",库别为:"+warehouseCode+",尺寸为:"+size+",库位号为:"+pos.getPosName()+",隔口数量为:6/1"); log.info("生成出库任务,料箱为:" + barcode.getBarcode() + ",库别为:" + warehouseCode + ",尺寸为:" + size + ",库位号为:" + pos.getPosName() + ",隔口数量为:6/1");
BoxHandleUtil.generateTask(storage,barcode,pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), TaskCurrentLoc.Manual_FeedingInlet, ExtendType.STORAGE_CHECKOUT,999); BoxHandleUtil.generateTask(storage, barcode, pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), TaskCurrentLoc.Manual_FeedingInlet, ExtendType.STORAGE_CHECKOUT, 999);
hasTask = true; hasTask = true;
} else { } else {
Map<String, Long> countMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting())); Map<String, Long> countMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
...@@ -145,11 +194,11 @@ public class CallEmptyBoxController { ...@@ -145,11 +194,11 @@ public class CallEmptyBoxController {
noReelNum = noReelNum + 1; noReelNum = noReelNum + 1;
} }
} }
if (noReelNum > 0){ if (noReelNum > 0) {
count = count + noReelNum; count = count + noReelNum;
Storage storage = dataCache.getStorageById(pos.getStorageId()); Storage storage = dataCache.getStorageById(pos.getStorageId());
log.info("生成出库任务,料箱为:"+barcode.getBarcode()+",库别为:"+warehouseCode+",尺寸为:"+size+",库位号为:"+pos.getPosName()+",隔口数量为:"+noReelNum); log.info("生成出库任务,料箱为:" + barcode.getBarcode() + ",库别为:" + warehouseCode + ",尺寸为:" + size + ",库位号为:" + pos.getPosName() + ",隔口数量为:" + noReelNum);
BoxHandleUtil.generateTask(storage,barcode,pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), TaskCurrentLoc.Manual_FeedingInlet, ExtendType.STORAGE_CHECKOUT,999); BoxHandleUtil.generateTask(storage, barcode, pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), TaskCurrentLoc.Manual_FeedingInlet, ExtendType.STORAGE_CHECKOUT, 999);
hasTask = true; hasTask = true;
} }
} else if ("13".equals(size) || "15".equals(size)) { } else if ("13".equals(size) || "15".equals(size)) {
...@@ -157,38 +206,14 @@ public class CallEmptyBoxController { ...@@ -157,38 +206,14 @@ public class CallEmptyBoxController {
if (countMap.get(binCode) == null || countMap.get(binCode) == 0) { if (countMap.get(binCode) == null || countMap.get(binCode) == 0) {
count = count + 1; count = count + 1;
Storage storage = dataCache.getStorageById(pos.getStorageId()); Storage storage = dataCache.getStorageById(pos.getStorageId());
log.info("生成出库任务,料箱为:"+barcode.getBarcode()+",库别为:"+warehouseCode+",尺寸为:"+size+",库位号为:"+pos.getPosName()+",隔口数量为:1"); log.info("生成出库任务,料箱为:" + barcode.getBarcode() + ",库别为:" + warehouseCode + ",尺寸为:" + size + ",库位号为:" + pos.getPosName() + ",隔口数量为:1");
BoxHandleUtil.generateTask(storage,barcode,pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), TaskCurrentLoc.Manual_FeedingInlet, ExtendType.STORAGE_CHECKOUT,999); BoxHandleUtil.generateTask(storage, barcode, pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), TaskCurrentLoc.Manual_FeedingInlet, ExtendType.STORAGE_CHECKOUT, 999);
hasTask = true; hasTask = true;
} }
} }
} }
} }
if (hasTask){ dataCache.updateCache(CACHE_CALL_EMPTY,null);
isCall = false;
return ResultBean.newOkResult("");
}
isCall = false;
return ResultBean.newErrorResult(-1,"","未找到符合条件的料箱");
}
@ApiOperation("获取所有手动线任务")
@RequestMapping("/getManualTask")
@AnonymousAccess
public ResultBean getManualTask() {
List<DataLog> resultList = new ArrayList<>();
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.isCheckOutTask() && !dataLog.isFinished() && !dataLog.isCancel()){
if (TaskCurrentLoc.Manual_FeedingInlet.equals(dataLog.getLoc())){
resultList.add(dataLog);
}
}
}
return ResultBean.newOkResult(resultList);
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!