郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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.gk.hotwork.Controller;
 
import com.gk.hotwork.Controller.Base.BaseController;
import com.gk.hotwork.Domain.Enum.ErrorCode;
import com.gk.hotwork.Domain.UserInfo;
import com.gk.hotwork.Domain.Utils.Msg;
import com.gk.hotwork.Domain.Utils.PageInfo;
import com.gk.hotwork.Domain.Utils.StringUtils;
import com.gk.hotwork.Domain.WarningInfo;
import com.gk.hotwork.Service.UserService;
import com.gk.hotwork.Service.WarningService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
/**
 * @author : jingjy
 * @date : 2021/9/10 9:26
 */
@Api(tags = "任务流程数据接口")
@RestController
@RequestMapping("/warning")
public class WarningController extends BaseController {
    @Autowired
    private WarningService warningService;
    @Autowired
    private UserService userService;
 
    @GetMapping("/info")
    public Msg getWarningInfo(@RequestParam(value = "code", required = false) String code,
                              @RequestParam(value = "isDeal", required = false) String isDeal,
                              @RequestParam(value = "type", required = false) String type,
                              @RequestParam(defaultValue = "0") Integer pageIndex,
                              @RequestParam(value = "startTime", required = false) String startTime,
                              @RequestParam(value = "endTime", required = false) String endTime,
                              @RequestParam(defaultValue = "10") Integer pageSize,
                              String sort, String order){
        PageInfo pageInfo = new PageInfo(pageIndex, pageSize,sort,order);
 
        Map<String, Object> condition = new HashMap<>(4);
        if (StringUtils.isNotBlank(code)) {
            condition.put("code", code);
        }
        if (StringUtils.isNotBlank(isDeal)) {
            condition.put("isDeal", isDeal);
        }
        if (StringUtils.isNotBlank(type)) {
            condition.put("type", type);
        }
        if (StringUtils.isNotBlank(startTime)){
            condition.put("startTime", startTime);
        }
        if (StringUtils.isNotBlank(endTime)){
            condition.put("endTime", endTime);
        }
        pageInfo.setCondition(condition);
        warningService.selectDataGrid(pageInfo);
 
        return success(pageInfo);
    }
 
    @PostMapping("/deal")
    public Msg dealWarning(String id){
        UserInfo userInfo = userService.getById(getUser().getId());
        if (StringUtils.isBlank(id)){
            return new Msg(ErrorCode.ERROR_10001);
        }
        WarningInfo warningInfo = warningService.getById(id);
        if (warningInfo == null || warningInfo.getIsdeal() == 1){
            return new Msg(ErrorCode.ERROR_50001,"警告信息未找到或已处理");
        }
        warningInfo.setIsdeal((byte)1);
        warningInfo.setDealat(new Date());
        warningInfo.setDealby(userInfo.getRealname());
        warningService.updateById(warningInfo);
        return success();
    }
}