ViolationCaseFileController.java
6.99 KB
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
package com.trash.casefile.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.trash.casefile.domain.ViolationWarningInformation;
import com.trash.casefile.domain.vo.ViolationCaseFileVo;
import com.trash.casefile.domain.vo.ViolationWarningInformationVo;
import com.trash.office.domain.UploadFile;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.trash.common.annotation.Log;
import com.trash.common.core.controller.BaseController;
import com.trash.common.core.domain.AjaxResult;
import com.trash.common.enums.BusinessType;
import com.trash.casefile.domain.ViolationCaseFile;
import com.trash.casefile.service.IViolationCaseFileService;
import com.trash.common.utils.DateUtils;
import com.trash.common.utils.SecurityUtils;
import com.trash.common.utils.poi.ExcelUtil;
import com.trash.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 平台违规案卷Controller
*
* @author 2c
* @date 2023-05-11
*/
@RestController
@RequestMapping("/casefile/violationCaseFile")
public class ViolationCaseFileController extends BaseController
{
@Autowired
private IViolationCaseFileService violationCaseFileService;
/**
* 查询平台违规案卷列表
*/
@PreAuthorize("@ss.hasPermi('casefile:violationCaseFile:list')")
@GetMapping("/list")
public TableDataInfo list(ViolationCaseFile violationCaseFile)
{
startPage();
List<ViolationCaseFile> list = violationCaseFileService.selectViolationCaseFileList(violationCaseFile);
return getDataTable(list);
}
/**
* 导出平台违规案卷列表
*/
@PreAuthorize("@ss.hasPermi('casefile:violationCaseFile:export')")
@Log(title = "平台违规案卷", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(ViolationCaseFile violationCaseFile)
{
List<ViolationCaseFile> list = violationCaseFileService.selectViolationCaseFileList(violationCaseFile);
ExcelUtil<ViolationCaseFile> util = new ExcelUtil<ViolationCaseFile>(ViolationCaseFile.class);
return util.exportExcel(list, "平台违规案卷数据");
}
/**
* 获取平台违规案卷详细信息
*/
@PreAuthorize("@ss.hasPermi('casefile:violationCaseFile:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(violationCaseFileService.selectViolationCaseFileById(id));
}
/**
* 新增平台违规案卷
*/
@PreAuthorize("@ss.hasPermi('casefile:violationCaseFile:add')")
@Log(title = "平台违规案卷", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestParam(value = "fileList") MultipartFile[] files, ViolationCaseFile violationCaseFile) throws IOException
{
return toAjax(violationCaseFileService.insertViolationCaseFile(files,violationCaseFile));
}
/**
* 修改平台违规案卷
*/
@PreAuthorize("@ss.hasPermi('casefile:violationCaseFile:edit')")
@Log(title = "平台违规案卷", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestParam(value = "fileList") MultipartFile[] files, String violationCaseFile, String[] uploadFilesList) throws IOException
{
ViolationCaseFileVo violationCaseFileVo = new ViolationCaseFileVo();
violationCaseFileVo.setViolationCaseFile(JSON.parseObject(violationCaseFile, ViolationCaseFile.class));
List<UploadFile> uploadFileList = new ArrayList<>();
for (String uploadFile : uploadFilesList) {
UploadFile uploadFile1 = JSON.parseObject(uploadFile,UploadFile.class);
if(uploadFile1!=null){
if(uploadFile1.getId()!=null){
uploadFileList.add(uploadFile1);
}
}
}
violationCaseFileVo.setUploadFiles(uploadFileList);
return toAjax(violationCaseFileService.updateViolationCaseFile(files,violationCaseFileVo));
}
@PutMapping(value="updateViolationCaseFileReader")
public int updateViolationCaseFileReader(@RequestBody ViolationCaseFile violationCaseFile) throws IOException
{
try {
violationCaseFile.setReadBy(SecurityUtils.getUsername());
violationCaseFile.setReadTime(DateUtils.getNowDate());
violationCaseFileService.updateViolationCaseFile(violationCaseFile);
return 1;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
String[] caseType = {"进入非专用车辆","无许可手续(工)","无许可手续(消)","黄土覆盖情况","出入口路面污染","出入口道路硬化","车辆冲洗是否到位",
"雾炮机是否正常开启","使用费专用车运输","监控点位未对准","未报开工作业","视频设备离线超时报警","三无车辆进入工地","未按时间作业",
"未报开工作业","视频设备离线超时报警","三无车辆进入消纳场","未到指定的消纳场作业","离线运输报警(工)","离线运输报警(消)","未激活车辆作业",
"未核准作业车辆作业","未按线路行驶","闯禁行驶","失信车辆作业","其他1","其他2","其他3","其他4","其他5"};
@GetMapping(value = "/caseTable")
public AjaxResult getTable(){
List<HashMap<String, String>> maps = new ArrayList<HashMap<String,String>>();
List<ViolationCaseFile> list = violationCaseFileService.selectViolationCaseFileList(new ViolationCaseFile());
for(String type:caseType){
HashMap<String, String> map = new HashMap<>();
map.put("type", type);
int count = 0;
int repCount = 0;
for(ViolationCaseFile file:list){
if(type.equals(file.getViolationType())){
count +=1;
if(file.getReadBy() != null && !file.getReadBy().isEmpty()){
repCount += 1;
}
}
}
map.put("count", count + "");
map.put("repCount", repCount + "");
if(count == 0){
double pct = ((double)repCount)/((double)count);
map.put("repPct","0%");
maps.add(map);
}else{
double pct = ((double)repCount)/((double)count);
map.put("repPct",(pct*100) + "%");
maps.add(map);
}
}
return AjaxResult.success(maps);
}
/**
* 删除平台违规案卷
*/
@PreAuthorize("@ss.hasPermi('casefile:violationCaseFile:remove')")
@Log(title = "平台违规案卷", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) throws IOException
{
return toAjax(violationCaseFileService.deleteViolationCaseFileByIds(ids));
}
}