ZQN
2024-09-03 5944c9ea054165cc4adfa79254f9b724abc371db
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package com.project.admin.controller.enforce;
 
import com.project.common.annotation.Log;
import com.project.common.annotation.RepeatSubmit;
import com.project.common.core.controller.BaseController;
import com.project.common.core.domain.AjaxResult;
import com.project.common.core.domain.entity.SysDept;
import com.project.common.core.domain.entity.SysUser;
import com.project.common.core.page.TableDataInfo;
import com.project.common.enums.BusinessType;
import com.project.common.utils.SecurityUtils;
import com.project.common.utils.StringUtils;
import com.project.common.utils.poi.ExcelUtil;
import com.project.enforce.domain.bo.editBo.EnforceOrderBo;
import com.project.enforce.domain.bo.editBo.OrderComplaintBo;
import com.project.enforce.domain.bo.editBo.OrderResultBo;
import com.project.enforce.domain.bo.queryBo.EnforceOrderQueryBo;
import com.project.enforce.domain.bo.queryBo.OrderCheckedQueryBo;
import com.project.enforce.domain.vo.EnforceOrderVo;
import com.project.enforce.domain.vo.OrderNodeVo;
import com.project.enforce.service.IEnforceOrderService;
import com.project.system.service.ISysDeptService;
import com.project.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.List;
 
/**
 * 执法单Controller
 *
 * @author manton
 */
@Api(value = "执法单控制器", tags = {"执法单管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/enforce/order")
public class EnforceOrderController extends BaseController {
 
    private final IEnforceOrderService iEnforceOrderService;
    private final ISysUserService userService;
    private final ISysDeptService deptService;
 
    @ApiOperation("获取同行人")
    @GetMapping("/peerList")
    @Cacheable(value = "sysUser:peerList")
    public AjaxResult peerList(String nickName, Long deptId)
    {
        String queryScope = " (dept_id = {} OR dept_id IN ( SELECT dept_id FROM sys_dept  WHERE find_in_set({}, ancestors) )) ";
        if (deptId==null){
            deptId = deptService.getCheckDeptIdByLoginDeptId(SecurityUtils.getDeptId());
        } else {
            deptId = deptService.getCheckDeptIdByLoginDeptId(deptId);
        }
        List<SysUser> list = userService.list(userService.lq()
                .ne(SysUser::getUserType,"02")
                .ne(SysUser::getUserName,"admin")
                .ne(SysUser::getUserId, SecurityUtils.getUserId())
                .likeRight(StringUtils.isNotEmpty(nickName), SysUser::getNickName,nickName)
                .apply( StringUtils.format(queryScope, deptId, deptId))
        );
        list.forEach(user->{
            SysDept sysDept = deptService.selectDeptById(user.getDeptId());
            sysDept.setDeptName(deptService.getDeptAllName(sysDept.getDeptId()));
            user.setDept(sysDept);
        });
        return AjaxResult.success(list);
    }
 
    @ApiOperation("列表——无特殊查询")
    @GetMapping("/commonList")
    public TableDataInfo commonList(EnforceOrderQueryBo bo)
    {
        if (bo.getCheckDeptId()==null){
            bo.setCheckDeptId(deptService.getCheckDeptIdByLoginDeptId(SecurityUtils.getDeptId()));
        }
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.queryCommonList(bo);
        return getDataTable(list);
    }
 
    @ApiOperation("列表——企业执法记录")
    @GetMapping("/companyList")
    public TableDataInfo companyList(EnforceOrderQueryBo bo)
    {
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.queryCompanyList(bo);
        return getDataTable(list);
    }
 
    @ApiOperation("列表——执法申请单")
    @GetMapping("/list")
    public TableDataInfo list(EnforceOrderQueryBo bo)
    {
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.queryList(bo);
        return getDataTable(list);
    }
 
    @ApiOperation("列表——执法执行单")
    @GetMapping("/execute/list")
    public TableDataInfo executeList(EnforceOrderQueryBo bo)
    {
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.getExecuteList(bo);
        return getDataTable(list);
    }
 
    @ApiOperation("列表——信息公式")
    @GetMapping("/showList")
    public TableDataInfo showList()
    {
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.showList();
        return getDataTable(list);
    }
 
 
    @ApiOperation("列表——审批人待审批")
    @GetMapping("/checkList")
    public TableDataInfo checkList(EnforceOrderQueryBo bo)
    {
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.queryCheckList(bo);
        return getDataTable(list);
    }
 
    @ApiOperation("列表——审批记录")
    @GetMapping("/checkedList")
    public TableDataInfo checkedList(OrderCheckedQueryBo bo)
    {
        startPage();
        List<EnforceOrderVo> list = iEnforceOrderService.queryCheckedList(bo);
        return getDataTable(list);
    }
 
    @ApiOperation("执法人扫码")
    @GetMapping("/getScanList")
    public AjaxResult scan(@RequestParam("companyCode") String companyCode)
    {
        List<EnforceOrderVo> list = iEnforceOrderService.getScanList(companyCode);
        return AjaxResult.success(list);
    }
 
    @ApiOperation("确认执法")
    @Log(title = "执法队员确认执法", businessType = BusinessType.UPDATE)
    @PostMapping("/doScanOrder/{orderId}")
    public AjaxResult doScanOrder(@PathVariable("orderId") Long orderId)
    {
        return toAjax(iEnforceOrderService.doScanOrder(orderId));
    }
 
    @ApiOperation("上报结果")
    @Log(title = "执法队员上报结果", businessType = BusinessType.UPDATE)
    @PostMapping("/doResultOrder")
    public AjaxResult doResultOrder(@RequestBody OrderResultBo resultBo)
    {
        return AjaxResult.success(iEnforceOrderService.doResultOrder(resultBo));
    }
 
 
    @ApiOperation("执法单节点")
    @GetMapping("/orderNodeList")
    public AjaxResult orderNodeList(@RequestParam("orderId") Long orderId)
    {
        List<OrderNodeVo> list = iEnforceOrderService.orderNodeList(orderId);
        return AjaxResult.success(list);
    }
 
    @ApiOperation("执法单投诉")
    @Log(title = "执法单投诉", businessType = BusinessType.UPDATE)
    @PostMapping("/orderComplaint")
    public AjaxResult orderComplaint(@RequestBody OrderComplaintBo bo)
    {
        return toAjax(iEnforceOrderService.orderComplaint(bo));
    }
 
    @ApiOperation("执法单投诉节点")
    @GetMapping("/orderComplaintNodeList")
    public AjaxResult orderComplaintNodeList(@RequestParam("orderId") Long orderId)
    {
        List<OrderNodeVo> list = iEnforceOrderService.orderComplaintNodeList(orderId);
        return AjaxResult.success(list);
    }
 
    @ApiOperation("导出执法单列表")
    //@PreAuthorize("@ss.hasPermi('enforce:order:export')")
    @Log(title = "执法单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @RepeatSubmit
    public AjaxResult export(EnforceOrderQueryBo bo)
    {
        List<EnforceOrderVo> list = iEnforceOrderService.queryList(bo);
        ExcelUtil<EnforceOrderVo> util = new ExcelUtil<>(EnforceOrderVo.class);
        return util.exportExcel(list, "执法单");
    }
 
 
    @ApiOperation("获取执法单详细信息")
    @GetMapping("/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId" ) Long orderId)
    {
        return AjaxResult.success(iEnforceOrderService.queryById(orderId));
    }
 
 
 
    @ApiOperation("新增执法单")
    //@PreAuthorize("@ss.hasPermi('enforce:order:add')")
    @Log(title = "执法单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @RepeatSubmit
    public AjaxResult add(@RequestBody EnforceOrderBo bo)
    {
        return toAjax(iEnforceOrderService.insertByBo(bo) ? 1 : 0);
    }
 
 
    @ApiOperation("修改执法单")
    //@PreAuthorize("@ss.hasPermi('enforce:order:edit')")
    @Log(title = "执法单", businessType = BusinessType.UPDATE)
    @PostMapping("/upd")
    @RepeatSubmit
    public AjaxResult upd(@RequestBody EnforceOrderBo bo)
    {
        return toAjax(iEnforceOrderService.updateByBo(bo) ? 1 : 0);
    }
 
 
    @ApiOperation("删除执法单")
    //@PreAuthorize("@ss.hasPermi('enforce:order:remove')")
    @Log(title = "执法单" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{orderIds}")
    @RepeatSubmit
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(iEnforceOrderService.deleteByIds(Arrays.asList(orderIds)) ? 1 : 0);
    }
 
 
    @ApiOperation("企业确认——执法单")
    //@PreAuthorize("@ss.hasPermi('enforce:order:remove')")
    @Log(title = "企业确认执法单" , businessType = BusinessType.UPDATE)
    @PostMapping("/confirm/{orderId}")
    @RepeatSubmit
    public AjaxResult remove(@PathVariable Long orderId)
    {
        return toAjax(iEnforceOrderService.confirm(orderId) ? 1 : 0);
    }
}