物资管理大屏接口优化

This commit is contained in:
2025-12-16 19:06:44 +08:00
parent bb63e7464d
commit 5fc35e1a4c
2 changed files with 50 additions and 40 deletions

View File

@ -85,12 +85,13 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
.between(MatMaterialReceiveItem::getCreateTime, monthStart, currentTime));
if (CollUtil.isEmpty(matMaterialReceiveItems)) {
vo.setEnterTotalPrices(BigDecimal.ZERO);
}
}else {
// 计算本月入库金额
matMaterialReceiveItems.forEach(item -> {
vo.setEnterTotalPrices(vo.getEnterTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice())));
});
vo.setEnterTotalPrices(vo.getEnterTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP));
BigDecimal enterTotalPrices = matMaterialReceiveItems.stream()
.map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setEnterTotalPrices(enterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取上月入库数据
List<MatMaterialReceiveItem> oldMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialReceiveItem>()
.eq(MatMaterialReceiveItem::getProjectId, projectId)
@ -98,12 +99,13 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
.between(MatMaterialReceiveItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay));
if (CollUtil.isEmpty(oldMatMaterialReceiveItems)) {
vo.setOldEnterTotalPrices(BigDecimal.ZERO);
}
}else {
// 计算上月入库金额
oldMatMaterialReceiveItems.forEach(item -> {
vo.setOldEnterTotalPrices(vo.getOldEnterTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice())));
});
vo.setOldEnterTotalPrices(vo.getOldEnterTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP));
BigDecimal oldEnterTotalPrices = oldMatMaterialReceiveItems.stream()
.map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setOldEnterTotalPrices(oldEnterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取当月出库数据
List<MatMaterialIssueItem> matMaterialIssueItems = materialIssueItemService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialIssueItem>()
@ -114,11 +116,12 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
//计算本月出库金额
if (CollUtil.isEmpty(matMaterialIssueItems)) {
vo.setLeaveTotalPrices(BigDecimal.ZERO);
}else {
BigDecimal leaveTotalPrices = matMaterialIssueItems.stream()
.map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setLeaveTotalPrices(leaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
matMaterialIssueItems.forEach(item -> {
vo.setLeaveTotalPrices(vo.getLeaveTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice())));
});
vo.setLeaveTotalPrices(vo.getLeaveTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP));
// 获取上月出库数据
List<MatMaterialIssueItem> oldMatMaterialIssueItems = materialIssueItemService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialIssueItem>()
@ -128,29 +131,36 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
//计算上月出库金额
if (CollUtil.isEmpty(oldMatMaterialIssueItems)) {
vo.setOldLeaveTotalPrices(BigDecimal.ZERO);
}else {
BigDecimal oldLeaveTotalPrices = oldMatMaterialIssueItems.stream()
.map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setOldLeaveTotalPrices(oldLeaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
oldMatMaterialIssueItems.forEach(item -> {
vo.setOldLeaveTotalPrices(vo.getOldLeaveTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice())));
});
vo.setOldLeaveTotalPrices(vo.getOldLeaveTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP));
//获取总入库存金额 入库 * 单价
List<MatMaterialReceiveItem> totalMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialReceiveItem>().eq(MatMaterialReceiveItem::getProjectId, projectId));
if (CollUtil.isEmpty(totalMatMaterialReceiveItems)) {
vo.setInventoryTotalPrices(BigDecimal.ZERO);
}else {
// 计算总入库存金额
BigDecimal inventoryTotalPrices = totalMatMaterialReceiveItems.stream()
.map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setInventoryTotalPrices(inventoryTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
totalMatMaterialReceiveItems.forEach(item -> {
vo.setInventoryTotalPrices(vo.getInventoryTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice())));
});
vo.setInventoryTotalPrices(vo.getInventoryTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP));
// 获取总出库金额 出库 * 单价
List<MatMaterialIssueItem> totalMatMaterialIssueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialIssueItem>().eq(MatMaterialIssueItem::getProjectId, projectId));
if (CollUtil.isEmpty(totalMatMaterialIssueItems)) {
vo.setOutTotalPrices(BigDecimal.ZERO);
}else {
// 计算总出库金额
BigDecimal outTotalPrices = totalMatMaterialIssueItems.stream()
.map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setOutTotalPrices(outTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
totalMatMaterialIssueItems.forEach(item -> {
vo.setOutTotalPrices(vo.getOutTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice())));
});
vo.setOutTotalPrices(vo.getOutTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP));
// 获取施工图一览大类名下所有小类名
List<BusBillofquantitiesLimitList> limitLists = billofquantitiesLimitListService.getBaseMapper().selectList(new LambdaQueryWrapper<BusBillofquantitiesLimitList>()

View File

@ -74,11 +74,12 @@ public class BigScreenWebSocketServer {
// 存储会话到在线列表
ONLINE_SESSIONS.put(session.getId(), session);
log.info("📌 客户端连接成功会话ID{},当前在线数:{}", session.getId(), ONLINE_SESSIONS.size());
String[] split = currentSubscriptionId.split("-");
Long projectId = Long.parseLong(split[0]);
long type = Long.parseLong(split[1]);
// 异步推送初始化数据(原有逻辑保留)
CompletableFuture.runAsync(() -> {
try {
String[] split = currentSubscriptionId.split("-");
//todo 填充不同类型大屏获取基础数据的方法判断
IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class);
IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class);
@ -88,8 +89,7 @@ public class BigScreenWebSocketServer {
// 大屏-质安管理
DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class);
Long projectId = Long.parseLong(split[0]);
long type = Long.parseLong(split[1]);
List<Map<String, String>> maps = new ArrayList<>();
switch ((int) type){
case 1: