Commit 48dd6f0e LN

1053:看板任务列表修改。第三方料仓入库完成时根据容量更新库位号。

1 个父辈 9f602532
......@@ -160,7 +160,7 @@ public class BoxStatusBean {
if (ObjectUtil.isNotEmpty(ar)) {
String[] ar2 = ar.split("=");
if (ar2.length == 2) {
caMap.put(ar2[0].toUpperCase(), Integer.valueOf(ar2[1]));
caMap.put(ar2[0].toLowerCase(), Integer.valueOf(ar2[1]));
}
}
}
......
......@@ -11,6 +11,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.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.storage.bean.UsageItem;
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;
......@@ -217,16 +218,69 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
}
return statusBean;
}
//比较料仓容量,若不一样时返回一个新库位号
protected StoragePos UsePosProcess(DataLog task,Map<String,Integer> posCapMap) {
try {
if (task == null || (!task.isCheckOutTask())||posCapMap==null||posCapMap.size()<=0) {
return null;
}
Storage storage = dataCache.getStorage(task.getCid());
if (storage == null) {
log.error("入库任务完成时库存比对:未找到料仓:" + task.getCid());
}
protected void thirdBoxFinishedPutIn(String cid, Map<String,Integer> posCapMap,String posName,String barcode,int executeTime) throws ValidateException {
DataLog task = taskService.findExecutingTask(cid, posName, barcode);
String sizeStr = task.getW() + "x" + task.getH();
UsageItem item = storage.getUsageMap().getOrDefault(sizeStr, new UsageItem());
int updateCount = posCapMap.getOrDefault(sizeStr, 0);
int currCount = item.getTotalCount() - item.getUsedCount();
if (currCount - 1 == updateCount) {
log.info("入库任务完成时库存比对:料仓[" + storage.getCid() + "]尺寸[" + sizeStr + "]当前库存[" + currCount + "]上传库存[" + updateCount + "],不更改库位号");
//完全相等,不处理
return null;
} else if (currCount > updateCount) {
log.error("入库任务完成时库存比对:料仓[" + storage.getCid() + "]尺寸[" + sizeStr + "]当前库存[" + currCount + "]上传库存[" + updateCount + "],不更改库位号");
return null;
}
if (task != null && task.isPutInTask()) {
//查找实时库存小于当前库存的尺寸
Map<String, UsageItem> currUseMap = storage.getUsageMap();
for (String key :
currUseMap.keySet()) {
item = currUseMap.get(key);
int sizeCount = posCapMap.getOrDefault(key, 0);
int sizeEmptyCount = item.getTotalCount() - item.getUsedCount();
if (sizeEmptyCount > sizeCount) {
Collection<String> operatingPosIds = taskService.excludePosIds();
//使用此尺寸的库位
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, item.getW(), item.getH(), operatingPosIds);
if (pos == null) {
//对比容量,更新库位号
log.info("入库任务完成时库存比对:料仓[" + storage.getCid() + "]新尺寸[" + key + "]当前库存[" + sizeEmptyCount + "]上传库存[" + sizeCount + "],尝试查找空库位失败");
} else {
log.info("入库任务完成时库存比对:料仓[" + storage.getCid() + "]新尺寸[" + key + "]当前库存[" + sizeEmptyCount + "]上传库存[" + sizeCount + "],查找到新库位[" + pos.getPosName() + "],更改任务为新库位");
return pos;
}
}
}
} catch (Exception ex) {
log.error("入库任务完成时库存比对:料仓[" + task.getCid() + "]id[" + task.getId() + "]条码[" + task.getBarcode() + "]库位号[" + task.getPosName() + "]出错:" + ex.getMessage());
}
return null;
}
protected void thirdBoxFinishedPutIn(String cid, Map<String,Integer> posCapMap,String posName,String barcode,int executeTime) throws ValidateException {
DataLog task = taskService.findExecutingTask(cid, posName, barcode);
if (task != null && task.isPutInTask()) {
//对比容量,更新库位号
StoragePos newPos=UsePosProcess(task,posCapMap);
if(newPos!=null){
log.error(cid + "入仓位[" + posName + "]ReelId[" + barcode + "] 更改库位号为["+newPos.getPosName()+"]");
task.setPosName(newPos.getPosName());
}
if (executeTime > 0) {
task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime);
......@@ -245,6 +299,14 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
task = taskService.findFinishedPutInTask(cid, posName, barcode);
if (task != null && task.isPutInTask()) {
if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
//对比容量,更新库位号
StoragePos newPos=UsePosProcess(task,posCapMap);
if(newPos!=null){
log.error(cid + "入仓位[" + posName + "]ReelId[" + barcode + "]完成,但任务已被取消, 更改库位号为["+newPos.getPosName()+"]");
task.setPosName(newPos.getPosName());
}
if (executeTime > 0) {
task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime);
......
......@@ -162,15 +162,14 @@ public class BoxKanbanController {
}
}
boolean statusOk = false;
Date lastUpdateTime = new Date((new Date().getTime()) - 10 * 60 * 1000);
//正常
if (criteria.getTaskStatus() == 1) {
if (lastUpdateTime.before(datalog.getUpdateDate()) && datalog.getStatus().equals(OP_STATUS.EXECUTING.name())) {
if(datalog.isNormal()){
statusOk = true;
}
}//异常
else if (criteria.getTaskStatus() == 2) {
if (lastUpdateTime.after(datalog.getUpdateDate()) && datalog.getStatus().equals(OP_STATUS.EXECUTING.name())) {
if(datalog.isAbnormal()){
statusOk = true;
}
}//等待
......
......@@ -45,6 +45,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds, String lastPosId) throws ValidateException;
StoragePos getEmptyPosByStorage(Storage storage, int size, int height, Collection<String> excludePosIds) throws ValidateException;
List<StoragePos> findNotEmpty();
List<StoragePos> findByStorage(String storageId);
......
......@@ -421,10 +421,50 @@ public class StoragePosManagerImpl implements IStoragePosManager {
StoragePos pos = storagePosDao.findOne(query);
if ((!ObjectUtil.isNotEmpty(msg) )&& (pos != null)) {
Point targetP = PointUtil.getPosPoint(lastPosId, false);
log.info(msg + "结果:[" + pos.getPosName() + "][" + targetP.getX() + "," + targetP.getY() + "]");
log.debug(msg + "结果:[" + pos.getPosName() + "][" + targetP.getX() + "," + targetP.getY() + "]");
}
return pos;
}
@Override
public StoragePos getEmptyPosByStorage(Storage storage, int size,int height, Collection<String> excludePosIds ) 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(size).and("h").is(height);
} else if (compatibleType == COMPATIBLE_TYPE.FULLY_COMPATIBLE) {//同厚度兼容
c = c.and("w").gte(size).and("h").gte(height);//除7寸外,完全兼容
} else if (compatibleType == COMPATIBLE_TYPE.SIZE_COMPATIBLE) {//同尺寸兼容
c = c.and("w").is(size).and("h").gte(height);//宽度等于料盘宽度,高度大于等于料盘高度
}
c = c.and("enabled").is(true)//可用
.and("used").is(false);//未使用
//去除的仓位
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c = c.and("id").nin(excludePosIds);
}
Query query = new Query(c);
String msg = "";
// if (lastPosId == null || lastPosId.equals("")) {
//优先放入最合适的位置(根据尺寸),相同尺寸按优先级排序
query.with(Sort.by(Sort.Direction.ASC, "w").and(Sort.by(Sort.Direction.ASC, "h")).and(Sort.by(Sort.Direction.DESC, "priority")));
// } else {
// Point point = PointUtil.getPosPoint(lastPosId, false);
// query.addCriteria(Criteria.where("coordinate").nearSphere(point));
// msg += "getEmptyPosByStorage 根据就近坐标查询[" + lastPosId + "][" + point.getX() + "," + point.getY() + "]";
// }
StoragePos pos = storagePosDao.findOne(query);
return pos;
}
@Override
public List<StoragePos> findNotEmpty(){
return findNotEmptyByStorageId(null);
......
......@@ -417,11 +417,22 @@ public class DataLog extends BasePo implements Serializable {
* 判断任务是否异常,执行中,且10分钟未更新的认为异常
*/
public boolean isAbnormal(){
if(isExecuting() ){
if(isExecuting() ||isInLine()||isInRobot()||isBoxdoor() ){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 10 * 60 * 1000){
return true;
}
}
return false;
}
/**
* 是否正常执行中,执行中,且10分钟内有更新
*/
public boolean isNormal(){
if(isExecuting() ||isInLine()||isInRobot()||isBoxdoor() ){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() <= 10 * 60 * 1000){
return true;
}
}
return false;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!