diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/DTO/CityScreenDTO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/DTO/CityScreenDTO.java new file mode 100644 index 0000000..786addf --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/DTO/CityScreenDTO.java @@ -0,0 +1,24 @@ +package com.bonus.material.cityScreen.DTO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class CityScreenDTO { + @ApiModelProperty(value = "公司ID") + private String companyId; + @ApiModelProperty(value = "年限类型") + private Integer year; + @ApiModelProperty(value = "类型ID") + private Integer typeId; + @ApiModelProperty(value = "状态") + private Integer status; + @ApiModelProperty(value = "电压等级") + private Integer voltageLevel; + @ApiModelProperty(value = "城市") + private String city; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/AlarmVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/AlarmVO.java new file mode 100644 index 0000000..5748992 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/AlarmVO.java @@ -0,0 +1,22 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class AlarmVO { + + @ApiModelProperty(value = "工序") + private String procedureName; + + @ApiModelProperty(value = "设备名称") + private String deviceName; + + @ApiModelProperty(value = "情况") + private String situation; + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/BasicTitleVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/BasicTitleVO.java new file mode 100644 index 0000000..4737c06 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/BasicTitleVO.java @@ -0,0 +1,27 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:20 + */ +@Data +public class BasicTitleVO { + + @ApiModelProperty(value = "装备总数") + private String totalCount; + + @ApiModelProperty(value = "装备总价值") + private Integer totalValue; + + @ApiModelProperty(value = "装备配置率") + private String allocationRate; + + @ApiModelProperty(value = "今日入库") + private String enterNum; + + @ApiModelProperty(value = "今日出库") + private String outNum; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/DateVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/DateVO.java new file mode 100644 index 0000000..1f68a96 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/DateVO.java @@ -0,0 +1,23 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class DateVO { + @ApiModelProperty(value = "总数") + private Integer total; + + @ApiModelProperty(value = "在用数") + private Integer useNum; + + @ApiModelProperty(value = "集合") + private List list; + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EchartsVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EchartsVO.java new file mode 100644 index 0000000..b2251c0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EchartsVO.java @@ -0,0 +1,26 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class EchartsVO { + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "数量") + private Integer num; + + @ApiModelProperty(value = "比例") + private String rate; + + public EchartsVO(String name, int num, String rate) { + this.name = name; + this.num = num; + this.rate = rate; + } + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentQuantityVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentQuantityVO.java new file mode 100644 index 0000000..ba654d0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentQuantityVO.java @@ -0,0 +1,44 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class EquipmentQuantityVO { + + @ApiModelProperty(value = "设备数量") + private Integer deviceQuantity; + + @ApiModelProperty(value = "设备类型") + private String deviceType; + + @ApiModelProperty(value = "设备类型ID") + private String deviceTypeId; + + @ApiModelProperty(value = "总价值") + private BigDecimal totalValue; + + @ApiModelProperty("5年个数") + private Integer fiveYearCount; + + @ApiModelProperty(value = "5年占比") + private String fiveYearRatio; + + @ApiModelProperty(value = "5-10年个数") + private Integer fiveToTenYearCount; + + @ApiModelProperty(value = "5-10年占比") + private String fiveToTenYearRatio; + + @ApiModelProperty(value = "10年以上个数") + private Integer aboveTenYearCount; + + @ApiModelProperty(value = "10年以上占比") + private String aboveTenYearRatio; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentTurnoverRateVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentTurnoverRateVO.java new file mode 100644 index 0000000..2d88d43 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentTurnoverRateVO.java @@ -0,0 +1,26 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:20 + */ +@Data +public class EquipmentTurnoverRateVO { + @ApiModelProperty(value = "专业") + private String major; + + @ApiModelProperty(value = "主工序") + private String mainProcess; + + @ApiModelProperty(value = "子工序") + private String subprocess; + + @ApiModelProperty(value = "装备名称") + private String deviceName; + + @ApiModelProperty(value = "装备周转率") + private String turnoverRate; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentUseVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentUseVO.java new file mode 100644 index 0000000..a47ac92 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/EquipmentUseVO.java @@ -0,0 +1,28 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:20 + */ +@Data +public class EquipmentUseVO { + @ApiModelProperty(value = "工程") + private String projectName; + + @ApiModelProperty(value = "在用装备数") + private Integer useNum; + + @ApiModelProperty(value = "投资额") + private Integer investAmount; + + @ApiModelProperty(value = "现场人员") + private Integer scenePersonNum; + + @ApiModelProperty(value = "风险等级") + private Integer riskLevel; + + @ApiModelProperty(value = "地理特征") + private String geoFeature; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/MapVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/MapVO.java new file mode 100644 index 0000000..c3a0321 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/MapVO.java @@ -0,0 +1,25 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class MapVO { + + @ApiModelProperty(value = "仓库装备数") + private Integer warehouseEquipmentNum; + + @ApiModelProperty(value = "市外装备数") + private Integer outCityEquipmentNum; + + @ApiModelProperty(value = "工程集合") + private List proList; + + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/ProVO.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/ProVO.java new file mode 100644 index 0000000..d378bb0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/VO/ProVO.java @@ -0,0 +1,24 @@ +package com.bonus.material.cityScreen.VO; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class ProVO { + @ApiModelProperty(value = "工程名称") + private String projectName; + @ApiModelProperty(value = "在用数量") + private Integer useNum; + @ApiModelProperty(value = "市") + private String city; + @ApiModelProperty(value = "区、县") + private String county; + @ApiModelProperty(value = "经度") + private String lon; + @ApiModelProperty(value = "纬度") + private String lat; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/controller/CityScreenController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/controller/CityScreenController.java new file mode 100644 index 0000000..dd8d928 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/controller/CityScreenController.java @@ -0,0 +1,147 @@ +package com.bonus.material.cityScreen.controller; + +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.cityScreen.DTO.CityScreenDTO; +import com.bonus.material.cityScreen.VO.*; +import com.bonus.material.cityScreen.mapper.CityScreenMapper; +import com.bonus.material.cityScreen.service.CityScreenService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 15:46 + */ + +@Api(value = "地市大屏", tags = {"地市大屏"}) +@RestController +@RequestMapping("/city_screen") +public class CityScreenController extends BaseController { + + @Resource + private CityScreenService cityScreenService; + @Resource + private CityScreenMapper cityScreenMapper; + + @ApiOperation("基础头部数据") + @GetMapping("/getBasicHead") + public AjaxResult getBasicHead(CityScreenDTO dto) { + BasicTitleVO titleVO = cityScreenService.getBasicHead(dto); + return AjaxResult.success(titleVO); + } + + @ApiOperation("装备数量价值") + @GetMapping("/equipmentQuantityValue") + public AjaxResult equipmentQuantityValue(CityScreenDTO dto) { + List list = cityScreenService.equipmentQuantityValue(dto); + return AjaxResult.success(list); + } + + @ApiOperation("装备状态") + @GetMapping("/equipmentStatus") + public AjaxResult equipmentStatus(CityScreenDTO dto) { + List list = cityScreenService.equipmentStatus(dto); + return AjaxResult.success(list); + } + + @ApiOperation("维修报警") + @GetMapping("/maintenanceAlarm") + public AjaxResult maintenanceAlarm(CityScreenDTO dto) { + startPage(); + List list = cityScreenService.maintenanceAlarm(dto); + DateVO dateVO = new DateVO<>(); + dateVO.setList(list); + try { + int total = cityScreenMapper.countMaintenanceAlarm(dto); + dateVO.setTotal(total); + } catch (Exception e) { + throw new ServiceException("获取维修报警数据失败"); + } + return AjaxResult.success(dateVO); + } + + @ApiOperation("退役报警") + @GetMapping("/retirementAlarm") + public AjaxResult retirementAlarm(CityScreenDTO dto) { + startPage(); + List list = cityScreenService.retirementAlarm(dto); + DateVO dateVO = new DateVO<>(); + dateVO.setList(list); + try { + int total = cityScreenMapper.countRetirementAlarm(dto); + dateVO.setTotal(total); + } catch (Exception e) { + throw new ServiceException("获取退役报警数据失败"); + } + return AjaxResult.success(dateVO); + } + + @ApiOperation("装备在用率") + @GetMapping("/equipmentInServiceRate") + public AjaxResult equipmentInServiceRate(CityScreenDTO dto) { + List list = cityScreenService.equipmentInServiceRate(dto); + return AjaxResult.success(list); + } + + @ApiOperation("装备周转率") + @GetMapping("/equipmentTurnoverRate") + public AjaxResult equipmentTurnoverRate(CityScreenDTO dto) { + startPage(); + List list = cityScreenService.equipmentTurnoverRate(dto); + DateVO dateVO = new DateVO<>(); + dateVO.setList(list); + try { + int total = cityScreenMapper.countEquipmentTurnoverRate(dto); + dateVO.setTotal(total); + } catch (Exception e) { + throw new ServiceException("获取装备周转率数据失败"); + } + return AjaxResult.success(dateVO); + } + + @ApiOperation("工程在用装备情况") + @GetMapping("/equipmentInUseInTheProject") + public AjaxResult equipmentInUseInTheProject(CityScreenDTO dto) { + startPage(); + List list = cityScreenService.equipmentInUseInTheProject(dto); + DateVO dateVO = new DateVO<>(); + dateVO.setList(list); + try { + int proNum = cityScreenMapper.countProNum(dto); + int useNum = cityScreenMapper.countUseNum(dto); + dateVO.setTotal(proNum); + dateVO.setUseNum(useNum); + } catch (Exception e) { + throw new ServiceException("获取工程在用装备情况数据失败"); + } + return AjaxResult.success(dateVO); + } + + @ApiOperation("地图数据") + @GetMapping("/mapData") + public AjaxResult mapData(CityScreenDTO dto) { + // 查询工程列表数据 + List list = cityScreenService.proList(dto); + MapVO mapVO = new MapVO(); + mapVO.setProList(list); + try { + //仓库装备数 + int deviceNum = cityScreenMapper.countDeviceNum(dto); + mapVO.setWarehouseEquipmentNum(deviceNum); + //市外装备数 + int outDeviceNum = cityScreenMapper.countOutDeviceNum(dto); + mapVO.setOutCityEquipmentNum(outDeviceNum); + } catch (Exception e) { + throw new ServiceException("获取地图数据失败"); + } + return AjaxResult.success(mapVO); + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/entity/DeviceInfoEntity.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/entity/DeviceInfoEntity.java new file mode 100644 index 0000000..338f763 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/entity/DeviceInfoEntity.java @@ -0,0 +1,22 @@ +package com.bonus.material.cityScreen.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 16:49 + */ +@Data +public class DeviceInfoEntity { + @ApiModelProperty(value = "设备名称") + private String deviceName; + @ApiModelProperty(value = "装备总价值") + private String buyMoney; + @ApiModelProperty(value = "装备总数量") + private String totalNum; + @ApiModelProperty(value = "装备状态") + private String status; + @ApiModelProperty(value = "装备类型ID") + private String typeId; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/mapper/CityScreenMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/mapper/CityScreenMapper.java new file mode 100644 index 0000000..7f61bd0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/mapper/CityScreenMapper.java @@ -0,0 +1,125 @@ +package com.bonus.material.cityScreen.mapper; + +import com.bonus.material.cityScreen.DTO.CityScreenDTO; +import com.bonus.material.cityScreen.VO.*; +import com.bonus.material.cityScreen.entity.DeviceInfoEntity; + +import java.util.List; + +public interface CityScreenMapper { + /** + * 获取设备数据 + * @param dto 入参 + * @return DeviceInfoEntity + */ + BasicTitleVO getDeviceData(CityScreenDTO dto); + + /** + * 获取今日出入库数量 + * @param dto 入参 + * @return BasicTitleVO + */ + BasicTitleVO getTodayDeviceEnterOutNum(CityScreenDTO dto); + + /** + * 装备数量价值 + * @param dto 入参 + * @return EquipmentQuantityVO + */ + EquipmentQuantityVO equipmentQuantityValue(CityScreenDTO dto); + + /** + * 装备状态 + * @return List + */ + List selectTypeIdList(); + + /** + * 获取设备信息 + * @param dto 入参 + * @return List + */ + List getDeviceInfo(CityScreenDTO dto); + + /** + * 维修报警 + * @param dto 入参 + * @return List + */ + List maintenanceAlarm(CityScreenDTO dto); + + /** + * 退役报警 + * @param dto 入参 + * @return List + */ + List retirementAlarm(CityScreenDTO dto); + + /** + * 维修报警总数 + * @param dto 入参 + * @return int + */ + int countMaintenanceAlarm(CityScreenDTO dto); + + /** + * 退役报警总数 + * @param dto 入参 + * @return int + */ + int countRetirementAlarm(CityScreenDTO dto); + /** + * 装备周转率总数 + * @param dto 入参 + * @return List + */ + int countEquipmentTurnoverRate(CityScreenDTO dto); + /** + * 装备周转率 + * @param dto 入参 + * @return List + */ + List equipmentTurnoverRate(CityScreenDTO dto); + + /** + * 工程在用装备情况 + * @param dto 入参 + * @return List + */ + List equipmentInUseInTheProject(CityScreenDTO dto); + + /** + * 工程数 + * @param dto 入参 + * @return int + */ + int countProNum(CityScreenDTO dto); + + /** + * 装备在用数量 + * @param dto 入参 + * @return int + */ + int countUseNum(CityScreenDTO dto); + + /** + * 获取工程列表 + * @param dto 入参 + * @return List + */ + List proList(CityScreenDTO dto); + + /** + * 统计仓库装备数 + * @param dto 入参 + * @return int + */ + int countDeviceNum(CityScreenDTO dto); + + /** + * 统计市外装备数 + * @param dto 入参 + * @return int + */ + int countOutDeviceNum(CityScreenDTO dto); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/service/CityScreenService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/service/CityScreenService.java new file mode 100644 index 0000000..f732263 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/service/CityScreenService.java @@ -0,0 +1,73 @@ +package com.bonus.material.cityScreen.service; + +import com.bonus.material.cityScreen.DTO.CityScreenDTO; +import com.bonus.material.cityScreen.VO.*; + +import java.util.List; +/** + * @Author:tqzhang + * @Date:2025/9/14 - 15:47 + */ +public interface CityScreenService { + /** + * 基础头部数据 + * @param dto 入参 + * @return List + */ + BasicTitleVO getBasicHead(CityScreenDTO dto); + /** + * 装备数量价值 + * @param dto 入参 + * @return List + */ + List equipmentQuantityValue(CityScreenDTO dto); + + /** + * 装备状态 + * @param dto 入参 + * @return List + */ + List equipmentStatus(CityScreenDTO dto); + + /** + * 维修报警 + * @param dto 入参 + * @return List + */ + List maintenanceAlarm(CityScreenDTO dto); + + /** + * 退役报警 + * @param dto 入参 + * @return List + */ + List retirementAlarm(CityScreenDTO dto); + + /** + * 装备在役率 + * @param dto 入参 + * @return List + */ + List equipmentInServiceRate(CityScreenDTO dto); + + /** + * 装备周转率 + * @param dto 入参 + * @return List + */ + List equipmentTurnoverRate(CityScreenDTO dto); + + /** + * 工程在用装备情况 + * @param dto 入参 + * @return List + */ + List equipmentInUseInTheProject(CityScreenDTO dto); + + /** + * 工程列表 + * @param dto 入参 + * @return List + */ + List proList(CityScreenDTO dto); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/service/CityScreenServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/service/CityScreenServiceImpl.java new file mode 100644 index 0000000..bde3fa3 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/cityScreen/service/CityScreenServiceImpl.java @@ -0,0 +1,262 @@ +package com.bonus.material.cityScreen.service; + +import com.bonus.common.core.exception.ServiceException; +import com.bonus.material.cityScreen.DTO.CityScreenDTO; +import com.bonus.material.cityScreen.VO.*; +import com.bonus.material.cityScreen.entity.DeviceInfoEntity; +import com.bonus.material.cityScreen.mapper.CityScreenMapper; +import com.bonus.material.equipment.domain.DeptConfigRateSummary; +import com.bonus.material.equipment.service.ISysDeptService; +import org.hibernate.validator.internal.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author:tqzhang + * @Date:2025/9/14 - 15:47 + */ +@Service +public class CityScreenServiceImpl implements CityScreenService { + private static final Logger logger = LoggerFactory.getLogger(CityScreenServiceImpl.class); + @Resource + private CityScreenMapper cityScreenMapper; + @Resource + private ISysDeptService sysDeptService; + + /** + * 基础头部数据 + * + * @param dto 入参 + * @return List + */ + @Override + public BasicTitleVO getBasicHead(CityScreenDTO dto) { + try { + if (StringHelper.isNullOrEmptyString(dto.getCompanyId())) { + throw new ServiceException("公司不能为空"); + } + String companyId = dto.getCompanyId(); + //根据公司ID查询设备总数、总价值 + BasicTitleVO titleVO = cityScreenMapper.getDeviceData(dto); + if (titleVO == null) { + throw new ServiceException("未查询到相关数据"); + } + // 获取装备转换率 + DeptConfigRateSummary user = new DeptConfigRateSummary(); + List list = sysDeptService.selectDeptConfigRatePivot(user); + list.forEach(item -> { + String deptId = String.valueOf(item.getCompanyId()); + if (deptId != null && deptId.equals(companyId)) { + titleVO.setAllocationRate(StringHelper.isNullOrEmptyString(String.valueOf(item.getConfigRate())) ? "0" : String.valueOf(item.getConfigRate())); + } + }); + if (titleVO.getAllocationRate().trim().isEmpty() || "null".equals(titleVO.getAllocationRate())) { + titleVO.setAllocationRate("0"); + } + //查询今日出入库设备数 + BasicTitleVO todayTitleVO = cityScreenMapper.getTodayDeviceEnterOutNum(dto); + if (todayTitleVO != null) { + titleVO.setEnterNum(todayTitleVO.getEnterNum()); + titleVO.setOutNum(todayTitleVO.getOutNum()); + } + return titleVO; + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取数据失败"); + } + } + + /** + * 装备数量价值 + * + * @param dto 入参 + * @return List + */ + @Override + public List equipmentQuantityValue(CityScreenDTO dto) { + try { + List list = new ArrayList<>(); + List typeIds = cityScreenMapper.selectTypeIdList(); + for (int typeId : typeIds) { + EquipmentQuantityVO vo = new EquipmentQuantityVO(); + dto.setTypeId(typeId + 1); + dto.setYear(1); + EquipmentQuantityVO fiveVO = cityScreenMapper.equipmentQuantityValue(dto); + dto.setYear(2); + EquipmentQuantityVO fiveToTenVO = cityScreenMapper.equipmentQuantityValue(dto); + dto.setYear(3); + EquipmentQuantityVO aboveTenVO = cityScreenMapper.equipmentQuantityValue(dto); + vo.setDeviceQuantity(fiveVO.getDeviceQuantity() + fiveToTenVO.getDeviceQuantity() + aboveTenVO.getDeviceQuantity()); + vo.setTotalValue(fiveVO.getTotalValue().add(fiveToTenVO.getTotalValue()).add(aboveTenVO.getTotalValue())); + vo.setDeviceType(String.valueOf(typeId)); + vo.setFiveYearCount(fiveVO.getDeviceQuantity()); + vo.setFiveToTenYearCount(fiveToTenVO.getDeviceQuantity()); + vo.setAboveTenYearCount(aboveTenVO.getDeviceQuantity()); + vo.setFiveYearRatio(vo.getTotalValue().compareTo(BigDecimal.ZERO) == 0 ? "0" : String.format("%.2f", (fiveVO.getTotalValue().divide(vo.getTotalValue(), 2, BigDecimal.ROUND_HALF_UP)).multiply(BigDecimal.valueOf(100)))); + vo.setFiveYearRatio(vo.getTotalValue().compareTo(BigDecimal.ZERO) == 0 ? "0" : String.format("%.2f", (fiveToTenVO.getTotalValue().divide(vo.getTotalValue(), 2, BigDecimal.ROUND_HALF_UP)).multiply(BigDecimal.valueOf(100)))); + vo.setFiveYearRatio(vo.getTotalValue().compareTo(BigDecimal.ZERO) == 0 ? "0" : String.format("%.2f", (aboveTenVO.getTotalValue().divide(vo.getTotalValue(), 2, BigDecimal.ROUND_HALF_UP)).multiply(BigDecimal.valueOf(100)))); + list.add(vo); + } + return list; + + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取装备数量价值数据失败"); + } + } + + /** + * 装备状态 + * + * @param dto 入参 + * @return List + */ + @Override + public List equipmentStatus(CityScreenDTO dto) { + try { + dto.setStatus(9); + List list = cityScreenMapper.getDeviceInfo(dto); + List resultList = new ArrayList<>(); + List usingList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getStatus()) && item.getStatus().equals("1")).collect(Collectors.toList()); + List inTheLibraryList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getStatus()) && (item.getStatus().equals("2") || item.getStatus().equals("3"))).collect(Collectors.toList()); + List repairAgainList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getStatus()) && item.getStatus().equals("5")).collect(Collectors.toList()); + List sharingList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getStatus()) && item.getStatus().equals("3")).collect(Collectors.toList()); + + double totalSize = usingList.size() + inTheLibraryList.size() + repairAgainList.size(); + resultList.add(new EchartsVO("在用", usingList.size(), totalSize == 0 ? "0.00" : String.format("%.2f", (usingList.size() / totalSize) * 100))); + resultList.add(new EchartsVO("在库", inTheLibraryList.size(), totalSize == 0 ? "0.00" : String.format("%.2f", (inTheLibraryList.size() / totalSize) * 100))); + resultList.add(new EchartsVO("在修", repairAgainList.size(), totalSize == 0 ? "0.00" : String.format("%.2f", (repairAgainList.size() / totalSize) * 100))); + resultList.add(new EchartsVO("共享", sharingList.size(), "0.00")); + return resultList; + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取装备状态数据失败"); + } + } + + /** + * 维修报警 + * + * @param dto 入参 + * @return List + */ + @Override + public List maintenanceAlarm(CityScreenDTO dto) { + try { + return cityScreenMapper.maintenanceAlarm(dto); + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取维修报警数据失败"); + } + } + + /** + * 退役报警 + * + * @param dto 入参 + * @return List + */ + @Override + public List retirementAlarm(CityScreenDTO dto) { + try { + return cityScreenMapper.retirementAlarm(dto); + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取退役报警数据失败"); + } + } + + /** + * 装备在役率 + * + * @param dto 入参 + * @return List + */ + @Override + public List equipmentInServiceRate(CityScreenDTO dto) { + try { + dto.setStatus(9); + List list = cityScreenMapper.getDeviceInfo(dto); + List resultList = new ArrayList<>(); + //每种设备数量 + List powerList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getTypeId()) && item.getTypeId().equals("1")).collect(Collectors.toList()); + List lineList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getTypeId()) && item.getTypeId().equals("2")).collect(Collectors.toList()); + List cableList = list.stream().filter(item -> !StringHelper.isNullOrEmptyString(item.getTypeId()) && item.getTypeId().equals("3")).collect(Collectors.toList()); + + int powerNum = calculateInUseCount(powerList); + int lineNum = calculateInUseCount(lineList); + int cableNum = calculateInUseCount(cableList); + + double totalSize = powerList.size() + lineList.size() + cableList.size(); + double useSize = powerNum + lineNum + cableNum; + System.out.println("totalSize:" + totalSize + ",useSize:" + useSize); + resultList.add(new EchartsVO("变电装备在用率", powerNum, calculatePercentage(powerNum, powerList.size()))); + resultList.add(new EchartsVO("线路装备在用率", lineNum, calculatePercentage(lineNum, lineList.size()))); + resultList.add(new EchartsVO("电缆装备在用率", cableNum, calculatePercentage(cableNum, cableList.size()))); + resultList.add(new EchartsVO("总体在用率", (int) useSize, calculatePercentage(useSize / 3, totalSize / 3))); + return resultList; + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取装备在役率数据失败"); + } + } + + private int calculateInUseCount(List list) { + return (int) list.stream() + .filter(item -> item.getStatus().equals("2") || item.getStatus().equals("3")) + .count(); + } + + private String calculatePercentage(double part, double total) { + return total == 0 ? "0.00" : String.format("%.2f", (part / total) * 100); + } + + /** + * 装备周转率 + * + * @param dto 入参 + * @return List + */ + @Override + public List equipmentTurnoverRate(CityScreenDTO dto) { + try { + return cityScreenMapper.equipmentTurnoverRate(dto); + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取装备周转率数据失败"); + } + } + + /** + * 工程在用装备情况 + * + * @param dto 入参 + * @return List + */ + @Override + public List equipmentInUseInTheProject(CityScreenDTO dto) { + try { + return cityScreenMapper.equipmentInUseInTheProject(dto); + } catch (Exception e) { + logger.error(e.getMessage()); + throw new ServiceException("获取工程在用装备情况数据失败"); + } + } + + @Override + public List proList(CityScreenDTO dto) { + List list = cityScreenMapper.proList(dto); + //根据county进行分组 取每组下面useNum最大的那组数据 组成新的集合 + return list.stream().collect(Collectors.groupingBy(ProVO::getCounty)).values().stream() + .map(list1 -> list1.stream().max(Comparator.comparing(ProVO::getUseNum)) + .orElse(null)).collect(Collectors.toList()); + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/cityScreen/CityScreenMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/cityScreen/CityScreenMapper.xml new file mode 100644 index 0000000..00faa89 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/cityScreen/CityScreenMapper.xml @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file