|
@ -2,10 +2,16 @@ package com.yihu.wlyy.controller.manager.datastatic;
|
|
|
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
import com.yihu.wlyy.entity.SignFamily;
|
|
|
import com.yihu.wlyy.entity.es.HealthEduPatientCode;
|
|
|
import com.yihu.wlyy.entity.organization.HospitalMapping;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
|
|
|
import com.yihu.wlyy.service.healthedu.HealthEduService;
|
|
|
import com.yihu.wlyy.service.manager.sign.FamilyContractService;
|
|
|
import com.yihu.wlyy.util.ElasticsearchUtil;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
@ -14,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 健康教育推送报表导出
|
|
@ -28,6 +34,17 @@ public class HealthEduController extends BaseController {
|
|
|
@Autowired
|
|
|
private HealthEduService healthEduService;
|
|
|
|
|
|
@Value("${es.type.HealthEduArticlePatient}")
|
|
|
private String esType;
|
|
|
@Value("${es.index.HealthEduArticlePatient}")
|
|
|
private String esIndex;
|
|
|
@Autowired
|
|
|
private ElasticsearchUtil elasticsearchUtil;
|
|
|
@Autowired
|
|
|
private FamilyContractService familyContractService;
|
|
|
@Autowired
|
|
|
private HospitalMappingDao hospitalMappingDao;
|
|
|
|
|
|
//页面跳转(主页面)
|
|
|
@RequestMapping(value = "initial")
|
|
|
public String listInit() {
|
|
@ -41,11 +58,47 @@ public class HealthEduController extends BaseController {
|
|
|
@RequestParam(value = "endDate",required = false)String endDate,
|
|
|
HttpServletResponse response){
|
|
|
try {
|
|
|
List<SignFamily> datalist = healthEduService.getPatientPushList(beginDate,endDate);
|
|
|
|
|
|
List<SignFamily> signFamilies = new ArrayList<>();
|
|
|
|
|
|
Map<String,String> orgcodemap = new HashMap<>();
|
|
|
|
|
|
Set<String> patientcodesets = new HashSet<>();
|
|
|
|
|
|
String sql = "SELECT patientCode FROM "+esType+" where createTime >='"+beginDate+"T00:00:00+0800' and createTime <='"+endDate+"T23:59:59+0800' group by patientCode limit 0,1000000";
|
|
|
|
|
|
List<HealthEduPatientCode> patientCodes = elasticsearchUtil.excute(sql, HealthEduPatientCode.class, esIndex, esType);
|
|
|
|
|
|
for (HealthEduPatientCode es: patientCodes) {
|
|
|
System.out.println(patientcodesets.size());
|
|
|
if(patientcodesets.contains(es.getPatientCode())){
|
|
|
continue;
|
|
|
}else{
|
|
|
patientcodesets.add(es.getPatientCode());
|
|
|
}
|
|
|
SignFamily obj = familyContractService.findSignByPatient(es.getPatientCode());
|
|
|
if( obj == null){
|
|
|
continue;
|
|
|
}
|
|
|
String jworgcode = "";
|
|
|
if(orgcodemap.isEmpty() || !orgcodemap.keySet().contains(obj.getHospital())){
|
|
|
HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(obj.getHospital());
|
|
|
if(hospitalMapping == null){
|
|
|
continue;
|
|
|
}
|
|
|
jworgcode = hospitalMapping.getMappingCode();
|
|
|
orgcodemap.put(obj.getHospital(),jworgcode);
|
|
|
}else{
|
|
|
jworgcode = orgcodemap.get(obj.getHospital());
|
|
|
}
|
|
|
obj.setHospital(jworgcode);
|
|
|
signFamilies.add(obj);
|
|
|
}
|
|
|
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "pushDataList.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.pushListWrite(os,datalist);
|
|
|
this.pushListWrite(os,signFamilies);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
}
|