diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java index a80018c..0c1be89 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java @@ -1,5 +1,6 @@ package org.nl.wms.cockpit.service.impl; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; @@ -28,6 +29,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ThreadPoolExecutor; +import java.util.stream.Collectors; /** * @Author: lyd @@ -98,27 +100,45 @@ public class BigScreenServiceImpl implements BigScreenService { map.put("YZDayList", dtos); return null; }); - // TODO: 3、当日成品 + // 3、当日成品 CompletableFuture> manufacturedProductsDayProductionTask = CompletableFuture.supplyAsync(() -> { List res = new ArrayList<>(); - Random random = new Random(); - // 使用随机数 - for (int i = 1; i <= 5; i++) { - ManufacturedProductsDto manufacturedProductsDto = new ManufacturedProductsDto(); - manufacturedProductsDto.setInventory_qty(random.nextInt(2000 - 100 + 1) + 100); - manufacturedProductsDto.setQualified_in_qty(random.nextInt(2000 - 100 + 1) + 100); - manufacturedProductsDto.setUnqualified_in_qty(random.nextInt(2000 - 100 + 1) + 100); - manufacturedProductsDto.setMaterial_code("成品" + i); - res.add(manufacturedProductsDto); + String date = DateUtil.today() + "%"; + JSONArray qualified = WQL.getWO("COCKPIT_PROCESS_PRODUCTION") + .addParam("flag", "16") + .addParam("date", date) + .process() + .getResultJSONArray(0); + JSONArray unqualified = WQL.getWO("COCKPIT_PROCESS_PRODUCTION") + .addParam("flag", "17") + .addParam("date", date) + .process() + .getResultJSONArray(0); + for (int i = 0; i < qualified.size(); i++) { + JSONObject qualified_data = qualified.getJSONObject(0); + String material_code = qualified_data.getString("material_code"); + JSONObject unqualified_data = unqualified + .stream() + .map(o -> (JSONObject) o) + .filter(o -> material_code.equals(o.getString("material_code"))) + .collect(Collectors.toList()) + .get(0); + ManufacturedProductsDto dto = new ManufacturedProductsDto(); + dto.setMaterial_code(material_code.substring(1, 12)); + dto.setQualified_in_qty(qualified_data.getIntValue("qualified_qty")); + dto.setUnqualified_in_qty(ObjectUtil.isEmpty(unqualified_data) ? 0 : unqualified_data.getIntValue("unqualified_qty")); + dto.setInventory_qty(dto.getQualified_in_qty() + dto.getUnqualified_in_qty()); + res.add(dto); } + return res; }, pool); manufacturedProductsDayProductionTask.thenAccept((result) -> { map.put("CPDayList", result); }).exceptionally((e) -> { log.error("当日成品生产: {}", e.getMessage(), e); - map.put("CPDayList", null); + map.put("CPDayList", new ArrayList<>()); return null; }); // 4、设备运行情况 @@ -1426,7 +1446,7 @@ public class BigScreenServiceImpl implements BigScreenService { }); for (int i = 0; i < res.size(); i++) { JSONObject BZX = res.getJSONObject(i); - int vehicleType = BZX.getInteger("vehicle_type") + 2; + int vehicleType = BZX.getIntValue("vehicle_type") == 0 ? 0 : BZX.getIntValue("vehicle_type") + 2; String vehicleCode = TaskUtils.formatVehicleCode(BZX.getString("vehicle_code")); BZX.put("vehicle_type", vehicleType); BZX.put("vehicle_code", vehicleCode); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql index cfc9d04..6440781 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql @@ -16,6 +16,7 @@ 输入.flag TYPEAS s_string 输入.region_code TYPEAS s_string 输入.point_type TYPEAS s_string + 输入.date TYPEAS s_string [临时表] --这边列出来的临时表就会在运行期动态创建 @@ -357,3 +358,37 @@ ENDSELECT ENDPAGEQUERY ENDIF + + IF 输入.flag = "16" + QUERY + SELECT + cInvCode AS material_code, + SUM(iNum) AS qualified_qty + FROM + st_ivt_regionio + WHERE + cInvCode LIKE 'F%' + AND cVouchType = '完工入库' + AND dDate LIKE 输入.date + GROUP BY + cInvCode + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "16" + QUERY + SELECT + cInvCode AS material_code, + SUM(iNum) AS unqualified_qty + FROM + st_ivt_regionio + WHERE + cInvCode LIKE 'F%' + AND cVouchType = '废品入库' + AND dDate LIKE 输入.date + GROUP BY + cInvCode + ENDSELECT + ENDQUERY + ENDIF