mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
package com.panzhihua.grid_app.api;
 
import javax.annotation.Resource;
 
import com.panzhihua.common.model.vos.grid.GridMemberPositionDTO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.grid.*;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.grid.EventVO;
import com.panzhihua.common.service.grid.GridService;
import com.panzhihua.common.utlis.ClazzUtils;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
 
/**
 *
 * @author cedoo email:cedoo(a)qq.com
 * @version 1.0
 * @since 1.0
 * @date 2021-05-26
 */
@Slf4j
@RestController
@RequestMapping("/event/common")
@Api(tags = {"网格综治事件管理 @chendong"})
public class CommonEventApi extends BaseController {
 
    @Resource
    private GridService gridService;
 
    private boolean isCommonType(Integer eventType) {
        if (eventType == null) {
            return false;
        }
        boolean inType =
            eventType == 1 | eventType == 2 | eventType == 3 | eventType == 4 | eventType == 5 | eventType == 6;
        return inType;
    }
 
    /**
     * 事件列表
     * 
     * @param pageEventDTO
     *            查找事件
     * @return 查找结果
     */
    @GetMapping("/usersList")
    @ApiOperation(value = "事件列表", response = EventVO.class)
    R usersList(@Validated @ModelAttribute PageEventDTO pageEventDTO) {
        ClazzUtils.setIfStringIsEmpty(pageEventDTO);
        if (!isCommonType(pageEventDTO.getEventType())) {
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        pageEventDTO.setUserId(loginUserInfoVO.getUserId());
        pageEventDTO.setRevokeType(1);
        return gridService.query(pageEventDTO);
    }
 
    /**
     * 新增并发布事件事件
     * 
     * @param commonEventAddDTO
     *            添加事件传递对象
     * @return 新增结果
     */
    @PostMapping("/release")
    @ApiOperation(value = "新增并发布事件", response = R.class)
    R add(@Validated @RequestBody CommonEventAddDTO commonEventAddDTO) {
        ClazzUtils.setIfStringIsEmpty(commonEventAddDTO);
        if (!isCommonType(commonEventAddDTO.getEventType())) {
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventAddDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventAddDTO.setUserName(loginUserInfoVO.getNickName());
        commonEventAddDTO.setPhone(loginUserInfoVO.getPhone());
        R r = gridService.addCommon(commonEventAddDTO);
        if(R.isOk(r)){
            GridMemberPositionDTO memberPositionDTO = new GridMemberPositionDTO();
            memberPositionDTO.setGridMemberId(loginUserInfoVO.getUserId());
            memberPositionDTO.setPositionAddress(commonEventAddDTO.getHappenAddress());
            String []lngLatString = commonEventAddDTO.getHappentLatLng().split(",");
            memberPositionDTO.setLngLat(lngLatString[1] + "," + lngLatString[0]);
            gridService.gridReportPosition(memberPositionDTO);
        }
        return r;
    }
 
    /**
     * 保存草稿
     * 
     * @param commonEventEditDTO
     *            保存草稿传递对象
     * @return 新增结果
     */
    @PostMapping("/draft")
    @ApiOperation(value = "保存草稿", response = R.class)
    R saveDraft(@Validated @RequestBody CommonEventEditDTO commonEventEditDTO) {
        ClazzUtils.setIfStringIsEmpty(commonEventEditDTO);
        ClazzUtils.setIfStringIsEmpty(commonEventEditDTO);
        if (!isCommonType(commonEventEditDTO.getEventType())) {
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventEditDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventEditDTO.setUserName(loginUserInfoVO.getNickName());
        commonEventEditDTO.setPhone(loginUserInfoVO.getPhone());
        return gridService.saveDraft(commonEventEditDTO);
    }
 
    /**
     * 上报社区
     * 
     * @param commonEventReportDTO
     *            上报社区传递对象
     * @return 上报结果
     */
    @PutMapping("/report")
    @ApiOperation(value = "上报社区", response = R.class)
    R report(@Validated @RequestBody CommonEventReportDTO commonEventReportDTO) {
        LoginUserInfoVO loginUserInfoVO = getLoginUserInfo();
        ClazzUtils.setIfStringIsEmpty(commonEventReportDTO);
        commonEventReportDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventReportDTO.setUserName(loginUserInfoVO.getNickName());
        commonEventReportDTO.setCommunityId(loginUserInfoVO.getCommunityId());
        return gridService.report(commonEventReportDTO);
    }
 
    /**
     * 处理事件
     * 
     * @param commonEventDealDTO
     *            修改事件传递对象
     * @return 处理结果
     */
    @PutMapping("/deal")
    @ApiOperation(value = "处理事件", response = R.class)
    R deal(@Validated @RequestBody CommonEventDealDTO commonEventDealDTO) {
        ClazzUtils.setIfStringIsEmpty(commonEventDealDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventDealDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventDealDTO.setUserName(loginUserInfoVO.getNickName());
        commonEventDealDTO.setOperateType(0);
        commonEventDealDTO.setCommunityId(loginUserInfoVO.getCommunityId());
        commonEventDealDTO.setCommunityName(loginUserInfoVO.getCommunityName());
        return gridService.dealEvent(commonEventDealDTO);
    }
 
    /**
     * 验证事件
     * 
     * @param commonEventVerifyDTO
     *            验证事件传递对象
     * @return 验证结果
     */
    @PutMapping("/verify")
    @ApiOperation(value = "验证事件", response = R.class)
    R verify(@Validated @RequestBody CommonEventVerifyDTO commonEventVerifyDTO) {
        ClazzUtils.setIfStringIsEmpty(commonEventVerifyDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventVerifyDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventVerifyDTO.setUserName(loginUserInfoVO.getNickName());
        return gridService.verifyEvent(commonEventVerifyDTO);
    }
 
    /**
     * 直接上报社区
     * 
     * @param commonEventDirectReportDTO
     *            上报社区传递对象
     * @return 上报结果
     */
    @PostMapping("/reportDirect")
    @ApiOperation(value = "直接上报社区", response = R.class)
    R reportDirect(@Validated @RequestBody CommonEventDirectReportDTO commonEventDirectReportDTO) {
        LoginUserInfoVO loginUserInfoVO = getLoginUserInfo();
        ClazzUtils.setIfStringIsEmpty(commonEventDirectReportDTO);
        commonEventDirectReportDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventDirectReportDTO.setUserName(loginUserInfoVO.getNickName());
        commonEventDirectReportDTO.setCommunityId(loginUserInfoVO.getCommunityId());
        return gridService.reportDirect(commonEventDirectReportDTO);
    }
 
}