Просмотр исходного кода

2023-3-21 定时通风半成品。

chaiyunlong лет назад: 2
Родитель
Сommit
82f94f6a4e
20 измененных файлов с 1369 добавлено и 35 удалено
  1. 4 29
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabAbnormalController.java
  2. 147 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustController.java
  3. 38 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustJoinsubController.java
  4. 53 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabTimedExhaust.java
  5. 36 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabTimedExhaustJoinsub.java
  6. 3 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabDealyNotifyVo.java
  7. 26 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExecutionDateVo.java
  8. 35 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExhaustJoinSubVo.java
  9. 37 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExhaustPeriodVo.java
  10. 30 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabTimedExhaustJoinsubVo.java
  11. 33 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabTimedExhaustVo.java
  12. 63 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredAndWorkListener.java
  13. 47 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabTimedExhaustJoinsubMapper.java
  14. 82 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabTimedExhaustMapper.java
  15. 21 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabTimedExhaustJoinsubService.java
  16. 90 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabTimedExhaustService.java
  17. 57 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustJoinsubServiceImpl.java
  18. 315 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustServiceImpl.java
  19. 64 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustJoinsubMapper.xml
  20. 188 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustMapper.xml

+ 4 - 29
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabAbnormalController.java

@@ -1,7 +1,5 @@
 package com.zd.laboratory.controller;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.annotation.PreAuthorize;
 import com.zd.common.core.log.BusinessType;
@@ -11,11 +9,9 @@ import com.zd.common.core.utils.ExcelUtil;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.laboratory.domain.LabAbnormal;
 import com.zd.laboratory.domain.vo.LabAbnormalVO;
-import com.zd.laboratory.domain.vo.LabDealyNotifyVo;
 import com.zd.laboratory.service.ILabAbnormalService;
 import com.zd.laboratory.socket.command.Symbol;
 import com.zd.laboratory.socket.service.SocketService;
-import com.zd.model.constant.BaseConstants;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
 import com.zd.model.domain.per.PerPrefix;
@@ -28,8 +24,10 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 
 /**
  * 异常设备Controller
@@ -45,9 +43,6 @@ public class LabAbnormalController extends BaseController {
     @Autowired
     private SocketService socketService;
 
-    @Autowired
-    private RedisService redisService;
-
     @GetMapping("/send")
     public ResultData send(int num, String deviceNum, int type) {
 
@@ -193,24 +188,4 @@ public class LabAbnormalController extends BaseController {
     public ResultData getAbnormalCount(LabAbnormalVO labAbnormal) {
         return ResultData.success(labAbnormalService.getAbnormalCount(labAbnormal));
     }
-
-    @GetMapping("/sendMsg")
-    public ResultData sendMsg() {
-        LabDealyNotifyVo labDealyNotifyVo = new LabDealyNotifyVo();
-        labDealyNotifyVo.setRandomNum(UUID.randomUUID().toString());
-        labDealyNotifyVo.setHardwareNum("123455");
-        labDealyNotifyVo.setOpenOrCloseType(1);
-        JSONObject jsonObj = new JSONObject();
-        jsonObj.put(BaseConstants.DELAY_QUEUE,labDealyNotifyVo);
-        redisService.setCacheObject(BaseConstants.DELAY_QUEUE+"~"+ jsonObj,jsonObj, 10L, TimeUnit.SECONDS);
-
-        LabDealyNotifyVo labDealyNotifyVo2 = new LabDealyNotifyVo();
-        labDealyNotifyVo2.setRandomNum(UUID.randomUUID().toString());
-        labDealyNotifyVo2.setHardwareNum("123455");
-        labDealyNotifyVo2.setOpenOrCloseType(0);
-        JSONObject jsonObj2 = new JSONObject();
-        jsonObj2.put(BaseConstants.DELAY_QUEUE,labDealyNotifyVo2);
-        redisService.setCacheObject(BaseConstants.DELAY_QUEUE+"~"+ jsonObj2,jsonObj2, 20L, TimeUnit.SECONDS);
-        return null;
-    }
 }

+ 147 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustController.java

@@ -0,0 +1,147 @@
+package com.zd.laboratory.controller;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.zd.common.core.annotation.Log;
+import com.zd.common.core.log.BusinessType;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.laboratory.domain.LabTimedExhaust;
+import com.zd.laboratory.domain.vo.LabExhaustJoinSubVo;
+import com.zd.laboratory.domain.vo.LabSubjectVO;
+import com.zd.laboratory.domain.vo.LabTimedExhaustVo;
+import com.zd.laboratory.service.ILabTimedExhaustService;
+import com.zd.model.domain.ResultData;
+import com.zd.model.page.TableDataInfo;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 定时排风表Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@RestController
+@RequestMapping("/timed/exhaust")
+public class LabTimedExhaustController  extends BaseController {
+
+    @Autowired
+    private ILabTimedExhaustService labTimedExhaustService;
+
+    @ApiOperation(value = "定时排风列表")
+    @GetMapping("/list")
+    public TableDataInfo list(LabTimedExhaust labTimedExhaust) {
+        startPage();
+        List <LabTimedExhaust> list = labTimedExhaustService.selectLabTimedExhaustList(labTimedExhaust);
+        return getDataTable(list);
+    }
+
+    /**
+     * 新增定时排风
+     */
+    @ApiOperation(value = "新增定时排风")
+    @Log(title = "新增定时排风", businessType = BusinessType.INSERT)
+    @PostMapping
+    public ResultData add(@RequestBody LabTimedExhaustVo labTimedExhaustVo) {
+        return ResultData.success(labTimedExhaustService.insertLabTimedExhaust(labTimedExhaustVo));
+    }
+
+    /**
+     * 修改定时排风
+     */
+    @ApiOperation(value = "修改定时排风")
+    @Log(title = "修改定时排风", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public ResultData edit(@RequestBody LabTimedExhaustVo labTimedExhaustVo) {
+        return ResultData.success(labTimedExhaustService.updateLabTimedExhaust(labTimedExhaustVo));
+    }
+
+    /**
+     * 定时排风启用停用
+     */
+    @ApiOperation(value = "定时排风启用停用")
+    @Log(title = "定时排风启用停用", businessType = BusinessType.UPDATE)
+    @PutMapping("/operateExhaust")
+    public ResultData operateExhaust(@RequestBody LabTimedExhaust labTimedExhaust) {
+        return ResultData.result(labTimedExhaustService.operateExhaust(labTimedExhaust));
+    }
+
+    /**
+     * 获取定时排风详细信息
+     */
+    @ApiOperation(value = "获取定时排风详细信息")
+    @GetMapping(value = "/{id}")
+    public ResultData<LabTimedExhaustVo> getInfo(@PathVariable("id") Long id) {
+        return ResultData.success(labTimedExhaustService.selectLabTimedExhaustById(id));
+    }
+
+
+    /**
+     * 获取定时排风详未关联实验室列表信息
+     */
+    @GetMapping(value = "/getLabExhaustNoJoinSub")
+    public TableDataInfo getLabExhaustNoJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo) {
+        startPage();
+        List<LabSubjectVO> labExhaustNoJoinSubList = labTimedExhaustService.getLabExhaustNoJoinSub(labExhaustJoinSubVo);
+        return getDataTable(labExhaustNoJoinSubList);
+    }
+
+    /**
+     * 获取定时排风详关联实验室列表信息
+     */
+    @GetMapping(value = "/getLabExhaustJoinSub")
+    public ResultData<Map <String,Object>> getLabExhaustJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo) {
+        List<LabSubjectVO> labExhaustJoinSubList = labTimedExhaustService.getLabExhaustJoinSub(labExhaustJoinSubVo);
+        Map <String,Object> allMap = new HashMap <>();
+        allMap.put("list",labExhaustJoinSubList);
+        allMap.put("total",labExhaustJoinSubList.size());
+        return ResultData.success(allMap);
+    }
+
+    /**
+     * 删除定时排风
+     */
+    @ApiOperation(value = "删除定时排风")
+    @DeleteMapping("/{ids}")
+    public ResultData remove(@PathVariable Long[] ids) {
+        return ResultData.result(labTimedExhaustService.deleteLabTimedExhaustByIds(ids));
+    }
+
+
+    /**
+     * 获取节假日列表数据
+     */
+    @ApiOperation(value = "获取定时排风详细信息")
+    @GetMapping(value = "/getHoliday")
+    public ResultData<List<String>> getHoliday() {
+        List<String> arr = new ArrayList <>();
+        try{
+            String str = HttpUtil.get("https://api.apihubs.cn/holiday/get?year=2023&holiday_recess=1&order_by=1&cn=1&size=100",2000);
+            JSONArray jsonObject = JSON.parseObject(str).getJSONObject("data").getJSONArray("list");
+            for (int i=0;i<jsonObject.size();i++) {
+                JSONObject json = jsonObject.getJSONObject(i);
+                arr.add(json.getString("date"));
+//                System.out.println(""+json.getString("date"));
+            }
+        }catch (Exception e){
+            return ResultData.success(new ArrayList <>());
+        }
+        return ResultData.success(arr);
+    }
+
+    /**
+     * 自动排风
+     */
+    @RequestMapping(value = "/automaticExhaust")
+    public ResultData automaticExhaust(){
+        return ResultData.success(labTimedExhaustService.automaticExhaust());
+    }
+}

+ 38 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustJoinsubController.java

@@ -0,0 +1,38 @@
+package com.zd.laboratory.controller;
+
+import com.zd.common.core.annotation.Log;
+import com.zd.common.core.log.BusinessType;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo;
+import com.zd.laboratory.service.ILabTimedExhaustJoinsubService;
+import com.zd.model.domain.ResultData;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 定时排风关联实验室表Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@RestController
+@RequestMapping("/timed/joinsub")
+public class LabTimedExhaustJoinsubController extends BaseController {
+
+    @Autowired
+    private ILabTimedExhaustJoinsubService labTimedExhaustJoinsubService;
+
+    /**
+     * 新增定时排风关联实验室
+     */
+    @ApiOperation(value = "新增定时排风关联实验室")
+    @Log(title = "新增定时排风关联实验室", businessType = BusinessType.INSERT)
+    @PostMapping
+    public ResultData add(@RequestBody LabTimedExhaustJoinsubVo labTimedExhaustJoinsubVo) {
+        return ResultData.result(labTimedExhaustJoinsubService.insertLabTimedExhaustJoinsub(labTimedExhaustJoinsubVo));
+    }
+}

+ 53 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabTimedExhaust.java

@@ -0,0 +1,53 @@
+package com.zd.laboratory.domain;
+
+import com.zd.model.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@ApiModel("定时排风表")
+@Data
+public class LabTimedExhaust  extends BaseEntity {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+
+    /**
+     * 任务名称
+     */
+    @ApiModelProperty("任务名称")
+    private String taskName;
+
+    /**
+     * 排风时段,json数据
+     */
+    @ApiModelProperty("排风时段,json数据")
+    private String exhaustPeriod;
+
+    /**
+     * 执行日期类型,1是跳过节假日,0不跳过
+     */
+    @ApiModelProperty("执行日期类型,1是跳过节假日,0不跳过")
+    private Integer executionDateType;
+
+    /**
+     * 执行日期时间段,json数据
+     */
+    @ApiModelProperty("执行日期时间段,json数据")
+    private String executionDate;
+
+    /**
+     * 排风状态,1是启动,0是不启动
+     */
+    @ApiModelProperty("排风状态,1是启动,0是不启动")
+    private Integer exhaustType;
+}

+ 36 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabTimedExhaustJoinsub.java

@@ -0,0 +1,36 @@
+package com.zd.laboratory.domain;
+
+import com.zd.model.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@ApiModel("定时排风关联实验室表")
+@Data
+public class LabTimedExhaustJoinsub extends BaseEntity {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+
+    /**
+     * 定时排风id
+     */
+    @ApiModelProperty("定时排风id")
+    private Long timedExhaustId;
+
+    /**
+     * 实验室id
+     */
+    @ApiModelProperty("实验室id")
+    private Long subId;
+
+}

+ 3 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabDealyNotifyVo.java

@@ -19,9 +19,9 @@ public class LabDealyNotifyVo {
     @ApiModelProperty(value = "随机数")
     private String randomNum;
 
-    /** 继电器编号 */
-    @ApiModelProperty(value = "继电器编号")
-    private String hardwareNum;
+    /** 实验室id */
+    @ApiModelProperty(value = "实验室id")
+    private Long subId;
 
     /** 开启关闭状态 */
     @ApiModelProperty(value = "开启关闭状态")

+ 26 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExecutionDateVo.java

@@ -0,0 +1,26 @@
+package com.zd.laboratory.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@Data
+public class LabExecutionDateVo {
+
+    /**
+     * 开始时间 年-月-日
+     */
+    @ApiModelProperty("开始时间 年-月-日")
+    private String beginDate;
+
+    /**
+     * 结束时间 年-月-日
+     */
+    @ApiModelProperty("结束时间 年-月-日")
+    private String endDate;
+}

+ 35 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExhaustJoinSubVo.java

@@ -0,0 +1,35 @@
+package com.zd.laboratory.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@Data
+public class LabExhaustJoinSubVo {
+
+    @ApiModelProperty(name = "登录人id")
+    private Long userId;
+
+    @ApiModelProperty(name = "指定的实验室查询")
+    private Long[] subIds;
+
+    @ApiModelProperty(name = "排除指定的实验室过滤")
+    private Long[] noSubIds;
+
+    @ApiModelProperty(name = "公共查询")
+    private String searchValue;
+
+    @ApiModelProperty(name = "安全分级")
+    private String level;
+
+    @ApiModelProperty(name = "安全分类")
+    private String typeId;
+
+    @ApiModelProperty(name = "学院")
+    private Long deptId;
+}

+ 37 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExhaustPeriodVo.java

@@ -0,0 +1,37 @@
+package com.zd.laboratory.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@Data
+public class LabExhaustPeriodVo {
+    /**
+     * 开始时间 时:分
+     */
+    @ApiModelProperty("开始时间 时:分")
+    private String beginTime;
+
+    /**
+     * 结束时间 时:分
+     */
+    @ApiModelProperty("结束时间 时:分")
+    private String endTime;
+
+    /**
+     * 时间段类型:1是工作日(周一到周五),2是周(周一至周末),3是自定义
+     */
+    @ApiModelProperty("时间段类型:1是工作日(周一到周五),2是周(周一至周末),3是自定义")
+    private Integer timedType;
+
+    /**
+     * 自定义时间段
+     */
+    @ApiModelProperty("自定义时间段")
+    private String customTime;
+}

+ 30 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabTimedExhaustJoinsubVo.java

@@ -0,0 +1,30 @@
+package com.zd.laboratory.domain.vo;
+
+import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@Data
+public class LabTimedExhaustJoinsubVo {
+
+    /**
+     * 勾选后删除的实验室
+     */
+    private List<LabTimedExhaustJoinsub> joinsubList = new ArrayList <>();
+
+    /**
+     * 勾选后删除的实验室
+     */
+    @ApiModelProperty("勾选后删除的实验室")
+    private List<Long> delSubIds = new ArrayList <>();
+
+}

+ 33 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabTimedExhaustVo.java

@@ -0,0 +1,33 @@
+package com.zd.laboratory.domain.vo;
+
+import com.zd.laboratory.domain.LabTimedExhaust;
+import com.zd.model.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@ApiModel("定时排风表")
+@Data
+public class LabTimedExhaustVo extends LabTimedExhaust {
+
+    /**
+     * 排风时段列表
+     */
+    @ApiModelProperty("排风时段列表")
+    private List <LabExhaustPeriodVo> exhaustPeriodVoList = new ArrayList <>();
+
+    /**
+     * 排风日期
+     */
+    @ApiModelProperty("排风日期")
+    private List <LabExecutionDateVo> executionDateVoList = new ArrayList <>();
+}

+ 63 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredAndWorkListener.java

@@ -3,13 +3,28 @@ package com.zd.laboratory.event;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.fastjson.parser.Feature;
+import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
+import com.zd.laboratory.domain.LabControl;
+import com.zd.laboratory.domain.LabHardware;
 import com.zd.laboratory.domain.vo.LabDealyNotifyVo;
+import com.zd.laboratory.domain.vo.LabHardwareVO;
+import com.zd.laboratory.mapper.LabHardwareMapper;
+import com.zd.laboratory.service.ILabControlService;
+import com.zd.laboratory.service.impl.LabSubjectManagerService;
+import com.zd.laboratory.socket.command.Symbol;
 import com.zd.model.constant.BaseConstants;
+import com.zd.model.enums.HardwareTypeEnum;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.connection.Message;
 import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
 
 /**
  * 当前由于没有消息中间件,所以只能暂时采用此种方式直接消费数据
@@ -30,6 +45,15 @@ import org.springframework.stereotype.Component;
 @Component
 public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListener {
 
+    @Autowired
+    private LabHardwareMapper labHardwareMapper;
+
+    @Autowired
+    private LabSubjectManagerService subjectManagerService;
+
+    @Autowired
+    private ILabControlService labControlService;
+
     public RedisExpiredAndWorkListener(RedisMessageListenerContainer listenerContainer)
     {
         super(listenerContainer);
@@ -43,11 +67,47 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
             String[] delayStr = expiredKey.split(BaseConstants.DELAY_QUEUE+"~");
             JSONObject jsonObj = (JSONObject) JSONObject.parseObject(delayStr[1], Object.class, Feature.OrderedField);
             LabDealyNotifyVo dealyNotifyVo = jsonObj.getObject(BaseConstants.DELAY_QUEUE, new TypeReference <LabDealyNotifyVo>(){});
-            System.out.println("测试继电器编号:"+dealyNotifyVo.getHardwareNum());
-            System.out.println("测试随机数:"+dealyNotifyVo.getRandomNum());
-            System.out.println("测试开启或关闭::::"+dealyNotifyVo.getOpenOrCloseType());
+
+            //这里类型固定写死2,智能通风
+            List <Long> ids = new ArrayList <>();
+            ids.add(2L);
+            LabHardwareVO labHardwareVO = new LabHardwareVO();
+            labHardwareVO.setIds(ids);
+            labHardwareVO.setSubjectId(dealyNotifyVo.getSubId());
+            List<LabHardware> hardwareList = labHardwareMapper.selectNewLabHardwareByTypes(labHardwareVO);
+            Optional.ofNullable(hardwareList).orElseGet(Collections::emptyList)
+                    .stream()
+                    .forEach(a->{
+                        if(dealyNotifyVo.getOpenOrCloseType().intValue()==1){
+                            subjectManagerService.control(a.getId(), Symbol.command.open);
+                            //插入control 打开日志
+                            saveControl(a,1);
+                        }else{
+                            subjectManagerService.control(a.getId(), Symbol.command.close);
+                            //插入control 关闭日志
+                            saveControl(a,0);
+                        }
+
+                    });
         }
 
     }
 
+
+    public void saveControl(LabHardware labHardware,Integer controlType){
+        LabControl control = new LabControl();
+        control.setTriggerModes(1);
+        control.setControlType(controlType);
+        control.setUserName("定时排风自动执行");
+        if(controlType.intValue()==1){
+            control.setOperation("定时排风:打开");
+        }else{
+            control.setOperation("定时排风:关闭");
+        }
+        control.setHardwareType(HardwareTypeEnum.AI_VENTILATION);
+        control.setHardwareId(labHardware.getId());
+        control.setSubjectId(labHardware.getSubjectId());
+        labControlService.insertLabControl(control);
+    }
+
 }

+ 47 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabTimedExhaustJoinsubMapper.java

@@ -0,0 +1,47 @@
+package com.zd.laboratory.mapper;
+
+import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
+
+import java.util.List;
+
+/**
+ * 定时排风关联实验室Controller
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+public interface LabTimedExhaustJoinsubMapper {
+
+    /**
+     * 查询定时排风关联实验室
+     *
+     * @param labTimedExhaustJoinsub 定时排风关联实验室
+     * @return 定时排风关联实验室
+     */
+    public List <LabTimedExhaustJoinsub> selectLabTimedExhaustJoinsubList(LabTimedExhaustJoinsub labTimedExhaustJoinsub);
+
+    /**
+     * 新增定时排风关联实验室
+     *
+     * @param labTimedExhaustJoinsub 定时排风关联实验室
+     * @return 结果
+     */
+    public int insertLabTimedExhaustJoinsub(LabTimedExhaustJoinsub labTimedExhaustJoinsub);
+
+    /**
+     * 删除定时排风
+     *
+     * @param subIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteLabTimedExhaustJoinsubByIds(List <Long> subIds);
+
+    /**
+     * 根据定时排风主键删除关联数据
+     *
+     * @param timedExhaustId 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteLabTimedExhaustJoinsubByExhaustId(Long timedExhaustId);
+
+}

+ 82 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabTimedExhaustMapper.java

@@ -0,0 +1,82 @@
+package com.zd.laboratory.mapper;
+
+import com.zd.laboratory.domain.LabTimedExhaust;
+import com.zd.laboratory.domain.vo.LabExhaustJoinSubVo;
+import com.zd.laboratory.domain.vo.LabSubjectVO;
+
+import java.util.List;
+
+/**
+ * 定时排风Mapper接口
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+public interface LabTimedExhaustMapper {
+
+    /**
+     * 查询定时排风列表
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 定时排风集合
+     */
+    public List <LabTimedExhaust> selectLabTimedExhaustList(LabTimedExhaust labTimedExhaust);
+
+
+    /**
+     * 新增定时排风
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 结果
+     */
+    public int insertLabTimedExhaust(LabTimedExhaust labTimedExhaust);
+
+
+    /**
+     * 修改定时排风
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 结果
+     */
+    public int updateLabTimedExhaust(LabTimedExhaust labTimedExhaust);
+
+    /**
+     * 修改定时排风
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 结果
+     */
+    public int operateExhaust(LabTimedExhaust labTimedExhaust);
+
+    /**
+     * 查询定时排风详细信息
+     *
+     * @param id 定时排风主键
+     * @return 定时排风详细信息
+     */
+    public LabTimedExhaust selectLabTimedExhaustById(Long id);
+
+    /**
+     * 获取定时排风详未关联实验室列表信息
+     *
+     * @param labExhaustJoinSubVo 定时排风关联的实验室
+     * @return 实验室列表信息
+     */
+    List<LabSubjectVO> getLabExhaustNoJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo);
+
+    /**
+     * 获取定时排风详关联实验室列表信息
+     *
+     * @param labExhaustJoinSubVo 定时排风关联的实验室
+     * @return 实验室列表信息
+     */
+    List<LabSubjectVO> getLabExhaustJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo);
+
+    /**
+     * 批量删除定时排风
+     *
+     * @param ids 需要删除的定时排风主键集合
+     * @return 结果
+     */
+    public int deleteLabTimedExhaustByIds(Long ids);
+}

+ 21 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabTimedExhaustJoinsubService.java

@@ -0,0 +1,21 @@
+package com.zd.laboratory.service;
+
+import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
+import com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo;
+
+/**
+ * 定时排风关联实验室Service
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+public interface ILabTimedExhaustJoinsubService {
+
+    /**
+     * 新增定时排风关联实验室
+     *
+     * @param labTimedExhaustJoinsubVo 定时排风关联实验室
+     * @return 结果
+     */
+    public int insertLabTimedExhaustJoinsub(LabTimedExhaustJoinsubVo labTimedExhaustJoinsubVo);
+}

+ 90 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabTimedExhaustService.java

@@ -0,0 +1,90 @@
+package com.zd.laboratory.service;
+
+import com.zd.laboratory.domain.LabTimedExhaust;
+import com.zd.laboratory.domain.vo.LabExhaustJoinSubVo;
+import com.zd.laboratory.domain.vo.LabSubjectVO;
+import com.zd.laboratory.domain.vo.LabTimedExhaustVo;
+
+import java.util.List;
+
+/**
+ * 定时排风Service接口
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+public interface ILabTimedExhaustService {
+
+    /**
+     * 查询定时排风列表
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 定时排风集合
+     */
+    public List <LabTimedExhaust> selectLabTimedExhaustList(LabTimedExhaust labTimedExhaust);
+
+    /**
+     * 新增定时排风
+     *
+     * @param labTimedExhaustVo 定时排风
+     * @return 结果
+     */
+    public LabTimedExhaust insertLabTimedExhaust(LabTimedExhaustVo labTimedExhaustVo);
+
+    /**
+     * 修改定时排风
+     *
+     * @param labTimedExhaustVo 定时排风
+     * @return 结果
+     */
+    public LabTimedExhaust updateLabTimedExhaust(LabTimedExhaustVo labTimedExhaustVo);
+
+    /**
+     * 定时排风启用停用
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 结果
+     */
+    public int operateExhaust(LabTimedExhaust labTimedExhaust);
+
+    /**
+     * 查询定时排风详细信息
+     *
+     * @param id 定时排风主键
+     * @return 定时排风详细信息
+     */
+    public LabTimedExhaustVo selectLabTimedExhaustById(Long id);
+
+    /**
+     * 获取定时排风详未关联实验室列表信息
+     *
+     * @param labExhaustJoinSubVo 定时排风关联的实验室
+     * @return 实验室列表信息
+     */
+    List<LabSubjectVO> getLabExhaustNoJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo);
+
+    /**
+     * 获取定时排风详关联实验室列表信息
+     *
+     * @param labExhaustJoinSubVo 定时排风关联的实验室
+     * @return 实验室列表信息
+     */
+    List<LabSubjectVO> getLabExhaustJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo);
+
+
+    /**
+     * 批量删除定时排风
+     *
+     * @param ids 需要删除的定时排风主键集合
+     * @return 结果
+     */
+    public int deleteLabTimedExhaustByIds(Long[] ids);
+
+
+    /**
+     * 自动排风
+     *
+     * @return 结果
+     */
+    public int automaticExhaust();
+}

+ 57 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustJoinsubServiceImpl.java

@@ -0,0 +1,57 @@
+package com.zd.laboratory.service.impl;
+
+import com.zd.common.core.security.TokenService;
+import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
+import com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo;
+import com.zd.laboratory.mapper.LabTimedExhaustJoinsubMapper;
+import com.zd.laboratory.service.ILabTimedExhaustJoinsubService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+
+/**
+ * 定时排风关联实验室Service
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@Service
+public class LabTimedExhaustJoinsubServiceImpl implements ILabTimedExhaustJoinsubService {
+
+    @Autowired
+    private LabTimedExhaustJoinsubMapper labTimedExhaustJoinsubMapper;
+
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 新增定时排风关联实验室
+     *
+     * @param labTimedExhaustJoinsubVo 定时排风关联实验室
+     * @return 是否成功
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertLabTimedExhaustJoinsub(LabTimedExhaustJoinsubVo labTimedExhaustJoinsubVo) {
+
+        //todo 这里需要删除做两步,第一步删除选中的实验室,第二部删除要插入的相关数据
+        for(LabTimedExhaustJoinsub joinsub : labTimedExhaustJoinsubVo.getJoinsubList()){
+            labTimedExhaustJoinsubVo.getDelSubIds().add(joinsub.getSubId());
+        }
+
+        if(labTimedExhaustJoinsubVo.getDelSubIds().size()>0){
+            labTimedExhaustJoinsubMapper.deleteLabTimedExhaustJoinsubByIds(labTimedExhaustJoinsubVo.getDelSubIds());
+        }
+
+        //todo 循环插入
+        for(LabTimedExhaustJoinsub joinsub : labTimedExhaustJoinsubVo.getJoinsubList()){
+            joinsub.setUserId(tokenService.getLoginUser().getUserid());
+            joinsub.setCreateBy(tokenService.getLoginUser().getNickName());
+            joinsub.setCreateTime(new Date());
+            labTimedExhaustJoinsubMapper.insertLabTimedExhaustJoinsub(joinsub);
+        }
+        return 1;
+    }
+}

+ 315 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustServiceImpl.java

@@ -0,0 +1,315 @@
+package com.zd.laboratory.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.zd.common.core.redis.RedisService;
+import com.zd.common.core.security.TokenService;
+import com.zd.common.core.utils.StringUtils;
+import com.zd.laboratory.domain.LabTimedExhaust;
+import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
+import com.zd.laboratory.domain.vo.*;
+import com.zd.laboratory.mapper.LabTimedExhaustJoinsubMapper;
+import com.zd.laboratory.mapper.LabTimedExhaustMapper;
+import com.zd.laboratory.service.ILabTimedExhaustService;
+import com.zd.model.constant.BaseConstants;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+/**
+ * 定时排风Service接口
+ *
+ * @author cyl
+ * @date 2023/3/16
+ */
+@Service
+public class LabTimedExhaustServiceImpl implements ILabTimedExhaustService {
+
+    @Autowired
+    private LabTimedExhaustMapper labTimedExhaustMapper;
+
+    @Autowired
+    private TokenService tokenService;
+
+    @Autowired
+    private LabTimedExhaustJoinsubMapper labTimedExhaustJoinsubMapper;
+
+    @Autowired
+    private RedisService redisService;
+
+    /**
+     * 查询定时排风列表
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 定时排风集合
+     */
+    @Override
+    public List <LabTimedExhaust> selectLabTimedExhaustList(LabTimedExhaust labTimedExhaust) {
+        return labTimedExhaustMapper.selectLabTimedExhaustList(labTimedExhaust);
+    }
+
+    /**
+     * 新增定时排风
+     *
+     * @param labTimedExhaustVo 定时排风
+     * @return 是否成功
+     */
+    @Override
+    public LabTimedExhaust insertLabTimedExhaust(LabTimedExhaustVo labTimedExhaustVo) {
+        LabTimedExhaust timedExhaust = getTimedExhaustInfo(labTimedExhaustVo);
+        timedExhaust.setUserId(tokenService.getLoginUser().getUserid());
+        timedExhaust.setCreateBy(tokenService.getLoginUser().getNickName());
+        timedExhaust.setCreateTime(new Date());
+        timedExhaust.setUpdateBy(tokenService.getLoginUser().getNickName());
+        timedExhaust.setUpdateTime(new Date());
+        labTimedExhaustMapper.insertLabTimedExhaust(timedExhaust);
+        return timedExhaust;
+    }
+
+    /**
+     * 修改定时排风
+     *
+     * @param labTimedExhaustVo 修改定时排风
+     * @return 是否成功
+     */
+    @Override
+    public LabTimedExhaust updateLabTimedExhaust(LabTimedExhaustVo labTimedExhaustVo) {
+        LabTimedExhaust timedExhaust = getTimedExhaustInfo(labTimedExhaustVo);
+        timedExhaust.setUpdateBy(tokenService.getLoginUser().getNickName());
+        timedExhaust.setUpdateTime(new Date());
+        labTimedExhaustMapper.updateLabTimedExhaust(timedExhaust);
+        return timedExhaust;
+    }
+
+    /**
+     * 定时排风启用停用
+     *
+     * @param labTimedExhaust 定时排风
+     * @return 是否成功
+     */
+    @Override
+    public int operateExhaust(LabTimedExhaust labTimedExhaust) {
+        labTimedExhaust.setUpdateBy(tokenService.getLoginUser().getNickName());
+        labTimedExhaust.setUpdateTime(new Date());
+        return labTimedExhaustMapper.operateExhaust(labTimedExhaust);
+    }
+
+    /**
+     * 查询定时排风详细信息
+     *
+     * @param id 定时排风主键
+     * @return 定时排风详细信息
+     */
+    @Override
+    public LabTimedExhaustVo selectLabTimedExhaustById(Long id) {
+        LabTimedExhaust timedExhaust = labTimedExhaustMapper.selectLabTimedExhaustById(id);
+        return getTimedExhaustVo(timedExhaust);
+    }
+
+    @Override
+    public List <LabSubjectVO> getLabExhaustNoJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo) {
+        labExhaustJoinSubVo.setUserId(tokenService.getLoginUser().getUserid());
+        return labTimedExhaustMapper.getLabExhaustNoJoinSub(labExhaustJoinSubVo);
+    }
+
+    @Override
+    public List <LabSubjectVO> getLabExhaustJoinSub(LabExhaustJoinSubVo labExhaustJoinSubVo) {
+        labExhaustJoinSubVo.setUserId(tokenService.getLoginUser().getUserid());
+        return labTimedExhaustMapper.getLabExhaustJoinSub(labExhaustJoinSubVo);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteLabTimedExhaustByIds(Long[] ids) {
+        //先删除定时排风关联的实验室
+        labTimedExhaustJoinsubMapper.deleteLabTimedExhaustJoinsubByExhaustId(ids[0]);
+        //在删除定时排风数据
+        labTimedExhaustMapper.deleteLabTimedExhaustByIds(ids[0]);
+        return 1;
+    }
+
+    @Override
+    public int automaticExhaust() {
+        //查询定时排风列表
+        LabTimedExhaust labTimedExhaust = new LabTimedExhaust();
+        labTimedExhaust.setExhaustType(1);
+        List <LabTimedExhaust> timedExhaustList = labTimedExhaustMapper.selectLabTimedExhaustList(labTimedExhaust);
+        List<LabTimedExhaustVo> timedExhaustVoList = Optional.ofNullable(timedExhaustList).orElseGet(Collections::emptyList)
+                .stream()
+                .map(a->getTimedExhaustVo(a)).collect(Collectors.toList());
+
+        List <LabTimedExhaustJoinsub> joinsubList = labTimedExhaustJoinsubMapper.selectLabTimedExhaustJoinsubList(new LabTimedExhaustJoinsub());
+
+        Calendar calendar = Calendar.getInstance();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        System.out.println(formatter.format(calendar.getTime()));
+        //后去年
+        int year = calendar.get(Calendar.YEAR);
+        int monthInt = calendar.get(Calendar.MONTH)+1;
+        String monthStr;
+        if (monthInt<10){
+            monthStr = "0"+monthInt;
+        }else {
+            monthStr = ""+monthInt;
+        }
+        int dateInt = calendar.get(Calendar.DATE);
+        String dateStr;
+        if (dateInt<10){
+            dateStr = "0"+dateInt;
+        }else {
+            dateStr = ""+dateInt;
+        }
+        Integer newDateInt = Integer.parseInt(year+""+monthStr+""+""+dateStr);
+
+        //todo 函数校验当日是否落选到时间区间   这里由于需求变动,在跳过节假日的时候,数据上报是不是节假日的日期时间段
+        Predicate<List <LabExecutionDateVo>> predicate = a->a.stream()
+                .map(b->{
+                    Integer beginDate = Integer.parseInt(b.getBeginDate().replaceAll("-",""));
+                    Integer endDate = Integer.parseInt(b.getEndDate().replaceAll("-",""));
+                    if(beginDate.intValue()<=newDateInt.intValue() && newDateInt.intValue()<=endDate.intValue()){
+                        return b;
+                    }
+                    return null;
+                })
+                .filter(b-> StringUtils.isNotNull(b))
+                .collect(Collectors.toList()).size()>0;
+
+        Function <List<LabTimedExhaustVo>,List<LabTimedExhaustVo>> consumer = a->a.stream()
+                .filter(b->{
+                    if(StringUtils.isNotNull(b.getExecutionDateVoList()) && b.getExecutionDateVoList().size()>0){
+                        if(b.getExecutionDateType().intValue()==0){
+                            return predicate.test(b.getExecutionDateVoList());
+                        }else if(b.getExecutionDateType().intValue()==1){
+                            return predicate.test(b.getExecutionDateVoList());
+                        }else{
+                            return false;
+                        }
+                    }else{
+                        return true;
+                    }
+                })
+                .collect(Collectors.toList());
+        //todo 函数校验当日落选后,根据时间段,执行对应的
+        Optional.ofNullable(joinsubList).orElseGet(Collections::emptyList)
+                .stream()
+                .forEach(a->Optional.ofNullable(consumer.apply(timedExhaustVoList)).orElseGet(Collections::emptyList)
+                        .stream()
+                        .filter(b->a.getTimedExhaustId().longValue()==b.getId().longValue())
+                        .forEach(b->{
+                            executionFun(a.getSubId(),b.getExhaustPeriodVoList(),calendar);
+                        })
+                );
+        return 0;
+    }
+
+    public void executionFun(final Long subId,List <LabExhaustPeriodVo> exhaustPeriodVoList,Calendar calendar){
+        Predicate<LabExhaustPeriodVo> predicate = a->{
+//            Integer[] weekDays = { 7, 1, 2, 3, 4, 5, 6 };
+            int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+            if (w < 0)
+                w = 0;
+            if(a.getTimedType().intValue()==1){
+                //工作日执行,周一到周五
+                Integer[] weekDays = { -1, 1, 2, 3, 4, 5, -1 };
+                if(weekDays[w].intValue()!=-1){
+                    return true;
+                }
+            }else if(a.getTimedType().intValue()==2){
+                return true;
+            }else if(a.getTimedType().intValue()==3){
+                //自定义执行
+                Map<Integer,Integer> map = new HashMap <>();
+                if(StringUtils.isNotNull(a.getCustomTime())){
+                    Arrays.asList(a.getCustomTime().split(",")).stream()
+                            .forEach(x->{
+                                map.put(Integer.parseInt(x),Integer.parseInt(x));
+                            });
+                }
+                //自定义执行
+                Integer[] weekDays = { 7, 1, 2, 3, 4, 5, 6 };
+                if(map.get(weekDays[w].intValue()) !=null && weekDays[w].intValue()==map.get(weekDays[w].intValue()).intValue()){
+                    return true;
+                }
+            }
+            return false;
+        };
+
+
+        Optional.ofNullable(exhaustPeriodVoList).orElseGet(Collections::emptyList)
+                .stream()
+                .filter(a->predicate.test(a))
+                .forEach(a->{
+                    //这里执行redis存储,如果是开始时间,那么就存实验室和开关“开”。
+                    String[] beginTimeStr = a.getBeginTime().split(":");
+                    long lDate1 = calendar.getTime().getTime();
+                    Calendar newCalendar = Calendar.getInstance();
+                    Long newBeginTime = calendarTime(lDate1,beginTimeStr,newCalendar);
+                    if(newBeginTime>=0){
+                        executionTimer(newBeginTime,subId,1);
+                    }
+                    //这里执行redis存储,如果是结束时间,那么就存实验室和开关“关”。
+                    String[] endTimeStr = a.getEndTime().split(":");
+                    Long newEndTime = calendarTime(lDate1,endTimeStr,newCalendar);
+                    if(newEndTime>=0){
+                        executionTimer(Long.parseLong(newEndTime+""),subId,0);
+                    }
+                });
+    }
+
+    public Long calendarTime(long lDate1,String[] timeStr,Calendar calendar){
+        calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeStr[0]));
+        calendar.set(Calendar.MINUTE, Integer.parseInt(timeStr[1]));
+        long lDate2 = calendar.getTime().getTime();
+        long diff = (lDate2 - lDate1);
+        long day = diff / (24 * 60 * 60 * 1000);
+        long hour = diff / (60 * 60 * 1000) - day * 24;
+        long min = diff / (60 * 1000) - day * 24 * 60 - hour * 60;
+        return (hour*60L)+(min);
+    }
+
+    public void executionTimer(final Long newBeginTime,final Long subId,final Integer type){
+        LabDealyNotifyVo labDealyNotifyVo = new LabDealyNotifyVo();
+        labDealyNotifyVo.setRandomNum(UUID.randomUUID().toString());
+        labDealyNotifyVo.setSubId(subId);
+        labDealyNotifyVo.setOpenOrCloseType(type);
+        JSONObject jsonObj = new JSONObject();
+        jsonObj.put(BaseConstants.DELAY_QUEUE,labDealyNotifyVo);
+        redisService.setCacheObject(BaseConstants.DELAY_QUEUE+"~"+ jsonObj,jsonObj, newBeginTime, TimeUnit.MINUTES);
+    }
+
+    public LabTimedExhaustVo getTimedExhaustVo(LabTimedExhaust timedExhaust){
+        LabTimedExhaustVo labTimedExhaustVo = new LabTimedExhaustVo();
+        BeanUtils.copyProperties(timedExhaust, labTimedExhaustVo);
+        JSONObject object = new JSONObject();
+        object.put("objectPeriod",JSONArray.parseArray(timedExhaust.getExhaustPeriod()));
+        object.put("objectDate",JSONArray.parseArray(timedExhaust.getExecutionDate()));
+
+        labTimedExhaustVo.setExhaustPeriodVoList(object.getObject("objectPeriod",new TypeReference <List<LabExhaustPeriodVo>>(){}));
+        labTimedExhaustVo.setExecutionDateVoList(object.getObject("objectDate",new TypeReference <List<LabExecutionDateVo>>(){}));
+        return labTimedExhaustVo;
+    }
+
+    public LabTimedExhaust getTimedExhaustInfo(LabTimedExhaustVo labTimedExhaustVo){
+        LabTimedExhaust timedExhaust = new LabTimedExhaust();
+        BeanUtils.copyProperties(labTimedExhaustVo, timedExhaust);
+        if(labTimedExhaustVo.getExhaustPeriodVoList().size()>0){
+            String exhaustPeriodStr = JSON.toJSONString(labTimedExhaustVo.getExhaustPeriodVoList());
+            timedExhaust.setExhaustPeriod(exhaustPeriodStr);
+        }
+        if(labTimedExhaustVo.getExecutionDateVoList().size()>0){
+            String executionDateStr = JSON.toJSONString(labTimedExhaustVo.getExecutionDateVoList());
+            timedExhaust.setExecutionDate(executionDateStr);
+        }
+        return timedExhaust;
+    }
+}

+ 64 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustJoinsubMapper.xml

@@ -0,0 +1,64 @@
+<?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="com.zd.laboratory.mapper.LabTimedExhaustJoinsubMapper">
+
+    <resultMap type="com.zd.laboratory.domain.LabTimedExhaustJoinsub" id="LabTimedExhaustJoinsubResult">
+        <result property="id" column="id"/>
+        <result property="timedExhaustId" column="timed_exhaust_id"/>
+        <result property="subId" column="sub_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+
+    <sql id="selectLabTimedExhaustJoinsubVo">
+        SELECT tej.id,tej.`timed_exhaust_id`,tej.`sub_id`,tej.`user_id`,
+        tej.`create_by`,tej.`create_time`,tej.`update_by`,tej.`update_time`,tej.`remark`
+        FROM lab_timed_exhaust_joinsub tej
+    </sql>
+
+    <select id="selectLabTimedExhaustJoinsubList" resultType="com.zd.laboratory.domain.LabTimedExhaust" resultMap="LabTimedExhaustJoinsubResult">
+        <include refid="selectLabTimedExhaustJoinsubVo"/>
+    </select>
+
+    <insert id="insertLabTimedExhaustJoinsub" parameterType="com.zd.laboratory.domain.LabTimedExhaustJoinsub" useGeneratedKeys="true" keyProperty="id">
+        insert into lab_timed_exhaust_joinsub
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="timedExhaustId != null">timed_exhaust_id,</if>
+            <if test="subId != null">sub_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="timedExhaustId != null">#{timedExhaustId},</if>
+            <if test="subId != null">#{subId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+    <delete id="deleteLabTimedExhaustJoinsubByIds">
+        delete from lab_timed_exhaust_joinsub where sub_id in
+        <foreach item="id" collection="list" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    <delete id="deleteLabTimedExhaustJoinsubByExhaustId">
+        delete from lab_timed_exhaust_joinsub where timed_exhaust_id = #{timedExhaustId}
+    </delete>
+
+
+</mapper>

+ 188 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustMapper.xml

@@ -0,0 +1,188 @@
+<?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="com.zd.laboratory.mapper.LabTimedExhaustMapper">
+
+    <resultMap type="com.zd.laboratory.domain.LabTimedExhaust" id="LabTimedExhaustResult">
+        <result property="id" column="id"/>
+        <result property="taskName" column="task_name"/>
+        <result property="exhaustPeriod" column="exhaust_period"/>
+        <result property="executionDateType" column="execution_date_type"/>
+        <result property="executionDate" column="execution_date"/>
+        <result property="exhaustType" column="exhaust_type"/>
+        <result property="userId" column="user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+
+    <sql id="selectLabTimedExhaustVo">
+        SELECT DISTINCT te.id,te.`task_name`,te.`exhaust_period`,te.`execution_date_type`,te.`execution_date`,te.`exhaust_type`,te.`user_id`,
+        te.`create_by`,te.`create_time`,te.`update_by`,te.`update_time`,te.`remark`
+        FROM lab_timed_exhaust te
+    </sql>
+    <delete id="deleteLabTimedExhaustByIds">
+        delete from lab_timed_exhaust where id = #{ids}
+    </delete>
+
+
+    <select id="selectLabTimedExhaustList" parameterType="com.zd.laboratory.domain.LabTimedExhaust" resultMap="LabTimedExhaustResult">
+        <include refid="selectLabTimedExhaustVo"/>
+        LEFT JOIN lab_timed_exhaust_joinsub tej ON te.`id` = tej.`timed_exhaust_id`
+        LEFT JOIN lab_subject s ON s.`id` = tej.`sub_id`
+        LEFT JOIN lab_build_floor_layout bfl ON bfl.`sub_id` = s.`id`
+        <where>
+            <if test="searchValue != null  and searchValue != ''">
+                AND (
+                te.task_name LIKE CONCAT('%', #{searchValue}, '%')
+                OR
+                s.`name` LIKE CONCAT('%', #{searchValue}, '%')
+                OR
+                bfl.`room_num`  LIKE CONCAT('%', #{searchValue}, '%')
+                )
+            </if>
+            <if test="deptId != null  and deptId != ''">
+                and s.dept_id = #{deptId}
+            </if>
+        </where>
+        ORDER BY te.`create_time` desc
+    </select>
+    <select id="selectLabTimedExhaustById" resultType="com.zd.laboratory.domain.LabTimedExhaust">
+        <include refid="selectLabTimedExhaustVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="getLabExhaustNoJoinSub" parameterType="com.zd.laboratory.domain.vo.LabExhaustJoinSubVo" resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
+      select xx.* from (
+      SELECT ls.*,sc.`classified_name` levelName,st.`type_name` typeName,
+        (SELECT COUNT(1) FROM lab_hardware h WHERE h.type=2 AND h.subject_id = ls.`id`) hdcount
+        FROM lab_subject ls LEFT JOIN lab_safe_classified sc ON ls.level = sc.`id`
+        LEFT JOIN lab_safe_classtype st ON ls.type_id = st.`id`
+        <where>
+            (ls.id NOT IN(
+            SELECT tej.`sub_id` FROM lab_timed_exhaust_joinsub tej
+            )
+            <if test="subIds != null and subIds.length > 0">
+                OR
+                ls.id IN
+                <foreach item="subId" collection="subIds" open="(" separator="," close=")">
+                    #{subId}
+                </foreach>
+            </if>
+            )
+            <if test="noSubIds != null and noSubIds.length > 0">
+                and ls.id NOT IN
+                <foreach item="subId" collection="noSubIds" open="(" separator="," close=")">
+                    #{subId}
+                </foreach>
+            </if>
+
+            <if test="userId != null">
+                and ( FIND_IN_SET (#{userId},ls.safe_user_id) or ls.admin_id = #{userId})
+            </if>
+            <if test="searchValue != null and searchValue != ''">
+                and ls.name like concat('%', #{searchValue}, '%')
+            </if>
+            <if test="level != null and level!=''">
+                and ls.level = #{level}
+            </if>
+            <if test="typeId != null and typeId!=''">
+                and ls.type_id = #{typeId}
+            </if>
+            <if test="deptId != null">
+                and ls.dept_id = #{deptId}
+            </if>
+        </where>
+        )xx WHERE xx.hdcount>0
+    </select>
+
+    <select id="getLabExhaustJoinSub" parameterType="com.zd.laboratory.domain.vo.LabExhaustJoinSubVo" resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
+        select xx.* from (
+        SELECT ls.*,sc.`classified_name` levelName,st.`type_name` typeName,
+        (SELECT COUNT(1) FROM lab_hardware h WHERE h.type=2 AND h.subject_id = ls.`id`) hdcount
+        FROM lab_subject ls LEFT JOIN lab_safe_classified sc ON ls.level = sc.`id`
+        LEFT JOIN lab_safe_classtype st ON ls.type_id = st.`id`
+        <where>
+            (ls.id IN(
+            SELECT tej.`sub_id` FROM lab_timed_exhaust_joinsub tej
+            )
+            <if test="subIds != null and subIds.length > 0">
+                and
+                ls.id NOT IN
+                <foreach item="subId" collection="subIds" open="(" separator="," close=")">
+                    #{subId}
+                </foreach>
+            </if>
+            )
+            <if test="userId != null">
+                and ( FIND_IN_SET (#{userId},ls.safe_user_id) or ls.admin_id = #{userId})
+            </if>
+            <if test="searchValue != null and searchValue != ''">
+                and ls.name like concat('%', #{searchValue}, '%')
+            </if>
+        </where>
+        )xx WHERE xx.hdcount>0
+    </select>
+
+    <insert id="insertLabTimedExhaust" parameterType="com.zd.laboratory.domain.LabTimedExhaust" useGeneratedKeys="true" keyProperty="id">
+        insert into lab_timed_exhaust
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="taskName != null">task_name,</if>
+            <if test="exhaustPeriod != null">exhaust_period,</if>
+            <if test="executionDateType != null">execution_date_type,</if>
+            <if test="executionDate != null">execution_date,</if>
+            <if test="exhaustType != null">exhaust_type,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="taskName != null">#{taskName},</if>
+            <if test="exhaustPeriod != null">#{exhaustPeriod},</if>
+            <if test="executionDateType != null">#{executionDateType},</if>
+            <if test="executionDate != null">#{executionDate},</if>
+            <if test="exhaustType != null">#{exhaustType},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+
+    <update id="updateLabTimedExhaust" parameterType="com.zd.laboratory.domain.LabTimedExhaust">
+        update lab_timed_exhaust
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="taskName != null">task_name = #{taskName},</if>
+            exhaust_period = #{exhaustPeriod},
+            <if test="executionDateType != null">execution_date_type = #{executionDateType},</if>
+            execution_date = #{executionDate},
+            <if test="exhaustType != null">exhaust_type = #{exhaustType},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+    <update id="operateExhaust">
+        update lab_timed_exhaust
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="exhaustType != null">exhaust_type = #{exhaustType},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+</mapper>