修复了Task的新建;添加了批量导入的文件摘要验证
parent
64e4a7dfec
commit
41fec4a47a
|
@ -8,6 +8,7 @@ import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@ -43,14 +44,17 @@ public class StaffController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PostMapping(value = "/staff/import")
|
@PostMapping(value = "/staff/import")
|
||||||
public ResponseMap upload(@RequestHeader("Token") String token, @RequestParam("uploadFile") MultipartFile uploadFile) {
|
public ResponseMap upload(@RequestHeader("Token") String token, @RequestParam("uploadFile") MultipartFile uploadFile,@RequestParam("digest") String digest) {
|
||||||
if (null == uploadFile) {
|
if (null == uploadFile) {
|
||||||
throw new BadRequestException("空的文件参数");
|
throw new BadRequestException("文件传输错误");
|
||||||
}
|
}
|
||||||
String fileName = Objects.requireNonNull(uploadFile.getOriginalFilename()).toLowerCase();
|
String fileName = Objects.requireNonNull(uploadFile.getOriginalFilename()).toLowerCase();
|
||||||
if (!fileName.endsWith(".xlsx")) {
|
if (!fileName.endsWith(".xlsx")) {
|
||||||
throw new BadRequestException("文件类型错误");
|
throw new BadRequestException("文件类型错误");
|
||||||
}
|
}
|
||||||
|
if(!Objects.equals(DigestUtils.md5DigestAsHex(uploadFile.getBytes()).toLowerCase(),digest.toLowerCase())){
|
||||||
|
throw new BadRequestException("文件传输错误");
|
||||||
|
}
|
||||||
Integer successCount = staffService.multiImport(token, uploadFile);
|
Integer successCount = staffService.multiImport(token, uploadFile);
|
||||||
return ResponseMap.ofSuccess("成功导入" + successCount + "条数据");
|
return ResponseMap.ofSuccess("成功导入" + successCount + "条数据");
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ public class Task {
|
||||||
return false;
|
return false;
|
||||||
if (father.getTaskId() == 0)
|
if (father.getTaskId() == 0)
|
||||||
return true;
|
return true;
|
||||||
|
if(!father.getTaskStatus().equals(STATUS_WAITING)&&!father.getTaskStatus().equals(STATUS_PROCESSING))
|
||||||
|
return false;
|
||||||
if (this.getTaskType().equals(TYPE_DEFECT)) {
|
if (this.getTaskType().equals(TYPE_DEFECT)) {
|
||||||
return father.getTaskType().equals(TYPE_DEMAND);
|
return father.getTaskType().equals(TYPE_DEMAND);
|
||||||
} else if (this.getTaskType().equals(TYPE_DEMAND)) {
|
} else if (this.getTaskType().equals(TYPE_DEMAND)) {
|
||||||
|
|
Loading…
Reference in New Issue