wuxw
2025-04-03 4a51c642a117c797b12807f7f403c08e96613b41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.java110.job.task.noticeStaff;
 
import com.java110.dto.community.CommunityDto;
import com.java110.dto.repair.RepairDto;
import com.java110.utils.cache.CommonCache;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
 
import java.util.Calendar;
import java.util.Date;
 
public class NoticeTaskUtil {
    /**
     * 计算是否为通知时间内
     *
     * @return
     */
    public static boolean isNotifyTodayInspection(CommunityDto communityDto) {
        Calendar calendar = Calendar.getInstance();
        int hours = calendar.get(Calendar.HOUR_OF_DAY);
        if (hours != 18) {
            return false;
        }
        String hasValue = CommonCache.getValue("notify_today_inspection_" + communityDto.getCommunityId());
        if (!StringUtil.isEmpty(hasValue)) {
            return false;
        }
        CommonCache.setValue("notify_today_inspection_" + communityDto.getCommunityId(), hours + "", 12 * 60 * 60);
        return true;
    }
 
    /**
     * 快超时
     *
     * @param tRepairDto
     * @return
     */
    public static boolean isRepairAboutTimeout(RepairDto tRepairDto) {
        Date timeout = DateUtil.getDateFromStringA(tRepairDto.getTimeout());
        Date nowTime = DateUtil.getCurrentDate();
        if (nowTime.after(timeout)) { // 说明已经超时了
            return false;
        }
        int warnTime = Integer.parseInt(tRepairDto.getWarningTime());
 
        if (timeout.getTime() - nowTime.getTime() > warnTime * 60 * 1000) {
            return false;
        }
        String hasValue = CommonCache.getValue("notify_repair_about_timeout_" + tRepairDto.getRepairId());
        if (!StringUtil.isEmpty(hasValue)) {
            return false;
        }
        if (warnTime > 1) {
            warnTime -= 1;
        }
        CommonCache.setValue("notify_repair_about_timeout_" + tRepairDto.getRepairId(), warnTime + "", warnTime * 60);
 
        return true;
    }
 
    /**
     * 已经超时
     *
     * @param tRepairDto
     * @return
     */
    public static boolean isRepairTimeout(RepairDto tRepairDto) {
        Date timeout = DateUtil.getDateFromStringA(tRepairDto.getTimeout());
        Date nowTime = DateUtil.getCurrentDate();
        if (nowTime.before(timeout)) { // 说明已经没有超时
            return false;
        }
 
        String hasValue = CommonCache.getValue("notify_repair_timeout_" + tRepairDto.getRepairId());
        if (!StringUtil.isEmpty(hasValue)) {
            return false;
        }
        CommonCache.setValue("notify_repair_timeout_" + tRepairDto.getRepairId(), "Y", 24 * 60 * 60);
 
        return true;
    }
}