|
|
@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.nl.config.thread.ThreadPoolExecutorUtil; |
|
|
|
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.*; |
|
|
@ -42,7 +43,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
public ConcurrentHashMap<String,Object> productionStatistics() { |
|
|
|
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); |
|
|
|
ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>(3); |
|
|
|
// 1、获取生产任务列表、
|
|
|
|
// 1、获取生产任务列表
|
|
|
|
CompletableFuture<List<WorkorderDto>> productionTask = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<WorkorderDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); |
|
|
@ -71,22 +72,24 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
return null; |
|
|
|
}); |
|
|
|
// 3、获取成品计划完成情况,今日压制量,干燥量,成品量
|
|
|
|
CompletableFuture<List<ProductionStatisticsDto>> finishedTask = CompletableFuture.supplyAsync(() -> { |
|
|
|
List<ProductionStatisticsDto> res = new CopyOnWriteArrayList<>(); |
|
|
|
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0); |
|
|
|
CompletableFuture<JSONArray> finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0), pool); |
|
|
|
finishedTask.thenAccept((result) -> { |
|
|
|
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>(); |
|
|
|
List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>(); |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
res.forEach(r -> { |
|
|
|
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { |
|
|
|
r.setWorkorder_procedure(Objects.equals(r.getWorkorder_procedure(), "2") ? "今日压制量" : Objects.equals(r.getWorkorder_procedure(), "3") ? "今日干燥量" : "今日成品量"); |
|
|
|
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用
|
|
|
|
planRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
getProcedureName(planRes, 1); |
|
|
|
//今日压制量,干燥量,成品量
|
|
|
|
finishedRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
getProcedureName(finishedRes, 2); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
finishedTask.thenAccept((result) -> map.put("finishedTask", result)).exceptionally((e) -> { |
|
|
|
map.put("planRes", planRes); |
|
|
|
map.put("finishedRes", finishedRes); |
|
|
|
}).exceptionally((e) -> { |
|
|
|
log.error("获取成品计划完成情况: {}", e.getMessage(), e); |
|
|
|
map.put("finishedTask", ""); |
|
|
|
map.put("planRes", ""); |
|
|
|
map.put("finishedRes", ""); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(productionTask, materialTask, finishedTask); |
|
|
@ -126,9 +129,15 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
materialStorage.thenAccept((result) -> map.put("materialTask", result)).exceptionally((e) -> { |
|
|
|
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、获取成品仓储信息
|
|
|
@ -140,9 +149,15 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
} |
|
|
|
return res; |
|
|
|
}, pool); |
|
|
|
finishedStorage.thenAccept((result) -> map.put("productionTask", result)).exceptionally((e) -> { |
|
|
|
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); |
|
|
@ -161,8 +176,8 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public SchBasePointDto findStorageById(String id) { |
|
|
|
JSONObject rows = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "3").addParam("point_id", id).process().uniqueResult(0); |
|
|
|
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); |
|
|
@ -192,7 +207,7 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
r.setDevice_url("ylj"); |
|
|
|
//设备运行状态
|
|
|
|
if(StringUtils.isNotEmpty(r.getPoint_status())) { |
|
|
|
r.setPoint_status(PointStatusEnum.getName(r.getPoint_status())); |
|
|
|
r.setPoint_status_name(PointStatusEnum.getName(r.getPoint_status())); |
|
|
|
} |
|
|
|
}); |
|
|
|
return res; |
|
|
@ -207,8 +222,8 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
* @since 2023/3/1 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public DeviceDetailDto findDeviceById(String id) { |
|
|
|
JSONObject rows = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "2").addParam("point_id", id).process().uniqueResult(0); |
|
|
|
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 点击设备弹窗临时演示数据,后面需要根据业务逻辑查询
|
|
|
@ -283,6 +298,26 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
return hashMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理工序字段 |
|
|
|
*/ |
|
|
|
private void getProcedureName(List<ProductionStatisticsDto> result, Integer type) { |
|
|
|
if(type == 1) { |
|
|
|
result.forEach(r -> { |
|
|
|
if(StringUtils.isNotEmpty(r.getLabel())) { |
|
|
|
r.setWorkorder_procedure(r.getLabel().substring(0, 2)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
else{ |
|
|
|
result.forEach(r -> { |
|
|
|
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { |
|
|
|
r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断静置状态 |
|
|
|
*/ |
|
|
|