add: 工序生产大屏开发
This commit is contained in:
@@ -15,7 +15,7 @@ import javax.sql.DataSource;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Configuration
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
public class DataBaseConfig {
|
||||
|
||||
|
||||
@@ -114,4 +114,15 @@ public class CockpitController{
|
||||
public CommonResult<Object> workshopCondition() {
|
||||
return RestBusinessTemplate.execute(cockpitService::workshopCondition);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工序生产Process production
|
||||
*/
|
||||
@PostMapping("/processProduction")
|
||||
@Log("工序生产")
|
||||
@SaIgnore
|
||||
@ApiOperation("工序生产")
|
||||
public CommonResult<Object> processProduction() {
|
||||
return RestBusinessTemplate.execute(cockpitService::processProduction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,10 @@ public interface CockpitService{
|
||||
* @return 返回结果集
|
||||
*/
|
||||
Map<String,Object> workshopCondition();
|
||||
|
||||
/**
|
||||
* 工序生产
|
||||
* @return
|
||||
*/
|
||||
ConcurrentHashMap<String,Object> processProduction();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.wms.cockpit.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 库存数据
|
||||
* @Date: 2023/5/29
|
||||
*/
|
||||
@Data
|
||||
public class InventoryDto implements Serializable {
|
||||
private Integer region_in_qty;
|
||||
private Integer region_out_qty;
|
||||
private Integer inventory_qty;
|
||||
private String material_code;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.wms.cockpit.service.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 数量与真实数量
|
||||
* @Date: 2023/5/29
|
||||
*/
|
||||
@Data
|
||||
public class NumberDto implements Serializable {
|
||||
// 计划数量
|
||||
private Integer plan_qty;
|
||||
// 真实数量
|
||||
private Integer real_qty;
|
||||
private Integer qualified_qty;
|
||||
private Integer unqualified_qty;
|
||||
// 设备编码
|
||||
private String device_code;
|
||||
private String material_code;
|
||||
private String device_name;
|
||||
// 区域编码
|
||||
private String region_code;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.nl.wms.cockpit.service.impl;
|
||||
|
||||
import cn.hutool.core.date.*;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -9,20 +12,22 @@ 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.ProductionStatisticsEnum;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
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.nl.wms.util.MapOf;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 大屏服务实现1
|
||||
@@ -364,33 +369,346 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
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());
|
||||
@Override
|
||||
public ConcurrentHashMap<String, Object> processProduction() {
|
||||
// 工序生产:混料、压制(成型)、包装、成品
|
||||
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll();
|
||||
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>(2);
|
||||
// 1.1 获取混料当日计划与实际生产、生产率 单位(吨)需要除1000
|
||||
CompletableFuture<List<NumberDto>> mixMaterialStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<NumberDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有混料设备的数据
|
||||
JSONArray result = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "1", "region_code", "HL")).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
res = result.toJavaList(NumberDto.class);
|
||||
// 设备空数据值
|
||||
setResultCompleteInProcessProduction(res, "HL");
|
||||
}
|
||||
}
|
||||
// 检查 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());
|
||||
return res;
|
||||
}, pool);
|
||||
mixMaterialStorage.thenAccept((result) -> {
|
||||
// 整理数据
|
||||
JSONObject res = new JSONObject();
|
||||
int sumRealDay = 0;
|
||||
int sumPlanDay = 0;
|
||||
for (NumberDto numberDto : result) {
|
||||
sumRealDay += numberDto.getReal_qty();
|
||||
sumPlanDay += numberDto.getPlan_qty();
|
||||
}
|
||||
}
|
||||
// 排序
|
||||
Collections.sort(result, Comparator.comparing(dto -> Integer.parseInt(dto.getLabel())));
|
||||
res.put("hl_plan_day", BigDecimal.valueOf((double) sumPlanDay / 1000).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
res.put("hl_real_day", BigDecimal.valueOf((double) sumRealDay / 1000).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
res.put("hl_productivity", sumRealDay / sumPlanDay);
|
||||
res.put("HLDayList", result);
|
||||
if (map.containsKey("HL")) { // 如果存在
|
||||
JSONObject hl = (JSONObject) map.get("HL");
|
||||
res.put("HLWeekList", hl.getJSONArray("HLWeekList"));
|
||||
map.put("HL", res);
|
||||
} else {
|
||||
map.put("HL", res);
|
||||
}
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取混料设备生产信息: {}", e.getMessage(), e);
|
||||
List<NumberDto> dtos = new ArrayList<>();
|
||||
setResultCompleteInProcessProduction(dtos, "HL");
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("hl_plan_day", "0.00");
|
||||
res.put("hl_real_day", "0.00");
|
||||
res.put("hl_productivity", 0);
|
||||
res.put("HLDayList", dtos);
|
||||
if (map.containsKey("HL")) { // 如果存在
|
||||
JSONObject hl = (JSONObject) map.get("HL");
|
||||
res.put("HLWeekList", hl.getJSONArray("HLWeekList"));
|
||||
map.put("HL", res);
|
||||
} else {
|
||||
map.put("HL", res);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
// 1.2 获取每台混捻设备的每周数据
|
||||
CompletableFuture<List<NumberDto>> mixDeviceWeekDayStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<NumberDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有混捻每周的数据
|
||||
JSONArray result = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "2", "region_code", "HL")).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
res = result.toJavaList(NumberDto.class);
|
||||
setResultCompleteInProcessProduction(res, "HL");
|
||||
}
|
||||
return res;
|
||||
}, pool);
|
||||
mixDeviceWeekDayStorage.thenAccept((result) -> {
|
||||
//每周的数据
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("HLWeekList", result);
|
||||
if (map.containsKey("HL")) { // 如果存在
|
||||
JSONObject hl = (JSONObject) map.get("HL");
|
||||
res.put("hl_plan_day", hl.getString("hl_plan_day"));
|
||||
res.put("hl_real_day", hl.getString("hl_real_day"));
|
||||
res.put("hl_productivity", hl.getString("hl_productivity"));
|
||||
res.put("HLDayList", hl.getJSONArray("HLDayList"));
|
||||
map.put("HL", res);
|
||||
} else {
|
||||
map.put("HL", res);
|
||||
}
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取混捻(每周)信息: {}", e.getMessage(), e);
|
||||
List<NumberDto> dtos = new ArrayList<>();
|
||||
setResultCompleteInProcessProduction(dtos, "HL");
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("HLWeekList", dtos);
|
||||
if (map.containsKey("HL")) { // 如果存在
|
||||
JSONObject hl = (JSONObject) map.get("HL");
|
||||
res.put("hl_plan_day", hl.getString("hl_plan_day"));
|
||||
res.put("hl_real_day", hl.getString("hl_real_day"));
|
||||
res.put("hl_productivity", hl.getString("hl_productivity"));
|
||||
res.put("HLDayList", hl.getJSONArray("HLDayList"));
|
||||
map.put("HL", res);
|
||||
} else {
|
||||
map.put("HL", res);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
// 2.1 获取成型的计划与实际生产数量:单位万块, 每天的合格与不合格数量
|
||||
CompletableFuture<List<NumberDto>> yzPlanAndRealStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<NumberDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有混捻每周的数据
|
||||
JSONArray result = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "1", "region_code", "YZ")).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
res = result.toJavaList(NumberDto.class);
|
||||
setResultCompleteInProcessProduction(res, "YZ");
|
||||
}
|
||||
return res;
|
||||
}, pool);
|
||||
yzPlanAndRealStorage.thenAccept((result) -> {
|
||||
// 整理数据
|
||||
JSONObject res = new JSONObject();
|
||||
int sumRealDay = 0;
|
||||
int sumPlanDay = 0;
|
||||
for (NumberDto numberDto : result) {
|
||||
sumRealDay += numberDto.getReal_qty();
|
||||
sumPlanDay += numberDto.getPlan_qty();
|
||||
}
|
||||
res.put("yz_plan_day", BigDecimal.valueOf((double) sumPlanDay / 10000).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
res.put("yz_real_day", BigDecimal.valueOf((double) sumRealDay / 10000).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
res.put("yz_productivity", sumRealDay / sumPlanDay);
|
||||
res.put("YZDayList", result);
|
||||
if (map.containsKey("YZ")) { // 如果存在
|
||||
JSONObject yz = (JSONObject) map.get("YZ");
|
||||
res.put("YZWeekList", yz.getJSONArray("YZWeekList"));
|
||||
map.put("YZ", res);
|
||||
} else {
|
||||
map.put("YZ", res);
|
||||
}
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取压制设备生产信息: {}", e.getMessage(), e);
|
||||
List<NumberDto> dtos = new ArrayList<>();
|
||||
setResultCompleteInProcessProduction(dtos, "YZ");
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("yz_plan_day", "0.00");
|
||||
res.put("yz_real_day", "0.00");
|
||||
res.put("yz_productivity", 0);
|
||||
res.put("YZDayList", dtos);
|
||||
if (map.containsKey("YZ")) { // 如果存在
|
||||
JSONObject yz = (JSONObject) map.get("YZ");
|
||||
res.put("YZWeekList", yz.getJSONArray("YZWeekList"));
|
||||
map.put("YZ", res);
|
||||
} else {
|
||||
map.put("YZ", res);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
// 2.2 压制每周的合格与不合格数量
|
||||
CompletableFuture<List<NumberDto>> yzDeviceWeekDayStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<NumberDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有压制每周的数据
|
||||
JSONArray result = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "2", "region_code", "YZ")).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
res = result.toJavaList(NumberDto.class);
|
||||
setResultCompleteInProcessProduction(res, "YZ");
|
||||
}
|
||||
return res;
|
||||
}, pool);
|
||||
yzDeviceWeekDayStorage.thenAccept((result) -> {
|
||||
//每周的数据
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("YZWeekList", result);
|
||||
if (map.containsKey("YZ")) { // 如果存在
|
||||
JSONObject yz = (JSONObject) map.get("YZ");
|
||||
res.put("yz_plan_day", yz.getString("yz_plan_day"));
|
||||
res.put("yz_real_day", yz.getString("yz_real_day"));
|
||||
res.put("yz_productivity", yz.getString("yz_productivity"));
|
||||
res.put("YZDayList", yz.getJSONArray("YZDayList"));
|
||||
map.put("YZ", res);
|
||||
} else {
|
||||
map.put("YZ", res);
|
||||
}
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取压制(每周)信息: {}", e.getMessage(), e);
|
||||
List<NumberDto> dtos = new ArrayList<>();
|
||||
setResultCompleteInProcessProduction(dtos, "YZ");
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("YZWeekList", dtos);
|
||||
if (map.containsKey("YZ")) { // 如果存在
|
||||
JSONObject yz = (JSONObject) map.get("YZ");
|
||||
res.put("yz_plan_day", yz.getString("yz_plan_day"));
|
||||
res.put("yz_real_day", yz.getString("yz_real_day"));
|
||||
res.put("yz_productivity", yz.getString("yz_productivity"));
|
||||
res.put("YZDayList", yz.getJSONArray("YZDayList"));
|
||||
map.put("YZ", res);
|
||||
} else {
|
||||
map.put("YZ", res);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
// 3.1 获取包装的计划与实际生产数量:单位万块, 每天的合格与不合格数量
|
||||
CompletableFuture<List<NumberDto>> bzPlanAndRealStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<NumberDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有包装每天的数据
|
||||
JSONArray result = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "3")).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
res = result.toJavaList(NumberDto.class);
|
||||
}
|
||||
return res;
|
||||
}, pool);
|
||||
bzPlanAndRealStorage.thenAccept((result) -> {
|
||||
// 整理数据
|
||||
JSONObject res = new JSONObject();
|
||||
int sumRealDay = 0;
|
||||
int sumPlanDay = 0;
|
||||
for (NumberDto numberDto : result) {
|
||||
sumRealDay += numberDto.getReal_qty();
|
||||
sumPlanDay += numberDto.getPlan_qty();
|
||||
}
|
||||
res.put("bz_plan_day", BigDecimal.valueOf((double) sumPlanDay / 10000).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
res.put("bz_real_day", BigDecimal.valueOf((double) sumRealDay / 10000).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
res.put("bz_productivity", sumRealDay / sumPlanDay);
|
||||
res.put("BZDayList", result);
|
||||
if (map.containsKey("BZ")) { // 如果存在
|
||||
JSONObject bz = (JSONObject) map.get("BZ");
|
||||
res.put("BZWeekList", bz.getJSONArray("BZWeekList"));
|
||||
map.put("BZ", res);
|
||||
} else {
|
||||
map.put("BZ", res);
|
||||
}
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取包装设备生产信息: {}", e.getMessage(), e);
|
||||
List<NumberDto> dtos = new ArrayList<>();
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("bz_plan_day", "0.00");
|
||||
res.put("bz_real_day", "0.00");
|
||||
res.put("bz_productivity", 0);
|
||||
res.put("BZDayList", dtos);
|
||||
if (map.containsKey("BZ")) { // 如果存在
|
||||
JSONObject bz = (JSONObject) map.get("BZ");
|
||||
res.put("BZWeekList", bz.getJSONArray("BZWeekList"));
|
||||
map.put("BZ", res);
|
||||
} else {
|
||||
map.put("BZ", res);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
// 3.2 包装每周的合格与不合格数量
|
||||
CompletableFuture<List<NumberDto>> bzDeviceWeekDayStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<NumberDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有包装每周的数据
|
||||
JSONArray result = WQL.getWO("COCKPIT_PROCESS_PRODUCTION").addParamMap(MapOf.of("flag", "4")).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
res = result.toJavaList(NumberDto.class);
|
||||
}
|
||||
return res;
|
||||
}, pool);
|
||||
bzDeviceWeekDayStorage.thenAccept((result) -> {
|
||||
//每周的数据
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("BZWeekList", result);
|
||||
if (map.containsKey("BZ")) { // 如果存在
|
||||
JSONObject bz = (JSONObject) map.get("BZ");
|
||||
res.put("bz_plan_day", bz.getString("bz_plan_day"));
|
||||
res.put("bz_real_day", bz.getString("bz_real_day"));
|
||||
res.put("bz_productivity", bz.getString("bz_productivity"));
|
||||
res.put("BZDayList", bz.getJSONArray("BZDayList"));
|
||||
map.put("BZ", res);
|
||||
} else {
|
||||
map.put("BZ", res);
|
||||
}
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取包装(每周)信息: {}", e.getMessage(), e);
|
||||
List<NumberDto> dtos = new ArrayList<>();
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("BZWeekList", dtos);
|
||||
if (map.containsKey("BZ")) { // 如果存在
|
||||
JSONObject bz = (JSONObject) map.get("BZ");
|
||||
res.put("bz_plan_day", bz.getString("bz_plan_day"));
|
||||
res.put("bz_real_day", bz.getString("bz_real_day"));
|
||||
res.put("bz_productivity", bz.getString("bz_productivity"));
|
||||
res.put("BZDayList", bz.getJSONArray("BZDayList"));
|
||||
map.put("BZ", res);
|
||||
} else {
|
||||
map.put("BZ", res);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
// 4 成品出入库
|
||||
CompletableFuture<List<InventoryDto>> cpDeviceDataStorage = CompletableFuture.supplyAsync(() -> {
|
||||
List<InventoryDto> res = new CopyOnWriteArrayList<>();
|
||||
// 查找所有包装每周的数据
|
||||
return res;
|
||||
}, pool);
|
||||
cpDeviceDataStorage.thenAccept((result) -> {
|
||||
//数据
|
||||
JSONObject result1 = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
InventoryDto dto = new InventoryDto();
|
||||
dto.setInventory_qty(1000000);
|
||||
dto.setRegion_out_qty(5000);
|
||||
dto.setRegion_in_qty(9995000);
|
||||
dto.setMaterial_code("成品" + i);
|
||||
jsonArray.add(dto);
|
||||
}
|
||||
result1.put("in_qty", "100.00");
|
||||
result1.put("out_qty", "10.00");
|
||||
result1.put("inventory_qty", "90.00");
|
||||
result1.put("in_productivity", 30);
|
||||
result1.put("out_productivity", 60);
|
||||
result1.put("inv_productivity", 80);
|
||||
result1.put("KCDayList", jsonArray);
|
||||
result1.put("KCWeekList", jsonArray);
|
||||
map.put("KC", result1);
|
||||
}).exceptionally((e) -> {
|
||||
JSONObject result = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
InventoryDto dto = new InventoryDto();
|
||||
dto.setInventory_qty(1000000);
|
||||
dto.setRegion_out_qty(5000);
|
||||
dto.setRegion_in_qty(9995000);
|
||||
dto.setMaterial_code("成品" + i);
|
||||
jsonArray.add(dto);
|
||||
}
|
||||
result.put("in_qty", "100.00");
|
||||
result.put("out_qty", "10.00");
|
||||
result.put("inventory_qty", "90.00");
|
||||
result.put("in_productivity", 30);
|
||||
result.put("out_productivity", 60);
|
||||
result.put("inv_productivity", 80);
|
||||
result.put("KCDayList", jsonArray);
|
||||
result.put("KCWeekList", jsonArray);
|
||||
map.put("KC", result);
|
||||
return null;
|
||||
});
|
||||
CompletableFuture<Void> allQuery = CompletableFuture.allOf(mixMaterialStorage
|
||||
, mixDeviceWeekDayStorage
|
||||
, yzPlanAndRealStorage
|
||||
, yzDeviceWeekDayStorage
|
||||
, bzPlanAndRealStorage
|
||||
, bzDeviceWeekDayStorage
|
||||
, cpDeviceDataStorage);
|
||||
CompletableFuture<ConcurrentHashMap<String, Object>> future = allQuery.thenApply((result) -> map).exceptionally((e) -> {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
future.join();
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,4 +729,74 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理空白数据设置默认值
|
||||
*/
|
||||
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())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理空白数据 - 工序
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
private void setResultCompleteInProcessProduction(List<NumberDto> result, String region_code) {
|
||||
HashSet<String> existingLabels = new HashSet<>(); // 创建一个 HashSet 对象
|
||||
// 遍历 result 列表中的每个 ProductionStatisticsDto 对象
|
||||
for (NumberDto dto : result) {
|
||||
// 检查 device_code 字段是否存在于 existingLabels 集合中
|
||||
if (!existingLabels.contains(dto.getDevice_code())) {
|
||||
// 将缺少的标签值添加到 existingLabels 集合中
|
||||
existingLabels.add(dto.getDevice_code());
|
||||
}
|
||||
}
|
||||
// 获取所有设备编码
|
||||
WQLObject deviceTab = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONArray resultJSONArray = deviceTab.query("region_code = '" + region_code + "' AND is_workorder = '1'").getResultJSONArray(0);
|
||||
for (int i = 0; i < resultJSONArray.size(); i++) {
|
||||
JSONObject jsonObject = resultJSONArray.getJSONObject(i);
|
||||
if (!existingLabels.contains(jsonObject.getString("device_code"))) {
|
||||
NumberDto dto = new NumberDto();
|
||||
dto.setDevice_code(jsonObject.getString("device_code"));
|
||||
dto.setRegion_code(jsonObject.getString("region_code"));
|
||||
dto.setDevice_name(jsonObject.getString("device_name"));
|
||||
dto.setPlan_qty(0);
|
||||
dto.setReal_qty(0);
|
||||
dto.setQualified_qty(0);
|
||||
dto.setUnqualified_qty(0);
|
||||
result.add(dto);
|
||||
} else {
|
||||
result.forEach(numberDto -> {
|
||||
if (numberDto.getDevice_code().equals(jsonObject.getString("device_code"))) {
|
||||
numberDto.setDevice_name(jsonObject.getString("device_name"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Collections.sort(result, Comparator.comparing(NumberDto::getDevice_code));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
[交易说明]
|
||||
交易名: 仓储监控
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.region_code TYPEAS s_string
|
||||
输入.point_type TYPEAS s_string
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
w.device_code,
|
||||
d.region_code,
|
||||
IF(LENGTH(SUM(w.plan_qty)) > 0,SUM(w.plan_qty),0) AS plan_qty,
|
||||
IF(LENGTH(SUM(w.real_qty)) > 0,SUM(w.real_qty),0) AS real_qty,
|
||||
IF(LENGTH(SUM(w.qualified_qty)) > 0,SUM(w.qualified_qty),0) AS qualified_qty,
|
||||
IF(LENGTH(SUM(w.unqualified_qty)) > 0,SUM(w.unqualified_qty),0) AS unqualified_qty
|
||||
FROM
|
||||
pdm_bd_workorder w
|
||||
LEFT JOIN pdm_bi_device d ON w.device_id = d.device_id
|
||||
WHERE
|
||||
DATE( w.plan_date ) = CURDATE()
|
||||
OPTION 输入.region_code <> ""
|
||||
d.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
GROUP BY w.device_code
|
||||
ORDER BY w.device_code
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
w.device_code,
|
||||
d.region_code,
|
||||
IF(LENGTH(SUM(w.plan_qty)) > 0,SUM(w.plan_qty),0) AS plan_qty,
|
||||
IF(LENGTH(SUM(w.real_qty)) > 0,SUM(w.real_qty),0) AS real_qty
|
||||
FROM
|
||||
pdm_bd_workorder w
|
||||
LEFT JOIN pdm_bi_device d ON w.device_id = d.device_id
|
||||
WHERE
|
||||
WEEKDAY(w.plan_date) >= 0
|
||||
AND WEEKDAY(w.plan_date) <= 6
|
||||
AND YEARWEEK(w.plan_date) = YEARWEEK(CURDATE())
|
||||
OPTION 输入.region_code <> ""
|
||||
d.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
GROUP BY w.device_code
|
||||
ORDER BY w.device_code
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
m.material_code,
|
||||
IF(LENGTH(SUM(w.plan_qty)) > 0,SUM(w.plan_qty),0) AS plan_qty,
|
||||
IF(LENGTH(SUM(w.real_qty)) > 0,SUM(w.real_qty),0) AS real_qty,
|
||||
IF(LENGTH(SUM(w.qualified_qty)) > 0,SUM(w.qualified_qty),0) AS qualified_qty,
|
||||
IF(LENGTH(SUM(w.unqualified_qty)) > 0,SUM(w.unqualified_qty),0) AS unqualified_qty
|
||||
FROM
|
||||
pdm_bd_workorder w
|
||||
LEFT JOIN pdm_bi_device d ON w.device_id = d.device_id
|
||||
LEFT JOIN md_me_materialbase m ON w.material_id = m.material_id
|
||||
WHERE d.region_code = 'FJ'
|
||||
GROUP BY w.material_id
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
m.material_code,
|
||||
IF(LENGTH(SUM(w.plan_qty)) > 0,SUM(w.plan_qty),0) AS plan_qty,
|
||||
IF(LENGTH(SUM(w.real_qty)) > 0,SUM(w.real_qty),0) AS real_qty,
|
||||
IF(LENGTH(SUM(w.qualified_qty)) > 0,SUM(w.qualified_qty),0) AS qualified_qty,
|
||||
IF(LENGTH(SUM(w.unqualified_qty)) > 0,SUM(w.unqualified_qty),0) AS unqualified_qty
|
||||
FROM
|
||||
pdm_bd_workorder w
|
||||
LEFT JOIN pdm_bi_device d ON w.device_id = d.device_id
|
||||
LEFT JOIN md_me_materialbase m ON w.material_id = m.material_id
|
||||
WHERE d.region_code = 'FJ'
|
||||
GROUP BY w.material_id
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
Reference in New Issue
Block a user