Browse Source

改了一堆乱七八糟的东西

dongjh 5 months ago
parent
commit
c3cfe59d38
17 changed files with 1162 additions and 13 deletions
  1. 9 9
      jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 4 4
      jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml
  3. 175 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/controller/EquipmentHealthController.java
  4. 90 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/entity/EquipmentHealth.java
  5. 22 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/mapper/EquipmentHealthMapper.java
  6. 37 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/mapper/xml/EquipmentHealthMapper.xml
  7. 22 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/service/IEquipmentHealthService.java
  8. 32 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/service/impl/EquipmentHealthServiceImpl.java
  9. 196 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/controller/EquipmentHealthSectionController.java
  10. 121 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/entity/EquipmentHealthSection.java
  11. 37 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/EquipmentHealthSectionMapper.java
  12. 145 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/xml/EquipmentHealthSectionMapper.xml
  13. 29 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/service/IEquipmentHealthSectionService.java
  14. 77 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/service/impl/EquipmentHealthSectionServiceImpl.java
  15. 42 0
      module_tpm/src/main/java/org/jeecg/modules/healthStatistics/controller/HealthStatisticsController.java
  16. 15 0
      module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/IHealthStatisticsService.java
  17. 109 0
      module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/Impl/HealthStatisticsServiceImpl.java

+ 9 - 9
jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -126,15 +126,15 @@ public class ShiroConfig {
 
         filterChainDefinitionMap.put("/sys/annountCement/show/**", "anon");
 
-        //积木报表排除
-        filterChainDefinitionMap.put("/jmreport/**", "anon");
-        filterChainDefinitionMap.put("/**/*.js.map", "anon");
-        filterChainDefinitionMap.put("/**/*.css.map", "anon");
-        
-        //大屏模板例子
-        filterChainDefinitionMap.put("/test/bigScreen/**", "anon");
-        filterChainDefinitionMap.put("/bigscreen/template1/**", "anon");
-        filterChainDefinitionMap.put("/bigscreen/template1/**", "anon");
+//        //积木报表排除
+//        filterChainDefinitionMap.put("/jmreport/**", "anon");
+//        filterChainDefinitionMap.put("/**/*.js.map", "anon");
+//        filterChainDefinitionMap.put("/**/*.css.map", "anon");
+//
+//        //大屏模板例子
+//        filterChainDefinitionMap.put("/test/bigScreen/**", "anon");
+//        filterChainDefinitionMap.put("/bigscreen/template1/**", "anon");
+//        filterChainDefinitionMap.put("/bigscreen/template1/**", "anon");
         //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
         //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
         //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试

+ 4 - 4
jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml

@@ -25,7 +25,7 @@ spring:
   #redis 配置
   redis:
     # 地址
-    host: 119.3.168.55
+    host: 127.0.0.1
     # 端口,默认为6379
     port: 6380
     # 数据库索引
@@ -36,7 +36,7 @@ spring:
   #  mongodb配置
   data:
     mongodb:
-      uri: mongodb://phm:phm123@127.0.0.1:27017/phm
+      uri: mongodb://phm:phm529a@127.0.0.1:27017/phm
       print: true
       slowQuery: true
       slowTime: 1000
@@ -44,8 +44,8 @@ spring:
 jeecg:
   #分布式锁配置
   redisson:
-    address: 127.0.0.1:6379
-    password:
+    address: 127.0.0.1:6380
+    password: 123qx
     type: STANDALONE
     enabled: true
 

+ 175 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/controller/EquipmentHealthController.java

@@ -0,0 +1,175 @@
+package org.jeecg.modules.equipmentHealth.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
+import org.jeecg.modules.equipmentHealth.service.IEquipmentHealthService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Description: 设备健康记录表
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Api(tags="设备健康记录表")
+@RestController
+@RequestMapping("/equipmentHealth/equipmentHealth")
+@Slf4j
+public class EquipmentHealthController extends JeecgController<EquipmentHealth, IEquipmentHealthService> {
+	@Autowired
+	private IEquipmentHealthService equipmentHealthService;
+
+	/**
+	 * 分页列表查询
+	 *
+	 * @param equipmentHealth
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "设备健康记录表-分页列表查询")
+	@ApiOperation(value="设备健康记录表-分页列表查询", notes="设备健康记录表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<EquipmentHealth>> queryPageList(EquipmentHealth equipmentHealth,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<EquipmentHealth> queryWrapper = QueryGenerator.initQueryWrapper(equipmentHealth, req.getParameterMap());
+		Page<EquipmentHealth> page = new Page<EquipmentHealth>(pageNo, pageSize);
+		IPage<EquipmentHealth> pageList = equipmentHealthService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+
+	/**
+	 *   添加
+	 *
+	 * @param equipmentHealth
+	 * @return
+	 */
+	@AutoLog(value = "设备健康记录表-添加")
+	@ApiOperation(value="设备健康记录表-添加", notes="设备健康记录表-添加")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health:add")
+	@PostMapping(value = "/add")
+	public Result<String> add(@RequestBody EquipmentHealth equipmentHealth) {
+		equipmentHealthService.save(equipmentHealth);
+		return Result.OK("添加成功!");
+	}
+
+	/**
+	 *  编辑
+	 *
+	 * @param equipmentHealth
+	 * @return
+	 */
+	@AutoLog(value = "设备健康记录表-编辑")
+	@ApiOperation(value="设备健康记录表-编辑", notes="设备健康记录表-编辑")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health:edit")
+	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> edit(@RequestBody EquipmentHealth equipmentHealth) {
+		equipmentHealthService.updateById(equipmentHealth);
+		return Result.OK("编辑成功!");
+	}
+
+	/**
+	 *   通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "设备健康记录表-通过id删除")
+	@ApiOperation(value="设备健康记录表-通过id删除", notes="设备健康记录表-通过id删除")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health:delete")
+	@DeleteMapping(value = "/delete")
+	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		equipmentHealthService.removeById(id);
+		return Result.OK("删除成功!");
+	}
+
+	/**
+	 *  批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "设备健康记录表-批量删除")
+	@ApiOperation(value="设备健康记录表-批量删除", notes="设备健康记录表-批量删除")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health:deleteBatch")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.equipmentHealthService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.OK("批量删除成功!");
+	}
+
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	//@AutoLog(value = "设备健康记录表-通过id查询")
+	@ApiOperation(value="设备健康记录表-通过id查询", notes="设备健康记录表-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<EquipmentHealth> queryById(@RequestParam(name="id",required=true) String id) {
+		EquipmentHealth equipmentHealth = equipmentHealthService.getById(id);
+		if(equipmentHealth==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(equipmentHealth);
+	}
+
+    /**
+    * 导出excel
+    *
+    * @param request
+    * @param equipmentHealth
+    */
+    //@RequiresPermissions("org.jeecg.modules:tpm_equipment_health:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, EquipmentHealth equipmentHealth) {
+        return super.exportXls(request, equipmentHealth, EquipmentHealth.class, "设备健康记录表");
+    }
+
+    /**
+      * 通过excel导入数据
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    //@RequiresPermissions("tpm_equipment_health:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, EquipmentHealth.class);
+    }
+
+	/**
+	 * 汇总查询最近的状态
+	 *
+	 * @return
+	 */
+	//@AutoLog(value = "设备健康记录表-汇总查询最近的状态")
+	@ApiOperation(value="设备健康记录表-汇总查询最近的状态", notes="设备健康记录表-汇总查询最近的状态")
+	@GetMapping(value = "/statusgroup")
+	public Result<List<EquipmentHealth>> selectLastStatusGroup() {
+		List<EquipmentHealth> healthList = equipmentHealthService.selectLastStatusGroup();
+		return Result.OK(healthList);
+	}
+
+}

+ 90 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/entity/EquipmentHealth.java

@@ -0,0 +1,90 @@
+package org.jeecg.modules.equipmentHealth.entity;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import lombok.Data;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @Description: 设备健康记录表
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Data
+@TableName("tpm_equipment_health")
+//@Accessors(chain = true)
+//@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="tpm_equipment_health对象", description="设备健康记录表")
+public class EquipmentHealth implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**设备运行状态记录id*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "设备运行状态记录id")
+    private java.lang.Integer id;
+	/**设备id*/
+	@Excel(name = "设备id", width = 15)
+    @ApiModelProperty(value = "设备id")
+    private java.lang.String equipmentid;
+	/**设备名称*/
+	@Excel(name = "设备名称", width = 15)
+    @ApiModelProperty(value = "设备名称")
+    private java.lang.String equipmentname;
+	/**设备状态:1健康、2亚健康、3高危、4离线*/
+	@Excel(name = "设备状态:1健康、2亚健康、3高危、4离线", width = 15)
+    @ApiModelProperty(value = "设备状态:1健康、2亚健康、3高危、4离线")
+    private java.lang.String status;
+	/**当前时间*/
+	@Excel(name = "当前时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "当前时间")
+    private java.util.Date logtime;
+	/**所属年*/
+	@Excel(name = "所属年", width = 15)
+    @ApiModelProperty(value = "所属年")
+    private java.lang.Integer year;
+	/**所属月*/
+	@Excel(name = "所属月", width = 15)
+    @ApiModelProperty(value = "所属月")
+    private java.lang.Integer month;
+	/**日期*/
+	@Excel(name = "日期", width = 15)
+    @ApiModelProperty(value = "日期")
+    private java.lang.String day;
+	/**时间*/
+	@Excel(name = "时间", width = 15)
+    @ApiModelProperty(value = "时间")
+    private java.lang.String time;
+	/**所属年月*/
+	@Excel(name = "所属年月", width = 15)
+    @ApiModelProperty(value = "所属年月")
+    private java.lang.String yearmonth;
+	/**所属周*/
+	@Excel(name = "所属周", width = 15)
+    @ApiModelProperty(value = "所属周")
+    private java.lang.Integer week;
+	/**周几*/
+	@Excel(name = "周几", width = 15)
+    @ApiModelProperty(value = "周几")
+    private java.lang.Integer dayofweek;
+
+    /**多少*/
+    @Excel(name = "多少")
+    @ApiModelProperty(value = "多少")
+    private Integer howmany;
+}

+ 22 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/mapper/EquipmentHealthMapper.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.equipmentHealth.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
+
+import java.util.List;
+
+/**
+ * @Description: 设备健康记录表
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+public interface EquipmentHealthMapper extends BaseMapper<EquipmentHealth> {
+
+    /**
+     * 汇总查询最近的状态
+     *
+     * @return 状态汇总
+     */
+    public List<EquipmentHealth> selectLastStatusGroup();
+}

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

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.equipmentHealth.mapper.EquipmentHealthMapper">
+
+    <resultMap type="org.jeecg.modules.equipmentHealth.entity.EquipmentHealth" id="EquipmentHealthResult">
+        <result property="id"    column="id"    />
+        <result property="equipmentid"    column="equipmentid"    />
+        <result property="equipmentname"    column="equipmentname"    />
+        <result property="status"    column="status"    />
+        <result property="logtime"    column="logtime"    />
+        <result property="year"    column="year"    />
+        <result property="month"    column="month"    />
+        <result property="day"    column="day"    />
+        <result property="time"    column="time"    />
+        <result property="yearmonth"    column="yearmonth"    />
+        <result property="week"    column="week"    />
+        <result property="dayofweek"    column="dayofweek"    />
+        <result property="howmany"    column="howmany"    />
+    </resultMap>
+
+    <!--汇总查询最近的状态-->
+    <select id="selectLastStatusGroup" resultMap="EquipmentHealthResult">
+        select c.status as status,count(*) as howmany
+        from (
+            select b.equipmentid,b.status
+            from (
+                select equipmentid,status,
+                    row_number() over(partition by equipmentid order by id desc) mm
+                from tpm_equipment_health
+            ) b
+            where mm=1
+        ) as c
+        group by c.status
+        order by c.status asc
+    </select>
+
+</mapper>

+ 22 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/service/IEquipmentHealthService.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.equipmentHealth.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
+
+import java.util.List;
+
+/**
+ * @Description: 设备健康记录表
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+public interface IEquipmentHealthService extends IService<EquipmentHealth> {
+
+    /**
+     * 汇总查询最近的状态
+     *
+     * @return 状态汇总
+     */
+    public List<EquipmentHealth> selectLastStatusGroup();
+}

+ 32 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealth/service/impl/EquipmentHealthServiceImpl.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.equipmentHealth.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
+import org.jeecg.modules.equipmentHealth.mapper.EquipmentHealthMapper;
+import org.jeecg.modules.equipmentHealth.service.IEquipmentHealthService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Description: 设备健康记录表
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Service
+public class EquipmentHealthServiceImpl extends ServiceImpl<EquipmentHealthMapper, EquipmentHealth> implements IEquipmentHealthService {
+
+    @Autowired
+    private EquipmentHealthMapper equipmentHealthMapper;
+    /**
+     * 汇总查询最近的状态
+     *
+     * @return 状态汇总
+     */
+    @Override
+    public List<EquipmentHealth> selectLastStatusGroup() {
+        return equipmentHealthMapper.selectLastStatusGroup();
+    }
+}

+ 196 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/controller/EquipmentHealthSectionController.java

@@ -0,0 +1,196 @@
+package org.jeecg.modules.equipmentHealthSection.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
+import org.jeecg.modules.equipmentHealthSection.service.IEquipmentHealthSectionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description: 设备健康时间段
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Api(tags="设备健康时间段")
+@RestController
+@RequestMapping("/EquipmentHealthSection/equipmentHealthSection")
+@Slf4j
+public class EquipmentHealthSectionController extends JeecgController<EquipmentHealthSection, IEquipmentHealthSectionService> {
+	@Autowired
+	private IEquipmentHealthSectionService equipmentHealthSectionService;
+
+	/**
+	 * 分页列表查询
+	 *
+	 * @param equipmentHealthSection
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "设备健康时间段-分页列表查询")
+	@ApiOperation(value="设备健康时间段-分页列表查询", notes="设备健康时间段-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<EquipmentHealthSection>> queryPageList(EquipmentHealthSection equipmentHealthSection,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<EquipmentHealthSection> queryWrapper = QueryGenerator.initQueryWrapper(equipmentHealthSection, req.getParameterMap());
+		Page<EquipmentHealthSection> page = new Page<EquipmentHealthSection>(pageNo, pageSize);
+		IPage<EquipmentHealthSection> pageList = equipmentHealthSectionService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+
+	/**
+	 *   添加
+	 *
+	 * @param equipmentHealthSection
+	 * @return
+	 */
+	@AutoLog(value = "设备健康时间段-添加")
+	@ApiOperation(value="设备健康时间段-添加", notes="设备健康时间段-添加")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health_section:add")
+	@PostMapping(value = "/add")
+	public Result<String> add(@RequestBody EquipmentHealthSection equipmentHealthSection) {
+		equipmentHealthSectionService.save(equipmentHealthSection);
+		return Result.OK("添加成功!");
+	}
+
+	/**
+	 *  编辑
+	 *
+	 * @param equipmentHealthSection
+	 * @return
+	 */
+	@AutoLog(value = "设备健康时间段-编辑")
+	@ApiOperation(value="设备健康时间段-编辑", notes="设备健康时间段-编辑")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health_section:edit")
+	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> edit(@RequestBody EquipmentHealthSection equipmentHealthSection) {
+		equipmentHealthSectionService.updateById(equipmentHealthSection);
+		return Result.OK("编辑成功!");
+	}
+
+	/**
+	 *   通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "设备健康时间段-通过id删除")
+	@ApiOperation(value="设备健康时间段-通过id删除", notes="设备健康时间段-通过id删除")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health_section:delete")
+	@DeleteMapping(value = "/delete")
+	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		equipmentHealthSectionService.removeById(id);
+		return Result.OK("删除成功!");
+	}
+
+	/**
+	 *  批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "设备健康时间段-批量删除")
+	@ApiOperation(value="设备健康时间段-批量删除", notes="设备健康时间段-批量删除")
+	//@RequiresPermissions("org.jeecg.modules:tpm_equipment_health_section:deleteBatch")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.equipmentHealthSectionService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.OK("批量删除成功!");
+	}
+
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	//@AutoLog(value = "设备健康时间段-通过id查询")
+	@ApiOperation(value="设备健康时间段-通过id查询", notes="设备健康时间段-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<EquipmentHealthSection> queryById(@RequestParam(name="id",required=true) String id) {
+		EquipmentHealthSection equipmentHealthSection = equipmentHealthSectionService.getById(id);
+		if(equipmentHealthSection==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(equipmentHealthSection);
+	}
+
+    /**
+    * 导出excel
+    *
+    * @param request
+    * @param equipmentHealthSection
+    */
+    //@RequiresPermissions("org.jeecg.modules:tpm_equipment_health_section:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, EquipmentHealthSection equipmentHealthSection) {
+        return super.exportXls(request, equipmentHealthSection, EquipmentHealthSection.class, "设备健康时间段");
+    }
+
+    /**
+      * 通过excel导入数据
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    //@RequiresPermissions("tpm_equipment_health_section:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, EquipmentHealthSection.class);
+    }
+
+	 /**
+	  * 按年度查询汇总查月状态时长汇总
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备健康时间段-按年度查询汇总查月状态时长汇总")
+	 @ApiOperation(value="设备健康时间段-按年度查询汇总查月状态时长汇总", notes="设备健康时间段-按年度查询汇总查月状态时长汇总")
+	 @GetMapping(value = "/statusgroup")
+	 public Result<List<EquipmentHealthSection>> selectStatusGroupByMonth(@RequestParam(name="year") String year) {
+	 	if (year.equals("") || year == null) {
+	 		year = DateUtils.getYear() + "";
+		}
+		 List<EquipmentHealthSection> healthList = equipmentHealthSectionService.selectStatusGroupByYear(year);
+		 return Result.OK(healthList);
+	 }
+
+	 /**
+	  * 按年度查询汇总查月状态时长汇总
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备健康时间段-按年月、状态分组查询")
+	 @ApiOperation(value="设备健康时间段-按年月、状态分组查询", notes="设备健康时间段-按年月、状态分组查询")
+	 @GetMapping(value = "/statusbyyearmonth")
+	 public Result<List<EquipmentHealthSection>> selectStatusByYearmonth(@RequestParam(name="yearmonth") String yearmonth) {
+		 if (yearmonth.equals("") || yearmonth == null) {
+			 yearmonth = DateUtils.formatDate(new Date(), "yyyy-MM");
+		 }
+		 List<EquipmentHealthSection> healthList = equipmentHealthSectionService.selectStatusByYearmonth(yearmonth);
+		 return Result.OK(healthList);
+	 }
+
+}

+ 121 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/entity/EquipmentHealthSection.java

@@ -0,0 +1,121 @@
+package org.jeecg.modules.equipmentHealthSection.entity;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @Description: 设备健康时间段
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Data
+@TableName("tpm_equipment_health_section")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="tpm_equipment_health_section对象", description="设备健康时间段")
+public class EquipmentHealthSection implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**设备运行状态时间段id*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "设备运行状态时间段id")
+    private java.lang.Integer id;
+	/**设备id*/
+	@Excel(name = "设备id", width = 15)
+    @ApiModelProperty(value = "设备id")
+    private java.lang.String equipmentid;
+	/**设备状态:1健康、2亚健康、3高危、4离线*/
+	@Excel(name = "设备状态:1健康、2亚健康、3高危、4离线", width = 15)
+    @ApiModelProperty(value = "设备状态:1健康、2亚健康、3高危、4离线")
+    private java.lang.String status;
+	/**开始时间*/
+	@Excel(name = "开始时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "开始时间")
+    private java.util.Date starttime;
+	/**结束时间*/
+	@Excel(name = "结束时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "结束时间")
+    private java.util.Date endtime;
+	/**时长(分钟)*/
+	@Excel(name = "时长(分钟)", width = 15)
+    @ApiModelProperty(value = "时长(分钟)")
+    private java.lang.Integer duration;
+	/**所属年*/
+	@Excel(name = "所属年", width = 15)
+    @ApiModelProperty(value = "所属年")
+    private java.lang.Integer year;
+	/**所属月*/
+	@Excel(name = "所属月", width = 15)
+    @ApiModelProperty(value = "所属月")
+    private java.lang.Integer month;
+	/**日期*/
+	@Excel(name = "日期", width = 15)
+    @ApiModelProperty(value = "日期")
+    private java.lang.String day;
+	/**时间*/
+	@Excel(name = "时间", width = 15)
+    @ApiModelProperty(value = "时间")
+    private java.lang.String time;
+	/**所属年月*/
+	@Excel(name = "所属年月", width = 15)
+    @ApiModelProperty(value = "所属年月")
+    private java.lang.String yearmonth;
+	/**所属周*/
+	@Excel(name = "所属周", width = 15)
+    @ApiModelProperty(value = "所属周")
+    private java.lang.Integer week;
+	/**周几*/
+	@Excel(name = "周几", width = 15)
+    @ApiModelProperty(value = "周几")
+    private java.lang.Integer dayofweek;
+
+
+
+
+    /**设备编号*/
+    @TableField(exist = false)
+    @ApiModelProperty(value = "设备编号")
+    private String equipmentcode;
+    /**设备名称*/
+    @TableField(exist = false)
+    @ApiModelProperty(value = "设备名称")
+    private String equipmentname;
+    /**健康时长(分钟)*/
+    @TableField(exist = false)
+    @ApiModelProperty(value = "健康时长(分钟)")
+    private Integer healthduration;
+    /**亚健康时长(分钟)*/
+    @TableField(exist = false)
+    @ApiModelProperty(value = "亚健康时长(分钟)")
+    private Integer subhealthduration;
+    /**不健康时长(分钟)*/
+    @TableField(exist = false)
+    @ApiModelProperty(value = "不健康时长(分钟)")
+    private Integer unhealthduration;
+    /**离线时长(分钟)*/
+    @TableField(exist = false)
+    @ApiModelProperty(value = "离线时长(分钟)")
+    private Integer offlineduration;
+    /**多少*/
+    @Excel(name = "多少")
+    @ApiModelProperty(value = "多少")
+    private Integer howmany;
+}

+ 37 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/EquipmentHealthSectionMapper.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.equipmentHealthSection.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
+
+import java.util.List;
+
+/**
+ * @Description: 设备健康时间段
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+public interface EquipmentHealthSectionMapper extends BaseMapper<EquipmentHealthSection> {
+
+    /**
+     * 按年度查询汇总查月状态时长汇总
+     * @param year 年度
+     * @return
+     */
+    public List<EquipmentHealthSection> selectStatusGroupByYear(@Param("year") String year);
+
+    /**
+     * 按年月、状态分组查询
+     * @param yearmonth 年月
+     * @return
+     */
+    public List<EquipmentHealthSection> selectStatusByYearmonth(@Param("yearmonth") String yearmonth);
+
+    /**
+     * 按日期、状态分组查询
+     * @param day 日期
+     * @return
+     */
+    public List<EquipmentHealthSection> selectStatusByDay(@Param("day") String day);
+}

+ 145 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/xml/EquipmentHealthSectionMapper.xml

@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.equipmentHealthSection.mapper.EquipmentHealthSectionMapper">
+
+    <resultMap type="org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection" id="EquipmentHealthSectionResult">
+        <result property="id"    column="id"    />
+        <result property="equipmentid"    column="equipmentid"    />
+        <result property="status"    column="status"    />
+        <result property="starttime"    column="starttime"    />
+        <result property="endtime"    column="endtime"    />
+        <result property="duration"    column="duration"    />
+        <result property="year"    column="year"    />
+        <result property="month"    column="month"    />
+        <result property="day"    column="day"    />
+        <result property="time"    column="time"    />
+        <result property="yearmonth"    column="yearmonth"    />
+        <result property="week"    column="week"    />
+        <result property="dayofweek"    column="dayofweek"    />
+
+        <result property="equipmentname"    column="equipmentname"    />
+        <result property="equipmentcode"    column="equipmentcode"    />
+        <result property="healthduration"    column="healthduration"    />
+        <result property="subhealthduration"    column="subhealthduration"    />
+        <result property="unhealthduration"    column="unhealthduration"    />
+        <result property="offlineduration"    column="offlineduration"    />
+    </resultMap>
+
+    <resultMap type="org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection" id="EquipmentResult">
+        <result property="equipmentid"    column="equipmentid"    />
+        <result property="status"    column="status"    />
+        <result property="duration"    column="duration"    />
+        <result property="month"    column="month"    />
+        <result property="day"    column="day"    />
+        <result property="time"    column="time"    />
+        <result property="yearmonth"    column="yearmonth"    />
+        <result property="week"    column="week"    />
+        <result property="dayofweek"    column="dayofweek"    />
+
+        <result property="howmany"    column="howmany"    />
+    </resultMap>
+
+    <!--按年度查询汇总查月状态时长汇总-->
+    <select id="selectStatusGroupByYear" resultMap="EquipmentHealthSectionResult">
+        select o.month, sum(o.duration) as duration,
+            sum( CASE o.status WHEN '1' THEN o.duration ELSE 0 END ) as healthduration,
+            sum( CASE o.status WHEN '2' THEN o.duration ELSE 0 END ) as subhealthduration,
+            sum( CASE o.status WHEN '3' THEN o.duration ELSE 0 END ) as unhealthduration,
+            sum( CASE o.status WHEN '4' THEN o.duration ELSE 0 END ) as offlineduration
+        from tpm_equipment_health_section as o
+				where o.year= #{year}
+        group by o.month
+        order by o.month asc
+    </select>
+
+    <!--按年月、状态分组查询-->
+    <select id="selectStatusByYearmonth" resultMap="EquipmentResult">
+        select cast(SUBSTR(o.day,9,10) as DECIMAL) as day,
+            sum(CASE o.status WHEN '1' THEN o.howmany ELSE 0 END ) as healthduration,
+            sum(CASE o.status WHEN '2' THEN o.howmany ELSE 0 END ) as subhealthduration,
+            sum(CASE o.status WHEN '3' THEN o.howmany ELSE 0 END ) as unhealthduration,
+            ((select count(*) from tpm_equipment) -sum(o.howmany)) as offlineduration
+        from (
+            select a.day,count(*) as howmany,status
+            from (
+                    select equipmentid,day,status
+                    from tpm_equipment_health_section
+                    where yearmonth=#{yearmonth} and status=3
+                    group by equipmentid,day,status
+            ) as a
+            group by a.day
+            union
+            select a.day,count(*) as howmany,status
+            from (
+                    select equipmentid,day,status
+                    from tpm_equipment_health_section as s
+                    where yearmonth=#{yearmonth} and status=2 and equipmentid not in (
+                            select equipmentid
+                            from tpm_equipment_health_section
+                            where yearmonth=s.yearmonth and status=3 and s.day=day
+                    )
+                    group by equipmentid,day,status
+            ) as a
+            group by a.day
+            union
+            select a.day,count(*) as howmany,status
+            from (
+                    select equipmentid,day,status
+                    from tpm_equipment_health_section as s
+                    where yearmonth=#{yearmonth} and status=1 and equipmentid not in (
+                            select equipmentid
+                            from tpm_equipment_health_section
+                            where yearmonth=s.yearmonth and status in (2,3) and s.day=day
+                    )
+                    group by equipmentid,day,status
+            ) as a
+            group by a.day
+        ) as o
+        group by o.day
+        order by o.day asc
+    </select>
+
+
+    <!--按日期、状态分组查询-->
+    <select id="selectStatusByDay" resultMap="EquipmentResult">
+        select o.day,
+            sum(CASE o.status WHEN '1' THEN o.howmany ELSE 0 END ) as healthduration,
+            sum(CASE o.status WHEN '2' THEN o.howmany ELSE 0 END ) as subhealthduration,
+            sum(CASE o.status WHEN '3' THEN o.howmany ELSE 0 END ) as unhealthduration,
+            ((select count(*) from tpm_equipment) -sum(o.howmany)) as offlineduration
+        from (
+            select a.day,count(*) as howmany,status
+            from (
+                    select equipmentid,day,status
+                    from tpm_equipment_health_section
+                    where day=#{day} and status=3
+                    group by equipmentid,day,status
+            ) as a
+            union
+            select a.day,count(*) as howmany,status
+            from (
+                    select equipmentid,day,status
+                    from tpm_equipment_health_section as s
+                    where day=#{day} and status=2 and equipmentid not in (
+                            select equipmentid
+                            from tpm_equipment_health_section
+                            where status=3 and s.day=day
+                    )
+                    group by equipmentid,day,status
+            ) as a
+            union
+            select a.day,count(*) as howmany,status
+            from (
+                    select equipmentid,day,status
+                    from tpm_equipment_health_section as s
+                    where day=#{day} and status=1 and equipmentid not in (
+                            select equipmentid
+                            from tpm_equipment_health_section
+                            where status in (2,3) and s.day=day
+                    )
+                    group by equipmentid,day,status
+            ) as a
+        ) as o
+    </select>
+
+</mapper>

+ 29 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/service/IEquipmentHealthSectionService.java

@@ -0,0 +1,29 @@
+package org.jeecg.modules.equipmentHealthSection.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
+
+import java.util.List;
+
+/**
+ * @Description: 设备健康时间段
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+public interface IEquipmentHealthSectionService extends IService<EquipmentHealthSection> {
+
+    /**
+     * 按年度查询汇总查月状态时长汇总
+     *
+     * @return 状态汇总
+     */
+    public List<EquipmentHealthSection> selectStatusGroupByYear(String year);
+
+    /**
+     * 按年月、状态分组查询
+     *
+     * @return 状态汇总
+     */
+    public List<EquipmentHealthSection> selectStatusByYearmonth(String yearmonth);
+}

+ 77 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/service/impl/EquipmentHealthSectionServiceImpl.java

@@ -0,0 +1,77 @@
+package org.jeecg.modules.equipmentHealthSection.service.impl;
+
+import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
+import org.jeecg.modules.equipmentHealth.mapper.EquipmentHealthMapper;
+import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
+import org.jeecg.modules.equipmentHealthSection.mapper.EquipmentHealthSectionMapper;
+import org.jeecg.modules.equipmentHealthSection.service.IEquipmentHealthSectionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.time.YearMonth;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 设备健康时间段
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Service
+public class EquipmentHealthSectionServiceImpl extends ServiceImpl<EquipmentHealthSectionMapper, EquipmentHealthSection> implements IEquipmentHealthSectionService {
+
+    @Autowired
+    private EquipmentHealthSectionMapper equipmentHealthSectionMapper;
+
+    /**
+     * 按年度查询汇总查月状态时长汇总
+     *
+     * year 年
+     * @return 状态汇总
+     */
+    @Override
+    public List<EquipmentHealthSection> selectStatusGroupByYear(String year) {
+        return equipmentHealthSectionMapper.selectStatusGroupByYear(year);
+    }
+
+    /**
+     * 按年月、状态分组查询
+     *
+     * @return 状态汇总
+     */
+    @Override
+    public List<EquipmentHealthSection> selectStatusByYearmonth(String yearmonth) {
+        String year = yearmonth.substring(0, 4);
+        String month = yearmonth.substring(5, 7);
+        int dayAccount = YearMonth.of(Integer.parseInt(year), Integer.parseInt(month)).lengthOfMonth();
+        List<Integer> days = new ArrayList<>();
+
+        // 按年月、状态分组查询
+        List<EquipmentHealthSection> monthList = equipmentHealthSectionMapper.selectStatusByYearmonth(yearmonth);
+        List<EquipmentHealthSection> monthSectionList = new ArrayList<>();
+        for (int i = 1; i<=dayAccount; i++) {
+            days.add(i);
+            String rows = i + "";
+            List<EquipmentHealthSection> subList = monthList.stream().filter(p->p.getDay().equals(rows)).collect(Collectors.toList());
+            if (subList != null && subList.size() > 0) {
+                monthSectionList.add(subList.get(0));
+            }
+            else {
+                EquipmentHealthSection section = new EquipmentHealthSection();
+                section.setDay(i + "");
+                section.setHealthduration(0);
+                section.setSubhealthduration(0);
+                section.setUnhealthduration(0);
+                section.setOfflineduration(0);
+
+                monthSectionList.add(section);
+            }
+        }
+
+        return monthSectionList;
+    }
+}

+ 42 - 0
module_tpm/src/main/java/org/jeecg/modules/healthStatistics/controller/HealthStatisticsController.java

@@ -0,0 +1,42 @@
+package org.jeecg.modules.healthStatistics.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.healthStatistics.service.IHealthStatisticsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description: 设备健康统计
+ * @Author: jeecg-boot
+ * @Date:   2024-12-03
+ * @Version: V1.0
+ */
+@Api(tags="设备健康统计")
+@RestController
+@RequestMapping("/healthStatistics/healthStatistics")
+@Slf4j
+public class HealthStatisticsController {
+    @Autowired
+    private IHealthStatisticsService healthStatisticsService;
+
+    /**
+     * 健康概况
+     *
+     * @return
+     */
+    //@AutoLog(value = "设备健康统计-健康概况")
+    @ApiOperation(value="设备健康统计-健康概况", notes="设备健康统计-健康概况")
+    @GetMapping(value = "/dashboard")
+    public Result dashboardStatistics() {
+//        String day = DateUtils.formatDate();
+        String day="2024-10-01";
+        Result rtn = healthStatisticsService.DashboardStatistics(day);
+        return rtn;
+    }
+
+}

+ 15 - 0
module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/IHealthStatisticsService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.healthStatistics.service;
+
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * 设备健康统计报表
+ */
+public interface IHealthStatisticsService {
+    /**
+     *
+     * @param day
+     * @return
+     */
+    public Result DashboardStatistics(String day);
+}

+ 109 - 0
module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/Impl/HealthStatisticsServiceImpl.java

@@ -0,0 +1,109 @@
+package org.jeecg.modules.healthStatistics.service.Impl;
+
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
+import org.jeecg.modules.equipmentHealth.mapper.EquipmentHealthMapper;
+import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
+import org.jeecg.modules.equipmentHealthSection.mapper.EquipmentHealthSectionMapper;
+import org.jeecg.modules.healthStatistics.service.IHealthStatisticsService;
+import org.jeecg.modules.tpmMessageAlarm.mapper.TpmMessageAlarmMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.ParseException;
+import java.time.YearMonth;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class HealthStatisticsServiceImpl implements IHealthStatisticsService {
+
+    @Autowired
+    private EquipmentHealthMapper equipmentHealthMapper;
+
+    @Autowired
+    private EquipmentHealthSectionMapper equipmentHealthSectionMapper;
+
+    /**
+     * 健康概况信息获取
+     * @param day
+     * @return
+     */
+    @Override
+    public Result DashboardStatistics(String day) {
+        String year = day.substring(0, 4);
+        String yearmonth = day.substring(0, 7);
+        String month = day.substring(5, 7);
+        int dayAccount = YearMonth.of(Integer.parseInt(year), Integer.parseInt(month)).lengthOfMonth();
+        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();
+        }
+
+        // 年度查询汇总查月状态时长汇总
+        List<EquipmentHealthSection> yearList = equipmentHealthSectionMapper.selectStatusGroupByYear(year);
+        List<EquipmentHealthSection> yearSectionList = new ArrayList<>();
+        for (int i = 1; i <= 12; i++) {
+            int rows = i;
+            List<EquipmentHealthSection> subList = yearList.stream().filter(p->p.getMonth().equals(rows)).collect(Collectors.toList());
+            if (subList != null && subList.size() > 0) {
+                int day111 = YearMonth.of(Integer.parseInt(year), i).lengthOfMonth();
+                EquipmentHealthSection section = subList.get(0);
+                int offline = day111 * equipnum * 24 - (section.getHealthduration() + section.getUnhealthduration() + section.getOfflineduration()) / 60;
+                section.setHealthduration(section.getHealthduration() / 60 / 24);
+                section.setSubhealthduration(section.getSubhealthduration() / 60 / 24);
+                section.setUnhealthduration(section.getUnhealthduration() / 60 / 24);
+                section.setOfflineduration(offline / 24);
+                yearSectionList.add(section);
+            }
+            else {
+                EquipmentHealthSection section = new EquipmentHealthSection();
+                section.setMonth(i);
+                section.setHealthduration(0);
+                section.setSubhealthduration(0);
+                section.setUnhealthduration(0);
+                section.setOfflineduration(0);
+
+                yearSectionList.add(section);
+            }
+        }
+        // 按年月、状态分组查询
+        List<EquipmentHealthSection> monthList = equipmentHealthSectionMapper.selectStatusByYearmonth(yearmonth);
+        List<EquipmentHealthSection> monthSectionList = new ArrayList<>();
+        for (int i = 1; i<=dayAccount; i++) {
+            days.add(i);
+            String rows = i + "";
+            List<EquipmentHealthSection> subList = monthList.stream().filter(p->p.getDay().equals(rows)).collect(Collectors.toList());
+            if (subList != null && subList.size() > 0) {
+                monthSectionList.add(subList.get(0));
+            }
+            else {
+                EquipmentHealthSection section = new EquipmentHealthSection();
+                section.setDay(i + "");
+                section.setHealthduration(0);
+                section.setSubhealthduration(0);
+                section.setUnhealthduration(0);
+                section.setOfflineduration(0);
+
+                monthSectionList.add(section);
+            }
+        }
+//        // 按日期、状态、设备分组查询
+//        List<EquipmentHealthSection> daySectionList = equipmentHealthSectionMapper.selectStatusByDay(day);
+
+        HashMap map = new HashMap();
+        map.put("healthList", healthList);
+        map.put("yearSectionList", yearSectionList);
+        map.put("monthSectionList", monthSectionList);
+        map.put("days", days);
+
+        return Result.OK(map);
+    }
+}