From c308a55b10f09bc6bd0846117c612f8ed601b9c7 Mon Sep 17 00:00:00 2001 From: erdanergou Date: Thu, 25 May 2023 13:12:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=87=BA=E5=85=A5=E5=BA=93=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=B7=BB=E5=8A=A0=E7=94=B3=E8=AF=B7=E4=BA=BA=E7=9A=84?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PageController.java | 1 - .../impl/DepositoryRecordServiceImpl.java | 51 ++++++++++--------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java index 5c5ee449..597fa7f4 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java @@ -1284,7 +1284,6 @@ public class PageController { // 获取当前用户管理的仓库 List depositoryAndRole = roleService.findDepositoryAndRole(userToken.getId()); depositoryAndRole.addAll(roleService.findDepositoryAndRole(userToken.getPosition())); - List depositoryIdList = new ArrayList<>(); for (Depository depository : depositoryByAdminorg ) { diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java index d133e2ca..a927d063 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java @@ -409,43 +409,43 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { double priceForYesterDay = 0.0; for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) { // 获取当前入库类型(1物料2组合) - sumForToday += (double) applicationInRecordP.getQuantity() / 100; + sumForToday = ObjectFormatUtil.sum(sumForToday, (double) applicationInRecordP.getQuantity() / 100); Integer mid = applicationInRecordP.getMid(); Material materialById = materialMapper.findMaterialById(mid); - if (materialById.getPrice() != null) { + if (materialById.getPrice() == null) { priceForToday += 0; } else { if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) { - priceForToday += materialById.getPrice() * (double) applicationInRecordP.getQuantity() / 100; + priceForToday = ObjectFormatUtil.sum(priceForToday, materialById.getPrice() * (double) applicationInRecordP.getQuantity() / 100); } else { Map paramForSplitInfo = new HashMap<>(); paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit()); paramForSplitInfo.put("mid", mid); SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1); - priceForToday += materialById.getPrice() / scale * (double) applicationInRecordP.getQuantity() / 100; + priceForToday = ObjectFormatUtil.sum(priceForToday, materialById.getPrice() / scale * (double) applicationInRecordP.getQuantity() / 100); } } } for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) { - sumForYesterDay += (double) applicationInRecordP.getQuantity() / 100; + sumForYesterDay = ObjectFormatUtil.sum(sumForYesterDay, (double) applicationInRecordP.getQuantity() / 100); Integer mid = applicationInRecordP.getMid(); Material materialById = materialMapper.findMaterialById(mid); - if (materialById.getPrice() != null) { + if (materialById.getPrice() == null) { priceForYesterDay += 0; } else { if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) { - priceForYesterDay += materialById.getPrice() * (double) applicationInRecordP.getQuantity() / 100; + priceForYesterDay = ObjectFormatUtil.sum(priceForYesterDay, materialById.getPrice() * (double) applicationInRecordP.getQuantity() / 100); } else { Map paramForSplitInfo = new HashMap<>(); paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit()); paramForSplitInfo.put("mid", mid); SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1); - priceForYesterDay += materialById.getPrice() / scale * (double) applicationInRecordP.getQuantity() / 100; + priceForYesterDay = ObjectFormatUtil.sum(priceForYesterDay, materialById.getPrice() / scale * (double) applicationInRecordP.getQuantity() / 100); } } } @@ -548,8 +548,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } catch (ExecutionException e) { e.printStackTrace(); } - countForToday += ObjectFormatUtil.toDouble(((Map) o).get("count")); - priceForToday += ObjectFormatUtil.toDouble(((Map) o).get("price")); + countForToday = ObjectFormatUtil.sum(countForToday, ObjectFormatUtil.toDouble(((Map) o).get("count"))); + priceForToday = ObjectFormatUtil.sum(priceForToday, ObjectFormatUtil.toDouble(((Map) o).get("price"))); } // 关闭线程池 PublicConfig.closeThreadPool(exsForToday); @@ -578,8 +578,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } catch (ExecutionException e) { e.printStackTrace(); } - countForYesterday += ObjectFormatUtil.toDouble(((Map) o).get("count")); - priceForYesterday += ObjectFormatUtil.toDouble(((Map) o).get("price")); + countForYesterday = ObjectFormatUtil.sum(countForYesterday, ObjectFormatUtil.toDouble(((Map) o).get("count"))); + priceForYesterday = ObjectFormatUtil.sum(priceForYesterday, ObjectFormatUtil.toDouble(((Map) o).get("price"))); } // 关闭线程池 PublicConfig.closeThreadPool(exsForYesterday); @@ -592,6 +592,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { Double ratioForPrice = 0.0; if (Double.compare(countForYesterday, 0.0) != 0) { ratioForCount = ((countForToday - countForYesterday) / countForYesterday); + } if (Double.compare(priceForYesterday, 0.0) != 0) { ratioForPrice = (priceForToday - priceForYesterday) / Double.parseDouble(Double.toString(priceForYesterday)); @@ -605,6 +606,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 获取金额比值 result.put("radioForPrice", ratioForPrice * 100); } else { + // 如果获取已经出库的数量(今天) List applicationOutMinForCompleteForToday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForToday); // 如果获取已经出库的数量(昨天) @@ -4377,7 +4379,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } if (map.containsKey("depositoryId")) { depositoryIdList.add(ObjectFormatUtil.toInteger(map.get("depositoryId"))); - } else if(!map.containsKey("depositoryIdList")){ + } else if (!map.containsKey("depositoryIdList")) { List depositoryAndRole = roleService.findDepositoryAndRole(userByPort.getId()); depositoryAndRole.addAll(roleService.findDepositoryAndRole(userByPort.getPosition())); @@ -4630,17 +4632,20 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { double count = 0; for (ApplicationInRecord applicationInRecordP : applicationInRecordPAll) { Material materialById = materialMapper.findMaterialById(applicationInRecordP.getMid()); - if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) { - sum += materialById.getPrice() / 100 * (double) applicationInRecordP.getQuantity() / 100; - } else { - Map paramForSplitInfo = new HashMap<>(); - paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit()); - paramForSplitInfo.put("mid", applicationInRecordP.getMid()); - SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); - int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1); - sum += materialById.getPrice() / scale / 100 * (double) applicationInRecordP.getQuantity() / 100; + if (materialById.getPrice() != null) { + if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) { + sum = ObjectFormatUtil.sum(sum, (materialById.getPrice() / 100 * (double) applicationInRecordP.getQuantity() / 100)); + } else { + Map paramForSplitInfo = new HashMap<>(); + paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit()); + paramForSplitInfo.put("mid", applicationInRecordP.getMid()); + SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); + int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1); + sum = ObjectFormatUtil.sum(sum, (materialById.getPrice() / scale / 100 * (double) applicationInRecordP.getQuantity() / 100)); + } } - count += (double) applicationInRecordP.getQuantity() / 100; + count = ObjectFormatUtil.sum(count, (double) applicationInRecordP.getQuantity() / 100); + } BigDecimal bg = new BigDecimal(sum); sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();