Browse Source

根据上下班时间来给盒子发送是否开启/关闭算法

tjf 3 days ago
parent
commit
fedf25149f

+ 91 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/ClockSetController.java

@@ -0,0 +1,91 @@
+package com.ruoyi.web.controller.manage;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.manage.domain.ClockSet;
+import com.ruoyi.manage.service.IClockSetService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 打卡时间设置Controller
+ *
+ * @author boman
+ * @date 2025-07-28
+ */
+@RestController
+@RequestMapping("/manage/clockSet")
+public class ClockSetController extends BaseController {
+    @Autowired
+    private IClockSetService clockSetService;
+
+    /**
+     * 查询打卡时间设置列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:clockSet:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(ClockSet clockSet) {
+        startPage();
+        List<ClockSet> list = clockSetService.selectClockSetList(clockSet);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出打卡时间设置列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:clockSet:export')")
+    @Log(title = "打卡时间设置", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, ClockSet clockSet) {
+        List<ClockSet> list = clockSetService.selectClockSetList(clockSet);
+        ExcelUtil<ClockSet> util = new ExcelUtil<ClockSet>(ClockSet.class);
+        util.exportExcel(response, list, "打卡时间设置数据");
+    }
+
+    /**
+     * 获取打卡时间设置详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('manage:clockSet:query')")
+    @GetMapping(value = "/{clockSetId}")
+    public AjaxResult getInfo(@PathVariable("clockSetId") Long clockSetId) {
+        return success(clockSetService.selectClockSetByClockSetId(clockSetId));
+    }
+
+    /**
+     * 新增打卡时间设置
+     */
+    @PreAuthorize("@ss.hasPermi('manage:clockSet:add')")
+    @Log(title = "打卡时间设置", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody ClockSet clockSet) {
+        return toAjax(clockSetService.insertClockSet(clockSet));
+    }
+
+    /**
+     * 修改打卡时间设置
+     */
+    @PreAuthorize("@ss.hasPermi('manage:clockSet:edit')")
+    @Log(title = "打卡时间设置", businessType = BusinessType.UPDATE)
+    @PostMapping("/put")
+    public AjaxResult edit(@RequestBody ClockSet clockSet) {
+        return toAjax(clockSetService.updateClockSet(clockSet));
+    }
+
+    /**
+     * 删除打卡时间设置
+     */
+    @PreAuthorize("@ss.hasPermi('manage:clockSet:remove')")
+    @Log(title = "打卡时间设置", businessType = BusinessType.DELETE)
+    @GetMapping("/delete/{clockSetIds}")
+    public AjaxResult remove(@PathVariable Long[] clockSetIds) {
+        return toAjax(clockSetService.deleteClockSetByClockSetIds(clockSetIds));
+    }
+}

+ 20 - 33
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/StaffManageController.java

@@ -1,25 +1,19 @@
 package com.ruoyi.web.controller.manage;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.manage.domain.StaffManage;
 import com.ruoyi.manage.service.IStaffManageService;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 人员管理Controller
@@ -29,18 +23,16 @@ import com.ruoyi.common.core.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/manage/staffManage")
-public class StaffManageController extends BaseController
-{
+public class StaffManageController extends BaseController {
     @Autowired
     private IStaffManageService staffManageService;
 
-/**
- * 查询人员管理列表
- */
-@PreAuthorize("@ss.hasPermi('manage:staffManage:list')")
-@GetMapping("/list")
-    public TableDataInfo list(StaffManage staffManage)
-    {
+    /**
+     * 查询人员管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:staffManage:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(StaffManage staffManage) {
         startPage();
         List<StaffManage> list = staffManageService.selectStaffManageList(staffManage);
         return getDataTable(list);
@@ -52,8 +44,7 @@ public class StaffManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:staffManage:export')")
     @Log(title = "人员管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, StaffManage staffManage)
-    {
+    public void export(HttpServletResponse response, StaffManage staffManage) {
         List<StaffManage> list = staffManageService.selectStaffManageList(staffManage);
         ExcelUtil<StaffManage> util = new ExcelUtil<StaffManage>(StaffManage.class);
         util.exportExcel(response, list, "人员管理数据");
@@ -64,8 +55,7 @@ public class StaffManageController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('manage:staffManage:query')")
     @GetMapping(value = "/{staffId}")
-    public AjaxResult getInfo(@PathVariable("staffId") Long staffId)
-    {
+    public AjaxResult getInfo(@PathVariable("staffId") Long staffId) {
         return success(staffManageService.selectStaffManageByStaffId(staffId));
     }
 
@@ -75,8 +65,7 @@ public class StaffManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:staffManage:add')")
     @Log(title = "人员管理", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody StaffManage staffManage)
-    {
+    public AjaxResult add(@RequestBody StaffManage staffManage) {
         return toAjax(staffManageService.insertStaffManage(staffManage));
     }
 
@@ -86,8 +75,7 @@ public class StaffManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:staffManage:edit')")
     @Log(title = "人员管理", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody StaffManage staffManage)
-    {
+    public AjaxResult edit(@RequestBody StaffManage staffManage) {
         return toAjax(staffManageService.updateStaffManage(staffManage));
     }
 
@@ -97,8 +85,7 @@ public class StaffManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:staffManage:remove')")
     @Log(title = "人员管理", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{staffIds}")
-    public AjaxResult remove(@PathVariable Long[] staffIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] staffIds) {
         return toAjax(staffManageService.deleteStaffManageByStaffIds(staffIds));
     }
 }

+ 20 - 33
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/TaskManageController.java

@@ -1,25 +1,19 @@
 package com.ruoyi.web.controller.manage;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.manage.domain.TaskManage;
 import com.ruoyi.manage.service.ITaskManageService;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 任务管理Controller
@@ -29,18 +23,16 @@ import com.ruoyi.common.core.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/manage/taskManage")
-public class TaskManageController extends BaseController
-{
+public class TaskManageController extends BaseController {
     @Autowired
     private ITaskManageService taskManageService;
 
-/**
- * 查询任务管理列表
- */
-@PreAuthorize("@ss.hasPermi('manage:taskManage:list')")
-@GetMapping("/list")
-    public TableDataInfo list(TaskManage taskManage)
-    {
+    /**
+     * 查询任务管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:taskManage:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TaskManage taskManage) {
         startPage();
         List<TaskManage> list = taskManageService.selectTaskManageList(taskManage);
         return getDataTable(list);
@@ -52,8 +44,7 @@ public class TaskManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:taskManage:export')")
     @Log(title = "任务管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, TaskManage taskManage)
-    {
+    public void export(HttpServletResponse response, TaskManage taskManage) {
         List<TaskManage> list = taskManageService.selectTaskManageList(taskManage);
         ExcelUtil<TaskManage> util = new ExcelUtil<TaskManage>(TaskManage.class);
         util.exportExcel(response, list, "任务管理数据");
@@ -64,8 +55,7 @@ public class TaskManageController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('manage:taskManage:query')")
     @GetMapping(value = "/{taskId}")
-    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
-    {
+    public AjaxResult getInfo(@PathVariable("taskId") Long taskId) {
         return success(taskManageService.selectTaskManageByTaskId(taskId));
     }
 
@@ -75,8 +65,7 @@ public class TaskManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:taskManage:add')")
     @Log(title = "任务管理", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TaskManage taskManage)
-    {
+    public AjaxResult add(@RequestBody TaskManage taskManage) {
         return toAjax(taskManageService.insertTaskManage(taskManage));
     }
 
@@ -86,8 +75,7 @@ public class TaskManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:taskManage:edit')")
     @Log(title = "任务管理", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody TaskManage taskManage)
-    {
+    public AjaxResult edit(@RequestBody TaskManage taskManage) {
         return toAjax(taskManageService.updateTaskManage(taskManage));
     }
 
@@ -97,8 +85,7 @@ public class TaskManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:taskManage:remove')")
     @Log(title = "任务管理", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{taskIds}")
-    public AjaxResult remove(@PathVariable Long[] taskIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] taskIds) {
         return toAjax(taskManageService.deleteTaskManageByTaskIds(taskIds));
     }
 }

+ 3 - 3
ruoyi-admin/src/main/resources/application.yml

@@ -19,8 +19,8 @@ spring:
     # 国际化资源文件路径
     basename: i18n/messages
   profiles:
-#          active: druid
-          active: prod
+          active: druid
+#          active: prod
   # 文件上传
   servlet:
     multipart:
@@ -84,7 +84,7 @@ mqtt:
   client-id: JavaClientBoMan
   username:
   password:
-  default-topic: toServer_leaveStat,toServer_playStat,toServer_picPos
+  default-topic: toServer_leaveStat,toServer_playStat,toServer_picPos,toServer_workStat
   default-qos: 1
   timeout: 30
   keep-alive: 60

+ 2 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -190,6 +190,8 @@ public class Constants {
     public static final String DETECTION_PLAYRATE = "detection/playrate";
     //rtsp地址
     public static final String DETECTION_RTSP = "detection/rtsp";
+    //通知盒子启动或者关闭算法检查
+    public static final String DETECTION_WORK_STAT = "detection/workStat";
     //离岗告警接收
     public static final String TO_SERVER_LEAVE_STAT = "toServer_leaveStat";
     //玩手机告警接收

+ 28 - 2
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -161,7 +161,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         long nd = 1000 * 24 * 60 * 60;
         long nh = 1000 * 60 * 60;
         long nm = 1000 * 60;
-        // long ns = 1000;
+         long ns = 1000;
         // 获得两个时间的毫秒时间差异
         long diff = endDate.getTime() - startTime.getTime();
         // 计算差多少天
@@ -171,10 +171,36 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         // 计算差多少分钟
         long min = diff % nd % nh / nm;
         // 计算差多少秒//输出结果
-        // long sec = diff % nd % nh % nm / ns;
+        long sec = diff % nd % nh % nm / ns;
         return day + "天" + hour + "小时" + min + "分钟";
     }
 
+    /**
+     * 计算时间差返回秒数
+     *
+     * @param endDate   最后时间
+     * @param startTime 开始时间
+     * @return 时间差(天/小时/分钟)
+     */
+    public static Long timeDistanceSec(Date endDate, Date startTime) {
+        long nd = 1000 * 24 * 60 * 60;
+        long nh = 1000 * 60 * 60;
+        long nm = 1000 * 60;
+        long ns = 1000;
+        // 获得两个时间的毫秒时间差异
+        long diff = endDate.getTime() - startTime.getTime();
+        // 计算差多少天
+        long day = diff / nd;
+        // 计算差多少小时
+        long hour = diff % nd / nh;
+        // 计算差多少分钟
+        long min = diff % nd % nh / nm;
+        // 计算差多少秒
+        long sec = diff % nd % nh % nm / ns;
+        //输出结果
+        return sec;
+    }
+
     /**
      * 增加 LocalDateTime ==> Date
      */

+ 61 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/HolidayUtils.java

@@ -0,0 +1,61 @@
+package com.ruoyi.common.utils;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class HolidayUtils {
+
+    public static String request( String httpArg) {
+
+        String httpUrl="http://tool.bitefu.net/jiari/";
+
+        BufferedReader reader = null;
+
+        String result = null;
+
+        StringBuffer sbf = new StringBuffer();
+
+        httpUrl = httpUrl + "?d=" + httpArg;
+
+        try {
+
+            URL url = new URL(httpUrl);
+
+            HttpURLConnection connection = (HttpURLConnection) url
+
+                    .openConnection();
+
+            connection.setRequestMethod("GET");
+
+            connection.connect();
+
+            InputStream is = connection.getInputStream();
+
+            reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+
+            String strRead = null;
+
+            while ((strRead = reader.readLine()) != null) {
+                sbf.append(strRead);
+            }
+
+            reader.close();
+
+            result = sbf.toString();
+
+            //Map map= (Map) JSON.parse(result);
+
+            //String res=(String)map.get(httpArg);
+
+        } catch (Exception e) {
+
+            e.printStackTrace();
+
+        }
+
+        return result;
+    }
+}

+ 2 - 2
ruoyi-generator/src/main/resources/generator.yml

@@ -1,9 +1,9 @@
 # 代码生成
 gen:
   # 作者
-  author: ruoyi
+  author: boman
   # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
-  packageName: com.ruoyi.system
+  packageName: com.ruoyi.manage
   # 自动去除表前缀,默认是false
   autoRemovePre: false
   # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)

+ 98 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/domain/ClockSet.java

@@ -0,0 +1,98 @@
+package com.ruoyi.manage.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 打卡时间设置对象 clock_set
+ * 
+ * @author boman
+ * @date 2025-07-28
+ */
+public class ClockSet extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 打卡时间设置id */
+    private Long clockSetId;
+
+    /** 上午上班时间 */
+    //@JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "上午上班时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private String clockBeginAm;
+
+    /** 上午下班时间 */
+    //@JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "上午下班时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private String clockEndAm;
+
+    /** 下午上班时间 */
+    //@JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "下午上班时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private String clockBeginPm;
+
+    /** 下午下班时间 */
+    //@JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "下午下班时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private String clockEndPm;
+
+    public void setClockSetId(Long clockSetId) 
+    {
+        this.clockSetId = clockSetId;
+    }
+
+    public Long getClockSetId() 
+    {
+        return clockSetId;
+    }
+
+    public String getClockBeginAm() {
+        return clockBeginAm;
+    }
+
+    public void setClockBeginAm(String clockBeginAm) {
+        this.clockBeginAm = clockBeginAm;
+    }
+
+    public String getClockEndAm() {
+        return clockEndAm;
+    }
+
+    public void setClockEndAm(String clockEndAm) {
+        this.clockEndAm = clockEndAm;
+    }
+
+    public String getClockBeginPm() {
+        return clockBeginPm;
+    }
+
+    public void setClockBeginPm(String clockBeginPm) {
+        this.clockBeginPm = clockBeginPm;
+    }
+
+    public String getClockEndPm() {
+        return clockEndPm;
+    }
+
+    public void setClockEndPm(String clockEndPm) {
+        this.clockEndPm = clockEndPm;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("clockSetId", getClockSetId())
+            .append("clockBeginAm", getClockBeginAm())
+            .append("clockEndAm", getClockEndAm())
+            .append("clockBeginPm", getClockBeginPm())
+            .append("clockEndPm", getClockEndPm())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 62 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/mapper/ClockSetMapper.java

@@ -0,0 +1,62 @@
+package com.ruoyi.manage.mapper;
+
+import com.ruoyi.manage.domain.ClockSet;
+
+import java.util.List;
+
+/**
+ * 打卡时间设置Mapper接口
+ * 
+ * @author boman
+ * @date 2025-07-28
+ */
+public interface ClockSetMapper 
+{
+    /**
+     * 查询打卡时间设置
+     * 
+     * @param clockSetId 打卡时间设置主键
+     * @return 打卡时间设置
+     */
+    public ClockSet selectClockSetByClockSetId(Long clockSetId);
+
+    /**
+     * 查询打卡时间设置列表
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 打卡时间设置集合
+     */
+    public List<ClockSet> selectClockSetList(ClockSet clockSet);
+
+    /**
+     * 新增打卡时间设置
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 结果
+     */
+    public int insertClockSet(ClockSet clockSet);
+
+    /**
+     * 修改打卡时间设置
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 结果
+     */
+    public int updateClockSet(ClockSet clockSet);
+
+    /**
+     * 删除打卡时间设置
+     * 
+     * @param clockSetId 打卡时间设置主键
+     * @return 结果
+     */
+    public int deleteClockSetByClockSetId(Long clockSetId);
+
+    /**
+     * 批量删除打卡时间设置
+     * 
+     * @param clockSetIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteClockSetByClockSetIds(Long[] clockSetIds);
+}

+ 62 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/service/IClockSetService.java

@@ -0,0 +1,62 @@
+package com.ruoyi.manage.service;
+
+import com.ruoyi.manage.domain.ClockSet;
+
+import java.util.List;
+
+/**
+ * 打卡时间设置Service接口
+ * 
+ * @author boman
+ * @date 2025-07-28
+ */
+public interface IClockSetService 
+{
+    /**
+     * 查询打卡时间设置
+     * 
+     * @param clockSetId 打卡时间设置主键
+     * @return 打卡时间设置
+     */
+    public ClockSet selectClockSetByClockSetId(Long clockSetId);
+
+    /**
+     * 查询打卡时间设置列表
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 打卡时间设置集合
+     */
+    public List<ClockSet> selectClockSetList(ClockSet clockSet);
+
+    /**
+     * 新增打卡时间设置
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 结果
+     */
+    public int insertClockSet(ClockSet clockSet);
+
+    /**
+     * 修改打卡时间设置
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 结果
+     */
+    public int updateClockSet(ClockSet clockSet);
+
+    /**
+     * 批量删除打卡时间设置
+     * 
+     * @param clockSetIds 需要删除的打卡时间设置主键集合
+     * @return 结果
+     */
+    public int deleteClockSetByClockSetIds(Long[] clockSetIds);
+
+    /**
+     * 删除打卡时间设置信息
+     * 
+     * @param clockSetId 打卡时间设置主键
+     * @return 结果
+     */
+    public int deleteClockSetByClockSetId(Long clockSetId);
+}

+ 101 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ClockSetServiceImpl.java

@@ -0,0 +1,101 @@
+package com.ruoyi.manage.service.impl;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.manage.domain.ClockSet;
+import com.ruoyi.manage.mapper.ClockSetMapper;
+import com.ruoyi.manage.service.IClockSetService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 打卡时间设置Service业务层处理
+ * 
+ * @author boman
+ * @date 2025-07-28
+ */
+@Service
+public class ClockSetServiceImpl implements IClockSetService 
+{
+    @Autowired
+    private ClockSetMapper clockSetMapper;
+
+    /**
+     * 查询打卡时间设置
+     * 
+     * @param clockSetId 打卡时间设置主键
+     * @return 打卡时间设置
+     */
+    @Override
+    public ClockSet selectClockSetByClockSetId(Long clockSetId)
+    {
+        return clockSetMapper.selectClockSetByClockSetId(clockSetId);
+    }
+
+    /**
+     * 查询打卡时间设置列表
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 打卡时间设置
+     */
+    @Override
+    public List<ClockSet> selectClockSetList(ClockSet clockSet)
+    {
+        return clockSetMapper.selectClockSetList(clockSet);
+    }
+
+    /**
+     * 新增打卡时间设置
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 结果
+     */
+    @Override
+    public int insertClockSet(ClockSet clockSet)
+    {
+        List<ClockSet> clockSets = clockSetMapper.selectClockSetList(new ClockSet());
+        if (!clockSets.isEmpty()){
+            return 0;
+        }
+        clockSet.setCreateTime(DateUtils.getNowDate());
+        return clockSetMapper.insertClockSet(clockSet);
+    }
+
+    /**
+     * 修改打卡时间设置
+     * 
+     * @param clockSet 打卡时间设置
+     * @return 结果
+     */
+    @Override
+    public int updateClockSet(ClockSet clockSet)
+    {
+        clockSet.setUpdateTime(DateUtils.getNowDate());
+        return clockSetMapper.updateClockSet(clockSet);
+    }
+
+    /**
+     * 批量删除打卡时间设置
+     * 
+     * @param clockSetIds 需要删除的打卡时间设置主键
+     * @return 结果
+     */
+    @Override
+    public int deleteClockSetByClockSetIds(Long[] clockSetIds)
+    {
+        return clockSetMapper.deleteClockSetByClockSetIds(clockSetIds);
+    }
+
+    /**
+     * 删除打卡时间设置信息
+     * 
+     * @param clockSetId 打卡时间设置主键
+     * @return 结果
+     */
+    @Override
+    public int deleteClockSetByClockSetId(Long clockSetId)
+    {
+        return clockSetMapper.deleteClockSetByClockSetId(clockSetId);
+    }
+}

+ 105 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/Task.java

@@ -0,0 +1,105 @@
+package com.ruoyi.system.service;
+
+
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.HolidayUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.manage.domain.ClockSet;
+import com.ruoyi.manage.mapper.ClockSetMapper;
+import com.ruoyi.mqtt.service.MqttService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import static com.ruoyi.common.constant.Constants.*;
+
+@Component
+public class Task {
+    @Autowired
+    private RedisCache redisCache;
+    @Autowired
+    private MqttService mqttService;
+    @Autowired
+    private ClockSetMapper clockSetMapper;
+
+    /***
+     * 查询是否是节假日
+     */
+    @Async
+    @Scheduled(cron = "0 5 0 * * ? ")
+    public void thirdNucleicAcid() {
+        String data = DateUtils.getDate();
+        //判断当天天是否是法定节假日  0 上班 1周末 2节假日
+        String jsonResult = HolidayUtils.request(data);
+        if (!ZERO.equals(jsonResult)) {
+            try {
+                //是节假日MQTT发送关闭服务消息
+                mqttService.publish(DETECTION_WORK_STAT, ZERO);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } else {
+            //查询考勤日期规则
+            List<ClockSet> clockSets = clockSetMapper.selectClockSetList(new ClockSet());
+            if (clockSets != null && clockSets.size() > 0) {
+                ClockSet clockSet = clockSets.get(0);
+                String clockBeginAm = clockSet.getClockBeginAm();
+                String clockEndAm = clockSet.getClockEndAm();
+                String clockBeginPm = clockSet.getClockBeginPm();
+                String clockEndPm = clockSet.getClockEndPm();
+                if (StringUtils.isNotEmpty(clockBeginAm)) {
+                    //计算两个时间的差值秒数
+                    Date dateBegin = DateUtils.getNowDate();
+                    String date = DateUtils.getDate();
+                    Date dateEnd = DateUtils.parseDate(date + " " + clockBeginAm);
+                    //活得差值的秒数
+                    long sec = DateUtils.timeDistanceSec(dateEnd, dateBegin);
+                    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+                    Runnable task = () -> mqttService.publish(DETECTION_WORK_STAT, ONE);
+                    scheduler.schedule(task, sec, TimeUnit.SECONDS);
+                }
+                if (StringUtils.isNotEmpty(clockEndAm)) {
+                    //计算两个时间的差值秒数
+                    Date dateBegin = DateUtils.getNowDate();
+                    String date = DateUtils.getDate();
+                    Date dateEnd = DateUtils.parseDate(date + " " + clockEndAm);
+                    //活得差值的秒数
+                    long sec = DateUtils.timeDistanceSec(dateEnd, dateBegin);
+                    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+                    Runnable task = () -> mqttService.publish(DETECTION_WORK_STAT, ZERO);
+                    scheduler.schedule(task, sec, TimeUnit.SECONDS);
+                }
+                if (StringUtils.isNotEmpty(clockBeginPm)) {
+                    //计算两个时间的差值秒数
+                    Date dateBegin = DateUtils.getNowDate();
+                    String date = DateUtils.getDate();
+                    Date dateEnd = DateUtils.parseDate(date + " " + clockBeginPm);
+                    //活得差值的秒数
+                    long sec = DateUtils.timeDistanceSec(dateEnd, dateBegin);
+                    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+                    Runnable task = () -> mqttService.publish(DETECTION_WORK_STAT, ONE);
+                    scheduler.schedule(task, sec, TimeUnit.SECONDS);
+                }
+                if (StringUtils.isNotEmpty(clockEndPm)) {
+                    //计算两个时间的差值秒数
+                    Date dateBegin = DateUtils.getNowDate();
+                    String date = DateUtils.getDate();
+                    Date dateEnd = DateUtils.parseDate(date + " " + clockEndPm);
+                    //活得差值的秒数
+                    long sec = DateUtils.timeDistanceSec(dateEnd, dateBegin);
+                    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+                    Runnable task = () -> mqttService.publish(DETECTION_WORK_STAT, ZERO);
+                    scheduler.schedule(task, sec, TimeUnit.SECONDS);
+                }
+            }
+        }
+    }
+}

+ 91 - 0
ruoyi-system/src/main/resources/mapper/manage/ClockSetMapper.xml

@@ -0,0 +1,91 @@
+<?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.ruoyi.manage.mapper.ClockSetMapper">
+    
+    <resultMap type="ClockSet" id="ClockSetResult">
+        <result property="clockSetId"    column="clock_set_id"    />
+        <result property="clockBeginAm"    column="clock_begin_am"    />
+        <result property="clockEndAm"    column="clock_end_am"    />
+        <result property="clockBeginPm"    column="clock_begin_pm"    />
+        <result property="clockEndPm"    column="clock_end_pm"    />
+        <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="selectClockSetVo">
+        select clock_set_id, clock_begin_am, clock_end_am, clock_begin_pm, clock_end_pm, create_by, create_time, update_by, update_time, remark from clock_set
+    </sql>
+
+    <select id="selectClockSetList" parameterType="ClockSet" resultMap="ClockSetResult">
+        <include refid="selectClockSetVo"/>
+        <where>  
+            <if test="clockBeginAm != null "> and clock_begin_am = #{clockBeginAm}</if>
+            <if test="clockEndAm != null "> and clock_end_am = #{clockEndAm}</if>
+            <if test="clockBeginPm != null "> and clock_begin_pm = #{clockBeginPm}</if>
+            <if test="clockEndPm != null "> and clock_end_pm = #{clockEndPm}</if>
+        </where>
+    </select>
+    
+    <select id="selectClockSetByClockSetId" parameterType="Long" resultMap="ClockSetResult">
+        <include refid="selectClockSetVo"/>
+        where clock_set_id = #{clockSetId}
+    </select>
+
+    <insert id="insertClockSet" parameterType="ClockSet" useGeneratedKeys="true" keyProperty="clockSetId">
+        insert into clock_set
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="clockBeginAm != null">clock_begin_am,</if>
+            <if test="clockEndAm != null">clock_end_am,</if>
+            <if test="clockBeginPm != null">clock_begin_pm,</if>
+            <if test="clockEndPm != null">clock_end_pm,</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="clockBeginAm != null">#{clockBeginAm},</if>
+            <if test="clockEndAm != null">#{clockEndAm},</if>
+            <if test="clockBeginPm != null">#{clockBeginPm},</if>
+            <if test="clockEndPm != null">#{clockEndPm},</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="updateClockSet" parameterType="ClockSet">
+        update clock_set
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="clockBeginAm != null">clock_begin_am = #{clockBeginAm},</if>
+            <if test="clockEndAm != null">clock_end_am = #{clockEndAm},</if>
+            <if test="clockBeginPm != null">clock_begin_pm = #{clockBeginPm},</if>
+            <if test="clockEndPm != null">clock_end_pm = #{clockEndPm},</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 clock_set_id = #{clockSetId}
+    </update>
+
+    <delete id="deleteClockSetByClockSetId" parameterType="Long">
+        delete from clock_set where clock_set_id = #{clockSetId}
+    </delete>
+
+    <delete id="deleteClockSetByClockSetIds" parameterType="String">
+        delete from clock_set where clock_set_id in 
+        <foreach item="clockSetId" collection="array" open="(" separator="," close=")">
+            #{clockSetId}
+        </foreach>
+    </delete>
+</mapper>