From e763d2271a7de2d0188574904c8b2619ff9d37ba Mon Sep 17 00:00:00 2001 From: xs Date: Thu, 5 Dec 2024 16:30:14 +0800 Subject: [PATCH] =?UTF-8?q?3.5.10=20=E7=9C=8B=E6=9D=BF=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=92=8C=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FifthMesBorderController.java | 8 +-- .../impl/FourthMesBoardServiceImpl.java | 36 +++++++----- .../domain/MesProduceStatisticsDetail.java | 10 ++++ .../com/hw/mes/domain/MesProductPlan.java | 10 ++++ .../impl/MesProductPlanDetailServiceImpl.java | 5 +- .../mes/MesProduceStatisticsDetailMapper.xml | 3 + .../mapper/mes/MesProductOrderMapper.xml | 14 ++--- .../mapper/mes/MesProductPlanMapper.xml | 4 +- .../mapper/mes/MesSaleOrderMapper.xml | 2 +- .../controller/FifthWmsBorderController.java | 7 ++- .../controller/SecondWmsBorderController.java | 55 +++++++++++-------- .../impl/FifthWmsBoardServiceImpl.java | 36 +++++++----- .../service/impl/FourthWmsBoardService.java | 2 +- .../impl/SecondWmsBoardServiceImpl.java | 46 ++++++++++------ .../mapper/wms/WmsBaseLocationMapper.xml | 4 +- .../mapper/wms/WmsProductStockMapper.xml | 10 ++-- .../src/views/board/warehouse/fifthFloor.vue | 24 ++++---- .../src/views/board/warehouse/secondFloor.vue | 14 ++--- .../src/views/dms/dmsBaseAlarmRule/index.vue | 32 +++++------ .../views/dms/dmsRecordAlarmInfo/index.vue | 12 ++-- .../qms/base/checkrule/checkRuleDetail.vue | 4 +- 21 files changed, 204 insertions(+), 134 deletions(-) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/board/controller/FifthMesBorderController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/board/controller/FifthMesBorderController.java index f6ea6b49..2eddae11 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/board/controller/FifthMesBorderController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/board/controller/FifthMesBorderController.java @@ -15,21 +15,21 @@ public class FifthMesBorderController { private FifthMesBorderService fifthMesBorderService; /** - * 五楼生产进度 + * 五楼生产进度(最新一条生产任务,看板最上方) */ @GetMapping("/productProgress") public AjaxResult productProgress(){ return AjaxResult.success(fifthMesBorderService.productProgress()); } /** - * 工单生产进度 + * 生产任务信息(左下) */ @GetMapping("/workOrderProgress") public AjaxResult workOrderProgress(){ return AjaxResult.success(fifthMesBorderService.workOrderProgress()); } /** - * 生产合格 + * 组员生产合格率,后台配置(左中) */ @GetMapping("/productionQualified") public AjaxResult productionQualified(){ @@ -44,7 +44,7 @@ public class FifthMesBorderController { return AjaxResult.success(fifthMesBorderService.orderTime()); } /** - * 工位生产效率 + * 工位生产效率(右下角) */ @GetMapping("/orderEfficiency") public AjaxResult orderEfficiency(){ diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/board/service/impl/FourthMesBoardServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/board/service/impl/FourthMesBoardServiceImpl.java index 7400957d..33d583b6 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/board/service/impl/FourthMesBoardServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/board/service/impl/FourthMesBoardServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; import java.text.DecimalFormat; + @Service public class FourthMesBoardServiceImpl implements IFourthMesBoardService { @Autowired @@ -68,7 +69,7 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService { latestProductOrder.setMesProductPlanList(mesProductPlanList); - List mesBaseProcessInfoList = this.computeProcessPercentage(mesProductPlanList); + List mesBaseProcessInfoList = this.computeProcessPercentage(mesProductPlanList); latestProductOrder.setBaseProcessInfoList(mesBaseProcessInfoList); } @@ -79,17 +80,17 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService { /** * 计算工序占比 */ - private List computeProcessPercentage(List mesProductPlanList){ + private List computeProcessPercentage(List mesProductPlanList) { //所有工序加起来的占比 int totalPercentage = mesProductPlanList.stream() .mapToInt(MesProductPlan::getProcessPercentageInt) .reduce(0, Integer::sum); - Map processInfo = new HashMap<>(); - processInfo.put(41L,"激光切割"); - processInfo.put(42L,"折弯"); - processInfo.put(43L,"焊接"); - processInfo.put(44L,"装配"); + Map processInfo = new HashMap<>(); + processInfo.put(41L, "激光切割"); + processInfo.put(42L, "折弯"); + processInfo.put(43L, "焊接"); + processInfo.put(44L, "装配"); Map> processIdMap = mesProductPlanList.stream().collect(Collectors.groupingBy(MesProductPlan::getProcessId)); @@ -100,10 +101,14 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService { int processTotalPercentage = mesProductPlans.stream() .mapToInt(MesProductPlan::getProcessPercentageInt) .reduce(0, Integer::sum); - int computePercentage = processTotalPercentage/totalPercentage*75; + int computePercentage = 0 ; + if (totalPercentage>0){ + computePercentage = processTotalPercentage / totalPercentage * 75; + } + MesBaseProcessInfo baseProcessInfo = new MesBaseProcessInfo();//喷塑 - baseProcessInfo.setProcessPercentage(computePercentage+"%"); + baseProcessInfo.setProcessPercentage(computePercentage + "%"); baseProcessInfo.setProcessName(processInfo.get(processId)); mesBaseProcessInfoList.add(baseProcessInfo); } @@ -124,12 +129,13 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService { /** * 获取良率,不良率和物料利用率,供4楼生产看板右下方展示 + * * @return */ @Override - public JSONObject getQualityAndAvailablePercentage(){ + public JSONObject getQualityAndAvailablePercentage() { JSONObject resultJson = new JSONObject(); - // 定义良率范围 + // 定义良率范围 double passRateMin = 95.0; // 最小值 double passRateMax = 100.0; // 最大值 @@ -137,7 +143,7 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService { double passRate = generateRandomWithOneDecimal(passRateMin, passRateMax); //不良率 - double failureRate = 100-passRate; + double failureRate = 100 - passRate; DecimalFormat df = new DecimalFormat("#.0"); @@ -147,9 +153,9 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService { double availableRate = generateRandomWithOneDecimal(availableRateMin, availableRateMax); - resultJson.put("passRate",passRate+"%"); - resultJson.put("failureRate",Double.parseDouble(df.format(failureRate))+"%"); - resultJson.put("availableRate",availableRate+"%"); + resultJson.put("passRate", passRate + "%"); + resultJson.put("failureRate", Double.parseDouble(df.format(failureRate)) + "%"); + resultJson.put("availableRate", availableRate + "%"); return resultJson; diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProduceStatisticsDetail.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProduceStatisticsDetail.java index 863506bb..a82841f6 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProduceStatisticsDetail.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProduceStatisticsDetail.java @@ -25,6 +25,8 @@ public class MesProduceStatisticsDetail extends BaseEntity @Excel(name = "生产工单ID") private Long productOrderId; + private String productOrderStatus; + private String dispatchType; private Long dispatchId; @@ -132,6 +134,14 @@ public class MesProduceStatisticsDetail extends BaseEntity return productOrderId; } + public String getProductOrderStatus() { + return productOrderStatus; + } + + public void setProductOrderStatus(String productOrderStatus) { + this.productOrderStatus = productOrderStatus; + } + public String getDispatchType() { return dispatchType; } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java index 06851d55..0f23f972 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java @@ -210,6 +210,8 @@ public class MesProductPlan extends BaseEntity private String processPercentage; + private String orderStatus;//生产工单状态 + public Long getSaleOrderId() { return saleOrderId; } @@ -647,6 +649,14 @@ public class MesProductPlan extends BaseEntity this.processPercentage = processPercentage; } + public String getOrderStatus() { + return orderStatus; + } + + public void setOrderStatus(String orderStatus) { + this.orderStatus = orderStatus; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java index aa0bf938..19f5ab87 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java @@ -831,8 +831,10 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer queryProductPlandetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH); queryProductPlandetail.setStatisticsFlag("1"); List mesProductPlanDetailList = mesProductPlanDetailMapper.selectMesProductPlanDetailList4Statistics(queryProductPlandetail); + List filterProductPlanDetailList = mesProductPlanDetailList.stream() + .filter(mppd-> mppd.getRealBeginTime()!=null && mppd.getRealEndTime()!=null).collect(Collectors.toList()); - for (MesProductPlanDetail mesProductPlanDetail : mesProductPlanDetailList) { + for (MesProductPlanDetail mesProductPlanDetail : filterProductPlanDetailList) { MesProductPlan mesProductPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanId(mesProductPlanDetail.getPlanId()); //计算工时 @@ -877,6 +879,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer MesProduceStatisticsDetail mesProduceStatisticsDetail = new MesProduceStatisticsDetail(); mesProduceStatisticsDetail.setProductOrderId(mesProductPlan.getProductOrderId()); + mesProduceStatisticsDetail.setProductOrderStatus(mesProductPlan.getOrderStatus()); mesProduceStatisticsDetail.setDispatchType(mesProductPlan.getDispatchType()); mesProduceStatisticsDetail.setDispatchId(mesProductPlan.getDispatchId()); mesProduceStatisticsDetail.setSaleOrderId(mesProductPlan.getSaleOrderId()); diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProduceStatisticsDetailMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProduceStatisticsDetailMapper.xml index 33c26f13..cd355016 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProduceStatisticsDetailMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProduceStatisticsDetailMapper.xml @@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -87,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into mes_produce_statistics_detail product_order_id, + product_order_status, dispatch_type, dispatch_id, sale_order_id, @@ -112,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{productOrderId}, + #{productOrderStatus}, #{dispatchType}, #{dispatchId}, #{saleOrderId}, diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml index 838f3e83..cad0a5c0 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml @@ -460,16 +460,16 @@ - select - x.* + x.order_code,x.plan_amount,x.complete_amount,mbmi.material_name from - `hwjy-cloud`.mes_product_order x + mes_product_order x left join mes_base_material_info mbmi on x.material_id=mbmi.material_id where x.dispatch_id = 4 - and x.real_begin_time > now() - interval 1 month + and x.plan_begin_time > now() - interval 1 month order by - x.real_begin_time asc + x.plan_begin_time desc diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml index 27f17bb7..ac508333 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml @@ -272,7 +272,7 @@ and not exists (select 1 from mes_sale_order_relate msor where mso.sale_order_id = msor.relate_sale_order_id) and exists (select 1 from mes_material_bom mmb where mmb.erp_material_id=mso.material_id and mmb.material_bom_id in (${parentIds})) - order by mso.saleorder_code,mso.erp_modify_date desc + order by mso.erp_modify_date desc diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/FifthWmsBorderController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/FifthWmsBorderController.java index b3c55dab..ada0ca15 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/FifthWmsBorderController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/FifthWmsBorderController.java @@ -16,19 +16,22 @@ public class FifthWmsBorderController { private FifthWmsBorderService fifthWmsBorderService; /** - * 五楼库存数量 + * 五楼库存数量(看板最上方) */ @GetMapping("/locationCount") public AjaxResult locationCount(){ return AjaxResult.success(fifthWmsBorderService.locationCount()); } /** - * 库存饼状图 + * 库存饼状图(左边四个饼状图) */ @GetMapping("fifthPanake") public AjaxResult fifthPanake(){ return AjaxResult.success(fifthWmsBorderService.fifthPanake()); } + + + /** * 成品库可用库存占比 */ diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/SecondWmsBorderController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/SecondWmsBorderController.java index f3df0b67..c2bcb2b1 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/SecondWmsBorderController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/controller/SecondWmsBorderController.java @@ -15,29 +15,26 @@ public class SecondWmsBorderController { private SecondWmsBorderService secondWmsBorderService; /** - * 库存总量统计 + * 当日入库量和出库量,本月入库量和本月出库量(看板最上方) + * @return + */ + @GetMapping("/todayInstockAmount") + public AjaxResult todayInstockAmount(){ + return AjaxResult.success(secondWmsBorderService.todayInstockAmount()); + } + + + /** + * 库存总量统计(左中) * @return */ @GetMapping("/totalStock") public AjaxResult totalStock(){ return AjaxResult.success(secondWmsBorderService.totalStock()); } + /** - * 库位原理统计 - */ - @GetMapping("/locationCount") - public AjaxResult locationCount(){ - return AjaxResult.success(secondWmsBorderService.locationCount()); - } - /** - * 任务编号 - */ - @GetMapping("/tableInfo") - public AjaxResult tableInfo(){ - return AjaxResult.success(secondWmsBorderService.tableInfo()); - } - /** - * 库存变化折线图 + * 库存变化折线图(右中) */ @GetMapping("/inAndOutStockInfo") public AjaxResult inAndOutStockInfo(){ @@ -45,7 +42,7 @@ public class SecondWmsBorderController { } /** - * 入库时段统计 + * 入库时段统计(左下) * @return */ @GetMapping("/instockTimeCount") @@ -53,12 +50,26 @@ public class SecondWmsBorderController { return AjaxResult.success(secondWmsBorderService.instockTimeCount()); } + /** - * 当日入库量 - * @return + * 库位分析(中下) */ - @GetMapping("/todayInstockAmount") - public AjaxResult todayInstockAmount(){ - return AjaxResult.success(secondWmsBorderService.todayInstockAmount()); + @GetMapping("/locationCount") + public AjaxResult locationCount(){ + return AjaxResult.success(secondWmsBorderService.locationCount()); } + + + /** + * 查询成品出库明细 + */ + @GetMapping("/tableInfo") + public AjaxResult tableInfo(){ + return AjaxResult.success(secondWmsBorderService.tableInfo()); + } + + + + + } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FifthWmsBoardServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FifthWmsBoardServiceImpl.java index 397d51bb..9513e568 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FifthWmsBoardServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FifthWmsBoardServiceImpl.java @@ -39,21 +39,29 @@ public class FifthWmsBoardServiceImpl implements FifthWmsBorderService { @Override public Map locationCount() { HashMap map = new HashMap<>(); - List list = wmsRawInstockMapper.locationCount(); - List list1 = wmsRawOutstockMapper.locationCount(); + List list = wmsRawInstockMapper.locationCount();//原料柜体和辅料近一个月入库数量 + List list1 = wmsRawOutstockMapper.locationCount();//辅料近一个月出库数量 List list2 = wmsProductInstockMapper.locationCount(); List list3 = wmsProductOutstockMapper.locationCount(); - for (WmsProductInstock wmsProductInstock : list) { - if (wmsProductInstock.getWarehouseId()==511){ - map.put("rawInStock",wmsProductInstock.getInstockAmount()); - } - if (wmsProductInstock.getWarehouseId()==512){ - map.put("furawInStock",wmsProductInstock.getInstockAmount()); + if(list!=null && !list.isEmpty()) { + for (WmsProductInstock wmsProductInstock : list) { + if (wmsProductInstock.getWarehouseId() == 511) { + map.put("rawInStock", wmsProductInstock.getInstockAmount().intValue());//原料柜体入库数量 + } + if (wmsProductInstock.getWarehouseId() == 512) { + map.put("furawInStock", wmsProductInstock.getInstockAmount().intValue());//辅料入库数量 + } } } - map.put("rawOutStock",list1.get(0).getRealOutstockAmount()); - map.put("productInStock",list2.get(0).getInstockAmount()); - map.put("productOutStock",list3.get(0).getOutstockQty()); + if(list1!=null && !list1.isEmpty()) { + map.put("rawOutStock", list1.get(0).getRealOutstockAmount().intValue()); + } + if(list2!=null && !list2.isEmpty()) { + map.put("productInStock", list2.get(0).getInstockAmount().intValue()); + } + if(list3!=null && !list3.isEmpty()) { + map.put("productOutStock", list3.get(0).getOutstockQty().intValue()); + } return map; } @@ -67,9 +75,9 @@ public class FifthWmsBoardServiceImpl implements FifthWmsBorderService { @Override public Map fifthPanake() { - List wmsRawStocks = wmsRawStockMapper.selectRawLocationPercentage(); + List wmsRawStocks = wmsRawStockMapper.selectRawLocationPercentage();//原材料库存占比(原料柜体) List productStocks = wmsProductStockMapper.selectProductStockPercentage(); - Integer emptyLocationCount = wmsBaseLocationMapper.selectEmptyLocation(); + Integer emptyLocationCount = wmsBaseLocationMapper.selectEmptyLocation();// Integer allLocation = wmsBaseLocationMapper.selectAllLocation(); BigDecimal emptyLocationPercentage = new BigDecimal(emptyLocationCount).divide(new BigDecimal(allLocation), 2, BigDecimal.ROUND_HALF_UP); Integer oppylLocation = allLocation - emptyLocationCount; @@ -77,7 +85,7 @@ public class FifthWmsBoardServiceImpl implements FifthWmsBorderService { HashMap map = new HashMap<>(); map.put("wmsRawStocks",wmsRawStocks); map.put("productStocks",productStocks); - map.put("emptyLocationPercentage",emptyLocationPercentage); + map.put("emptyLocationPercentage",emptyLocationPercentage);//辅料空料箱占比 map.put("opplyLocationPercentage",opplyLocationPercentage); return map; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FourthWmsBoardService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FourthWmsBoardService.java index 21ddeff5..45d3c8f2 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FourthWmsBoardService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/FourthWmsBoardService.java @@ -63,7 +63,7 @@ public class FourthWmsBoardService implements IFourthWmsBoardService { @Override public List getFourthFloorTotalProductStocks() { WmsStockTotal queryStockTotal = new WmsStockTotal(); - //todo: 需要设置仓库ID为431 + queryStockTotal.setWarehouseId(431L); List wmsStockTotalList = wmsStockTotalMapper.selectStockTotalListGroupByMaterial(queryStockTotal); return wmsStockTotalList; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/SecondWmsBoardServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/SecondWmsBoardServiceImpl.java index 23b396e4..78192d48 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/SecondWmsBoardServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/board/service/impl/SecondWmsBoardServiceImpl.java @@ -12,11 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service public class SecondWmsBoardServiceImpl implements SecondWmsBorderService { @@ -62,16 +60,32 @@ public class SecondWmsBoardServiceImpl implements SecondWmsBorderService { public List inAndOutStockInfo() { List instocks = wmsProductStockMapper.selectInStock(); List outstocks = wmsProductStockMapper.selectOutStock(); - Map> map = outstocks.stream().collect(Collectors.groupingBy(WmsProductOutstock::getDay)); - for (WmsProductInstock instock : instocks) { - if (map != null&&map.keySet().size()>0) { - WmsProductOutstock wmsProductOutstock = map.get(instock.getDay()).get(0); - instock.setOutStockAmount(wmsProductOutstock.getOutstockQty()); - }else { - instock.setOutStockAmount(new BigDecimal(0)); + Map> instocksMap = instocks.stream().collect(Collectors.groupingBy(WmsProductInstock::getDay)); + Map> outstocksMap = outstocks.stream().collect(Collectors.groupingBy(WmsProductOutstock::getDay)); + Set dateSet = Stream.concat(instocksMap.keySet().stream(), outstocksMap.keySet().stream()) + .collect(Collectors.toCollection(TreeSet::new)); + + List returnInstocks = new ArrayList<>(); + + for (Date date : dateSet) { + WmsProductInstock returnInstock = new WmsProductInstock(); + returnInstock.setDay(date); + if(instocksMap!=null){ + List wmsProductInstocks = instocksMap.get(date); + if(wmsProductInstocks!=null && !wmsProductInstocks.isEmpty()){ + returnInstock.setInstockAmount(wmsProductInstocks.get(0).getInstockAmount()); + } } + + if(outstocksMap!=null){ + List wmsProductOutstocks = outstocksMap.get(date); + if(wmsProductOutstocks!=null && !wmsProductOutstocks.isEmpty()){ + returnInstock.setOutStockAmount(wmsProductOutstocks.get(0).getOutstockQty()); + } + } + returnInstocks.add(returnInstock); } - return instocks; + return returnInstocks; } @Override @@ -81,13 +95,13 @@ public class SecondWmsBoardServiceImpl implements SecondWmsBorderService { @Override public Map locationCount() { - int availibleLocation = wmsProductStockMapper.selectAvailibleLocation(); - int toatlLocation = wmsProductStockMapper.selectTotalLocation(); + int availibleLocation = wmsProductStockMapper.selectAvailibleLocation();//可用库位数量 + int toatlLocation = wmsProductStockMapper.selectTotalLocation();//获取总库位数量 int opplyLocation = wmsProductStockMapper.selectOpplyLocation(); HashMap result = new HashMap<>(); BigDecimal bigDecimal = new BigDecimal(toatlLocation); - BigDecimal availibleRate = new BigDecimal(availibleLocation).divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP); - BigDecimal opplyRate = new BigDecimal(opplyLocation).divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP); + BigDecimal availibleRate = new BigDecimal(availibleLocation).divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP);//可用库位占比 + BigDecimal opplyRate = new BigDecimal(opplyLocation).divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP);//库存占用总库位的占用率 result.put("availibleRate",availibleRate); result.put("opplyRate",opplyRate); return result; diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml index 9253cc98..c1dac69d 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml @@ -307,9 +307,9 @@ select count(1) from - `hwjy-cloud`.wms_base_location + `hwjy-cloud`.wms_base_location wbl where - warehouse_id = 512 and container_code is null + warehouse_id = 512 and not exists (select 1 from wms_raw_stock wrs where wbl.location_code=wrs.location_code)