Commit e27b628a zshaohui

1.任务取消,解绑库位

2.页面更新优化
1 个父辈 d412ab90
package com.neotel.smfcore.common.bean; package com.neotel.smfcore.common.bean;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data; import lombok.Data;
@Data @Data
public class ReelLockPosInfo { public class ReelLockPosInfo extends BasePo {
/** /**
* 条码信息 * 条码信息
*/ */
......
...@@ -134,4 +134,8 @@ public class ReelLockPosUtil { ...@@ -134,4 +134,8 @@ public class ReelLockPosUtil {
} }
return lockPosIds; return lockPosIds;
} }
public static Collection<ReelLockPosInfo> getAllReelLockPosInfo(){
return reelLocKPosMap.values();
}
} }
...@@ -31,6 +31,10 @@ public enum OP_STATUS { ...@@ -31,6 +31,10 @@ public enum OP_STATUS {
*/ */
CANCEL, CANCEL,
/** /**
* 出库完成,放在缓存区
*/
OUT_BOX,
/**
* 已结束 * 已结束
*/ */
END END
......
...@@ -413,7 +413,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -413,7 +413,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
} else if (BOX_STATUS.IN_FAILED == status) {//入库失败 } else if (BOX_STATUS.IN_FAILED == status) {//入库失败
//暂不处理 //暂不处理
} else if (BOX_STATUS.OUT_FINISHED == status) {//出仓完成 } else if (BOX_STATUS.OUT_FINISHED == status) {//出仓完成
finishedOutPos(statusBean.getCid(),posName,executeTime); finishedOutPos(statusBean.getCid(),posName,executeTime,OP_STATUS.FINISHED);
} else if (BOX_STATUS.OUT_END == status) {//出库完成(放到仓门口 } else if (BOX_STATUS.OUT_END == status) {//出库完成(放到仓门口
//暂不处理 //暂不处理
} }
...@@ -537,7 +537,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -537,7 +537,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected void finishedOutPos(String cid, String posName) throws ValidateException { protected void finishedOutPos(String cid, String posName) throws ValidateException {
finishedOutPos(cid,posName,-1); finishedOutPos(cid,posName,-1,OP_STATUS.FINISHED);
} }
/** /**
* 出仓位完成处理 * 出仓位完成处理
...@@ -546,9 +546,15 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -546,9 +546,15 @@ public class BaseDeviceHandler implements IDeviceHandler {
* @param executeTime 执行时间 * @param executeTime 执行时间
* @throws ValidateException * @throws ValidateException
*/ */
protected void finishedOutPos(String cid, String posName,int executeTime) throws ValidateException { protected void finishedOutPos(String cid, String posName,int executeTime,OP_STATUS outBoxStatus) throws ValidateException {
DataLog task = taskService.findExecutingTask(cid, posName); DataLog task = taskService.findExecutingTask(cid, posName);
if (task != null && task.isCheckOutTask()) { if (task != null && task.isCheckOutTask()) {
//判断状态是否重复推送
log.info(task.getBarcode()+"状态为:"+task.getStatus()+",重新更改状态:"+outBoxStatus.name());
if (outBoxStatus.name().equals(task.getStatus())){
log.info("状态一致,不处理,返回");
return;
}
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
} }
...@@ -559,22 +565,27 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -559,22 +565,27 @@ public class BaseDeviceHandler implements IDeviceHandler {
taskService.removeFinishedTask(cancelTask); taskService.removeFinishedTask(cancelTask);
log.info("从已完成的任务列表中删除之前取消的任务:" + cancelTask.getPosName() + " ReelId:" + cancelTask.getBarcode()); log.info("从已完成的任务列表中删除之前取消的任务:" + cancelTask.getPosName() + " ReelId:" + cancelTask.getBarcode());
} }
updateCheckoutData(task); updateCheckoutData(task,outBoxStatus);
} else { } else {
//log.error(operationKey + "触发仓位完成时,操作队列中不存在"); //log.error(operationKey + "触发仓位完成时,操作队列中不存在");
//从已完成列表中找,如果还找不到就忽略 //从已完成列表中找,如果还找不到就忽略
task = taskService.findFinishedTask(cid, posName); task = taskService.findFinishedTask(cid, posName);
if (task != null && task.isCheckOutTask()) { if (task != null && task.isCheckOutTask()) {
//判断状态是否重复推送
log.info(task.getBarcode()+"状态为:"+task.getStatus()+",重新更改状态:"+outBoxStatus.name());
if (outBoxStatus.name().equals(task.getStatus())){
log.info("状态一致,不处理,返回");
return;
}
if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成 if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
} }
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒"); log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒");
updateCheckoutData(task); updateCheckoutData(task,outBoxStatus);
} }
} else { } else {
StoragePos storagePos = storagePosManager.getByPosName(posName); StoragePos storagePos = storagePosManager.getByPosName(posName);
if (storagePos != null && storagePos.isUsed()) { if (storagePos != null && storagePos.isUsed()) {
String barcode = storagePos.getBarcode().getBarcode(); String barcode = storagePos.getBarcode().getBarcode();
//查找库位是否为空,如果库位有料,调用清理手动出库的方法清理库存 //查找库位是否为空,如果库位有料,调用清理手动出库的方法清理库存
...@@ -669,7 +680,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -669,7 +680,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
/** /**
* 出仓位完成 * 出仓位完成
*/ */
private void updateCheckoutData(DataLog task) throws ValidateException { private void updateCheckoutData(DataLog task,OP_STATUS outBoxStatus) throws ValidateException {
//从队列里面移除操作 //从队列里面移除操作
taskService.removeQueueTask(task); taskService.removeQueueTask(task);
...@@ -681,7 +692,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -681,7 +692,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
log.warn("任务:" + task.getId() + " 仓位:" + task.getPosId() + " 的 Barcode 为null, 之前可能处理过,结束任务后直接返回"); log.warn("任务:" + task.getId() + " 仓位:" + task.getPosId() + " 的 Barcode 为null, 之前可能处理过,结束任务后直接返回");
//记录日志 //记录日志
task.setStatus(OP_STATUS.FINISHED.name()); task.setStatus(outBoxStatus.name());
taskService.updateFinishedTask(task); taskService.updateFinishedTask(task);
return; return;
} }
...@@ -716,7 +727,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -716,7 +727,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
// SiemensApi.lotInOut(barcode.getBarcode(),2); // SiemensApi.lotInOut(barcode.getBarcode(),2);
//记录日志 //记录日志
task.setStatus(OP_STATUS.FINISHED.name()); task.setStatus(outBoxStatus.name());
taskService.updateFinishedTask(task); taskService.updateFinishedTask(task);
} }
...@@ -804,7 +815,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -804,7 +815,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (data != null) { if (data != null) {
String humiAndtempListStr = data.get("humiAndtempList"); String humiAndtempListStr = data.get("humiAndtempList");
if (StringUtils.isNotBlank(humiAndtempListStr)) { if (StringUtils.isNotBlank(humiAndtempListStr)) {
log.info("收到温湿度信息,Cid为:" + cid + ",集合信息为:" + humiAndtempListStr); //log.info("收到温湿度信息,Cid为:" + cid + ",集合信息为:" + humiAndtempListStr);
Humiture humiture = new Humiture(); Humiture humiture = new Humiture();
humiture.setHumiAndtempListStr(humiAndtempListStr); humiture.setHumiAndtempListStr(humiAndtempListStr);
humiture.setCid(cid); humiture.setCid(cid);
...@@ -899,6 +910,15 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -899,6 +910,15 @@ public class BaseDeviceHandler implements IDeviceHandler {
return dataLogs; return dataLogs;
} }
protected void finishedOutTask(String cid, String posName){
log.info(cid +"将物料从库位["+posName+"]出库到门口/料串完成");
DataLog task = taskService.findFinishedTask(cid, posName);
if(task != null){
task.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(task);
}
}
/** /**
* 判断是否打开了亮灯指引功能 * 判断是否打开了亮灯指引功能
* @return * @return
......
...@@ -111,6 +111,18 @@ public class DeviceController { ...@@ -111,6 +111,18 @@ public class DeviceController {
@ResponseBody @ResponseBody
@AnonymousAccess @AnonymousAccess
public Map<String, Object> emptyPosForPutin(HttpServletRequest request) { public Map<String, Object> emptyPosForPutin(HttpServletRequest request) {
//判断锁定库位,是否超过1小时,如果超过,则解绑
Collection<ReelLockPosInfo> copyList = new ArrayList<>();
Collection<ReelLockPosInfo> allReelLockPosInfo = ReelLockPosUtil.getAllReelLockPosInfo();
for (ReelLockPosInfo lockPosInfo : allReelLockPosInfo) {
copyList.add(lockPosInfo);
}
for (ReelLockPosInfo lockPosInfo : copyList) {
if (System.currentTimeMillis() - lockPosInfo.getCreateDate().getTime() >= 1000 * 60 * 30) {
ReelLockPosUtil.removeReelLockPosInfo(lockPosInfo.getBarcode());
log.info(lockPosInfo.getBarcode() + "锁定时间超过1小时,解除锁定:" + lockPosInfo.getCreateDate());
}
}
String code = request.getParameter("code"); String code = request.getParameter("code");
String cids = request.getParameter("cids"); String cids = request.getParameter("cids");
String rfid = request.getParameter("rfid"); String rfid = request.getParameter("rfid");
......
package com.neotel.smfcore.core.device.util; package com.neotel.smfcore.core.device.util;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -15,6 +17,8 @@ import com.neotel.smfcore.core.barcode.service.po.Component; ...@@ -15,6 +17,8 @@ import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.inList.util.InListCache; import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import com.neotel.smfcore.core.language.service.bean.LanguageInfo; import com.neotel.smfcore.core.language.service.bean.LanguageInfo;
import com.neotel.smfcore.core.language.service.po.LanguageMsg; import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import com.neotel.smfcore.core.language.util.MessageUtils; import com.neotel.smfcore.core.language.util.MessageUtils;
...@@ -74,6 +78,9 @@ public class DataCache { ...@@ -74,6 +78,9 @@ public class DataCache {
@Autowired @Autowired
private IComponentManager componentManager; private IComponentManager componentManager;
@Autowired
private IInOutDataManager inOutDataManager;
/** /**
* 是否需要推送温湿度报警值 * 是否需要推送温湿度报警值
*/ */
...@@ -590,6 +597,7 @@ public class DataCache { ...@@ -590,6 +597,7 @@ public class DataCache {
amount = - barcode.getAmount(); amount = - barcode.getAmount();
storage.emptyOnePos(pos); storage.emptyOnePos(pos);
removeUsedPosNameList(cid, pos.getPosName()); removeUsedPosNameList(cid, pos.getPosName());
updateInOutData(cid, storage.getId(), -1);
}else{ }else{
//入库 //入库
amount = barcode.getAmount(); amount = barcode.getAmount();
...@@ -599,11 +607,44 @@ public class DataCache { ...@@ -599,11 +607,44 @@ public class DataCache {
if(ObjectUtil.isNotEmpty(storage.getInListName())){ if(ObjectUtil.isNotEmpty(storage.getInListName())){
inListCache.UpdateInList(storage.getInListName(),pos,barcode); inListCache.UpdateInList(storage.getInListName(),pos,barcode);
} }
updateInOutData(cid, storage.getId(), 1);
} }
allStorage.put(cid, storage); allStorage.put(cid, storage);
return updateInventoryAmount(cid,partNumber,amount); return updateInventoryAmount(cid,partNumber,amount);
} }
private synchronized void updateInOutData(String cid, String storageId, int amount) {
InOutData inOutData = getLastSaveInOutData(cid, storageId);
//如果amount小于0,则是出库,否则入库
if (amount < 0) {
inOutData.setOutCount(inOutData.getOutCount() + 1);
} else if (amount > 0) {
inOutData.setInCount(inOutData.getInCount() + 1);
}
inOutData.setUpdateDate(new Date());
inOutDataManager.save(inOutData);
}
private InOutData getLastSaveInOutData(String cid, String storageId) {
InOutData inOutData = inOutDataManager.findOneByCidAndStorageId(cid,storageId);
if (inOutData == null) {
inOutData = new InOutData();
} else {
Date createDate = inOutData.getCreateDate();
//判断当前是否超过1个小时
String createDateStr = DateUtil.format(createDate, "yyyy-MM-dd HH");
String currentDateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH");
long between = DateUtil.between(DateUtil.parse(createDateStr,"yyyy-MM-dd HH"), DateUtil.parse(currentDateStr,"yyyy-MM-dd HH"), DateUnit.HOUR);
if (between >= 1) {
inOutData = new InOutData();
}
}
inOutData.setCid(cid);
inOutData.setStorageId(storageId);
return inOutData;
}
private void updateStorageInventory(String cid, InventoryItem inventoryItem){ private void updateStorageInventory(String cid, InventoryItem inventoryItem){
Map<String, InventoryItem> storageInventory = inventoryMap.get(cid); Map<String, InventoryItem> storageInventory = inventoryMap.get(cid);
storageInventory.put(inventoryItem.getPartNumber(), inventoryItem); storageInventory.put(inventoryItem.getPartNumber(), inventoryItem);
......
...@@ -20,6 +20,7 @@ import com.neotel.smfcore.core.kanban.rest.bean.dto.*; ...@@ -20,6 +20,7 @@ import com.neotel.smfcore.core.kanban.rest.bean.dto.*;
import com.neotel.smfcore.core.kanban.rest.bean.mapstruct.BoxTaskMapper; import com.neotel.smfcore.core.kanban.rest.bean.mapstruct.BoxTaskMapper;
import com.neotel.smfcore.core.kanban.rest.bean.query.BoxTaskQueryCriter; import com.neotel.smfcore.core.kanban.rest.bean.query.BoxTaskQueryCriter;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; 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.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
...@@ -441,7 +442,7 @@ public class BoxKanbanController { ...@@ -441,7 +442,7 @@ public class BoxKanbanController {
int allCount = inTask + outTask; int allCount = inTask + outTask;
BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0, BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0,
"0", "0", "", allCount, inTask, outTask, "0", "0", "", allCount, inTask, outTask,
0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName(),null); 0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName(),null,0);
//获取设备状态,设置状态和当前任务信息 //获取设备状态,设置状态和当前任务信息
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid()); StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
...@@ -532,6 +533,13 @@ public class BoxKanbanController { ...@@ -532,6 +533,13 @@ public class BoxKanbanController {
} }
} }
} }
//总使用数量汇总
Map<String, UsageItem> usageMap = boxDto.getUsageMap();
if (usageMap != null){
Collection<UsageItem> usageItems = usageMap.values();
int sum = usageItems.stream().mapToInt(UsageItem::getUsedCount).sum();
boxDto.setTotalUsedCount(sum);
}
return boxDto; return boxDto;
} }
......
...@@ -84,4 +84,7 @@ public class BoxStatusDto { ...@@ -84,4 +84,7 @@ public class BoxStatusDto {
@ApiModelProperty("温湿度列表") @ApiModelProperty("温湿度列表")
private List<HumiAndtemp> humiAndtempList; private List<HumiAndtemp> humiAndtempList;
@ApiModelProperty("总使用数量")
private int totalUsedCount = 0;
} }
...@@ -139,6 +139,6 @@ public enum DeviceType { ...@@ -139,6 +139,6 @@ public enum DeviceType {
} }
public static List<DeviceType> availableTypeList(){ public static List<DeviceType> availableTypeList(){
return Lists.newArrayList(AUTO,LINE,BATCH,SOLDERPASTE,VERTICALBOX,SMD_XL,SMD_DUO,SMD_XLC,VIRTUAL,NL,NLP,NLM); return Lists.newArrayList(AUTO,LINE,BATCH,SOLDERPASTE,VERTICALBOX,SMD_XL,SMD_DUO,SMD_XLC,SMD_XLR,VIRTUAL,NL,NLP,NLM);
} }
} }
...@@ -251,6 +251,8 @@ public class TaskService { ...@@ -251,6 +251,8 @@ public class TaskService {
task.setUpdateDate(new Date()); task.setUpdateDate(new Date());
updateFinishedTask(task); updateFinishedTask(task);
log.info("任务[" + task.getId() + "] posName[" + task.getPosName() + "] Reel Id[" + task.getBarcode() + "]取消成功"); log.info("任务[" + task.getId() + "] posName[" + task.getPosName() + "] Reel Id[" + task.getBarcode() + "]取消成功");
//同时,解除锁定库位
ReelLockPosUtil.removeReelLockPosInfo(task.getBarcode());
return true; return true;
} }
return false; return false;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!