Commit ad74ca3e 孙克
2 个父辈 f90a593e ffe0c4b6
正在显示 72 个修改的文件 包含 1698 行增加227 行删除
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<description>SMF project for Spring Boot</description> <description>SMF project for Spring Boot</description>
<properties> <properties>
<maven.build.timestamp.format>M.ddHHmm</maven.build.timestamp.format> <maven.build.timestamp.format>M.ddHHmm</maven.build.timestamp.format>
<main.version>3.${maven.build.timestamp}</main.version> <main.version>4.${maven.build.timestamp}</main.version>
<app.version>${main.version}</app.version> <app.version>${main.version}</app.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<jjwt.version>0.11.1</jjwt.version> <jjwt.version>0.11.1</jjwt.version>
......
...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
...@@ -90,6 +91,15 @@ public class GlobalExceptionHandler { ...@@ -90,6 +91,15 @@ public class GlobalExceptionHandler {
return buildResponseEntity(ApiError.error(e.getStatus(),targetMsg)); return buildResponseEntity(ApiError.error(e.getStatus(),targetMsg));
} }
@ExceptionHandler(value = InternalAuthenticationServiceException.class)
public ResponseEntity<ApiError> internalAuthenticationServiceException(HttpServletRequest servlet,ValidateException e){
// String language= servlet.getLocale().getLanguage();
// 打印堆栈信息
//log.error(ThrowableUtil.getStackTrace(e));
String targetMsg=messageUtils.getText(e.getMsgKey(),e.getMsgParam(),servlet.getLocale() ,e.getDefaultMsg());
return buildResponseEntity(ApiError.error(e.getStatus(),targetMsg));
}
/** /**
* 处理所有接口数据验证异常 * 处理所有接口数据验证异常
*/ */
......
...@@ -89,7 +89,7 @@ public class DataInitManager { ...@@ -89,7 +89,7 @@ public class DataInitManager {
operator = roleManager.save(operator); operator = roleManager.save(operator);
log.info("创建默认角色:" + operator.toString()); log.info("创建默认角色:" + operator.toString());
admin = new User(userName, "admin@qq.com", "zh-CN", role.getId(), "$2a$10$Egp1/gvFlt7zhlXVfEFw4OfWQCGPw0ClmMcc6FjTnvXNRVf9zdMRa", true, true, new Date(), groupIds, ""); admin = new User(userName, "admin@neotel.tech", "zh-CN", role.getId(), "$2a$10$Egp1/gvFlt7zhlXVfEFw4OfWQCGPw0ClmMcc6FjTnvXNRVf9zdMRa", true, true, new Date(), groupIds, "");
admin = userManager.save(admin); admin = userManager.save(admin);
log.info("创建默认用户:" + admin.toString()); log.info("创建默认用户:" + admin.toString());
......
...@@ -41,7 +41,12 @@ public class MenuInit { ...@@ -41,7 +41,12 @@ public class MenuInit {
/** /**
* 锡膏料仓展示菜单 * 锡膏料仓展示菜单
*/ */
private static String SP_SHOW_MENU = "sp"; public static String SP_SHOW_MENU = "sp";
/**
* 料架展示菜单,包括nl,nlp,nlm,nls
*/
public static String NL_SHOW_MENU = "nl";
private static Map<String, Menu> allMenuMap = new HashMap<>(); private static Map<String, Menu> allMenuMap = new HashMap<>();
...@@ -115,7 +120,7 @@ public class MenuInit { ...@@ -115,7 +120,7 @@ public class MenuInit {
addDefaultFunctionMenu(-1,null,"Neo Ai","neoai","neoai/index","neoai"); addDefaultFunctionMenu(-1,null,"Neo Ai","neoai","neoai/index","neoai");
//Mimo临时看板 //Mimo看板
addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo"); addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo");
Menu boardMap = Menu.CreatePMenu("仪表盘", 0, "dashBoard", "kanban", null); Menu boardMap = Menu.CreatePMenu("仪表盘", 0, "dashBoard", "kanban", null);
...@@ -127,7 +132,7 @@ public class MenuInit { ...@@ -127,7 +132,7 @@ public class MenuInit {
addDefaultFunctionMenu(1, boardMap, "仪表盘2", "eleckanban", "eleckanban/index", "kanban"); addDefaultFunctionMenu(1, boardMap, "仪表盘2", "eleckanban", "eleckanban/index", "kanban");
//设备看板 //设备看板
addDefaultFunctionMenu(1,null,"设备看板","lockMaterial", "lockMaterial/material/index","kanban",DEFAULT_SHOW_MENU); addDefaultFunctionMenu(1,null,"设备互联","lockMaterial", "lockMaterial/material/index","kanban",DEFAULT_SHOW_MENU);
//设备互联 //设备互联
addDefaultFunctionMenu(2,null,"设备互联","equipmentView", "neolight/equipmentView/index","sKanban"); addDefaultFunctionMenu(2,null,"设备互联","equipmentView", "neolight/equipmentView/index","sKanban");
...@@ -148,13 +153,13 @@ public class MenuInit { ...@@ -148,13 +153,13 @@ public class MenuInit {
addDefaultFunctionMenu(9, poutOut, "入库单", "inList", "system/inList/index", "headIcon"); addDefaultFunctionMenu(9, poutOut, "入库单", "inList", "system/inList/index", "headIcon");
addDefaultFunctionMenu(10, poutOut, "物料入库", "putIn", "system/putIn/index", "headIcon"); addDefaultFunctionMenu(10, poutOut, "物料入库", "putIn", "system/putIn/index", "headIcon");
addDefaultFunctionMenu(11, poutOut, "转储入库", "dumpWarehousing", "system/dumpWarehousing/index", "headIcon"); // addDefaultFunctionMenu(11, poutOut, "转储入库", "dumpWarehousing", "system/dumpWarehousing/index", "headIcon");
addDefaultFunctionMenu(12, poutOut, "单盘入库", "singleDiskWarehousing", "system/singleDiskWarehousing/index", "headIcon"); // addDefaultFunctionMenu(12, poutOut, "单盘入库", "singleDiskWarehousing", "system/singleDiskWarehousing/index", "headIcon");
addDefaultFunctionMenu(13, poutOut, "呆滞物料", "sluggishMaterials", "system/sluggishMaterials/index", "sMaterial"); addDefaultFunctionMenu(13, poutOut, "呆滞物料", "sluggishMaterials", "system/sluggishMaterials/index", "sMaterial");
addDefaultFunctionMenu(14,poutOut, "安全库存", "safetyInventory", "system/safetyInventory/index", "safeInventory"); addDefaultFunctionMenu(14,poutOut, "安全库存", "safetyInventory", "system/safetyInventory/index", "safeInventory");
addDefaultFunctionMenu(15, poutOut,"过期物料", "expireMaterials", "system/expireMaterials/index", "sMaterial"); addDefaultFunctionMenu(15, poutOut,"过期物料", "expireMaterials", "system/expireMaterials/index", "sMaterial");
addDefaultFunctionMenu(16, poutOut,"生成工单", "createOrder", "system/createOrder/index", "createOrder"); addDefaultFunctionMenu(16, poutOut,"生成工单", "createOrder", "system/createOrder/index", "createOrder");
addDefaultFunctionMenu(91,poutOut, "共享文件夹", "orderSetting", "system/orderSetting/index", "sysSet"); addDefaultFunctionMenu(91,poutOut, "共享文件夹", "orderSetting", "system/orderSetting/index", "sysSet",DEFAULT_SHOW_MENU);
//MSD管理:MSD库存.MSD追溯性.MSD设置 //MSD管理:MSD库存.MSD追溯性.MSD设置
...@@ -185,7 +190,7 @@ public class MenuInit { ...@@ -185,7 +190,7 @@ public class MenuInit {
//日志管理:物料日志 //日志管理:物料日志
Menu pMenuLog = Menu.CreatePMenu("日志管理", 8, "log","log",null); Menu pMenuLog = Menu.CreatePMenu("日志管理", 8, "log","log",null);
addDefaultFunctionMenu(61, pMenuLog, "物料日志", "taskLog", "neolight/taskLog/index", "education",DEFAULT_SHOW_MENU); addDefaultFunctionMenu(61, pMenuLog, "物料日志", "taskLog", "neolight/taskLog/index", "education",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(62, pMenuLog, "消息查询", "message", "neolight/message/index", "messagefind"); addDefaultFunctionMenu(62, pMenuLog, "消息查询", "message", "neolight/message/index", "messagefind",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(63, pMenuLog, "接口异常", "interfaceException", "neolight/interfaceException/index", "messagefind"); addDefaultFunctionMenu(63, pMenuLog, "接口异常", "interfaceException", "neolight/interfaceException/index", "messagefind");
//报表:出入库、库存 //报表:出入库、库存
...@@ -193,7 +198,7 @@ public class MenuInit { ...@@ -193,7 +198,7 @@ public class MenuInit {
addDefaultFunctionMenu(70, pMenuReport, "锁定物料", "lockMaterials", "system/lockMaterials/index", "lockMaterials"); addDefaultFunctionMenu(70, pMenuReport, "锁定物料", "lockMaterials", "system/lockMaterials/index", "lockMaterials");
addDefaultFunctionMenu(71, pMenuReport, "出入库", "inOutData", "neolight/inOutData/index", "outPut"); addDefaultFunctionMenu(71, pMenuReport, "出入库", "inOutData", "neolight/inOutData/index", "outPut");
//新的出入库报表 //新的出入库报表
addDefaultFunctionMenu(71, pMenuReport, "出入库", "inOutDataCount", "neolight/inOutDataCount/index", "outPut"); addDefaultFunctionMenu(71, pMenuReport, "出入库", "inOutDataCount", "neolight/inOutDataCount/index", "outPut",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(72, pMenuReport,"库存", "inventory", "neolight/inventory/index", "inventory"); addDefaultFunctionMenu(72, pMenuReport,"库存", "inventory", "neolight/inventory/index", "inventory");
addDefaultFunctionMenu(73, pMenuReport,"温湿度", "humiture", "humiture/humitureReport/index", "humiture"); addDefaultFunctionMenu(73, pMenuReport,"温湿度", "humiture", "humiture/humitureReport/index", "humiture");
addDefaultFunctionMenu(73, pMenuReport,"温湿度", "spHumiture", "humiture/spHumitureReport/index", "humiture"); addDefaultFunctionMenu(73, pMenuReport,"温湿度", "spHumiture", "humiture/spHumitureReport/index", "humiture");
...@@ -203,7 +208,7 @@ public class MenuInit { ...@@ -203,7 +208,7 @@ public class MenuInit {
addDefaultFunctionMenu(81,guanceMenu, "物料追踪", "materialChart", "neolight/materialChart/index", "maChart"); addDefaultFunctionMenu(81,guanceMenu, "物料追踪", "materialChart", "neolight/materialChart/index", "maChart");
//物联网:共享文件夹 //物联网:共享文件夹
Menu pMenuWulian = Menu.CreatePMenu("物联网", 11, "internet", "interMenu",null); //Menu pMenuWulian = Menu.CreatePMenu("物联网", 11, "internet", "interMenu",null);
//设置:料仓管理,菜单管理 //设置:料仓管理,菜单管理
...@@ -213,10 +218,10 @@ public class MenuInit { ...@@ -213,10 +218,10 @@ public class MenuInit {
addDefaultFunctionMenu(103, poutSet, "菜单管理", "menu", "system/menu/index", "menu"); addDefaultFunctionMenu(103, poutSet, "菜单管理", "menu", "system/menu/index", "menu");
// Menu sysSetting = new Menu(, "barcode", "条码设置", "barcodeSetting", "system/barcodeSetting/index", "database"); // Menu sysSetting = new Menu(, "barcode", "条码设置", "barcodeSetting", "system/barcodeSetting/index", "database");
// Menu outSet = new Menu(, "outSetting", "出库策略", "outSetting", "system/outSetting/index", "outSet"); // Menu outSet = new Menu(, "outSetting", "出库策略", "outSetting", "system/outSetting/index", "outSet");
addDefaultFunctionMenu(104,poutSet, "系统设置", "sysSetting", "system/sysSetting/index", "sysSet"); addDefaultFunctionMenu(104,poutSet, "系统设置", "sysSetting", "system/sysSetting/index", "sysSet",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(105,poutSet, "资源翻译", "translation", "system/translation/index", "translation"); addDefaultFunctionMenu(105,poutSet, "资源翻译", "translation", "system/translation/index", "translation");
// Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet"); // Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet");
addDefaultFunctionMenu(106,poutSet, "料架设置", "shelfSetting", "system/shelfSetting/index", "translation"); addDefaultFunctionMenu(106,poutSet, "料架设置", "shelfSetting", "system/shelfSetting/index", "translation",NL_SHOW_MENU);
//用户管理:用户管理,角色管理 //用户管理:用户管理,角色管理
......
...@@ -148,26 +148,30 @@ public class HttpHelper { ...@@ -148,26 +148,30 @@ public class HttpHelper {
} }
public static String postJsonWithAuth(String url, Object params, String auth) throws ApiException { public static String postJsonWithAuth(String url, Object params, String auth) throws ApiException {
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8"); String requestBody = "";
if (auth != null && !auth.isEmpty()) {
httpPost.addHeader("Authorization", auth);
}
// 设置请求参数 // 设置请求参数
if (params != null) { if (params != null) {
try { try {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String requestBody = mapper.writeValueAsString(params); requestBody = mapper.writeValueAsString(params);
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
throw new ApiException("Request params to [" + url + "] Json failed:" + e.getMessage()); throw new ApiException("Request params to [" + url + "] Json failed:" + e.getMessage());
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request params to [" + url + "] json exception:" + e.getMessage()); throw new ApiException("Request params to [" + url + "] json exception:" + e.getMessage());
} }
} }
HttpPost httpPost = null;
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
try { try {
httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
if (auth != null && !auth.isEmpty()) {
httpPost.addHeader("Authorization", auth);
}
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost); response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
...@@ -188,6 +192,9 @@ public class HttpHelper { ...@@ -188,6 +192,9 @@ public class HttpHelper {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (httpPost != null) {
httpPost.releaseConnection();
}
} }
} }
...@@ -211,11 +218,12 @@ public class HttpHelper { ...@@ -211,11 +218,12 @@ public class HttpHelper {
// 设置请求参数 // 设置请求参数
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
HttpPost httpPost = null;
try { try {
List<NameValuePair> params = toNameValuePair(paramMap); List<NameValuePair> params = toNameValuePair(paramMap);
URI uri = new URIBuilder(url).setParameters(params).build(); URI uri = new URIBuilder(url).setParameters(params).build();
log.info("执行请求:" + uri.toString()); log.info("执行请求:" + uri.toString());
HttpPost httpPost = new HttpPost(uri); httpPost = new HttpPost(uri);
httpPost.addHeader("Content-Type", contentType); httpPost.addHeader("Content-Type", contentType);
// httpPost.setEntity(new UrlEncodedFormEntity(params, CONTENT_CHARSET)); // httpPost.setEntity(new UrlEncodedFormEntity(params, CONTENT_CHARSET));
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
...@@ -238,6 +246,9 @@ public class HttpHelper { ...@@ -238,6 +246,9 @@ public class HttpHelper {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (httpPost != null){
httpPost.releaseConnection();
}
} }
} }
......
package com.neotel.smfcore.common.utils; package com.neotel.smfcore.common.utils;
import com.google.common.collect.Lists; import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.common.bean.ReelLockPosInfo; import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.*; import java.util.*;
...@@ -25,15 +25,15 @@ public class ReelLockPosUtil { ...@@ -25,15 +25,15 @@ public class ReelLockPosUtil {
/** /**
* 料盘锁定库位信息,用于包装料分配到其他料仓 * 料盘锁定库位信息,用于包装料分配到其他料仓
*/ */
private static Map<String, ReelLockPosInfo> reelLocKPosMap; private static Map<String, ReelLockPosInfo> reelLocKPosMap = Maps.newConcurrentMap();
@PostConstruct @PostConstruct
public void init() { public void init() {
dataCache = autodataCache; dataCache = autodataCache;
reelLocKPosMap=dataCache.getCache(REEL_LOCK_POS_MAP_KEY); Map<String, ReelLockPosInfo> cacheReelLocKPosMap = dataCache.getCache(REEL_LOCK_POS_MAP_KEY);
if(reelLocKPosMap==null){ if (cacheReelLocKPosMap != null) {
reelLocKPosMap=new HashMap<String,ReelLockPosInfo>(){}; reelLocKPosMap.putAll(cacheReelLocKPosMap);
} }
} }
...@@ -43,26 +43,33 @@ public class ReelLockPosUtil { ...@@ -43,26 +43,33 @@ public class ReelLockPosUtil {
* @param reelLockPosInfo * @param reelLockPosInfo
*/ */
public static synchronized ReelLockPosInfo addReelLockPosInfo(ReelLockPosInfo reelLockPosInfo , List<String> cidList) { public static synchronized ReelLockPosInfo addReelLockPosInfo(ReelLockPosInfo reelLockPosInfo , List<String> cidList) {
log.info("为[" + reelLockPosInfo.getBarcode() + "]锁定库位[" + reelLockPosInfo.getLockPosName() + "]"); String key = processBarcode(reelLockPosInfo.getBarcode());
ReelLockPosInfo oldLocInfo = reelLocKPosMap.get(reelLockPosInfo.getBarcode()); log.info("为[" + reelLockPosInfo.getBarcode() + "]锁定库位[" + reelLockPosInfo.getLockPosName() + "],key=[" + key + "]");
if (oldLocInfo != null && oldLocInfo.getLockPosName() != null) { ReelLockPosInfo oldLocInfo = reelLocKPosMap.get(key);
if(cidList.contains(oldLocInfo.getCid())){ try {
log.info("[" + oldLocInfo.getBarcode() + "]已有锁定库位[" + oldLocInfo.getLockPosName() + "],返回之前锁定的库位");
return oldLocInfo; if (oldLocInfo != null && oldLocInfo.getLockPosName() != null) {
}else{ if (cidList.contains(oldLocInfo.getCid())) {
//锁定库位不在cid列表中 log.info("[" + oldLocInfo.getBarcode() + "]已有锁定库位[" + oldLocInfo.getLockPosName() + "],返回之前锁定的库位");
log.info("[" + oldLocInfo.getBarcode() + "]已有锁定库位[" + oldLocInfo.getLockPosName() + "],Cid["+oldLocInfo.getCid()+"]不在["+String.join(",",cidList)+"]中,清理原有锁定库位"); return oldLocInfo;
reelLocKPosMap.remove(reelLockPosInfo.getBarcode()); } else {
//锁定库位不在cid列表中
log.info("[" + oldLocInfo.getBarcode() + "]已有锁定库位[" + oldLocInfo.getLockPosName() + "],Cid[" + oldLocInfo.getCid() + "]不在[" + String.join(",", cidList) + "]中,清理原有锁定库位");
reelLocKPosMap.remove(key);
}
} }
} for (ReelLockPosInfo locInfo : reelLocKPosMap.values()) {
for (ReelLockPosInfo locInfo : reelLocKPosMap.values()) { if (locInfo.getLockPosId().equals(reelLockPosInfo.getLockPosId()) && !locInfo.getBarcode().equals(key)) {
if (locInfo.getLockPosId().equals(reelLockPosInfo.getLockPosId()) && !locInfo.getBarcode().equals(reelLockPosInfo.getBarcode())) { log.info("为[" + reelLockPosInfo.getBarcode() + "]锁定库位[" + reelLockPosInfo.getLockPosName() + "]时,库位已被[" + locInfo.getBarcode() + "]锁定");
log.info("为[" + reelLockPosInfo.getBarcode() + "]锁定库位[" + reelLockPosInfo.getLockPosName() + "]时,库位已被[" + locInfo.getBarcode() + "]锁定"); return null;
return null; }
} }
reelLocKPosMap.put(key, reelLockPosInfo);
dataCache.updateCache(REEL_LOCK_POS_MAP_KEY, reelLocKPosMap);
} catch (Exception exception) {
log.error("为[" + reelLockPosInfo.getBarcode() + "]锁定库位[" + reelLockPosInfo.getLockPosName() + "],key=[" + key + "]出错:"+exception.toString());
} }
reelLocKPosMap.put(reelLockPosInfo.getBarcode(), reelLockPosInfo);
dataCache.updateCache(REEL_LOCK_POS_MAP_KEY, reelLocKPosMap);
return reelLockPosInfo; return reelLockPosInfo;
} }
...@@ -73,7 +80,7 @@ public class ReelLockPosUtil { ...@@ -73,7 +80,7 @@ public class ReelLockPosUtil {
String lockBarcode = reelLockPosInfo.getBarcode(); String lockBarcode = reelLockPosInfo.getBarcode();
if (org.apache.logging.log4j.util.Strings.isNotBlank(lockBarcode)) { if (org.apache.logging.log4j.util.Strings.isNotBlank(lockBarcode)) {
if (lockBarcode.equals(barcode)) { if (lockBarcode.equals(processBarcode(barcode) )) {
return reelLockPosInfo; return reelLockPosInfo;
} }
} }
...@@ -88,7 +95,7 @@ public class ReelLockPosUtil { ...@@ -88,7 +95,7 @@ public class ReelLockPosUtil {
* 清理条码锁定库位信息 * 清理条码锁定库位信息
*/ */
public static void removeReelLockPosInfo(String barcode) { public static void removeReelLockPosInfo(String barcode) {
reelLocKPosMap.remove(barcode); reelLocKPosMap.remove(processBarcode(barcode));
dataCache.updateCache(REEL_LOCK_POS_MAP_KEY, reelLocKPosMap); dataCache.updateCache(REEL_LOCK_POS_MAP_KEY, reelLocKPosMap);
} }
...@@ -99,7 +106,7 @@ public class ReelLockPosUtil { ...@@ -99,7 +106,7 @@ public class ReelLockPosUtil {
* @return * @return
*/ */
public static String getReelLockPosId(String barcode) { public static String getReelLockPosId(String barcode) {
ReelLockPosInfo lockPosInfo = reelLocKPosMap.get(barcode); ReelLockPosInfo lockPosInfo = reelLocKPosMap.get(processBarcode(barcode));
if (lockPosInfo != null) { if (lockPosInfo != null) {
return lockPosInfo.getLockPosId(); return lockPosInfo.getLockPosId();
} }
...@@ -116,4 +123,18 @@ public class ReelLockPosUtil { ...@@ -116,4 +123,18 @@ public class ReelLockPosUtil {
} }
return lockPosIds; return lockPosIds;
} }
private static String processBarcode(String str) {
if (ObjectUtil.isEmpty(str)) {
return str;
}
if (str.contains(".")) {
String res = str.replace(".", "__");
return res;
} else {
return str;
}
}
} }
...@@ -38,13 +38,19 @@ public class CodeResolve { ...@@ -38,13 +38,19 @@ public class CodeResolve {
private Integer defaultExpiresDay=0; private Integer defaultExpiresDay=0;
private boolean useSizeConfirm = true;
public void updateBarcodeRuleList(List<String> ruleList){ public void updateBarcodeRuleList(List<String> ruleList) {
barcodeRuleList = Lists.newArrayList(); try {
for(String codeRule : ruleList){
if(!Strings.isNullOrEmpty(codeRule)){ barcodeRuleList = Lists.newArrayList();
barcodeRuleList.add(BarcodeRule.newRule(codeRule)); for (String codeRule : ruleList) {
if (!Strings.isNullOrEmpty(codeRule)) {
barcodeRuleList.add(BarcodeRule.newRule(codeRule));
}
} }
} catch (Exception ex) {
log.error("updateBarcodeRuleList出错:" + ex.toString());
} }
} }
...@@ -56,6 +62,10 @@ public class CodeResolve { ...@@ -56,6 +62,10 @@ public class CodeResolve {
defaultExpiresDay=expiresDay; defaultExpiresDay=expiresDay;
} }
public void updateUseSizeConfirm(boolean confirm) {
useSizeConfirm = confirm;
}
public CodeBean resolveSingleCode(String barcodeItemStr ){ public CodeBean resolveSingleCode(String barcodeItemStr ){
return resolveSingleCode(barcodeItemStr, COMPONENT_TYPE.COMPONENT); return resolveSingleCode(barcodeItemStr, COMPONENT_TYPE.COMPONENT);
...@@ -132,7 +142,7 @@ public class CodeResolve { ...@@ -132,7 +142,7 @@ public class CodeResolve {
codeBeanFromRule.setShowImg(component.getShowImg()); codeBeanFromRule.setShowImg(component.getShowImg());
//如果已经确认尺寸,使用确认的尺寸 //如果已经确认尺寸,使用确认的尺寸
if (component.isSizeConfirmed() || ((component.hasSizeInfo()) && (!codeBeanFromRule.hasReelSizeInfo()))) { if ((component.isSizeConfirmed() && useSizeConfirm) || ((component.hasSizeInfo()) && (!codeBeanFromRule.hasReelSizeInfo()))) {
codeBeanFromRule.setReelWidth(component.getPlateSize()); codeBeanFromRule.setReelWidth(component.getPlateSize());
codeBeanFromRule.setReelHeight(component.getHeight()); codeBeanFromRule.setReelHeight(component.getHeight());
...@@ -269,7 +279,7 @@ public class CodeResolve { ...@@ -269,7 +279,7 @@ public class CodeResolve {
}else{ }else{
//如果已经确认尺寸,使用确认的尺寸 //如果已经确认尺寸,使用确认的尺寸
if(component.isSizeConfirmed() || ((component.hasSizeInfo())&&(!codeBeanFromRule.hasReelSizeInfo()))){ if((component.isSizeConfirmed() && useSizeConfirm) || ((component.hasSizeInfo())&&(!codeBeanFromRule.hasReelSizeInfo()))){
codeBeanFromRule.setReelWidth(component.getPlateSize()); codeBeanFromRule.setReelWidth(component.getPlateSize());
codeBeanFromRule.setReelHeight(component.getHeight()); codeBeanFromRule.setReelHeight(component.getHeight());
} }
...@@ -294,7 +304,7 @@ public class CodeResolve { ...@@ -294,7 +304,7 @@ public class CodeResolve {
log.info("档案["+barcodeFromRule.getPartNumber()+"]不存在"); log.info("档案["+barcodeFromRule.getPartNumber()+"]不存在");
// throw new ValidateException("component.error.notExist",new String[]{barcodeFromRule.getPartNumber()}); // throw new ValidateException("component.error.notExist",new String[]{barcodeFromRule.getPartNumber()});
throw new ValidateException("smfcore.valueNotExist","{0}[{1}]不存在",new String[]{"component",barcodeFromRule.getPartNumber()}); throw new ValidateException("smfcore.valueNotExist","{0}[{1}]不存在",new String[]{"component",barcodeFromRule.getPartNumber()});
}else if(component.isSizeConfirmed() || ((component.hasSizeInfo())&&(!codeBeanFromRule.hasReelSizeInfo()))){ }else if((component.isSizeConfirmed() && useSizeConfirm) || ((component.hasSizeInfo())&&(!codeBeanFromRule.hasReelSizeInfo()))){
//如果已经确认尺寸,使用确认的尺寸 //如果已经确认尺寸,使用确认的尺寸
codeBeanFromRule.setReelWidth(component.getPlateSize()); codeBeanFromRule.setReelWidth(component.getPlateSize());
codeBeanFromRule.setReelHeight(component.getHeight()); codeBeanFromRule.setReelHeight(component.getHeight());
......
package com.neotel.smfcore.core.dashboard.bean.dto.box;
import cn.hutool.core.date.DateTime;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MesInfoDto implements Serializable
{
private String status="OK";
private DateTime time;
private String request="";
private String response="";
}
package com.neotel.smfcore.core.dashboard.bean.dto.first; package com.neotel.smfcore.core.dashboard.bean.dto.first;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.neotel.smfcore.core.system.service.po.DataLog;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data @Data
public class ElecKanbanBoxStatusDto { public class ElecKanbanBoxStatusDto {
private String id;
private String cid;
/** /**
* 设备名称 * 设备名称
*/ */
...@@ -44,4 +55,26 @@ public class ElecKanbanBoxStatusDto { ...@@ -44,4 +55,26 @@ public class ElecKanbanBoxStatusDto {
* 湿度 * 湿度
*/ */
public String humidity = ""; public String humidity = "";
private List<DataLog> taskList = new ArrayList<>();
@ApiModelProperty("消息")
public String msg="";
@ApiModelProperty("最低温度")
private float minTemperature = 22.0F;
@ApiModelProperty("最高温度")
private float maxTemperature = 38.0F;
@ApiModelProperty("最低湿度值")
private float minHumidity = 0.0F;
@ApiModelProperty("最大湿度值")
private float maxHumidity = 100.0F;
@ApiModelProperty("客户端上传数据,closeLock为enable时此按钮状态为可用,openLock为enable时,此按钮状态为可用" +
"客户端收到服务器openLock为doit时,执行打开门锁动作,closeLock为doit时,执行关闭门锁" )
private Map<String, String> data = null;
@ApiModelProperty("使用情况")
private Map<String, UsageItem> usageMap = null;
} }
package com.neotel.smfcore.core.dashboard.box;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.dashboard.bean.dto.first.ElecKanbanBoxStatusDto;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import com.neotel.smfcore.core.message.rest.bean.mapstruct.MessageMapper;
import com.neotel.smfcore.core.message.service.manager.IMessageManager;
import com.neotel.smfcore.core.msd.bean.MSDSettiings;
import com.neotel.smfcore.core.storage.service.manager.IStorageManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/smdBox")
public class SmdBoxController {
@Autowired
DataCache dataCache;
@Autowired
IInOutDataManager inOutDataManager;
@Autowired
IMessageManager messageManager;
@Autowired
MessageMapper messageMapper;
@Autowired
TaskService taskService;
private Storage storage;
private Storage getDefaultBox() {
if (storage != null) {
return storage;
}
for (Storage stor : dataCache.getAllStorage().values()) {
if (stor.isBatchStorage()||stor.isMimoG2()) {
storage = stor;
return storage;
}
}
return null;
}
@ApiOperation("设备状态")
@RequestMapping("/boxStatus")
@AnonymousAccess
public List<ElecKanbanBoxStatusDto> getElecKanbanBoxStatusDto(String cid, HttpServletRequest servletRequest) throws ParseException {
List<ElecKanbanBoxStatusDto> resultList = new ArrayList<>();
if (StringUtils.isBlank(cid)) {
Storage storage = getDefaultBox();
if (storage != null) {
cid = storage.getCid();
}
}
MSDSettiings msdSettiings = dataCache.getCache(Constants.CACHE_msdSetting);
if (msdSettiings == null) {
msdSettiings = new MSDSettiings();
}
List<String> cids=new ArrayList<>();
if(StringUtils.isNotBlank(cid)){
Storage storage=dataCache.getStorage(cid);
if(storage!=null){
cids.add(cid);
if(ObjectUtil.isNotEmpty(storage.getAppendCid())){
cids.add(storage.getAppendCid());
}
}
}
Collections.sort(cids);
for (String theCid :
cids) {
Date currentDate = com.neotel.smfcore.common.utils.DateUtil.getCurrentDate("yyyy-MM-dd");
List<InOutData> inOutDataList = inOutDataManager.findByDate(currentDate, com.neotel.smfcore.common.utils.DateUtil.addDays(currentDate, 1), null);
ElecKanbanBoxStatusDto dto = new ElecKanbanBoxStatusDto();
StatusBean statusBean = DevicesStatusUtil.getStatusBean(theCid);
if (statusBean != null) {
//dto.setStatus(statusBean.getStatus());
Collection<BoxStatusBean> boxStatusBeans = statusBean.getBoxStatus().values();
if (boxStatusBeans != null && !boxStatusBeans.isEmpty()) {
for (BoxStatusBean boxStatusBean : boxStatusBeans) {
dto.setHumidity(boxStatusBean.getHumidity());
dto.setTemperature(boxStatusBean.getTemperature());
dto.setStatus(boxStatusBean.getStatus());
dto.setMsg(statusBean.getShowMsg(servletRequest.getLocale()));
dto.setData(statusBean.getData());
}
}
}
Storage storage = dataCache.getStorage(theCid);
if (storage.isNLShelf() || storage.isNLPShelf() || storage.isNLMShelf() || storage.isShelf()) {
dto.setType(0);
} else {
dto.setType(1);
}
int usage = (storage.getTotalSlots() - storage.getEmptySlots()) * 100 / storage.getTotalSlots();
dto.setUsage(usage);
int inCount = getTodayInOutCount(storage.getId(), inOutDataList, true);
int outCount = getTodayInOutCount(storage.getId(), inOutDataList, false);
dto.setTodayInCount(inCount);
dto.setTodayOutCount(outCount);
dto.setName(storage.getName());
dto.setId(storage.getId());
dto.setCid(storage.getCid());
Collection<DataLog> queueTasks = taskService.getQueueTasks(theCid);
if (queueTasks != null){
dto.setTaskList((List<DataLog>) queueTasks);
} else {
dto.setTaskList(new ArrayList<>());
}
dto.setMinHumidity(msdSettiings.getMinHumidity());
dto.setMaxHumidity(msdSettiings.getMaxHumidity());
dto.setMinTemperature(msdSettiings.getMinTemperature());
dto.setMaxTemperature(msdSettiings.getMaxTemperature());
dto.setUsageMap(storage.getUsageMap());
MesInfoDto mesInfoDto=DevicesStatusUtil.getLastAgvInfo(cid);
if(mesInfoDto!=null){
dto.getData().put("AGV", JsonUtil.toJsonStr(mesInfoDto));
}
resultList.add(dto);
}
return resultList;
}
private int getTodayInOutCount(String storageId, List<InOutData> inOutDataList, boolean isInCount) {
if (inOutDataList == null || inOutDataList.isEmpty()){
return 0;
}
if (isInCount){
return inOutDataList.stream().filter(inOutData -> inOutData.getStorageId().equals(storageId)).collect(Collectors.summingInt(InOutData :: getInCount)).intValue();
} else {
return inOutDataList.stream().filter(inOutData -> inOutData.getStorageId().equals(storageId)).collect(Collectors.summingInt(InOutData :: getOutCount)).intValue();
}
}
}
...@@ -198,7 +198,7 @@ public class SmdBoxMimoController { ...@@ -198,7 +198,7 @@ public class SmdBoxMimoController {
@ApiOperation("设备状态") @ApiOperation("设备状态")
@RequestMapping("/getBoxStatusDto") @RequestMapping("/getBoxStatusDto")
@AnonymousAccess @AnonymousAccess
public List<ElecKanbanBoxStatusDto> getElecKanbanBoxStatusDto(String cid) throws ParseException { public List<ElecKanbanBoxStatusDto> getElecKanbanBoxStatusDto(String cid,HttpServletRequest servletRequest) throws ParseException {
List<ElecKanbanBoxStatusDto> resultList = new ArrayList<>(); List<ElecKanbanBoxStatusDto> resultList = new ArrayList<>();
if (StringUtils.isBlank(cid)) { if (StringUtils.isBlank(cid)) {
Storage storage = getDefaultBox(); Storage storage = getDefaultBox();
...@@ -219,6 +219,8 @@ public class SmdBoxMimoController { ...@@ -219,6 +219,8 @@ public class SmdBoxMimoController {
dto.setHumidity(boxStatusBean.getHumidity()); dto.setHumidity(boxStatusBean.getHumidity());
dto.setTemperature(boxStatusBean.getTemperature()); dto.setTemperature(boxStatusBean.getTemperature());
dto.setStatus(boxStatusBean.getStatus()); dto.setStatus(boxStatusBean.getStatus());
dto.setMsg(statusBean.getShowMsg(servletRequest.getLocale()));
dto.setData(statusBean.getData());
} }
} }
} }
...@@ -236,6 +238,13 @@ public class SmdBoxMimoController { ...@@ -236,6 +238,13 @@ public class SmdBoxMimoController {
dto.setTodayInCount(inCount); dto.setTodayInCount(inCount);
dto.setTodayOutCount(outCount); dto.setTodayOutCount(outCount);
dto.setName(storage.getName()); dto.setName(storage.getName());
dto.setId(storage.getId());
Collection<DataLog> queueTasks = taskService.getQueueTasks(cid);
if (queueTasks != null){
dto.setTaskList((List<DataLog>) queueTasks);
} else {
dto.setTaskList(new ArrayList<>());
}
resultList.add(dto); resultList.add(dto);
} }
return resultList; return resultList;
...@@ -298,7 +307,7 @@ public class SmdBoxMimoController { ...@@ -298,7 +307,7 @@ public class SmdBoxMimoController {
return storage; return storage;
} }
for (Storage stor : dataCache.getAllStorage().values()) { for (Storage stor : dataCache.getAllStorage().values()) {
if (stor.isBatchStorage()) { if (stor.isBatchStorage()||stor.isMimoG2()) {
storage = stor; storage = stor;
return storage; return storage;
} }
......
...@@ -41,6 +41,10 @@ public class StatusBean { ...@@ -41,6 +41,10 @@ public class StatusBean {
*客户端IP *客户端IP
*/ */
private String clientIp; private String clientIp;
/**
* 附属CID
*/
private String appendCid;
/// <summary> /// <summary>
/// 操作相关数据, /// 操作相关数据,
/// op=1时,客户端发送 code 二维码给服务器,服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度 /// op=1时,客户端发送 code 二维码给服务器,服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度
...@@ -49,6 +53,16 @@ public class StatusBean { ...@@ -49,6 +53,16 @@ public class StatusBean {
//数据还放入data那个map里面,客户端收到服务器openLock为doit时,执行打开门锁动作;startBatchIn为doit时,执行开始批量入库动作;closeLock为doit时,执行关闭门锁;takeOutReel为doit时,执行取出出库料盘动作;confirmReelOut为doit时,执行门口料盘已取出; //数据还放入data那个map里面,客户端收到服务器openLock为doit时,执行打开门锁动作;startBatchIn为doit时,执行开始批量入库动作;closeLock为doit时,执行关闭门锁;takeOutReel为doit时,执行取出出库料盘动作;confirmReelOut为doit时,执行门口料盘已取出;
//当服务器收到客户端:doorStatus为门锁状态(如开门中,或关闭中);openLock为enable时,此按钮状态为可用;startBatchIn为enable时此按钮状态为可用;closeLock为enable时此按钮状态为可用;takeOutReel为enable时此按钮状态为可用;confirmReelOut为enable时此按钮状态为可用; //当服务器收到客户端:doorStatus为门锁状态(如开门中,或关闭中);openLock为enable时,此按钮状态为可用;startBatchIn为enable时此按钮状态为可用;closeLock为enable时此按钮状态为可用;takeOutReel为enable时此按钮状态为可用;confirmReelOut为enable时此按钮状态为可用;
//服务器默认这些按钮都为不可用状态,只有收到对应的enable时,按钮才可以进行点击 //服务器默认这些按钮都为不可用状态,只有收到对应的enable时,按钮才可以进行点击
// 多料仓 doorStatus open/close
// shelfStatus ,表示料串状态:
// IDLE=空闲;
// LOADING=入库中;
// UNLOADING=出库中;
// NEED_EMPTY=需要空料串出库;
// EMPTY_OUT=空料串需要取走
// FULL_OUT=满料串需要取走
//料串类型 shelfType smallReel, bigReel, tray
//需求单号:hSerial 出库中需要上传工单号
private Map<String, String> data = new HashMap<>(); private Map<String, String> data = new HashMap<>();
/** /**
...@@ -118,6 +132,12 @@ public class StatusBean { ...@@ -118,6 +132,12 @@ public class StatusBean {
* 消息集合 * 消息集合
*/ */
public List<MsgInfo> msgList; public List<MsgInfo> msgList;
/**
* 消息合并
*/
public List<MsgInfo> mergeMsgList;
/** /**
* 料仓类型 * 料仓类型
*/ */
...@@ -242,10 +262,18 @@ public class StatusBean { ...@@ -242,10 +262,18 @@ public class StatusBean {
data.put("temp",String.valueOf(temperature)); data.put("temp",String.valueOf(temperature));
} }
public void setMinTemperature(float minTemperature) {
data.put("minTemp",String.valueOf(minTemperature));
}
public void setHumidity(float humidity) { public void setHumidity(float humidity) {
data.put("humi", String.valueOf(humidity)); data.put("humi", String.valueOf(humidity));
} }
public void setMinHumidity(float minHumidity) {
data.put("minHumi", String.valueOf(minHumidity));
}
public List<AlarmInfo> getAlarmList() { public List<AlarmInfo> getAlarmList() {
return alarmList; return alarmList;
} }
...@@ -286,7 +314,7 @@ public class StatusBean { ...@@ -286,7 +314,7 @@ public class StatusBean {
addPosInfo(barcode,posId,plateW,plateH,isSingleOut,false,0); addPosInfo(barcode,posId,plateW,plateH,isSingleOut,false,0);
} }
public void addPosInfo(String barcode, String posId, int plateW, int plateH, boolean isSingleOut,boolean isNgReel,int usedCount) { public void addPosInfo(String barcode, String posId, int plateW, int plateH, boolean isSingleOut,boolean isNgReel,int usedCount) {
addPosInfo(barcode, posId, plateW, plateH, isSingleOut, isNgReel, "", usedCount); addPosInfo(barcode, posId, plateW, plateH, isSingleOut, isNgReel, "", usedCount,"");
} }
/** /**
* 获取客户端发送上来的条码信息 * 获取客户端发送上来的条码信息
...@@ -297,7 +325,7 @@ public class StatusBean { ...@@ -297,7 +325,7 @@ public class StatusBean {
/** /**
* 入库时添加仓位及料盘大小信息(posId库位编号,plateW:料盘宽度,plateH:料盘高度,singleOut:是否出库到料仓门口) * 入库时添加仓位及料盘大小信息(posId库位编号,plateW:料盘宽度,plateH:料盘高度,singleOut:是否出库到料仓门口)
*/ */
public void addPosInfo(String barcode, String posId, int plateW, int plateH, boolean isSingleOut,boolean isNgReel,String ngMsg,int usedCount) { public void addPosInfo(String barcode, String posId, int plateW, int plateH, boolean isSingleOut,boolean isNgReel,String ngMsg,int usedCount,String hSerial) {
String originalPosId = data.get("posId"); String originalPosId = data.get("posId");
String originalPlateW = data.get("plateW"); String originalPlateW = data.get("plateW");
String originalPlateH = data.get("plateH"); String originalPlateH = data.get("plateH");
...@@ -334,6 +362,7 @@ public class StatusBean { ...@@ -334,6 +362,7 @@ public class StatusBean {
data.put("ngMsg", "Repeat Inbound"); data.put("ngMsg", "Repeat Inbound");
} }
data.put("usedCount", usedCount + ""); data.put("usedCount", usedCount + "");
data.put("hSerial",hSerial);
} }
/** /**
...@@ -656,12 +685,12 @@ public class StatusBean { ...@@ -656,12 +685,12 @@ public class StatusBean {
} }
public String getShowMsg(Locale locale) { public String getShowMsg(Locale locale) {
if (ObjectUtil.isEmpty(this.msgList)) { if (ObjectUtil.isEmpty(this.mergeMsgList)) {
return ""; return "";
} }
String returnMsg = ""; String returnMsg = "";
for (MsgInfo msg : for (MsgInfo msg :
msgList) { mergeMsgList) {
String mMsg = GetMsgStr(msg,locale); String mMsg = GetMsgStr(msg,locale);
if (ObjectUtil.isEmpty(returnMsg)) { if (ObjectUtil.isEmpty(returnMsg)) {
returnMsg = mMsg; returnMsg = mMsg;
...@@ -701,13 +730,15 @@ public class StatusBean { ...@@ -701,13 +730,15 @@ public class StatusBean {
} }
public void MsgDataProcess() { public List<MsgInfo> MsgDataProcess() {
//消息格式处理 List<MsgInfo> mergeMsgList = new ArrayList<>();
if( getMsgList()==null&& ObjectUtil.isNotEmpty(msg)){ if (msgList != null && !msgList.isEmpty()) {
msgList=new ArrayList<>(); mergeMsgList.addAll(msgList);
}
if (ObjectUtil.isNotEmpty(msg)) {
//判断是否有换行 //判断是否有换行
String[] msgArray=this.msg.split("\r\n"); String[] msgArray = this.msg.split("\r\n");
if(msgArray.length>0) { if (msgArray.length > 0) {
for (String msg : for (String msg :
msgArray) { msgArray) {
if (ObjectUtil.isEmpty(msg)) { if (ObjectUtil.isEmpty(msg)) {
...@@ -726,13 +757,15 @@ public class StatusBean { ...@@ -726,13 +757,15 @@ public class StatusBean {
} }
if (msgArray.length == 1) { if (msgArray.length == 1) {
msgList.add(new MsgInfo(msg, msgType,msgEn,msgJp,msgCode,msgParam,"","")); mergeMsgList.add(new MsgInfo(msg, msgType, msgEn, msgJp, msgCode, msgParam, "", ""));
} else { } else {
msgList.add(new MsgInfo(msg, msgType)); mergeMsgList.add(new MsgInfo(msg, msgType));
} }
} }
} }
} }
setMergeMsgList(mergeMsgList);
return mergeMsgList;
} }
public void setRMsg(String msgKey, String[] msgParam, String message) { public void setRMsg(String msgKey, String[] msgParam, String message) {
......
...@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.device.handler.impl; ...@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR; import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
...@@ -37,7 +38,7 @@ public class AccShelfHandler extends BaseDeviceHandler{ ...@@ -37,7 +38,7 @@ public class AccShelfHandler extends BaseDeviceHandler{
ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb); ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
if (color == null) { if (color == null) {
if (queueTask.isPutInTask()) { if (queueTask.isPutInTask()) {
color = ORDER_COLOR.DARKGREEN; color = ORDER_COLOR.FORESTGREEN;
} else { } else {
if (openZhiYin && ObjectUtil.isNotEmpty(queueTask.getSourceId())) { if (openZhiYin && ObjectUtil.isNotEmpty(queueTask.getSourceId())) {
List<DataLog> dataLogList = outMap.get(queueTask.getSourceId()); List<DataLog> dataLogList = outMap.get(queueTask.getSourceId());
...@@ -55,10 +56,15 @@ public class AccShelfHandler extends BaseDeviceHandler{ ...@@ -55,10 +56,15 @@ public class AccShelfHandler extends BaseDeviceHandler{
log.info("库位[" + queueTask.getPosName() + "]+亮灯:" + color.name()); log.info("库位[" + queueTask.getPosName() + "]+亮灯:" + color.name());
} }
} }
List<DataLog> dataLogs = getLightGuideTask(outMap); List<DataLog> dataLogs = getLightGuideTask(outMap,statusBean.getCid());
for (DataLog task : for (DataLog task :
dataLogs) { dataLogs) {
statusBean.addData("open", task.getPosName() + "=" + ORDER_COLOR.fromRgb(task.getLightColor()).name()); if (StringUtils.isBlank(task.getLightColor())){
task.setLightColor(ORDER_COLOR.BLUE.getRgb());
}
String colorName = ORDER_COLOR.fromRgb(task.getLightColor()).name();
statusBean.addData("open", task.getPosName() + "=" + colorName);
log.info("库位[" + task.getPosName() + "][" + task.getType() + "]+亮灯:" + colorName);
} }
return statusBean; return statusBean;
......
...@@ -17,6 +17,7 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode; ...@@ -17,6 +17,7 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component; 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.BoxStatusBean; import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.MsgInfo;
import com.neotel.smfcore.core.device.enums.BOX_STATUS; 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;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
...@@ -127,6 +128,13 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -127,6 +128,13 @@ public class BaseDeviceHandler implements IDeviceHandler {
log.info("获取温湿度报警值 maxTemperature["+maxTemperature+"]maxHumidity["+maxHumidity+"]"); log.info("获取温湿度报警值 maxTemperature["+maxTemperature+"]maxHumidity["+maxHumidity+"]");
statusBean.setTemperature(maxTemperature); statusBean.setTemperature(maxTemperature);
statusBean.setHumidity(maxHumidity); statusBean.setHumidity(maxHumidity);
float minTemperature = msdSettiings.getMinTemperature();
float minHumidity = msdSettiings.getMinHumidity();
log.info("获取温湿度报警值 minTemperature["+minTemperature+"]minHumidity["+minHumidity+"]");
statusBean.setMinTemperature(minTemperature);
statusBean.setMinHumidity(minHumidity);
return statusBean; return statusBean;
} else if (dataCache.needUpdateHumidiy(statusBean.getCid())) { } else if (dataCache.needUpdateHumidiy(statusBean.getCid())) {
MSDSettiings msdSettiings = dataCache.getCache(Constants.CACHE_msdSetting); MSDSettiings msdSettiings = dataCache.getCache(Constants.CACHE_msdSetting);
...@@ -361,7 +369,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -361,7 +369,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
Collection<String> operatingPosIds =taskService.excludePosIds(); Collection<String> operatingPosIds =taskService.excludePosIds();
// 是否有出库任务 // 是否有出库任务
if (storage.isSmdDuo() || storage.isBatchStorage()) { if (storage.isSmdDuo() || storage.isBatchStorage()||storage.isMimoG2()) {
//DUO料仓和MIMO客户端缓存出库任务,入库优先 //DUO料仓和MIMO客户端缓存出库任务,入库优先
log.info("从" + storage.getName() + " 中为" + barcode.getBarcode() + "寻找空的仓位"); log.info("从" + storage.getName() + " 中为" + barcode.getBarcode() + "寻找空的仓位");
storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds); storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
...@@ -802,20 +810,20 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -802,20 +810,20 @@ public class BaseDeviceHandler implements IDeviceHandler {
return; return;
} }
barcode = barcodeManager.get(barcode.getId()); Barcode barcodeDB = barcodeManager.get(barcode.getId());
if (barcode != null) { if (barcodeDB != null) {
//二维码状态 //二维码状态
barcode.setUsed(true); barcodeDB.setUsed(true);
barcode.setUsedDate(new Date()); barcodeDB.setUsedDate(new Date());
//仓位状态 //仓位状态
barcode.setCheckOutDate(new Date(), task.getOperator()); barcodeDB.setCheckOutDate(new Date(), task.getOperator());
barcode.setPosName(""); barcodeDB.setPosName("");
barcodeManager.save(barcode); barcodeManager.save(barcodeDB);
task.setBatchInfo(barcode.getBatch()); task.setBatchInfo(barcodeDB.getBatch());
//记录在库时长 //记录在库时长
task.setInStoreTime(barcode.getInStoreMiniute()); task.setInStoreTime(barcodeDB.getInStoreMiniute());
} }
storagePos.setBarcode(null); storagePos.setBarcode(null);
...@@ -844,7 +852,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -844,7 +852,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
try { try {
//转换为新格式 //转换为新格式
statusBean.MsgDataProcess(); List<MsgInfo> mergeMsgList = statusBean.MsgDataProcess();
//判断是否刚刚上线 //判断是否刚刚上线
StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid()); StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
if (bean == null || bean.getBoxStatus() == null) { if (bean == null || bean.getBoxStatus() == null) {
...@@ -854,8 +862,8 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -854,8 +862,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp()); DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), new ArrayList<>()); DevicesStatusUtil.updateClientMsg(statusBean.getCid(), new ArrayList<>());
} }
if(ObjectUtil.isNotEmpty(statusBean.msgList)&& statusBean.msgList.size()>0) { if(ObjectUtil.isNotEmpty(mergeMsgList)&& mergeMsgList.size()>0) {
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), statusBean.msgList); DevicesStatusUtil.updateClientMsg(statusBean.getCid(), mergeMsgList);
} }
// //判断是否刚刚上线 // //判断是否刚刚上线
// StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid()); // StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
...@@ -908,6 +916,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -908,6 +916,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
statusBean.setOp(statusBeanToSave.getOp()); statusBean.setOp(statusBeanToSave.getOp());
statusBean.setSeq(statusBeanToSave.getSeq()); statusBean.setSeq(statusBeanToSave.getSeq());
statusBean.setClientIp(statusBeanToSave.getClientIp()); statusBean.setClientIp(statusBeanToSave.getClientIp());
statusBean.setMergeMsgList(statusBeanToSave.getMergeMsgList());
/** /**
* 已解除的报警信息存到数据库中 * 已解除的报警信息存到数据库中
...@@ -951,14 +960,76 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -951,14 +960,76 @@ public class BaseDeviceHandler implements IDeviceHandler {
return statusBean; return statusBean;
} }
protected List<DataLog> getLightGuideTask(Map<String,List<DataLog>> outMap) { protected List<DataLog> getLightGuideTask(Map<String,List<DataLog>> outMap,String cid) {
List<DataLog> dataLogs = Lists.newArrayList(); List<DataLog> dataLogs = Lists.newArrayList();
if (outMap.size() <= 0) { if (outMap.size() <= 0) {
return dataLogs; return dataLogs;
} }
//先查找正在执行中的发过去 //先查找正在执行中的发过去
for (String sourceId : outMap.keySet()) { for (String sourceId : outMap.keySet()) {
List<DataLog> dataLogList = outMap.get(sourceId);
//1.获取当前工单,所有的任务
List<DataLog> dataLogList = new ArrayList<>();
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.isWait() || dataLog.isExecuting()){
if (sourceId.equals(dataLog.getSourceId())){
dataLogList.add(dataLog);
}
}
}
//2.判断有没有正在执行的任务
boolean hasExecuting = false;
for (DataLog dataLog : dataLogList) {
if (dataLog.isExecuting()){
hasExecuting = true;
if (cid.equals(dataLog.getCid())){
dataLogs.add(dataLog);
}
}
}
//3.判断工单是否存在
if (!hasExecuting) {
LiteOrder order = liteOrderCache.getOrderSortItems(sourceId);
if (order == null) {
log.error("ACCSHELF: sourceId=" + sourceId + "的工单号未找到");
continue;
}
//3.获取到站位信息对应的任务
DataLog needSendLog = null;
for (LiteOrderItem orderItem : order.getOrderItems()) {
for (DataLog dataLog : dataLogList) {
if (orderItem.getId().equals(dataLog.getSubSourceId())) {
needSendLog = dataLog;
break;
}
}
if (needSendLog != null) {
break;
}
}
//4.处理任务
if (needSendLog != null) {
if (cid.equals(needSendLog.getCid())) {
if (needSendLog.isWait()) {
needSendLog.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(needSendLog);
dataLogs.add(needSendLog);
log.info("ACCSHELF: sourceId=" + sourceId + "的工单[" + order.getOrderNo() + "]开始执行任务:[" + needSendLog.getPosName() + "][" + needSendLog.getPartNumber() + "][" + needSendLog.getBarcode() + "]");
}
}
}
}
/*List<DataLog> dataLogList = outMap.get(sourceId);
boolean isFind = false; boolean isFind = false;
for (DataLog dataLog : dataLogList) { for (DataLog dataLog : dataLogList) {
...@@ -996,7 +1067,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -996,7 +1067,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (isFind) { if (isFind) {
break; break;
} }
} }*/
} }
return dataLogs; return dataLogs;
} }
...@@ -1047,6 +1118,14 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -1047,6 +1118,14 @@ public class BaseDeviceHandler implements IDeviceHandler {
} }
} }
protected String replaceSpecial(String code){
code = code.replace("[RS]","$");
code = code.replace("[GS]","$");
code = code.replace("[EOT]","$");
return code;
}
@Override @Override
public DeviceType getDeviceType() { public DeviceType getDeviceType() {
return DeviceType.DEFAULT; return DeviceType.DEFAULT;
......
package com.neotel.smfcore.core.device.handler.impl;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "DUO料仓")
@RestController
@Slf4j
public class DUOBoxHandler extends XLRBoxHandler{
@Override
public DeviceType getDeviceType() {
return DeviceType.SMD_DUO;
}
}
package com.neotel.smfcore.core.device.handler.impl;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.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 com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.custom.djk20388.util.AgvDataUtil;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Map;
@Api(tags = "MIMOG2: 批量料仓")
@Service
@Slf4j
public class MimoG2BoxHandler extends BaseDeviceHandler {
@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;
}
statusBean.setClientIp(request.getRemoteHost());
handleMsg(statusBean);
// if(ObjectUtil.isNotEmpty(statusBean.getMsg())){
// log.info("cid["+cid+"],msgCode["+statusBean.getMsgCode()+"],msg["+statusBean.getMsg()+"]");
// }
statusBean = saveAlarmAndHumidity(statusBean);
statusBean = handleInOutFinished(statusBean);
StatusBean humidityResult = handleHumidity(statusBean);
statusBean=handleSelfAudit(statusBean);
if (humidityResult != null) {
return humidityResult;
}
if (statusBean.getOp() == OP.PUT_IN) {
log.debug("入库:" + statusBean.toString());
statusBean = putInLine(storage, statusBean);
} else {
//先查找紧急出库的物料
StatusBean outSingleTaskResult = outSingleOutTask(storage, statusBean);
if(outSingleTaskResult != null){
statusBean = outSingleTaskResult;
}else{
//查看是否有要出库的操作
statusBean =taskService.checkOut(storage, statusBean);
}
}
//获取操作
Map<String, String> opMap = DevicesStatusUtil.getAndRemoveOp(cid);
statusBean.putOp(opMap);
//agv附加操作
Map<String, String> agvToMimoOpMap = AgvDataUtil.getAndRemoveToMimoOp(cid);
statusBean.putOp(agvToMimoOpMap);
return statusBean;
}
@Override
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();
String barcode = boxStatus.getBarcode();
int executeTime = boxStatus.getExecuteTime();
if ((!Strings.isNullOrEmpty(posName)) || (!Strings.isNullOrEmpty(barcode))) {//客户端发一次完成之后,会发空的 posName,不需要处理
if (BOX_STATUS.IN_FINISHED == status) {//入仓完成
finishedPutIn(statusBean.getCid(), posName, barcode, executeTime);
} else if (BOX_STATUS.IN_FAILED == status) {//入库失败
//暂不处理
} else if (BOX_STATUS.OUT_FINISHED == status) {//出仓完成
finishedOutPos(statusBean.getCid(), posName,barcode,executeTime, OP_STATUS.OUT_BOX);
} else if (BOX_STATUS.OUT_END == status) {//出库完成(放到仓门口
endOutTask(statusBean.getCid(), posName, barcode);
}
}
} catch (ValidateException e) {
log.error("更新状态时出错" + e.getMessage());
}
}
}
return statusBean;
}
/**
* 出库紧急物料
*/
public StatusBean outSingleOutTask(Storage storage, StatusBean statusBean) {
try {
//准备更新暂停出入库
if (dataCache.getCache(Constants.CACHE_StopOut)) {
return statusBean;
}
String cid = storage.getCid();
//紧急出库任务不论是否有入库任务都发到客户端,由客户端在入库间隙进行出库
Collection<DataLog> queueTasks = taskService.getQueueTasks();
int excuttingOutTaskNum = 0;
DataLog singleOutTask = null;
for (DataLog queueTask : queueTasks) {
if(queueTask.isCheckOutTask()){
if (cid.equals(queueTask.getCid())) {
if(queueTask.isExecuting()){
excuttingOutTaskNum ++;
}
if (queueTask.isSingleOut() && queueTask.isWait()) {
//单盘优先出库
if (singleOutTask == null || queueTask.getCreateDate().before(singleOutTask.getCreateDate())) {
singleOutTask = queueTask;
}
}
}
}
}
//已经有2个出库任务在执行,不再发了
if(excuttingOutTaskNum < 2){
if (singleOutTask != null) {
log.info("MIMO料仓优先分配紧急出库任务" + singleOutTask.getBarcode() + "[" + singleOutTask.getPosName() + "]到 " + cid);
singleOutTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(singleOutTask);
statusBean.setOp(OP.CHECKOUT);
String posName = singleOutTask.getPosName();
Barcode codeObj = barcodeManager.findByBarcode(singleOutTask.getBarcode());
int plateW = 0;
int plateH = 0;
if (codeObj != null) {
plateW = codeObj.getPlateSize();
plateH = codeObj.getHeight();
} else {
log.warn("MIMO紧急出库无料仓位" + storage.getName() + "[" + posName + "]");
StoragePos pos=storagePosManager.getByPosName(posName);
plateW = pos.getW();
plateH = pos.getH();
}
statusBean.addPosInfo(singleOutTask.getBarcode(), posName, plateW, plateH, true);
log.info("出库紧急物料" + storage.getName() + "[" + posName + "]物料[" + singleOutTask.getBarcode() + "]" + "发送到客户端" + cid);
return statusBean;
}
}
} catch (Exception e) {
log.error("出库紧急物料出错", e);
}
return null;
}
@Override
public DeviceType getDeviceType() {
return DeviceType.SMD_MIMO_G2;
}
}
...@@ -104,6 +104,8 @@ public class NLLShelfHandler extends BaseDeviceHandler { ...@@ -104,6 +104,8 @@ public class NLLShelfHandler extends BaseDeviceHandler {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
} }
code = replaceSpecial(code);
Barcode barcode = codeResolve.resolveOneValideBarcode(code); Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode == null) { if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.noValidCode", "条码无效"); throw new ValidateException("smfcore.error.barcode.noValidCode", "条码无效");
...@@ -185,6 +187,10 @@ public class NLLShelfHandler extends BaseDeviceHandler { ...@@ -185,6 +187,10 @@ public class NLLShelfHandler extends BaseDeviceHandler {
String posName = paramMap.get("posName"); String posName = paramMap.get("posName");
String code = paramMap.get("code"); String code = paramMap.get("code");
if (StringUtils.isNotEmpty(code)){
code = replaceSpecial(code);
}
Barcode barcode = codeResolve.resolveOneValideBarcode(code); Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode == null) { if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.noValidCode", "条码无效"); throw new ValidateException("smfcore.error.barcode.noValidCode", "条码无效");
......
...@@ -6,8 +6,10 @@ import com.google.common.collect.Lists; ...@@ -6,8 +6,10 @@ import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.inList.util.InListCache; import com.neotel.smfcore.core.inList.util.InListCache;
...@@ -103,10 +105,13 @@ public class NLMShelfHandler extends BaseDeviceHandler { ...@@ -103,10 +105,13 @@ public class NLMShelfHandler extends BaseDeviceHandler {
} }
} }
List<DataLog> dataLogs = getLightGuideTask(outMap); List<DataLog> dataLogs = getLightGuideTask(outMap,statusBean.getCid());
for (DataLog task : for (DataLog task :
dataLogs) { dataLogs) {
// statusBean.addData("open", task.getPosName() + "=" + ORDER_COLOR.fromRgb(task.getLightColor()).name()); // statusBean.addData("open", task.getPosName() + "=" + ORDER_COLOR.fromRgb(task.getLightColor()).name());
if (StringUtils.isBlank(task.getLightColor())){
task.setLightColor(ORDER_COLOR.BLUE.getRgb());
}
String color = ORDER_COLOR.fromRgb(task.getLightColor()).name(); String color = ORDER_COLOR.fromRgb(task.getLightColor()).name();
addMergeData(statusBean, task, "open", color); addMergeData(statusBean, task, "open", color);
} }
...@@ -217,6 +222,9 @@ public class NLMShelfHandler extends BaseDeviceHandler { ...@@ -217,6 +222,9 @@ public class NLMShelfHandler extends BaseDeviceHandler {
if (ObjectUtils.isEmpty(code)) { if (ObjectUtils.isEmpty(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
} }
code = replaceSpecial(code);
if (groupId == null && storageId == null) { if (groupId == null && storageId == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"});
} }
...@@ -240,6 +248,31 @@ public class NLMShelfHandler extends BaseDeviceHandler { ...@@ -240,6 +248,31 @@ public class NLMShelfHandler extends BaseDeviceHandler {
if (!Strings.isNullOrEmpty(code)) { if (!Strings.isNullOrEmpty(code)) {
code = code.replace("。", "."); code = code.replace("。", ".");
} }
String w = mapValues.get("w");
String h = mapValues.get("h");
if (StringUtils.isEmpty(w) || StringUtils.isEmpty(h)) {
w = "1";
h = "1";
Barcode noSizeBarcode = codeResolve.resolveCode(code);
if (noSizeBarcode == null){
noSizeBarcode = barcodeManager.findByBarcode(code);
}
if (noSizeBarcode != null) {
Component component = componentManager.findByPartNumberAndProvider(noSizeBarcode.getPartNumber(), noSizeBarcode.getProvider());
if (component != null) {
w = component.getPlateSize() + "";
h = component.getHeight() + "";
}
}
}
if (w.equals("1") || h.equals("1")){
return ResultBean.newErrorResult(101,"smfcore.error.barcode.errorSize","条码未设置尺寸");
}
code = "="+w+"x"+h+"="+code;
CodeBean codeBean = codeResolve.resolveSingleCode(code); CodeBean codeBean = codeResolve.resolveSingleCode(code);
if (!codeBean.isValid()) { if (!codeBean.isValid()) {
throw new ValidateException("smfcore.error.barcode.invalid", "未找到有效的条码"); throw new ValidateException("smfcore.error.barcode.invalid", "未找到有效的条码");
...@@ -250,10 +283,10 @@ public class NLMShelfHandler extends BaseDeviceHandler { ...@@ -250,10 +283,10 @@ public class NLMShelfHandler extends BaseDeviceHandler {
if (expireDate != null && System.currentTimeMillis() > expireDate.getTime()) { if (expireDate != null && System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
} }
if (barcode.getPlateSize() <= 1) { /* if (barcode.getPlateSize() <= 1) {
//长宽为1的需要弹框设置尺寸 //长宽为1的需要弹框设置尺寸
return ResultBean.newErrorResult(101,"smfcore.error.barcode.errorSize","条码未设置尺寸"); return ResultBean.newErrorResult(101,"smfcore.error.barcode.errorSize","条码未设置尺寸");
} }*/
try { try {
StoragePos inPos = storagePosManager.getByBarcodeId(barcode.getId()); StoragePos inPos = storagePosManager.getByBarcodeId(barcode.getId());
if (inPos != null) { if (inPos != null) {
......
...@@ -64,6 +64,9 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -64,6 +64,9 @@ public class NLPShelfHandler extends BaseDeviceHandler {
if (ObjectUtils.isEmpty(code)) { if (ObjectUtils.isEmpty(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
} }
code = replaceSpecial(code);
if (groupId == null && storageId == null) { if (groupId == null && storageId == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"});
} }
...@@ -244,9 +247,14 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -244,9 +247,14 @@ public class NLPShelfHandler extends BaseDeviceHandler {
} }
} }
List<DataLog> dataLogs = getLightGuideTask(outMap); List<DataLog> dataLogs = getLightGuideTask(outMap,statusBean.getCid());
for (DataLog task : dataLogs) { for (DataLog task : dataLogs) {
statusBean.addData("open", task.getPosName() + "=" + ORDER_COLOR.fromRgb(task.getLightColor()).name()); if (StringUtils.isBlank(task.getLightColor())){
task.setLightColor(ORDER_COLOR.BLUE.getRgb());
}
String colorName = ORDER_COLOR.fromRgb(task.getLightColor()).name();
statusBean.addData("open", task.getPosName() + "=" + colorName);
log.info("库位[" + task.getPosName() + "][" + task.getType() + "]+亮灯:" + colorName);
} }
return statusBean; return statusBean;
......
...@@ -95,7 +95,7 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -95,7 +95,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb); ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
if (color == null) { if (color == null) {
if (queueTask.isPutInTask()) { if (queueTask.isPutInTask()) {
color = ORDER_COLOR.DARKGREEN; color = ORDER_COLOR.FORESTGREEN;
} else { } else {
color = ORDER_COLOR.BLUE; color = ORDER_COLOR.BLUE;
} }
...@@ -117,8 +117,11 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -117,8 +117,11 @@ public class NLShelfHandler extends BaseDeviceHandler {
} }
} }
List<DataLog> dataLogs = getLightGuideTask(outMap); List<DataLog> dataLogs = getLightGuideTask(outMap,statusBean.getCid());
for (DataLog task : dataLogs) { for (DataLog task : dataLogs) {
if (StringUtils.isBlank(task.getLightColor())){
task.setLightColor(ORDER_COLOR.BLUE.getRgb());
}
String colorName = ORDER_COLOR.fromRgb(task.getLightColor()).name(); String colorName = ORDER_COLOR.fromRgb(task.getLightColor()).name();
statusBean.addData("open", task.getPosName() + "=" + colorName); statusBean.addData("open", task.getPosName() + "=" + colorName);
log.info("库位[" + task.getPosName() + "][" + task.getType() + "]+亮灯:" + colorName); log.info("库位[" + task.getPosName() + "][" + task.getType() + "]+亮灯:" + colorName);
...@@ -267,6 +270,9 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -267,6 +270,9 @@ public class NLShelfHandler extends BaseDeviceHandler {
if (ObjectUtils.isEmpty(code)) { if (ObjectUtils.isEmpty(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
} }
code = replaceSpecial(code);
if (groupId == null && storageId == null) { if (groupId == null && storageId == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"});
} }
...@@ -374,7 +380,7 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -374,7 +380,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
if (liteOrder != null && liteOrder.isTaskFinished()) { if (liteOrder != null && liteOrder.isTaskFinished()) {
//工单任务已完成 //工单任务已完成
String orderNo = liteOrder.getOrderNo(); String orderNo = liteOrder.getOrderNo();
String orderFinishedTxt = MessageUtils.getText("smfcore.order.finished", new String[]{orderNo}, request.getLocale(), "工单["+orderNo+"]的任务已全部完成"); String orderFinishedTxt = MessageUtils.getText("smfcore.order.finished", new String[]{orderNo}, request.getLocale(), "工单[{0}]的任务已全部完成");
dataMap.put("orderFinishedTxt",orderFinishedTxt); dataMap.put("orderFinishedTxt",orderFinishedTxt);
log.info("工单完成,返回 orderFinishedTxt, "+orderFinishedTxt); log.info("工单完成,返回 orderFinishedTxt, "+orderFinishedTxt);
} }
......
...@@ -10,6 +10,7 @@ import com.neotel.smfcore.core.device.enums.OP_STATUS; ...@@ -10,6 +10,7 @@ import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.storage.enums.DeviceType; 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.Storage;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -49,7 +50,9 @@ public class XLRBoxHandler extends BaseDeviceHandler { ...@@ -49,7 +50,9 @@ public class XLRBoxHandler extends BaseDeviceHandler {
//查看是否有要出库的操作 //查看是否有要出库的操作
statusBean =taskService.checkOut(storage, statusBean); statusBean =taskService.checkOut(storage, statusBean);
} }
//获取操作
Map<String, String> opMap = DevicesStatusUtil.getAndRemoveOp(cid);
statusBean.putOp(opMap);
return statusBean; return statusBean;
} }
......
...@@ -15,15 +15,19 @@ import com.neotel.smfcore.common.utils.SecurityUtils; ...@@ -15,15 +15,19 @@ import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; 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.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component; 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.PosInfo; import com.neotel.smfcore.core.device.bean.PosInfo;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.storage.service.manager.IStorageManager;
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.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.dao.IAlarmInfoDao; import com.neotel.smfcore.core.system.service.dao.IAlarmInfoDao;
...@@ -69,6 +73,9 @@ public class DeviceController { ...@@ -69,6 +73,9 @@ public class DeviceController {
private IStoragePosManager storagePosManager; private IStoragePosManager storagePosManager;
@Autowired @Autowired
private IStorageManager storageManager;
@Autowired
private IComponentManager componentManager; private IComponentManager componentManager;
@Autowired @Autowired
...@@ -101,6 +108,31 @@ public class DeviceController { ...@@ -101,6 +108,31 @@ public class DeviceController {
log.error("料仓cid: [" + cid + "]不存在"); log.error("料仓cid: [" + cid + "]不存在");
return null; return null;
} }
try {
String appendCid=statusBean.getFromData("appendCid");
if(ObjectUtil.isNotEmpty(appendCid)){
statusBean.setAppendCid(appendCid);
}
//判断是否需要更改附属CID
if(ObjectUtil.isNotEmpty(statusBean.getAppendCid())){
boolean needsave=false;
if(ObjectUtil.isEmpty(storage.getAppendCid()) ){
needsave=true;
log.info("料仓["+cid+"] 更改 appendCid ="+statusBean.getAppendCid());
}
else if( !(storage.getAppendCid().equals(statusBean.getAppendCid()))){
needsave=true;
log.info("料仓["+cid+"] 更改 appendCid ="+statusBean.getAppendCid()+", 原来 appendCid ="+storage.getAppendCid());
}
if(needsave) {
storage.setAppendCid(statusBean.getAppendCid());
storageManager.save(storage);
dataCache.reloadStorage(storage, storage.getCid());
}
}
}catch (Exception ex){
log.error("更改cid=的appendId出错:"+ex.toString());
}
synchronized (storage) { synchronized (storage) {
String deviceType = storage.getType(); String deviceType = storage.getType();
IDeviceHandler deviceHandler = handlerMap.get(deviceType); IDeviceHandler deviceHandler = handlerMap.get(deviceType);
...@@ -315,7 +347,7 @@ public class DeviceController { ...@@ -315,7 +347,7 @@ public class DeviceController {
errorMsg = ve.getMessage(); errorMsg = ve.getMessage();
log.info("查找空库位失败:" + errorMsg); log.info("查找空库位失败:" + errorMsg);
resultMap.put("result", "105"); resultMap.put("result", "105");
resultMap.put("msg", errorMsg); resultMap.put("msg", MessageUtils.getText(ve.getMsgKey(),ve.getMsgParam(),request.getLocale(),ve.getDefaultMsg()));
} catch (Exception e) { } catch (Exception e) {
errorMsg = e.getMessage(); errorMsg = e.getMessage();
log.info("查找空库位失败,", e); log.info("查找空库位失败,", e);
...@@ -649,16 +681,20 @@ public class DeviceController { ...@@ -649,16 +681,20 @@ public class DeviceController {
public ResultBean getHeightandWidthByCode(@RequestBody Map<String, String> paramMap) { public ResultBean getHeightandWidthByCode(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("code"); String code = paramMap.get("code");
if (StringUtils.isNotBlank(code)) { if (StringUtils.isNotBlank(code)) {
Barcode barcode = codeResolve.resolveCode(code); String[] barcodeItemStrs = code.split("##");
if (barcode != null) { for (String barcodeItemStr : barcodeItemStrs) {
String partNumber = barcode.getPartNumber(); log.info("开始解析:"+barcodeItemStr);
Component component = componentManager.findOneByPN(partNumber); Barcode barcode = codeResolve.resolveCode(barcodeItemStr);
if (component != null) { if (barcode != null) {
Map<String,Object> resultMap = new HashMap<>(); String partNumber = barcode.getPartNumber();
resultMap.put("partNumber",partNumber); Component component = componentManager.findOneByPN(partNumber);
resultMap.put("plateSize",component.getPlateSize()); if (component != null) {
resultMap.put("height",component.getHeight()); Map<String, Object> resultMap = new HashMap<>();
return ResultBean.newOkResult(resultMap); resultMap.put("partNumber", partNumber);
resultMap.put("plateSize", component.getPlateSize());
resultMap.put("height", component.getHeight());
return ResultBean.newOkResult(resultMap);
}
} }
} }
} }
...@@ -709,7 +745,6 @@ public class DeviceController { ...@@ -709,7 +745,6 @@ public class DeviceController {
} }
@ApiOperation("移动物料到另外一个库位") @ApiOperation("移动物料到另外一个库位")
@RequestMapping("/service/store/moveToOtherPos") @RequestMapping("/service/store/moveToOtherPos")
@ResponseBody @ResponseBody
...@@ -726,17 +761,57 @@ public class DeviceController { ...@@ -726,17 +761,57 @@ public class DeviceController {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{needMovePosName, "barcode"}); return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{needMovePosName, "barcode"});
} }
//生成一条出库任务
taskService.addTaskToFinished(needMovePos, barcode, "admin-move");
//判断目标库位是否存在 //判断目标库位是否存在
StoragePos targetPos = storagePosManager.getByPosName(targetPosName); StoragePos targetPos = storagePosManager.getByPosName(targetPosName);
if (targetPos == null) { if (targetPos == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"posName", targetPosName}); return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"posName", targetPosName});
} }
taskService.addTaskToFinished(targetPos, barcode, "admin-move"); //把外侧相同的任务给改成内侧的
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.isCheckOutTask()) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
if (dataLog.getPosId().equals(needMovePos.getId())) {
dataLog.setPosId(targetPos.getId());
dataLog.setPosName(targetPos.getPosName());
taskService.updateQueueTask(dataLog);
log.info(dataLog.getBarcode()+":外测有任务,原始库位为:"+dataLog.getPosName()+"更改后的库位为:"+targetPos.getPosName());
break;
}
}
}
}
//生成一条出库任务
Storage storage = dataCache.getStorageById(needMovePos.getStorageId());
DataLog needMovePosTask = new DataLog(storage, barcode, needMovePos);
needMovePosTask.setOperator("admin-move");
needMovePosTask.setType(OP.CHECKOUT);
needMovePosTask.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(needMovePosTask);
needMovePos.setBarcode(null);
needMovePos.setUsed(false);
storagePosManager.save(needMovePos);
log.info(barcode.getBarcode() + "转移库位,清空仓位: " + needMovePos.getId() + "[" + needMovePos.getPosName() + "]");
dataCache.updateInventory(needMovePos, barcode);
//生成一条入库任务
DataLog targetPosTask = new DataLog(storage, barcode, targetPos);
targetPosTask.setOperator("admin-move");
targetPosTask.setType(OP.PUT_IN);
targetPosTask.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(targetPosTask);
targetPos.setBarcode(barcode);
targetPos.setUsed(true);
targetPos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(targetPos);
log.info(barcode.getBarcode() + "转移库位,入库库位: " + needMovePos.getId() + "[" + needMovePos.getPosName() + "]");
dataCache.updateInventory(targetPos, barcode);
//解除库位绑定
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode()); ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
......
package com.neotel.smfcore.core.device.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Slf4j
@RestController
@Api(tags = "视频控制")
public class VideoController {
@ApiOperation("图片上传接口,客户端调用")
@PostMapping(value = "/service/video/upload")
@ResponseBody
@AnonymousAccess
public ResultBean upload(@RequestBody Map<String, String> params) {
try {
String cid = params.get("cid");
String img = params.get("img");
updateVideo(cid,img);
} catch (Exception e) {
log.error("出错:", e);
return ResultBean.newErrorResult(-1, "", "");
}
return ResultBean.newOkResult("ok");
}
@ApiOperation("图片获取接口,smf调用")
@PostMapping(value = "/service/video/downloading")
@ResponseBody
@AnonymousAccess
public ResultBean downloading(@RequestBody Map<String, String> params) {
try {
String cid = params.get("cid");
String value = getVideo(cid);
return ResultBean.newOkResult(value);
} catch (Exception e) {
log.error("出错:", e);
return ResultBean.newErrorResult(-1, "", "");
}
}
public static String getVideo(String cid) {
String value = videoMap.getOrDefault(cid, "");
if (ObjectUtil.isEmpty(value) && videoMap.size() > 0) {
//默认查找cid_1的视频
String nCid=cid+"_1";
value = videoMap.getOrDefault(nCid, "");
// List<String> keylist = new ArrayList<>(videoMap.keySet());
// Collections.sort(keylist);
// for (String key :
// keylist) {
// if (key.startsWith(cid)) {
// value = videoMap.getOrDefault(key, "");
// }
// }
}
return value;
}
public static void updateVideo(String cid, String img) {
if (videoMap.containsKey(cid)) {
videoMap.remove(cid);
}
videoMap.put(cid, img);
}
public static Map<String, String> videoMap = new HashMap<>();
}
...@@ -123,6 +123,9 @@ public class DataCache { ...@@ -123,6 +123,9 @@ public class DataCache {
initCacheItem(); initCacheItem();
Integer expireDay = getCache(Constants.CACHE_ExpiresDay); Integer expireDay = getCache(Constants.CACHE_ExpiresDay);
codeResolve.updateExpiresDay(expireDay); codeResolve.updateExpiresDay(expireDay);
String apiName = getCache("api.name");
codeResolve.updateUseSizeConfirm("kbd".equals(apiName) ? false : true);
} }
private void initCacheItem() { private void initCacheItem() {
...@@ -662,13 +665,14 @@ public class DataCache { ...@@ -662,13 +665,14 @@ public class DataCache {
* @param amount * @param amount
* @return * @return
*/ */
public int updateInventoryAmount(String cid, String partNumber, int amount) { public int updateInventoryAmount(String cid, String partNumber, int amount,String barcode) {
if (amount != 0) { if (amount != 0) {
InventoryItem inventoryItem = getStorageInventoryByPartNumber(cid, partNumber); InventoryItem inventoryItem = getStorageInventoryByPartNumber(cid, partNumber);
if (inventoryItem == null) { if (inventoryItem == null) {
inventoryItem = new InventoryItem(); inventoryItem = new InventoryItem();
inventoryItem.setPartNumber(partNumber); inventoryItem.setPartNumber(partNumber);
} }
log.info("修改barcode为:"+barcode+",partNumber为:"+ partNumber+"的缓存信息,数量为:"+amount+",盘数+1");
inventoryItem.updateInventory(amount); inventoryItem.updateInventory(amount);
updateStorageInventory(cid, inventoryItem); updateStorageInventory(cid, inventoryItem);
return inventoryItem.getStockReel(); return inventoryItem.getStockReel();
...@@ -705,7 +709,7 @@ public class DataCache { ...@@ -705,7 +709,7 @@ public class DataCache {
updateInOutData(cid, storage.getId(), 1); updateInOutData(cid, storage.getId(), 1);
} }
allStorage.put(cid, storage); allStorage.put(cid, storage);
return updateInventoryAmount(cid, partNumber, amount); return updateInventoryAmount(cid, partNumber, amount,barcode.getBarcode());
} }
private void updateStorageInventory(String cid, InventoryItem inventoryItem) { private void updateStorageInventory(String cid, InventoryItem inventoryItem) {
......
...@@ -45,10 +45,30 @@ public class EquipStatusBean implements Serializable { ...@@ -45,10 +45,30 @@ public class EquipStatusBean implements Serializable {
/** /**
* 仅显示的日志消息集合
*/
private List<EquipMsg> showLogs = new ArrayList<>();
/**
* 发上来的数据 * 发上来的数据
*
* NS200定义:
* key=tPCount,value=今天已打印数量
* key=tNGCount,value=今天NG数量
* key=MES,value=MES最后一次对接信息:格式参考NsMesInfo
*
* key=inShelfStatus ,value=入口料串状态:
* key=outShelfStatus ,value=出口料串状态:
*/ */
private Map<String, Object> data = new HashMap<>(); private Map<String, Object> data = new HashMap<>();
// 料串状态定义 IDLE=空闲;
// LOADING=入库中;
// UNLOADING=出库中;
// NEED_EMPTY=需要空料串出库;
// EMPTY_OUT=空料串需要取走
// FULL_OUT=满料串需要取走
/** /**
* 离线时间,用于判断是否已经处理过离线 * 离线时间,用于判断是否已经处理过离线
*/ */
...@@ -114,5 +134,17 @@ public class EquipStatusBean implements Serializable { ...@@ -114,5 +134,17 @@ public class EquipStatusBean implements Serializable {
return null; return null;
} }
public String getShowMsg(Locale locale){
MessageType[] types=new MessageType[]{MessageType.ERROR,MessageType.WARNING,MessageType.INFO,MessageType.SHOW };
for (MessageType type :
types) {
EquipMsg showMsg= getMsgByType(type.name());
if(showMsg!=null){
return showMsg.getShowMsg(locale);
}
}
return "";
}
} }
...@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.equipment.handler.impl; ...@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.equipment.handler.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.core.agv.util.AgvCache; import com.neotel.smfcore.core.agv.util.AgvCache;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.equipment.bean.EquipMsg; import com.neotel.smfcore.core.equipment.bean.EquipMsg;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean; import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.equipment.enums.EquipmentType; import com.neotel.smfcore.core.equipment.enums.EquipmentType;
...@@ -73,6 +74,18 @@ public class BaseEquipHandler implements IEquipmentHandler { ...@@ -73,6 +74,18 @@ public class BaseEquipHandler implements IEquipmentHandler {
} }
} }
} }
if(statusBean.getData().containsKey("MES")) {
try {
MesInfoDto mesInfo = (MesInfoDto) statusBean.getData().get("MES");
if(mesInfo!=null){
EquipStatusUtil.updateNsMesInfo(statusBean.getCid(),mesInfo);
}
} catch (Exception ex) {
log.error(""+ex);
}
}
EquipStatusUtil.updateStatusBean(statusBean); EquipStatusUtil.updateStatusBean(statusBean);
} catch (Exception e) { } catch (Exception e) {
......
package com.neotel.smfcore.core.equipment.rest; package com.neotel.smfcore.core.equipment.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.EquipmentCache; import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean; import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.equipment.enums.EquipmentType; import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.handler.IEquipmentHandler; import com.neotel.smfcore.core.equipment.handler.IEquipmentHandler;
...@@ -53,10 +54,19 @@ public class EquipCommunicationController { ...@@ -53,10 +54,19 @@ public class EquipCommunicationController {
return null; return null;
} }
} else { } else {
if (StringUtils.isNotBlank(name)){ if (StringUtils.isNotBlank(name)) {
if (!name.equals(equipment.getName())){ if (!name.equals(equipment.getName())) {
log.info("自动修改设备 cid[" + equipment.getCid() + "] name[" + equipment.getName() + "] 的名字为=" + name);
equipment.setName(name); equipment.setName(name);
equipment = equipmentCache.reloadEquipment(equipment,equipment.getCid()); equipment = equipmentCache.reloadEquipment(equipment, equipment.getCid());
}
}
String type = statusBean.getType();
if (ObjectUtil.isNotEmpty(type)) {
if (!type.equals(equipment.getType())) {
log.info("自动修改设备 cid[" + equipment.getCid() + "] type [" + equipment.getType() + "] 的类型为=" + type);
equipment.setType(type);
equipment = equipmentCache.reloadEquipment(equipment, equipment.getCid());
} }
} }
} }
......
package com.neotel.smfcore.core.equipment.rest; package com.neotel.smfcore.core.equipment.rest;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.device.util.EquipmentCache; import com.neotel.smfcore.core.equipment.rest.dto.NsViewDto;
import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.equipment.bean.EquipMsg; import com.neotel.smfcore.core.equipment.bean.EquipMsg;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean; import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.equipment.bean.EquipStatusDto; import com.neotel.smfcore.core.equipment.rest.dto.EquipStatusDto;
import com.neotel.smfcore.core.equipment.service.po.Equipment; ; import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.message.enums.MessageType; import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.service.po.Message;
import com.neotel.smfcore.core.storage.enums.DeviceType; 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.Storage;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil; import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
...@@ -58,23 +60,7 @@ public class EquipViewController { ...@@ -58,23 +60,7 @@ public class EquipViewController {
}else{ }else{
dto.setOnLine(true); dto.setOnLine(true);
dto.setStatus(bean.getStatus()); dto.setStatus(bean.getStatus());
EquipMsg showMsg= bean.getMsgByType(MessageType.ERROR.name()); dto.setMsg(bean.getShowMsg(locale));
if(showMsg==null){
showMsg=bean.getMsgByType(MessageType.WARNING.name());
}
if(showMsg==null){
showMsg=bean.getMsgByType(MessageType.INFO.name());
}
if(showMsg!=null){
dto.setMsg(showMsg.getShowMsg(locale));
}
// if(bean.getMsgList()!=null){
// for (EquipMsg msg : bean.getMsgList()){
// if(msg.getType().equals(MessageType.ERROR.name())){
// dto.setMsg(msg.getShowMsg(locale));
// }
// }
// }
} }
} }
...@@ -99,4 +85,50 @@ public class EquipViewController { ...@@ -99,4 +85,50 @@ public class EquipViewController {
} }
return resultList; return resultList;
} }
@ApiOperation("获取NS看板数据")
@GetMapping("nsView")
@PreAuthorize("@el.check('equipmentView:info')")
public NsViewDto nsView(String cid, HttpServletRequest servletRequest){
Equipment equip = equipmentCache.getEquipment(cid);
if (equip == null ||(!equip.isNEOSCAN())) {
throw new ValidateException("smfcore.equip.notExist","设备不存在");
}
NsViewDto dto=new NsViewDto();
dto.setCid(cid);
dto.setName(equip.getName());
EquipStatusBean bean= EquipStatusUtil.getStatusBean(equip.getCid());
if(bean!=null){
if(bean.timeOut()){
dto.setStatus(0);
}else{
dto.setStatus(bean.getStatus());
dto.setMsg(bean.getShowMsg(servletRequest.getLocale()));
dto.setData(bean.getData());
dto.setShowLogs(bean.getShowLogs());
MesInfoDto mesInfo=EquipStatusUtil.getNsMesInfo(cid);
if(mesInfo!=null){
dto.setMesInfo(mesInfo);
}
}
}
// if(dto.getShowLogs().size()<=0){
// EquipMsg msg=new EquipMsg();
// msg.setModule("module1");
// msg.setMsg("msg1111111111111111111");
// dto.getShowLogs().add(msg);
// }
if(dto.getMesInfo()==null){
MesInfoDto mesInfoDto=EquipStatusUtil.getLastAgvInfo(cid);
if(mesInfoDto!=null){
dto.setAgvInfo(mesInfoDto);
}
}
return dto;
}
} }
package com.neotel.smfcore.core.equipment.bean; package com.neotel.smfcore.core.equipment.rest.dto;
import com.neotel.smfcore.core.equipment.enums.EquipmentType; import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
package com.neotel.smfcore.core.equipment.rest.dto;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.equipment.bean.EquipMsg;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class NsViewDto implements Serializable {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("CID")
private String cid;
@ApiModelProperty("设备状态,0=离线,1=正常运行中, 2=急停")
private int status=0;
@ApiModelProperty("文字显示")
private String msg = "";
@ApiModelProperty("Mes信息")
private MesInfoDto mesInfo = null;
@ApiModelProperty("agv通信信息")
private MesInfoDto agvInfo = null;
@ApiModelProperty("仅显示的日志消息集合")
private List<EquipMsg> showLogs = new ArrayList<>();
/**
* 发上来的数据
*
* NS200定义:
* key=tPCount,value=今天已打印数量
* key=tNGCount,value=今天NG数量
* key=MES,value=MES最后一次对接信息:格式参考NsMesInfo
*/
private Map<String, Object> data = new HashMap<>();
}
...@@ -26,4 +26,8 @@ public class Equipment extends BasePo implements Serializable { ...@@ -26,4 +26,8 @@ public class Equipment extends BasePo implements Serializable {
* 是否可用 * 是否可用
*/ */
private boolean available = true; private boolean available = true;
public boolean isNEOSCAN() {
return EquipmentType.NEOSCAN.name().equals(type);
}
} }
package com.neotel.smfcore.core.device.util; package com.neotel.smfcore.core.equipment.util;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
...@@ -87,7 +87,7 @@ public class EquipmentCache { ...@@ -87,7 +87,7 @@ public class EquipmentCache {
} }
} }
public Equipment autoCreateEquip(String name,String cid, String type) { public synchronized Equipment autoCreateEquip(String name,String cid, String type) {
//判断cid存在 //判断cid存在
Equipment equipment = null; Equipment equipment = null;
equipment = getEquipment(cid); equipment = getEquipment(cid);
......
...@@ -48,6 +48,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -48,6 +48,7 @@ import javax.servlet.http.HttpServletRequest;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -91,6 +92,7 @@ public class BoxKanbanController { ...@@ -91,6 +92,7 @@ public class BoxKanbanController {
for (Group group : groupList) { for (Group group : groupList) {
List<BoxStatusDto> boxStatusDtos = new ArrayList<>(); List<BoxStatusDto> boxStatusDtos = new ArrayList<>();
List<String> cidList =dataCache. getCidsByGroupId(group.getId(), false); List<String> cidList =dataCache. getCidsByGroupId(group.getId(), false);
Collections.sort(cidList);
int groupType=0; int groupType=0;
for (String cid : cidList) { for (String cid : cidList) {
Storage storage=dataCache.getStorage(cid); Storage storage=dataCache.getStorage(cid);
...@@ -105,6 +107,7 @@ public class BoxKanbanController { ...@@ -105,6 +107,7 @@ public class BoxKanbanController {
} }
} }
if(boxStatusDtos.size()>0){ if(boxStatusDtos.size()>0){
boxStatusDtos = boxStatusDtos.stream().sorted(Comparator.comparing(BoxStatusDto :: getName)).collect(Collectors.toList());
GroupStatusDto groupStatusDto = new GroupStatusDto(group.getId(),group.getGroupName(),boxStatusDtos,groupType); GroupStatusDto groupStatusDto = new GroupStatusDto(group.getId(),group.getGroupName(),boxStatusDtos,groupType);
groupStatusDtos.add(groupStatusDto); groupStatusDtos.add(groupStatusDto);
} }
...@@ -420,8 +423,8 @@ public class BoxKanbanController { ...@@ -420,8 +423,8 @@ 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","0", "", allCount, inTask, outTask, "0", "0", "0", "", allCount, inTask, outTask,
0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName()); 0, "", "", "", "", "", storage.getType(), storage.getUsageMap(), new HashMap<>(), storage.getInListName());
//获取设备状态,设置状态和当前任务信息 //获取设备状态,设置状态和当前任务信息
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid()); StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
...@@ -429,7 +432,7 @@ public class BoxKanbanController { ...@@ -429,7 +432,7 @@ public class BoxKanbanController {
boxDto.setOnLine(false); boxDto.setOnLine(false);
//如果是虚拟仓,默认在线 //如果是虚拟仓,默认在线
if(storage.isVirtual()){ if (storage.isVirtual()) {
boxDto.setOnLine(true); boxDto.setOnLine(true);
boxDto.setStatus(1); boxDto.setStatus(1);
} }
...@@ -482,16 +485,16 @@ public class BoxKanbanController { ...@@ -482,16 +485,16 @@ public class BoxKanbanController {
} }
} }
//如果是锡膏料仓,需要把回温区物料数量,冷藏区物料数量显示 //如果是锡膏料仓,需要把回温区物料数量,冷藏区物料数量显示
if(storage.isSolderPaste()){ if (storage.isSolderPaste()) {
Integer warmUseCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.warmPosUseCount); Integer warmUseCount = dataCache.getSpUsePosCount(storage.getCid(), DataCache.warmPosUseCount);
Integer coldingUseCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.coldingPosUseCount); Integer coldingUseCount = dataCache.getSpUsePosCount(storage.getCid(), DataCache.coldingPosUseCount);
boxDto.getData().put(DataCache.warmPosUseCount,warmUseCount.toString()); boxDto.getData().put(DataCache.warmPosUseCount, warmUseCount.toString());
boxDto.getData().put(DataCache.coldingPosUseCount,coldingUseCount.toString()); boxDto.getData().put(DataCache.coldingPosUseCount, coldingUseCount.toString());
Integer warmCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.warmPosCount); Integer warmCount = dataCache.getSpUsePosCount(storage.getCid(), DataCache.warmPosCount);
Integer coldingCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.coldingPosCount); Integer coldingCount = dataCache.getSpUsePosCount(storage.getCid(), DataCache.coldingPosCount);
boxDto.getData().put(DataCache.warmPosCount,warmCount.toString()); boxDto.getData().put(DataCache.warmPosCount, warmCount.toString());
boxDto.getData().put(DataCache.coldingPosCount,coldingCount.toString()); boxDto.getData().put(DataCache.coldingPosCount, coldingCount.toString());
} }
return boxDto; return boxDto;
} }
......
...@@ -360,6 +360,9 @@ public class LanguageMsgService { ...@@ -360,6 +360,9 @@ public class LanguageMsgService {
} }
if (isUpdate) { if (isUpdate) {
if (isNeedUpdate) {
oldMsg.setEdited(true);
}
updateLanguageList.add(oldMsg); updateLanguageList.add(oldMsg);
languageMsgManager.save(oldMsg); languageMsgManager.save(oldMsg);
MessageUtils.updateMsg(oldMsg); MessageUtils.updateMsg(oldMsg);
......
...@@ -21,4 +21,8 @@ public enum MessageType { ...@@ -21,4 +21,8 @@ public enum MessageType {
* 3 设备操作数据 * 3 设备操作数据
*/ */
DATA, DATA,
/**
* 4 显示数据,仅显示不保存
*/
SHOW,
} }
...@@ -3,7 +3,7 @@ package com.neotel.smfcore.core.message.util; ...@@ -3,7 +3,7 @@ package com.neotel.smfcore.core.message.util;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.device.util.EquipmentCache; import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.equipment.service.po.Equipment; import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.language.util.MessageUtils; import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.enums.MessageType; import com.neotel.smfcore.core.message.enums.MessageType;
...@@ -14,8 +14,6 @@ import com.neotel.smfcore.core.message.util.bean.DeviceInfo; ...@@ -14,8 +14,6 @@ import com.neotel.smfcore.core.message.util.bean.DeviceInfo;
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;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil; import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
......
package com.neotel.smfcore.core.msd.rest; package com.neotel.smfcore.core.msd.rest;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
...@@ -87,6 +88,12 @@ public class MSDController { ...@@ -87,6 +88,12 @@ public class MSDController {
@GetMapping("/settings") @GetMapping("/settings")
@PreAuthorize("@el.check('msd')") @PreAuthorize("@el.check('msd')")
public MSDSettiingsDto getSysSettings() { public MSDSettiingsDto getSysSettings() {
MSDSettiings msdSettiings=getSetting();
MSDSettiingsDto dto = msdSettingsMapper.toDto(msdSettiings);
return dto;
}
private MSDSettiings getSetting(){
MSDSettiings msdSettiings = dataCache.getCache(Constants.CACHE_msdSetting); MSDSettiings msdSettiings = dataCache.getCache(Constants.CACHE_msdSetting);
if(msdSettiings==null){ if(msdSettiings==null){
msdSettiings=new MSDSettiings() ; msdSettiings=new MSDSettiings() ;
...@@ -105,8 +112,7 @@ public class MSDController { ...@@ -105,8 +112,7 @@ public class MSDController {
dataCache.updateCache(Constants.CACHE_msdSetting, msdSettiings); dataCache.updateCache(Constants.CACHE_msdSetting, msdSettiings);
log.info("默认MSD:CACHE_msdSetting=" + msdSettiings.toString()); log.info("默认MSD:CACHE_msdSetting=" + msdSettiings.toString());
} }
MSDSettiingsDto dto = msdSettingsMapper.toDto(msdSettiings); return msdSettiings;
return dto;
} }
@ApiOperation("修改MSD设置信息") @ApiOperation("修改MSD设置信息")
...@@ -116,11 +122,11 @@ public class MSDController { ...@@ -116,11 +122,11 @@ public class MSDController {
MSDSettiings settiings = msdSettingsMapper.toEntity(msdSettiingsDto); MSDSettiings settiings = msdSettingsMapper.toEntity(msdSettiingsDto);
if (settiings.getMaxHumidity() <= settiings.getMinHumidity()) { if (settiings.getMaxHumidity() <= settiings.getMinHumidity()) {
throw new ValidateException("smfcore.humidityValueError", "温度范围数据错误"); throw new ValidateException("smfcore.temperatureValueError", "湿度范围数据错误");
} }
if (settiings.getMaxTemperature() <= settiings.getMinTemperature()) { if (settiings.getMaxTemperature() <= settiings.getMinTemperature()) {
throw new ValidateException("smfcore.temperatureValueError", "湿度范围数据错误"); throw new ValidateException("smfcore.humidityValueError", "温度范围数据错误");
} }
dataCache.updateCache(Constants.CACHE_msdSetting, settiings); dataCache.updateCache(Constants.CACHE_msdSetting, settiings);
log.info("更改MSD:CACHE_msdSetting=" + settiings.toString()); log.info("更改MSD:CACHE_msdSetting=" + settiings.toString());
...@@ -128,6 +134,47 @@ public class MSDController { ...@@ -128,6 +134,47 @@ public class MSDController {
} }
@ApiOperation("修改MSD设置预警湿度信息")
@PutMapping("/settings/maxHumidity")
@PreAuthorize("@el.check('msd')")
public ResultBean updateMaxHumidity(String maxHumidityStr) {
float maxHumidity=0;
try{
maxHumidity= Convert.toFloat(maxHumidityStr);
}catch (Exception ex){
throw new ValidateException("smfcore.temperatureValueError", "湿度范围数据错误");
}
MSDSettiings settiings =getSetting();
settiings.setMaxHumidity(maxHumidity);
if (settiings.getMaxHumidity() <= settiings.getMinHumidity()) {
throw new ValidateException("smfcore.temperatureValueError", "湿度范围数据错误");
}
dataCache.updateCache(Constants.CACHE_msdSetting, settiings);
log.info("更改MSD maxHumidity:CACHE_msdSetting=" + settiings.toString());
return ResultBean.newOkResult("保存成功");
}
@ApiOperation("修改MSD设置预警溫度信息")
@PutMapping("/settings/maxTemperature")
@PreAuthorize("@el.check('msd')")
public ResultBean updateMaxTemperature(String maxTemperatureStr) {
float maxTemperature=0;
try{
maxTemperature= Convert.toFloat(maxTemperatureStr);
}catch (Exception ex){
throw new ValidateException("smfcore.temperatureValueError", "湿度范围数据错误");
}
MSDSettiings settiings =getSetting();
settiings.setMaxTemperature(maxTemperature);
if (settiings.getMaxTemperature() <= settiings.getMinTemperature()) {
throw new ValidateException("smfcore.humidityValueError", "温度范围数据错误");
}
dataCache.updateCache(Constants.CACHE_msdSetting, settiings);
log.info("更改MSD maxTemperature:CACHE_msdSetting=" + settiings.toString());
return ResultBean.newOkResult("保存成功");
}
@ApiOperation("MSD库存数据查询") @ApiOperation("MSD库存数据查询")
@GetMapping("/query") @GetMapping("/query")
@PreAuthorize("@el.check('msd')") @PreAuthorize("@el.check('msd')")
......
...@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service; ...@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/** /**
* Created by sunke on 2021/7/12. * Created by sunke on 2021/7/12.
...@@ -70,9 +71,11 @@ public class LiteOrderCache { ...@@ -70,9 +71,11 @@ public class LiteOrderCache {
List<LiteOrder> unEndOutInfoList = liteOrderManager.findUnEndOrdersList(); List<LiteOrder> unEndOutInfoList = liteOrderManager.findUnEndOrdersList();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
for (LiteOrder order : unEndOutInfoList) { for (LiteOrder order : unEndOutInfoList) {
if (now - order.getCreateDate().getTime() > 7 * 24 * 60 * 60 * 1000) { long v1=now - order.getCreateDate().getTime();
long v2= 30 * 24 * 60 * 60 * 1000L;
if (now - order.getCreateDate().getTime() > v2) {
//7天前的需求单,关闭,并解绑 //7天前的需求单,关闭,并解绑
log.info("需求单 =[" + order.getOrderNo() + "]为7天前,关闭并解绑工单"); log.info("需求单 =[" + order.getOrderNo() + "],创建日期:["+order.getCreateDate().toString()+"]为30天前,关闭并解绑工单");
closeOrder(order.getOrderNo()); closeOrder(order.getOrderNo());
} else { } else {
...@@ -488,7 +491,7 @@ public class LiteOrderCache { ...@@ -488,7 +491,7 @@ public class LiteOrderCache {
int remainReelCount = orderItem.getNeedReelCount() - orderItem.getTotalOutReelCount(); int remainReelCount = orderItem.getNeedReelCount() - orderItem.getTotalOutReelCount();
//此PN未完成 //此PN未完成
if (remainNum > 0) { if (remainNum > 0 || remainReelCount > 0) {
if (outBom) { if (outBom) {
//套料出库,设置剩余数量为1,这样就只会出一盘 //套料出库,设置剩余数量为1,这样就只会出一盘
remainNum = 1; remainNum = 1;
...@@ -712,8 +715,8 @@ public class LiteOrderCache { ...@@ -712,8 +715,8 @@ public class LiteOrderCache {
LiteOrder order = liteOrderManager.get(sourceId); LiteOrder order = liteOrderManager.get(sourceId);
if (order != null && order.getOrderItems().size() > 0) { if (order != null && order.getOrderItems().size() > 0) {
List<LiteOrderItem> list = order.getOrderItems(); List<LiteOrderItem> list = order.getOrderItems();
//根据站位号排序 //根据站位号和id排序
Collections.sort(list); list = list.stream().sorted(Comparator.comparing(LiteOrderItem::getSlotNum).thenComparing(LiteOrderItem::getId)).collect(Collectors.toList());
order.setOrderItems(list); order.setOrderItems(list);
return order; return order;
} }
......
...@@ -31,12 +31,12 @@ public enum ORDER_COLOR { ...@@ -31,12 +31,12 @@ public enum ORDER_COLOR {
// 'magenta':[17,125,125,0] // 'magenta':[17,125,125,0]
BLUE("0000FF"), BLUE("0000FF"),
//MAGENTA("FF00FF"), //MAGENTA("FF00FF"),
//CYAN("00FFFF"), CYAN("00FFFF"),
FIREBRICK("B22222"), FIREBRICK("B22222"),
PURPLE("A020F0"), PURPLE("A020F0"),
//SKYBLUE("6CA6CD"), //SKYBLUE("6CA6CD"),
//PINK("FF1493"), //PINK("FF1493"),
//FORESTGREEN("228B22"), FORESTGREEN("228B22"),
//LIGHTBLUE("8470FF"), //LIGHTBLUE("8470FF"),
//INDIANRED("8B3A3A"), //INDIANRED("8B3A3A"),
DARKGREEN("556B2F"), DARKGREEN("556B2F"),
...@@ -73,7 +73,7 @@ public enum ORDER_COLOR { ...@@ -73,7 +73,7 @@ public enum ORDER_COLOR {
public static ORDER_COLOR nextColor(Collection<String> excludeColors){ public static ORDER_COLOR nextColor(Collection<String> excludeColors){
excludeColors.add(ORDER_COLOR.BLUE.getRgb());//手动出库 excludeColors.add(ORDER_COLOR.BLUE.getRgb());//手动出库
excludeColors.add(ORDER_COLOR.DARKGREEN.getRgb());//入库 excludeColors.add(ORDER_COLOR.FORESTGREEN.getRgb());//入库
ORDER_COLOR[] allColors = values(); ORDER_COLOR[] allColors = values();
if (excludeColors.size() >= allColors.length){ if (excludeColors.size() >= allColors.length){
......
...@@ -84,8 +84,8 @@ public class DefaultOrderFileListener implements IOrderFileListener { ...@@ -84,8 +84,8 @@ public class DefaultOrderFileListener implements IOrderFileListener {
liteOrderCache.addOrderToMap(liteOrder); liteOrderCache.addOrderToMap(liteOrder);
//resultFile = new File(localDir+File.separator + "sucess",backupFileName); //resultFile = new File(localDir+File.separator + "sucess",backupFileName);
return true;
} }
return true;
} }
}catch (Exception e){ }catch (Exception e){
log.error("read order from file ["+orderFile.getAbsolutePath()+"] :",e); log.error("read order from file ["+orderFile.getAbsolutePath()+"] :",e);
......
...@@ -572,14 +572,14 @@ public class OrderController { ...@@ -572,14 +572,14 @@ public class OrderController {
findItem.setTotalOutNum(findItem.getTotalOutNum() + num); findItem.setTotalOutNum(findItem.getTotalOutNum() + num);
findItem.setOutReelCount(findItem.getOutReelCount() + 1); findItem.setOutReelCount(findItem.getOutReelCount() + 1);
findItem.setTotalOutReelCount(findItem.getTotalOutReelCount() + 1); findItem.setTotalOutReelCount(findItem.getTotalOutReelCount() + 1);
findItem.setNeedReelCount(findItem.getNeedReelCount() + 1); //findItem.setNeedReelCount(findItem.getNeedReelCount() + 1);
liteOrderItemManager.save(findItem); liteOrderItemManager.save(findItem);
liteOrder.updateOrderItems(findItem); liteOrder.updateOrderItems(findItem);
//工单未关闭的话,检查状态,全部都出完进行关闭 //工单未关闭的话,检查状态,全部都出完进行关闭
boolean closed = true; boolean closed = true;
for (LiteOrderItem liteOrderItem : liteOrder.getOrderItems()) { for (LiteOrderItem liteOrderItem : liteOrder.getOrderItems()) {
if (!liteOrderItem.isOutFinished()) { if (!liteOrderItem.isOutFinished() || !liteOrderItem.isOutReelFinished()) {
closed = false; closed = false;
break; break;
} }
...@@ -670,10 +670,16 @@ public class OrderController { ...@@ -670,10 +670,16 @@ public class OrderController {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"orderNo"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"orderNo"});
} }
LiteOrder liteOrder = smfApi.fetchOrder(orderNo, SecurityUtils.getCurrentUsername()); //判断工单是否存在
LiteOrder liteOrder = liteOrderManager.findByOrderNo(orderNo);
if (liteOrder != null){
throw new ValidateException("smfcore.order.ameExists", "工单名称[{0}]已存在",new String[]{orderNo});
}
//从api获取
liteOrder = smfApi.fetchOrder(orderNo, SecurityUtils.getCurrentUsername());
if (liteOrder == null) { if (liteOrder == null) {
throw new ValidateException("smfcore.api.noUrl", "未配置API地址"); throw new ValidateException("smfcore.order.out.notFound", "工单未找到");
} }
OrderDto dto = orderMapper.toDto(liteOrder); OrderDto dto = orderMapper.toDto(liteOrder);
......
...@@ -65,7 +65,9 @@ public class OrderItemDto { ...@@ -65,7 +65,9 @@ public class OrderItemDto {
*/ */
private int inventoryReelCount = 0; private int inventoryReelCount = 0;
private int totalOutNum = 0;
private int totalOutReelCount = 0;
// Inventory Quantity // Inventory Quantity
// Inventory Reel / Bundle count // Inventory Reel / Bundle count
......
...@@ -337,14 +337,15 @@ public class SpBoxHandler extends BaseDeviceHandler { ...@@ -337,14 +337,15 @@ public class SpBoxHandler extends BaseDeviceHandler {
//回温取料任务 //回温取料任务
statusBean.setOp(OP.REWARM_TAKING); statusBean.setOp(OP.REWARM_TAKING);
statusBean.addData("posId", task.getPosName()); statusBean.addData("posId", task.getPosName());
statusBean.addData("plateW", task.getW()+"");
statusBean.addData("plateH", task.getH()+"");
DataLog rewarmPuttingTask = findRewarmPuttingTask(task); DataLog rewarmPuttingTask = findRewarmPuttingTask(task);
if (rewarmPuttingTask == null) { if (rewarmPuttingTask == null) {
log.error("[" + cid + "]回温取料任务[" + task.getBarcode() + "][" + task.getPosName() + "]未找到回温放料任务"); log.error("[" + cid + "]回温取料任务[" + task.getBarcode() + "][" + task.getPosName() + "]未找到回温放料任务");
} else { } else {
statusBean.addData("secondPosId", rewarmPuttingTask.getPosName()); statusBean.addData("secondPosId", rewarmPuttingTask.getPosName());
log.info(task.getBarcode() + "回温移库信息发送到客户端[" + task.getPosName() + "]=>" + rewarmPuttingTask.getPosName()); log.info(task.getBarcode() + "回温移库信息发送到客户端[" + task.getPosName() + "]=>" + rewarmPuttingTask.getPosName()+",W:"+task.getW()+",H:"+task.getH());
rewarmPuttingTask.setStatus(OP_STATUS.EXECUTING.name()); rewarmPuttingTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(rewarmPuttingTask); taskService.updateQueueTask(rewarmPuttingTask);
......
...@@ -19,12 +19,14 @@ import com.neotel.smfcore.core.device.enums.OP; ...@@ -19,12 +19,14 @@ import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.util.MessageUtils; import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.solder.rest.bean.dto.SpTaskDto; import com.neotel.smfcore.core.solder.rest.bean.dto.SpTaskDto;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.rest.dto.CheckOutDto; import com.neotel.smfcore.core.storage.rest.dto.CheckOutDto;
import com.neotel.smfcore.core.storage.rest.dto.InventoryItemDto; import com.neotel.smfcore.core.storage.rest.dto.InventoryItemDto;
import com.neotel.smfcore.core.storage.rest.dto.StoragePosDto; import com.neotel.smfcore.core.storage.rest.dto.StoragePosDto;
import com.neotel.smfcore.core.storage.rest.mapstruct.StoragePosMapper; import com.neotel.smfcore.core.storage.rest.mapstruct.StoragePosMapper;
import com.neotel.smfcore.core.storage.rest.query.StoragePosFindCriteria; import com.neotel.smfcore.core.storage.rest.query.StoragePosFindCriteria;
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.manager.impl.StoragePosManagerImpl;
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;
import com.neotel.smfcore.core.system.rest.bean.query.TaskQueryCondition; import com.neotel.smfcore.core.system.rest.bean.query.TaskQueryCondition;
...@@ -71,6 +73,9 @@ public class SpBoxController { ...@@ -71,6 +73,9 @@ public class SpBoxController {
private IComponentManager componentManager; private IComponentManager componentManager;
@Autowired
private StoragePosManagerImpl posManager;
@ApiOperation("锡膏UID出库") @ApiOperation("锡膏UID出库")
@GetMapping("/uidList") @GetMapping("/uidList")
@PreAuthorize("@el.check('checkOut')") @PreAuthorize("@el.check('checkOut')")
...@@ -252,8 +257,10 @@ public class SpBoxController { ...@@ -252,8 +257,10 @@ public class SpBoxController {
} }
Query q = new Query(c); Query q = new Query(c);
q.limit(num); q.limit(num);
CHECKOUT_TYPE checkoutType = dataCache.getCheckOutType();
Sort sort =storagePosManager.getSortByCheckOutType(checkoutType);
//优先使用二次入库的 //优先使用二次入库的
q.with(Sort.by(Sort.Direction.ASC, "barcode.solderStatus").and(Sort.by(Sort.Direction.ASC, "barcode.putInTime"))); q.with(Sort.by(Sort.Direction.ASC, "barcode.solderStatus").and(sort));
return storagePosManager.findByQuery(q); return storagePosManager.findByQuery(q);
} }
...@@ -262,8 +269,11 @@ public class SpBoxController { ...@@ -262,8 +269,11 @@ public class SpBoxController {
public List<SpTaskDto> filterTask(TaskQueryCondition criteria, HttpServletRequest request) { public List<SpTaskDto> filterTask(TaskQueryCondition criteria, HttpServletRequest request) {
String storageId = criteria.getStorageId(); String storageId = criteria.getStorageId();
if(ObjectUtil.isEmpty(storageId)){
return new ArrayList<>();
}
Storage storage = dataCache.getStorageById(storageId); Storage storage = dataCache.getStorageById(storageId);
if (!storage.isSolderPaste()) { if (storage==null|| !storage.isSolderPaste()) {
return new ArrayList<>(); return new ArrayList<>();
} }
Criteria c = Criteria.where("storageId").is(storageId) Criteria c = Criteria.where("storageId").is(storageId)
......
...@@ -258,6 +258,8 @@ public class SolderBoxCache { ...@@ -258,6 +258,8 @@ public class SolderBoxCache {
puttingTask.setType(OP.REWARM_PUTTING); puttingTask.setType(OP.REWARM_PUTTING);
//puttingTask = dataLogDao.save(puttingTask); //puttingTask = dataLogDao.save(puttingTask);
taskService.addTaskToExecute(puttingTask); taskService.addTaskToExecute(puttingTask);
}else{
log.error(barcode.getBarcode() + "创建回温移库任务失败:未找到回温库位");
} }
} catch (ValidateException e) { } catch (ValidateException e) {
log.info(barcode.getBarcode() + "查找回温库位失败"); log.info(barcode.getBarcode() + "查找回温库位失败");
......
...@@ -137,7 +137,13 @@ public enum DeviceType { ...@@ -137,7 +137,13 @@ public enum DeviceType {
/** /**
* 22 钢网料架 NLS * 22 钢网料架 NLS
*/ */
NLS("storage.type.nls"); NLS("storage.type.nls"),
/**
* 23 SMD_MIMO_G2
*/
SMD_MIMO_G2("storage.type.smdMimoG2")
;
private String key; private String key;
...@@ -158,6 +164,6 @@ public enum DeviceType { ...@@ -158,6 +164,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,SMD_XLR,VIRTUAL,NL,NLP,NLM,NLL,NLS,SMDBOX_THIRD); return Lists.newArrayList(AUTO,LINE,BATCH,SOLDERPASTE,VERTICALBOX,SMD_XL,SMD_DUO,SMD_XLC,SMD_XLR,VIRTUAL,NL,NLP,NLM,NLL,NLS,SMDBOX_THIRD,SMD_MIMO_G2);
} }
} }
...@@ -24,6 +24,7 @@ import com.neotel.smfcore.core.storage.service.po.Label; ...@@ -24,6 +24,7 @@ import com.neotel.smfcore.core.storage.service.po.Label;
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;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.service.manager.IGroupManager; import com.neotel.smfcore.security.service.manager.IGroupManager;
import com.neotel.smfcore.security.service.po.Group; import com.neotel.smfcore.security.service.po.Group;
...@@ -364,6 +365,16 @@ public class MaterialController { ...@@ -364,6 +365,16 @@ public class MaterialController {
String opUser = SecurityUtils.getCurrentUsername(); String opUser = SecurityUtils.getCurrentUsername();
log.info(opUser + "清理库位[" + storagePos.getPosName() + "],条码[" + code + "]中的库存" + barcode.getBarcode()); log.info(opUser + "清理库位[" + storagePos.getPosName() + "],条码[" + code + "]中的库存" + barcode.getBarcode());
taskService.addTaskToFinished(storagePos, null, opUser + "-manual"); taskService.addTaskToFinished(storagePos, null, opUser + "-manual");
//如果是料架,库位灭灯
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
if (storage != null){
if (storage.isShelf() || storage.isNLShelf() || storage.isNLPShelf() || storage.isNLMShelf()){
String opKey = "close";
String opStr = storagePos.getPosName();
DevicesStatusUtil.appendOp(storage.getCid(), opKey , opStr);
log.info("操作库位["+storagePos.getPosName()+"]" + opKey + " : " + opStr);
}
}
} else { } else {
log.info("清理库位[" + storagePos.getPosName() + "],条码[" + code + "],库位条码为空"); log.info("清理库位[" + storagePos.getPosName() + "],条码[" + code + "],库位条码为空");
} }
......
...@@ -336,8 +336,8 @@ public class MaterialStockController { ...@@ -336,8 +336,8 @@ public class MaterialStockController {
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put(partNumberStr, item.getPartNumber()); map.put(partNumberStr, item.getPartNumber());
map.put(countStr, item.getStockCount()); map.put(countStr, item.getStockCount());
map.put(lockReelStr, item.getLockReel()); map.put(stockReelStr, item.getStockReel());
map.put(stockReelStr, item.getSupplementReel()); map.put(lockReelStr, item.getSupplementReel());
map.put(storageNameStr, item.getAmount()); map.put(storageNameStr, item.getAmount());
maps.add(map); maps.add(map);
} }
......
...@@ -476,6 +476,7 @@ public class StorageController { ...@@ -476,6 +476,7 @@ public class StorageController {
int wIndex = csvRead.getCsvIndex("宽度","w"); int wIndex = csvRead.getCsvIndex("宽度","w");
int warmPosIndex = csvRead.getHasCsvIndex("回温库位","warmPos");//true表示回温区库位, int warmPosIndex = csvRead.getHasCsvIndex("回温库位","warmPos");//true表示回温区库位,
int areaIndex = csvRead.getHasCsvIndex("区域","area"); int areaIndex = csvRead.getHasCsvIndex("区域","area");
int posTypeIndex = csvRead.getHasCsvIndex("库位类型","posType");
int row = 1; int row = 1;
...@@ -493,6 +494,7 @@ public class StorageController { ...@@ -493,6 +494,7 @@ public class StorageController {
Integer height =0; Integer height =0;
Integer width =0; Integer width =0;
String labelName=""; String labelName="";
Integer posType=0;
try { try {
priority =Integer.parseInt(lineValues[priIndex]) ; priority =Integer.parseInt(lineValues[priIndex]) ;
height = Integer.parseInt(lineValues[hIndex]); height = Integer.parseInt(lineValues[hIndex]);
...@@ -505,6 +507,9 @@ public class StorageController { ...@@ -505,6 +507,9 @@ public class StorageController {
String areaStr=lineValues[areaIndex]; String areaStr=lineValues[areaIndex];
labelName=areaStr.trim(); labelName=areaStr.trim();
} }
if(posTypeIndex>=0){
posType=Integer.parseInt(lineValues[posTypeIndex]);
}
}catch (Exception ex){ }catch (Exception ex){
log.warn("第"+row+"行中有空白内容,此行忽略"); log.warn("第"+row+"行中有空白内容,此行忽略");
continue; continue;
...@@ -514,6 +519,15 @@ public class StorageController { ...@@ -514,6 +519,15 @@ public class StorageController {
log.warn("第"+row+"行中有空白内容,此行忽略"); log.warn("第"+row+"行中有空白内容,此行忽略");
continue; continue;
} }
if(storage.isSolderPaste()&&posType>0){
if(posType>=3){
log.warn("锡膏料仓["+storage.getCid()+"-"+storage.getName()+"]上传库位号,第"+row+"行,库位号["+posName+"]类型="+posType+",此库位忽略");
continue;
}
else if(posType==2){
isWarmPos=true;
}
}
// StoragePos posInfo = storagePosManager.getByPosName(posName); // StoragePos posInfo = storagePosManager.getByPosName(posName);
StoragePos posInfo =findFormList(storagePosList,posName); StoragePos posInfo =findFormList(storagePosList,posName);
......
...@@ -29,6 +29,7 @@ import com.neotel.smfcore.core.storage.rest.query.StoragePosQueryCriteria; ...@@ -29,6 +29,7 @@ import com.neotel.smfcore.core.storage.rest.query.StoragePosQueryCriteria;
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;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.siemens.SiemensApi; import com.neotel.smfcore.custom.siemens.SiemensApi;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
...@@ -205,8 +206,17 @@ public class StoragePosController { ...@@ -205,8 +206,17 @@ public class StoragePosController {
taskService.addTaskToFinished(storagePos, null, opUser + "-clear"); taskService.addTaskToFinished(storagePos, null, opUser + "-clear");
Storage storage = dataCache.getStorageById(storagePos.getStorageId()); Storage storage = dataCache.getStorageById(storagePos.getStorageId());
dataCache.reloadStorage(storage,""); dataCache.reloadStorage(storage,"");
}
//如果是料架,库位灭灯
if (storage != null){
if (storage.isShelf() || storage.isNLShelf() || storage.isNLPShelf() || storage.isNLMShelf()){
String opKey = "close";
String opStr = storagePos.getPosName();
DevicesStatusUtil.appendOp(storage.getCid(), opKey , opStr);
log.info("操作库位["+storagePos.getPosName()+"]" + opKey + " : " + opStr);
}
}
}
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} catch (Exception e) { } catch (Exception e) {
// return e.getMessage(); // return e.getMessage();
......
...@@ -18,4 +18,10 @@ public class StorageSearchDto implements Serializable { ...@@ -18,4 +18,10 @@ public class StorageSearchDto implements Serializable {
@ApiModelProperty("分组ID") @ApiModelProperty("分组ID")
private String groupId = ""; private String groupId = "";
@ApiModelProperty("分组名称")
private String groupName = "";
@ApiModelProperty("料仓类型")
private String type = "";
} }
...@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE; ...@@ -9,6 +9,7 @@ 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.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -93,4 +94,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> { ...@@ -93,4 +94,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
StoragePos findByStorageName(String code); StoragePos findByStorageName(String code);
StoragePos findOne(Query query); StoragePos findOne(Query query);
Sort getSortByCheckOutType(CHECKOUT_TYPE checkoutType);
} }
...@@ -332,22 +332,24 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -332,22 +332,24 @@ public class StoragePosManagerImpl implements IStoragePosManager {
/** /**
* 根据出库方式获取不同的 Sort * 根据出库方式获取不同的 Sort
*/ */
@Override
public Sort getSortByCheckOutType(CHECKOUT_TYPE checkoutType){ public Sort getSortByCheckOutType(CHECKOUT_TYPE checkoutType){
Sort sort = null; Sort sort = null;
if(CHECKOUT_TYPE.EXPIRE_FIRST.equals(checkoutType)){//先过期先出 if(CHECKOUT_TYPE.EXPIRE_FIRST.equals(checkoutType)){//先过期先出
sort = Sort.by(Sort.Direction.ASC, "barcode.expTime","barcode.expireDate","canCheckOutTime"); sort = Sort.by(Sort.Direction.ASC, "barcode.expTime","barcode.expireDate","barcode.putInDate");
}else if(CHECKOUT_TYPE.FIFO.equals(checkoutType)){//严格的先进先出 }else if(CHECKOUT_TYPE.FIFO.equals(checkoutType)){//严格的先进先出
sort = Sort.by(Sort.Direction.ASC, "canCheckOutTime", "barcode.usedCount"); sort = Sort.by(Sort.Direction.ASC, "barcode.putInDate", "barcode.usedCount");
}else if(CHECKOUT_TYPE.USED_FIRST.equals(checkoutType)){//尾料优先 }else if(CHECKOUT_TYPE.USED_FIRST.equals(checkoutType)){//尾料优先
sort = Sort.by(Sort.Direction.ASC, "barcode.amount", "canCheckOutTime"); sort = Sort.by(Sort.Direction.ASC, "barcode.amount", "barcode.putInDate");
}else if(CHECKOUT_TYPE.PRODUCE_DATE.equals(checkoutType)){ }else if(CHECKOUT_TYPE.PRODUCE_DATE.equals(checkoutType)){
//先生产先出 //先生产先出
sort = Sort.by(Sort.Direction.ASC, "barcode.amount","barcode.produceDate", "canCheckOutTime"); sort = Sort.by(Sort.Direction.ASC, "barcode.produceDate","barcode.amount", "barcode.putInDate");
}else if(CHECKOUT_TYPE.BATCH_FIRST.equals(checkoutType)){ }else if(CHECKOUT_TYPE.BATCH_FIRST.equals(checkoutType)){
//批次优先 //批次优先
sort = Sort.by(Sort.Direction.ASC, "barcode.batch","barcode.produceDate", "canCheckOutTime"); sort = Sort.by(Sort.Direction.ASC, "barcode.batch","barcode.produceDate","barcode.amount", "barcode.putInDate");
}else{//效率优先 }else{//效率优先
sort = Sort.by(Sort.Direction.ASC, "canCheckOutTime", "createDate"); sort = Sort.by(Sort.Direction.ASC, "barcode.putInDate", "createDate");
} }
return sort; return sort;
} }
......
...@@ -24,6 +24,10 @@ public class Storage extends BasePo implements Serializable { ...@@ -24,6 +24,10 @@ public class Storage extends BasePo implements Serializable {
*/ */
private String sourcePath; private String sourcePath;
private String cid; private String cid;
/**
* 附属CID
*/
private String appendCid;
private int totalSlots; private int totalSlots;
private int emptySlots; private int emptySlots;
...@@ -62,6 +66,11 @@ public class Storage extends BasePo implements Serializable { ...@@ -62,6 +66,11 @@ public class Storage extends BasePo implements Serializable {
private String groupId = ""; private String groupId = "";
/** /**
* 分组名称
*/
private String groupName = "";
/**
* 当前绑定的入库单名称 * 当前绑定的入库单名称
*/ */
private String inListName=""; private String inListName="";
...@@ -89,6 +98,13 @@ public class Storage extends BasePo implements Serializable { ...@@ -89,6 +98,13 @@ public class Storage extends BasePo implements Serializable {
} }
/** /**
* 是否是MimoG2
* @return
*/
public boolean isMimoG2(){
return DeviceType.SMD_MIMO_G2.name().equals(type);
}
/**
* 是否是单台自动仓 * 是否是单台自动仓
*/ */
public boolean isAuto(){ public boolean isAuto(){
...@@ -264,6 +280,9 @@ public class Storage extends BasePo implements Serializable { ...@@ -264,6 +280,9 @@ public class Storage extends BasePo implements Serializable {
this.emptySlots = this.emptySlots + 1; this.emptySlots = this.emptySlots + 1;
int usedCount = usageItem.getUsedCount(); int usedCount = usageItem.getUsedCount();
usageItem.setUsedCount(usedCount - 1); usageItem.setUsedCount(usedCount - 1);
if(usageItem.getUsedCount()<0){
usageItem.setUsedCount(0);
}
usageMap.put(sizeStr, usageItem); usageMap.put(sizeStr, usageItem);
} }
} }
......
...@@ -37,6 +37,8 @@ public class DataLog extends BasePo implements Serializable ,Comparable<DataLog> ...@@ -37,6 +37,8 @@ public class DataLog extends BasePo implements Serializable ,Comparable<DataLog>
setProviderNumber(barcode.getProviderNumber()); setProviderNumber(barcode.getProviderNumber());
setBatchInfo(barcode.getBatch()); setBatchInfo(barcode.getBatch());
setPutInDate(barcode.getPutInDate()); setPutInDate(barcode.getPutInDate());
setW(barcode.getPlateSize());
setH(barcode.getHeight());
msdAppendInfo = new MSDAppendInfo(); msdAppendInfo = new MSDAppendInfo();
msdAppendInfo.setMsl(barcode.getMsl()); msdAppendInfo.setMsl(barcode.getMsl());
......
package com.neotel.smfcore.core.system.util; package com.neotel.smfcore.core.system.util;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.device.bean.MsgInfo; import com.neotel.smfcore.core.device.bean.MsgInfo;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.message.enums.MessageType; import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.storage.service.po.Storage;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -18,8 +27,24 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -18,8 +27,24 @@ import java.util.concurrent.ConcurrentHashMap;
* Created by sunke on 2021/8/4. * Created by sunke on 2021/8/4.
*/ */
@Slf4j @Slf4j
@Service
public class DevicesStatusUtil { public class DevicesStatusUtil {
private static DataCache dataCache;
@Autowired
private void setDataCache(DataCache cache) {
this.dataCache = cache;
}
private static MenuInit menuInit;
@Autowired
private void setMenuInit(MenuInit init) {
DevicesStatusUtil.menuInit = init;
}
/** /**
* 状态 map,key为 cid value 为状态 Bean * 状态 map,key为 cid value 为状态 Bean
*/ */
...@@ -55,6 +80,21 @@ public class DevicesStatusUtil { ...@@ -55,6 +80,21 @@ public class DevicesStatusUtil {
* 更新设备状态信息 * 更新设备状态信息
*/ */
public static void updateStatusBean(StatusBean statusBean) { public static void updateStatusBean(StatusBean statusBean) {
String cid = statusBean.getCid();
if (statusMap.get(cid) == null) {
Storage storage = dataCache.getStorage(cid);
if (storage != null) {
String menuClient = "";
if (storage.isNLShelf() || storage.isShelf() || storage.isNLMShelf() || storage.isNLPShelf()) {
menuClient = MenuInit.NL_SHOW_MENU;
} else if (storage.isSolderPaste()) {
menuClient = MenuInit.SP_SHOW_MENU;
}
if (StringUtils.isNotBlank(menuClient)) {
menuInit.showMenu(menuClient);
}
}
}
statusMap.put(statusBean.getCid(), statusBean); statusMap.put(statusBean.getCid(), statusBean);
} }
// //
...@@ -158,7 +198,7 @@ public class DevicesStatusUtil { ...@@ -158,7 +198,7 @@ public class DevicesStatusUtil {
StatusBean statusBean = new StatusBean(); StatusBean statusBean = new StatusBean();
statusBean.setCid(cid); statusBean.setCid(cid);
statusBean.setTime(System.currentTimeMillis()); statusBean.setTime(System.currentTimeMillis());
statusBean.setMsgList(msgs); //statusBean.setMsgList(msgs);
clientMsgs.put(cid, statusBean); clientMsgs.put(cid, statusBean);
return statusBean; return statusBean;
} }
...@@ -259,4 +299,26 @@ public class DevicesStatusUtil { ...@@ -259,4 +299,26 @@ public class DevicesStatusUtil {
log.error("设备状态定时器执行出错:", ex); log.error("设备状态定时器执行出错:", ex);
} }
} }
private static Map<String, MesInfoDto> lastAgvMesMap =new HashMap<>();
public static void UpdateAgvInfo(String key, String request, String response, String status){
MesInfoDto mesInfo=new MesInfoDto(status, DateTime.now(),request,response );
if(ObjectUtil.isEmpty(key)){
key="";
}
lastAgvMesMap.put(key,mesInfo);
}
public static MesInfoDto getLastAgvInfo(String key) {
if (lastAgvMesMap.containsKey(key)) {
return lastAgvMesMap.get(key);
}
return lastAgvMesMap.get("");
}
} }
package com.neotel.smfcore.core.system.util; package com.neotel.smfcore.core.system.util;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean; import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
public class EquipStatusUtil { public class EquipStatusUtil {
...@@ -18,9 +18,9 @@ public class EquipStatusUtil { ...@@ -18,9 +18,9 @@ public class EquipStatusUtil {
protected static Map<String, EquipStatusBean> statusMap = Maps.newConcurrentMap(); protected static Map<String, EquipStatusBean> statusMap = Maps.newConcurrentMap();
/** /**
* CID的设备故障消息(key 为 cid) * NS设备最后一次MES通信信息(key 为 cid,value是最后一次MesInfo)
*/ */
private static Map<String, EquipStatusBean> clientMsgs = Maps.newConcurrentMap(); private static Map<String, MesInfoDto> NsMesInfoMap = Maps.newConcurrentMap();
/** /**
...@@ -38,6 +38,22 @@ public class EquipStatusUtil { ...@@ -38,6 +38,22 @@ public class EquipStatusUtil {
statusMap.put(statusBean.getCid(), statusBean); statusMap.put(statusBean.getCid(), statusBean);
} }
public static void updateNsMesInfo(String cid,MesInfoDto nsMesInfo) {
if(nsMesInfo==null){
return;
}
if(nsMesInfo.getTime()==null){
nsMesInfo.setTime(DateTime.now());
}
NsMesInfoMap.put(cid, nsMesInfo);
}
public static MesInfoDto getNsMesInfo(String cid){
MesInfoDto mesInfo= NsMesInfoMap.get(cid);
return mesInfo;
}
/** /**
* 获取所有的设备信息 * 获取所有的设备信息
* @return * @return
...@@ -66,4 +82,24 @@ public class EquipStatusUtil { ...@@ -66,4 +82,24 @@ public class EquipStatusUtil {
log.error("设备状态定时器执行出错:", ex); log.error("设备状态定时器执行出错:", ex);
} }
} }
private static Map<String, MesInfoDto> lastAgvMesMap =new HashMap<>();
public static void UpdateAgvInfo(String key, String request, String response, String status){
MesInfoDto mesInfo=new MesInfoDto(status, DateTime.now(),request,response );
if(ObjectUtil.isEmpty(key)){
key="";
}
lastAgvMesMap.put(key,mesInfo);
}
public static MesInfoDto getLastAgvInfo(String key) {
if (lastAgvMesMap.containsKey(key)) {
return lastAgvMesMap.get(key);
}
return lastAgvMesMap.get("");
}
} }
...@@ -99,6 +99,11 @@ public class TaskService { ...@@ -99,6 +99,11 @@ public class TaskService {
return task; return task;
} }
public synchronized String checkout(Storage storage, StoragePos pos, boolean isSingleOut,boolean ngReel, String opUserName,String outType) throws ValidateException{
return checkout(storage,pos,isSingleOut,ngReel,opUserName,outType,"");
}
/** /**
* 库位出库 * 库位出库
* *
...@@ -108,7 +113,7 @@ public class TaskService { ...@@ -108,7 +113,7 @@ public class TaskService {
* @return * @return
* @throws ValidateException * @throws ValidateException
*/ */
public synchronized String checkout(Storage storage, StoragePos pos, boolean isSingleOut,boolean ngReel, String opUserName,String outType) throws ValidateException { public synchronized String checkout(Storage storage, StoragePos pos, boolean isSingleOut,boolean ngReel, String opUserName,String outType,String ngMsg) throws ValidateException {
if (pos.getBarcode() == null) { if (pos.getBarcode() == null) {
String msg = "库位[" + pos.getPosName() + "]中已无物料,忽略"; String msg = "库位[" + pos.getPosName() + "]中已无物料,忽略";
log.info(msg); log.info(msg);
...@@ -123,6 +128,9 @@ public class TaskService { ...@@ -123,6 +128,9 @@ public class TaskService {
task.setSingleOut(isSingleOut); task.setSingleOut(isSingleOut);
task.setNgReel(ngReel); task.setNgReel(ngReel);
task.setOperator(opUserName); task.setOperator(opUserName);
if (StringUtils.isNotBlank(ngMsg)){
task.updateAppendData("ngMsg",ngMsg);
}
addTaskToExecute(task); addTaskToExecute(task);
return ""; return "";
} }
...@@ -542,13 +550,12 @@ public class TaskService { ...@@ -542,13 +550,12 @@ public class TaskService {
plateW = pos.getW(); plateW = pos.getW();
plateH = pos.getH(); plateH = pos.getH();
} }
statusBean.addData("hSerial",task.getSourceName());
String NgMsg=task.getAppendData("ngMsg"); String NgMsg=task.getAppendData("ngMsg");
boolean isNg=false; boolean isNg=false;
if(ObjectUtil.isNotEmpty(NgMsg)){ if(ObjectUtil.isNotEmpty(NgMsg)){
isNg=true; isNg=true;
} }
statusBean.addPosInfo(task.getBarcode(), posName, plateW, plateH, isSingleOut,isNg,NgMsg,0); statusBean.addPosInfo(task.getBarcode(), posName, plateW, plateH, isSingleOut,isNg,NgMsg,0,task.getSourceName());
log.info("出库" + storage.getName() + "[" + posName + "]物料[" + task.getBarcode() + "]" + isSingleOut + "["+NgMsg+"]发送到客户端" + cid); log.info("出库" + storage.getName() + "[" + posName + "]物料[" + task.getBarcode() + "]" + isSingleOut + "["+NgMsg+"]发送到客户端" + cid);
} }
} }
...@@ -853,8 +860,8 @@ public class TaskService { ...@@ -853,8 +860,8 @@ public class TaskService {
//如果已在库位中,那么自动将该库位的物料出库 //如果已在库位中,那么自动将该库位的物料出库
log.info("出库已在库位中的物料[" + barcodeSave.getBarcode() + "]"); log.info("出库已在库位中的物料[" + barcodeSave.getBarcode() + "]");
Storage storage = dataCache.getStorageById(pos.getStorageId()); Storage storage = dataCache.getStorageById(pos.getStorageId());
checkout(storage, pos, true, ""); //checkout(storage, pos, true, "");
checkout(storage,pos,true,true,"","",barcodeSave.getBarcode()+"已存在库位:"+pos.getPosName());
throw new ValidateException("smfcore.error.barcode.exist", "[{0}}]已在{1}}[{2}}]中", new String[]{barcodeSave.getBarcode(), storage.getName(), pos.getPosName()}); throw new ValidateException("smfcore.error.barcode.exist", "[{0}}]已在{1}}[{2}}]中", new String[]{barcodeSave.getBarcode(), storage.getName(), pos.getPosName()});
} }
......
package com.neotel.smfcore.custom.deif20861;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.EquipStatusUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Slf4j
@RestController
@RequestMapping("/rest/api")
public class DEIF20861Controller {
@Autowired
private DataCache dataCache;
@Autowired
private EquipmentCache equipmentCache;
@ApiOperation("S001 MES或AGV系统获取料仓状态信息")
@RequestMapping("/boxDoorInfo")
@AnonymousAccess
public ResultBean boxDoorInfo( @RequestBody Map<String, Object> paramMap) {
Collection<Storage> storageList = Lists.newArrayList();
storageList.addAll(dataCache.getAllStorage().values());
List<Map<String, Object>> results = Lists.newArrayList();
for (Storage storage : storageList) {
if(!storage.isSmdDuo()){
continue;
}
StatusBean statusBean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (statusBean == null) {
statusBean = new StatusBean();
}
Map<String, BoxStatusBean> boxStatusMap = statusBean.getBoxStatus();
int status = -1;
String shelfS = statusBean.getData().getOrDefault("shelfState", "OFFLINE");
String hserial = statusBean.getData().getOrDefault("hSerial", "");
String shelfType = statusBean.getData().getOrDefault("shelfType", "");
if (boxStatusMap != null) {
BoxStatusBean boxStatusBean = boxStatusMap.get("1");
if (boxStatusBean != null) {
status = boxStatusBean.getStatus();
}
}
if (status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
//离线
shelfS = "OFFLINE";
}
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("cid", storage.getCid());
String reelSize = shelfType.replace("smallReel", "7").replace("bigReel", "15");
String s = StringUtil.join(reelSize);
itemMap.put("reelSize", s);
itemMap.put("status", shelfS);
itemMap.put("hSerial", hserial);
results.add(itemMap);
}
ResultBean<Object> bean= ResultBean.newOkResult(results);
DevicesStatusUtil.UpdateAgvInfo("",JsonUtil.toJsonStr(paramMap), JsonUtil.toJsonStr(bean),"OK");
return bean;
}
@ApiOperation("S002 MES或AGV系统操作料仓门打开或关闭")
@RequestMapping("/boxDoorOp")
@AnonymousAccess
public ResultBean boxDoorOp(@RequestBody Map<String, Object> paramList) {
// 请求参数参数名参数描述类型是否必填备注
// cid料仓编号String是
// op操作String是OPEN=开门,CLOSE=关门
// 参数示例{"cid":"001","op":"OPEN"}
// 返回结果参数名参数描述类型是否必填备注
// code状态码。Integer是0为正常。其他为异常。
// msg提示消息String是
// data
//
// 返回示例{ "code": 0, "msg": "ok", "data": ""}
log.info("{}收到数据为:{}", "boxDoorOp", JsonUtil.toJsonStr(paramList));
String cid = paramList.get("cid").toString();
String op = paramList.get("op").toString();
StatusBean statusBean = DevicesStatusUtil.getStatusBean(cid);
if (statusBean == null || statusBean.timeOut()) {
return ResultBean.newErrorResult(1, "smfcore.duo.offline", "设备{0}离线", new String[]{cid});
}
// closeLock 为enable时此按钮状态为可用,openLock 为enable时,此按钮状态为可用已读
// 客户端收到服务器openLock为doit时,执行打开门锁动作,closeLock为doit时,执行关闭门锁
String opKey = "";
if (op.equals("OPEN")) {
opKey = "openLock";
}
if (op.equals("CLOSE")) {
opKey = "closeLock";
}
if (ObjectUtil.isNotEmpty(opKey)) {
String openLock = statusBean.getData().getOrDefault(opKey, "");
if (openLock.equals("enable")) {
String opValue = "doit";
log.info("boxDoorOp:cid=" + cid + "," + opKey + "=" + opValue);
DevicesStatusUtil.addOp(cid, opKey, opValue);
return ResultBean.newOkResult("smfcore.msg.ok", "操作成功");
}
}
return ResultBean.newErrorResult(2,"smfcore.msg.op.fail","操作失败");
}
@ApiOperation("S003 NS200设备状态查询")
@RequestMapping("/nsShelfInfo")
@AnonymousAccess
public ResultBean nsShelfInfo( @RequestBody Map<String, Object> paramMap) {
Collection<Equipment> storageList = Lists.newArrayList();
storageList.addAll(equipmentCache.getAllEquipment().values());
List<Map<String, Object>> results = Lists.newArrayList();
for (Equipment equipment : storageList) {
if(!equipment.isNEOSCAN()){
continue;
}
StatusBean statusBean = DevicesStatusUtil.getStatusBean(equipment.getCid());
if (statusBean == null) {
statusBean = new StatusBean();
}
Map<String, BoxStatusBean> boxStatusMap = statusBean.getBoxStatus();
int status = -1;
String outShelfStatus = statusBean.getData().getOrDefault("outShelfStatus ", "OFFLINE");
String inShelfStatus = statusBean.getData().getOrDefault("inShelfStatus ", "OFFLINE");
if (boxStatusMap != null) {
BoxStatusBean boxStatusBean = boxStatusMap.get("1");
if (boxStatusBean != null) {
status = boxStatusBean.getStatus();
}
}
if (status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
//离线
outShelfStatus = "OFFLINE";
inShelfStatus="OFFLINE";
}
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("cid", equipment.getCid());
itemMap.put("reelSize", "7,15");
itemMap.put("inShelfStatus", inShelfStatus);
itemMap.put("outShelfStatus", outShelfStatus);
results.add(itemMap);
}
ResultBean<Object> bean= ResultBean.newOkResult(results);
EquipStatusUtil.UpdateAgvInfo("",JsonUtil.toJsonStr(paramMap), JsonUtil.toJsonStr(bean),"OK");
return bean;
}
}
...@@ -106,7 +106,7 @@ public class DJK20388AGVController { ...@@ -106,7 +106,7 @@ public class DJK20388AGVController {
Map<String, Storage> storages = dataCache.getAllStorage(); Map<String, Storage> storages = dataCache.getAllStorage();
for (Storage storage : for (Storage storage :
storages.values()) { storages.values()) {
if (storage.isBatchStorage()) { if (storage.isBatchStorage()||storage.isMimoG2()) {
cid = storage.getCid(); cid = storage.getCid();
break; break;
} }
......
...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON; ...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.exception.ApiException; import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper; import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener; import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
...@@ -135,8 +136,12 @@ public class IriichiApi extends BaseSmfApiListener { ...@@ -135,8 +136,12 @@ public class IriichiApi extends BaseSmfApiListener {
return ""; return "";
} }
private LiteOrder getOrderByResult(String orderNo, String result) { private LiteOrder getOrderByResult(String orderNo, String result) {
JSONObject resultObj = JSONObject.parseObject(result); JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj.get("Items") == null){
throw new ValidateException("mes.api.orderError",result);
}
List<List<Map<String, String>>> itemArr = resultObj.getObject("Items", List.class); List<List<Map<String, String>>> itemArr = resultObj.getObject("Items", List.class);
List<LiteOrderItem> itemList = new ArrayList<>(); List<LiteOrderItem> itemList = new ArrayList<>();
for (List<Map<String, String>> mapList : itemArr) { for (List<Map<String, String>> mapList : itemArr) {
......
package com.neotel.smfcore.custom.keboda1335;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.security.service.po.Menu;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* @author sunke
* @date 2022/12/14 4:01 PM
*/
@Component
public class Keboda1335Menu {
@Autowired
MenuInit menuInit;
@Autowired
SmfApi smfApi;
@PostConstruct
public void init(){
String menuLabel = "kbd";
MenuInit.addMenu(menuLabel,null, -1, "看板", "kebodaKanban", "kebodakanban/index","kanbanMenu");
MenuInit.addMenu(menuLabel,null, -1, "库存", "kebodaInventory", "neolight/kebodaInventory/index","inventory");
String apiName = smfApi.getApiName();
if(Strings.isNotBlank(apiName) && apiName.equals(menuLabel)){
menuInit.showMenu(apiName);
}
}
}
...@@ -16,6 +16,8 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve; ...@@ -16,6 +16,8 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
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;
...@@ -45,6 +47,8 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -45,6 +47,8 @@ public class PanaApiController extends BaseSmfApiListener {
protected TaskService taskService; protected TaskService taskService;
@Autowired @Autowired
protected IStoragePosManager storagePosManager; protected IStoragePosManager storagePosManager;
@Autowired
protected LiteOrderCache liteOrderCache;
protected static DataCache dataCache; protected static DataCache dataCache;
...@@ -136,6 +140,13 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -136,6 +140,13 @@ public class PanaApiController extends BaseSmfApiListener {
String JobID = panaMaterial.getJobID(); String JobID = panaMaterial.getJobID();
List<String> ReelBarcodes = panaMaterial.getReelBarcodes();//["ABC123","BCD345","LL13212"] List<String> ReelBarcodes = panaMaterial.getReelBarcodes();//["ABC123","BCD345","LL13212"]
log.info("收到 PanaCIM 的deliverMaterial 命令:ReelBarcodes="+ StringUtils.join(ReelBarcodes,",")); log.info("收到 PanaCIM 的deliverMaterial 命令:ReelBarcodes="+ StringUtils.join(ReelBarcodes,","));
//获取亮灯颜色
ORDER_COLOR nextColor = liteOrderCache.getNextColor();
if (nextColor == null){
nextColor = ORDER_COLOR.BLUE;
}
List<String> ReelBarcodesDelivered = Lists.newArrayList(); List<String> ReelBarcodesDelivered = Lists.newArrayList();
List<String> ReelBarcodesNonExisting = Lists.newArrayList(); List<String> ReelBarcodesNonExisting = Lists.newArrayList();
for (String barcode : ReelBarcodes){//加入到出库列表 for (String barcode : ReelBarcodes){//加入到出库列表
...@@ -147,7 +158,7 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -147,7 +158,7 @@ public class PanaApiController extends BaseSmfApiListener {
continue; continue;
} }
log.info("出库["+barcode+"]位置仓位【"+pos.getPosName()+"】"); log.info("出库["+barcode+"]位置仓位【"+pos.getPosName()+"】");
taskService.checkout(pos,false,null,false); taskService.checkout(pos,false,null,false,nextColor.getRgb());
ReelBarcodesDelivered.add(barcode); ReelBarcodesDelivered.add(barcode);
}catch (Exception e){ }catch (Exception e){
ReelBarcodesNonExisting.add(barcode); ReelBarcodesNonExisting.add(barcode);
...@@ -323,6 +334,13 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -323,6 +334,13 @@ public class PanaApiController extends BaseSmfApiListener {
result.put("ErrorCode","401"); result.put("ErrorCode","401");
result.put("ErrorMessage","JobID["+JobID+"]未包含物料"); result.put("ErrorMessage","JobID["+JobID+"]未包含物料");
}else{ }else{
//获取亮灯颜色
ORDER_COLOR nextColor = liteOrderCache.getNextColor();
if (nextColor == null){
nextColor = ORDER_COLOR.BLUE;
}
List<DataLog> tasks = Lists.newArrayList(); List<DataLog> tasks = Lists.newArrayList();
for (StoragePos pos :lockPoses){ for (StoragePos pos :lockPoses){
//已经加过的就不再加了 //已经加过的就不再加了
...@@ -355,6 +373,8 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -355,6 +373,8 @@ public class PanaApiController extends BaseSmfApiListener {
task.setPosId(pos.getId()); task.setPosId(pos.getId());
task.setPosName(pos.getPosName()); task.setPosName(pos.getPosName());
task.setLightColor(nextColor.getRgb());
tasks.add(task); tasks.add(task);
} }
......
...@@ -250,8 +250,12 @@ public class MesApiController { ...@@ -250,8 +250,12 @@ public class MesApiController {
return "Error: RI 为必须项"; return "Error: RI 为必须项";
} }
//rgbCode为空时,默认是蓝色
if (StringUtils.isBlank(rgbCode)){
rgbCode = "0000FF";
}
//判断亮灯颜色是否在这20种内 //判断亮灯颜色是否在这20种内
if (StringUtils.isBlank(colorMap.get(rgbCode)) || StringUtils.isBlank(rgbCode)){ if (StringUtils.isBlank(rgbCode) || StringUtils.isBlank(colorMap.get(rgbCode))) {
return "Error :rgbCode不在指定范围内"; return "Error :rgbCode不在指定范围内";
//return "Error: rgbCode 不在颜色范围内"; //return "Error: rgbCode 不在颜色范围内";
} }
......
...@@ -17,6 +17,8 @@ package com.neotel.smfcore.security.service; ...@@ -17,6 +17,8 @@ package com.neotel.smfcore.security.service;
import com.neotel.smfcore.common.exception.EntityNotFoundException; import com.neotel.smfcore.common.exception.EntityNotFoundException;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.Md5Utls;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto; import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto;
...@@ -57,21 +59,21 @@ public class UserDetailsServiceImpl implements UserDetailsService { ...@@ -57,21 +59,21 @@ public class UserDetailsServiceImpl implements UserDetailsService {
if (user == null) { if (user == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"username", username}); throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"username", username});
} else { } else {
// if(user.getEnabled()==null){ if(user.getEnabled()==null){
// throw new ValidateException("smfcore.notActivated","账号未激活"); throw new ValidateException("smfcore.notActivated","账号未激活");
// } }
// if (!user.getEnabled()) { if (!user.getEnabled()) {
// throw new ValidateException("smfcore.notActivated","账号未激活"); throw new ValidateException("smfcore.notActivated","账号未激活");
// } }
// if(user.getUsername().equals(Constants.SUPER_USERNAME)){ if(user.getUsername().equals(Constants.SUPER_USERNAME)){
//
// }else { }else {
// //判断激活码是否正确 //判断激活码是否正确
// String code = Md5Utls.getMd5(user.getId(), user.getCreateDate()); String code = Md5Utls.getMd5(user.getId(), user.getCreateDate());
// if (!code.equals(user.getCheckCode())) { if (!code.equals(user.getCheckCode())) {
// throw new ValidateException("smfcore.notActivated","账号未激活"); throw new ValidateException("smfcore.notActivated","账号未激活");
// } }
// } }
List<Long> dataScopes = new ArrayList<>(); List<Long> dataScopes = new ArrayList<>();
jwtUserDto = new JwtUserDto( jwtUserDto = new JwtUserDto(
user, user,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# 登录相关配置 # 登录相关配置
login: login:
single-login: false single-login: true
#配置数据源 #配置数据源
spring: spring:
...@@ -12,6 +12,10 @@ spring: ...@@ -12,6 +12,10 @@ spring:
host: localhost # 主机地址 host: localhost # 主机地址
port: 27017 # 端口 port: 27017 # 端口
database: smf # 数据库 database: smf # 数据库
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
#jwt #jwt
jwt: jwt:
......
...@@ -380,4 +380,8 @@ smfcore.agv.dispatch=\u8D27\u7269\u5DF2\u7ECF\u53D1\u9001\u5230\u5B58\u50A8\u7CF ...@@ -380,4 +380,8 @@ smfcore.agv.dispatch=\u8D27\u7269\u5DF2\u7ECF\u53D1\u9001\u5230\u5B58\u50A8\u7CF
smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A
smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D
smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8BBE\u5907{0}\u79BB\u7EBF
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u8D25
smfcore.equip.notExist=\u8BBE\u5907\u4E0D\u5B58\u5728
smfcore.order.finished=\u5DE5\u5355[{0}]\u7684\u4EFB\u52A1\u5DF2\u5168\u90E8\u5B8C\u6210
\ No newline at end of file \ No newline at end of file
...@@ -371,4 +371,8 @@ smfcore.agv.dispatch=Goods dispatched to storage system ...@@ -371,4 +371,8 @@ smfcore.agv.dispatch=Goods dispatched to storage system
smfcore.agv.awaitingInstruction=Awaiting instruction smfcore.agv.awaitingInstruction=Awaiting instruction
smfcore.agv.operation=AGV is in operation smfcore.agv.operation=AGV is in operation
smfcore.boxmimokanban=SMD BOX KANBAN smfcore.boxmimokanban=SMD BOX KANBAN
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
smfcore.neoai=Neo Ai
smfcore.duo.offline=Equipment {0} offline
smfcore.msg.op.fail=failure of an operation
smfcore.equip.notExist=Device does not exist
smfcore.order.finished=workorder[{0}] has completed all of its tasks
\ No newline at end of file \ No newline at end of file
...@@ -367,4 +367,8 @@ smfcore.agv.awaitingInstruction=\u6307\u793A\u5F85\u3061 ...@@ -367,4 +367,8 @@ smfcore.agv.awaitingInstruction=\u6307\u793A\u5F85\u3061
smfcore.agv.operation=AGV\u52D5\u4F5C\u4E2D\u3067\u3059 smfcore.agv.operation=AGV\u52D5\u4F5C\u4E2D\u3067\u3059
smfcore.boxmimokanban=\u30AF\u30E9\u30A6\u30C9\u5009\u5EAB\u30AB\u30F3\u30D0\u30F3 smfcore.boxmimokanban=\u30AF\u30E9\u30A6\u30C9\u5009\u5EAB\u30AB\u30F3\u30D0\u30F3
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8BBE\u5907{0}\u79BB\u7EBF
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u8D25
smfcore.equip.notExist=\u8BBE\u5907\u4E0D\u5B58\u5728
smfcore.order.finished=\u30EF\u30FC\u30AF\u30AA\u30FC\u30C0\u30FC[{0}]\u306E\u30BF\u30B9\u30AF\u306F\u3059\u3079\u3066\u5B8C\u4E86\u3057\u307E\u3057\u305F
\ No newline at end of file \ No newline at end of file
...@@ -367,4 +367,8 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A ...@@ -367,4 +367,8 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A
smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D
smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8BBE\u5907{0}\u79BB\u7EBF
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u8D25
smfcore.equip.notExist=\u8BBE\u5907\u4E0D\u5B58\u5728
smfcore.order.finished=\u5DE5\u5355[{0}]\u7684\u4EFB\u52A1\u5DF2\u5168\u90E8\u5B8C\u6210
\ No newline at end of file \ No newline at end of file
...@@ -367,4 +367,8 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A ...@@ -367,4 +367,8 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A
smfcore.agv.operation=AGV\u6B63\u5728\u904B\u884C smfcore.agv.operation=AGV\u6B63\u5728\u904B\u884C
smfcore.boxmimokanban=\u96F2\u6599\u5009\u770B\u677F smfcore.boxmimokanban=\u96F2\u6599\u5009\u770B\u677F
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8A2D\u5099{0}\u96E2\u7DDA
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u6557
smfcore.equip.notExist=\u8A2D\u5099\u4E0D\u5B58\u5728
smfcore.order.finished=\u5DE5\u55AE[{0}]\u7684\u4EFB\u52D9\u5DF2\u5168\u90E8\u5B8C\u6210
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!