Commit c1f70781 authored by chenhao's avatar chenhao

修改上传文件时同步响应等待时间太长的问题

parent db2e3734
...@@ -25,7 +25,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -25,7 +25,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto;
import com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService; import com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService;
......
...@@ -8,9 +8,6 @@ import java.util.List; ...@@ -8,9 +8,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.enums.AuditResultEnum;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -18,6 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -26,6 +24,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -26,6 +24,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService; import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dto.CurrentStatusDto;
import com.yeejoin.amos.boot.module.common.api.dto.FailureDetailsDto;
import com.yeejoin.amos.boot.module.common.api.dto.FailureRepairlogDto;
import com.yeejoin.amos.boot.module.common.api.dto.StatusDto;
import com.yeejoin.amos.boot.module.common.api.entity.FailureDetails;
import com.yeejoin.amos.boot.module.common.api.entity.FailureRepairlog;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.entity.SourceFile;
import com.yeejoin.amos.boot.module.common.api.enums.FailureStatuEnum; import com.yeejoin.amos.boot.module.common.api.enums.FailureStatuEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.FailureDetailsMapper; import com.yeejoin.amos.boot.module.common.api.mapper.FailureDetailsMapper;
import com.yeejoin.amos.boot.module.common.api.service.IFailureAuditService; import com.yeejoin.amos.boot.module.common.api.service.IFailureAuditService;
......
package com.yeejoin.amos.boot.module.jcs.biz.controller; package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.ExcelDto; import com.yeejoin.amos.boot.module.common.api.dto.ExcelDto;
import com.yeejoin.amos.boot.module.jcs.api.enums.ExcelEnums; import com.yeejoin.amos.boot.module.jcs.api.enums.ExcelEnums;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.DataSourcesImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.DataSourcesImpl;
...@@ -42,9 +44,24 @@ public class ExcelController extends BaseController { ...@@ -42,9 +44,24 @@ public class ExcelController extends BaseController {
@Autowired @Autowired
DataSourcesImpl dataSources; DataSourcesImpl dataSources;
private static final String NOT_DUTY = "休班"; @Autowired
RedisUtils redisUtils;
@Autowired
Sequence sequence;
private static final String NOT_DUTY = "休班";
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取上传excle文件是否成功")
@GetMapping("/get/template/isSuccess/{key}")
public ResponseModel<Object> getTemplateIsSuccess(HttpServletResponse response, @PathVariable(value = "key") String key) {
if (redisUtils.hasKey(key)) {
Object obj = redisUtils.get(key);
return ResponseHelper.buildResponse(obj);
}
return ResponseHelper.buildResponse(null);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "下载模板") @ApiOperation(value = "下载模板")
...@@ -88,10 +105,13 @@ public class ExcelController extends BaseController { ...@@ -88,10 +105,13 @@ public class ExcelController extends BaseController {
@PostMapping("/upload/{type}") @PostMapping("/upload/{type}")
public ResponseModel<Object> upload(@RequestPart("file") MultipartFile multipartFile, @PathVariable(value = "type") String type) { public ResponseModel<Object> upload(@RequestPart("file") MultipartFile multipartFile, @PathVariable(value = "type") String type) {
try { try {
long uuid = sequence.nextId();
String uuidString = Long.toString(uuid);
redisUtils.set(uuidString, 0);
ExcelEnums excelEnums= ExcelEnums.getByKey(type); ExcelEnums excelEnums= ExcelEnums.getByKey(type);
ExcelDto excelDto = new ExcelDto(excelEnums.getFileName(), excelEnums.getSheetName(), excelEnums.getClassUrl(), excelEnums.getType()); ExcelDto excelDto = new ExcelDto(excelEnums.getFileName(), excelEnums.getSheetName(), excelEnums.getClassUrl(), excelEnums.getType());
excelService.commonUpload(multipartFile, excelDto); excelService.commonUpload(multipartFile, excelDto,uuidString);
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(uuidString);
} catch (RuntimeException e) { } catch (RuntimeException e) {
e.printStackTrace(); e.printStackTrace();
throw new BadRequest("文件格式不正确或excel 模板不匹配"); // BUG 2821 by litw 2021年9月16日 throw new BadRequest("文件格式不正确或excel 模板不匹配"); // BUG 2821 by litw 2021年9月16日
......
...@@ -96,6 +96,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet; ...@@ -96,6 +96,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -353,7 +354,7 @@ public class ExcelServiceImpl { ...@@ -353,7 +354,7 @@ public class ExcelServiceImpl {
} }
} }
public void commonUpload(MultipartFile multipartFile, ExcelDto excelDto) throws Exception { public void commonUpload(MultipartFile multipartFile, ExcelDto excelDto,String uuidString) throws Exception {
switch (excelDto.getType()) { switch (excelDto.getType()) {
case "WHP": case "WHP":
...@@ -378,10 +379,10 @@ public class ExcelServiceImpl { ...@@ -378,10 +379,10 @@ public class ExcelServiceImpl {
excelImportFirefighters(multipartFile); excelImportFirefighters(multipartFile);
break; break;
case "CLZQ": case "CLZQ":
excelImportDutyPerson(multipartFile, "CLZQ"); excelImportDutyPerson(multipartFile, "CLZQ",uuidString);
break; break;
case "RYZB": case "RYZB":
excelImportDutyPerson(multipartFile, "RYZB"); excelImportDutyPerson(multipartFile, "RYZB",uuidString);
break; break;
case "WBRY": case "WBRY":
excelImportMaintenancePerson(multipartFile); excelImportMaintenancePerson(multipartFile);
...@@ -403,13 +404,13 @@ public class ExcelServiceImpl { ...@@ -403,13 +404,13 @@ public class ExcelServiceImpl {
excelImportLinkageUnitJYZBDto(multipartFile); excelImportLinkageUnitJYZBDto(multipartFile);
break; break;
case "WXXFZB": case "WXXFZB":
excelImportDutyPerson(multipartFile, "WXXFZB"); excelImportDutyPerson(multipartFile, "WXXFZB",uuidString);
break; break;
case "XFAQBG": case "XFAQBG":
excelImportSafeReport(multipartFile); excelImportSafeReport(multipartFile);
break; break;
case "JJZB": case "JJZB":
excelImportDutyPerson(multipartFile, "JJZB"); excelImportDutyPerson(multipartFile, "JJZB",uuidString);
break; break;
} }
return; return;
...@@ -999,9 +1000,21 @@ public class ExcelServiceImpl { ...@@ -999,9 +1000,21 @@ public class ExcelServiceImpl {
}); });
fireExpertsServiceImpl.saveBatch(excelEntityList); fireExpertsServiceImpl.saveBatch(excelEntityList);
} }
@Async
private void excelImportDutyPerson(MultipartFile multipartFile, String dutyType,String uuidString) throws Exception {
try {
ImportDutyPerson(multipartFile,dutyType);
if(redisUtils.hasKey(uuidString)){
redisUtils.set(uuidString, 1);
}
} catch (Exception e) {
if(redisUtils.hasKey(uuidString)){
redisUtils.set(uuidString, 2);
}
}
private void excelImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception { }
private void ImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception {
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
if (fileName == null) { if (fileName == null) {
throw new Exception("文件不存在!"); throw new Exception("文件不存在!");
...@@ -1036,8 +1049,8 @@ public class ExcelServiceImpl { ...@@ -1036,8 +1049,8 @@ public class ExcelServiceImpl {
dutyFirstAidService.saveImportData(dataList); dutyFirstAidService.saveImportData(dataList);
} }
} }
}
}
private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyFirstAidDto dutyFirstAidDto = new DutyFirstAidDto(); DutyFirstAidDto dutyFirstAidDto = new DutyFirstAidDto();
...@@ -1128,6 +1141,10 @@ public class ExcelServiceImpl { ...@@ -1128,6 +1141,10 @@ public class ExcelServiceImpl {
if (row == null) { if (row == null) {
continue; continue;
} }
Cell cell4 = row.getCell(4);
if(cell4 ==null) {
continue;
}
Cell cell = row.getCell(1); Cell cell = row.getCell(1);
if (cell != null) { if (cell != null) {
String[] split = cell.toString().split("@"); String[] split = cell.toString().split("@");
...@@ -1184,6 +1201,10 @@ public class ExcelServiceImpl { ...@@ -1184,6 +1201,10 @@ public class ExcelServiceImpl {
if (row == null) { if (row == null) {
continue; continue;
} }
Cell cell4 = row.getCell(4);
if(cell4 ==null) {
continue;
}
Cell cell = row.getCell(1); Cell cell = row.getCell(1);
if (cell != null) { if (cell != null) {
dutyPersonDto.setUserId(cell.toString()); dutyPersonDto.setUserId(cell.toString());
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.base.Joiner; import com.itextpdf.text.Document;
import com.itextpdf.text.*; import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfPTable;
import com.yeejoin.amos.boot.biz.common.utils.PdfUtils; import com.yeejoin.amos.boot.biz.common.utils.PdfUtils;
...@@ -18,26 +42,6 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangePowerDto; ...@@ -18,26 +42,6 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangePowerDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.ShiftChange; import com.yeejoin.amos.boot.module.jcs.api.entity.ShiftChange;
import com.yeejoin.amos.boot.module.jcs.api.mapper.ShiftChangeMapper; import com.yeejoin.amos.boot.module.jcs.api.mapper.ShiftChangeMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IShiftChangeService; import com.yeejoin.amos.boot.module.jcs.api.service.IShiftChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import springfox.documentation.spring.web.json.Json;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 交接班记录表服务实现类 * 交接班记录表服务实现类
...@@ -59,7 +63,6 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha ...@@ -59,7 +63,6 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
@Override @Override
public Map<String, Object> createFormAndEntry(Map<String, Object> model) { public Map<String, Object> createFormAndEntry(Map<String, Object> model) {
Long instanceId = dynamicFormInstanceService.commonSave(GROUP_CODE, model); Long instanceId = dynamicFormInstanceService.commonSave(GROUP_CODE, model);
ShiftChange shiftChange = (ShiftChange) Bean.mapToBean(model, ShiftChange.class); ShiftChange shiftChange = (ShiftChange) Bean.mapToBean(model, ShiftChange.class);
shiftChange.setInstanceId(instanceId); shiftChange.setInstanceId(instanceId);
......
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