|
@@ -7,14 +7,23 @@ import com.example.civilizedcity.common.*;
|
7
|
7
|
import com.example.civilizedcity.entity.SysUser;
|
8
|
8
|
import com.example.civilizedcity.entity.TaCheckItem;
|
9
|
9
|
import com.example.civilizedcity.service.TaCheckItemService;
|
|
10
|
+import com.example.civilizedcity.vo.CheckLocExport;
|
10
|
11
|
import io.swagger.annotations.Api;
|
11
|
12
|
import io.swagger.annotations.ApiOperation;
|
12
|
13
|
import io.swagger.annotations.ApiParam;
|
13
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
+import org.springframework.beans.factory.annotation.Value;
|
14
|
16
|
import org.springframework.web.bind.annotation.*;
|
15
|
17
|
import com.example.civilizedcity.entity.TaCheck;
|
16
|
18
|
import com.example.civilizedcity.service.TaCheckService;
|
17
|
19
|
|
|
20
|
+import javax.servlet.http.HttpServletResponse;
|
|
21
|
+import java.io.FileInputStream;
|
|
22
|
+import java.io.InputStream;
|
|
23
|
+import java.util.HashMap;
|
|
24
|
+import java.util.List;
|
|
25
|
+import java.util.Map;
|
|
26
|
+
|
18
|
27
|
/**
|
19
|
28
|
* 模拟测评;(ta_check)表控制层
|
20
|
29
|
*
|
|
@@ -32,6 +41,9 @@ public class TaCheckController extends BaseController {
|
32
|
41
|
@Autowired
|
33
|
42
|
private TaCheckItemService taCheckItemService;
|
34
|
43
|
|
|
44
|
+ @Value("${yz.excel.tpl.check}")
|
|
45
|
+ String tplPath;
|
|
46
|
+
|
35
|
47
|
/**
|
36
|
48
|
* 通过ID查询单条数据
|
37
|
49
|
*
|
|
@@ -112,6 +124,59 @@ public class TaCheckController extends BaseController {
|
112
|
124
|
}
|
113
|
125
|
|
114
|
126
|
|
|
127
|
+ /**
|
|
128
|
+ * 导出实地测评
|
|
129
|
+ *
|
|
130
|
+ * @param taCheck 实例对象
|
|
131
|
+ * @return 实例对象
|
|
132
|
+ */
|
|
133
|
+ @ApiOperation("导出实地测评")
|
|
134
|
+ @PostMapping("/taCheck/{id}/loc/export")
|
|
135
|
+ public ResponseBean exportLoc(@ApiParam("对象ID") @PathVariable String id,
|
|
136
|
+ HttpServletResponse response) throws Exception {
|
|
137
|
+ TaCheck taCheck = taCheckService.getById(id);
|
|
138
|
+ List<CheckLocExport> list = taCheckItemService.getExportByCheck(id, Constants.CHECK_OF_LOC);
|
|
139
|
+ if (null == list) {
|
|
140
|
+ return ResponseBean.error("当前测评数据不正确");
|
|
141
|
+ }
|
|
142
|
+
|
|
143
|
+ Double totalFullScore = 0.0;
|
|
144
|
+ Integer totalAnswerNum = 0;
|
|
145
|
+ Integer totalNum = 0;
|
|
146
|
+ Double totalSubtotal = 0.0;
|
|
147
|
+ Double totalScore = 0.0;
|
|
148
|
+
|
|
149
|
+ for (CheckLocExport item : list) {
|
|
150
|
+ totalFullScore += getVal(item.getFullScore());
|
|
151
|
+ totalAnswerNum += getVal(item.getAnswerNum());
|
|
152
|
+ totalNum += getVal(item.getNum());
|
|
153
|
+ totalSubtotal += getVal(item.getSubtotal());
|
|
154
|
+ totalScore += getVal(item.getScore());
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ String title = taCheck.getTitle() + " 实地测评";
|
|
158
|
+ Map<String, Object> map = new HashMap<>();
|
|
159
|
+ map.put("totalFullScore", totalFullScore);
|
|
160
|
+ map.put("totalAnswerNum", totalAnswerNum);
|
|
161
|
+ map.put("totalNum", totalNum);
|
|
162
|
+ map.put("totalSubtotal", totalSubtotal);
|
|
163
|
+ map.put("totalScore", totalScore);
|
|
164
|
+ map.put("title", title);
|
|
165
|
+
|
|
166
|
+ InputStream tpl = new FileInputStream(tplPath);
|
|
167
|
+ ExcelUtils.flushFile(response, tpl, CheckLocExport.class, list, map, title);
|
|
168
|
+
|
|
169
|
+ return null;
|
|
170
|
+ }
|
|
171
|
+
|
|
172
|
+ private Double getVal(Double d) {
|
|
173
|
+ return null == d ? 0.0 : d;
|
|
174
|
+ }
|
|
175
|
+ private Integer getVal(Integer d) {
|
|
176
|
+ return null == d ? 0 : d;
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+
|
115
|
180
|
/**
|
116
|
181
|
* 复制
|
117
|
182
|
*
|