diff --git a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/CompanyDashboardController.java b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/CompanyDashboardController.java index 6b9399d..e214e94 100644 --- a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/CompanyDashboardController.java +++ b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/CompanyDashboardController.java @@ -2,6 +2,7 @@ package com.inspur.web.controller.bigscreen; import com.inspur.bigscreen.service.ICompanyDashboardService; import com.inspur.common.core.domain.AjaxResult; +import com.inspur.system.service.ISysRegionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -20,6 +21,9 @@ public class CompanyDashboardController { @Autowired private ICompanyDashboardService factoryDashboardService; + @Autowired + private ISysRegionService sysRegionService; + @GetMapping("/countEquipNumByCompany/{deptId}") public AjaxResult countEquipNumByCompany(@PathVariable Long deptId) { return AjaxResult.success(factoryDashboardService.countEquipNumByStatus(deptId)); @@ -75,4 +79,14 @@ public class CompanyDashboardController { public AjaxResult companyDeptTree() { return AjaxResult.success(factoryDashboardService.selectCompanyDeptTreeList()); } + + @GetMapping("/regionByCompany/{deptId}") + public AjaxResult regionByCompany(@PathVariable Long deptId) { + return AjaxResult.success(sysRegionService.selectSysRegionByDeptId(deptId)); + } + + @GetMapping("/getCompanyMapData/{regionId}") + public AjaxResult getCompanyMapData(@PathVariable Long regionId) { + return AjaxResult.success(factoryDashboardService.getCompanyMapData(regionId)); + } } diff --git a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/OverallDashboardController.java b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/OverallDashboardController.java index acf0a4d..d7bb4a1 100644 --- a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/OverallDashboardController.java +++ b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/bigscreen/OverallDashboardController.java @@ -4,6 +4,7 @@ import com.inspur.bigscreen.service.IOverallDashboardService; import com.inspur.common.core.domain.AjaxResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -52,4 +53,19 @@ public class OverallDashboardController { public AjaxResult countCompanyDetails() { return AjaxResult.success(overallDashboardService.countCompanyDetails()); } + + @GetMapping("/listLatestAlarmRecord") + public AjaxResult listLatestAlarmRecord() { + return AjaxResult.success(overallDashboardService.selectLatestIpcAlarmRecord()); + } + + @GetMapping("/countCompanyEquipNumByProvince") + public AjaxResult countCompanyEquipNumByProvince() { + return AjaxResult.success(overallDashboardService.countCompanyEquipNumByProvince()); + } + + @GetMapping("/countCompanyEquipNumByCity/{provinceName}") + public AjaxResult countCompanyEquipNumByCity(@PathVariable String provinceName) { + return AjaxResult.success(overallDashboardService.countEquipNumByCity(provinceName)); + } } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/FactoryDashboardDTO.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/FactoryDashboardDTO.java index e67f18b..c8b88b9 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/FactoryDashboardDTO.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/FactoryDashboardDTO.java @@ -22,6 +22,10 @@ public class FactoryDashboardDTO { private String time; + private Integer alarmNum; + + private Integer deptNum; + private List x; private List y; diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/OverallDashboardDTO.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/OverallDashboardDTO.java index a60a16a..ddd7df3 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/OverallDashboardDTO.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/dto/OverallDashboardDTO.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import org.apache.ibatis.annotations.ConstructorArgs; import java.util.List; +import java.util.Map; /** * @Author zhangjunwen @@ -37,10 +38,24 @@ public class OverallDashboardDTO { private Integer alarmNum; + private String rate; + + private Integer total; + + private Long regionId; + + private String regionName; + + private Long provinceId; + + private Map params; + public OverallDashboardDTO() {} - public OverallDashboardDTO(Integer status, Integer data) { + public OverallDashboardDTO(Integer status, Integer data, String rate, Integer total) { this.status = status; this.data = data; + this.rate = rate; + this.total = total; } } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/mapper/OverallDashboardMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/mapper/OverallDashboardMapper.java index 58d7720..09c6824 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/mapper/OverallDashboardMapper.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/mapper/OverallDashboardMapper.java @@ -2,6 +2,8 @@ package com.inspur.bigscreen.mapper; import com.inspur.bigscreen.dto.OverallDashboardDTO; +import java.util.List; + /** * @Author zhangjunwen * @create 2024/7/17 @@ -17,4 +19,14 @@ public interface OverallDashboardMapper { * 根据公司id统计维修单数量 */ public OverallDashboardDTO countMaintenanceNum(Long deptId); + + /** + * 统计各个regionid的设备数量 + */ + public List countEquipNumByRegionId(); + + /** + * 根据省名统计该省各个市的设备数量 + */ + public List countEquipNumByCity(String provinceName); } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/ICompanyDashboardService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/ICompanyDashboardService.java index 79f35cb..f426323 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/ICompanyDashboardService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/ICompanyDashboardService.java @@ -70,4 +70,9 @@ public interface ICompanyDashboardService { * 获取公司部门列表 */ public List selectCompanyDeptTreeList(); + + /** + * 获取公司地图数据 + */ + public List getCompanyMapData(Long regionId); } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/IOverallDashboardService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/IOverallDashboardService.java index 194c0b7..14df24d 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/IOverallDashboardService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/IOverallDashboardService.java @@ -1,6 +1,7 @@ package com.inspur.bigscreen.service; import com.inspur.bigscreen.dto.OverallDashboardDTO; +import com.inspur.industrial.domain.IpcAlarmRecord; import java.util.List; @@ -44,4 +45,19 @@ public interface IOverallDashboardService { * 查询各个企业相关展示信息,产线数、设备数,告警数量 */ public List countCompanyDetails(); + + /** + * 查询包含公司名称的最新的报警信息 + */ + public List selectLatestIpcAlarmRecord(); + + /** + * 根据省来统计省的设备数量 + */ + public List countCompanyEquipNumByProvince(); + + /** + * 根据省名统计该省各个市的设备数量 + */ + public List countEquipNumByCity(String provinceName); } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/CompanyDashboardServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/CompanyDashboardServiceImpl.java index 51115bc..8124f81 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/CompanyDashboardServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/CompanyDashboardServiceImpl.java @@ -2,6 +2,7 @@ package com.inspur.bigscreen.service.impl; import com.inspur.bigscreen.constant.EquipInfoStatus; import com.inspur.bigscreen.dto.CompanyDashboardDTO; +import com.inspur.bigscreen.dto.FactoryDashboardDTO; import com.inspur.bigscreen.mapper.CompanyDashboardMapper; import com.inspur.bigscreen.service.ICompanyDashboardService; import com.inspur.common.core.domain.TreeSelect; @@ -228,6 +229,26 @@ public class CompanyDashboardServiceImpl implements ICompanyDashboardService { return sysDeptService.buildDeptTreeSelect(companyDepts); } + /** + * 获取公司地图数据 + */ + public List getCompanyMapData(Long regionId){ + List resultList = new ArrayList<>(); + List deptList = sysDeptService.selectDeptByRegionId(regionId); + if(deptList.size() == 0){ + return resultList; + } + for (SysDept sysDept : deptList) { + FactoryDashboardDTO data = new FactoryDashboardDTO(); + data.setDeptId(sysDept.getDeptId()); + data.setDeptName(sysDept.getDeptName()); + data.setAlarmNum(ipcAlarmRecordService.countAllAlarmNumByDeptId(sysDept.getDeptId())); + data.setDeptNum(sysDeptService.countChildrenDeptById(sysDept.getDeptId())); + resultList.add(data); + } + return resultList; + } + /** * 通过公司id获取厂区部门信息 */ diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/OverallDashboardServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/OverallDashboardServiceImpl.java index 2fc8f1c..19122d6 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/OverallDashboardServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/bigscreen/service/impl/OverallDashboardServiceImpl.java @@ -9,7 +9,11 @@ import com.inspur.bigscreen.mapper.OverallDashboardMapper; import com.inspur.bigscreen.service.ICompanyDashboardService; import com.inspur.bigscreen.service.IOverallDashboardService; import com.inspur.common.core.domain.entity.SysDept; +import com.inspur.industrial.domain.IpcAlarmRecord; +import com.inspur.industrial.service.IIpcAlarmRecordService; +import com.inspur.system.domain.SysRegion; import com.inspur.system.mapper.SysDeptMapper; +import com.inspur.system.service.ISysRegionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -37,6 +41,11 @@ public class OverallDashboardServiceImpl implements IOverallDashboardService { @Autowired private CompanyDashboardMapper companyDashboardMapper; + @Autowired + private IIpcAlarmRecordService ipcAlarmRecordService; + + @Autowired + private ISysRegionService sysRegionService; /** * 查询各个公司的设备(轴承)数量 */ @@ -75,12 +84,24 @@ public class OverallDashboardServiceImpl implements IOverallDashboardService { public List countMaintenanceNum(){ List companyDepts = getCompanyDept(); List resultList = new ArrayList<>(); + int sum = 0; + int companyNum = 0; for (SysDept companyDept : companyDepts) { OverallDashboardDTO data = overallDashboardMapper.countMaintenanceNum(companyDept.getDeptId()); data.setDeptId(companyDept.getDeptId()); data.setDeptName(companyDept.getDeptName()); + sum += data.getData(); resultList.add(data); } + if(resultList.size() == 0){ + return null; + }else{ + int finalSum = sum; + resultList.forEach(item -> { + item.setRate(finalSum != 0 ? item.getData() * 100 / finalSum + "%" : "0%"); + item.setTotal(finalSum); + }); + } return resultList; } @@ -109,11 +130,15 @@ public class OverallDashboardServiceImpl implements IOverallDashboardService { long paperNum = companyDepts.stream().filter(dept -> dept.getIndustryCode().equals(DeptIndustryCode.PAPER)).count(); long alchemyNum = companyDepts.stream().filter(dept -> dept.getIndustryCode().equals(DeptIndustryCode.ALCHEMY)).count(); long otherNum = companyDepts.stream().filter(dept -> dept.getIndustryCode().equals(DeptIndustryCode.OTHER)).count(); + long totalNum = paperNum + alchemyNum + otherNum; + String paperRate = totalNum != 0L ? paperNum * 100 / totalNum + "%" : "0%"; + String alchemyRate = totalNum != 0L ? alchemyNum * 100 / totalNum + "%" : "0%"; + String otherRate = totalNum != 0L ? otherNum * 100 / totalNum + "%" : "0%"; return Arrays.asList( - new OverallDashboardDTO(Integer.valueOf(DeptIndustryCode.PAPER),(int)paperNum), - new OverallDashboardDTO(Integer.valueOf(DeptIndustryCode.ALCHEMY),(int)alchemyNum), - new OverallDashboardDTO(Integer.valueOf(DeptIndustryCode.OTHER),(int)otherNum) + new OverallDashboardDTO(Integer.valueOf(DeptIndustryCode.PAPER),(int)paperNum,paperRate,(int) totalNum), + new OverallDashboardDTO(Integer.valueOf(DeptIndustryCode.ALCHEMY),(int)alchemyNum,alchemyRate,(int) totalNum), + new OverallDashboardDTO(Integer.valueOf(DeptIndustryCode.OTHER),(int)otherNum,otherRate,(int) totalNum) ); } @@ -159,6 +184,44 @@ public class OverallDashboardServiceImpl implements IOverallDashboardService { return resultList; } + /** + * 查询包含公司名称的最新的报警信息 + */ + public List selectLatestIpcAlarmRecord(){ + return ipcAlarmRecordService.selectLatestIpcAlarmRecord(); + } + + /** + * 根据省来统计省的设备数量 + */ + public List countCompanyEquipNumByProvince(){ + List resultList = new ArrayList<>(); + List cityEqpNumList = overallDashboardMapper.countEquipNumByRegionId(); + if(cityEqpNumList.size() == 0){ + return null; + } + List provinceIdList = cityEqpNumList.stream().map(OverallDashboardDTO::getProvinceId).distinct().collect(Collectors.toList()); + Map sumMap = cityEqpNumList.stream() + .collect(Collectors.groupingBy(OverallDashboardDTO::getProvinceId, Collectors.summingInt(OverallDashboardDTO::getData))); + for (Long providerId : provinceIdList) { + OverallDashboardDTO data = new OverallDashboardDTO(); + SysRegion region = sysRegionService.selectSysRegionById(providerId); + data.setDeptName(region.getName()); + data.setData(sumMap.get(providerId)); + data.setProvinceId(providerId); + + resultList.add(data); + } + return resultList; + } + + /** + * 根据省名统计该省各个市的设备数量 + */ + public List countEquipNumByCity(String provinceName){ + return overallDashboardMapper.countEquipNumByCity(provinceName); + } + /** * 查询系统重公司部门 */ diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java index ff8d9b0..5d509ef 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java @@ -2,6 +2,8 @@ package com.inspur.industrial.domain; import java.math.BigDecimal; import java.util.Date; +import java.util.Map; + import com.fasterxml.jackson.annotation.JsonFormat; import com.inspur.common.annotation.Excel; import com.inspur.common.core.domain.BaseEntity; @@ -76,6 +78,8 @@ public class IpcAlarmRecord extends BaseEntity private IpcAlarmRules alarmRules; + private Map params; + public void setId(Long id) { this.id = id; @@ -207,6 +211,16 @@ public class IpcAlarmRecord extends BaseEntity this.ids = ids; } + @Override + public Map getParams() { + return params; + } + + @Override + public void setParams(Map params) { + this.params = params; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java index bb0aa81..4d67964 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java @@ -2,6 +2,7 @@ package com.inspur.industrial.mapper; import java.util.List; +import com.inspur.bigscreen.dto.OverallDashboardDTO; import com.inspur.common.annotation.DataSource; import com.inspur.common.enums.DataSourceType; import com.inspur.industrial.domain.IpcAlarmRecord; @@ -38,6 +39,16 @@ public interface IpcAlarmRecordMapper */ public List selectLatestIpcAlarmRecordByFactoryId(Long deptId); + /** + * 查询全局看板最新的报警记录 + */ + public List selectLatestIpcAlarmRecord(); + + /** + * 根据部门id统计报警记录条数 + */ + public int countAllAlarmNumByDeptId(Long deptId); + /** * 新增报警记录 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java index a528e8d..859dba8 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java @@ -34,6 +34,16 @@ public interface IIpcAlarmRecordService */ public List selectLatestIpcAlarmRecordByFactoryId(Long deptId); + /** + * 查询全局最新报警记录(包含公司名称) + */ + public List selectLatestIpcAlarmRecord(); + + /** + * 根据部门id统计报警记录条数 + */ + public int countAllAlarmNumByDeptId(Long deptId); + /** * 新增报警记录 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java index 82dace4..ac09906 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java @@ -1,11 +1,16 @@ package com.inspur.industrial.service.impl; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import com.inspur.common.core.domain.entity.SysDept; import com.inspur.common.utils.SecurityUtils; import com.inspur.industrial.vo.AlarmCountVO; +import com.inspur.system.service.ISysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.industrial.mapper.IpcAlarmRecordMapper; @@ -24,6 +29,9 @@ public class IpcAlarmRecordServiceImpl implements IIpcAlarmRecordService @Autowired private IpcAlarmRecordMapper ipcAlarmRecordMapper; + @Autowired + private ISysDeptService sysDeptService; + /** * 查询报警记录 * @@ -55,6 +63,36 @@ public class IpcAlarmRecordServiceImpl implements IIpcAlarmRecordService return ipcAlarmRecordMapper.selectLatestIpcAlarmRecordByFactoryId(deptId); } + /** + * 查询全局最新报警记录(包含公司名称) + */ + public List selectLatestIpcAlarmRecord(){ + List recordList = new ArrayList<>(); + List ipcAlarmRecordList = ipcAlarmRecordMapper.selectLatestIpcAlarmRecord(); + for (IpcAlarmRecord ipcAlarmRecord : ipcAlarmRecordList) { + Map params = new HashMap<>(); + Long parentDeptId = ipcAlarmRecord.getEquipInfo().getDeptId(); + SysDept parentDept = sysDeptService.selectDeptById(parentDeptId); + String[] ancestors = parentDept.getAncestors().split(","); + if(ancestors.length >= 3) { + SysDept companyDept = sysDeptService.selectDeptById(Long.parseLong(parentDept.getAncestors().split(",")[2])); + params.put("companyName", companyDept.getDeptName()); + }else if (ancestors.length == 2) { + params.put("companyName", parentDept.getDeptName()); + } + ipcAlarmRecord.setParams(params); + recordList.add(ipcAlarmRecord); + } + return recordList; + } + + /** + * 根据部门id统计报警记录条数 + */ + public int countAllAlarmNumByDeptId(Long deptId){ + return ipcAlarmRecordMapper.countAllAlarmNumByDeptId(deptId); + } + /** * 新增报警记录 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysDeptMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysDeptMapper.java index aa16af9..1c0aed6 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysDeptMapper.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysDeptMapper.java @@ -49,6 +49,16 @@ public interface SysDeptMapper */ public List selectChildrenDeptById(Long deptId); + /** + * 根据id统计子部门数量 + */ + public int countChildrenDeptById(Long deptId); + + /** + * 根据regionId获取区域内的部门 + */ + public List selectDeptByRegionId(Long regionId); + /** * 根据ID查询所有子部门(正常状态) * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java index 4884f5f..70eebed 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/mapper/SysRegionMapper.java @@ -27,6 +27,11 @@ public interface SysRegionMapper */ public List selectSysRegionList(SysRegion sysRegion); + /** + * 通过部门id查询部门的行政区信息 + */ + public List selectSysRegionByDeptId(Long deptId); + /** * 新增行政区划 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysDeptService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysDeptService.java index 95b5e1d..88af54b 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysDeptService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysDeptService.java @@ -64,6 +64,17 @@ public interface ISysDeptService */ public SysDept selectDeptById(Long deptId); + /** + * 根据部门ID统计子部门数量 + */ + public int countChildrenDeptById(Long deptId); + + /** + * 根据省的id查询厂区部门信息 + */ + public List selectDeptByRegionId(Long regionId); + + /** * 根据ID查询所有子部门(正常状态) * @@ -72,6 +83,7 @@ public interface ISysDeptService */ public int selectNormalChildrenDeptById(Long deptId); + /** * 是否存在部门子节点 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java index 2ce4bfe..edbdd2e 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/ISysRegionService.java @@ -27,6 +27,11 @@ public interface ISysRegionService */ public List selectSysRegionList(SysRegion sysRegion); + /** + * 查询deptId及其子部门所在省的区域信息 + */ + public List selectSysRegionByDeptId(Long deptId); + /** * 新增行政区划 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysDeptServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysDeptServiceImpl.java index fb0607e..d13b00e 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysDeptServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysDeptServiceImpl.java @@ -4,6 +4,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; + +import com.inspur.system.domain.SysRegion; +import com.inspur.system.mapper.SysRegionMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.common.annotation.DataScope; @@ -35,6 +38,9 @@ public class SysDeptServiceImpl implements ISysDeptService @Autowired private SysRoleMapper roleMapper; + @Autowired + private SysRegionMapper regionMapper; + /** * 查询部门管理数据 * @@ -138,6 +144,21 @@ public class SysDeptServiceImpl implements ISysDeptService return deptMapper.selectDeptById(deptId); } + /** + * 根据部门ID统计子部门数量 + */ + public int countChildrenDeptById(Long deptId){ + return deptMapper.countChildrenDeptById(deptId); + } + + /** + * 根据省的id查询厂区部门信息 + */ + public List selectDeptByRegionId(Long regionId){ + List deptList = deptMapper.selectDeptByRegionId(regionId); + return deptList.size() == 0 ? null : deptList.stream().filter(dept -> dept.getAncestors().split(",").length == 3).collect(Collectors.toList()); + } + /** * 根据ID查询所有子部门(正常状态) * @@ -150,6 +171,7 @@ public class SysDeptServiceImpl implements ISysDeptService return deptMapper.selectNormalChildrenDeptById(deptId); } + /** * 是否存在子节点 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java index a8ba5d4..c316599 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java @@ -1,5 +1,6 @@ package com.inspur.system.service.impl; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -43,6 +44,26 @@ public class SysRegionServiceImpl implements ISysRegionService return sysRegionMapper.selectSysRegionList(sysRegion); } + /** + * 查询deptId及其子部门所在省的区域信息 + */ + @Override + public List selectSysRegionByDeptId(Long deptId){ + List resultList = new ArrayList<>(); + List sysRegionList = sysRegionMapper.selectSysRegionByDeptId(deptId); + if(sysRegionList != null) { + for (SysRegion sysRegion : sysRegionList) { + if (sysRegion.getParentId() != 0L) { + sysRegion = sysRegionMapper.selectSysRegionById(sysRegion.getParentId()); + resultList.add(sysRegion); + } else { + resultList.add(sysRegion); + } + } + } + return resultList; + } + /** * 新增行政区划 * diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/bigscreen/OverallDashboardMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/bigscreen/OverallDashboardMapper.xml index 4e15dca..4a2635b 100644 --- a/zfipc-server/zfipc-system/src/main/resources/mapper/bigscreen/OverallDashboardMapper.xml +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/bigscreen/OverallDashboardMapper.xml @@ -6,6 +6,9 @@ + + + @@ -43,4 +46,43 @@ where dept_id in (select dept_id from sys_dept where FIND_IN_SET(#{deptId}, ancestors) or dept_id = #{deptId}) + + + + + + \ No newline at end of file diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml index 1e20f8f..0acdb9f 100644 --- a/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml @@ -28,6 +28,7 @@ + @@ -111,6 +112,29 @@ limit 5 + + + + + + insert into ipc_alarm_record diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml index c0ae853..a6f7b17 100644 --- a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -93,6 +93,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select * from sys_dept where find_in_set(#{deptId}, ancestors) + + + + + + diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml index 836e83b..8ba2ba8 100644 --- a/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/system/SysRegionMapper.xml @@ -32,7 +32,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + + + insert into sys_region diff --git a/zfipc-ui/src/api/bigscreen/company.js b/zfipc-ui/src/api/bigscreen/company.js index 0640a00..fc2ceee 100644 --- a/zfipc-ui/src/api/bigscreen/company.js +++ b/zfipc-ui/src/api/bigscreen/company.js @@ -87,3 +87,19 @@ export function getCompanyDeptTree() { method: "get", }); } + +// 通过公司id查询厂区所在省信息 +export function getRegionByCompany(deptId) { + return request({ + url: "/bigscreen/company/regionByCompany/" + deptId, + method: "get", + }); +} + +//根据区域id获取地图数据 +export function getCompanyMapData(regionId) { + return request({ + url: "/bigscreen/company/getCompanyMapData/" + regionId, + method: "get", + }); +} diff --git a/zfipc-ui/src/api/bigscreen/overall.js b/zfipc-ui/src/api/bigscreen/overall.js index 4a95488..6018ee9 100644 --- a/zfipc-ui/src/api/bigscreen/overall.js +++ b/zfipc-ui/src/api/bigscreen/overall.js @@ -55,3 +55,27 @@ export function getCompanyDetails() { method: "get", }); } + +// 统计最新报警信息 +export function getLatestAlarmRecord() { + return request({ + url: "/bigscreen/overall/listLatestAlarmRecord", + method: "get", + }); +} + +//获取各个省设备数 +export function getEquNumByProvince() { + return request({ + url: "/bigscreen/overall/countCompanyEquipNumByProvince", + method: "get", + }); +} + +//获取某个省各个市的设备数 +export function getEquNumByCity(provinceName) { + return request({ + url: "/bigscreen/overall/countCompanyEquipNumByCity/" + provinceName, + method: "get", + }); +} diff --git a/zfipc-ui/src/views/bigscreen/company/index.vue b/zfipc-ui/src/views/bigscreen/company/index.vue index a0267a1..ef2d700 100644 --- a/zfipc-ui/src/views/bigscreen/company/index.vue +++ b/zfipc-ui/src/views/bigscreen/company/index.vue @@ -54,18 +54,23 @@ >
-
-
{{ "xxx工厂" }}
-
+
+
{{ item.deptName }}
{{ "产线数:" }}
-
{{ 1 }}
+
{{ item.deptNum }}
{{ "台" }}
@@ -73,10 +78,45 @@
{{ 1 }}
+ >{{ item.alarmNum }}
{{ "条" }}
+
--> +
+
{{ this.showProvinceName }} 关闭
+
+
+
+
{{ item.deptName }}
+
+
+
{{ "产线数:" }}
+
{{ item.deptNum + "台" }}
+
+
+
{{ "报警数:" }}
+
{{ item.alarmNum + "条" }}
+
+
+
@@ -194,6 +234,8 @@ import { getWeeklyAlarmNumByCompany, getSparePartsNumByCompany, getCompanyDeptTree, + getRegionByCompany, + getCompanyMapData, } from "@/api/bigscreen/company"; export default { dicts: ["equip_status", "severity_level"], @@ -255,21 +297,16 @@ export default { myChart: "", series: [], showPanel: false, + firstMark: false, loading: false, + coordData: [], + provinceName: [], + showProvinceName: "", + mapTableData: [], }; }, computed: {}, mounted() { - const data = chinaMap.features; - console.log("data:", data); - // console.log( - // "p:", - // data.filter((e) => e.properties.adcode > 0) - // ); - data.filter((e) => { - console.log("mmm:", e.properties.adcode); - return e; - }); this.getDeptTree(); this.getCompanyEquNum(); this.getPatrolRecordNum(); @@ -279,9 +316,48 @@ export default { this.getAlarmData(); this.getUpkeepRecord(); this.getWeeklyAlarmNum(); - this.mapRender(); + this.getCompanyRegionCoord(); + }, + created() { + // document.addEventListener("click", (event) => { + // // var popup = + // // this.mapTableData.length > 1 + // // ? document.getElementById("popPanel1") + // // : document.getElementById("popPanel2"); + // var popup = document.getElementById("popPanel1"); + // if (this.firstMark) { + // console.log("显示"); + // this.showPanel = true; + // this.firstMark = false; + // } else { + // console.log("验证是否显示"); + // var isOut = popup.contains(event.target); + // this.showPanel = isOut && this.showPanel; + // } + // }); }, methods: { + closePanel() { + this.showPanel = false; + }, + stopClick(e) { + e.stopPropagation(); + }, + getCompanyRegionCoord() { + const mapData = chinaMap.features; + this.coordData = []; + getRegionByCompany(this.selectedDeptId).then((res) => { + var reginList = res.data; + reginList.forEach((element) => { + this.provinceName.push(element.name); + const jsonData = mapData.filter( + (e) => e.properties.adcode === element.id + ); + this.coordData.push({ value: jsonData[0].properties.center }); + this.mapRender(); + }); + }); + }, getWeeklyAlarmNum() { let chart6 = echarts.init(this.$refs.chart6); chart6.showLoading(); @@ -393,33 +469,8 @@ export default { }, mapRender() { const _this = this; - // let mapDom = document.querySelector(".map-wrapper"); - // this.myChart = this.$echarts.init(mapDom); echarts.registerMap("china", { geoJSON: chinaMap }); this.myChart = echarts.init(document.getElementById("mapChart")); - let data = [ - { name: "上海", value: "90" }, - { name: "武汉", value: 90 }, - ]; - let geoCoordMap = { - //可以在地图上显示的城市的坐标信息 - 武汉: [114.31, 30.52], - 上海: [121.4648, 31.2891], - }; - let convertData = function (data) { - //返回[{coord: 极坐标},{coord: 极坐标}] - var res = []; - for (var i = 0; i < data.length; i++) { - var geoCoord = geoCoordMap[data[i].name]; - if (geoCoord) { - res.push({ - name: data[i].name, - value: geoCoord.concat(data[i].value), - }); - } - } - return res; - }; _this.series.push([ { name: "项目分布", @@ -446,73 +497,7 @@ export default { color: "#fff", }, }, - data: convertData(data), - }, - { - // type: "scatter", - // z: 5, - // roam: false, // 可缩放 - // coordinateSystem: "geo", - // symbolSize: [20, 30], //点的大小 - // symbolOffset: [0, -15], - // color: "#e1ebe3", - // showEffectOn: "render", - // effectType: "ripple", - // itemStyle: { - // color: "red", - // }, - // label: { - // normal: { - // show: false, //是否显示省份 - // textStyle: { - // color: "#00a0c9", - // size: "10", - // }, - // }, - // }, - // markLine: { - // smooth: true, - // symbol: ["pin", "circle"], - // symbolSize: 1, - // itemStyle: { - // normal: { - // color: "#ff0", - // borderWidth: 1, - // borderColor: "rgba(0,0,0,0)", - // }, - // }, - // data: [], - // }, - // data: convertData(data), - }, - { - // type: "map", - // map: "china", - // geoIndex: 0, - // aspectScale: 0.75, //长宽比 - // showLegendSymbol: false, // 存在legend时显示 - // label: { - // normal: { - // show: false, - // }, - // emphasis: { - // show: false, - // textStyle: { - // color: "#fff", - // }, - // }, - // }, - // roam: true, - // itemStyle: { - // normal: { - // areaColor: "#031525", - // borderColor: "#FFFFFF", - // }, - // emphasis: { - // areaColor: "#2B91B7", - // }, - // }, - // animation: false, + data: this.coordData, }, ]); // 指定相关的配置项和数据 @@ -587,34 +572,35 @@ export default { series: _this.series[0], }; this.myChart.setOption(mapBoxOption); - - // this.myChart.off("click"); this.myChart.on("click", (e) => { //判断该名字在有厂区的省 - this.showPanel = true; - let dx = e.event.offsetX; - let dy = e.event.offsetY; - var panel = document.getElementById("popPanel"); - panel.style.left = dx + "px"; - panel.style.top = dy + "px"; - // panel.css("left", dx + 30); - // $(".mainPanel").css("top", dy - 130); + if (this.provinceName.includes(e.name)) { + this.showProvinceName = e.name; + const mapData = chinaMap.features; + const selectData = mapData.filter((md) => { + return md.properties.name === e.name; + }); + const regionId = selectData[0].properties.adcode; + this.showPanel = true; + this.firstMark = true; + //获取数据列表 + let dx = e.event.offsetX; + let dy = e.event.offsetY; + // var panel = + // this.mapTableData.length > 1 + // ? document.getElementById("popPanel1") + // : document.getElementById("popPanel2"); + var panel = document.getElementById("popPanel1"); + panel.style.left = dx + "px"; + panel.style.top = dy + "px"; + if (regionId != null) { + getCompanyMapData(regionId).then((res) => { + this.mapTableData = res.data; + }); + } + } }); }, - // fixingPositon() { - // const e = event || window.event, - // top = e.clientY, - // left = e.clientX, - // boxDom = document.querySelector(".mainPanel"); - - // this.$nextTick(function () { - // const offsetX = boxDom.clientWidth; - // const offsetY = boxDom.clientHeight; - // boxDom.style.cssText = `top: ${top - offsetY - 25}px; left: ${ - // left + offsetX / 3 - // }px`; - // }); - // }, initMapChart() { echarts.registerMap("china", { geoJSON: chinaMap }); let myChart = echarts.init(document.getElementById("mapChart")); @@ -951,7 +937,7 @@ export default { data: element.y, type: "line", }); - legendData.push(data.deptName); + legendData.push(element.deptName); }); option.legend = { data: legendData }; } @@ -1021,7 +1007,7 @@ export default { data: element.y, type: "line", }); - legendData.push(data.deptName); + legendData.push(element.deptName); }); option.legend = { data: legendData }; } @@ -1171,7 +1157,7 @@ export default { data: element.y, type: "line", }); - legendData.push(data.deptName); + legendData.push(element.deptName); }); option.legend = { data: legendData }; } @@ -1241,7 +1227,7 @@ export default { data: element.y, type: "line", }); - legendData.push(data.deptName); + legendData.push(element.deptName); }); option.legend = { data: legendData }; } @@ -2038,8 +2024,8 @@ export default { background: url(../../../assets/images/bigscreen/company/pop_back.png) no-repeat center center; position: absolute; - width: 250px; - height: 150px; + width: 450px; + overflow-y: auto; background-size: 100% 100%; z-index: 999; } @@ -2054,16 +2040,31 @@ export default { } .contentPanel { display: grid; - grid-template-rows: 1fr 1rf; + grid-template-columns: 1fr 1fr 1fr; height: 35px; line-height: 35px; margin-bottom: 4px; font-size: 18px; font-weight: lighter; justify-content: space-around; + background: rgba(202, 238, 254, 0.1); } .showdata { display: flex; } +.single-contentPanel { + display: flex; + height: 35px; + margin-bottom: 4px; + font-size: 18px; + justify-content: space-around; +} +.single-showdata { + flex: 1; + display: flex; + margin: 5% 0 2% 0; + font-size: 18px; + justify-content: center; +} \ No newline at end of file diff --git a/zfipc-ui/src/views/bigscreen/overall/index.vue b/zfipc-ui/src/views/bigscreen/overall/index.vue index 39f03e6..e503e54 100644 --- a/zfipc-ui/src/views/bigscreen/overall/index.vue +++ b/zfipc-ui/src/views/bigscreen/overall/index.vue @@ -8,6 +8,7 @@
在线轴承运行信息
@@ -80,7 +81,7 @@
维修信息
- {{50}} + {{this.maintenTotal}} {{"维修总数"}}
@@ -89,10 +90,10 @@ :key="index" class="run-status-des" > -
- {{ item.name }} +
+ {{ item.deptName }}
-
{{ item.value }} | {{ item.rate }}
+
{{ item.data }} | {{ item.rate }}
@@ -127,21 +128,21 @@ class="mainPanel" v-show="showPanel" > -
{{ "xxx工厂" }}
-
-
-
{{ "产线数:" }}
-
{{ 1 }}
-
{{ "台" }}
-
-
-
{{ "报警数:" }}
-
{{ 1 }}
-
{{ "条" }}
-
+
{{ this.provinceName + ":" + this.eqpNums + "台" }} 关闭
+
+
{{ item.name + ":" }}
+
{{ item.value + "台" }}
@@ -150,43 +151,43 @@
客户告警信息
+ - - - - - - + + + + + + +
@@ -197,7 +198,7 @@
应用行业及占有率
- {{50}} + {{this.industryTotal}} {{"设备总数"}}
@@ -242,14 +243,14 @@
{{ "正常" }}
-
80
+
{{ 3 }}
{{ "离线" }}
-
80
+
{{1}}
@@ -268,14 +269,14 @@
{{ "正常" }}
-
70
+
{{7}}
{{ "离线" }}
-
10
+
{{3}}
@@ -288,41 +289,46 @@