|
|
@ -22,10 +22,7 @@ import java.math.BigDecimal; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 大屏服务实现1 |
|
|
@ -36,24 +33,24 @@ import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Slf4j |
|
|
|
public class CockpitServiceImpl implements CockpitService{ |
|
|
|
public class CockpitServiceImpl implements CockpitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 生产统计大屏 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/2/27 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ConcurrentHashMap<String,Object> productionStatistics() { |
|
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
|
ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>(3); |
|
|
|
// 1、获取生产任务列表
|
|
|
|
CompletableFuture<List<WorkorderDto>> productionTask = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<WorkorderDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(WorkorderDto.class); |
|
|
|
/** |
|
|
|
* 生产统计大屏 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/2/27 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ConcurrentHashMap<String, Object> productionStatistics() { |
|
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
|
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>(3); |
|
|
|
// 1、获取生产任务列表
|
|
|
|
CompletableFuture<List<WorkorderDto>> productionTask = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<WorkorderDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(WorkorderDto.class); |
|
|
|
// res.forEach(r -> {
|
|
|
|
// r.setCust_name("新余钢铁");
|
|
|
|
// if(StringUtils.isNotEmpty(r.getLabel())) {
|
|
|
@ -61,298 +58,315 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
// r.setShift_type(r.getLabel().substring(0, 2) + "白班");
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
productionTask.thenAccept((result) -> map.put("productionTask", result)).exceptionally((e) -> { |
|
|
|
log.error("获取生产任务列表: {}", e.getMessage(), e); |
|
|
|
map.put("productionTask", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
/** |
|
|
|
* 为了不破坏原来的输出形式,会有冗余数据的输出 |
|
|
|
*/ |
|
|
|
// 2、获取原料计划完成情况
|
|
|
|
CompletableFuture<JSONArray> materialTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "5").process().getResultJSONArray(0), pool); |
|
|
|
materialTask.thenAccept((result) -> { |
|
|
|
if (ObjectUtil.isEmpty(result)) { |
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
object.put("workorder_procedure", "原料"); |
|
|
|
object.put("label", "1"); |
|
|
|
object.put("plan_qty", "0"); |
|
|
|
object.put("real_qty", "0"); |
|
|
|
result.add(object); |
|
|
|
} |
|
|
|
map.put("materialTask", result); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取原料计划完成情况: {}", e.getMessage(), e); |
|
|
|
map.put("materialTask", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
// 3、获取成品计划完成情况,今日压制量,干燥量,成品量
|
|
|
|
CompletableFuture<JSONArray> finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "4").process().getResultJSONArray(0), pool); |
|
|
|
finishedTask.thenAccept((result) -> { |
|
|
|
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>(); |
|
|
|
List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>(); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
|
|
|
|
planRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
setResultComplete(planRes); |
|
|
|
//今日压制量,干燥量,成品量
|
|
|
|
finishedRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
setResultComplete(finishedRes); |
|
|
|
} |
|
|
|
map.put("planRes", planRes); |
|
|
|
map.put("finishedRes", finishedRes); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取成品计划完成情况: {}", e.getMessage(), e); |
|
|
|
map.put("planRes", ""); |
|
|
|
map.put("finishedRes", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(productionTask, materialTask, finishedTask); |
|
|
|
CompletableFuture<ConcurrentHashMap<String,Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
future.join(); |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
productionTask.thenAccept((result) -> map.put("productionTask", result)).exceptionally((e) -> { |
|
|
|
log.error("获取生产任务列表: {}", e.getMessage(), e); |
|
|
|
map.put("productionTask", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
/** |
|
|
|
* 为了不破坏原来的输出形式,会有冗余数据的输出 |
|
|
|
*/ |
|
|
|
// 2、获取原料计划完成情况
|
|
|
|
CompletableFuture<JSONArray> materialTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "5").process().getResultJSONArray(0), pool); |
|
|
|
materialTask.thenAccept((result) -> { |
|
|
|
if (ObjectUtil.isEmpty(result)) { |
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
object.put("workorder_procedure", "原料"); |
|
|
|
object.put("label", "1"); |
|
|
|
object.put("plan_qty", "0"); |
|
|
|
object.put("real_qty", "0"); |
|
|
|
result.add(object); |
|
|
|
} |
|
|
|
map.put("materialTask", result); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取原料计划完成情况: {}", e.getMessage(), e); |
|
|
|
map.put("materialTask", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
// 3、获取成品计划完成情况,今日压制量,干燥量,成品量
|
|
|
|
CompletableFuture<JSONArray> finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "4").process().getResultJSONArray(0), pool); |
|
|
|
finishedTask.thenAccept((result) -> { |
|
|
|
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>(); |
|
|
|
List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>(); |
|
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
|
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
|
|
|
|
planRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
setResultComplete(planRes); |
|
|
|
//今日压制量,干燥量,成品量
|
|
|
|
finishedRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
setResultComplete(finishedRes); |
|
|
|
} |
|
|
|
map.put("planRes", planRes); |
|
|
|
map.put("finishedRes", finishedRes); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取成品计划完成情况: {}", e.getMessage(), e); |
|
|
|
map.put("planRes", ""); |
|
|
|
map.put("finishedRes", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(productionTask, materialTask, finishedTask); |
|
|
|
CompletableFuture<ConcurrentHashMap<String, Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
future.join(); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 仓储监控大屏信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/2/27 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ConcurrentHashMap<String,Object> storageMonitor() { |
|
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
|
ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>(2); |
|
|
|
// 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); |
|
|
|
res.forEach(schBasePointDto -> { |
|
|
|
//Todo 空盅和强制完成状态相关逻辑待完善
|
|
|
|
//根据入库时间和静置时间判断静置状态
|
|
|
|
getStandingStatus(schBasePointDto); |
|
|
|
//是否满托
|
|
|
|
if(StringUtils.isNotEmpty(schBasePointDto.getIs_full())) { |
|
|
|
schBasePointDto.setIs_full(IsOrNotEnum.getName(schBasePointDto.getIs_full())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
materialStorage.thenAccept((result) -> { |
|
|
|
//原料仓储监控信息,应前端要求分开两个一样的数据结果,简化调用
|
|
|
|
map.put("materialTask", result); |
|
|
|
//原料库存
|
|
|
|
map.put("materialList", result); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取原料仓储信息: {}", e.getMessage(), e); |
|
|
|
map.put("materialTask", ""); |
|
|
|
map.put("materialList", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
// 2、获取成品仓储信息
|
|
|
|
CompletableFuture<List<SchBasePointDto>> finishedStorage = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "2").process().getResultJSONArray(0); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
finishedStorage.thenAccept((result) -> { |
|
|
|
//成品仓储监控信息,应前端要求分开两个一样的数据结果,简化调用
|
|
|
|
map.put("productionTask", result); |
|
|
|
//成品库存
|
|
|
|
map.put("productionList", result); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取成品仓储信息: {}", e.getMessage(), e); |
|
|
|
map.put("productionTask", ""); |
|
|
|
map.put("productionList", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(materialStorage, finishedStorage); |
|
|
|
CompletableFuture<ConcurrentHashMap<String,Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
future.join(); |
|
|
|
return map; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 仓储监控大屏信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/2/27 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ConcurrentHashMap<String, Object> storageMonitor() { |
|
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
|
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>(2); |
|
|
|
// 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); |
|
|
|
res.forEach(schBasePointDto -> { |
|
|
|
//Todo 空盅和强制完成状态相关逻辑待完善
|
|
|
|
//根据入库时间和静置时间判断静置状态
|
|
|
|
getStandingStatus(schBasePointDto); |
|
|
|
//是否满托
|
|
|
|
if (StringUtils.isNotEmpty(schBasePointDto.getIs_full())) { |
|
|
|
schBasePointDto.setIs_full(IsOrNotEnum.getName(schBasePointDto.getIs_full())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
materialStorage.thenAccept((result) -> { |
|
|
|
//原料仓储监控信息,应前端要求分开两个一样的数据结果,简化调用
|
|
|
|
map.put("materialTask", result); |
|
|
|
//原料库存
|
|
|
|
map.put("materialList", result); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取原料仓储信息: {}", e.getMessage(), e); |
|
|
|
map.put("materialTask", ""); |
|
|
|
map.put("materialList", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
// 2、获取成品仓储信息
|
|
|
|
CompletableFuture<List<SchBasePointDto>> finishedStorage = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<SchBasePointDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "2").process().getResultJSONArray(0); |
|
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(SchBasePointDto.class); |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
finishedStorage.thenAccept((result) -> { |
|
|
|
//成品仓储监控信息,应前端要求分开两个一样的数据结果,简化调用
|
|
|
|
map.put("productionTask", result); |
|
|
|
//成品库存
|
|
|
|
map.put("productionList", result); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取成品仓储信息: {}", e.getMessage(), e); |
|
|
|
map.put("productionTask", ""); |
|
|
|
map.put("productionList", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(materialStorage, finishedStorage); |
|
|
|
CompletableFuture<ConcurrentHashMap<String, Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
future.join(); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据点位id获取仓储信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
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); |
|
|
|
if(ObjectUtil.isNotEmpty(rows)) { |
|
|
|
SchBasePointDto res = rows.toJavaObject(SchBasePointDto.class); |
|
|
|
getStandingStatus(res); |
|
|
|
return res; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 根据点位id获取仓储信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
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); |
|
|
|
if (ObjectUtil.isNotEmpty(rows)) { |
|
|
|
SchBasePointDto res = rows.toJavaObject(SchBasePointDto.class); |
|
|
|
getStandingStatus(res); |
|
|
|
return res; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备监控大屏信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/2/28 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
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); |
|
|
|
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(result); |
|
|
|
if (ObjectUtil.isEmpty(devicesStatus)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONArray data = ObjectUtil.isNotEmpty( |
|
|
|
devicesStatus.getJSONArray("data"))?devicesStatus.getJSONArray("data"):result; |
|
|
|
if(ObjectUtil.isNotEmpty(data)) { |
|
|
|
res = data.toJavaList(DeviceInfoDto.class); |
|
|
|
res.forEach(d -> { |
|
|
|
DeviceEnum deviceEnum = DeviceEnum.get(d.getDevice_model(), d.getDevice_code()); |
|
|
|
// 添加图片名字
|
|
|
|
d.setDevice_url(deviceEnum.getPictureName()); |
|
|
|
}); |
|
|
|
return res; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 设备监控大屏信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/2/28 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ConcurrentHashMap<String, 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); |
|
|
|
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(result); |
|
|
|
if (ObjectUtil.isEmpty(devicesStatus)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONArray data = ObjectUtil.isNotEmpty( |
|
|
|
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : result; |
|
|
|
// 初始画数据
|
|
|
|
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.forEach(d -> { |
|
|
|
DeviceEnum deviceEnum = DeviceEnum.getByModel(d.getDevice_model()); |
|
|
|
// 添加图片名字
|
|
|
|
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 map; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据point_id获取设备信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
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); |
|
|
|
if(ObjectUtil.isNotEmpty(rows)) { |
|
|
|
DeviceDetailDto deviceDetailDto = rows.toJavaObject(DeviceDetailDto.class); |
|
|
|
//Todo 点击设备弹窗临时演示数据,后面需要根据业务逻辑查询
|
|
|
|
deviceDetailDto.setReal_qty("1500"); |
|
|
|
deviceDetailDto.setVehicle_code("L007"); |
|
|
|
deviceDetailDto.setPoint_status("运行中"); |
|
|
|
deviceDetailDto.setPallet_qty("120"); |
|
|
|
deviceDetailDto.setMove_first_kiln("30"); |
|
|
|
deviceDetailDto.setWork_time("3.5"); |
|
|
|
deviceDetailDto.setMove_second_kiln("30"); |
|
|
|
deviceDetailDto.setDevice_url("ylj"); |
|
|
|
deviceDetailDto.setSecond_kiln_qty("0"); |
|
|
|
deviceDetailDto.setPresent_kiln_qty("15"); |
|
|
|
deviceDetailDto.setVolume("20"); |
|
|
|
deviceDetailDto.setReady_lane("60"); |
|
|
|
deviceDetailDto.setFirst_kiln_qty("20"); |
|
|
|
deviceDetailDto.setMove_second_kiln("20"); |
|
|
|
deviceDetailDto.setMechanical_arm_qty("12000"); |
|
|
|
deviceDetailDto.setPack_qty("1200"); |
|
|
|
deviceDetailDto.setFinish_pallet_qty("120"); |
|
|
|
deviceDetailDto.setMechanical_pallet_qty("120"); |
|
|
|
deviceDetailDto.setFinish_pile_qty("12"); |
|
|
|
List<ProductionInfoDto> setMixingList = new ArrayList<>(); |
|
|
|
List<ProductionInfoDto> setCrushingList = new ArrayList<>(); |
|
|
|
setMixingList.add(ProductionInfoDto.builder().productionDetails("混料23.60*0.68").productionQty("1500").weightUnitName("KG").build()); |
|
|
|
setMixingList.add(ProductionInfoDto.builder().productionDetails("混料24.00*0.89").productionQty("800").weightUnitName("KG").build()); |
|
|
|
//混碾机,破碎机本日生产信息
|
|
|
|
deviceDetailDto.setMixingList(setMixingList); |
|
|
|
setCrushingList.add(ProductionInfoDto.builder().productionDetails("压制M29*0.90*5.5-6.5M").productionQty("10000").manufacturer("新余").build()); |
|
|
|
setCrushingList.add(ProductionInfoDto.builder().productionDetails("压制Y22.00*0.80*2.5-3M").productionQty("15000").manufacturer("重钢").build()); |
|
|
|
//压力机,机械手本日生产信息
|
|
|
|
deviceDetailDto.setCrushingList(setCrushingList); |
|
|
|
//窑本日生产信息
|
|
|
|
deviceDetailDto.setMKilnList(setCrushingList); |
|
|
|
return deviceDetailDto; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 根据point_id获取设备信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
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); |
|
|
|
if (ObjectUtil.isNotEmpty(rows)) { |
|
|
|
DeviceDetailDto deviceDetailDto = rows.toJavaObject(DeviceDetailDto.class); |
|
|
|
//Todo 点击设备弹窗临时演示数据,后面需要根据业务逻辑查询
|
|
|
|
deviceDetailDto.setReal_qty("1500"); |
|
|
|
deviceDetailDto.setVehicle_code("L007"); |
|
|
|
deviceDetailDto.setPoint_status("运行中"); |
|
|
|
deviceDetailDto.setPallet_qty("120"); |
|
|
|
deviceDetailDto.setMove_first_kiln("30"); |
|
|
|
deviceDetailDto.setWork_time("3.5"); |
|
|
|
deviceDetailDto.setMove_second_kiln("30"); |
|
|
|
deviceDetailDto.setDevice_url("ylj"); |
|
|
|
deviceDetailDto.setSecond_kiln_qty("0"); |
|
|
|
deviceDetailDto.setPresent_kiln_qty("15"); |
|
|
|
deviceDetailDto.setVolume("20"); |
|
|
|
deviceDetailDto.setReady_lane("60"); |
|
|
|
deviceDetailDto.setFirst_kiln_qty("20"); |
|
|
|
deviceDetailDto.setMove_second_kiln("20"); |
|
|
|
deviceDetailDto.setMechanical_arm_qty("12000"); |
|
|
|
deviceDetailDto.setPack_qty("1200"); |
|
|
|
deviceDetailDto.setFinish_pallet_qty("120"); |
|
|
|
deviceDetailDto.setMechanical_pallet_qty("120"); |
|
|
|
deviceDetailDto.setFinish_pile_qty("12"); |
|
|
|
List<ProductionInfoDto> setMixingList = new ArrayList<>(); |
|
|
|
List<ProductionInfoDto> setCrushingList = new ArrayList<>(); |
|
|
|
setMixingList.add(ProductionInfoDto.builder().productionDetails("混料23.60*0.68").productionQty("1500").weightUnitName("KG").build()); |
|
|
|
setMixingList.add(ProductionInfoDto.builder().productionDetails("混料24.00*0.89").productionQty("800").weightUnitName("KG").build()); |
|
|
|
//混碾机,破碎机本日生产信息
|
|
|
|
deviceDetailDto.setMixingList(setMixingList); |
|
|
|
setCrushingList.add(ProductionInfoDto.builder().productionDetails("压制M29*0.90*5.5-6.5M").productionQty("10000").manufacturer("新余").build()); |
|
|
|
setCrushingList.add(ProductionInfoDto.builder().productionDetails("压制Y22.00*0.80*2.5-3M").productionQty("15000").manufacturer("重钢").build()); |
|
|
|
//压力机,机械手本日生产信息
|
|
|
|
deviceDetailDto.setCrushingList(setCrushingList); |
|
|
|
//窑本日生产信息
|
|
|
|
deviceDetailDto.setMKilnList(setCrushingList); |
|
|
|
return deviceDetailDto; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 車间情况大屏信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String,Object> workshopCondition() { |
|
|
|
//Todo 车间设备情况临时演示数据,后面需要根据业务逻辑查询
|
|
|
|
Map<String,Object> hashMap = new HashMap<>(3); |
|
|
|
//运行情况
|
|
|
|
List<DeviceStatisticsDto> runningStatusList = new ArrayList<>(); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("混料").deviceQty(16).faultyDevice(2).build()); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("压制").deviceQty(14).faultyDevice(1).build()); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("干燥").deviceQty(6).faultyDevice(0).build()); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("包装").deviceQty(9).faultyDevice(3).build()); |
|
|
|
//近一个月故障次数
|
|
|
|
List<DeviceStatisticsDto> faultyStatusList = new ArrayList<>(); |
|
|
|
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个故障设备
|
|
|
|
List<DeviceStatisticsDto> faultyInfoList = new ArrayList<>(); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-15 11:09:08").deviceCode("YZJ07SL01").deviceName("压制机7").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-15 10:24:12").deviceCode("HLJ45W15").deviceName("混料机15").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-15 10:01:33").deviceCode("YZJ02XL01").deviceName("压制机2").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-14 15:21:31").deviceCode("HLJ02W03").deviceName("混料机3").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-14 11:27:24").deviceCode("YZJ0903").deviceName("压制机9").pointStatus("3").build()); |
|
|
|
hashMap.put("runningStatus", runningStatusList); |
|
|
|
hashMap.put("faultyStatus", faultyStatusList); |
|
|
|
hashMap.put("faultyInfo", faultyInfoList); |
|
|
|
return hashMap; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 車间情况大屏信息 |
|
|
|
* |
|
|
|
* @author gbx |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String, Object> workshopCondition() { |
|
|
|
//Todo 车间设备情况临时演示数据,后面需要根据业务逻辑查询
|
|
|
|
Map<String, Object> hashMap = new HashMap<>(3); |
|
|
|
//运行情况
|
|
|
|
List<DeviceStatisticsDto> runningStatusList = new ArrayList<>(); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("混料").deviceQty(16).faultyDevice(2).build()); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("压制").deviceQty(14).faultyDevice(1).build()); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("干燥").deviceQty(6).faultyDevice(0).build()); |
|
|
|
runningStatusList.add(DeviceStatisticsDto.builder().workorder_procedure("包装").deviceQty(9).faultyDevice(3).build()); |
|
|
|
//近一个月故障次数
|
|
|
|
List<DeviceStatisticsDto> faultyStatusList = new ArrayList<>(); |
|
|
|
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个故障设备
|
|
|
|
List<DeviceStatisticsDto> faultyInfoList = new ArrayList<>(); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-15 11:09:08").deviceCode("YZJ07SL01").deviceName("压制机7").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-15 10:24:12").deviceCode("HLJ45W15").deviceName("混料机15").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-15 10:01:33").deviceCode("YZJ02XL01").deviceName("压制机2").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-14 15:21:31").deviceCode("HLJ02W03").deviceName("混料机3").pointStatus("3").build()); |
|
|
|
faultyInfoList.add(DeviceStatisticsDto.builder().faultyTime("2023-02-14 11:27:24").deviceCode("YZJ0903").deviceName("压制机9").pointStatus("3").build()); |
|
|
|
hashMap.put("runningStatus", runningStatusList); |
|
|
|
hashMap.put("faultyStatus", faultyStatusList); |
|
|
|
hashMap.put("faultyInfo", faultyInfoList); |
|
|
|
return hashMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理空白数据设置默认值 |
|
|
|
*/ |
|
|
|
private void setResultComplete(List<ProductionStatisticsDto> result) { |
|
|
|
HashSet<String> existingLabels = new HashSet<>(); // 创建一个 HashSet 对象
|
|
|
|
// 遍历 result 列表中的每个 ProductionStatisticsDto 对象
|
|
|
|
for (ProductionStatisticsDto dto : result) { |
|
|
|
// 检查 label 字段是否存在于 existingLabels 集合中
|
|
|
|
if (!existingLabels.contains(dto.getLabel())) { |
|
|
|
// 将缺少的标签值添加到 existingLabels 集合中
|
|
|
|
existingLabels.add(dto.getLabel()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 检查 2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中
|
|
|
|
for (int i = 2; i <= 4; i++) { |
|
|
|
if (!existingLabels.contains(i+"")) { |
|
|
|
result.add(ProductionStatisticsDto |
|
|
|
.builder() |
|
|
|
.workorder_procedure(ProductionStatisticsEnum.getName(String.valueOf(i))) |
|
|
|
.label(String.valueOf(i)) |
|
|
|
.real_qty(BigDecimal.valueOf(0)) |
|
|
|
.plan_qty(BigDecimal.valueOf(0)) |
|
|
|
.build()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 排序
|
|
|
|
Collections.sort(result, Comparator.comparing(dto -> Integer.parseInt(dto.getLabel()))); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 处理空白数据设置默认值 |
|
|
|
*/ |
|
|
|
private void setResultComplete(List<ProductionStatisticsDto> result) { |
|
|
|
HashSet<String> existingLabels = new HashSet<>(); // 创建一个 HashSet 对象
|
|
|
|
// 遍历 result 列表中的每个 ProductionStatisticsDto 对象
|
|
|
|
for (ProductionStatisticsDto dto : result) { |
|
|
|
// 检查 label 字段是否存在于 existingLabels 集合中
|
|
|
|
if (!existingLabels.contains(dto.getLabel())) { |
|
|
|
// 将缺少的标签值添加到 existingLabels 集合中
|
|
|
|
existingLabels.add(dto.getLabel()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 检查 2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中
|
|
|
|
for (int i = 2; i <= 4; i++) { |
|
|
|
if (!existingLabels.contains(i + "")) { |
|
|
|
result.add(ProductionStatisticsDto |
|
|
|
.builder() |
|
|
|
.workorder_procedure(ProductionStatisticsEnum.getName(String.valueOf(i))) |
|
|
|
.label(String.valueOf(i)) |
|
|
|
.real_qty(BigDecimal.valueOf(0)) |
|
|
|
.plan_qty(BigDecimal.valueOf(0)) |
|
|
|
.build()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 排序
|
|
|
|
Collections.sort(result, Comparator.comparing(dto -> Integer.parseInt(dto.getLabel()))); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理工序字段 |
|
|
|
*/ |
|
|
|
private void getProcedureName(List<ProductionStatisticsDto> result, int type) { |
|
|
|
/** |
|
|
|
* 处理工序字段 |
|
|
|
*/ |
|
|
|
private void getProcedureName(List<ProductionStatisticsDto> result, int type) { |
|
|
|
// if(type == 1) {
|
|
|
|
// result.forEach(r -> {
|
|
|
|
// if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) {
|
|
|
@ -367,25 +381,24 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断静置状态 |
|
|
|
*/ |
|
|
|
private void getStandingStatus(SchBasePointDto schBasePointDto) { |
|
|
|
if(StringUtils.isNotBlank(schBasePointDto.getInstorage_time()) && null != schBasePointDto.getStanding_time()) { |
|
|
|
DateTime nowTime = DateUtil.parse(DateUtil.now(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
|
DateTime inStorageTime = DateUtil.parse(schBasePointDto.getInstorage_time(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
|
long minute = DateUtil.between(nowTime, inStorageTime, DateUnit.MINUTE); |
|
|
|
if(minute < schBasePointDto.getStanding_time().longValue()) { |
|
|
|
schBasePointDto.setStanding_status("静置中"); |
|
|
|
} |
|
|
|
else{ |
|
|
|
schBasePointDto.setStanding_status("静置完成"); |
|
|
|
} |
|
|
|
if (schBasePointDto.getPoint_status().equals(PointEnum.POINT_STATUS_EMPTY_POSITION.getCode())) { |
|
|
|
schBasePointDto.setPoint_status("空盅"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* 判断静置状态 |
|
|
|
*/ |
|
|
|
private void getStandingStatus(SchBasePointDto schBasePointDto) { |
|
|
|
if (StringUtils.isNotBlank(schBasePointDto.getInstorage_time()) && null != schBasePointDto.getStanding_time()) { |
|
|
|
DateTime nowTime = DateUtil.parse(DateUtil.now(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
|
DateTime inStorageTime = DateUtil.parse(schBasePointDto.getInstorage_time(), DatePattern.NORM_DATETIME_FORMAT); |
|
|
|
long minute = DateUtil.between(nowTime, inStorageTime, DateUnit.MINUTE); |
|
|
|
if (minute < schBasePointDto.getStanding_time().longValue()) { |
|
|
|
schBasePointDto.setStanding_status("静置中"); |
|
|
|
} else { |
|
|
|
schBasePointDto.setStanding_status("静置完成"); |
|
|
|
} |
|
|
|
if (schBasePointDto.getPoint_status().equals(PointEnum.POINT_STATUS_EMPTY_POSITION.getCode())) { |
|
|
|
schBasePointDto.setPoint_status("空盅"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|