|
|
@ -1,30 +1,36 @@ |
|
|
|
package org.nl.wms.cockpit.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import cn.hutool.core.date.DateUnit; |
|
|
|
import cn.hutool.core.date.*; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.nl.config.thread.ThreadPoolExecutorUtil; |
|
|
|
import org.nl.modules.common.utils.PointUpdateUtil; |
|
|
|
import org.nl.modules.common.utils.enums.IsOrNotEnum; |
|
|
|
import org.nl.modules.common.utils.enums.PointStatusEnum; |
|
|
|
import org.nl.modules.common.utils.enums.ProductionStatisticsEnum; |
|
|
|
import org.nl.modules.wql.WQL; |
|
|
|
import org.nl.wms.cockpit.service.CockpitService; |
|
|
|
import org.nl.wms.cockpit.service.dto.*; |
|
|
|
import org.nl.wms.sch.manage.DeviceEnum; |
|
|
|
import org.nl.wms.sch.manage.PointEnum; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
|
|
|
/** |
|
|
|
* 大屏服务实现 |
|
|
|
* 大屏服务实现1 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @date 2023-02-27 |
|
|
@ -33,6 +39,7 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Slf4j |
|
|
|
public class CockpitServiceImpl implements CockpitService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 生产统计大屏 |
|
|
|
* |
|
|
@ -114,6 +121,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
// 1、获取原料仓储信息
|
|
|
|
CompletableFuture<List<SchBasePointDto>> materialStorage = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
// 查找所有困料货架
|
|
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
@ -143,7 +151,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
// 2、获取成品仓储信息
|
|
|
|
CompletableFuture<List<SchBasePointDto>> finishedStorage = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "2").process().getResultJSONArray(0); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
|
} |
|
|
@ -193,22 +201,44 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
* @since 2023/2/28 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<DeviceStatusDto> deviceMonitor() { |
|
|
|
List<DeviceStatusDto> res; |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
|
public List<DeviceInfoDto> deviceMonitor() { |
|
|
|
List<DeviceInfoDto> res; |
|
|
|
ConcurrentHashMap<String,List<DeviceInfoDto>> map = new ConcurrentHashMap<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "3").process().getResultJSONArray(0); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(DeviceStatusDto.class); |
|
|
|
//已工作时间
|
|
|
|
res.forEach(r -> { |
|
|
|
//Todo 设备运行时间和图标相关暂为固定值,逻辑待完善
|
|
|
|
//设备运行时间
|
|
|
|
r.setWork_time("3.5"); |
|
|
|
//设备监控图标
|
|
|
|
r.setDevice_url("ylj"); |
|
|
|
//设备运行状态
|
|
|
|
if(StringUtils.isNotEmpty(r.getPoint_status())) { |
|
|
|
r.setPoint_status_name(PointStatusEnum.getName(r.getPoint_status())); |
|
|
|
res = result.toJavaList(DeviceInfoDto.class); |
|
|
|
res.forEach(d -> { |
|
|
|
if (ObjectUtil.isNotEmpty(d.getRealproducestart_date())) { |
|
|
|
// 如果时间存在
|
|
|
|
LocalDateTime dateTime = LocalDateTimeUtil.parse(d.getRealproducestart_date().replace(" ", "T")); |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
Duration duration = Duration.between(dateTime, now); |
|
|
|
d.setWork_time(duration.toHours() + ""); |
|
|
|
} |
|
|
|
// 设备状态
|
|
|
|
d.setDevice_status(PointUpdateUtil.getDeviceStatus(d.getDevice_code())); |
|
|
|
DeviceEnum deviceEnum = DeviceEnum.get(d.getDevice_model(), d.getDevice_code()); |
|
|
|
// 添加图片名字
|
|
|
|
d.setDevice_url(deviceEnum.getPictureName()); |
|
|
|
// todo: 区分窑与其他设备
|
|
|
|
if (d.getDevice_model().equals(DeviceEnum.YAO.getModel())) { |
|
|
|
d.setVehicle_qty(15); |
|
|
|
d.setVehicle_max_qty(20); |
|
|
|
} |
|
|
|
// todo: RGV
|
|
|
|
if (d.getDevice_model().equals(DeviceEnum.RGV.getModel())) { |
|
|
|
d.setDevice_status_name("空位无车,满位有车"); |
|
|
|
} |
|
|
|
// todo: 包装机、碟盘机
|
|
|
|
// 分类链表
|
|
|
|
// if (ObjectUtil.isEmpty(map.get(deviceEnum.getKeyName()))) {
|
|
|
|
// List<DeviceInfoDto> de = new ArrayList<>();
|
|
|
|
// de.add(d);
|
|
|
|
// map.put(deviceEnum.getKeyName(), de);
|
|
|
|
// } else {
|
|
|
|
// map.get(deviceEnum.getKeyName()).add(d);
|
|
|
|
// map.put(deviceEnum.getKeyName(), map.get(deviceEnum.getKeyName()));
|
|
|
|
// }
|
|
|
|
}); |
|
|
|
return res; |
|
|
|
} |
|
|
@ -281,9 +311,8 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("包装").deviceQty(9).faultyDevice(3).build()); |
|
|
|
//近一个月故障次数
|
|
|
|
List<DeviceStatisticsDto> faultyStatusList = new ArrayList<>(); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("压制机4").faultyFrequency(90).build()); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("压制机9").faultyFrequency(85).build()); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("压制机11").faultyFrequency(83).build()); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("压制机4").faultyFrequency(91).build()); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("压制机9").faultyFrequency(82).build()); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("混料机5").faultyFrequency(71).build()); |
|
|
|
faultyStatusList.add(DeviceStatisticsDto.builder().deviceName("压制机3").faultyFrequency(33).build()); |
|
|
|
//最近5个故障设备
|
|
|
@ -333,6 +362,9 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
else{ |
|
|
|
schBasePointDto.setStanding_status("静置完成"); |
|
|
|
} |
|
|
|
if (schBasePointDto.getPoint_status().equals(PointEnum.POINT_STATUS_EMPTY_POSITION.getCode())) { |
|
|
|
schBasePointDto.setPoint_status("空盅"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|