|
@@ -0,0 +1,144 @@
|
|
|
+package com.jpsoft.insurance.modules.open;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.insurance.config.OSSConfig;
|
|
|
+import com.jpsoft.insurance.modules.base.entity.Report;
|
|
|
+import com.jpsoft.insurance.modules.base.service.ReportService;
|
|
|
+import com.jpsoft.insurance.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.insurance.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.insurance.modules.common.utils.OSSUtil;
|
|
|
+import com.jpsoft.insurance.modules.common.utils.PojoUtils;
|
|
|
+import com.jpsoft.insurance.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.insurance.modules.sys.entity.User;
|
|
|
+import com.jpsoft.insurance.modules.sys.service.DataDictionaryService;
|
|
|
+import com.jpsoft.insurance.modules.sys.service.UserService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/open/reportApi")
|
|
|
+@Api(description = "reportApi")
|
|
|
+public class ReportApiController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportService reportService;
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @ApiOperation(value="添加信息")
|
|
|
+ @PostMapping("add")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "visitingDate", value = "入院日期(yyyy-MM-dd)", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "name", value = "出险人", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "phone", value = "联系号码", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "cardNo", value = "证件号码", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "insuredArea", value = "参保区域", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "visitingHospital", value = "就诊医院", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "visitingHospitalName", value = "就诊医院名称", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "insuranceType", value = "参保类型", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "whatHappened", value = "事情经过", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "remark", value = "备注", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "visitingDepartment", value = "就诊科室", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "admissionNumber", value = "住院号", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "isDischarged", value = "是否出院", required = false, paramType = "query", dataType = "Boolean"),
|
|
|
+
|
|
|
+ })
|
|
|
+ public MessageResult<Report> add(String visitingDate, String name, String phone, String cardNo, String insuredArea, String visitingHospital,
|
|
|
+ String visitingHospitalName, String insuranceType, String whatHappened, String remark, String visitingDepartment,
|
|
|
+ String admissionNumber, Boolean isDischarged){
|
|
|
+ MessageResult<Report> msgResult = new MessageResult<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ DataDictionary dataDictionary = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ Report report = new Report();
|
|
|
+ report.setId(UUID.randomUUID().toString());
|
|
|
+ report.setVisitingDate(sdf.parse(visitingDate));
|
|
|
+ report.setName(name);
|
|
|
+ report.setPhone(phone);
|
|
|
+ report.setCardNo(cardNo);
|
|
|
+ report.setInsuredArea(insuredArea);
|
|
|
+ report.setVisitingHospital(visitingHospital);
|
|
|
+ report.setVisitingHospitalName(visitingHospitalName);
|
|
|
+ dataDictionary = dataDictionaryService.findByCatalogNameAndValue("就诊医院", report.getVisitingHospital());
|
|
|
+ if(dataDictionary != null && !"其他".equals(dataDictionary.getName())) report.setVisitingHospitalName(dataDictionary.getName());
|
|
|
+ report.setInsuranceType(insuranceType);
|
|
|
+ report.setWhatHappened(whatHappened);
|
|
|
+ report.setRemark(remark);
|
|
|
+ report.setVisitingDepartment(visitingDepartment);
|
|
|
+ report.setAdmissionNumber(admissionNumber);
|
|
|
+ if(report.getIsDischarged() == null) report.setIsDischarged(false);
|
|
|
+ if(report.getIsOutland() == null) report.setIsOutland(false);
|
|
|
+ report.setDelFlag(false);
|
|
|
+ report.setCreateBy("8ed505d2-e36b-4343-bffb-1de9972b1f75");
|
|
|
+ report.setCreateTime(new Date());
|
|
|
+ dataDictionary = dataDictionaryService.findByCatalogNameAndValue("就诊医院", report.getVisitingHospital());
|
|
|
+ if(dataDictionary != null && !"其他".equals(dataDictionary.getName())) {
|
|
|
+ report.setVisitingHospitalName(dataDictionary.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ int affectCount = reportService.insert(report);
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(report);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库添加失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("findByCatalogName")
|
|
|
+ @ApiOperation(value = "根据目录名称查询数据列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "catalogName",value = "数据目录名称(参保类型|参保区域|就诊医院)", required = true, paramType = "query"),
|
|
|
+ })
|
|
|
+ public MessageResult<List> findByCatalogName(String catalogName){
|
|
|
+ MessageResult<List> messageResult = new MessageResult<>();
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ //todo
|
|
|
+ List<DataDictionary> list = dataDictionaryService.findByCatalogName(catalogName);
|
|
|
+ for(DataDictionary dataDictionary : list){
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("name", dataDictionary.getName());
|
|
|
+ map.put("value", dataDictionary.getValue());
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setData(mapList);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+}
|