fix 今日成品量
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.wms.cockpit.service.impl;
|
package org.nl.wms.cockpit.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONException;
|
import com.alibaba.fastjson.JSONException;
|
||||||
@@ -28,6 +29,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: lyd
|
* @Author: lyd
|
||||||
@@ -98,27 +100,45 @@ public class BigScreenServiceImpl implements BigScreenService {
|
|||||||
map.put("YZDayList", dtos);
|
map.put("YZDayList", dtos);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
// TODO: 3、当日成品
|
// 3、当日成品
|
||||||
CompletableFuture<List<ManufacturedProductsDto>> manufacturedProductsDayProductionTask
|
CompletableFuture<List<ManufacturedProductsDto>> manufacturedProductsDayProductionTask
|
||||||
= CompletableFuture.supplyAsync(() -> {
|
= CompletableFuture.supplyAsync(() -> {
|
||||||
List<ManufacturedProductsDto> res = new ArrayList<>();
|
List<ManufacturedProductsDto> res = new ArrayList<>();
|
||||||
Random random = new Random();
|
String date = DateUtil.today() + "%";
|
||||||
// 使用随机数
|
JSONArray qualified = WQL.getWO("COCKPIT_PROCESS_PRODUCTION")
|
||||||
for (int i = 1; i <= 5; i++) {
|
.addParam("flag", "16")
|
||||||
ManufacturedProductsDto manufacturedProductsDto = new ManufacturedProductsDto();
|
.addParam("date", date)
|
||||||
manufacturedProductsDto.setInventory_qty(random.nextInt(2000 - 100 + 1) + 100);
|
.process()
|
||||||
manufacturedProductsDto.setQualified_in_qty(random.nextInt(2000 - 100 + 1) + 100);
|
.getResultJSONArray(0);
|
||||||
manufacturedProductsDto.setUnqualified_in_qty(random.nextInt(2000 - 100 + 1) + 100);
|
JSONArray unqualified = WQL.getWO("COCKPIT_PROCESS_PRODUCTION")
|
||||||
manufacturedProductsDto.setMaterial_code("成品" + i);
|
.addParam("flag", "17")
|
||||||
res.add(manufacturedProductsDto);
|
.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;
|
return res;
|
||||||
}, pool);
|
}, pool);
|
||||||
manufacturedProductsDayProductionTask.thenAccept((result) -> {
|
manufacturedProductsDayProductionTask.thenAccept((result) -> {
|
||||||
map.put("CPDayList", result);
|
map.put("CPDayList", result);
|
||||||
}).exceptionally((e) -> {
|
}).exceptionally((e) -> {
|
||||||
log.error("当日成品生产: {}", e.getMessage(), e);
|
log.error("当日成品生产: {}", e.getMessage(), e);
|
||||||
map.put("CPDayList", null);
|
map.put("CPDayList", new ArrayList<>());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
// 4、设备运行情况
|
// 4、设备运行情况
|
||||||
@@ -1426,7 +1446,7 @@ public class BigScreenServiceImpl implements BigScreenService {
|
|||||||
});
|
});
|
||||||
for (int i = 0; i < res.size(); i++) {
|
for (int i = 0; i < res.size(); i++) {
|
||||||
JSONObject BZX = res.getJSONObject(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"));
|
String vehicleCode = TaskUtils.formatVehicleCode(BZX.getString("vehicle_code"));
|
||||||
BZX.put("vehicle_type", vehicleType);
|
BZX.put("vehicle_type", vehicleType);
|
||||||
BZX.put("vehicle_code", vehicleCode);
|
BZX.put("vehicle_code", vehicleCode);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
输入.flag TYPEAS s_string
|
输入.flag TYPEAS s_string
|
||||||
输入.region_code TYPEAS s_string
|
输入.region_code TYPEAS s_string
|
||||||
输入.point_type TYPEAS s_string
|
输入.point_type TYPEAS s_string
|
||||||
|
输入.date TYPEAS s_string
|
||||||
|
|
||||||
[临时表]
|
[临时表]
|
||||||
--这边列出来的临时表就会在运行期动态创建
|
--这边列出来的临时表就会在运行期动态创建
|
||||||
@@ -357,3 +358,37 @@
|
|||||||
ENDSELECT
|
ENDSELECT
|
||||||
ENDPAGEQUERY
|
ENDPAGEQUERY
|
||||||
ENDIF
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user