|
|
@ -18,12 +18,10 @@ import org.nl.wms.sch.manage.DeviceEnum; |
|
|
|
import org.nl.wms.sch.manage.PointEnum; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
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.*; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
@ -57,7 +55,6 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
res = result.toJavaList(WorkorderDto.class); |
|
|
|
// res.forEach(r -> {
|
|
|
|
// todo: 未根据实际,可以不需要客户
|
|
|
|
// r.setCust_name("新余钢铁");
|
|
|
|
// if(StringUtils.isNotEmpty(r.getLabel())) {
|
|
|
|
// r.setLabel(r.getLabel().substring(0, 2));
|
|
|
@ -77,7 +74,17 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
*/ |
|
|
|
// 2、获取原料计划完成情况
|
|
|
|
CompletableFuture<JSONArray> materialTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "5").process().getResultJSONArray(0), pool); |
|
|
|
materialTask.thenAccept((result) -> map.put("materialTask", result)).exceptionally((e) -> { |
|
|
|
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; |
|
|
@ -90,10 +97,10 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
if(ObjectUtil.isNotEmpty(result)) { |
|
|
|
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
|
|
|
|
planRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
// getProcedureName(planRes, 1);
|
|
|
|
setResultComplete(planRes); |
|
|
|
//今日压制量,干燥量,成品量
|
|
|
|
finishedRes = result.toJavaList(ProductionStatisticsDto.class); |
|
|
|
// getProcedureName(finishedRes, 2);
|
|
|
|
setResultComplete(finishedRes); |
|
|
|
} |
|
|
|
map.put("planRes", planRes); |
|
|
|
map.put("finishedRes", finishedRes); |
|
|
@ -314,25 +321,52 @@ public class CockpitServiceImpl implements CockpitService{ |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理工序字段 |
|
|
|
* 处理空白数据设置默认值 |
|
|
|
*/ |
|
|
|
private void getProcedureName(List<ProductionStatisticsDto> result, Integer type) { |
|
|
|
if(type == 1) { |
|
|
|
result.forEach(r -> { |
|
|
|
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { |
|
|
|
r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); |
|
|
|
} |
|
|
|
}); |
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
result.forEach(r -> { |
|
|
|
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { // 处理字段
|
|
|
|
r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 检查 1、2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中
|
|
|
|
for (int i = 1; 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()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理工序字段 |
|
|
|
*/ |
|
|
|
private void getProcedureName(List<ProductionStatisticsDto> result, int type) { |
|
|
|
// if(type == 1) {
|
|
|
|
// result.forEach(r -> {
|
|
|
|
// if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) {
|
|
|
|
// r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure()));
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// else{
|
|
|
|
// result.forEach(r -> {
|
|
|
|
// if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { // 处理字段
|
|
|
|
// r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure()));
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断静置状态 |
|
|
|
*/ |
|
|
|