Browse Source

Merge remote-tracking branch 'origin/master'

丁治程 2 months ago
parent
commit
68ac2807e0

+ 1 - 1
module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/mapper/xml/EquipmentHealthMapper.xml

@@ -27,7 +27,7 @@
             from (
                 select equipmentid,status,
                     row_number() over(partition by equipmentid order by id desc) mm
-                from tpm_equipment_health
+                from tpm_equipment_health where day=current_date
             ) b
             where mm=1
         ) as c

+ 58 - 2
module_tpm/src/main/java/org/jeecg/modules/equipmentOnoff/controller/EquipmentOnoffController.java

@@ -191,15 +191,71 @@ public class EquipmentOnoffController extends JeecgController<EquipmentOnoff, IE
 	 }
 
 	 /**
-	  * 设备健康-设备运行查询  从mongodb查询设备的历史数据  查询给的日期当天所有的数据
+	  * 设备健康-设备运行查询-折线展示  从mongodb查询设备的历史数据  查询给的日期当天所有的数据
 	  *
 	  * @return
 	  */
 	 //@AutoLog(value = "设备健康-设备运行查询")
-	 @ApiOperation(value="设备健康-设备运行查询", notes="设备健康-设备运行查询")
+	 @ApiOperation(value="设备健康-设备运行查询-折线展示", notes="设备健康-设备运行查询-折线展示")
 	 @GetMapping(value = "/getEquipmentHistoryData")
 	 public Result<List<Map<String, Object>>> getEquipmentHistoryData(HistoryParamDayDto historyParamDayDto) {
 		 return equipmentOnoffService.getEquipmentHistoryData(historyParamDayDto);
 	 }
 
+	 /**
+	  * 设备健康-设备运行查询-折线展示  从mongodb查询设备的历史数据  查询给的日期当天所有的数据
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备健康-设备运行查询")
+	 @ApiOperation(value="设备健康-设备运行查询-折线展示默认值", notes="设备健康-设备运行查询-折线展示默认值")
+	 @GetMapping(value = "/getEquipmentHistoryDataDefault")
+	 public Result<List<Map<String, Object>>> getEquipmentHistoryDataDefault(HistoryParamDayDto historyParamDayDto) {
+		 return equipmentOnoffService.getEquipmentHistoryDataDefault(historyParamDayDto);
+	 }
+
+	 /**
+	  * 设备健康-设备运行查询-表格展示  从mongodb查询设备的历史数据  查询给的日期当天所有的数据
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备健康-设备运行查询")
+	 @ApiOperation(value="设备健康-设备运行查询-表格展示", notes="设备健康-设备运行查询-表格展示")
+	 @GetMapping(value = "/getEquipHistoryDataList")
+	 public Result<List<Map<String, Object>>> getEquipHistoryDataList(HistoryParamDayDto historyParamDayDto) {
+		 return equipmentOnoffService.getEquipHistoryDataList(historyParamDayDto);
+	 }
+
+	 /**
+	  * 设备健康-设备运行查询-表格展示  从mongodb查询设备的历史数据  查询给的日期当天所有的数据
+	  * 分列页表查询
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备健康-设备运行查询")
+	 @ApiOperation(value="设备健康-设备运行查询-表格展示分列页表", notes="设备健康-设备运行查询-表格展示分列页表")
+	 @GetMapping(value = "/getHistoryListByPage")
+	 public Result<IPage<Map<String, Object>>> getHistoryListByPage(HistoryParamDayDto historyParamDayDto,
+												   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+												   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
+		 return equipmentOnoffService.getHistoryListByPage(pageNo, pageSize, historyParamDayDto);
+
+	 }
+
+	 /**
+	  * 设备健康-设备运行查询-表格展示  从mongodb查询设备的历史数据  查询给的日期当天所有的数据
+	  * 分列页表查询  不拆分数据
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备健康-设备运行查询")
+	 @ApiOperation(value="设备健康-设备运行查询-表格展示分列页表不拆分数据", notes="设备健康-设备运行查询-表格展示分列页表不拆分数据")
+	 @GetMapping(value = "/getHistoryListByPage2")
+	 public Result<IPage<Map<String, Object>>> getHistoryListByPage2(HistoryParamDayDto historyParamDayDto,
+																	@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+																	@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
+		 return equipmentOnoffService.getHistoryListByPage2(pageNo, pageSize, historyParamDayDto);
+
+	 }
+
 }

+ 8 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentOnoff/service/IEquipmentOnoffService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.equipmentOnoff.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.equipmentOnoff.entity.EquipmentOnoff;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -21,4 +22,11 @@ public interface IEquipmentOnoffService extends IService<EquipmentOnoff> {
 
     Result<List<Map<String, Object>>> getEquipmentHistoryData(HistoryParamDayDto historyParamDayDto);
 
+    Result<List<Map<String, Object>>> getEquipmentHistoryDataDefault(HistoryParamDayDto historyParamDayDto);
+
+    Result<List<Map<String, Object>>> getEquipHistoryDataList(HistoryParamDayDto historyParamDayDto);
+
+    Result<IPage<Map<String, Object>>> getHistoryListByPage(Integer pageNo, Integer pageSize, HistoryParamDayDto historyParamDayDto);
+    Result<IPage<Map<String, Object>>> getHistoryListByPage2(Integer pageNo, Integer pageSize, HistoryParamDayDto historyParamDayDto);
+
 }

+ 297 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentOnoff/service/impl/EquipmentOnoffServiceImpl.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.equipmentOnoff.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.collectdata.entity.Collectdata;
@@ -9,7 +11,11 @@ import org.jeecg.modules.equipmentOnoff.entity.HistoryParamDto;
 import org.jeecg.modules.equipmentOnoff.mapper.EquipmentOnoffMapper;
 import org.jeecg.modules.equipmentOnoff.service.IEquipmentOnoffService;
 import org.jeecg.modules.tpmEquipment.service.ITpmEquipmentService;
+import org.jeecg.modules.tpmparams.entity.TpmParams;
+import org.jeecg.modules.tpmparams.mapper.TpmParamsMapper;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
@@ -20,6 +26,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: tpm_equipment_onoff
@@ -37,6 +44,10 @@ public class EquipmentOnoffServiceImpl extends ServiceImpl<EquipmentOnoffMapper,
     @SuppressWarnings("all")
     private ITpmEquipmentService tpmEquipmentService;
 
+    @Autowired
+    @SuppressWarnings("all")
+    private TpmParamsMapper tpmParamsMapper;
+
     public Map<String, Date> splitByMonth(Date beginTime, Date endTime){
         Map<String, Date> dateMap = new HashMap<>();
         Calendar calB = Calendar.getInstance();
@@ -105,6 +116,7 @@ public class EquipmentOnoffServiceImpl extends ServiceImpl<EquipmentOnoffMapper,
         return Result.ok(historyList);
     }
 
+    //折线展示
     @Override
     public Result<List<Map<String, Object>>> getEquipmentHistoryData(HistoryParamDayDto historyParamDayDto){
         List<Map<String, Object>> historyList = new ArrayList<>();
@@ -168,4 +180,289 @@ public class EquipmentOnoffServiceImpl extends ServiceImpl<EquipmentOnoffMapper,
         return Result.ok(historyList);
     }
 
+    @Override
+    public Result<List<Map<String, Object>>> getEquipmentHistoryDataDefault(HistoryParamDayDto historyParamDayDto){
+        List<Map<String, Object>> historyList = new ArrayList<>();
+        List<Collectdata> orgDataList = new ArrayList<>();
+        //根据设备id找到设备编号
+        String equipmentcode;
+        try {
+            equipmentcode = (tpmEquipmentService.getById(historyParamDayDto.getEquipmentid())).getEquipmentcode();
+        }catch (NullPointerException e){
+            return Result.error("id为" + historyParamDayDto.getEquipmentid() + "的设备找不到设备编号,无法进行数据查询!");
+        }
+        //根据时间确定要查询哪一天的数据
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+        sdf1.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置时区为UTC
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+//        String dateStr = historyParamDayDto.getDate();
+        Date date;
+        String dateStr = historyParamDayDto.getDate().replace("\"", "");
+        try {
+            if(dateStr.contains("T")){
+                date = sdf1.parse(dateStr);
+            }else{
+                date = sdf2.parse(dateStr);
+            }
+
+        } catch (ParseException e) {
+            return Result.error("日期类型转换失败!");
+        }
+
+        Calendar dateCal = Calendar.getInstance();
+        dateCal.setTime(date);
+        dateCal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        for(int i=0;i<100;i++){
+            Map<String, Object> map = new HashMap<>();
+            map.put("BSPEED1", 60);
+            map.put("BSPEED2", 150);
+            map.put("BSPEED3", 150);
+            map.put("BSPEED4", 150);
+            map.put("BPRESS1", 60);
+            map.put("BPRESS2", 60);
+            map.put("BPRESS3", 60);
+            map.put("BPRESS4", 60);
+            map.put("BDIST1", 60);
+            map.put("BDIST2", 60);
+            map.put("BDIST3", 60);
+            map.put("BDIST4", 60);
+            map.put("TEMP", 150);
+            map.put("HUMI", 25);
+            map.put("ALARM", 0);
+            map.put("HEATER_TEMP", 150);
+            map.put("POOL_TEMP", 150);
+            map.put("logtime", dateCal.getTime());
+            dateCal.add(Calendar.SECOND, 15);
+            historyList.add(map);
+        }
+
+        return Result.ok(historyList);
+    }
+
+    //表格展示
+    public Result<List<Map<String, Object>>> getEquipHistoryDataList(HistoryParamDayDto historyParamDayDto){
+        List<Map<String, Object>> historyList = new ArrayList<>();
+        List<Collectdata> orgDataList = new ArrayList<>();
+        //根据设备id找到设备编号
+        String equipmentcode;
+        try {
+            equipmentcode = (tpmEquipmentService.getById(historyParamDayDto.getEquipmentid())).getEquipmentcode();
+        }catch (NullPointerException e){
+            return Result.error("id为" + historyParamDayDto.getEquipmentid() + "的设备找不到设备编号,无法进行数据查询!");
+        }
+        List<TpmParams> tpmParamsList = tpmParamsMapper.queryByEquipId(historyParamDayDto.getEquipmentid());
+        if(tpmParamsList.size()==0) {
+            return Result.error("未找到对应数据");
+        }
+        //根据时间确定要查询哪一天的数据
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+        sdf1.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置时区为UTC
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+//        String dateStr = historyParamDayDto.getDate();
+        Date date;
+        String dateStr = historyParamDayDto.getDate().replace("\"", "");
+        try {
+            if(dateStr.contains("T")){
+                date = sdf1.parse(dateStr);
+            }else{
+                date = sdf2.parse(dateStr);
+            }
+
+        } catch (ParseException e) {
+            return Result.error("日期类型转换失败!");
+        }
+
+        Calendar dateCal = Calendar.getInstance();
+        dateCal.setTime(date);
+        dateCal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        Date startDate = dateCal.getTime();
+        // 将日期增加一天
+        dateCal.add(Calendar.DATE, 1);
+        Date endDate = dateCal.getTime();
+        System.out.println(new SimpleDateFormat("yyyyMM").format(startDate));
+        System.out.println(new SimpleDateFormat("yyyyMM").format(endDate));
+        //创建查询对象
+        Query HistoryQuery = new Query();
+        //添加查询条件
+        HistoryQuery.addCriteria(Criteria.where("equipmentcode").is(equipmentcode));
+//        HistoryQuery.addCriteria(Criteria.where("logtime").is(dateCal.getTime())); // 大于等于startDate且小于等于endDate
+        HistoryQuery.addCriteria(Criteria.where("logtime").gte(startDate).lte(endDate)); // 大于等于startDate且小于等于endDate
+
+        //执行查询
+        try{
+            orgDataList.addAll(mongoTemplate.find(HistoryQuery, Collectdata.class, "data_"+new SimpleDateFormat("yyyyMM").format(startDate)));
+        }catch (NullPointerException e){}
+        //表格展示示例:
+        //[{"tagname":"电流","logtime","2025-02-24 10:10:10","tagvalue":12},.......................]
+        for(Collectdata collectdata:orgDataList){
+            Map<String, Object> dataMap = new ObjectMapper().convertValue(collectdata.getProperties(), Map.class);
+            for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
+                for(TpmParams tpmParams:tpmParamsList){
+                    if(tpmParams.getSymbol().equals(entry.getKey())){
+                        Map<String, Object> dataMapNew = new HashMap<>();
+                        dataMapNew.put("tagname", tpmParams.getTagname());//参数名称
+                        dataMapNew.put("logtime", collectdata.getLogtime());//记录时间
+                        dataMapNew.put("tagvalue", entry.getValue());//参数值
+                        historyList.add(dataMapNew);
+                    }
+                }
+            }
+        }
+        return Result.ok(historyList);
+    }
+
+    public Result<IPage<Map<String, Object>>> getHistoryListByPage(Integer pageNo, Integer pageSize, HistoryParamDayDto historyParamDayDto){
+        //1.根据设备id查找设备的参数信息列表 找不到直接返回
+        List<TpmParams> tpmParamsList = tpmParamsMapper.queryByEquipId(historyParamDayDto.getEquipmentid());
+        if(tpmParamsList.size()==0) {
+            return Result.error("未找到对应数据");
+        }
+        //2.根据设备id找到设备编号 找不到直接返回
+        String equipmentcode;
+        try {
+            equipmentcode = (tpmEquipmentService.getById(historyParamDayDto.getEquipmentid())).getEquipmentcode();
+        }catch (NullPointerException e){
+            return Result.error("id为" + historyParamDayDto.getEquipmentid() + "的设备找不到设备编号,无法进行数据查询!");
+        }
+        //3.处理传来的时间数据   根据时间确定要查询哪一天的数据  处理成带时区的时间
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+        sdf1.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置时区为UTC
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+//        String dateStr = historyParamDayDto.getDate();
+        Date date;
+        String dateStr = historyParamDayDto.getDate().replace("\"", "");
+        try {
+            if(dateStr.contains("T")){
+                date = sdf1.parse(dateStr);
+            }else{
+                date = sdf2.parse(dateStr);
+            }
+        } catch (ParseException e) {
+            return Result.error("日期类型转换失败!");
+        }
+        Calendar dateCal = Calendar.getInstance();
+        dateCal.setTime(date);
+        dateCal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        Date startDate = dateCal.getTime();
+        // 将日期增加一天
+        dateCal.add(Calendar.DATE, 1);
+        Date endDate = dateCal.getTime();
+
+        //4.通过前面处理得到的设备code和时间,以及page分页读取mongodb
+        List<Map<String, Object>> historyList = new ArrayList<>();
+        List<Collectdata> orgDataList = new ArrayList<>();
+        //创建查询对象
+        Query HistoryQuery = new Query();
+        //添加查询条件
+        HistoryQuery.addCriteria(Criteria.where("equipmentcode").is(equipmentcode));
+        HistoryQuery.addCriteria(Criteria.where("logtime").gte(startDate).lte(endDate)); // 大于等于startDate且小于等于endDate
+        //执行查询
+        try{
+            orgDataList.addAll(mongoTemplate.find(HistoryQuery, Collectdata.class, "data_"+new SimpleDateFormat("yyyyMM").format(startDate)));
+        }catch (NullPointerException e){}
+        //表格展示示例:
+        //[{"tagname":"电流","logtime","2025-02-24 10:10:10","tagvalue":12},.......................]
+        for(Collectdata collectdata:orgDataList){
+            Map<String, Object> dataMap = new ObjectMapper().convertValue(collectdata.getProperties(), Map.class);
+            for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
+                for(TpmParams tpmParams:tpmParamsList){
+                    if(tpmParams.getSymbol().equals(entry.getKey())){
+                        Map<String, Object> dataMapNew = new HashMap<>();
+                        dataMapNew.put("tagname", tpmParams.getTagname());//参数名称
+                        dataMapNew.put("logtime", collectdata.getLogtime());//记录时间
+                        dataMapNew.put("tagvalue", entry.getValue());//参数值
+                        historyList.add(dataMapNew);
+                    }
+                }
+            }
+        }
+        //手动创建一个分页
+        //创建分页示例
+//        Pageable pageable = PageRequest.of(pageNo - 1, pageSize);
+        List<Map<String, Object>> pagedRecords = historyList.stream()
+                .skip((long) (pageNo - 1) * pageSize)
+                .limit(pageSize)
+                .collect(Collectors.toList());
+        IPage<Map<String, Object>> result = new Page<>(pageNo, pageSize, historyList.size());
+        result.setRecords(pagedRecords);
+        return Result.ok(result);
+    }
+
+    public Result<IPage<Map<String, Object>>> getHistoryListByPage2(Integer pageNo, Integer pageSize, HistoryParamDayDto historyParamDayDto){
+        //1.根据设备id查找设备的参数信息列表 找不到直接返回
+        List<TpmParams> tpmParamsList = tpmParamsMapper.queryByEquipId(historyParamDayDto.getEquipmentid());
+        if(tpmParamsList.size()==0) {
+            return Result.error("未找到对应数据");
+        }
+        //2.根据设备id找到设备编号 找不到直接返回
+        String equipmentcode;
+        try {
+            equipmentcode = (tpmEquipmentService.getById(historyParamDayDto.getEquipmentid())).getEquipmentcode();
+        }catch (NullPointerException e){
+            return Result.error("id为" + historyParamDayDto.getEquipmentid() + "的设备找不到设备编号,无法进行数据查询!");
+        }
+        //3.处理传来的时间数据   根据时间确定要查询哪一天的数据  处理成带时区的时间
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+        sdf1.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置时区为UTC
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+//        String dateStr = historyParamDayDto.getDate();
+        Date date;
+        String dateStr = historyParamDayDto.getDate().replace("\"", "");
+        try {
+            if(dateStr.contains("T")){
+                date = sdf1.parse(dateStr);
+            }else{
+                date = sdf2.parse(dateStr);
+            }
+        } catch (ParseException e) {
+            return Result.error("日期类型转换失败!");
+        }
+        Calendar dateCal = Calendar.getInstance();
+        dateCal.setTime(date);
+        dateCal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        Date startDate = dateCal.getTime();
+        // 将日期增加一天
+        dateCal.add(Calendar.DATE, 1);
+        Date endDate = dateCal.getTime();
+
+        //4.通过前面处理得到的设备code和时间,以及page分页读取mongodb
+        List<Map<String, Object>> historyList = new ArrayList<>();
+        List<Collectdata> orgDataList = new ArrayList<>();
+        long total = 0;
+        Pageable pageable = PageRequest.of(pageNo - 1, pageSize);
+        //创建查询对象
+        Query HistoryQuery = new Query().with(pageable);
+        //添加查询条件
+        HistoryQuery.addCriteria(Criteria.where("equipmentcode").is(equipmentcode));
+        HistoryQuery.addCriteria(Criteria.where("logtime").gte(startDate).lte(endDate)); // 大于等于startDate且小于等于endDate
+        //创建查询对象
+        Query HistoryQueryCount = new Query();
+        //添加查询条件
+        HistoryQueryCount.addCriteria(Criteria.where("equipmentcode").is(equipmentcode));
+        HistoryQueryCount.addCriteria(Criteria.where("logtime").gte(startDate).lte(endDate));
+        //执行查询
+        try{
+            orgDataList.addAll(mongoTemplate.find(HistoryQuery, Collectdata.class, "data_"+new SimpleDateFormat("yyyyMM").format(startDate)));
+            total = mongoTemplate.count(HistoryQueryCount, Collectdata.class, "data_"+new SimpleDateFormat("yyyyMM").format(startDate));
+        }catch (NullPointerException e){}
+        //表格展示示例:
+        //[{"tagname":"电流","logtime","2025-02-24 10:10:10","tagvalue":12},.......................]
+        for(Collectdata collectdata:orgDataList){
+            Map<String, Object> dataMap = new ObjectMapper().convertValue(collectdata.getProperties(), Map.class);
+            if(dataMap.containsKey("TIME")){
+                dataMap.remove("TIME");
+            }
+            if(dataMap.containsKey("time")){
+                dataMap.remove("time");
+            }
+            dataMap.put("logtime", collectdata.getLogtime());
+            historyList.add(dataMap);
+        }
+        //手动创建一个分页
+        //创建分页示例
+        IPage<Map<String, Object>> result = new Page<>(pageNo, pageSize, total);
+        result.setRecords(historyList);
+        return Result.ok(result);
+    }
+
 }

+ 38 - 3
module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/Impl/HealthStatisticsServiceImpl.java

@@ -9,6 +9,7 @@ import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
 import org.jeecg.modules.equipmentHealthSection.mapper.EquipmentHealthSectionMapper;
 import org.jeecg.modules.equipmentOnoffSection.entity.EquipmentOnoffSection;
 import org.jeecg.modules.healthStatistics.service.IHealthStatisticsService;
+import org.jeecg.modules.tpmEquipment.mapper.TpmEquipmentMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -30,6 +31,9 @@ public class HealthStatisticsServiceImpl implements IHealthStatisticsService {
     @Autowired
     private StatisticsMapper statisticsMapper;
 
+    @Autowired
+    private TpmEquipmentMapper tpmEquipmentMapper;
+
     /**
      * 健康概况信息获取
      * @param day
@@ -44,10 +48,41 @@ public class HealthStatisticsServiceImpl implements IHealthStatisticsService {
         List<Integer> days = new ArrayList<>();
         // 汇总查询最近的状态
         List<EquipmentHealth> healthList = equipmentHealthMapper.selectLastStatusGroup();
-        int equipnum = 0;
-        if (healthList != null && healthList.size() > 0) {
-            equipnum = healthList.stream().mapToInt(EquipmentHealth::getHowmany).sum();
+//        int equipnum = 0;
+//        if (healthList != null && healthList.size() > 0) {
+//            equipnum = healthList.stream().mapToInt(EquipmentHealth::getHowmany).sum();
+//        }
+//        EquipmentHealth equipmentHealth2 = new EquipmentHealth();
+//        equipmentHealth2.setStatus("1");
+//        equipmentHealth2.setHowmany(99);
+//        healthList.add(equipmentHealth2);
+//        EquipmentHealth equipmentHealth3 = new EquipmentHealth();
+//        equipmentHealth3.setStatus("3");
+//        equipmentHealth3.setHowmany(2);
+//        healthList.add(equipmentHealth3);
+        int equipnum = tpmEquipmentMapper.getAllByTpmequip();
+        int offlinenum = equipnum;
+        for(int i=0;i<3;i++){
+            if(healthList.size()>0 && healthList.size()>=i+1){
+                if(!healthList.get(i).getStatus().equals(Integer.toString(i+1))){
+                    EquipmentHealth equipmentHealth = new EquipmentHealth();
+                    equipmentHealth.setStatus(Integer.toString(i+1));
+                    equipmentHealth.setHowmany(0);
+                    healthList.add(i, equipmentHealth);
+                }
+            }else {
+                EquipmentHealth equipmentHealth = new EquipmentHealth();
+                equipmentHealth.setStatus(Integer.toString(i+1));
+                equipmentHealth.setHowmany(0);
+                healthList.add(i, equipmentHealth);
+            }
+            offlinenum = offlinenum-healthList.get(i).getHowmany();
         }
+        EquipmentHealth equipmentHealth1 = new EquipmentHealth();
+        equipmentHealth1.setStatus("4");
+        equipmentHealth1.setHowmany(offlinenum);
+        healthList.add(equipmentHealth1);
+
 
         // 年度查询汇总查月状态时长汇总
         List<EquipmentHealthSection> yearList = equipmentHealthSectionMapper.selectStatusGroupByYear(year);

+ 4 - 0
module_tpm/src/main/java/org/jeecg/modules/tpmEquipment/mapper/TpmEquipmentMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.tpmEquipment.entity.TpmEquipment;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -16,4 +17,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 @Mapper
 public interface TpmEquipmentMapper extends BaseMapper<TpmEquipment> {
 
+    @Select("select count(*) from tpm_equipment")
+    Integer getAllByTpmequip();
+
 }