|
@ -22,10 +22,7 @@ import java.math.BigDecimal; |
|
|
import java.time.Duration; |
|
|
import java.time.Duration; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.CompletableFuture; |
|
|
import java.util.concurrent.*; |
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 大屏服务实现1 |
|
|
* 大屏服务实现1 |
|
@ -36,7 +33,7 @@ import java.util.concurrent.ThreadPoolExecutor; |
|
|
@Service |
|
|
@Service |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class CockpitServiceImpl implements CockpitService{ |
|
|
public class CockpitServiceImpl implements CockpitService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生产统计大屏 |
|
|
* 生产统计大屏 |
|
@ -45,14 +42,14 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* @since 2023/2/27 |
|
|
* @since 2023/2/27 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public ConcurrentHashMap<String,Object> productionStatistics() { |
|
|
public ConcurrentHashMap<String, Object> productionStatistics() { |
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>(3); |
|
|
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>(3); |
|
|
// 1、获取生产任务列表
|
|
|
// 1、获取生产任务列表
|
|
|
CompletableFuture<List<WorkorderDto>> productionTask = CompletableFuture.supplyAsync(() -> { |
|
|
CompletableFuture<List<WorkorderDto>> productionTask = CompletableFuture.supplyAsync(() -> { |
|
|
List<WorkorderDto> res = new CopyOnWriteArrayList<>(); |
|
|
List<WorkorderDto> res = new CopyOnWriteArrayList<>(); |
|
|
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
res = result.toJavaList(WorkorderDto.class); |
|
|
res = result.toJavaList(WorkorderDto.class); |
|
|
// res.forEach(r -> {
|
|
|
// res.forEach(r -> {
|
|
|
// r.setCust_name("新余钢铁");
|
|
|
// r.setCust_name("新余钢铁");
|
|
@ -94,7 +91,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
finishedTask.thenAccept((result) -> { |
|
|
finishedTask.thenAccept((result) -> { |
|
|
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>(); |
|
|
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>(); |
|
|
List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>(); |
|
|
List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>(); |
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
|
|
|
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
|
|
|
planRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
planRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
setResultComplete(planRes); |
|
|
setResultComplete(planRes); |
|
@ -111,7 +108,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
return null; |
|
|
return null; |
|
|
}); |
|
|
}); |
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(productionTask, materialTask, finishedTask); |
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(productionTask, materialTask, finishedTask); |
|
|
CompletableFuture<ConcurrentHashMap<String,Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
CompletableFuture<ConcurrentHashMap<String, Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
log.error(e.getMessage(), e); |
|
|
log.error(e.getMessage(), e); |
|
|
return null; |
|
|
return null; |
|
|
}); |
|
|
}); |
|
@ -126,22 +123,22 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* @since 2023/2/27 |
|
|
* @since 2023/2/27 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public ConcurrentHashMap<String,Object> storageMonitor() { |
|
|
public ConcurrentHashMap<String, Object> storageMonitor() { |
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>(2); |
|
|
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>(2); |
|
|
// 1、获取原料仓储信息
|
|
|
// 1、获取原料仓储信息
|
|
|
CompletableFuture<List<SchBasePointDto>> materialStorage = CompletableFuture.supplyAsync(() -> { |
|
|
CompletableFuture<List<SchBasePointDto>> materialStorage = CompletableFuture.supplyAsync(() -> { |
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
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", "1").process().getResultJSONArray(0); |
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
res.forEach(schBasePointDto -> { |
|
|
res.forEach(schBasePointDto -> { |
|
|
//Todo 空盅和强制完成状态相关逻辑待完善
|
|
|
//Todo 空盅和强制完成状态相关逻辑待完善
|
|
|
//根据入库时间和静置时间判断静置状态
|
|
|
//根据入库时间和静置时间判断静置状态
|
|
|
getStandingStatus(schBasePointDto); |
|
|
getStandingStatus(schBasePointDto); |
|
|
//是否满托
|
|
|
//是否满托
|
|
|
if(StringUtils.isNotEmpty(schBasePointDto.getIs_full())) { |
|
|
if (StringUtils.isNotEmpty(schBasePointDto.getIs_full())) { |
|
|
schBasePointDto.setIs_full(IsOrNotEnum.getName(schBasePointDto.getIs_full())); |
|
|
schBasePointDto.setIs_full(IsOrNotEnum.getName(schBasePointDto.getIs_full())); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -163,7 +160,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
CompletableFuture<List<SchBasePointDto>> finishedStorage = CompletableFuture.supplyAsync(() -> { |
|
|
CompletableFuture<List<SchBasePointDto>> finishedStorage = CompletableFuture.supplyAsync(() -> { |
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "2").process().getResultJSONArray(0); |
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "2").process().getResultJSONArray(0); |
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
} |
|
|
} |
|
|
return res; |
|
|
return res; |
|
@ -180,7 +177,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
return null; |
|
|
return null; |
|
|
}); |
|
|
}); |
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(materialStorage, finishedStorage); |
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(materialStorage, finishedStorage); |
|
|
CompletableFuture<ConcurrentHashMap<String,Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
CompletableFuture<ConcurrentHashMap<String, Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
log.error(e.getMessage(), e); |
|
|
log.error(e.getMessage(), e); |
|
|
return null; |
|
|
return null; |
|
|
}); |
|
|
}); |
|
@ -195,9 +192,9 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* @since 2023/3/1 |
|
|
* @since 2023/3/1 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public SchBasePointDto findStorageById(Map<String,String> id) { |
|
|
public SchBasePointDto findStorageById(Map<String, String> id) { |
|
|
JSONObject rows = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "3").addParam("point_id", id.get("id")).process().uniqueResult(0); |
|
|
JSONObject rows = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "3").addParam("point_id", id.get("id")).process().uniqueResult(0); |
|
|
if(ObjectUtil.isNotEmpty(rows)) { |
|
|
if (ObjectUtil.isNotEmpty(rows)) { |
|
|
SchBasePointDto res = rows.toJavaObject(SchBasePointDto.class); |
|
|
SchBasePointDto res = rows.toJavaObject(SchBasePointDto.class); |
|
|
getStandingStatus(res); |
|
|
getStandingStatus(res); |
|
|
return res; |
|
|
return res; |
|
@ -212,9 +209,9 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* @since 2023/2/28 |
|
|
* @since 2023/2/28 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<DeviceInfoDto> deviceMonitor() { |
|
|
public ConcurrentHashMap<String, List<DeviceInfoDto>> deviceMonitor() { |
|
|
List<DeviceInfoDto> res; |
|
|
List<DeviceInfoDto> res; |
|
|
ConcurrentHashMap<String,List<DeviceInfoDto>> map = new ConcurrentHashMap<>(); |
|
|
ConcurrentHashMap<String, List<DeviceInfoDto>> map = new ConcurrentHashMap<>(); |
|
|
JSONArray result = WQL.getWO("COCKPIT_DEVICE") |
|
|
JSONArray result = WQL.getWO("COCKPIT_DEVICE") |
|
|
.addParam("flag", "3") |
|
|
.addParam("flag", "3") |
|
|
.process() |
|
|
.process() |
|
@ -224,15 +221,32 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
JSONArray data = ObjectUtil.isNotEmpty( |
|
|
JSONArray data = ObjectUtil.isNotEmpty( |
|
|
devicesStatus.getJSONArray("data"))?devicesStatus.getJSONArray("data"):result; |
|
|
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : result; |
|
|
if(ObjectUtil.isNotEmpty(data)) { |
|
|
// 初始画数据
|
|
|
|
|
|
for (int i = 1; i <= 13; i++) { |
|
|
|
|
|
DeviceEnum deviceEnum = DeviceEnum.getByModel(String.valueOf(i)); |
|
|
|
|
|
if (ObjectUtil.isEmpty(map.get(deviceEnum.getKeyName()))) { |
|
|
|
|
|
List<DeviceInfoDto> de = new ArrayList<>(); |
|
|
|
|
|
map.put(deviceEnum.getKeyName(), de); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(data)) { |
|
|
res = data.toJavaList(DeviceInfoDto.class); |
|
|
res = data.toJavaList(DeviceInfoDto.class); |
|
|
res.forEach(d -> { |
|
|
res.forEach(d -> { |
|
|
DeviceEnum deviceEnum = DeviceEnum.get(d.getDevice_model(), d.getDevice_code()); |
|
|
DeviceEnum deviceEnum = DeviceEnum.getByModel(d.getDevice_model()); |
|
|
// 添加图片名字
|
|
|
// 添加图片名字
|
|
|
d.setDevice_url(deviceEnum.getPictureName()); |
|
|
d.setDevice_url(deviceEnum.getPictureName()); |
|
|
|
|
|
// 分类链表
|
|
|
|
|
|
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; |
|
|
return map; |
|
|
} |
|
|
} |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
@ -244,9 +258,9 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* @since 2023/3/1 |
|
|
* @since 2023/3/1 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public DeviceDetailDto findDeviceById(Map<String,String> id) { |
|
|
public DeviceDetailDto findDeviceById(Map<String, String> id) { |
|
|
JSONObject rows = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "2").addParam("point_id", id.get("id")).process().uniqueResult(0); |
|
|
JSONObject rows = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "2").addParam("point_id", id.get("id")).process().uniqueResult(0); |
|
|
if(ObjectUtil.isNotEmpty(rows)) { |
|
|
if (ObjectUtil.isNotEmpty(rows)) { |
|
|
DeviceDetailDto deviceDetailDto = rows.toJavaObject(DeviceDetailDto.class); |
|
|
DeviceDetailDto deviceDetailDto = rows.toJavaObject(DeviceDetailDto.class); |
|
|
//Todo 点击设备弹窗临时演示数据,后面需要根据业务逻辑查询
|
|
|
//Todo 点击设备弹窗临时演示数据,后面需要根据业务逻辑查询
|
|
|
deviceDetailDto.setReal_qty("1500"); |
|
|
deviceDetailDto.setReal_qty("1500"); |
|
@ -292,9 +306,9 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* @since 2023/3/1 |
|
|
* @since 2023/3/1 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public Map<String,Object> workshopCondition() { |
|
|
public Map<String, Object> workshopCondition() { |
|
|
//Todo 车间设备情况临时演示数据,后面需要根据业务逻辑查询
|
|
|
//Todo 车间设备情况临时演示数据,后面需要根据业务逻辑查询
|
|
|
Map<String,Object> hashMap = new HashMap<>(3); |
|
|
Map<String, Object> hashMap = new HashMap<>(3); |
|
|
//运行情况
|
|
|
//运行情况
|
|
|
List<DeviceStatisticsDto> runningStatusList = new ArrayList<>(); |
|
|
List<DeviceStatisticsDto> runningStatusList = new ArrayList<>(); |
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("混料").deviceQty(16).faultyDevice(2).build()); |
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("混料").deviceQty(16).faultyDevice(2).build()); |
|
@ -335,7 +349,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
} |
|
|
} |
|
|
// 检查 2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中
|
|
|
// 检查 2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中
|
|
|
for (int i = 2; i <= 4; i++) { |
|
|
for (int i = 2; i <= 4; i++) { |
|
|
if (!existingLabels.contains(i+"")) { |
|
|
if (!existingLabels.contains(i + "")) { |
|
|
result.add(ProductionStatisticsDto |
|
|
result.add(ProductionStatisticsDto |
|
|
.builder() |
|
|
.builder() |
|
|
.workorder_procedure(ProductionStatisticsEnum.getName(String.valueOf(i))) |
|
|
.workorder_procedure(ProductionStatisticsEnum.getName(String.valueOf(i))) |
|
@ -373,14 +387,13 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
* 判断静置状态 |
|
|
* 判断静置状态 |
|
|
*/ |
|
|
*/ |
|
|
private void getStandingStatus(SchBasePointDto schBasePointDto) { |
|
|
private void getStandingStatus(SchBasePointDto schBasePointDto) { |
|
|
if(StringUtils.isNotBlank(schBasePointDto.getInstorage_time()) && null != schBasePointDto.getStanding_time()) { |
|
|
if (StringUtils.isNotBlank(schBasePointDto.getInstorage_time()) && null != schBasePointDto.getStanding_time()) { |
|
|
DateTime nowTime = DateUtil.parse(DateUtil.now(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
DateTime nowTime = DateUtil.parse(DateUtil.now(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
DateTime inStorageTime = DateUtil.parse(schBasePointDto.getInstorage_time(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
DateTime inStorageTime = DateUtil.parse(schBasePointDto.getInstorage_time(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
long minute = DateUtil.between(nowTime, inStorageTime, DateUnit.MINUTE); |
|
|
long minute = DateUtil.between(nowTime, inStorageTime, DateUnit.MINUTE); |
|
|
if(minute < schBasePointDto.getStanding_time().longValue()) { |
|
|
if (minute < schBasePointDto.getStanding_time().longValue()) { |
|
|
schBasePointDto.setStanding_status("静置中"); |
|
|
schBasePointDto.setStanding_status("静置中"); |
|
|
} |
|
|
} else { |
|
|
else{ |
|
|
|
|
|
schBasePointDto.setStanding_status("静置完成"); |
|
|
schBasePointDto.setStanding_status("静置完成"); |
|
|
} |
|
|
} |
|
|
if (schBasePointDto.getPoint_status().equals(PointEnum.POINT_STATUS_EMPTY_POSITION.getCode())) { |
|
|
if (schBasePointDto.getPoint_status().equals(PointEnum.POINT_STATUS_EMPTY_POSITION.getCode())) { |
|
|