双重预防项目-国泰新华二开定制版
SZH
2022-08-20 f9f0687195e0fe349185437d22c495d74c8d4a20
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package com.ruoyi.project.tr.hiddenDangerCheck.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.util.StringUtil;
import com.ruoyi.common.constant.TrHiddenDangerCheckConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.service.JpushService;
import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.service.IUserService;
import com.ruoyi.project.tr.JpushMsg.domain.JpushMsg;
import com.ruoyi.project.tr.JpushMsg.service.IJpushMsgService;
import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint;
import com.ruoyi.project.tr.hiddenDangerCheckPoint.service.IHiddenDangerCheckPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 隐患核查Controller
 *
 *
 * @date 2020-05-08
 */
@Controller
@RequestMapping("/tr/hiddenDangerCheck/dangerExamine")
public class DangerExamineController extends BaseController {
    private String prefix = "tr/hiddenDangerCheck/dangerExamine";
 
    @Autowired
    private IHiddenDangerCheckPointService hiddenDangerCheckPointService;
 
    @Autowired
    private IUserService userService;
 
 
    @Autowired
    JpushService jpushService;
 
    @GetMapping()
    public String dangerExamine() {
        return prefix + "/dangerExamine";
    }
 
 
    @GetMapping("/listByCompanyId/{companyId}")
    public String listByCompanyId(@PathVariable("companyId") Long companyId, ModelMap mmap) {
        mmap.put("companyId", companyId);
        return prefix + "/dangerExamineListByCompanyId";
    }
 
 
    /**
     * 查询隐患核查列表
     */
    @PostMapping("/listByCompanyId")
    @ResponseBody
    public TableDataInfo listByCompanyId(String companyId,HiddenDangerCheckPoint hiddenDangerCheckPoint) {
 
        User userQuery = new User();
        userQuery.setCompanyId(Long.valueOf(companyId));
        List<User> userList = userService.selectUserList(userQuery);
        List<Long>  userIdList = new ArrayList<>();
        for (User user : userList){
            userIdList.add(user.getUserId());
        }
        if(userIdList.size()==0){
            return getDataTable(new ArrayList<HiddenDangerCheckPoint>());
        }
        hiddenDangerCheckPoint.setExamineUserIdList(userIdList);//隐患整改人ID 为登陆账号companyId下的userId的
//        hiddenDangerCheckPoint.setExamineStatus(TrHiddenDangerCheckConstants.EXAMINE_STATUS_NOT_EXAMINE);/** 核查状态(待核查) */
        startPage();
        List<HiddenDangerCheckPoint> list = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(hiddenDangerCheckPoint);
        return getDataTable(list);
    }
 
 
    /**
     * 查询隐患核查列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HiddenDangerCheckPoint hiddenDangerCheckPoint) {
        startPage();
        hiddenDangerCheckPoint.setExamineUserId(getSysUser().getUserId());//核查人为本登录帐号userId的
        List<HiddenDangerCheckPoint> list = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(hiddenDangerCheckPoint);
        return getDataTable(list);
    }
 
    /**
     * 隐患核查--核查
     */
    @Log(title = "隐患核查--核查")
    @GetMapping("/editDangerExamine/{id}")
    public String editDangerExamine(@PathVariable("id") Long id, ModelMap mmap) {
        //隐患排查实体
        HiddenDangerCheckPoint hiddenDangerCheckPoint = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(Long.valueOf(id));
        mmap.put("hdcp", hiddenDangerCheckPoint);
 
        //获取所在公司人员信息
        User sysUser = getSysUser();
        if (sysUser != null && sysUser.getCompanyId() != null) {
            User userTemp = new User();
            userTemp.setCompanyId(sysUser.getCompanyId());
            List<User> userList = userService.selectUserList(userTemp);
            mmap.put("userList", userList);
        }
        return prefix + "/editDangerExamine";
    }
 
 
    /**
     * 隐患核查--保存
     */
    @Log(title = "隐患核查--保存", businessType = BusinessType.UPDATE)
    @PostMapping("/editDangerExamineSave")
    @ResponseBody
    public AjaxResult editDangerExamineSave(HiddenDangerCheckPoint hiddenDangerCheckPoint) {
        //获取当前更新用户信息
        User sysUser = getSysUser();
        hiddenDangerCheckPoint.setUpdateBy(ShiroUtils.getLoginName());
        hiddenDangerCheckPoint.setUpdateTime(DateUtils.getNowDate());
        hiddenDangerCheckPoint.setExamineCreateTime(DateUtils.getNowDate());//设置核查时间
        hiddenDangerCheckPoint.setExamineStatus(TrHiddenDangerCheckConstants.EXAMINE_STATUS_ALREADY_EXAMINE);//核查状态(已核查)
        if(!StringUtil.isEmpty(hiddenDangerCheckPoint.getDangerLevel())){
            if(("0".equals(hiddenDangerCheckPoint.getDangerLevel()))
                    ||("1".equals(hiddenDangerCheckPoint.getDangerLevel()))){//0 一般隐患 1 重大隐患
                hiddenDangerCheckPoint.setRectifyStatus(TrHiddenDangerCheckConstants.RECTIFY_STATUS_NOT_RECTIFY);//整改状态(未整改)
                hiddenDangerCheckPoint.setStage(TrHiddenDangerCheckConstants.DANGER_STAGE_PLAN_RECTIFY);//隐患整改阶段(数据进入到隐患整改阶段)
            }else if(("2".equals(hiddenDangerCheckPoint.getDangerLevel()))){ //2 不是隐患
                hiddenDangerCheckPoint.setWhetherDanger(TrHiddenDangerCheckConstants.WHETHER_DANGER_NOT);//是否为隐患(正常)
            }
        }
        int i = hiddenDangerCheckPointService.updateHiddenDangerCheckPoint(hiddenDangerCheckPoint);
        if(hiddenDangerCheckPoint.getRectifyDeadlineTime()!=null) {
            rectifyRemindJPush(hiddenDangerCheckPoint);
        }
        hiddenDangerCheckPointService.getTaskCountTotal(getSysUser().getUserId());//查询未执行任务总数量并推送
        return toAjax(i);
    }
 
 
 
    //整改任务发布时 推送
    /**
     * @param hiddenDangerCheckPoint
     */
    public void rectifyRemindJPush(HiddenDangerCheckPoint hiddenDangerCheckPoint) {
        HiddenDangerCheckPoint whole = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(hiddenDangerCheckPoint.getId());
        String title = "您有一项隐患待整改";
        String content = "【隐患整改任务】您有一项隐患待整改,(隐患描述:"+whole.getDangerDescription()+"), 需要在" +
                "(" + DateUtils.parseDateToStr("yyyy-MM-dd", whole.getRectifyDeadlineTime())+")," +
                "之前整改完成。";
        Map<String, String> extrasMap = new HashMap<String, String>();
        extrasMap.put("message", "这是一个整改待处理通知");
        extrasMap.put("methodType", "goToRectify");
        extrasMap.put("hiddenDangerCheckPoint", JSONObject.toJSONString(whole));
 
 
 
        //大文本通知栏样式
        jpushService.sendPushByAndroidBigText(title, content, 1, content, extrasMap, whole.getRectifyUserId().toString());
 
 
 
 
    }
 
 
    /**
     * 隐患核查--查看
     */
    @Log(title = "隐患核查--查看")
    @GetMapping("/detailDangerExamine/{id}")
    public String detailDangerExamine(@PathVariable("id") Long id, ModelMap mmap) {
        //隐患排查实体
        HiddenDangerCheckPoint hiddenDangerCheckPoint = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(Long.valueOf(id));
        mmap.put("hdcp", hiddenDangerCheckPoint);
        return prefix + "/detailDangerExamine";
    }
 
 
}