Commit 9e01f250 孙克
2 个父辈 83a63add 1e024f20
正在显示 33 个修改的文件 包含 2054 行增加30 行删除
......@@ -113,9 +113,14 @@ public class MenuInit {
//AGV看板
//addDefaultFunctionMenu(1,null,"AGV看板","agvkanban", "agv/agvkanban/index","agv");
//Mimo临时看板
addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo");
//电子看板
addDefaultFunctionMenu(1,null,"电子看板","eleckanban", "eleckanban/index","kanban");
//设备看板
addDefaultFunctionMenu(1,null,"设备看板","lockMaterial", "lockMaterial/material/index","kanban",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(1,null,"电子看板","eleckanban", "elecKanban/index","kanban",DEFAULT_SHOW_MENU);
//设备互联
addDefaultFunctionMenu(2,null,"设备互联","equipmentView", "neolight/equipmentView/index","sKanban");
......@@ -182,6 +187,7 @@ public class MenuInit {
addDefaultFunctionMenu(71, pMenuReport, "出入库", "inOutDataCount", "neolight/inOutDataCount/index", "outPut");
addDefaultFunctionMenu(72, pMenuReport,"库存", "inventory", "neolight/inventory/index", "inventory");
addDefaultFunctionMenu(73, pMenuReport,"温湿度", "humiture", "humiture/humitureReport/index", "humiture");
addDefaultFunctionMenu(73, pMenuReport,"温湿度", "spHumiture", "humiture/spHumitureReport/index", "humiture");
//可观测性:物料追踪
Menu guanceMenu = Menu.CreatePMenu("可观测性", 8, "observability", "scanKey",null);
......@@ -217,6 +223,7 @@ public class MenuInit {
addDefaultFunctionMenu(99991, helpAbout, "说明书", "instruction", "system/instruction/index","aboutBook");
addDefaultFunctionMenu(99992, helpAbout, "关于","about", "system/about/index","message",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(123,null,"LNB残数","LNBResidue", "neolight/lnbResidue/index","kanban");
return allMenuMap;
}
......
......@@ -358,6 +358,46 @@ public class HttpHelper {
}
}
public static String getJson(String url,Map<String,String> headerMap ,Object params) throws ApiException {
// 设置请求参数
if (params != null) {
try {
ObjectMapper mapper = new ObjectMapper();
String requestBody = mapper.writeValueAsString(params);
List<NameValuePair> nameValuePairs = new LinkedList<>();
nameValuePairs.add(new BasicNameValuePair("JSON", requestBody));
String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairs));
url = appendString(url, paramStr);
// url=url+"?JSON="+requestBody;
} catch (Exception e) {
throw new ApiException("getJson append params to [" + url + "] exception:" + e.getMessage());
}
}
try {
HttpGet httpGet = new HttpGet(url);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECTION_TIMEOUT).build();
httpGet.setConfig(requestConfig);
if (headerMap != null && !headerMap.isEmpty()) {
for (Entry<String, String> entry : headerMap.entrySet()) {
httpGet.addHeader(entry.getKey(), entry.getValue());
}
}
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpGet);
int code = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
response.close();
httpClient.close();
return responseContent;
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
}
}
private static String appendString(String url, String paramStr) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(url);
......
......@@ -123,4 +123,98 @@ public class SmbUtil {
}
return false;
}
/**
* @Title smbGet
* @Param shareUrl 共享目录中的文件路径,如smb://132.20.2.33/CIMPublicTest/eg.txt
* @Param localDirectory 本地目录,如tempStore/smb
*/
public static boolean smbGetByAuth(String smbFile, NtlmPasswordAuthentication auth,String localDirectory){
InputStream in = null;
OutputStream out = null;
try {
Config.registerSmbURLHandler();
SmbFile remoteFile = new SmbFile(smbFile,auth);
if (!remoteFile.exists()) {
log.info("共享文件不存在");
return false;
}
// 有文件的时候再初始化输入输出流
log.info("下载共享目录的文件 "+smbFile+" 到 "+ localDirectory);
String fileName = remoteFile.getName();
File localFile = new File(localDirectory + File.separator + fileName);
File fileParent = localFile.getParentFile();
if (null != fileParent && !fileParent.exists()) {
fileParent.mkdirs();
}
in = new BufferedInputStream(new SmbFileInputStream(remoteFile));
out = new BufferedOutputStream(new FileOutputStream(localFile));
byte[] buffer = new byte[1024];
while (in.read(buffer) != -1) {
out.write(buffer);
buffer = new byte[1024];
}
out.flush(); //刷新缓冲区输出流
return true;
} catch (Exception e) {
log.error("获取 SMB 文件出错",e);
} finally {
close(in,out);
}
return false;
}
/**
* 列出SMB服务器文件夹中的所有文件,如果目录不存在或者访问出错返回null
*/
public static List<SmbFile> smbFileList(String smbDir) {
try {
SmbFile remoteFile = new SmbFile(smbDir);
if (remoteFile.exists() && remoteFile.isDirectory()) {
return Lists.newArrayList(remoteFile.listFiles());
} else {
log.info("SMB目录[" + smbDir + "]不存在");
}
} catch (Exception e) {
log.error("访问SMB目录[" + smbDir + "]出错", e);
}
return null;
}
/**
* @Title smbGet
* @Param shareUrl 共享目录中的文件路径,如smb://132.20.2.33/CIMPublicTest/eg.txt
* @Param localDirectory 本地目录,如tempStore/smb
*/
public static boolean smbGet(SmbFile smbFile, String localDirectory) {
InputStream in = null;
OutputStream out = null;
try {
// 有文件的时候再初始化输入输出流
log.info("下载共享目录的文件 " + smbFile + " 到 " + localDirectory);
String fileName = smbFile.getName();
File localFile = new File(localDirectory + File.separator + fileName);
File fileParent = localFile.getParentFile();
if (null != fileParent && !fileParent.exists()) {
fileParent.mkdirs();
}
in = new BufferedInputStream(new SmbFileInputStream(smbFile));
out = new BufferedOutputStream(new FileOutputStream(localFile));
byte[] buffer = new byte[1024];
while (in.read(buffer) != -1) {
out.write(buffer);
buffer = new byte[1024];
}
out.flush(); //刷新缓冲区输出流
return true;
} catch (Exception e) {
log.error("获取 SMB 文件出错", e);
} finally {
close(in, out);
}
return false;
}
}
......@@ -7,6 +7,7 @@ import com.neotel.smfcore.common.csv.CsvReader;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.barcode.bean.BarcodeRule;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeRuleDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
......@@ -179,6 +180,15 @@ public class BarcodeController {
return ResultBean.newOkResult(resultMsg);
}
/*@ApiOperation("根据条码信息获取条码规则")
@PostMapping(value = "getBarcodeRule")
public ResultBean getBarcodeRule(@RequestBody Map<String, String> paramMap) {
String ruleStr = BarcodeRule.toCodeRule(paramMap.get("codeStr"), paramMap);
return ResultBean.newOkResult(ruleStr);
}*/
protected String handleBarcode(String fileURL) throws Exception {
log.info("开始读取文件:" + fileURL);
CsvReader csvRead =CsvReader.newReader(fileURL,"条码","RI");
......
......@@ -165,6 +165,10 @@ public class ComponentManagerImpl implements IComponentManager {
logName = "修改元器件";
c.and("id").ne(resources.getId());
}
if (StringUtils.isNotBlank(resources.getProvider())){
c.and("provider").is(resources.getProvider());
}
Component com = componentDao.findOne(new Query(c));
if (com != null) {
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"partNumber",resources.getPartNumber()});
......
......@@ -626,12 +626,24 @@ public class BaseDeviceHandler implements IDeviceHandler {
updateInOutDateExecuteTime(task.getPosName(),executeTime);
}
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒");
DataLog cancelTask = taskService.findFinishedOutTask(cid, task.getPosName(),task.getBarcode());
List<DataLog> taskList = taskService.findFinishedTaskList(cid, task.getPosName(), task.getBarcode(), false);
if (taskList != null && !taskList.isEmpty()){
for (DataLog dataLog : taskList) {
if (dataLog.isCancel()){
//将相同库位已经取消的任务从完成队列里删除
taskService.removeFinishedTask(dataLog);
log.info("从已完成的任务列表中删除之前取消的任务:" + dataLog.getPosName() + " ReelId:" + dataLog.getBarcode());
}
}
}
/* DataLog cancelTask = taskService.findFinishedOutTask(cid, task.getPosName(),task.getBarcode());
if (cancelTask != null && cancelTask.isCancel()) {
//将相同库位已经取消的任务从完成队列里删除
taskService.removeFinishedTask(cancelTask);
log.info("从已完成的任务列表中删除之前取消的任务:" + cancelTask.getPosName() + " ReelId:" + cancelTask.getBarcode());
}
}*/
updateCheckoutData(task,outBoxStatus);
} else {
//log.error(operationKey + "触发仓位完成时,操作队列中不存在");
......
package com.neotel.smfcore.core.device.handler.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import 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.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "SHELF: NLL(标签料架)")
@RestController
@Slf4j
public class NLLShelfHandler extends BaseDeviceHandler {
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private BarcodeMapper barcodeMapper;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
return super.handleClientRequest(statusBean, request);
}
@ApiOperation("获取库位信息")
@RequestMapping("/api/nllShelf/storagePos")
@AnonymousAccess
public BarcodeDto storagePos(HttpServletRequest request) {
String code = request.getParameter("code");
BarcodeDto dto = new BarcodeDto();
//判断库位信息是否存在
StoragePos storagePos = storagePosManager.findByStorageName(code);
if (storagePos == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"库位", code});
}
Barcode barcode = storagePos.getBarcode();
if (barcode == null){
barcode = new Barcode();
barcode.setBarcode(code);
barcode.setPartNumber(code);
}
dto = barcodeMapper.toDto(barcode);
opPosLight("open", storagePos, "");
return dto;
}
@ApiOperation("入库/出库操作")
@RequestMapping("/api/nllShelf/codeIn")
@AnonymousAccess
public ResultBean codeIn(@RequestBody Map<String, String> paramMap) {
//库位名称
String posName = paramMap.get("posName");
if (StringUtils.isBlank(posName)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"posName"});
}
//条码
String code = paramMap.get("code");
if (StringUtils.isBlank(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.noValidCode", "条码无效");
}
if (StringUtils.isNotBlank(barcode.getPosName())) {
return ResultBean.newErrorResult(-1, "smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{barcode.getPosName()});
}
//判断库位是否存在
StoragePos pos = storagePosManager.getByPosName(posName);
if (pos == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"库位", posName});
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
//判断是否存在库位中
Barcode posBarcode = pos.getBarcode();
if (posBarcode == null) {
posBarcode = new Barcode();
posBarcode.setPartNumber(posName);
posBarcode.setBarcode(posName);
}
boolean isExist = false;
List<Barcode> subCodeList = posBarcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode subBarcode : subCodeList) {
if (subBarcode.getBarcode().equals(barcode.getBarcode())) {
isExist = true;
break;
}
}
}
if (isExist) {
DataLog dataLog = new DataLog(storage, barcode, pos);
dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLog.setType(OP.CHECKOUT);
dataLog.setCreator(SecurityUtils.getLoginUsername());
taskService.updateFinishedTask(dataLog);
barcode.setPosName(null);
barcodeManager.save(barcode);
barcode.setAmount(0);
posBarcode.UpdateSubCode(barcode);
} else {
DataLog dataLog = new DataLog(storage, barcode, pos);
dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLog.setType(OP.CHECKOUT);
dataLog.setCreator(SecurityUtils.getLoginUsername());
taskService.updateFinishedTask(dataLog);
barcode.setPutInTime(new Date().getTime());
barcode.setPosName(pos.getPosName());
barcodeManager.save(barcode);
posBarcode.UpdateSubCode(barcode);
}
barcodeManager.save(posBarcode);
pos.setBarcode(posBarcode);
storagePosManager.save(pos);
updateStoragePosInfo(posName);
return ResultBean.newOkResult("");
}
@ApiOperation("取出")
@RequestMapping("/api/nllShelf/exeOut")
@AnonymousAccess
public ResultBean exeOut(@RequestBody Map<String, String> paramMap) {
String posName = paramMap.get("posName");
String code = paramMap.get("code");
Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.noValidCode", "条码无效");
}
//判断库位是否存在
StoragePos pos = storagePosManager.getByPosName(posName);
if (pos == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"库位", posName});
}
Barcode posBarcode = pos.getBarcode();
if (posBarcode != null) {
List<Barcode> subCodeList = posBarcode.getSubCodeList();
for (Barcode subCode : subCodeList) {
if (subCode.getBarcode().equals(barcode.getBarcode())) {
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog dataLog = new DataLog(storage, barcode, pos);
dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLog.setType(OP.CHECKOUT);
dataLog.setCreator(SecurityUtils.getLoginUsername());
taskService.updateFinishedTask(dataLog);
barcode.setPosName(null);
barcodeManager.save(barcode);
barcode.setAmount(0);
posBarcode.UpdateSubCode(barcode);
barcodeManager.save(posBarcode);
pos.setBarcode(posBarcode);
storagePosManager.save(pos);
updateStoragePosInfo(posName);
return ResultBean.newOkResult("");
}
}
}
return ResultBean.newErrorResult(-1, "smfcore.allBoxView.noReel", "库位{0}中无物料", new String[]{posName});
}
@ApiOperation("取出全部")
@RequestMapping("/api/nllShelf/exeOutAll")
@AnonymousAccess
public ResultBean exeOutAll(@RequestBody Map<String, String> paramMap) {
String posName = paramMap.get("posName");
//判断库位是否存在
StoragePos pos = storagePosManager.getByPosName(posName);
if (pos == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"库位", posName});
}
Barcode posBarcode = pos.getBarcode();
if (posBarcode != null) {
List<Barcode> subCodeList = posBarcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
for (int i = 0; i < subCodeList.size(); i++) {
Barcode subCode = subCodeList.get(i);
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog dataLog = new DataLog(storage, subCode, pos);
dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLog.setType(OP.CHECKOUT);
dataLog.setCreator(SecurityUtils.getLoginUsername());
taskService.updateFinishedTask(dataLog);
subCode.setPosName(null);
barcodeManager.save(subCode);
subCode.setAmount(0);
posBarcode.UpdateSubCode(subCode);
}
barcodeManager.save(posBarcode);
pos.setBarcode(posBarcode);
storagePosManager.save(pos);
updateStoragePosInfo(posName);
return ResultBean.newOkResult("");
}
}
return ResultBean.newErrorResult(-1, "smfcore.allBoxView.noReel", "库位{0}中无物料", new String[]{posName});
}
@ApiOperation("完成时关闭库位灯")
@RequestMapping("/api/nllShelf/finish")
@AnonymousAccess
public ResultBean finish(String posName) {
//判断库位是否存在
StoragePos pos = storagePosManager.getByPosName(posName);
if (pos == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"库位", posName});
}
opPosLight("close", pos, "");
return ResultBean.newOkResult("");
}
/**
* 获取库位信息
*
* @param posName
* @return
*/
private void updateStoragePosInfo(String posName) {
StoragePos storagePos = storagePosManager.getByPosName(posName);
if (storagePos != null) {
Map<String, Long> collect = new HashMap<>();
Map<String, Map<String, Long>> resultMap = new HashMap<>();
Barcode barcode = storagePos.getBarcode();
if (barcode != null) {
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
collect = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPartNumber, Collectors.counting()));
resultMap.put(posName, collect);
}
}
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
DevicesStatusUtil.addOp(storage.getCid(), "storagePosInfo", JSON.toJSONString(resultMap));
}
}
/**
* 操作库位灯(开灯,或关灯)
*
* @param opKey
* @param pos
* @param colorStr
*/
private void opPosLight(String opKey, StoragePos pos, String colorStr) {
String opStr = pos.getPosName();
if (!Strings.isNullOrEmpty(colorStr)) {
opStr = opStr + "=" + colorStr;
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
DevicesStatusUtil.appendOp(storage.getCid(), opKey, opStr);
log.info("操作库位[" + pos.getPosName() + "]" + opKey + " : " + opStr);
}
}
......@@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.StatusBean;
......@@ -228,13 +229,20 @@ public class NLPShelfHandler extends BaseDeviceHandler {
dataLogList.add(queueTask);
outMap.put(queueTask.getSourceId(), dataLogList);
} else {
if (StringUtils.isNotBlank(rgb)){
log.info(queueTask.getPosName() + "库位亮灯:" + "#" + rgb);
statusBean.addData("open", queueTask.getPosName() + "=#" + rgb);
} else {
color = ORDER_COLOR.BLUE;
}
}
}
if (color != null){
statusBean.addData("open", queueTask.getPosName() + "=" + color.name());
log.info("库位[" + queueTask.getPosName() + "]+亮灯:" + color.name());
}
}
}
List<DataLog> dataLogs = getLightGuideTask(outMap);
for (DataLog task : dataLogs) {
......@@ -306,7 +314,8 @@ public class NLPShelfHandler extends BaseDeviceHandler {
List<String> newList=new ArrayList<>();
for (String posName : hasReelPosList) {
if(disabledPosNameSet.contains(posName)){
//log.info(cid + "sensorChange hasReelPosList [" + posName + "]库位被禁用,忽略");
log.info(cid + "sensorChange hasReelPosList [" + posName + "]库位被禁用,忽略");
inOkList.add(posName);
continue;
}else if(usedPosList.contains(posName)){
log.info(cid + "sensorChange hasReelPosList [" + posName + "]库位已有物料,加入到ok列表");
......@@ -495,12 +504,19 @@ public class NLPShelfHandler extends BaseDeviceHandler {
String rgb = task.getLightColor();
ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
if (color == null) {
if (StringUtils.isNotBlank(rgb)){
String outTaskPos = task.getPosName() + "=#" + rgb;
outTaskPosList.add(outTaskPos);
} else {
color = ORDER_COLOR.BLUE;
}
}
if (color != null) {
String outTaskPos = task.getPosName() + "=" + color.name();
outTaskPosList.add(outTaskPos);
}
}
}
String hasReelPosColor = "orange";
//hasReelPosColor = ORDER_COLOR.DARKGREEN.name().toLowerCase();
......
......@@ -283,6 +283,13 @@ public class NLShelfHandler extends BaseDeviceHandler {
}
}
if (pos != null) {
//判断当前库位是否有任务
Collection<String> excludePosIds = taskService.excludePosIds();
if(excludePosIds.contains(pos.getId())){
throw new ValidateException("smfcore.shelf.nextPos.hasTask", "库位[{0}]已有任务,请重新扫描库位码",new String[]{pos.getPosName()});
}
//扫描的为库位条码,先关掉上一个库位灯, 当前库位中没有物料的话点亮库位灯
closeLastPos(token);
//判断库位是否是对应设备或者租
......
......@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
......@@ -35,6 +36,7 @@ import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
......@@ -44,6 +46,7 @@ import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
/**
* 缓存
......@@ -942,4 +945,15 @@ public class DataCache {
return inOutData;
}
public List getCacheList(String keyStr) {
List<Object> list = new ArrayList<>();
for (Map.Entry<String, Object> entry : cacheMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.startsWith(keyStr)) {
list.add(value);
}
}
return list;
}
}
......@@ -10,6 +10,7 @@ import com.neotel.smfcore.core.humiture.rest.bean.query.HumitureQueryCriteria;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.msd.bean.MSDSettiings;
import com.neotel.smfcore.core.solder.bean.SpSettings;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.manager.IHumitureManager;
import com.neotel.smfcore.core.system.service.po.Humiture;
import io.swagger.annotations.Api;
......@@ -44,22 +45,22 @@ public class HumitureController {
@GetMapping("api/humiture/list")
public HumitureDto info(HumitureQueryCriteria criteria, Pageable pageable) {
MSDSettiings msdSettiings = dataCache.getCache(Constants.CACHE_msdSetting);
if (msdSettiings == null){
if (msdSettiings == null) {
msdSettiings = new MSDSettiings();
}
Float maxTemperature = msdSettiings.getMaxTemperature();
Float maxHumidity = msdSettiings.getMaxHumidity();
Float minTemperature=msdSettiings.getMinTemperature();
Float minHumidity=msdSettiings.getMinHumidity();
Float minTemperature = msdSettiings.getMinTemperature();
Float minHumidity = msdSettiings.getMinHumidity();
List<String> cids = criteria.getCids();
if (cids == null || cids.isEmpty()){
if (cids == null || cids.isEmpty()) {
criteria.setCids(SecurityUtils.getUserGroupCid());
}
Query query = QueryHelp.getQuery(criteria);
query.with(Sort.by(Sort.Direction.ASC, "createDate"));
query.addCriteria(Criteria.where("temperature").ne("0"));
PageData<Humiture> humitureList = humitureManager.findByPage(query,pageable);
PageData<Humiture> humitureList = humitureManager.findByPage(query, pageable);
HumitureDto restultDto = new HumitureDto();
restultDto.setMaxHumidity(maxHumidity);
restultDto.setMinHumidity(minHumidity);
......@@ -69,7 +70,7 @@ public class HumitureController {
//获取锡膏料仓冷藏区温度设置
SpSettings spSettings = dataCache.getCache(Constants.CACHE_spSettings);
if(spSettings==null) {
if (spSettings == null) {
spSettings = new SpSettings();
}
restultDto.setMinColdAreaTemp(spSettings.getMinColdAreaTemp());
......@@ -77,6 +78,7 @@ public class HumitureController {
return restultDto;
}
public static boolean isSpStorage = false;
@ApiOperation("导出温湿度列表")
@GetMapping(value = "api/humiture/list/download")
......@@ -88,22 +90,42 @@ public class HumitureController {
Float maxTemperature = msdSettiings.getMaxTemperature();
Float maxHumidity = msdSettiings.getMaxHumidity();
List<String> cids = criteria.getCids();
if (cids == null || cids.isEmpty()){
if (cids == null || cids.isEmpty()) {
criteria.setCids(SecurityUtils.getUserGroupCid());
}
Query query = QueryHelp.getQuery(criteria);
query.with(Sort.by(Sort.Direction.ASC, "createDate"));
query.addCriteria(Criteria.where("temperature").ne("0"));
//如果有一个锡膏料仓,就添加冷藏区
Map<String, Storage> allStorages = dataCache.getAllStorage();
boolean isSp = false;
for (Storage s :
allStorages.values()) {
if (s.isSolderPaste()) {
isSp = true;
}
}
isSpStorage = isSp;
FileUtil.downloadExcel(query, pageable, response, new IExcelDownLoad() {
@Override
public List<List<String>> getHeader() {
List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.cid", locale, "CID")));
if (isSpStorage) {
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.ntemperature", locale, "回温区温度")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.codetemperature", locale, "冷藏区温度")));
}else{
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.temperature", locale, "温度")));
}
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.humiture", locale, "湿度")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.createDate", locale, "创建时间")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.updateDate", locale, "更新时间")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.createDate", locale, "时间")));
// header.add(Lists.newArrayList(MessageUtils.getText("smfcore.humiture.updateDate", locale, "更新时间")));
return header;
}
......@@ -121,9 +143,12 @@ public class HumitureController {
List<Object> data = new ArrayList<>();
data.add(humiture.getCid());
data.add(humiture.getTemperature());
if (isSpStorage) {
data.add(humiture.getCodeAirTemp());
}
data.add(humiture.getHumidity());
data.add(createDate);
data.add(updateDate);
// data.add(updateDate);
dataList.add(data);
}
return dataList;
......
......@@ -137,24 +137,50 @@ public class LanguageMsgController {
@ApiOperation("查询列表")
@GetMapping
@PreAuthorize("@el.check('translation')")
public PageData<LanguageMsgDto> query(LanguageMsgCriteria criteria, Pageable pageable){
public PageData<LanguageMsgDto> query(LanguageMsgCriteria criteria, Pageable pageable) {
List<String> typeList=languageMsgManager.findTypeList();
List<String> typeList = languageMsgManager.findTypeList();
int languageSize=messageService.getAllLanList().size();
Query query= QueryHelp.getQuery(criteria);
int languageSize = messageService.getAllLanList().size();
Query query = QueryHelp.getQuery(criteria);
if (criteria.getTranslationState() != null) {
if (criteria.getTranslationState() == 1) {
query.addCriteria(Criteria.where("contentList").size(languageSize));
} else if (criteria.getTranslationState() == 2) {
// db.getCollection('languageMsg').find({ "contentList.3" : { "$exists" : 0 } })
String proName="contentList."+(languageSize-1);
String proName = "contentList." + (languageSize - 1);
query.addCriteria(Criteria.where(proName).exists(false));
}
}
PageData<LanguageMsg> barcodes=languageMsgManager.findByPage(query,pageable);
List<LanguageMsgDto> barcodeDtos=languageMsgMapper.toDto(barcodes.getContent());
return new PageData(barcodeDtos,barcodes.getTotalElements());
PageData<LanguageMsg> barcodes = languageMsgManager.findByPage(query, pageable);
List<LanguageMsg> languageMsgList = barcodes.getContent();
if (languageMsgList != null && !languageMsgList.isEmpty()) {
for (LanguageMsg languageMsg : languageMsgList) {
List<Content> contentList = languageMsg.getContentList();
if (contentList == null) {
contentList = new ArrayList<>();
}
List<String> allLantypeList = messageService.getAllLanList();
for (String type : allLantypeList) {
boolean hasType = false;
for (Content content : contentList) {
if (type.equals(content.getLanCode())) {
hasType = true;
break;
}
}
if (!hasType) {
languageMsg.setContent(type, "");
}
}
}
}
List<LanguageMsgDto> barcodeDtos = languageMsgMapper.toDto(languageMsgList);
return new PageData(barcodeDtos, barcodes.getTotalElements());
}
@ApiOperation("新增资源")
@PostMapping
......
......@@ -331,8 +331,14 @@ public class LanguageMsgService {
newLanguageList.add(msg);
} else {
boolean isUpdate = false;
if(!oldMsg.getEdited()){
isNeedUpdate=true;
boolean needUpdate = false;
if (!oldMsg.getEdited()) {
needUpdate = true;
}
if (isNeedUpdate){
needUpdate = true;
}
//只新增不修改
List<String> allLanList = getAllLanList();
......@@ -340,7 +346,7 @@ public class LanguageMsgService {
String oldValue = oldMsg.getContent(lanType);
String newValue = msg.getContent(lanType);
if (ObjectUtil.isNotEmpty(newValue)) {
if (ObjectUtil.isEmpty(oldValue)||(isNeedUpdate &&(!newValue.equals(oldValue))) ) {
if (ObjectUtil.isEmpty(oldValue)||(needUpdate &&(!newValue.equals(oldValue))) ) {
oldMsg.setContent(lanType, newValue);
isUpdate = true;
//内容默认更改为中文
......
......@@ -367,6 +367,40 @@ public class TaskService {
return null;
}
/**
* 根据料仓编号和库位获取已完成/取消的任务
*
* @param cid
* @param posName
* @return
*/
public List<DataLog> findFinishedTaskList(String cid, String posName, String barcode, boolean putInTask) {
List<DataLog> dataLogList = new ArrayList<>();
Collection<DataLog> areaFinishedTasks = theFinishedTaskMap.values();
for (DataLog task : areaFinishedTasks) {
boolean isSameTask = false;
if (ObjectUtil.isNotEmpty(posName) && task.getPosName().equals(posName) && task.getCid().equals(cid)) {
isSameTask = true;
} else if (ObjectUtil.isNotEmpty(barcode) && task.getBarcode().equals(barcode) && task.getCid().equals(cid)) {
isSameTask = true;
}
if (isSameTask) {
if (putInTask) {
if (task.isPutInTask()) {
dataLogList.add(task);
}
} else {
if (task.isCheckOutTask()) {
dataLogList.add(task);
}
}
}
}
return dataLogList;
}
/**
* 根据cid 和 posName ,barcode 查找正在执行的任务,不存在时返回 null
*/
......@@ -549,6 +583,10 @@ public class TaskService {
public synchronized String checkout(StoragePos pos, boolean forceOut, String subSourceId, boolean isSingleOut) {
return checkout(pos,forceOut,subSourceId,isSingleOut,"");
}
public synchronized String checkout(StoragePos pos, boolean forceOut, String subSourceId, boolean isSingleOut,String rgbCode) {
Barcode barcode = pos.getBarcode();
if (barcode != null) {
......@@ -589,6 +627,12 @@ public class TaskService {
task.setType(OP.CHECKOUT);
task.setStatus(OP_STATUS.WAIT.name());
task.setSingleOut(isSingleOut);
//判断颜色是否为空
if (StringUtils.isNotBlank(rgbCode)){
task.setLightColor(rgbCode);
}
//工单出库任务
if (!Strings.isNullOrEmpty(subSourceId)) {
// LiteOrderItem liteOrderItem = liteOrderItemDao.findOneById(subSourceId);
......
package com.neotel.smfcore.custom.hicks20714;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.core.api.SmfApi;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class HicksMenu {
@Autowired
MenuInit menuInit;
@Autowired
SmfApi smfApi;
@PostConstruct
public void init() {
String[] menus = new String[]{
"LNBResidue"
};
menuInit.labelMenu("hicks", menus);
String apiName = smfApi.getApiName();
if (Strings.isNotBlank(apiName) && apiName.equals("hicks")) {
menuInit.showMenu(apiName);
}
}
}
package com.neotel.smfcore.custom.hicks20714.bean;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import lombok.ToString;
/**
* LNB残数信息
*/
@Data
@ToString
public class LNBResidueInfo {
@ExcelProperty(value = "Splicing remaining time")
private String splicingRemainingTime;
@ExcelProperty(value = "Machine No.")
private String machineNo;
@ExcelProperty(value = "Table No.")
private String tableNo;
@ExcelProperty(value = "Table")
private String table;
@ExcelProperty(value = "Feeder")
private String feeder;
@ExcelProperty(value = "Part name")
private String partName;
@ExcelProperty(value = "Remaining reel")
private String remainingReel;
@ExcelProperty(value = "Remaining chips")
private String remainingChips;
@ExcelProperty(value = "Remaining PCBs")
private String remainingPCBs;
@ExcelProperty(value = "Z")
private String z;
@ExcelProperty(value = "Exchange Frequency")
private String exchangeFrequency;
@ExcelProperty(value = "Parts empty remaining time")
private String partsEmptyRemainingTime;
@ExcelProperty(value = "Feeder serial")
private String feederSerial;
@ExcelProperty(value = "Machine name")
private String machineName;
@ExcelProperty(value = "Address")
private String address;
@ExcelProperty(value = "Sub")
private String sub;
@ExcelProperty(value = "Current LotName")
private String currentLotName;
@ExcelProperty(value = "Splice LotName")
private String spliceLotName;
@ExcelProperty(value = "Warning Status")
private String warningStatus;
/**
* 默认没有出库
*/
private boolean isOut = false;
private boolean isLight = false;
}
package com.neotel.smfcore.custom.hicks20714.bean.dto;
import com.neotel.smfcore.custom.hicks20714.bean.LNBResidueInfo;
import lombok.Data;
import java.util.List;
@Data
public class LNBResidueInfoDto {
// 0不展示亮灯, 1展示亮灯
boolean isLight = false;
//解析的详细信息
List<LNBResidueInfo> residueInfoList;
}
package com.neotel.smfcore.custom.hicks20714.rest;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
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.TaskService;
import com.neotel.smfcore.custom.hicks20714.bean.LNBResidueInfo;
import com.neotel.smfcore.custom.hicks20714.bean.dto.LNBResidueInfoDto;
import com.neotel.smfcore.custom.hicks20714.util.HicksUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Slf4j
@RestController
@RequestMapping("/hicks")
public class HicksController {
@Autowired
private DataCache dataCache;
/**
* 是否刷新页面
*
* @return
*/
@RequestMapping("/isRefreshIndex")
@AnonymousAccess
public ResultBean isRefreshIndex() {
boolean isRefresh = HicksUtil.isIsRefresh();
if (isRefresh) {
HicksUtil.setIsRefresh(false);
}
return ResultBean.newOkResult(isRefresh);
}
/**
* 获取LNB残数详情
*
* @return
*/
@RequestMapping("/getLNBResidueInfo")
@AnonymousAccess
public ResultBean getLNBResidueInfo() {
LNBResidueInfoDto dto = new LNBResidueInfoDto();
List<LNBResidueInfo> infoList = HicksUtil.getInfo();
for (LNBResidueInfo lnbResidueInfo : infoList) {
lnbResidueInfo.setLight(HicksUtil.idNeedLight(Arrays.asList(lnbResidueInfo)));
}
dto.setResidueInfoList(infoList);
return ResultBean.newOkResult(dto);
}
/**
* 亮灯出库
*
* @return
*/
@RequestMapping("/lightOut")
@AnonymousAccess
public ResultBean lightOut(String machineNo,String tableNo,String table,String feeder) {
List<LNBResidueInfo> infoList = HicksUtil.getInfo();
String id = machineNo +"_"+tableNo+"_"+table+"_"+feeder;
LNBResidueInfo info = null;
for (LNBResidueInfo lnbResidueInfo : infoList) {
String lnbResidueInfoId = lnbResidueInfo.getMachineNo() + "_" + lnbResidueInfo.getTableNo() + "_" + lnbResidueInfo.getTable() + "_" + lnbResidueInfo.getFeeder();
if (lnbResidueInfoId.equals(id)){
info = lnbResidueInfo;
break;
}
}
int count = 0;
if (info != null){
count = HicksUtil.lightOut(Arrays.asList(info));
}
if (count == 0){
return ResultBean.newErrorResult(-1,"smfcore.label.noReel","未找到可出库的物料");
}
return ResultBean.newOkResult("");
}
//是否自动亮灯
@RequestMapping("/isAutoLight")
@AnonymousAccess
public ResultBean isAutoLight(String isAutoLight) {
Boolean auto = Boolean.valueOf(isAutoLight);
dataCache.updateCache(HicksUtil.HICKS_AUTO_LIGHT, Boolean.valueOf(auto));
if(auto) {
HicksUtil.setIsRefresh(true);
List<LNBResidueInfo> infoList = HicksUtil.getInfo();
int count = HicksUtil.lightOut(infoList);
if (count == 0){
return ResultBean.newErrorResult(-1,"smfcore.label.noReel","未找到可出库的物料");
}
}
return ResultBean.newOkResult("");
}
//亮灯时间设置
@RequestMapping("/timeSetting")
@AnonymousAccess
public ResultBean timeSetting(String time) {
try {
dataCache.updateCache(HicksUtil.HICKS_TIME_SETTING, time);
HicksUtil.setIsRefresh(true);
} catch (Exception e) {
e.printStackTrace();
return ResultBean.newErrorResult(-1, "", "设置失败,请确认格式是否为数字");
}
return ResultBean.newOkResult("");
}
//获取设置
@RequestMapping("/getSetting")
@AnonymousAccess
public ResultBean getSetting(){
boolean isAutoLight = dataCache.getCache(HicksUtil.HICKS_AUTO_LIGHT) == null ? false : dataCache.getCache(HicksUtil.HICKS_AUTO_LIGHT);
String time = dataCache.getCache(HicksUtil.HICKS_TIME_SETTING) == null ? 20+"" : dataCache.getCache(HicksUtil.HICKS_TIME_SETTING);
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("isAutoLight",isAutoLight);
resultMap.put("time",time);
return ResultBean.newOkResult(resultMap);
}
}
\ No newline at end of file
package com.neotel.smfcore.custom.hicks20714.util;
import com.google.common.collect.Lists;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;
@Slf4j
@Component
public class FileUtil {
/**
* 读取远程最新的文件
*
* @param path
* @return
*/
public static SmbFile getSmbFile(String path, String userName, String password) {
List<SmbFile> fileList = smbFileList(path, userName, password);
if (fileList != null && !fileList.isEmpty()) {
fileList = fileList.stream().sorted(Comparator.comparing(SmbFile::getDate).reversed()).collect(Collectors.toList());
return fileList.get(0);
}
return null;
}
/**
* 列出SMB服务器文件夹中的所有文件名称,如果目录不存在或者访问出错返回null
*/
public static List<SmbFile> smbFileList(String smbDir, String userName, String password) {
try {
//String domain = "admin";
NtlmPasswordAuthentication nt = new NtlmPasswordAuthentication(null,userName,password);
SmbFile remoteFile = new SmbFile(smbDir, nt);
//SmbFile remoteFile = new SmbFile(smbDir);
if (remoteFile.exists() && remoteFile.isDirectory()) {
SmbFile[] smbFiles = remoteFile.listFiles();
return Lists.newArrayList(smbFiles);
} else {
log.info("SMB目录[" + smbDir + "]不存在");
}
} catch (Exception e) {
log.error("访问SMB目录[" + smbDir + "]出错", e);
}
return null;
}
/**
* 删除文件
*
* @param file
* @return
*/
public static boolean deleteFile(File file) {
//判断文件不为null或文件目录存在
if (file == null || !file.exists()) {
return false;
}
//取得这个目录下的所有子文件对象
File[] files = file.listFiles();
if (files == null) {
file.delete();
return true;
}
//遍历该目录下的文件对象
for (File f : files) {
//判断子目录是否存在子目录,如果是文件则删除
if (f.isDirectory()) {
deleteFile(f);
} else {
f.delete();
}
}
return true;
}
}
package com.neotel.smfcore.custom.hicks20714.util;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.utils.SmbUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
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.TaskService;
import com.neotel.smfcore.custom.hicks20714.bean.LNBResidueInfo;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class HicksUtil {
@Value("${smd.filePath}")
private String smdFilePath;
@Value("${smd.userName}")
private String userName;
@Value("${smd.password}")
private String password;
@Autowired
SmfApi smfApi;
private static DataCache dataCache;
@Autowired
private void setDataCache(DataCache cache){
HicksUtil.dataCache = cache;
}
private static TaskService taskService;
@Autowired
private void setTaskService(TaskService service){
HicksUtil.taskService = service;
}
private static IStoragePosManager storagePosManager;
@Autowired
private void setStoragePosManager(IStoragePosManager manager){
HicksUtil.storagePosManager = manager;
}
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
//读取文件信息前缀
public static final String PREFIX = "Hicks_Info_";
//保存上一次存的文件key
public static String LAST_READ_FILE_NAME = "Hicks_Last_Read_File_Name";
//本地存放路径
public static final String tempFilePath = "temp_hicks/";
//是否自动亮灯
public static final String HICKS_AUTO_LIGHT = "hicks_auto_light";
//亮灯时间设置
public static final String HICKS_TIME_SETTING = "hicks_time_setting";
//远程文件地址
public static final String HICKS_REMOTE_FILEPATH = "hicks_remote_filepath";
public static final String HICKS_REMOTE_USERNAME = "hicks_remote_username";
public static final String HICKS_REMOTE_PASSWORD = "hicks_remote_password";
//信息缓存
public static Map<String, LNBResidueInfo> infoMap = Maps.newConcurrentMap();
//是否需要刷新页面
public static boolean isRefresh = true;
@PostConstruct
public void init() {
readMapCache();
String remoteFilePath = dataCache.getConfigCache(HICKS_REMOTE_FILEPATH, smdFilePath);
String remoteUserName = dataCache.getConfigCache(HICKS_REMOTE_USERNAME, userName);
String remotePassword = dataCache.getConfigCache(HICKS_REMOTE_PASSWORD, password);
scheduledThreadPool.scheduleAtFixedRate(() -> {
if (StringUtils.isBlank(remoteFilePath)){
return;
}
if(!"hicks".equals(smfApi.getApiName())){
return;
}
//开始获取最新的文件
SmbFile smbFile = FileUtil.getSmbFile(remoteFilePath,remoteUserName,remotePassword);
if (smbFile != null) {
String lastReadFileName = dataCache.getCache(LAST_READ_FILE_NAME);
//如果和上一次不相同,则重新读取
if (!smbFile.getName().equals(lastReadFileName)) {
//放到本地路径下
boolean isSuccess = SmbUtil.smbGetByAuth(smbFile.getPath(), new NtlmPasswordAuthentication(null,remoteUserName,remotePassword),tempFilePath);
if (isSuccess) {
//删除本地中的其他文件
File tempFile = new File(tempFilePath);
if (tempFile.exists() && tempFile.isDirectory()) {
File[] files = tempFile.listFiles();
for (File temp : files) {
if (!temp.getName().equals(smbFile.getName())) {
FileUtil.deleteFile(temp);
}
}
}
//读取文件信息,放到缓存map
List<LNBResidueInfo> infoList = readTempFile(new File(tempFilePath + smbFile.getName()));
if (infoList != null && !infoList.isEmpty()) {
updateInfoMap(infoList);
boolean isAutoLight = dataCache.getCache(HICKS_AUTO_LIGHT) == null ? false : dataCache.getCache(HICKS_AUTO_LIGHT);
if (isAutoLight){
log.info("自动亮灯出库");
int count = lightOut(infoList);
log.info("自动亮灯出库的数量为:"+count);
}
}
dataCache.updateCache(LAST_READ_FILE_NAME, smbFile.getName());
setIsRefresh(true);
}
}
}
}, 10, 5, TimeUnit.SECONDS);
}
/**
* 读取文件信息
*/
public static List<LNBResidueInfo> readTempFile(File file) {
List<LNBResidueInfo> list = new ArrayList<>();
if (file != null) {
EasyExcel.read(file.getPath(), LNBResidueInfo.class, new ReadListener<LNBResidueInfo>() {
@Override
public void invoke(LNBResidueInfo data, AnalysisContext analysisContext) {
list.add(data);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}).charset(StandardCharsets.UTF_8).sheet().doRead();
}
return list;
}
/**
* 读取map缓存信息
*/
private void readMapCache() {
List<LNBResidueInfo> list = dataCache.getCacheList(PREFIX);
if (list != null && !list.isEmpty()) {
for (LNBResidueInfo info : list) {
String key = PREFIX + info.getMachineNo() + "_" + info.getTableNo() + "_" + info.getTable() + "_" + info.getFeeder();
infoMap.put(key, info);
}
}
}
/**
* 修改map信息
*
* @param infoList
*/
public static void updateInfoMap(List<LNBResidueInfo> infoList) {
for (LNBResidueInfo info : infoList) {
String key = PREFIX + info.getMachineNo() + "_" + info.getTableNo() + "_" + info.getTable() + "_" + info.getFeeder();
infoMap.put(key, info);
dataCache.updateCache(key, info);
}
}
public static List<LNBResidueInfo> getInfo() {
List<LNBResidueInfo> list = new ArrayList<>();
if (infoMap != null && !infoMap.isEmpty()) {
for (LNBResidueInfo info : infoMap.values()) {
list.add(info);
}
}
return list;
}
public static int lightOut(List<LNBResidueInfo> infoList) {
int count = 0;
int cacheTime = dataCache.getCache(HICKS_TIME_SETTING) == null ? 20 : Integer.valueOf(dataCache.getCache(HICKS_TIME_SETTING));
if (infoList != null && !infoList.isEmpty()) {
for (LNBResidueInfo info : infoList) {
try {
List<String> availableStorageIds = dataCache.getAvailableStorageIds();
CHECKOUT_TYPE checkoutType = dataCache.getCheckOutType();
Collection<String> excludePosIds = taskService.excludePosIds();
int time = getPartsEmptyRemainingTime(info.getPartsEmptyRemainingTime());
if (!info.isOut() && time <= cacheTime) {
StoragePos pos = storagePosManager.findPartNumberInStorages(availableStorageIds, info.getPartName(), excludePosIds, checkoutType);
if (pos != null) {
DataLog dataLog = new DataLog(dataCache.getStorageById(pos.getStorageId()), pos.getBarcode(), pos);
dataLog.setType(OP.CHECKOUT);
dataLog.setStatus(OP_STATUS.WAIT.name());
taskService.addTaskToExecute(dataLog);
info.setOut(true);
HicksUtil.updateInfoMap(Arrays.asList(info));
count++;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return count;
}
//是否需要亮灯
public static boolean idNeedLight(List<LNBResidueInfo> list) {
int cacheTime = dataCache.getCache(HICKS_TIME_SETTING) == null ? 20 : Integer.valueOf(dataCache.getCache(HICKS_TIME_SETTING));
for (LNBResidueInfo lnbResidueInfo : list) {
try {
int time = getPartsEmptyRemainingTime(lnbResidueInfo.getPartsEmptyRemainingTime());
//时间小于设定的分钟,且没有出过库的需要展示亮灯
if (time <= cacheTime) {
if (!lnbResidueInfo.isOut()) {
return true;
}
}
} catch (Exception e) {
log.error("解析partsEmptyRemainingTime时间出错:" + e.getMessage());
e.printStackTrace();
}
}
return false;
}
private static int getPartsEmptyRemainingTime(String timeStr) throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
Date parse = simpleDateFormat.parse(timeStr);
int minutes = parse.getMinutes();
int hours = parse.getHours();
return (minutes + hours * 60);
}
public static boolean isIsRefresh() {
return isRefresh;
}
public static void setIsRefresh(boolean isRefresh) {
HicksUtil.isRefresh = isRefresh;
}
}
\ No newline at end of file
package com.neotel.smfcore.custom.iriichi1081;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.iriichi1081.config.IriichiConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.IgnoredErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class IriichiApi extends BaseSmfApiListener {
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private LiteOrderCache liteOrderCache;
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("iriichi");
}
@Override
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username) {
String token = getToken();
if (StringUtils.isBlank(token)) {
log.info(orderNumber + "获取token信息失败");
return null;
}
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Authorization", token);
headerMap.put("Accept", IriichiConfig.accept);
/* Map<String, Object> paramMap = new HashMap<>();
paramMap.put("customloadmethod", "IR_GetJobMaterialPickListSp");
paramMap.put("customloadmethodparms", orderNumber);
paramMap.put("loadtype", "NEXT");
paramMap.put("readonly", "TRUE");*/
try {
String result = HttpHelper.getJson(fetchOrderUrl +
"?customloadmethod=IR_GetJobMaterialPickListSp" +
"&readonly=true" +
"&loadtype=NEXT" +
"&customloadmethodparms=" + orderNumber, headerMap, null);
return getOrderByResult(orderNumber, result);
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
public void cycleCount(Barcode barcode) {
String token = getToken();
if (StringUtils.isBlank(token)) {
log.info(barcode.getBarcode() + "获取token信息失败");
return;
}
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Authorization", token);
headerMap.put("Accept", IriichiConfig.accept);
String parms = barcode.getPartNumber()
+ ","
+ barcode.getMemo()
+ ","
+ barcode.getPosName()
+ ","
+ barcode.getBatch()
+ ","
+ barcode.getAmount()
+ ","
+ barcode.getPutInDateStr()
+ ","
+ "NULL"
+ ","
+ "NULL";
log.info(barcode.getBarcode() + "cycleCount入参为:" + parms);
try {
String result = HttpHelper.getJson(IriichiConfig.cycleCount_url + "?parms=" + parms, headerMap, null);
} catch (ApiException e) {
e.printStackTrace();
}
}
public String getToken() {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("UserId", IriichiConfig.userId);
headerMap.put("Password", IriichiConfig.passWord);
headerMap.put("Accept", IriichiConfig.accept);
try {
String result = HttpHelper.getJson(IriichiConfig.token_url, headerMap, null);
JSONObject jsonObject = JSONObject.parseObject(result);
if ("Success".equals(jsonObject.getString("Message"))) {
return jsonObject.getString("Token");
}
} catch (ApiException e) {
e.printStackTrace();
}
return "";
}
private LiteOrder getOrderByResult(String orderNo, String result) {
JSONObject resultObj = JSONObject.parseObject(result);
List<List<Map<String, String>>> itemArr = resultObj.getObject("Items", List.class);
List<LiteOrderItem> itemList = new ArrayList<>();
for (List<Map<String, String>> mapList : itemArr) {
LiteOrderItem orderItem = new LiteOrderItem();
for (Map<String, String> map : mapList) {
if ("item_code".equals(map.get("Name"))) {
orderItem.setPn(map.get("Value"));
} else if ("qty_to_pick".equals(map.get("Name"))) {
try {
orderItem.setNeedReelCount(NumberUtil.parseInt(map.get("Value")));
} catch (Exception e) {
e.printStackTrace();
}
}
}
itemList.add(orderItem);
}
if (itemList != null && !itemList.isEmpty()) {
LiteOrder order = new LiteOrder();
order.setOrderItems(itemList);
liteOrderManager.createWithItems(order);
liteOrderCache.addOrderToMap(order);
return order;
}
return null;
}
}
package com.neotel.smfcore.custom.iriichi1081;
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;
@Component
public class IriichiMenu {
@Autowired
MenuInit menuInit;
@Autowired
SmfApi smfApi;
@PostConstruct
public void init(){
String menuLabel = "iriichi";
MenuInit.addMenu(menuLabel,null,124, "Cycle Count","cycleCount", "neolight/cycleCount/index","");
String apiName = smfApi.getApiName();
if(Strings.isNotBlank(apiName) && apiName.equals(menuLabel)){
menuInit.showMenu(apiName);
}
}
}
package com.neotel.smfcore.custom.iriichi1081.config;
public class IriichiConfig {
//config name
public static final String iriichi_config_name = "app_neotel";
public static final String iriichi_crp_config_name = "Neotel@478*";
// token url
public static final String token_url = "http://myprai.iriichi.com.my:8888/IDORequestService/MGRestService.svc/json/token/IRIICHI_CRP";
// Job Material Picklist url 在配置文件中,配置fetchOrderUrl 地址
//public static final String picklist_url = "http://myprai.iriichi.com.my:8888/IDORequestService/MGRestService.svc/json/IR_SLAPIs/pick_list,job,job_suffix,job_item,job_item_desc,item_code,Rating,workcenter,vendnum,vendor_name,qty_to_pick/adv";
//Cycle Count url
public static final String cycleCount_url = "http://myprai.iriichi.com.my:8888/IDORequestService/MGRestService.svc/json/method/IR_SLAPIs/IR_InsertCycleCountSp";
// userId
public static final String userId = "app_neotel";
//password
public static final String passWord = "Neotel@478*";
//请求类型
public static final String accept = "application/json";
}
package com.neotel.smfcore.custom.iriichi1081.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.custom.iriichi1081.IriichiApi;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@RestController
@RequestMapping("/cycleCount")
public class CycleCountController {
@Autowired
private IriichiApi iriichiApi;
@Autowired
private IStoragePosManager storagePosManager;
private boolean cycleCount = false;
/**
* 发送库存信息
*
* @return
*/
@RequestMapping("/cycle")
//@AnonymousAccess
public ResultBean CycleCount() {
//10分钟内 不允许重复点击
if (cycleCount) {
return ResultBean.newErrorResult(-1, "smfcore.cyclecount.executing", "Cycle Count正在执行中");
}
cycleCount = true;
List<StoragePos> storagePosList = storagePosManager.findNotEmpty();
for (StoragePos storagePos : storagePosList) {
try {
iriichiApi.cycleCount(storagePos.getBarcode());
} catch (Exception e) {
e.printStackTrace();
}
}
cycleCount = false;
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.neotel;
import cn.hutool.core.util.NumberUtil;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
......@@ -178,7 +179,7 @@ public class NeotelApi extends BaseSmfApiListener {
String qtyStr = getData(dataMap, "qty");
if (Strings.isNotBlank(qtyStr)) {
int qty = Integer.valueOf(qtyStr);
int qty = NumberUtil.parseInt(qtyStr);
if (qty > 0) {
barcode.setAmount(qty);
}
......@@ -199,6 +200,16 @@ public class NeotelApi extends BaseSmfApiListener {
log.error("日期转换出错", e);
}
try {
String expireDateStr = getData(dataMap, "expireDate");
if (Strings.isNotBlank(expireDateStr)) {
Date expireDate = DateUtil.toDate(expireDateStr, "yyyy-MM-dd HH:mm:ss");
barcode.setExpireDate(expireDate);
}
} catch (Exception e) {
log.error("日期转换出错", e);
}
resolveComponent(barcode);
barcode = barcodeManager.saveBarcode(barcode);
return barcode;
......@@ -250,7 +261,7 @@ public class NeotelApi extends BaseSmfApiListener {
String qtyStr = getData(dataMap, "qty");
if (Strings.isNotBlank(qtyStr)) {
int qty = Integer.valueOf(qtyStr);
int qty = NumberUtil.parseInt(qtyStr);
if (qty > 0) {
barcode.setAmount(qty);
}
......@@ -271,7 +282,17 @@ public class NeotelApi extends BaseSmfApiListener {
log.error("日期转换出错", e);
}
barcode = barcodeManager.saveBarcode(barcode);
try {
String expireDateStr = getData(dataMap, "expireDate");
if (Strings.isNotBlank(expireDateStr)) {
Date expireDate = DateUtil.toDate(expireDateStr, "yyyy-MM-dd HH:mm:ss");
barcode.setExpireDate(expireDate);
}
} catch (Exception e) {
log.error("日期转换出错", e);
}
barcode = barcodeManager.save(barcode);
return barcode;
} else {
return null;
......
......@@ -30,6 +30,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.util.Integers;
......@@ -38,6 +39,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
......@@ -69,6 +71,31 @@ public class MesApiController {
@Autowired
protected CodeResolve codeResolve;
private Map<String,String> colorMap = Maps.newConcurrentMap();
@PostConstruct
private void initColor() {
colorMap.put("FF0000", "Red");
colorMap.put("FFC0CB", "Pink");
colorMap.put("C71585", "Medium Violet Red");
colorMap.put("FF8C00", "Dark Orange");
colorMap.put("FFFF00", "Yellow");
colorMap.put("BDB76B", "Dark Khaki");
colorMap.put("E6E6FA", "Lavender");
colorMap.put("9370DB", "Medium Purple");
colorMap.put("800080", "Purple");
colorMap.put("ADFF2F", "Green Yellow");
colorMap.put("98FB98", "Pale Green");
colorMap.put("008000", "Green");
colorMap.put("808000", "Olive");
colorMap.put("00FFFF", "Aqua");
colorMap.put("7FFFD4", "Aquamarine");
colorMap.put("B0C4DE", "Light Steel Blue");
colorMap.put("0000FF", "Blue");
colorMap.put("FFE4C4", "Bisque");
colorMap.put("f4A460", "Sandy Brown");
}
//http://localhost/myproject/rest/api/v2/mes/inventory?LOC=1
@ApiOperation("查询有料仓位")
@RequestMapping(value = "/inventory")
......@@ -217,11 +244,18 @@ public class MesApiController {
try {
String[] REEL_IDS = request.getParameterValues("RIS");
String rgbCode = request.getParameter("rgbCode"); //亮灯颜色
if(REEL_IDS == null || REEL_IDS.length == 0){
return "Error: RI 为必须项";
}
//判断亮灯颜色是否在这20种内
if (StringUtils.isBlank(colorMap.get(rgbCode)) || StringUtils.isBlank(rgbCode)){
return "Error :rgbCode不在指定范围内";
//return "Error: rgbCode 不在颜色范围内";
}
ArrayList<StoragePos> poses = Lists.newArrayList();
for (String REEL_ID : REEL_IDS) {
StoragePos pos = storagePosManager.getByBarcode(REEL_ID);
......@@ -232,7 +266,7 @@ public class MesApiController {
}
for (StoragePos pos : poses) {
log.info("出库位置仓位【"+pos.getPosName()+"】");
taskService.checkout(pos,false,null,false);
taskService.checkout(pos,false,null,false,rgbCode);
}
}catch (Exception e){
......
package com.neotel.smfcore.mimo.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.BetweenData;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.StringUtils;
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.elecKanban.bean.dto.ElecKanbanBoxStatusDto;
import com.neotel.smfcore.core.elecKanban.bean.dto.InOutDataDto;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import com.neotel.smfcore.core.kanban.rest.bean.dto.BoxStatusDto;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.rest.bean.dto.MessageDto;
import com.neotel.smfcore.core.message.rest.bean.mapstruct.MessageMapper;
import com.neotel.smfcore.core.message.rest.bean.query.MessageCriteria;
import com.neotel.smfcore.core.message.service.manager.IMessageManager;
import com.neotel.smfcore.core.message.service.po.Message;
import com.neotel.smfcore.core.msd.bean.MSDSettiings;
import com.neotel.smfcore.core.report.rest.dto.InventoryBoxDto;
import com.neotel.smfcore.core.report.rest.dto.InventoryGroupDto;
import com.neotel.smfcore.core.report.rest.query.ReportExtQuery;
import com.neotel.smfcore.core.storage.bean.UsageItem;
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 com.neotel.smfcore.security.service.manager.IGroupManager;
import com.neotel.smfcore.security.service.po.Group;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
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("/smdBoxMimo")
public class SmdBoxMimoController {
@Autowired
private IGroupManager groupManager;
@Autowired
DataCache dataCache;
@Autowired
IInOutDataManager inOutDataManager;
@Autowired
IMessageManager messageManager;
@Autowired
MessageMapper messageMapper;
@Autowired
TaskService taskService;
public static Storage storage = null;
@ApiOperation("库存分布")
@GetMapping(value = "/inventory")
@AnonymousAccess
public List<InventoryGroupDto> inventory(String cid) {
if (StringUtils.isBlank(cid)) {
Storage storage = getDefaultBox();
if (storage != null) {
cid = storage.getCid();
}
}
List<InventoryGroupDto> groupDtos = new ArrayList<>();
if (StringUtils.isNotBlank(cid)) {
List<Group> allGroup = groupManager.findAll();
allGroup.add(Group.defaulGroup());
for (Group group : allGroup) {
List<InventoryBoxDto> boxDtos = new ArrayList<>();
List<String> cidList = dataCache.getCidsByGroupId(group.getId(), false);
for (String cidStr : cidList) {
if (!cid.equals(cidStr)){
continue;
}
Storage storage = dataCache.getStorage(cidStr);
if (storage == null) {
continue;
}
int posCount = 0;
int usePosCount = 0;
for (UsageItem item : storage.getUsageMap().values()) {
posCount += item.getTotalCount();
usePosCount += item.getUsedCount();
}
InventoryBoxDto boxDto = new InventoryBoxDto(storage.getId(), storage.getName(), storage.getCid(), storage.getType(), storage.getUsageMap(), posCount, usePosCount);
boxDtos.add(boxDto);
}
if (boxDtos.size() > 0) {
InventoryGroupDto groupDto = new InventoryGroupDto(group.getId(), group.getGroupName(), boxDtos);
groupDtos.add(groupDto);
}
}
}
return groupDtos;
}
@ApiOperation("出入库统计")
@RequestMapping("/getInOutData")
@AnonymousAccess
public InOutDataDto getInOutData(ReportExtQuery query) {
InOutDataDto dto = new InOutDataDto();
List<String> dateStrList = new ArrayList<>();
List<Integer> inDataList = new ArrayList<>();
List<Integer> outDataList = new ArrayList<>();
if (query.getStorageIdList() == null || query.getStorageIdList().isEmpty()){
Storage storage = getDefaultBox();
if (storage != null) {
query.setStorageIdList(Arrays.asList(storage.getId()));
}
}
if (query.getStorageIdList() != null && !query.getStorageIdList().isEmpty()) {
//开始时间与结束时间赋值
String currentDateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH");
Date startDate = DateUtil.parse(currentDateStr, "yyyy-MM-dd HH");
Date endDate = DateUtil.parse(currentDateStr, "yyyy-MM-dd HH");
BetweenData<Date> updateDate = query.getUpdateDate();
if (updateDate != null && updateDate.size() > 0) {
Date from = updateDate.getFrom();
Date to = updateDate.getTo();
if (from != null) {
startDate = from;
}
if (to != null) {
endDate = to;
}
} else {
endDate = DateUtil.parse(currentDateStr, "yyyy-MM-dd");
endDate = DateUtil.offsetDay(endDate, 1);
startDate = DateUtil.offsetDay(endDate, -7);
}
//增加用户所属分组id
List<String> storageIdList = QueryHelp.getGroupStorageIdList(query.getStorageIdList());
//判断相差小时数,是否超过48小时
long between = DateUtil.between(startDate, endDate, DateUnit.HOUR);
List<InOutData> inOutDataList = inOutDataManager.findByDate(startDate, endDate, storageIdList);
while (startDate.getTime() < endDate.getTime()) {
DateTime nextDayTime;
if (between > 48) {
dateStrList.add(DateUtil.format(startDate, "MM/dd"));
nextDayTime = DateUtil.offsetDay(startDate, 1);
} else {
dateStrList.add(DateUtil.format(startDate, "MM/dd HH"));
nextDayTime = DateUtil.offsetHour(startDate, 1);
}
int inCount = 0, outCount = 0;
for (InOutData inOutData : inOutDataList) {
if (inOutData.getCreateDate().getTime() >= startDate.getTime() && inOutData.getCreateDate().getTime() < nextDayTime.getTime()) {
inCount = inCount + inOutData.getInCount();
outCount = outCount + inOutData.getOutCount();
}
}
inDataList.add(inCount);
outDataList.add(outCount);
if (between > 48) {
startDate = DateUtil.offsetDay(startDate, 1);
} else {
startDate = DateUtil.offsetHour(startDate, 1);
}
}
}
dto.setDateStrList(dateStrList);
dto.setInDataList(inDataList);
dto.setOutDataList(outDataList);
return dto;
}
@ApiOperation("设备状态")
@RequestMapping("/getBoxStatusDto")
@AnonymousAccess
public List<ElecKanbanBoxStatusDto> getElecKanbanBoxStatusDto(String cid) throws ParseException {
List<ElecKanbanBoxStatusDto> resultList = new ArrayList<>();
if (StringUtils.isBlank(cid)) {
Storage storage = getDefaultBox();
if (storage != null) {
cid = storage.getCid();
}
}
if (StringUtils.isNotBlank(cid)) {
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(cid);
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());
}
}
}
Storage storage = dataCache.getStorage(cid);
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());
resultList.add(dto);
}
return resultList;
}
@ApiOperation("查询消息列表")
@GetMapping("/getMessage")
@AnonymousAccess
public PageData<MessageDto> getMessage(MessageCriteria criteria, Pageable pageable, HttpServletRequest request) {
if (StringUtils.isBlank(criteria.getDeviceName())) {
Storage defaultBox = getDefaultBox();
if (defaultBox != null) {
criteria.setDeviceName(defaultBox.getName());
}
}
if (StringUtils.isNotBlank(criteria.getDeviceName())) {
Query query = QueryHelp.getQuery(criteria);
PageData<Message> messagePageData = messageManager.findByPage(query, pageable);
List<MessageDto> dtos = messageMapper.toDto(messagePageData.getContent());
for (int i = 0; i < dtos.size(); i++) {
if (ObjectUtil.isNotEmpty(dtos.get(i).getMsgCode())) {
dtos.get(i).setMsg(MessageUtils.getText(dtos.get(i).getMsgCode(), dtos.get(i).getMsgParams(), request.getLocale(), dtos.get(i).getMsg()));
}
}
return new PageData(dtos, messagePageData.getTotalElements());
}
return new PageData<>(new ArrayList<>(), 0);
}
@ApiOperation("料仓详情")
@GetMapping("/boxView")
@AnonymousAccess
public BoxStatusDto boxView(String id, HttpServletRequest servletRequest) {
List<DataLog> allTasks = taskService.getAllTasks();
Storage storage = dataCache.getStorageById(id);
if (storage == null){
storage = getDefaultBox();
}
if (storage == null) {
throw new ValidateException("smfcore.storage.error.notExist", "未找到料仓{0}", new String[]{id});
}
BoxStatusDto dto = getBoxDto(storage, allTasks, servletRequest.getLocale());
return dto;
}
/*@ApiOperation("删除消息列表")
@GetMapping("/deleteMessage")
@AnonymousAccess
public ResultBean deleteMessage(String id){
Message message = new Message();
message.setId(id);
messageManager.delete(message);
return ResultBean.newOkResult("");
}*/
private Storage getDefaultBox() {
if (storage != null) {
return storage;
}
for (Storage stor : dataCache.getAllStorage().values()) {
if (stor.isBatchStorage()) {
storage = stor;
return storage;
}
}
return null;
}
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();
}
}
private BoxStatusDto getBoxDto(Storage storage,List<DataLog> allTasks,Locale locale) {
int inTask = 0;
int outTask = 0;
for (DataLog data : allTasks) {
if (data.getStorageId().equals(storage.getId())) {
if (data.getType() == 1) {
inTask++;
} else if (data.getType() == 2) {
outTask++;
}
}
}
// if(storage.isSolderPaste()){
// outTask=solderBoxCache.getSpTaskCount(storage.getId());
// }
int allCount = inTask + outTask;
BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0,
"0", "0","0", "", allCount, inTask, outTask,
0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName());
//获取设备状态,设置状态和当前任务信息
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.getBoxStatus() == null) {
boxDto.setOnLine(false);
//如果是虚拟仓,默认在线
if(storage.isVirtual()){
boxDto.setOnLine(true);
boxDto.setStatus(1);
}
} else {
if (bean.timeOut()) {
boxDto.setOnLine(false);
for (BoxStatusBean boxStatus : bean.getBoxStatus().values()) {
// boxDto.setMsg(bean.getShowMsg(locale));
boxDto.setBarcode(bean.getCode());
boxDto.setPosName(bean.getPosId());
break;
}
} else {
boxDto.setOnLine(true);
for (BoxStatusBean boxStatus : bean.getBoxStatus().values()) {
String humidity = boxStatus.getHumidity();
String temperature = boxStatus.getTemperature();
boxDto.setHumidity(humidity);
boxDto.setTemperature(temperature);
MSDSettiings settiings = dataCache.getCache(Constants.CACHE_msdSetting);
if (settiings != null) {
if (settiings.getMinHumidity() == -1f) {
boxDto.setHumidity(0 + "");
}
if (settiings.getMinTemperature() == -1f) {
boxDto.setTemperature(0 + "");
}
}
boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp());
boxDto.setStatus(bean.getStatus());
boxDto.setMsg(bean.getShowMsg(locale));
boxDto.setBarcode(bean.getCode());
boxDto.setPosName(bean.getPosId());
boxDto.setData(bean.getData());
if (!StringUtils.isEmpty(bean.getPosId())) {
DataLog task = taskService.findExecutingTask(storage.getCid(), bean.getPosId());
if (task != null) {
boxDto.setPartNumber(task.getPartNumber());
boxDto.setSourceName(task.getSourceName());
boxDto.setCurrTaskType(task.getType());
boxDto.setCurrTaskStatus(task.getStatus());
}
}
break;
}
}
}
//如果是锡膏料仓,需要把回温区物料数量,冷藏区物料数量显示
if(storage.isSolderPaste()){
Integer warmUseCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.warmPosUseCount);
Integer coldingUseCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.coldingPosUseCount);
boxDto.getData().put(DataCache.warmPosUseCount,warmUseCount.toString());
boxDto.getData().put(DataCache.coldingPosUseCount,coldingUseCount.toString());
Integer warmCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.warmPosCount);
Integer coldingCount=dataCache.getSpUsePosCount(storage.getCid(),DataCache.coldingPosCount);
boxDto.getData().put(DataCache.warmPosCount,warmCount.toString());
boxDto.getData().put(DataCache.coldingPosCount,coldingCount.toString());
}
return boxDto;
}
}
......@@ -48,3 +48,7 @@ menu:
show:
hide:
smd:
filePath:
userName:
password:
\ No newline at end of file
......@@ -309,7 +309,7 @@ smfcore.storagePos.batch=\u6279\u6B21
smfcore.humiture.cid=CID
smfcore.humiture.temperature=\u6E29\u5EA6
smfcore.humiture.humiture=\u6E7F\u5EA6
smfcore.humiture.createDate=\u521B\u5EFA\u65F6\u95F4
smfcore.humiture.createDate=\u65F6\u95F4
smfcore.humiture.updateDate=\u66F4\u65B0\u65F6\u95F4
smfcore.order.ri=RI
smfcore.order.pn=PN
......@@ -370,3 +370,6 @@ smfcore.storagePos.weight=\u91CD\u91CF
smfcore.expireSolderPaste=\u8FC7\u671F\u9521\u818F
smfcore.spbox.backFail=\u56DE\u5E93\u9A8C\u8BC1\u5931\u8D25
smfcore.spbox.expireOut=\u8FC7\u671F\u7269\u6599\u51FA\u5E93
smfcore.humiture.codetemperature=\u51B7\u85CF\u533A\u6E29\u5EA6
smfcore.humiture.ntemperature=\u56DE\u6E29\u533A\u6E29\u5EA6
smfcore.cyclecount.executing=Cycle Count \u6B63\u5728\u6267\u884C
\ No newline at end of file
......@@ -359,3 +359,6 @@ smfcore.storagePos.weight=Weight
smfcore.expireSolderPaste=Expired Solder Paste
smfcore.spbox.backFail=Back to the library verification failure
smfcore.spbox.expireOut=Expired solder paste out of storage
smfcore.humiture.codetemperature=Refrigeration zone temperature
smfcore.humiture.ntemperature=Return temperature zone temperature
smfcore.cyclecount.executing=Cycle Count are being executed
\ No newline at end of file
......@@ -356,3 +356,6 @@ smfcore.storagePos.weight=\u91CD\u91CF
smfcore.expireSolderPaste=\u8FC7\u671F\u9521\u818F
smfcore.spbox.backFail=\u56DE\u5E93\u9A8C\u8BC1\u5931\u8D25
smfcore.spbox.expireOut=\u8FC7\u671F\u7269\u6599\u51FA\u5E93
smfcore.humiture.codetemperature=\u51B7\u85CF\u533A\u6E29\u5EA6
smfcore.humiture.ntemperature=\u56DE\u6E29\u533A\u6E29\u5EA6
smfcore.cyclecount.executing=Cycle Count \u5B9F\u884C
\ No newline at end of file
......@@ -356,3 +356,6 @@ smfcore.storagePos.weight=\u91CD\u91CF
smfcore.expireSolderPaste=\u8FC7\u671F\u9521\u818F
smfcore.spbox.backFail=\u56DE\u5E93\u9A8C\u8BC1\u5931\u8D25
smfcore.spbox.expireOut=\u8FC7\u671F\u7269\u6599\u51FA\u5E93
smfcore.humiture.codetemperature=\u51B7\u85CF\u533A\u6E29\u5EA6
smfcore.humiture.ntemperature=\u56DE\u6E29\u533A\u6E29\u5EA6
smfcore.cyclecount.executing=Cycle Count \u6B63\u5728\u6267\u884C
\ No newline at end of file
......@@ -357,3 +357,6 @@ smfcore.storagePos.weight=\u91CD\u91CF
smfcore.expireSolderPaste=\u8FC7\u671F\u9521\u818F
smfcore.spbox.backFail=\u56DE\u5EAB\u9A57\u8B49\u5931\u6557
smfcore.spbox.expireOut=\u904E\u671F\u7269\u6599\u51FA\u5EAB
smfcore.humiture.codetemperature=\u51B7\u85CF\u533A\u6E29\u5EA6
smfcore.humiture.ntemperature=\u56DE\u6E29\u533A\u6E29\u5EA6
smfcore.cyclecount.executing=Cycle Count \u6B63\u5728\u57F7\u884C
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!