Commit a8bce055 LN

Merge remote-tracking branch 'origin/master'

2 个父辈 2259f517 5683da12
...@@ -187,6 +187,14 @@ public class DateUtil { ...@@ -187,6 +187,14 @@ public class DateUtil {
return c.getTime(); return c.getTime();
} }
public static Date getCurrentDate(String aMask) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat(aMask);
Date date = new Date();
String dateStr = df.format(date);
return df.parse(dateStr);
}
public static Date getMinDate(Date date0, Date date1){ public static Date getMinDate(Date date0, Date date1){
return date0.before(date1)? date0 : date1; return date0.before(date1)? date0 : date1;
} }
......
...@@ -19,6 +19,8 @@ import cn.hutool.json.JSONArray; ...@@ -19,6 +19,8 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.storage.service.manager.IStorageManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.security.service.manager.IUserManager; import com.neotel.smfcore.security.service.manager.IUserManager;
import com.neotel.smfcore.security.service.po.User; import com.neotel.smfcore.security.service.po.User;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -30,9 +32,11 @@ import org.springframework.security.core.userdetails.UserDetails; ...@@ -30,9 +32,11 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
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;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
...@@ -46,6 +50,14 @@ public class SecurityUtils { ...@@ -46,6 +50,14 @@ public class SecurityUtils {
SecurityUtils.userManager = userManager; SecurityUtils.userManager = userManager;
} }
private static IStorageManager storageManager;
@Autowired
public void setStorageManager(IStorageManager storageManager){
SecurityUtils.storageManager = storageManager;
}
/** /**
* 获取当前登录的用户 * 获取当前登录的用户
* @return UserDetails * @return UserDetails
...@@ -132,4 +144,26 @@ public class SecurityUtils { ...@@ -132,4 +144,26 @@ public class SecurityUtils {
} }
return false; return false;
} }
/**
* 获取当前用户分组对应料仓id
*
* @return
*/
public static List<String> getUserGroupStorageId() {
List<String> resultList = new ArrayList<>();
String username = getLoginUsername();
User user = userManager.findByUserName(username);
List<Storage> storageList = storageManager.findAll();
if (user != null && user.getGroups() != null && !user.getGroups().isEmpty()) {
for (Storage storage : storageList) {
if (user.getGroups().contains(storage.getGroupId())) {
resultList.add(storage.getId());
}
}
} else {
resultList = storageList.stream().map(item -> item.getId()).collect(Collectors.toList());
}
return resultList;
}
} }
...@@ -597,6 +597,9 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -597,6 +597,9 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected void endOutTask(String cid, String posName,String barcode){ protected void endOutTask(String cid, String posName,String barcode){
log.info(cid +"将物料从库位["+posName+"]出库到门口/料串完成"); log.info(cid +"将物料从库位["+posName+"]出库到门口/料串完成");
DataLog task = taskService.findFinishedOutTask(cid, posName,barcode); DataLog task = taskService.findFinishedOutTask(cid, posName,barcode);
if (task == null){
log.info(barcode+"未找到对应的任务");
}
if(task != null){ if(task != null){
task.setStatus(OP_STATUS.END.name()); task.setStatus(OP_STATUS.END.name());
taskService.updateFinishedTask(task); taskService.updateFinishedTask(task);
...@@ -614,6 +617,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -614,6 +617,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
* @throws ValidateException * @throws ValidateException
*/ */
protected void finishedOutPos(String cid, String posName,String barcode,int executeTime,OP_STATUS outBoxStatus) throws ValidateException { protected void finishedOutPos(String cid, String posName,String barcode,int executeTime,OP_STATUS outBoxStatus) throws ValidateException {
taskService.removeFinishedTask(cid,posName,barcode);
DataLog task = taskService.findExecutingTask(cid, posName,barcode); DataLog task = taskService.findExecutingTask(cid, posName,barcode);
if (task != null && task.isCheckOutTask()) { if (task != null && task.isCheckOutTask()) {
//判断状态是否重复推送 //判断状态是否重复推送
......
...@@ -2,13 +2,18 @@ package com.neotel.smfcore.core.elecKanban; ...@@ -2,13 +2,18 @@ package com.neotel.smfcore.core.elecKanban;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.barcode.service.po.Barcode; 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.util.DataCache; 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.SluggishDto; import com.neotel.smfcore.core.elecKanban.bean.dto.SluggishDto;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager; import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
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.elecKanban.bean.dto.ExpireDto; import com.neotel.smfcore.core.elecKanban.bean.dto.ExpireDto;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -18,9 +23,12 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,9 +23,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -36,6 +44,9 @@ public class ElecKanbanController { ...@@ -36,6 +44,9 @@ public class ElecKanbanController {
@Autowired @Autowired
private DataCache dataCache; private DataCache dataCache;
@Autowired
private IInOutDataManager inOutDataManager;
@ApiOperation("过期信息") @ApiOperation("过期信息")
@RequestMapping("/getExpiredInfo") @RequestMapping("/getExpiredInfo")
@AnonymousAccess @AnonymousAccess
...@@ -109,8 +120,59 @@ public class ElecKanbanController { ...@@ -109,8 +120,59 @@ public class ElecKanbanController {
emptySlots = emptySlots + storage.getEmptySlots(); emptySlots = emptySlots + storage.getEmptySlots();
} }
if (totalSlots != 0) { if (totalSlots != 0) {
usage = (totalSlots - emptySlots) / totalSlots; usage = (totalSlots - emptySlots)*100 / totalSlots;
} }
return usage; return usage;
} }
@ApiOperation("设备状态")
@RequestMapping("/getElecKanbanBoxStatusDto")
@AnonymousAccess
public List<ElecKanbanBoxStatusDto> getElecKanbanBoxStatusDto() throws ParseException {
List<ElecKanbanBoxStatusDto> resultList = new ArrayList<>();
Date currentDate = DateUtil.getCurrentDate("yyyy-MM-dd");
List<InOutData> inOutDataList = inOutDataManager.findByDate(currentDate, DateUtil.addDays(currentDate, 1), null);
//List<InOutData> inOutDataList = inOutDataManager.findByDate(DateUtil.addDays(currentDate,-5), DateUtil.addDays(currentDate, 1), null);
for (Storage storage : dataCache.getAllStorage().values()) {
ElecKanbanBoxStatusDto dto = new ElecKanbanBoxStatusDto();
StatusBean statusBean = DevicesStatusUtil.getStatusBean(storage.getCid());
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());
}
}
}
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;
}
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();
}
}
} }
package com.neotel.smfcore.core.elecKanban.bean.dto;
import lombok.Data;
@Data
public class ElecKanbanBoxStatusDto {
/**
* 设备名称
*/
private String name;
/**
* 状态
*/
private int status;
/**
* 今日入库
*/
private int todayInCount;
/**
* 今日出库
*/
private int todayOutCount;
/**
* 库位使用率
*/
private int usage;
/**
* 0料架 1是料仓
*/
private int type = 1;
/**
* 温度
*/
public String temperature = "";
/**
* 湿度
*/
public String humidity = "";
}
...@@ -125,7 +125,7 @@ public class LiteOrderCache { ...@@ -125,7 +125,7 @@ public class LiteOrderCache {
public void onTaskStatusChange(DataLog task) { public void onTaskStatusChange(DataLog task) {
try { try {
//只有任务完成或取消时才处理,任务未完成直接返回 //只有任务完成或取消时才处理,任务未完成直接返回
if (task.isFinished() || task.isCancel()) { if (task.isFinished() || task.isCancel() || task.isEnd()) {
finishedOrderTask(task); finishedOrderTask(task);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -261,7 +261,7 @@ public class LiteOrderCache { ...@@ -261,7 +261,7 @@ public class LiteOrderCache {
checkoutAgain(task,order); checkoutAgain(task,order);
} }
else if (task.isFinished()) { else if (task.isFinished() || task.isEnd()) {
order.setFinishedReelCount(order.getFinishedReelCount() + 1); order.setFinishedReelCount(order.getFinishedReelCount() + 1);
order.setTotalFinishedReelCount(order.getTotalFinishedReelCount()+1); order.setTotalFinishedReelCount(order.getTotalFinishedReelCount()+1);
String orderItemId = task.getSubSourceId(); String orderItemId = task.getSubSourceId();
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.neotel.smfcore.common.bean.BetweenData; import com.neotel.smfcore.common.bean.BetweenData;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager; import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData; import com.neotel.smfcore.core.inout.service.po.InOutData;
...@@ -167,9 +168,16 @@ public class ReportController { ...@@ -167,9 +168,16 @@ public class ReportController {
endDate = DateUtil.offsetDay(endDate, 1); endDate = DateUtil.offsetDay(endDate, 1);
startDate = DateUtil.offsetDay(endDate, -7); startDate = DateUtil.offsetDay(endDate, -7);
} }
//增加用户所属分组id
List<String> storageIdList;
if (query.getStorageIdList() != null && !query.getStorageIdList().isEmpty() && !query.getStorageIdList().contains("0")){
storageIdList = query.getStorageIdList();
} else {
storageIdList = SecurityUtils.getUserGroupStorageId();
}
//判断相差小时数,是否超过48小时 //判断相差小时数,是否超过48小时
long between = DateUtil.between(startDate, endDate, DateUnit.HOUR); long between = DateUtil.between(startDate, endDate, DateUnit.HOUR);
List<InOutData> inOutDataList = inOutDataManager.findByDate(startDate, endDate, query.getStorageIdList()); List<InOutData> inOutDataList = inOutDataManager.findByDate(startDate, endDate, storageIdList);
while (startDate.getTime() < endDate.getTime()) { while (startDate.getTime() < endDate.getTime()) {
DateTime nextDayTime; DateTime nextDayTime;
if (between > 48) { if (between > 48) {
......
...@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.exception.ValidateException; ...@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.ReelLockPosUtil; import com.neotel.smfcore.common.utils.ReelLockPosUtil;
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.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
...@@ -1046,4 +1047,25 @@ public class TaskService { ...@@ -1046,4 +1047,25 @@ public class TaskService {
taskMap.remove(task.getId()); taskMap.remove(task.getId());
theFinishedTaskMap.put(task.getId(), task); theFinishedTaskMap.put(task.getId(), task);
} }
public void removeFinishedTask(String cid, String posName, String barcode) {
List<DataLog> dataLogList = new ArrayList<>();
for (DataLog dataLog : theFinishedTaskMap.values()) {
if (dataLog.isFinished() || dataLog.isEnd()){
if (dataLog.getCid().equals(cid)){
if (StringUtils.isNotBlank(posName) && posName.equals(dataLog.getPosName())){
dataLogList.add(dataLog);
} else if (StringUtils.isNotBlank(barcode) && barcode.equals(dataLog.getBarcode())){
dataLogList.add(dataLog);
}
}
}
}
if (dataLogList != null && !dataLogList.isEmpty()){
for (DataLog dataLog : dataLogList) {
log.info("["+dataLog.getBarcode()+"]["+dataLog.getPosName()+"],theFinishedTaskMap存在重复任务["+dataLog.getStatus()+"]");
removeFinishedTask(dataLog);
}
}
}
} }
...@@ -35,7 +35,7 @@ public class AptivApi extends NeotelApi { ...@@ -35,7 +35,7 @@ public class AptivApi extends NeotelApi {
public void outTaskStatusChange(String outNotifyUrl, DataLog task) { public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
String requestParams = ""; String requestParams = "";
String responseInfo = ""; String responseInfo = "";
if (task.isOutBox() || task.isFinished()) { if (task.isEnd() || task.isFinished()) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("reelId", task.getBarcode()); paramMap.put("reelId", task.getBarcode());
paramMap.put("partNum", task.getPartNumber()); paramMap.put("partNum", task.getPartNumber());
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!