Commit 18b4451d LN

客户端消息处理修改

1 个父辈 b5bbc12e
......@@ -157,51 +157,55 @@ public class DataInitManager {
}
private Set<String> MenuInitNew(){
private Set<String> MenuInitNew() {
List<Menu> menus=new ArrayList<Menu>();
List<Menu> menus = new ArrayList<Menu>();
//料架分组
// Menu menukanban = new Menu(new ArrayList<Menu>(), 1, "boxkanban", "锁定物料", 1, "lockMaterial", "lockMaterial/material/index", "", 0, "app");
// menus.addAll(createMenus(menukanban ));
Menu menukanban = new Menu(new ArrayList<Menu>(), 1, "boxkanban", "锁定物料", 1, "lockMaterial", "lockMaterial/material/index", "", 0, "app");
menukanban.setHidden(true);
menus.addAll(createMenus(menukanban));
//料架分组
Menu menuShelf = new Menu(new ArrayList<Menu>(), 1, "menu:list", "料架分组", 1, "lightGroup", "neolight/lightGroup/index", "", 0, "list");
menus.addAll(createMenus(menuShelf ));
menus.addAll(createMenus(menuShelf));
//出库:工单,查找出库
Menu poutOut=Menu.CreatePMenu("工单管理",20,"order",2,"zujian");
Menu poutOut = Menu.CreatePMenu("工单管理", 20, "order", 2, "zujian");
Menu menuOrder = new Menu(new ArrayList<Menu>(), 1, "menu:list", "工单", 1, "workOrder", "neolight/workOrder/index", "", 0, "icon");
Menu menuOut = new Menu(new ArrayList<Menu>(), 1, "menu:list", "查找出库", 1,"singleOuput", "neolight/singleOuput/index", "", 0, "search");
menus.addAll(createMenus( poutOut,menuOrder,menuOut));
Menu menuOut = new Menu(new ArrayList<Menu>(), 1, "menu:list", "查找出库", 1, "singleOuput", "neolight/singleOuput/index", "", 0, "search");
menus.addAll(createMenus(poutOut, menuOrder, menuOut));
//设置:料仓管理,菜单管理
Menu poutSet=Menu.CreatePMenu("设置",30,"system",2,"system");
Menu poutSet = Menu.CreatePMenu("设置", 30, "system", 2, "system");
Menu menuStorage = new Menu(new ArrayList<Menu>(), 1, "storage:list", "料仓管理", 1, "bunker", "storage/storage/index", "", 0, "database");
Menu menuStoragePos = new Menu(new ArrayList<Menu>(), 1, "storagePos:list", "库位管理", 1, "storagePos", "storagePos/storagePos/index", "", 0, "tree-table");
Menu menuMenu = new Menu(new ArrayList<Menu>(), 1, "menu:list", "菜单管理", 1, "menu", "system/menu/index", "", 0, "menu");
menus.addAll(createMenus( poutSet,menuStorage,menuStoragePos,menuMenu));
Menu sysSetting = new Menu(new ArrayList<Menu>(), 1, "setting", "系统设置", 1, "setting", "system/setting/index", "", 0, "database");
menuMenu.setHidden(true);
sysSetting.setHidden(true);
menus.addAll(createMenus(poutSet, menuStorage, menuStoragePos, menuMenu, sysSetting));
//物料管理:元器件管理,条形码管理
Menu pMenuWl=Menu.CreatePMenu("物料管理",30,"materiel ",2,"redis");
Menu menucom = new Menu(new ArrayList<Menu>(), 1, "component:list", "元器件",1, "componentParts", "parts/component/index", "", 0, "server");
Menu pMenuWl = Menu.CreatePMenu("物料管理", 30, "materiel ", 2, "redis");
Menu menucom = new Menu(new ArrayList<Menu>(), 1, "component:list", "元器件", 1, "componentParts", "parts/component/index", "", 0, "server");
Menu menubarcode = new Menu(new ArrayList<Menu>(), 1, "barcode:list", "条形码", 1, "barcode", "barcode/barcode/index", "", 0, "chart");
menus.addAll(createMenus( pMenuWl,menucom,menubarcode));
menus.addAll(createMenus(pMenuWl, menucom, menubarcode));
//日志管理:物料日志
Menu pMenuLog=Menu.CreatePMenu("日志管理",30,"log",2,"log");
Menu pMenuLog = Menu.CreatePMenu("日志管理", 30, "log", 2, "log");
Menu menuLog = new Menu(new ArrayList<Menu>(), 1, "taskLog:list", "物料日志", 1, "taskLog", "neolight/taskLog/index", "", 0, "education");
menus.addAll(createMenus( pMenuLog,menuLog));
menus.addAll(createMenus(pMenuLog, menuLog));
//用户管理:用户管理,角色管理
Menu pMenuUser=Menu.CreatePMenu("用户管理",30,"userManager",2,"Steve-Jobs");
Menu pMenuUser = Menu.CreatePMenu("用户管理", 30, "userManager", 2, "Steve-Jobs");
Menu menuUser = new Menu(new ArrayList<Menu>(), 1, "user:list", "用户管理", 1, "peoples", "system/user/index", "", 0, "peoples");
Menu menuRole = new Menu(new ArrayList<Menu>(), 1, "role:list", "角色管理", 1, "role", "system/role/index", "", 0, "role");
menus.addAll(createMenus( pMenuUser,menuUser,menuRole));
menus.addAll(createMenus(pMenuUser, menuUser, menuRole));
Set<String> menuIdSet = new HashSet<String>() {};
for (Menu menu: menus ) {
for (Menu menu : menus) {
log.info("创建默认菜单:" + menu.toString());
menuIdSet.add(menu.getId());
}
......
......@@ -143,36 +143,6 @@ public class BaseDeviceHandler implements IDeviceHandler {
return statusBean;
}
private Barcode resolveBarcode(String barcodeStr) throws ValidateException {
Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr(barcodeStr);
if (codeBeans.isEmpty()) {
log.info("未扫描到条码");
throw new ValidateException("smfcore.error.barcode.empty", "未扫描到条码");
}
List<Barcode> allBarcode = Lists.newArrayList();
for (CodeBean codeBean : codeBeans) {
if (codeBean.getError() == null) {
Barcode barcode = codeBean.getBarcode();
if (barcode != null) {
allBarcode.add(barcode);
}
} else {
//throw new ValidateException(codeBean.getError());
}
}
int codeSize = allBarcode.size();
if (codeSize == 0) {
throw new ValidateException("smfcore.error.barcode.noValidCode", "{0}不是有效的条码", new String[]{ barcodeStr});
} else if (codeSize > 1) {
throw new ValidateException("smfcore.error.barcode.many", "找到多个有效条码,无法入库");
}
return allBarcode.get(0);
}
protected DataLog generatePutInTask(StatusBean statusBean, Barcode barcodeSave, Storage storage) throws ValidateException {
StoragePos storagePos;
DataLog putInTask = null;
......@@ -289,101 +259,23 @@ public class BaseDeviceHandler implements IDeviceHandler {
//还需要排除掉正在队列里的仓位
StoragePos storagePos = null;
// Collection<String> operatingPosIds = excludePosIds();
//客户端扫码时指定了 boxId
// if(!Strings.isNullOrEmpty(codeBoxId)){
// log.info("客户端扫码时指定入库到 Box["+codeBoxId+"]");
// int inBoxId = Integer.valueOf(codeBoxId);
// if(statusBean.isBoxCanPutIn(inBoxId)){
// ArrayList<Integer> boxIds = Lists.newArrayList();
// boxIds.add(inBoxId);
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode , operatingPosIds);
// }else{
// //throw new ValidateException(storage.getName() + "的 BOX-"+codeBoxId+" 不可用");
//
// String statusStr = "";
// for (BoxStatusBean boxStatusBean : statusBean.getBoxStatus().values()) {
// //可正常使用,且未在出库执行中
// int bid = boxStatusBean.getBoxId();
// statusStr = statusStr + bid + "=" + boxStatusBean.getStatus();
// }
// log.info(barcode.getBarcode() + "入库失败,料仓不可用,当前状态:" + statusStr);
// throw new ValidateException("error.storage.unavailable",new String[]{storageCid+"-"+codeBoxId},storage.getName() + "的 BOX-"+codeBoxId+" 不可用");
// }
// }else{
// Set<Integer> checkOutBoxIds = getExcutingBoxIds(storageCid,StorageConstants.OP.CHECKOUT);
//
// List<Integer> idleBoxIds = new ArrayList<>();
// for (Integer idleBoxId : statusBean.allIdleBoxIds()){
// if(!checkOutBoxIds.contains(idleBoxId) && storage.isBoxEnable(idleBoxId)){//正在出库的 BOX 是不能分配入库的(被限制的 box 也不可分配入库)
// idleBoxIds.add(idleBoxId);
// }
// }
// if (!idleBoxIds.isEmpty()) {
// log.info("从"+storage.getName()+" 中为"+barcode.getBarcode()+"寻找空的仓位");
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
// }
//是否有出库任务
// if (storage.isSmdDuo() || storage.isBatchStorage()) {
// //DUO料仓和MIMO客户端缓存出库任务,入库优先
// log.info("从" + storage.getName() + " 中为" + barcode.getBarcode() + "寻找空的仓位");
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
// } else {
// boolean hasOutTask = hasExecutingTask(storageCid, OP.CHECKOUT);
// if (!hasOutTask) {
// log.info("从" + storage.getName() + " 中为" + barcode.getBarcode() + "寻找空的仓位");
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
// } else {
// log.info("料仓" + storageCid + "有出库任务未完成,不允许入库");
// }
// }
// boolean hasOutTask = hasExecutingTask(storageCid,StorageConstants.OP.CHECKOUT);
//
// if (!hasOutTask) {
// log.info("从"+storage.getName()+" 中为"+barcode.getBarcode()+"寻找空的仓位");
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
// }else{
//
// }
//没有空闲的 BOX或者查找到的仓位与料盘的尺寸不是最匹配的,查找所有可以入库的 BOX,
// if (storagePos == null || storagePos.getW() != barcode.getPlateSize() || storagePos.getH() != barcode.getHeight()) {
// List<Integer> canPutInBoxIds = new ArrayList<>();
// for (Integer canPutInBoxId : statusBean.allCanPutInBoxIds()){
// if(!checkOutBoxIds.contains(canPutInBoxId) && storage.isBoxEnable(canPutInBoxId)){//正在出库的 BOX 是不能分配入库的(被限制的 box 也不可分配入库)
// canPutInBoxIds.add(canPutInBoxId);
// }
// }
// if (canPutInBoxIds.isEmpty()) {
// //无可用Box
// //throw new ValidateException(storage.getName() + "无可用的 BOX");
// throw new ValidateException("error.storage.unavailable",new String[]{storageCid});
// }
// int availbleBoxCount = canPutInBoxIds.size();
// if(availbleBoxCount > 1){//多于一个随机才有意义
// //先再随机一次,如果找不到合适的就使用所有可以入库的 BOX
// int randomIndex = RandomUtils.nextInt(availbleBoxCount);
// Integer boxId = canPutInBoxIds.get(randomIndex);
// log.info("从"+storage.getName()+"随机到BOX["+boxId+"]为"+barcode.getBarcode()+"寻找空的仓位");
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
// }
//
// if(storagePos == null){
// log.info("从"+storage.getName()+"中为"+barcode.getBarcode()+"寻找空的仓位");
// storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
// }
//
// }
// }
Collection<String> operatingPosIds =taskService.excludePosIds();
// 是否有出库任务
if (storage.isSmdDuo() || storage.isBatchStorage()) {
//DUO料仓和MIMO客户端缓存出库任务,入库优先
log.info("从" + storage.getName() + " 中为" + barcode.getBarcode() + "寻找空的仓位");
storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
} else {
boolean hasOutTask = taskService.hasExecutingTask(storageCid, OP.CHECKOUT);
if (!hasOutTask) {
log.info("从" + storage.getName() + " 中为" + barcode.getBarcode() + "寻找空的仓位");
storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
} else {
log.info("料仓" + storageCid + "有出库任务未完成,不允许入库");
}
}
if (storagePos == null) {
// String boxIdStr = "";
// if(Strings.isNullOrEmpty(codeBoxId)){
// boxIdStr = "BOX-"+codeBoxId;
// }
throw new ValidateException("error.storage.noPos", storage.getName() + "的料格[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]已满,无法继续放入", new String[]{barcode.getPlateSize() + "x" + barcode.getHeight()});
}
log.info("[" + barcode.getBarcode() + "]寻找到" + storage.getName() + "的空仓位[" + storagePos.getPosName() + "]");
......
......@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.device.enums.BOX_STATUS;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
......@@ -30,7 +31,33 @@ public class MimoBoxHandler extends BaseDeviceHandler {
public MimoBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
String cid = statusBean.getCid();
Storage storage = dataCache.getStorage(cid);
if (storage == null) {
log.error("料仓cid: [" + cid + "]不存在");
return null;
}
handleMsg(statusBean);
statusBean = saveAlarmAndHumidity(statusBean);
statusBean = handleInOutFinished(statusBean);
StatusBean humidityResult = handleHumidity(statusBean);
if (humidityResult != null) {
return humidityResult;
}
if (statusBean.getOp() == OP.PUT_IN) {
log.debug("入库:" + statusBean.toString());
statusBean = putInLine(storage, statusBean);
} else {
//查看是否有要出库的操作
statusBean =taskService.checkOut(storage, statusBean);
}
return statusBean;
}
@Override
public DeviceType getDeviceType() {
return DeviceType.BATCH;
......
package com.neotel.smfcore.core.storage.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.storage.bean.InventoryItem;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import java.util.Collection;
......@@ -28,4 +31,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
void removePosByStorageId(String storageId);
void deletePoss(Set<String> ids);
StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds) throws ValidateException ;
}
......@@ -6,10 +6,13 @@ import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.storage.bean.InventoryItem;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.enums.COMPATIBLE_TYPE;
import com.neotel.smfcore.core.storage.service.dao.IStoragePosDao;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -273,4 +276,42 @@ public class StoragePosManagerImpl implements IStoragePosManager {
log.info("手动删除库位:"+delPosName+" 完成 ");
storagePosDao.removeByQuery(query);
}
@Override
public StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds) throws ValidateException{
return getEmptyPos(storage,barcode, excludePosIds,true);
}
private StoragePos getEmptyPos(Storage storage, Barcode barcode, Collection<String> excludePosIds, boolean warmPos) throws ValidateException {
Criteria c = Criteria.where("storageId").is(storage.getId());
COMPATIBLE_TYPE compatibleType = storage.getCompatibleType();
if(compatibleType == COMPATIBLE_TYPE.EXACT_MATCH){//完全匹配
c = c.and("w").is(barcode.getPlateSize()).and("h").is(barcode.getHeight());
}else if(compatibleType == COMPATIBLE_TYPE.FULLY_COMPATIBLE){//完全兼容
c = c.and("w").gte(barcode.getPlateSize()).and("h").gte(barcode.getHeight());//宽度大于等于料盘宽度,高度大于等于料盘高度
}else if(compatibleType == COMPATIBLE_TYPE.SIZE_COMPATIBLE){//同尺寸兼容
c = c.and("w").is(barcode.getPlateSize()).and("h").gte(barcode.getHeight());//宽度等于料盘宽度,高度大于等于料盘高度
}
c = c.and("enabled").is(true)//可用
.and("used").is(false);//未使用
if(storage.isSolderPaste()){
if(warmPos){
c = c.and("warmPos").is(true);//回温库位
}else{
c = c.and("warmPos").ne(true);//不是回温库位
}
}
//去除的仓位
if(excludePosIds != null && !excludePosIds.isEmpty()){
c = c.and("id").nin(excludePosIds);
}
Query query = new Query(c);
//优先放入最合适的位置(根据尺寸),相同尺寸按优先级排序
query.with(Sort.by(Sort.Direction.ASC, "w").and(Sort.by(Sort.Direction.ASC, "h")).and(Sort.by(Sort.Direction.DESC, "priority")));
StoragePos pos = storagePosDao.findOne(query);
return pos;
}
}
......@@ -258,7 +258,7 @@ public class TaskService {
*
* @return
*/
private boolean hasExecutingTask(String cid, int type) {
public boolean hasExecutingTask(String cid, int type) {
for (DataLog task : taskMap.values()) {
if (type == task.getType() && task.getCid().equals(cid)) {
return true;
......@@ -380,4 +380,22 @@ public class TaskService {
return statusBean;
}
/**
* 已分配的库位号
* @return
*/
public Collection<String> excludePosIds() {
//排除掉正在执行的仓位
Collection<DataLog> allTasks = taskMap.values();
Collection<String> operatingPosIds = new HashSet<>();
for (DataLog task : allTasks) {
String posId = task.getPosId();
if (!Strings.isNullOrEmpty(posId)) {
operatingPosIds.add(task.getPosId());
}
}
return operatingPosIds;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!