Commit 1f484b4b LN

增加普通料架类型NL,及扫码入库处理

1 个父辈 e48b9be2
......@@ -33,7 +33,7 @@ public class ResultBean<T> {
result.setMsg(MessageUtils.getText(msgKey, params, new Locale(SecurityUtils.getCurrentUserLanguage()), msg));
if (writeLog) {
log.info(msg);
log.info(result.getMsg());
}
return result;
}
......
package com.neotel.smfcore.core.device.bean;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
public class NLShelfOperateBean {
private String sessionId;
private long updateTime;
/**
* 当前操作库位信息
*/
private StoragePos opPos;
/**
* 需要关灯的库位
*/
private StoragePos posToClose;
/**
* 下一个库位的Id,用于自动推荐库位
*/
private String nextPosId;
public StoragePos getOpPos() {
return opPos;
}
public void setOpPos(StoragePos opPos) {
updateOpTime();
this.opPos = opPos;
}
public StoragePos getPosToClose() {
return posToClose;
}
public void setPosToClose(StoragePos posToClose) {
updateOpTime();
this.posToClose = posToClose;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
updateOpTime();
this.sessionId = sessionId;
}
public long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(long updateTime) {
this.updateTime = updateTime;
}
private void updateOpTime(){
setUpdateTime(System.currentTimeMillis());
}
public String getNextPosId() {
return nextPosId;
}
public void setNextPosId(String nextPosId) {
this.nextPosId = nextPosId;
}
/**
* 1个小时没有任何操作,即认为超时
*/
public boolean timeOut(){
if(updateTime > 0){
return System.currentTimeMillis() - updateTime > 1 * 60 * 60 * 1000;
}
return false;
}
}
......@@ -100,7 +100,12 @@ public enum DeviceType {
SMD_XLR("storage.type.smdXlr"),
/**
* 15 (默认料仓)
* 16 智能料架/亮灯料架/普通料架 NL
*/
NL("storage.type.nl"),
/**
* 17 (默认料仓)
*/
DEFAULT("storage.type.default")
;
......
......@@ -199,8 +199,13 @@ public class MaterialController {
if (posIds == null || posIds.size() <= 0) {
throw new ValidateException("smfcode.valueCanotNull", "{0}不能为空", new String[]{"ID"});
}
String labelName="";
if (ObjectUtil.isEmpty(labelId)) {
labelId = "";
}else
{
Label label=labelManager.get(labelId);
labelName=label.getLabelName();
}
String[] array = posIds.toArray(new String[posIds.size()]);
storagePosManager.updatePosLabel(array, labelId);
......@@ -231,7 +236,7 @@ public class MaterialController {
return ResultBean.newOkResult("smfcode.manualOut.ok", "手动出库成功", code);
} catch (Exception e) {
return ResultBean.newOkResult("smfcore.error", "出错{0}", new String[]{e.getMessage()}, code);
return ResultBean.newErrorResult(1,"smfcore.error", "出错{0}", new String[]{e.getMessage()}, true);
}
} else {
throw new ValidateException("smfcode.manualOut.notFound", "仓库中未找到料盘信息");
......
......@@ -53,4 +53,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
void updatePosLabel(String[] posIds, String labelId);
void clearLockPos(String lockId);
StoragePos autoFindNextEmptyPos(Storage storage, Collection<String> excludePosIds,StoragePos currentPos);
}
......@@ -407,4 +407,38 @@ public class StoragePosManagerImpl implements IStoragePosManager {
storagePosDao.updateMulti(query, Update.update("barcode.lockId",""));
}
@Override
public StoragePos autoFindNextEmptyPos(Storage storage, Collection<String> excludePosIds,StoragePos currentPos) {
Criteria c = Criteria.where("storageId").is(storage.getId());
// c.and("priority").lt(currentPos.getPriority());
COMPATIBLE_TYPE compatibleType = storage.getCompatibleType();
if (compatibleType == COMPATIBLE_TYPE.EXACT_MATCH) {//完全匹配
c = c.and("w").is(currentPos.getW()).and("h").is(currentPos.getH());
} else if (compatibleType == COMPATIBLE_TYPE.FULLY_COMPATIBLE) {//同厚度兼容
c = c.and("w").gte(currentPos.getW()).and("h").gte(currentPos.getH());//除7寸外,完全兼容
} else if (compatibleType == COMPATIBLE_TYPE.SIZE_COMPATIBLE) {//同尺寸兼容
c = c.and("w").is(currentPos.getW()).and("h").gte(currentPos.getH());//宽度等于料盘宽度,高度大于等于料盘高度
}
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")));
StoragePos pos = storagePosDao.findOne(query);
return pos;
}
}
......@@ -120,7 +120,12 @@ public class Storage extends BasePo implements Serializable {
public boolean isCodeShelf() {
return DeviceType.CODESHELF.name().equals(type);
}
/**
* 是否是普通料架
*/
public boolean isNLShelf() {
return DeviceType.NL.name().equals(type);
}
/**
* 是否是垂直货柜
*/
......
......@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by sunke on 2021/8/4.
......@@ -56,6 +57,9 @@ public class DevicesStatusUtil {
}
/**
* 主要用来存储感应料架库位报警信息
*/
private static Map<String, List<List<String>>> deviceDataMap = Maps.newConcurrentMap();
public static void updateDeviceData(String cid, List<List<String>> data) {
......@@ -66,4 +70,55 @@ public class DevicesStatusUtil {
return deviceDataMap.get(cid);
}
/**
*存储料仓 出入库的一些操作,KEY=cid
*/
private static Map<String,Map<String, String>> storageOpMap = new ConcurrentHashMap<>();
/**
* 添加操作
* @param cid
* @param opKey
* @param opValue
*/
public static void addOp(String cid, String opKey, String opValue){
if(opValue == null){
return;
}
Map<String, String> opMap = storageOpMap.get(cid);
if(opMap == null){
opMap = new ConcurrentHashMap<>();
}
opMap.put(opKey, opValue);
storageOpMap.put(cid, opMap);
}
/**
* 追加操作
* @param cid
* @param opKey
* @param opValue
*/
public static void appendOp(String cid, String opKey, String opValue){
Map<String, String> opMap = storageOpMap.get(cid);
if(opMap == null){
opMap = new ConcurrentHashMap<>();
}
String value = opMap.get(opKey);
if(value != null){
value = value + "|" + opValue;
}else{
value = opValue;
}
opMap.put(opKey, value);
storageOpMap.put(cid, opMap);
}
public static Map<String,String> getAndRemoveOp(String cid){
Map<String, String> opMap = storageOpMap.get(cid);
opMap.remove(cid);
return opMap;
}
}
......@@ -783,7 +783,7 @@ public class TaskService {
task.setPartNumber(barcode.getPartNumber());
task.setBarcode(barcode.getBarcode());
task.setNum(barcode.getInitialAmount());
task.setNum(barcode.getAmount());
dataCache.updateInventory(pos, barcode);
//dataCache.updateStorage(task.getCid());
......
......@@ -184,7 +184,7 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
String groupId = requestCommand.getGroupId();
if(respCommand.isOkResp()){
ResultBean okResult = ResultBean.newOkResult("smfcore.loadMaterialFinished","loading material is finished: {0}" ,new String[]{messageText});
ResultBean okResult = ResultBean.newOkResult("smfcore.loadMaterialFinished","loading material is finished: {0}" ,new String[]{messageText},"");
WebSocketServer.sendGroupMsg(groupId,new SocketMsg(okResult.getMsg(), MsgType.INFO));
}else{
ResultBean ngResult = ResultBean.newErrorResult(Integer.valueOf(returnCode),"smfcore.loadMaterialFailed","loading material failed:{0}",new String[]{messageText} );
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!