Commit 4325f1081624ffeaee747091f96c9be59064dbdf
1 parent
5f45119382
Exists in
master
and in
6 other branches
update
Showing 3 changed files with 202 additions and 12 deletions
platform-dal/src/main/java/com/lyms/platform/pojo/HealthChargeModel.java
View file @
4325f10
... | ... | @@ -61,6 +61,48 @@ |
61 | 61 | */ |
62 | 62 | private String doctorId; |
63 | 63 | |
64 | + //支持导入使用,存储导入数据记录和转换使用。 | |
65 | + //患者姓名 | |
66 | + private String name; | |
67 | + //身份证号码 | |
68 | + private String cardNo; | |
69 | + //计费时间 | |
70 | + private String createdStr; | |
71 | + //开单医生 | |
72 | + private String doctorName; | |
73 | + | |
74 | + public String getCreatedStr() { | |
75 | + return createdStr; | |
76 | + } | |
77 | + | |
78 | + public void setCreatedStr(String createdStr) { | |
79 | + this.createdStr = createdStr; | |
80 | + } | |
81 | + | |
82 | + public String getName() { | |
83 | + return name; | |
84 | + } | |
85 | + | |
86 | + public void setName(String name) { | |
87 | + this.name = name; | |
88 | + } | |
89 | + | |
90 | + public String getCardNo() { | |
91 | + return cardNo; | |
92 | + } | |
93 | + | |
94 | + public void setCardNo(String cardNo) { | |
95 | + this.cardNo = cardNo; | |
96 | + } | |
97 | + | |
98 | + public String getDoctorName() { | |
99 | + return doctorName; | |
100 | + } | |
101 | + | |
102 | + public void setDoctorName(String doctorName) { | |
103 | + this.doctorName = doctorName; | |
104 | + } | |
105 | + | |
64 | 106 | public String getBabyNutritionId() { |
65 | 107 | return babyNutritionId; |
66 | 108 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HealthChargeController.java
View file @
4325f10
... | ... | @@ -4,20 +4,13 @@ |
4 | 4 | import com.lyms.platform.common.annotation.TokenRequired; |
5 | 5 | import com.lyms.platform.common.base.BaseController; |
6 | 6 | import com.lyms.platform.common.base.LoginContext; |
7 | -import com.lyms.platform.common.constants.ErrorCodeConstants; | |
8 | -import com.lyms.platform.common.result.BaseObjectResponse; | |
9 | 7 | import com.lyms.platform.common.result.BaseResponse; |
10 | -import com.lyms.platform.common.utils.StringUtils; | |
11 | -import com.lyms.platform.operate.web.facade.AutoMatchFacade; | |
12 | -import com.lyms.platform.operate.web.facade.BabyCheckFacade; | |
13 | 8 | import com.lyms.platform.operate.web.facade.HealthChargeFacade; |
14 | -import com.lyms.platform.operate.web.request.BabyCheckRequest; | |
15 | 9 | import com.lyms.platform.operate.web.request.HealthChargeRequest; |
16 | -import com.lyms.platform.operate.web.request.RiskPatientsCountRequest; | |
17 | -import com.lyms.platform.permission.service.CouponService; | |
18 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
19 | 11 | import org.springframework.stereotype.Controller; |
20 | 12 | import org.springframework.web.bind.annotation.*; |
13 | +import org.springframework.web.multipart.MultipartFile; | |
21 | 14 | |
22 | 15 | import javax.servlet.http.HttpServletRequest; |
23 | 16 | import javax.servlet.http.HttpServletResponse; |
... | ... | @@ -76,6 +69,21 @@ |
76 | 69 | BaseResponse baseResponse =healthChargeFacade.getHealthCharges(healthType, hospitalId, time, source, status, type, page, limit, loginState.getId(), doctorId); |
77 | 70 | return baseResponse; |
78 | 71 | } |
72 | + | |
73 | + /** | |
74 | + * 体重报告结算导入2007 excle的方法 | |
75 | + * sieveType=1 | |
76 | + * @param request | |
77 | + * @param response | |
78 | + */ | |
79 | + @RequestMapping(value = "/importHealthCharges") | |
80 | + @ResponseBody | |
81 | + @TokenRequired | |
82 | + public BaseResponse importSerologySieve(@RequestParam MultipartFile file, HttpServletRequest request, HttpServletResponse response) { | |
83 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
84 | + return healthChargeFacade.importHealthCharges(file, loginState.getId(), response); | |
85 | + } | |
86 | + | |
79 | 87 | |
80 | 88 | /** |
81 | 89 | *结算 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/HealthChargeFacade.java
View file @
4325f10
... | ... | @@ -9,25 +9,33 @@ |
9 | 9 | import com.lyms.platform.common.utils.ExcelUtil; |
10 | 10 | import com.lyms.platform.common.utils.StringUtils; |
11 | 11 | import com.lyms.platform.operate.web.request.HealthChargeRequest; |
12 | -import com.lyms.platform.operate.web.service.ITemporaryBloodService; | |
13 | -import com.lyms.platform.operate.web.service.ITemporaryBloodSugarService; | |
14 | -import com.lyms.platform.operate.web.service.TemporaryWeightService; | |
15 | 12 | import com.lyms.platform.permission.model.Users; |
13 | +import com.lyms.platform.permission.model.UsersQuery; | |
16 | 14 | import com.lyms.platform.permission.service.UsersService; |
17 | 15 | import com.lyms.platform.pojo.*; |
18 | 16 | import com.lyms.platform.query.AntExRecordQuery; |
19 | 17 | import com.lyms.platform.query.ChargeRecordQuery; |
20 | 18 | import com.lyms.platform.query.HealthChargeQuery; |
19 | +import com.lyms.platform.query.PatientsQuery; | |
21 | 20 | import org.apache.commons.collections.CollectionUtils; |
21 | +import org.apache.commons.fileupload.disk.DiskFileItem; | |
22 | 22 | import org.apache.commons.lang.math.NumberUtils; |
23 | +import org.apache.poi.xssf.usermodel.XSSFCell; | |
24 | +import org.apache.poi.xssf.usermodel.XSSFRow; | |
25 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | |
26 | +import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |
23 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 28 | import org.springframework.data.domain.Sort; |
25 | 29 | import org.springframework.data.mongodb.core.MongoTemplate; |
26 | 30 | import org.springframework.data.mongodb.core.query.Criteria; |
27 | 31 | import org.springframework.data.mongodb.core.query.Query; |
28 | 32 | import org.springframework.stereotype.Component; |
33 | +import org.springframework.web.multipart.MultipartFile; | |
34 | +import org.springframework.web.multipart.commons.CommonsMultipartFile; | |
29 | 35 | |
30 | 36 | import javax.servlet.http.HttpServletResponse; |
37 | +import java.io.File; | |
38 | +import java.io.FileInputStream; | |
31 | 39 | import java.io.OutputStream; |
32 | 40 | import java.util.*; |
33 | 41 | |
34 | 42 | |
35 | 43 | |
... | ... | @@ -37,11 +45,15 @@ |
37 | 45 | */ |
38 | 46 | @Component |
39 | 47 | public class HealthChargeFacade { |
48 | + @Autowired | |
49 | + private AutoMatchFacade autoMatchFacade; | |
40 | 50 | |
41 | 51 | @Autowired |
52 | + private OperateLogFacade operateLogFacade; | |
53 | + | |
54 | + @Autowired | |
42 | 55 | private HealthChargeService healthChargeService; |
43 | 56 | |
44 | - | |
45 | 57 | @Autowired |
46 | 58 | private ChargeRecordService chargeRecordService; |
47 | 59 | |
... | ... | @@ -262,6 +274,134 @@ |
262 | 274 | } |
263 | 275 | return new BaseListResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(listData).setPageInfo(healthChargeQuery.getPageInfo()); |
264 | 276 | } |
277 | + | |
278 | + /** | |
279 | + * 体重报告结算导入2007 excle的方法 | |
280 | + * @author 武涛涛 | |
281 | + */ | |
282 | + public BaseResponse importHealthCharges(MultipartFile file, Integer id, HttpServletResponse response) { | |
283 | + | |
284 | + try { | |
285 | + String hospitalId = autoMatchFacade.getHospitalId(id); | |
286 | + | |
287 | + //把MultipartFile转化为File 第一种 | |
288 | + CommonsMultipartFile cmf = (CommonsMultipartFile) file; | |
289 | + DiskFileItem dfi = (DiskFileItem) cmf.getFileItem(); | |
290 | + File fo = dfi.getStoreLocation(); | |
291 | + // 创建对excel工作簿的引用 | |
292 | + XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(fo)); | |
293 | + | |
294 | + // 创建对工作表的引用,这里是按索引引用,第一张工作表的索引为0.也可以按名引用 | |
295 | + XSSFSheet sheet = workbook.getSheetAt(0); | |
296 | + // 需要得到总共的行数 | |
297 | + int rowNum = sheet.getLastRowNum(); | |
298 | + // 定义单元 | |
299 | + XSSFCell cell = null; | |
300 | + List<HealthChargeModel> healthChargeModelList = new ArrayList<>(); | |
301 | + // 按行循环读取 | |
302 | + | |
303 | + for (int j = 1; j <= rowNum; j++) { | |
304 | + HealthChargeModel chargeModel = new HealthChargeModel(); | |
305 | + // 得到该行对象 | |
306 | + XSSFRow rowLine = sheet.getRow(j); | |
307 | + // 获得该行的列数 | |
308 | + int colNum = rowLine.getLastCellNum(); | |
309 | + StringBuffer sb = new StringBuffer(); | |
310 | + // 按列读取每一行的各个单元格内容 | |
311 | + for (int i = 1; i < colNum; i++) { | |
312 | + //获取该行索引,对应的单元格,Value | |
313 | + cell = rowLine.getCell(i); | |
314 | + String cellValue = null; | |
315 | + if (cell != null) { | |
316 | + switch (cell.getCellType()) { | |
317 | + // 如果是数字格式 | |
318 | + case XSSFCell.CELL_TYPE_NUMERIC: | |
319 | + Integer number = new Integer( (int) cell.getNumericCellValue());// 数字 | |
320 | + cellValue = String.valueOf(number); | |
321 | + break; | |
322 | + case XSSFCell.CELL_TYPE_STRING: cellValue = cell.getStringCellValue();// 字符串 | |
323 | + break; | |
324 | + default: | |
325 | + cellValue = ""; | |
326 | + break; | |
327 | + } | |
328 | + | |
329 | + } else { | |
330 | + cellValue = ""; | |
331 | + } | |
332 | + switch (i) { | |
333 | + case 0: | |
334 | + chargeModel.setName(cellValue); //患者姓名 | |
335 | + break; | |
336 | + case 1: | |
337 | + chargeModel.setCardNo(cellValue); | |
338 | + break; | |
339 | + case 2: | |
340 | + chargeModel.setDoctorName(cellValue); | |
341 | + break; | |
342 | + case 3: | |
343 | + chargeModel.setCreatedStr(cellValue); | |
344 | + break; | |
345 | + } | |
346 | + | |
347 | + } | |
348 | + chargeModel.setStatus(1);//结算状态 1未结算 | |
349 | + chargeModel.setSource(1);//档案来源类型 1院内建档 | |
350 | + chargeModel.setType(1);//打印报告等级 1普通报告 | |
351 | + chargeModel.setHospitalId(hospitalId); //医院id | |
352 | + chargeModel.setHealthType(1);// 1体重 | |
353 | + chargeModel.setYn(YnEnums.YES.getId()); | |
354 | + chargeModel.setDoctorId(getUsersId(hospitalId, chargeModel.getDoctorName())); | |
355 | + chargeModel.setCreated(DateUtil.parseYMD(chargeModel.getCreatedStr())); | |
356 | + | |
357 | + String foreignId = getForeignId(hospitalId, chargeModel); | |
358 | + chargeModel.setForeignId(foreignId);//建档id或者临时档案id | |
359 | + chargeModel.setOperateUserId(String.valueOf(id)); | |
360 | + chargeModel.setModified(new Date()); | |
361 | + if(StringUtils.isNotEmpty(foreignId)){ | |
362 | + healthChargeService.addHealthCharge(chargeModel); | |
363 | + } | |
364 | + //System.out.println("chargeModel.toString(): " + chargeModel.toString()); | |
365 | + } | |
366 | + | |
367 | + } catch (Exception e) { | |
368 | + e.printStackTrace(); | |
369 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg("导入失败"); | |
370 | + } | |
371 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
372 | + } | |
373 | + | |
374 | + private String getForeignId(String hospitalId, HealthChargeModel chargeModel) { | |
375 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
376 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
377 | + patientsQuery.setHospitalId(hospitalId); | |
378 | + patientsQuery.setCardNo(chargeModel.getCardNo()); | |
379 | + patientsQuery.setExtSource(false); | |
380 | + List <Patients> patientsList = patientsService.queryPatient(patientsQuery); | |
381 | + if(CollectionUtils.isNotEmpty(patientsList)){ | |
382 | + Patients patients = patientsList.get(0); | |
383 | + return patients.getId(); | |
384 | + } | |
385 | + return null; | |
386 | + | |
387 | + } | |
388 | + | |
389 | + private String getUsersId(String hospitalId, String doctorName) { | |
390 | + if(StringUtils.isEmpty(doctorName) || StringUtils.isEmpty(hospitalId)){ | |
391 | + return null; | |
392 | + } | |
393 | + UsersQuery usersQuery = new UsersQuery(); | |
394 | + usersQuery.setName(doctorName); | |
395 | + usersQuery.setYn(YnEnums.YES.getId()); | |
396 | + usersQuery.setOrgId(Integer.parseInt(hospitalId)); | |
397 | + List <Users> users = usersService.queryUsers(usersQuery); | |
398 | + if (CollectionUtils.isNotEmpty(users)) { | |
399 | + Users users1 = users.get(0); | |
400 | + return users1.getId() !=null ? users1.getId().toString(): null; | |
401 | + } | |
402 | + return null; | |
403 | + } | |
404 | + | |
265 | 405 | |
266 | 406 | /** |
267 | 407 | * 返回列表字段 |