Administrator
2023-08-10 bd3916f68a3f8971bfe8c78b0b71e87fba643e11
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
package com.ruoyi.app.patrolplan.controller;
 
import java.text.ParseException;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpoint;
import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpointRecord;
import com.ruoyi.app.patrolplan.domain.param.ArdAppPatrolpointRecordParam;
import com.ruoyi.app.patrolplan.service.IArdAppPatrolpointRecordService;
import com.ruoyi.app.patrolplan.service.IArdAppPatrolpointService;
import com.ruoyi.app.patrolplan.service.IArdAppPatroluserService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.patrolplan.domain.ArdAppPatrolplan;
import com.ruoyi.app.patrolplan.service.IArdAppPatrolplanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
 
/**
 * app巡检计划Controller
 * 
 * @author ard
 * @date 2023-08-02
 */
@RestController
@RequestMapping("/app/appPatrolplan")
@Api(tags = "app巡检计划")
public class ArdAppPatrolplanController extends BaseController
{
    @Autowired
    private IArdAppPatrolplanService ardAppPatrolplanService;
 
    @Resource
    IArdAppPatrolpointService ardAppPatrolpointService;
 
    @Resource
    IArdAppPatroluserService ardAppPatroluserService;
 
    @Resource
    ISysUserService sysUserService;
 
    @Resource
    ISysDeptService sysDeptService;
 
    @Resource
    IArdAlarmpointsWellService wellService;
 
    @Resource
    IArdAppPatrolpointRecordService recordService;
 
    /**
     * 查询app巡检计划列表
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:list')")
    @GetMapping("/list")
    @ApiOperation("查询全部巡检列表及搜索筛选")
    public Results list(ArdAppPatrolplan ardAppPatrolplan)
    {
        String userId = SecurityUtils.getUserId();
        ardAppPatrolplan.setUserId(userId);
        if(ardAppPatrolplan.getPageNum()==null || ardAppPatrolplan.getPageNum() == 0){
            ardAppPatrolplan.setPageNum(1);
        }
        if(ardAppPatrolplan.getPageSize()==null || ardAppPatrolplan.getPageSize() == 0){
            ardAppPatrolplan.setPageSize(10);
        }
        PageHelper.startPage(ardAppPatrolplan.getPageNum(),ardAppPatrolplan.getPageSize());
        List<ArdAppPatrolplan> list = ardAppPatrolplanService.selectArdAppPatrolplanList(ardAppPatrolplan);
        return Results.succeed(new PageInfo<>(list));
    }
 
    /**
     * 导出app巡检计划列表
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:export')")
    @Log(title = "app巡检计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出全部巡检列表")
    public void export(HttpServletResponse response, ArdAppPatrolplan ardAppPatrolplan)
    {
        List<ArdAppPatrolplan> list = ardAppPatrolplanService.selectArdAppPatrolplanList(ardAppPatrolplan);
        ExcelUtil<ArdAppPatrolplan> util = new ExcelUtil<ArdAppPatrolplan>(ArdAppPatrolplan.class);
        util.exportExcel(response, list, "app巡检计划数据");
    }
 
    /**
     * 根据巡检ID查询兴趣点
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:wellByPlanId')")
    @GetMapping(value = "wellByPlanId/{id}")
    @ApiOperation("根据巡检ID查询兴趣点")
    public Results wellByPlanId(@PathVariable String id)
    {
        return ardAppPatrolpointService.wellByPlanId(id);
    }
 
    /**
     * 根据巡检ID查询巡检人
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:userByPlanId')")
    @GetMapping(value = "userByPlanId/{id}")
    @ApiOperation("根据巡检ID查询巡检人员")
    public Results userByPlanId(@PathVariable String id)
    {
        return ardAppPatroluserService.userByPlanId(id);
    }
 
    /**
     * 删除app巡检计划
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:remove')")
    @Log(title = "app巡检计划", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    @ApiOperation("删除app巡检计划")
    //public Results remove(@PathVariable String id)
    public AjaxResult remove(@PathVariable String id)
    {
        //return ardAppPatrolplanService.deleteArdApp(id);
        return toAjax(ardAppPatrolplanService.deleteArdApp(id));
    }
 
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:allPlanUser')")
    @PostMapping("allPlanUser")
    @ApiOperation("查询权限下全部人员和兴趣点")
    public Results allPlanUser()
    {
        JSONObject jsonObject = new JSONObject();
        String userId = SecurityUtils.getUserId();
        //根据userId查询部门Id
        SysUser sysUser = sysUserService.selectUserById(userId);
        //根据当前deptId或者当前及所属下级的所有deptId
        List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
        //根据deptId列表获取到所有用户
        List<SysUser> sysUserList = sysUserService.userByDeptList(deptList);
        jsonObject.put("user",sysUserList);
        //根据deptId列表获取到所有兴趣点
        List<ArdAlarmpointsWell> wellList = wellService.wellByDeptList(deptList);
        jsonObject.put("well",wellList);
        return Results.succeed(jsonObject);
    }
 
    /**
     * 新增app巡检计划及人员点位
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:insertArdAppPatrolplan')")
    @Log(title = "app巡检计划", businessType = BusinessType.INSERT)
    @PostMapping("/insertArdAppPatrolplan")
    @ApiOperation("新增app巡检计划及人员点位")
    public AjaxResult addArdAppPatrolplan(@RequestBody Map<String,Object> para)
    {
        return toAjax(ardAppPatrolplanService.insertArdAppPatrolplan(para));
    }
 
    /**
     * 查询单条数据
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:oneById')")
    @PostMapping("/oneById/{id}")
    @ApiOperation("查询单条数据")
    public Results oneById(@PathVariable String id)
    {
        return ardAppPatrolplanService.oneById(id);
    }
 
    /**
     * 修改app巡检计划
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:edit')")
    @Log(title = "app巡检计划", businessType = BusinessType.UPDATE)
    @ApiOperation("修改单条数据")
    @PutMapping("upd")
    public Results edit(@RequestBody Map<String,Object> para)
    {
        return ardAppPatrolplanService.updateArdAppPatrolplan(para);
    }
 
    /**
     * 巡检打卡
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:record')")
    @ApiOperation("巡检打卡")
    @PostMapping("record")
    public Results edit(@RequestBody ArdAppPatrolpointRecord ardAppPatrolpointRecord) {
        return recordService.record(ardAppPatrolpointRecord);
    }
 
    /**
     * 巡检日历
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:recordMonth')")
    @ApiOperation("巡检日历")
    @PostMapping("recordMonth")
    public Results recordMonth(@RequestBody ArdAppPatrolpointRecordParam ardAppPatrolpointRecordParam) throws ParseException {
        return recordService.recordMonth(ardAppPatrolpointRecordParam);
    }
 
}