Commit fda92693 authored by hezhuozhi's avatar hezhuozhi

Merge remote-tracking branch 'origin/developer_bw' into developer_bw

parents 2f6f416d 11d5757d
...@@ -58,6 +58,23 @@ public class CommonController { ...@@ -58,6 +58,23 @@ public class CommonController {
System.out.println("zip下载成功"); System.out.println("zip下载成功");
} }
/**
* 设备信息下载
*
* @return
*/
@GetMapping(value = "/test")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "资料下载", notes = "资料下载")
public void test(HttpServletResponse response) throws IOException {
// 设置响应头
response.setContentType("application/zip");
commonService.test(response);
System.out.println("zip下载成功");
}
/** /**
* 设备信息下载 * 设备信息下载
* *
......
...@@ -550,13 +550,16 @@ public class CommonServiceImpl { ...@@ -550,13 +550,16 @@ public class CommonServiceImpl {
Path currentWorkingDir = Paths.get(""); Path currentWorkingDir = Paths.get("");
// 获取当前工作目录 // 获取当前工作目录
Path rootDir = currentWorkingDir; Path rootDir = currentWorkingDir;
Path ziLiaoDir =rootDir.resolve("批量资料"); Path ziLiaoDir = createUniqueDirectory(rootDir, "批量资料");
// Path ziLiaoDir =rootDir.resolve("批量资料");
for (String peasantHouseholdId : peasantHouseholdIds) { for (String peasantHouseholdId : peasantHouseholdIds) {
SurveyInfoAllDto returnDto = surveyInformationServiceImpl.querySurveyInfo(surveyInformationId, peasantHouseholdId, processInstanceId, null); SurveyInfoAllDto returnDto = surveyInformationServiceImpl.querySurveyInfo(surveyInformationId, peasantHouseholdId, processInstanceId, null);
fileName = returnDto.getSurveyInformation().getOwnersName(); fileName = returnDto.getSurveyInformation().getOwnersName();
int current = 0; if (!redisKey.contains(",")){
redisUtils.set(redisKey, MapBuilder.<String, Object>create() redisUtils.set(redisKey, MapBuilder.<String, Object>create()
.put("value", current).build()); .put("value", currentBili).build());
}
String powerStationInstanceId = powerStationMapper.getInstanceIdByhouseId(peasantHouseholdId); String powerStationInstanceId = powerStationMapper.getInstanceIdByhouseId(peasantHouseholdId);
String financingInstanceId = financingAuditingMapper.getInstanceIdByhouseId(peasantHouseholdId); String financingInstanceId = financingAuditingMapper.getInstanceIdByhouseId(peasantHouseholdId);
List<LinkedHashMap> powerStationWorkLog = new ArrayList<>(); List<LinkedHashMap> powerStationWorkLog = new ArrayList<>();
...@@ -654,9 +657,11 @@ public class CommonServiceImpl { ...@@ -654,9 +657,11 @@ public class CommonServiceImpl {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
current = current + 15 ; if (!redisKey.contains(",")){
redisUtils.set(redisKey, MapBuilder.<String, Object>create() currentBili = currentBili + 15 ;
.put("value", current).build()); redisUtils.set(redisKey, MapBuilder.<String, Object>create()
.put("value", currentBili).build());
}
List<HygfRectificationOrder> areaOrdersCon =new ArrayList<>(); List<HygfRectificationOrder> areaOrdersCon =new ArrayList<>();
if (ObjectUtils.isNotEmpty(returnDto.getHygfOnGrid())) { if (ObjectUtils.isNotEmpty(returnDto.getHygfOnGrid())) {
areaOrdersCon = Optional.ofNullable(returnDto.getPowerStationConstructionData().getAreaOrders()) areaOrdersCon = Optional.ofNullable(returnDto.getPowerStationConstructionData().getAreaOrders())
...@@ -857,20 +862,22 @@ public class CommonServiceImpl { ...@@ -857,20 +862,22 @@ public class CommonServiceImpl {
} }
// response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename="+returnDto.getSurveyInformation().getOwnersName()+".zip"); // response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename="+returnDto.getSurveyInformation().getOwnersName()+".zip");
currentBili = currentBili + baifenbi; if (redisKey.contains(",")){
redisUtils.set(redisKey,MapBuilder.<String, Object>create() currentBili = currentBili + baifenbi;
.put("value", currentBili).build()); redisUtils.set(redisKey,MapBuilder.<String, Object>create()
.put("value", currentBili).build());
}
} }
String encodedFilename = ""; String encodedFilename = "";
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
if (peasantHouseholdIds.size() > 1){ if (peasantHouseholdIds.size() > 1){
fileName = "批量资料"; fileName = "批量资料";
encodedFilename = URLEncoder.encode( "批量资料.zip", StandardCharsets.UTF_8.name());
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName+".zip", "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName+".zip", "UTF-8"));
createZipFile(ziLiaoDir, fileName,response); createZipFile(ziLiaoDir, fileName,response);
}else { }else {
encodedFilename = URLEncoder.encode( fileName+".zip", StandardCharsets.UTF_8.name());
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName+".zip", "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName+".zip", "UTF-8"));
createZipFile(ziLiaoDir, "批量资料/"+fileName,response); createZipFile(ziLiaoDir, "批量资料/"+fileName,response);
} }
...@@ -881,6 +888,16 @@ public class CommonServiceImpl { ...@@ -881,6 +888,16 @@ public class CommonServiceImpl {
cleanup(ziLiaoDir); cleanup(ziLiaoDir);
} }
public void test (HttpServletResponse response) throws UnsupportedEncodingException {
String fileName = "批量资料";
Path currentWorkingDir = Paths.get("");
// 获取当前工作目录
Path rootDir = currentWorkingDir;
Path ziLiaoDir =rootDir.resolve("批量资料");
String encodedFilename = URLEncoder.encode( fileName+".zip", StandardCharsets.UTF_8.name());
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName+".zip", "UTF-8"));
createZipFile(ziLiaoDir, "批量资料",response);
}
private void fillSheet(Sheet sheet, Object data) { private void fillSheet(Sheet sheet, Object data) {
if (Objects.isNull(data)){ if (Objects.isNull(data)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment