|
@ -1,11 +1,12 @@
|
|
|
package com.yihu.jw.basic.agadmin.controller.resource;
|
|
|
|
|
|
|
|
|
|
|
|
import com.yihu.jw.basic.resource.dao.ResourceBrowseMetadataDao;
|
|
|
import com.yihu.jw.basic.resource.service.ResourceBrowseService;
|
|
|
import com.yihu.jw.basic.resource.service.ResourceIntegratedService;
|
|
|
import com.yihu.jw.basic.resource.service.RsResourceDefaultParamService;
|
|
|
import com.yihu.jw.basic.resource.service.RsResourceService;
|
|
|
import com.yihu.jw.basic.util.WorkbookUtil;
|
|
|
import com.yihu.jw.entity.ehr.id.BizObject;
|
|
|
import com.yihu.jw.entity.ehr.resource.RsResource;
|
|
|
import com.yihu.jw.entity.ehr.resource.RsResourceDefaultParam;
|
|
@ -17,8 +18,10 @@ import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.util.common.NumberUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import jxl.Cell;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.Label;
|
|
|
import jxl.write.WritableSheet;
|
|
|
import org.slf4j.Logger;
|
|
@ -29,8 +32,12 @@ import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Controller - 资源综合查询服务控制器
|
|
@ -55,6 +62,8 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
|
|
|
private RsResourceService rsResourceService;
|
|
|
@Autowired
|
|
|
private ResourceBrowseService resourceBrowseService;
|
|
|
@Autowired
|
|
|
private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
|
|
|
|
|
|
/**
|
|
|
* 综合查询档案数据列表树 zuul
|
|
@ -386,6 +395,49 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
//basic/resourceIntegrated/searchMetadataData
|
|
|
@ApiOperation("档案数据导出")
|
|
|
@RequestMapping(value = "exportExcel/archiveDataExport", method = RequestMethod.GET)
|
|
|
public void archiveDataExport(
|
|
|
@ApiParam(name = "resourcesCode", value = "资源code")
|
|
|
@RequestParam(value = "resourcesCode", required = true) String resourcesCode,
|
|
|
@ApiParam(name = "metaData", value = "数据元")
|
|
|
@RequestParam(value = "metaData", required = true) String metaData,
|
|
|
@ApiParam(name = "searchParams", value = "查询条件")
|
|
|
@RequestParam(value = "searchParams", required = false) String searchParams, HttpServletResponse response) {
|
|
|
try {
|
|
|
Page<Map<String, Object>> result = resourceBrowseService.getCustomizeDataMysql(resourcesCode,metaData,searchParams,1, 99999);
|
|
|
List<Map<String, Object>> listMap = result.toList();
|
|
|
//导出
|
|
|
String fileName = "档案数据导出";
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
fileName = URLEncoder.encode(fileName, "utf-8");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + new String(".xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
WorkbookUtil workbookUtil = new WorkbookUtil();
|
|
|
|
|
|
//获取表头
|
|
|
List<String> codeList = (List<String>) objectMapper.readValue(resourcesCode, List.class);
|
|
|
String resourcesCodes = org.apache.commons.lang.StringUtils.join(codeList,"','");
|
|
|
List<Map<String,Object>> metadatas = resourceBrowseMetadataDao.getMetadatas(resourcesCodes);
|
|
|
Map<String,String> metadataMap = metadatas.stream().collect(Collectors.toMap(e->e.get("ehr_id").toString(),e->e.get("name").toString()));
|
|
|
metaData = metaData.replaceAll(",","\",\"");
|
|
|
List<String> customizeList = (List<String>) objectMapper.readValue(metaData, List.class);
|
|
|
|
|
|
Map<Integer, String> columnMap = new HashMap<>();
|
|
|
String[] header = new String[customizeList.size()];
|
|
|
for (int i=0;i<customizeList.size();i++){
|
|
|
String key = customizeList.get(i);
|
|
|
columnMap.put(i, key);
|
|
|
header[i] = metadataMap.get(key);
|
|
|
}
|
|
|
workbookUtil.write(Workbook.createWorkbook(os), listMap, columnMap, header);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 综合查询档案数据导出
|
|
|
* @param request
|