qushaowei
2025-06-10 7542603a0f22dd73287556c9ec0df39184091ab0
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package org.jeecg.modules.eam.job;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.eam.entity.*;
import org.jeecg.modules.eam.service.*;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.service.*;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
 
/**
 * 三级保养工单  到期未执行  技术状态修改为 禁用(状态鉴定未按期完成)
 */
@Slf4j
public class ThirdMaintenanceOrderOverdueJob implements Job {
 
    @Autowired
    private IDailyMaintenanceOrderService dailyMaintenanceOrderService;
 
    @Autowired
    private IEamEquipmentService equipmentService;
    @Autowired
    private IMaintenanceCycleService maintenanceCycleService;
 
    @Autowired
    private ISysBaseAPI sysBaseApi;
 
    @Resource
    private ISysRoleService sysRoleService;
    @Resource
    private ISysDictService sysDictService;
    @Resource
    private ISysDictItemService sysDictItemService;
    @Resource
    private ISysUserRoleService sysUserRoleService;
    @Resource
    private ISysUserService sysUserService;
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
 
        LocalDateTime currentDateTime = LocalDateTime.now();
        Date result = Date.from(currentDateTime.atZone(ZoneId.systemDefault()).toInstant());
        List<DailyMaintenanceOrder> maintenanceOrders = dailyMaintenanceOrderService.list(new QueryWrapper<DailyMaintenanceOrder>().lt("plan_start_time", result).eq("status",1).eq("del_flag",0));
        for (DailyMaintenanceOrder dailyMaintenanceOrder : maintenanceOrders) {
            String maintenanceCycleId = dailyMaintenanceOrder.getMaintenanceCycleId();
            MaintenanceCycle maintenanceCycle = maintenanceCycleService.getById(maintenanceCycleId);
            String maintenanceType = maintenanceCycle.getMaintenanceType();
            if("3".equals(maintenanceType)){
                String equipmentId = dailyMaintenanceOrder.getEquipmentId();
 
                Equipment equipment = equipmentService.getById(equipmentId);
                equipment.setTechnologyStatus("disableNoExe");
                equipmentService.updateById(equipment);
                this.equipmentTechnologyStatuAlart(equipment.getNum(),equipment.getTechnologyStatus());
            }
        }
    }
 
    void equipmentTechnologyStatuAlart(String equipmentNum,String technologyStatus){
 
        SysDict sysDictT = sysDictService.getOne(new QueryWrapper<SysDict>().eq("dict_code","technology_status"),false);
        SysDictItem sysDictItemt = sysDictItemService.getOne(new QueryWrapper<SysDictItem>().eq("item_value",technologyStatus)
                .eq("dict_id",sysDictT.getId()),false);
 
        SysDict sysDict = sysDictService.getOne(new QueryWrapper<SysDict>().eq("dict_code","info_type"),false);
        SysDictItem sysDictItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>().eq("item_text","运保设备管理员")
                .eq("dict_id",sysDict.getId()),false);
        String roleCode = sysDictItem.getItemValue();
        SysRole sysRole = sysRoleService.getOne(new QueryWrapper<SysRole>().eq("role_code",roleCode),false);
        List<SysUserRole> sysUserRoles = sysUserRoleService.list(new QueryWrapper<SysUserRole>().eq("role_id",sysRole.getId()));
        for(SysUserRole sysUserRole:sysUserRoles){
            SysUser user = sysUserService.getById(sysUserRole.getUserId());
            String msg = "统一编号为【"+equipmentNum+"】的三级保养工单未执行,系统自动将该设备技术状态改为【"+sysDictItemt.getItemText()+"】,请知晓!!!";
            MessageDTO messageDTO = new MessageDTO();
            messageDTO.setTitle("设备台账技术状态修改");
            messageDTO.setContent(msg);
            messageDTO.setCategory("运保设备管理员");
            messageDTO.setFromUser("设备台账技术状态修改提醒小助手");
            messageDTO.setToUser(user.getUsername());
            sysBaseApi.sendSysAnnouncement(messageDTO);
        }
    }
}