Commit 10e7bf5050ddb14a2e3d92712aa7b36546b5f5c3
1 parent
ab92cd52df
Exists in
master
and in
6 other branches
产检医生统计-查看两次(含)以上人数/五次(含)以上人数接口优化
Showing 1 changed file with 40 additions and 4 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
10e7bf5
... | ... | @@ -8,11 +8,15 @@ |
8 | 8 | import com.lyms.platform.operate.web.service.IReportService; |
9 | 9 | import com.lyms.platform.operate.web.utils.MathUtil; |
10 | 10 | import com.lyms.platform.operate.web.utils.ResponseUtil; |
11 | +import com.lyms.platform.operate.web.utils.SystemDataSource; | |
11 | 12 | import org.apache.commons.lang.StringUtils; |
12 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
13 | 14 | import org.springframework.stereotype.Service; |
14 | 15 | |
15 | 16 | import javax.servlet.http.HttpServletResponse; |
17 | +import java.sql.PreparedStatement; | |
18 | +import java.sql.ResultSet; | |
19 | +import java.sql.SQLException; | |
16 | 20 | import java.util.*; |
17 | 21 | |
18 | 22 | /** |
... | ... | @@ -31,6 +35,9 @@ |
31 | 35 | |
32 | 36 | private static final Map<String, String> colorMap = new HashMap<>(); |
33 | 37 | |
38 | + @Autowired | |
39 | + private SystemDataSource db; | |
40 | + | |
34 | 41 | static { |
35 | 42 | colorMap.put("绿色预警", "#50e39f"); |
36 | 43 | colorMap.put("黄色预警", "#ffd84d"); |
... | ... | @@ -261,10 +268,39 @@ |
261 | 268 | BaseObjectResponse rest = new BaseObjectResponse(); |
262 | 269 | List<Object> params = new ArrayList<>(); |
263 | 270 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
264 | - PageResult page = findPage(getDoctorInfoSql(startDate, endDate, childBirth, number, name, hospitalId, params), currentPage, pageSize, params); | |
265 | - List<Map<String, Object>> grid = (List<Map<String, Object>>) page.getGrid(); | |
266 | - setColor(grid); | |
267 | - rest.setData(page); | |
271 | + | |
272 | + StringBuilder countSql = new StringBuilder(); | |
273 | + String sql = getDoctorInfoSql(startDate, endDate, childBirth, number, name, hospitalId, params); | |
274 | + countSql.append("select count(1) from ( ") | |
275 | + .append(sql) | |
276 | + .append(" )"); | |
277 | + PreparedStatement pstmt = null; | |
278 | + try { | |
279 | + pstmt = db.getDataSource().getConnection().prepareStatement(countSql.toString()); | |
280 | + for (int i = 1; i <= params.size(); i++) { | |
281 | + pstmt.setString(i, params.get(i - 1).toString()); | |
282 | + } | |
283 | + ResultSet rs = pstmt.executeQuery(); | |
284 | + rs.next(); | |
285 | + int count = rs.getInt(1); | |
286 | + | |
287 | + List<Map<String, Object>> rows = reportDao.findList(sql, currentPage, pageSize, params); | |
288 | + | |
289 | + PageResult pageResult = new PageResult(count, currentPage, pageSize, rows); | |
290 | + List<Map<String, Object>> grid = (List<Map<String, Object>>) pageResult.getGrid(); | |
291 | + setColor(grid); | |
292 | + rest.setData(pageResult); | |
293 | + } catch (SQLException e) { | |
294 | + e.printStackTrace(); | |
295 | + rest.setErrorcode(500); | |
296 | + rest.setErrormsg(e.getMessage()); | |
297 | + } | |
298 | + | |
299 | + | |
300 | + // PageResult page = findPage(getDoctorInfoSql(startDate, endDate, childBirth, number, name, hospitalId, params), currentPage, pageSize, params); | |
301 | +// List<Map<String, Object>> grid = (List<Map<String, Object>>) page.getGrid(); | |
302 | +// setColor(grid); | |
303 | +// rest.setData(page); | |
268 | 304 | return rest; |
269 | 305 | } |
270 | 306 |