Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

LLL 11 mēneši atpakaļ
vecāks
revīzija
7d0e63ea25
15 mainītis faili ar 739 papildinājumiem un 2 dzēšanām
  1. 7 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockDetailHistoryMapper.java
  2. 25 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockSummaryHistoryMapper.java
  3. 4 2
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockDetailHistoryMapper.xml
  4. 74 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockSummaryHistoryMapper.xml
  5. 8 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockDetailHistoryService.java
  6. 26 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockSummaryHistoryService.java
  7. 10 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java
  8. 43 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockSummaryHistoryServiceImpl.java
  9. 177 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/controller/InterlockCountController.java
  10. 75 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/entity/InterlockCount.java
  11. 17 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/mapper/InterlockCountMapper.java
  12. 5 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/mapper/xml/InterlockCountMapper.xml
  13. 14 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/service/IInterlockCountService.java
  14. 19 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/service/impl/InterlockCountServiceImpl.java
  15. 235 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockjob/DayStatisticsJob.java

+ 7 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockDetailHistoryMapper.java

@@ -35,4 +35,11 @@ public interface InterlockDetailHistoryMapper extends BaseMapper<InterlockDetail
      */
     List<InterlockSummaryHistoryVO> getForExport(InterlockHistoryQueryDTO dto);
 
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 日统计 仪表状态(根据联锁id查询对应时间下的联锁条件)
+     *   date: 2024/6/18
+     */
+    List<InterlockDetailHistory> getYbStatusListBySummaryIdAndTagTime(@Param("id") String id,@Param("yesterday") String yesterday);
 }

+ 25 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockSummaryHistoryMapper.java

@@ -7,6 +7,7 @@ import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
 import org.jeecg.modules.history.entity.InterlockSummaryHistory;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.history.vo.InterlockHistoryDistinctZZXTVO;
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
 import org.jeecg.modules.summary.entity.InterlockSummary;
 import org.jeecg.modules.summary.vo.InterlockSummaryVO;
 
@@ -28,4 +29,28 @@ public interface InterlockSummaryHistoryMapper extends BaseMapper<InterlockSumma
      * */
     Integer cocuntTYOrHL(InterlockHistoryQueryDTO dto);
 
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 按日统计 健康等级
+    *   date: 2024/6/17
+    */
+    List<InterlockCount> getLoopHealthLevelByTagTime(@Param("yesterday") String yesterday);
+
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 按日统计 投用状态(投用率)
+     *   date: 2024/6/17
+     */
+    List<InterlockCount> getInterlockStatusByTagTime(@Param("yesterday") String yesterday);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des:按日统计 仪表状态(查询系统下的所有联锁)
+    *   date: 2024/6/18
+    */
+    List<InterlockCount> getYbStatusListByTagTime(@Param("yesterday") String yesterday);
 }

+ 4 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockDetailHistoryMapper.xml

@@ -68,8 +68,10 @@
         order by s.create_time desc, s.tag_time desc
     </select>
 
-
-
+    <!-- 日统计 仪表状态(根据联锁id查询对应时间下的联锁条件) -->
+    <select id="getYbStatusListBySummaryIdAndTagTime" resultType="org.jeecg.modules.history.entity.InterlockDetailHistory">
+        select * from interlock_detail_history where interlock_system_id = #{id} and tag_time = #{yesterday}
+    </select>
 
 
 </mapper>

+ 74 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockSummaryHistoryMapper.xml

@@ -52,4 +52,78 @@
             </if>
         </where>
     </select>
+
+    <!-- 按日统计 健康等级 -->
+    <select id="getLoopHealthLevelByTagTime" resultType="org.jeecg.modules.interlockCount.entity.InterlockCount">
+        SELECT
+            h.interlock_system_id as interlock_system_id,
+            b.interlock_name as interlock_name,
+            h.loop_health_level as count_name,
+            COUNT( h.* ) AS count_num,
+            '0' as count_type,
+            '10' as time_type,
+            #{yesterday} as day
+        FROM
+            interlock_summary_history h
+            left join interlock_base b
+            on h.interlock_system_id = b.id
+        WHERE
+            h.tag_time LIKE #{yesterday} || '%'
+        GROUP BY
+            h.interlock_system_id,
+            b.interlock_name,
+            h.loop_health_level
+        ORDER BY
+            h.interlock_system_id
+    </select>
+
+    <!-- 按日统计 投用状态(投用率) -->
+    <select id="getInterlockStatusByTagTime" resultType="org.jeecg.modules.interlockCount.entity.InterlockCount">
+        SELECT
+            h.interlock_system_id as interlock_system_id,
+            b.interlock_name as interlock_name,
+            h.interlock_status as count_name,
+            COUNT( h.* ) AS count_num,
+            '1' as count_type,
+            '10' as time_type,
+            #{yesterday} as day
+        FROM
+            "interlock_summary_history" h
+            left join interlock_base b
+        on h.interlock_system_id = b.id
+        WHERE
+            h.tag_time like #{yesterday} || '%'
+        GROUP BY
+            h.interlock_system_id,
+            b.interlock_name,
+            h.interlock_status
+        ORDER BY
+            h.interlock_system_id
+    </select>
+
+    <!-- 按日统计 仪表状态(查询系统下的所有联锁) -->
+    <select id="getYbStatusListByTagTime" resultType="org.jeecg.modules.interlockCount.entity.InterlockCount">
+        SELECT
+            h.interlock_system_id as interlock_system_id,
+            b.interlock_name as interlock_name,
+            h.id as id,
+            h.interlock_name as lockname,
+            '3' as count_type,
+            '10' as time_type,
+            #{yesterday} as day
+        FROM
+            "interlock_summary_history" h
+            left join interlock_base b
+        on h.interlock_system_id = b.id
+        WHERE
+            h.tag_time like #{yesterday} || '%'
+        GROUP BY
+            h.interlock_system_id,
+            b.interlock_name,
+            h.id,
+            h.interlock_name
+        ORDER BY
+            h.interlock_system_id
+
+    </select>
 </mapper>

+ 8 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockDetailHistoryService.java

@@ -47,4 +47,12 @@ public interface IInterlockDetailHistoryService extends IService<InterlockDetail
      */
     public Integer exportXlsToFile(InterlockHistoryQueryDTO dto, Class<InterlockSummaryHistoryVO> clazz, String title, String filePath) throws IOException;
 
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 日统计 仪表状态(根据联锁id查询对应时间下的联锁条件)
+    *   date: 2024/6/18
+    */
+    List<InterlockDetailHistory> getYbStatusListBySummaryIdAndTagTime(String id, String yesterday);
 }

+ 26 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockSummaryHistoryService.java

@@ -2,6 +2,9 @@ package org.jeecg.modules.history.service;
 
 import org.jeecg.modules.history.entity.InterlockSummaryHistory;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+
+import java.util.List;
 
 /**
  * @Description: 联锁总历史数据表
@@ -11,4 +14,27 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IInterlockSummaryHistoryService extends IService<InterlockSummaryHistory> {
 
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 按日统计 健康等级
+    *   date: 2024/6/17
+    */
+    List<InterlockCount> getLoopHealthLevelByTagTime(String yesterday);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 按日统计 投用状态(投用率)
+    *   date: 2024/6/17
+    */
+    List<InterlockCount> getInterlockStatusByTagTime(String yesterday);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 按日统计 仪表状态(查询系统下的所有联锁)
+    *   date: 2024/6/18
+    */
+    List<InterlockCount> getYbStatusListByTagTime(String yesterday);
 }

+ 10 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java

@@ -383,4 +383,14 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
         return vo;
     }
 
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 日统计 仪表状态(根据联锁id查询对应时间下的联锁条件)
+     *   date: 2024/6/18
+     */
+    @Override
+    public List<InterlockDetailHistory> getYbStatusListBySummaryIdAndTagTime(String id, String yesterday) {
+        return interlockDetailHistoryMapper.getYbStatusListBySummaryIdAndTagTime(id,yesterday);
+    }
 }

+ 43 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockSummaryHistoryServiceImpl.java

@@ -3,10 +3,14 @@ package org.jeecg.modules.history.service.impl;
 import org.jeecg.modules.history.entity.InterlockSummaryHistory;
 import org.jeecg.modules.history.mapper.InterlockSummaryHistoryMapper;
 import org.jeecg.modules.history.service.IInterlockSummaryHistoryService;
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.List;
+
 /**
  * @Description: 联锁总历史数据表
  * @Author: jeecg-boot
@@ -16,4 +20,43 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class InterlockSummaryHistoryServiceImpl extends ServiceImpl<InterlockSummaryHistoryMapper, InterlockSummaryHistory> implements IInterlockSummaryHistoryService {
 
+    @Autowired
+    @SuppressWarnings("all")
+    private InterlockSummaryHistoryMapper mapper;
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 按日统计 健康等级
+    *   date: 2024/6/17
+    */
+
+    @Override
+    public List<InterlockCount> getLoopHealthLevelByTagTime(String yesterday) {
+        return mapper.getLoopHealthLevelByTagTime(yesterday);
+    }
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 按日统计 投用状态(投用率)
+     *   date: 2024/6/17
+     */
+
+    @Override
+    public List<InterlockCount> getInterlockStatusByTagTime(String yesterday) {
+        return mapper.getInterlockStatusByTagTime(yesterday);
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 按日统计 仪表状态(查询系统下的所有联锁)
+    *   date: 2024/6/18
+    */
+
+    @Override
+    public List<InterlockCount> getYbStatusListByTagTime(String yesterday) {
+        return mapper.getYbStatusListByTagTime(yesterday);
+    }
 }

+ 177 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/controller/InterlockCountController.java

@@ -0,0 +1,177 @@
+package org.jeecg.modules.interlockCount.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+import org.jeecg.modules.interlockCount.service.IInterlockCountService;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.jeecg.common.aspect.annotation.AutoLog;
+
+ /**
+ * @Description: 联锁统计表
+ * @Author: jeecg-boot
+ * @Date:   2024-06-17
+ * @Version: V1.0
+ */
+@Api(tags="联锁统计表")
+@RestController
+@RequestMapping("/interlockCount/interlockCount")
+@Slf4j
+public class InterlockCountController extends JeecgController<InterlockCount, IInterlockCountService> {
+	@Autowired
+	private IInterlockCountService interlockCountService;
+	
+	/**
+	 * 分页列表查询
+	 *
+	 * @param interlockCount
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "联锁统计表-分页列表查询")
+	@ApiOperation(value="联锁统计表-分页列表查询", notes="联锁统计表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<InterlockCount>> queryPageList(InterlockCount interlockCount,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<InterlockCount> queryWrapper = QueryGenerator.initQueryWrapper(interlockCount, req.getParameterMap());
+		Page<InterlockCount> page = new Page<InterlockCount>(pageNo, pageSize);
+		IPage<InterlockCount> pageList = interlockCountService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+	
+	/**
+	 *   添加
+	 *
+	 * @param interlockCount
+	 * @return
+	 */
+	@AutoLog(value = "联锁统计表-添加")
+	@ApiOperation(value="联锁统计表-添加", notes="联锁统计表-添加")
+	//@RequiresPermissions("org.jeecg.modules:interlock_count:add")
+	@PostMapping(value = "/add")
+	public Result<String> add(@RequestBody InterlockCount interlockCount) {
+		interlockCountService.save(interlockCount);
+		return Result.OK("添加成功!");
+	}
+	
+	/**
+	 *  编辑
+	 *
+	 * @param interlockCount
+	 * @return
+	 */
+	@AutoLog(value = "联锁统计表-编辑")
+	@ApiOperation(value="联锁统计表-编辑", notes="联锁统计表-编辑")
+	//@RequiresPermissions("org.jeecg.modules:interlock_count:edit")
+	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> edit(@RequestBody InterlockCount interlockCount) {
+		interlockCountService.updateById(interlockCount);
+		return Result.OK("编辑成功!");
+	}
+	
+	/**
+	 *   通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "联锁统计表-通过id删除")
+	@ApiOperation(value="联锁统计表-通过id删除", notes="联锁统计表-通过id删除")
+	//@RequiresPermissions("org.jeecg.modules:interlock_count:delete")
+	@DeleteMapping(value = "/delete")
+	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		interlockCountService.removeById(id);
+		return Result.OK("删除成功!");
+	}
+	
+	/**
+	 *  批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "联锁统计表-批量删除")
+	@ApiOperation(value="联锁统计表-批量删除", notes="联锁统计表-批量删除")
+	//@RequiresPermissions("org.jeecg.modules:interlock_count:deleteBatch")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.interlockCountService.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<InterlockCount> queryById(@RequestParam(name="id",required=true) String id) {
+		InterlockCount interlockCount = interlockCountService.getById(id);
+		if(interlockCount==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(interlockCount);
+	}
+
+    /**
+    * 导出excel
+    *
+    * @param request
+    * @param interlockCount
+    */
+    //@RequiresPermissions("org.jeecg.modules:interlock_count:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, InterlockCount interlockCount) {
+        return super.exportXls(request, interlockCount, InterlockCount.class, "联锁统计表");
+    }
+
+    /**
+      * 通过excel导入数据
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    //@RequiresPermissions("interlock_count:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, InterlockCount.class);
+    }
+
+}

+ 75 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/entity/InterlockCount.java

@@ -0,0 +1,75 @@
+package org.jeecg.modules.interlockCount.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-06-17
+ * @Version: V1.0
+ */
+@Data
+@TableName("interlock_count")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="interlock_count对象", description="联锁统计表")
+public class InterlockCount implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**主键*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private java.lang.String id;
+	/**系统id*/
+	@Excel(name = "系统id", width = 15)
+    @ApiModelProperty(value = "系统id")
+    private java.lang.String interlockSystemId;
+	/**系统名称*/
+	@Excel(name = "系统名称", width = 15)
+    @ApiModelProperty(value = "系统名称")
+    private java.lang.String interlockName;
+	/**统计名称(健康等级0/联锁状态1/投用率2/仪表状态3/系统状态4)*/
+	@Excel(name = "统计名称(健康等级0/联锁状态1/投用率2/仪表状态3/系统状态4)", width = 15)
+    @ApiModelProperty(value = "统计名称(健康等级0/联锁状态1/投用率2/仪表状态3/系统状态4)")
+    private java.lang.String countName;
+	/**统计数量*/
+	@Excel(name = "统计数量", width = 15)
+    @ApiModelProperty(value = "统计数量")
+    private java.lang.String countNum;
+	/**统计类型(健康等级/仪表状态/投用率)*/
+	@Excel(name = "统计类型(健康等级0/联锁状态1/投用率2/仪表状态3/系统状态4)", width = 15)
+    @ApiModelProperty(value = "统计类型(健康等级0/联锁状态1/投用率2/仪表状态3/系统状态4)")
+    private java.lang.String countType;
+	/**统计时间类型(按天/按月/按年)*/
+	@Excel(name = "统计时间类型(按天/按月/按年)", width = 15)
+    @ApiModelProperty(value = "统计时间类型(按天/按月/按年)")
+    private java.lang.String timeType;
+    /**按日统计的时间*/
+    @Excel(name = "按日统计的时间", width = 15)
+    @ApiModelProperty(value = "按日统计的时间")
+    private java.lang.String day;
+	/**按月统计的时间*/
+	@Excel(name = "按月统计的时间", width = 15)
+    @ApiModelProperty(value = "按月统计的时间")
+    private java.lang.String yearmonth;
+	/**按年统计的时间*/
+	@Excel(name = "按年统计的时间", width = 15)
+    @ApiModelProperty(value = "按年统计的时间")
+    private java.lang.String year;
+}

+ 17 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/mapper/InterlockCountMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.interlockCount.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: 联锁统计表
+ * @Author: jeecg-boot
+ * @Date:   2024-06-17
+ * @Version: V1.0
+ */
+public interface InterlockCountMapper extends BaseMapper<InterlockCount> {
+
+}

+ 5 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/mapper/xml/InterlockCountMapper.xml

@@ -0,0 +1,5 @@
+<?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.interlockCount.mapper.InterlockCountMapper">
+
+</mapper>

+ 14 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/service/IInterlockCountService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.interlockCount.service;
+
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 联锁统计表
+ * @Author: jeecg-boot
+ * @Date:   2024-06-17
+ * @Version: V1.0
+ */
+public interface IInterlockCountService extends IService<InterlockCount> {
+
+}

+ 19 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockCount/service/impl/InterlockCountServiceImpl.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.interlockCount.service.impl;
+
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+import org.jeecg.modules.interlockCount.mapper.InterlockCountMapper;
+import org.jeecg.modules.interlockCount.service.IInterlockCountService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: 联锁统计表
+ * @Author: jeecg-boot
+ * @Date:   2024-06-17
+ * @Version: V1.0
+ */
+@Service
+public class InterlockCountServiceImpl extends ServiceImpl<InterlockCountMapper, InterlockCount> implements IInterlockCountService {
+
+}

+ 235 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockjob/DayStatisticsJob.java

@@ -0,0 +1,235 @@
+package org.jeecg.modules.interlockjob;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.history.entity.InterlockDetailHistory;
+import org.jeecg.modules.history.entity.InterlockSummaryHistory;
+import org.jeecg.modules.history.service.IInterlockDetailHistoryService;
+import org.jeecg.modules.history.service.IInterlockSummaryHistoryService;
+import org.jeecg.modules.interlockCount.entity.InterlockCount;
+import org.jeecg.modules.interlockCount.service.IInterlockCountService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @author dzc
+ * @date 2024/6/14 10:00
+ * @package org.jeecg.modules.jod
+ * @project interlock_server
+ * @des   联锁 健康等级 仪表状态 投用率 日统计的定时任务
+ */
+@Component
+@Slf4j
+public class DayStatisticsJob implements Job {
+
+    @Autowired
+    @SuppressWarnings("all")
+    private IInterlockSummaryHistoryService summaryHistoryService;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private IInterlockCountService countService;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private IInterlockDetailHistoryService detailHistoryService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        // 日统计的定时任务  统计 每个系统下的每个联锁 健康等级(A/B/C/D)、联锁状态,每个联锁条件的仪表状态 的个数
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        String currentDay = DateUtils.getDate("yyyy-MM-dd");  // 当前日期
+        LocalDate yesterDate = LocalDate.now().minusDays(1);  // 当前 00:00:00 执行定时任务 减一天获取昨天的日期
+        //String yesterday = yesterDate.format(formatter); // 昨天的日期
+        String yesterday = "2024-06-12"; // 昨天的日期
+
+        // 统计健康等级 count_type = 0
+        List<InterlockCount> loopHealthLevelList = summaryHistoryService.getLoopHealthLevelByTagTime(yesterday);
+
+        HashMap<String, List<InterlockCount>> loopHealthLevelMap = new HashMap<>();
+        for (InterlockCount item:loopHealthLevelList) {
+            if (loopHealthLevelMap.containsKey(item.getInterlockSystemId())){
+                loopHealthLevelMap.get(item.getInterlockSystemId()).add(item);
+            }else {
+                ArrayList<InterlockCount> countList = new ArrayList<>();
+                countList.add(item);
+                loopHealthLevelMap.put(item.getInterlockSystemId(),countList);
+            }
+        }
+
+        ArrayList<InterlockCount> loopHealthLevelResultList = new ArrayList<>();
+        ArrayList<String> djList = new ArrayList<>();
+        djList.add("A");
+        djList.add("B");
+        djList.add("C");
+        djList.add("D");
+        for (String key:loopHealthLevelMap.keySet()){
+            List<InterlockCount> sonList = loopHealthLevelMap.get(key);
+            if (sonList.size() != 4){
+                ArrayList<String> jkdjList = new ArrayList<>();
+                for (InterlockCount son : sonList) {
+                    jkdjList.add(son.getCountName());
+                }
+                List<String> difference = djList.stream()
+                        .filter(item -> !jkdjList.contains(item))
+                        .collect(Collectors.toList());
+                for (String d:difference) {
+                    InterlockCount interlockCount = new InterlockCount();
+                    interlockCount.setInterlockSystemId(key);
+                    interlockCount.setInterlockName(sonList.get(0).getInterlockName());
+                    interlockCount.setCountName(d);
+                    interlockCount.setCountNum("0");
+                    interlockCount.setCountType("0");
+                    interlockCount.setTimeType("10");
+                    interlockCount.setDay(yesterday);
+                    sonList.add(interlockCount);
+                }
+            }
+            loopHealthLevelResultList.addAll(sonList);
+        }
+
+        // 批量保存健康等级
+        //countService.saveBatch(loopHealthLevelResultList);
+
+        // 统计联锁状态(投用/未投用)  count_type = 1
+        List<InterlockCount> interlockStatusList = summaryHistoryService.getInterlockStatusByTagTime(yesterday);
+
+        HashMap<String, List<InterlockCount>> interlockStatusMap = new HashMap<>();
+        for (InterlockCount item:interlockStatusList) {
+            if (interlockStatusMap.containsKey(item.getInterlockSystemId())){
+                interlockStatusMap.get(item.getInterlockSystemId()).add(item);
+            }else {
+                ArrayList<InterlockCount> countList = new ArrayList<>();
+                countList.add(item);
+                interlockStatusMap.put(item.getInterlockSystemId(),countList);
+            }
+        }
+
+        ArrayList<InterlockCount> interlockStatusResultList = new ArrayList<>();
+        ArrayList<String> lsList = new ArrayList<>();
+        lsList.add("0");
+        lsList.add("1");
+        for (String key:interlockStatusMap.keySet()){
+            List<InterlockCount> sonList = interlockStatusMap.get(key);
+            if (sonList.size() != 4){
+                ArrayList<String> lsStatusList = new ArrayList<>();
+                for (InterlockCount son : sonList) {
+                    lsStatusList.add(son.getCountName());
+                }
+                List<String> difference = lsList.stream()
+                        .filter(item -> !lsStatusList.contains(item))
+                        .collect(Collectors.toList());
+                for (String d:difference) {
+                    InterlockCount interlockCount = new InterlockCount();
+                    interlockCount.setInterlockSystemId(key);
+                    interlockCount.setInterlockName(sonList.get(0).getInterlockName());
+                    interlockCount.setCountName(d);
+                    interlockCount.setCountNum("0");
+                    interlockCount.setCountType("1");
+                    interlockCount.setTimeType("10");
+                    interlockCount.setDay(yesterday);
+                    sonList.add(interlockCount);
+                }
+            }
+            interlockStatusResultList.addAll(sonList);
+        }
+
+        //countService.saveBatch(interlockStatusResultList);
+
+        // 统计投用率  count_type = 2
+        ArrayList<InterlockCount> tylResultList = new ArrayList<>();
+
+        HashMap<String, List<InterlockCount>> tylMap = new HashMap<>();
+        for (InterlockCount item:interlockStatusResultList) {
+            if (tylMap.containsKey(item.getInterlockSystemId())){
+                tylMap.get(item.getInterlockSystemId()).add(item);
+            }else {
+                ArrayList<InterlockCount> countList = new ArrayList<>();
+                countList.add(item);
+                tylMap.put(item.getInterlockSystemId(),countList);
+            }
+        }
+
+        for (String key:tylMap.keySet()) {
+            List<InterlockCount> sonList = tylMap.get(key);
+            BigDecimal yty = BigDecimal.valueOf(0);
+            BigDecimal wty = BigDecimal.valueOf(0);
+            BigDecimal tyl = BigDecimal.valueOf(0);
+            for (InterlockCount son:sonList) {
+                if ("0".equals(son.getCountName())){
+                    wty = wty.add(new BigDecimal(son.getCountNum()));
+                }
+                if ("1".equals(son.getCountName())){
+                    yty = yty.add(new BigDecimal(son.getCountNum()));
+                }
+            }
+            BigDecimal total = yty.add(wty);
+            if ((total.compareTo(BigDecimal.valueOf(0)) != 0)){
+                tyl = yty.divide(total,2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+            }
+            InterlockCount interlockCount = new InterlockCount();
+            interlockCount.setInterlockSystemId(key);
+            interlockCount.setInterlockName(sonList.get(0).getInterlockName());
+            interlockCount.setCountName("投用率");
+            interlockCount.setCountNum(String.valueOf(tyl));
+            interlockCount.setCountType("2");
+            interlockCount.setTimeType("10");
+            interlockCount.setDay(yesterday);
+            tylResultList.add(interlockCount);
+        }
+
+        //countService.saveBatch(tylResultList);
+
+        // 统计仪表状态  count_type = 3
+        List<InterlockCount> ybStatusList = summaryHistoryService.getYbStatusListByTagTime(yesterday);
+
+        HashMap<String, List<InterlockCount>> ybStatusMap = new HashMap<>();
+        for (InterlockCount item:ybStatusList) {
+            if (ybStatusMap.containsKey(item.getInterlockSystemId())){
+                ybStatusMap.get(item.getInterlockSystemId()).add(item);
+            }else {
+                ArrayList<InterlockCount> countList = new ArrayList<>();
+                countList.add(item);
+                ybStatusMap.put(item.getInterlockSystemId(),countList);
+            }
+        }
+
+        for (String key : ybStatusMap.keySet()) {
+            List<InterlockCount> interlockList = ybStatusMap.get(key);
+            for (InterlockCount item : interlockList) {
+                List<InterlockDetailHistory> detailHistoryList = detailHistoryService.getYbStatusListBySummaryIdAndTagTime(item.getId(),yesterday);
+                // 遍历集合 查询仪表状态 是否异常 如果有一个异常的 联锁状态为异常
+
+            }
+        }
+
+
+        // 统计系统状态  count_type = 4
+
+
+
+
+
+        // 批量保存
+        List<InterlockCount> list = Stream.concat(Stream.concat(loopHealthLevelResultList.stream(), interlockStatusResultList.stream()), tylResultList.stream())
+                .collect(Collectors.toList());
+
+        countService.saveBatch(list);
+
+        log.info("日统计任务执行成功!");
+    }
+}