Commit c1f70781 authored by chenhao's avatar chenhao

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

parent db2e3734
......@@ -25,7 +25,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.service.IDutyFirstAidService;
......
......@@ -8,9 +8,6 @@ import java.util.List;
import java.util.Map;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -18,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -26,6 +24,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
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.mapper.FailureDetailsMapper;
import com.yeejoin.amos.boot.module.common.api.service.IFailureAuditService;
......
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.utils.RedisUtils;
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.biz.service.impl.DataSourcesImpl;
......@@ -41,10 +43,25 @@ public class ExcelController extends BaseController {
@Autowired
DataSourcesImpl dataSources;
@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)
@ApiOperation(value = "下载模板")
......@@ -88,10 +105,13 @@ public class ExcelController extends BaseController {
@PostMapping("/upload/{type}")
public ResponseModel<Object> upload(@RequestPart("file") MultipartFile multipartFile, @PathVariable(value = "type") String type) {
try {
long uuid = sequence.nextId();
String uuidString = Long.toString(uuid);
redisUtils.set(uuidString, 0);
ExcelEnums excelEnums= ExcelEnums.getByKey(type);
ExcelDto excelDto = new ExcelDto(excelEnums.getFileName(), excelEnums.getSheetName(), excelEnums.getClassUrl(), excelEnums.getType());
excelService.commonUpload(multipartFile, excelDto);
return ResponseHelper.buildResponse(null);
excelService.commonUpload(multipartFile, excelDto,uuidString);
return ResponseHelper.buildResponse(uuidString);
} catch (RuntimeException e) {
e.printStackTrace();
throw new BadRequest("文件格式不正确或excel 模板不匹配"); // BUG 2821 by litw 2021年9月16日
......
......@@ -96,6 +96,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
......@@ -196,7 +197,7 @@ public class ExcelServiceImpl {
@Autowired
DynamicFormInstanceServiceImpl dynamicFormInstanceService;
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url);
......@@ -352,8 +353,8 @@ public class ExcelServiceImpl {
break;
}
}
public void commonUpload(MultipartFile multipartFile, ExcelDto excelDto) throws Exception {
public void commonUpload(MultipartFile multipartFile, ExcelDto excelDto,String uuidString) throws Exception {
switch (excelDto.getType()) {
case "WHP":
......@@ -378,10 +379,10 @@ public class ExcelServiceImpl {
excelImportFirefighters(multipartFile);
break;
case "CLZQ":
excelImportDutyPerson(multipartFile, "CLZQ");
excelImportDutyPerson(multipartFile, "CLZQ",uuidString);
break;
case "RYZB":
excelImportDutyPerson(multipartFile, "RYZB");
excelImportDutyPerson(multipartFile, "RYZB",uuidString);
break;
case "WBRY":
excelImportMaintenancePerson(multipartFile);
......@@ -403,13 +404,13 @@ public class ExcelServiceImpl {
excelImportLinkageUnitJYZBDto(multipartFile);
break;
case "WXXFZB":
excelImportDutyPerson(multipartFile, "WXXFZB");
excelImportDutyPerson(multipartFile, "WXXFZB",uuidString);
break;
case "XFAQBG":
excelImportSafeReport(multipartFile);
break;
case "JJZB":
excelImportDutyPerson(multipartFile, "JJZB");
excelImportDutyPerson(multipartFile, "JJZB",uuidString);
break;
}
return;
......@@ -999,10 +1000,22 @@ public class ExcelServiceImpl {
});
fireExpertsServiceImpl.saveBatch(excelEntityList);
}
private void excelImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception {
String fileName = multipartFile.getOriginalFilename();
@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 ImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception {
String fileName = multipartFile.getOriginalFilename();
if (fileName == null) {
throw new Exception("文件不存在!");
}
......@@ -1036,8 +1049,8 @@ public class ExcelServiceImpl {
dutyFirstAidService.saveImportData(dataList);
}
}
}
}
private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyFirstAidDto dutyFirstAidDto = new DutyFirstAidDto();
......@@ -1128,6 +1141,10 @@ public class ExcelServiceImpl {
if (row == null) {
continue;
}
Cell cell4 = row.getCell(4);
if(cell4 ==null) {
continue;
}
Cell cell = row.getCell(1);
if (cell != null) {
String[] split = cell.toString().split("@");
......@@ -1184,6 +1201,10 @@ public class ExcelServiceImpl {
if (row == null) {
continue;
}
Cell cell4 = row.getCell(4);
if(cell4 ==null) {
continue;
}
Cell cell = row.getCell(1);
if (cell != null) {
dutyPersonDto.setUserId(cell.toString());
......
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.base.Joiner;
import com.itextpdf.text.*;
import com.itextpdf.text.Document;
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.PdfPTable;
import com.yeejoin.amos.boot.biz.common.utils.PdfUtils;
......@@ -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.mapper.ShiftChangeMapper;
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
@Override
public Map<String, Object> createFormAndEntry(Map<String, Object> model) {
Long instanceId = dynamicFormInstanceService.commonSave(GROUP_CODE, model);
ShiftChange shiftChange = (ShiftChange) Bean.mapToBean(model, ShiftChange.class);
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