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 ));
Menu menuShelf = new Menu(new ArrayList<Menu>(), 1, "menu:list", "料架分组", 1, "lightGroup", "neolight/lightGroup/index", "", 0, "list");
menus.addAll(createMenus(menuShelf));
//出库:工单,查找出库
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 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 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 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");
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 menubarcode = new Menu(new ArrayList<Menu>(), 1, "barcode:list", "条形码", 1, "barcode", "barcode/barcode/index", "", 0, "chart");
menus.addAll(createMenus( pMenuWl,menucom,menubarcode));
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));
//日志管理:物料日志
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));
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));
//用户管理:用户管理,角色管理
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");
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;
......
......@@ -5,12 +5,15 @@ import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
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.device.handler.impl.BaseDeviceHandler;
......@@ -25,6 +28,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 锡膏料仓
......@@ -269,4 +273,190 @@ public class SpBoxHandler extends BaseDeviceHandler {
public DeviceType getDeviceType() {
return DeviceType.SOLDERPASTE;
}
protected StatusBean handleInOutFinished(StatusBean statusBean) {
Map<String, BoxStatusBean> statusOfBoxes = statusBean.getBoxStatus();
if (statusOfBoxes != null) {
for (BoxStatusBean boxStatus : statusOfBoxes.values()) {
try {
//出库入库完成处理
int status = boxStatus.getStatus();
String posName = boxStatus.getPosId();
if (!Strings.isNullOrEmpty(posName)) {//客户端发一次完成之后,会发空的 posName,不需要处理
if (BOX_STATUS.IN_FINISHED == status) {//入仓完成
finishedPutIn(statusBean.getCid(),posName);
} else if (BOX_STATUS.IN_FAILED == status) {//入库失败
//暂不处理
} else if (BOX_STATUS.OUT_FINISHED == status) {//出仓完成
finishedOutPos(statusBean.getCid(),posName);
} else if (BOX_STATUS.OUT_END == status) {//出库完成(放到仓门口
//暂不处理
}
else if (BOX_STATUS.REWARM_TAKING_END == status) {
//回温取料完成, 将库位清空
DataLog takingTask = taskService.findExecutingTask(statusBean.getCid(), boxStatus.getPosId());
if (takingTask == null) {
//从已完成列表中找,如果还找不到就忽略
takingTask = taskService.findFinishedTask(statusBean.getCid(), boxStatus.getPosId());
}
if (takingTask != null) {
if (takingTask.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
log.warn(statusBean.getCid() + "回温取料[" + boxStatus.getPosId() + "]完成时任务不存在");
}
DataLog puttingTask = null;
List<DataLog> allTasks=taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.getCid().equals(statusBean.getCid())) {
if (dataLog.getBarcode().equals(takingTask.getBarcode())) {
if (dataLog.isRewarmPuttingTask()) {
puttingTask = dataLog;
}
}
}
}
rewarmTakingEnd(takingTask);
if (puttingTask != null) {
puttingTask.setStatus(OP_STATUS.EXECUTING.name());
//dataLog.setSourceType();
// dataLogDao.save(puttingTask);
// taskMap.put(puttingTask.getId(), puttingTask);
taskService.addTaskToExecute(puttingTask);;
statusBean.addData("secondPosId", puttingTask.getPosName());
}
} else {
log.warn(statusBean.getCid() + "出仓位[" + boxStatus.getPosId() + "]完成时任务不存在");
}
} else if (BOX_STATUS.REWARM_PUTTING_END == status) {
//回温放料结束
DataLog puttingTask =taskService.findExecutingTask(statusBean.getCid(), boxStatus.getPosId());
if (puttingTask == null) {
//从已完成列表中找,如果还找不到就忽略
puttingTask = taskService.findFinishedTask(statusBean.getCid(), boxStatus.getPosId());
}
if (puttingTask != null) {
if (puttingTask.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
log.warn(statusBean.getCid() + "回温取料[" + boxStatus.getPosId() + "]完成时任务不存在");
}
}
rewarmPuttingEnd(puttingTask);
} else if (BOX_STATUS.MIX_TAKING == status) {
//搅拌取料
} else if (BOX_STATUS.WAIT_MIX == status) {
//搅拌取料结束,等待搅拌
} else if (BOX_STATUS.MIXING == status) {
//搅拌中
changeSolderStatus(boxStatus.getPosId(), BOX_STATUS.MIXING);
} else if (BOX_STATUS.MIX_PUTTING == status) {
//搅拌完成
} else if (BOX_STATUS.MIX_END == status) {
//搅拌放回原位完成
DataLog mixTask = taskService.findExecutingTask(statusBean.getCid(), boxStatus.getPosId());
mixEnd(mixTask);
}
}
} catch (ValidateException e) {
log.error("更新状态时出错" + e.getMessage());
}
}
}
return statusBean;
}
private void rewarmPuttingEnd(DataLog puttingTask) throws ValidateException {
//从队列里面移除操作
taskService.removeQueueTask(puttingTask);
StoragePos storagePos = storagePosManager.get(puttingTask.getPosId());
if (storagePos.getBarcode() != null) {
log.warn("任务:" + puttingTask.getId() + " 仓位:" + puttingTask.getPosId() + " 已有物料[" + storagePos.getBarcode().getBarcode() + "], 之前可能处理过直接返回");
return;
}
//二维码状态
Barcode barcode = barcodeManager.findByBarcode(puttingTask.getBarcode());
barcode.setPosName(puttingTask.getPosName());
barcode.setStartWarmTime(System.currentTimeMillis());
barcode.setSolderStatus(SOLDER_STATUS.REWARMING);
barcodeManager.save(barcode);
/**
* 仓位状态
*/
storagePos.setBarcode(barcode);
storagePos.setUsed(true);
storagePosManager.save(storagePos);
//更新缓存中的库存信息
dataCache.updateInventory(storagePos, barcode);
//记录日志,完成 task
puttingTask.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(puttingTask);
// dataLogDao.save(puttingTask);
// theFinishedTaskMap.put(puttingTask.getId(), puttingTask);
}
/**
* 锡膏回温完成处理
*/
private void rewarmTakingEnd(DataLog task) throws ValidateException {
//从队列里面移除操作
taskService.removeQueueTask(task);
StoragePos storagePos = storagePosManager.get(task.getPosId());
Barcode barcode = storagePos.getBarcode();
if (barcode == null) {
log.warn("任务:" + task.getId() + " 仓位:" + task.getPosId() + " 的 Barcode 为null, 之前可能处理过直接返回");
return;
}
storagePos.setBarcode(null);
storagePos.setUsed(false);
storagePosManager.save(storagePos);
log.info("回温取料完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]");
//更新缓存中的库存信息
dataCache.updateInventory(storagePos, barcode);
//记录日志
task.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(task);
// dataLogDao.save(task);
// theFinishedTaskMap.put(task.getId(), task);
}
private void changeSolderStatus(String posId, int solderStatus) throws ValidateException {
StoragePos storagePos = storagePosManager.get(posId);
if (storagePos == null) {
log.error("更改状态为[" + solderStatus + "]时,未找到库位[" + posId + "]");
return;
}
Barcode barcode = storagePos.getBarcode();
if (barcode != null && barcode.getSolderStatus() != solderStatus) {
barcode.setSolderStatus(solderStatus);
barcode = barcodeManager.save(barcode);
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
}
private void mixEnd(DataLog mixTask) throws ValidateException {
if (mixTask != null) {
log.info(mixTask.getBarcode() + "搅拌完成,送回原库位,更改状态为待出库");
taskService.removeQueueTask(mixTask);
mixTask.setStatus(OP_STATUS.FINISHED.name());
// dataLogDao.save(mixTask);
taskService.updateFinishedTask(mixTask);
// theFinishedTaskMap.put(mixTask.getId(), mixTask);
changeSolderStatus(mixTask.getPosId(), SOLDER_STATUS.TO_BE_OUT);
} else {
log.error("搅拌完成时,未找到任务");
}
}
}
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!