From ec17584681fe0cdbf47df11ba2d276b3aaa5456b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=89=E7=82=AE?= <15856818120@163.com> Date: Mon, 15 Sep 2025 23:21:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/device/mapper/DevInfoMapper.java | 4 + .../controller/ProvinceScreenController.java | 80 +++++++++++++---- .../service/ProvinceScreenService.java | 14 ++- .../impl/ProvinceScreenServiceImpl.java | 90 ++++++++++++++++++- .../material/ma/mapper/MaTypeMapper.java | 6 +- .../mapper/material/device/DevInfoMapper.xml | 24 +++++ .../material/ma/MaMachineTypeMapper.xml | 17 +++- 7 files changed, 213 insertions(+), 22 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index 9c30d6e..60fb3a8 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -303,5 +303,9 @@ public interface DevInfoMapper { List selectCheckDevInfoList(DevInfoVo devInfo); Integer updateCheckStatus(List list); + + Integer getTotalEquipmentByLevel(DevInfoReq devInfoReq); + + int getTurnoverRateByLevel(DevInfoReq devInfoReq); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/ProvinceScreenController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/ProvinceScreenController.java index a741c96..10a42df 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/ProvinceScreenController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/ProvinceScreenController.java @@ -126,36 +126,80 @@ public class ProvinceScreenController extends BaseController { public AjaxResult getEquipmentUse() { try { List> res = provinceScreenService.getEquipmentUse(); - for (int i = 0; i < 10; i++) { - Map map = new HashMap<>(); - map.put("projectName","石桥-大陇π入万济变、大陇-阳湖T接万济变 35kV架空线路工程"); - map.put("inUser","82"); - map.put("scale","172"); - map.put("usage","47.67"); - res.add(map); - } + Map map = new HashMap<>(); + map.put("projectName","石桥-大陇π入万济变、大陇-阳湖T接万济变 35kV架空线路工程"); + map.put("inUser","82"); + map.put("scale","172"); + map.put("usage","47.67"); + res.add(map); + map.put("projectName","淮南泥河110kV变电站新建工程"); + map.put("inUser","66"); + map.put("scale","170"); + map.put("usage","48.67"); + res.add(map); + map.put("projectName","安徽黄山市徽州区呈坎35kV变电站新建工程"); + map.put("inUser","68"); + map.put("scale","160"); + map.put("usage","49.67"); + res.add(map); + map.put("projectName","凌云220kV变电站新建工程"); + map.put("inUser","65"); + map.put("scale","175"); + map.put("usage","45.67"); + res.add(map); + map.put("projectName","东坡110kV变电站新建工程"); + map.put("inUser","68"); + map.put("scale","174"); + map.put("usage","49.67"); + res.add(map); return AjaxResult.success(res); } catch (Exception e) { return AjaxResult.error("工程在用装备情况异常"); } } + /** + * 装备在用率统计 + * @return + */ @ApiOperation("装备在用率统计") @GetMapping("/getUsageStatistics") - public AjaxResult getUsageStatistics() { + public AjaxResult getUsageStatistics(Integer type) { try { - List> res = provinceScreenService.getUsageStatistics(); - for (int i = 0; i < 10; i++) { - Map map = new HashMap<>(); - map.put("projectName","石桥-大陇π入万济变、大陇-阳湖T接万济变 35kV架空线路工程"); - map.put("inUser","82"); - map.put("scale","172"); - map.put("usage","47.67"); - res.add(map); - } + List> res = provinceScreenService.getUsageStatistics(type); return AjaxResult.success(res); } catch (Exception e) { return AjaxResult.error("装备在用率统计异常"); } } + + /** + * 在库装备数 + * @return + */ + @ApiOperation("在库装备数") + @GetMapping("/getEquipmentNumber") + public AjaxResult getEquipmentNumber() { + try { + List> res = provinceScreenService.getEquipmentNumber(); + return AjaxResult.success(res); + } catch (Exception e) { + return AjaxResult.error("在库装备数异常"); + } + } + + /** + * 机械化率 + * @return + */ + @ApiOperation("机械化率") + @GetMapping("/getMechanizationRate") + public AjaxResult getMechanizationRate() { + try { + List> res = provinceScreenService.getMechanizationRate(); + return AjaxResult.success(res); + } catch (Exception e) { + return AjaxResult.error("在库装备数异常"); + } + } } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/ProvinceScreenService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/ProvinceScreenService.java index 2c5d555..9e79986 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/ProvinceScreenService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/ProvinceScreenService.java @@ -47,5 +47,17 @@ public interface ProvinceScreenService { */ List> getEquipmentUse(); - List> getUsageStatistics(); + /** + * 装备在用率统计 + * @return + */ + List> getUsageStatistics(Integer type); + + /** + * 在库装备数 + * @return + */ + List> getEquipmentNumber(); + + List> getMechanizationRate(); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/impl/ProvinceScreenServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/impl/ProvinceScreenServiceImpl.java index 623db9f..d0b58f7 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/impl/ProvinceScreenServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/service/impl/ProvinceScreenServiceImpl.java @@ -1,6 +1,7 @@ package com.bonus.material.largeScreen.service.impl; import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.core.utils.StringUtils; import com.bonus.material.device.domain.DevInfo; import com.bonus.material.device.mapper.DevInfoMapper; import com.bonus.material.equipment.domain.DeptConfigRateSummary; @@ -9,6 +10,8 @@ import com.bonus.material.equipment.service.ISysDeptService; import com.bonus.material.equipment.service.impl.SysDeptServiceImpl; import com.bonus.material.largeScreen.entity.DevInfoReq; import com.bonus.material.largeScreen.service.ProvinceScreenService; +import com.bonus.material.ma.mapper.MaTypeMapper; +import com.bonus.material.ma.vo.MaType; import com.bonus.system.api.domain.SysDept; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -38,6 +41,9 @@ public class ProvinceScreenServiceImpl implements ProvinceScreenService { @Resource private ISysDeptService sysDeptService; + @Resource + private MaTypeMapper maTypeMapper; + /** * 装备总量,总价值 * @return @@ -282,8 +288,90 @@ public class ProvinceScreenServiceImpl implements ProvinceScreenService { return res; } + /** + * 装备在用率统计 + * @return + */ @Override - public List> getUsageStatistics() { + public List> getUsageStatistics(Integer type) { + + List> res = new ArrayList<>(); + List maTypeList = new ArrayList<>(); + //获取装备在用率 查询全部 + if (StringUtils.isNull(type)){ + maTypeList = maTypeMapper.selectMaTypeTreeBy5Level(type); + }else { + maTypeList = maTypeMapper.selectMaTypeTreeBy5Level2(type); + } + if (maTypeList.size()>0){ + for (MaType maType:maTypeList) { + Map dev = new HashMap<>(); + DevInfoReq devInfoReq = new DevInfoReq(); + devInfoReq.setTypeId(Math.toIntExact(maType.getTypeId())); + //装备总数 + Integer sum = devInfoMapper.getTotalEquipmentByLevel(devInfoReq); + //自用2 + devInfoReq.setChangeStatus("2"); + Integer inUse = devInfoMapper.getTotalEquipmentByLevel(devInfoReq); + devInfoReq.setChangeStatus("3"); + Integer share = devInfoMapper.getTotalEquipmentByLevel(devInfoReq); + inUse = inUse+share; + dev.put("name",maType.getTypeName()); + //在用率 + dev.put("proportion",sum > 0 ? (inUse * 100) / sum : 0+"%"); + //周转率 + int turnoverRate = devInfoMapper.getTurnoverRateByLevel(devInfoReq); + dev.put("turnoverRate",sum > 0 ? (turnoverRate * 100) / sum : 0+"次/年"); + res.add(dev); + } + } + // 【核心排序逻辑】按proportion数值降序排序(高在用率优先) + Collections.sort(res, new Comparator>() { + @Override + public int compare(Map map1, Map map2) { + // 1. 提取两个map中的proportion字符串 + String proportion1 = (String) map1.get("proportion"); + String proportion2 = (String) map2.get("proportion"); + // 2. 处理null值(默认视为0%) + proportion1 = proportion1 == null ? "0%" : proportion1; + proportion2 = proportion2 == null ? "0%" : proportion2; + // 3. 去掉"%"符号,转为Integer数值(核心步骤) + // 注意:若proportion含小数(如"83.5%"),需转为Double,此处按整数处理(适配原代码逻辑) + int propValue1 = Integer.parseInt(proportion1.replace("%", "")); + int propValue2 = Integer.parseInt(proportion2.replace("%", "")); + // 4. 数值降序排序(高在用率在前);升序用:propValue1 - propValue2 + return propValue2 - propValue1; + } + }); + return res; + } + + /** + * 在库装备数 + * @return + */ + @Override + public List> getEquipmentNumber() { + //在库装备数 + List> res = new ArrayList<>(); + SysDept sysDept = new SysDept(); + List sysDeptList = sysDeptMapper.selectDeptList(sysDept); + for (SysDept sysDeptNew:sysDeptList) { + Map dept = new HashMap<>(); + //入库1 + DevInfoReq devInfoReq = new DevInfoReq(); + devInfoReq.setOwnCo(Math.toIntExact(sysDeptNew.getDeptId())); + devInfoReq.setChangeStatus("1"); + Integer inStock = devInfoMapper.getTotalEquipment(devInfoReq); + dept.put("name",sysDeptNew.getDeptName()); + dept.put("num",inStock); + res.add(dept); + } + return res; + } + + @Override + public List> getMechanizationRate() { return null; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/ma/mapper/MaTypeMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/ma/mapper/MaTypeMapper.java index ccad80f..389d59a 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/ma/mapper/MaTypeMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/ma/mapper/MaTypeMapper.java @@ -96,4 +96,8 @@ public interface MaTypeMapper { int insertMaTypePropertyNames(@Param("typeId") Long typeId, @Param("list") List properties); List getList(@Param("typeName") String typeName, @Param("level") Integer level); -} \ No newline at end of file + + List selectMaTypeTreeBy5Level(Integer type); + + List selectMaTypeTreeBy5Level2(Integer type); +} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index af8f001..89f0186 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -1572,4 +1572,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml index b2f9176..22106c2 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml @@ -618,6 +618,21 @@ and m.type_name = #{typeName} + + delete @@ -639,4 +654,4 @@ ) - \ No newline at end of file +