bug fixed 内部人员教育下载不了文件

This commit is contained in:
Timer
2026-03-25 00:48:45 +08:00
parent 82d68ed669
commit 17751bd0ab
2 changed files with 21 additions and 14 deletions

View File

@ -66,7 +66,7 @@ public class SafetyEducationTraineeController {
**/
@RequestMapping("/add.do")
public String add(HttpServletRequest request, Model model) throws Exception {
String educationCode =safetySeqService.code(request,SafetyFunctionEnum.EDUCATION_TRAINEE);
String educationCode = safetySeqService.code(request, SafetyFunctionEnum.EDUCATION_TRAINEE);
model.addAttribute("educationCode", educationCode);
return "safety/EducationTraineeAdd";
}
@ -82,9 +82,10 @@ public class SafetyEducationTraineeController {
SafetyEducationTrainee educationTrainee = safetyEducationTraineeService.selectById(id);
SafetyFiles file = safetyFilesService.selectById(educationTrainee.getFileId());
model.addAttribute("bean", educationTrainee);
model.addAttribute("fileName", file==null?"":file.getOriginalFileName());
model.addAttribute("fileName", file == null ? "" : file.getOriginalFileName());
return "safety/EducationTraineeEdit";
}
/**
* 跳转至编辑弹窗
*
@ -96,9 +97,10 @@ public class SafetyEducationTraineeController {
SafetyEducationTrainee educationTrainee = safetyEducationTraineeService.selectById(id);
SafetyFiles file = safetyFilesService.selectById(educationTrainee.getFileId());
model.addAttribute("bean", educationTrainee);
model.addAttribute("fileName",file==null?"":file.getOriginalFileName());
model.addAttribute("fileName", file == null ? "" : file.getOriginalFileName());
return "safety/EducationTraineeView";
}
/**
* 获取分页列表信息
*
@ -169,24 +171,24 @@ public class SafetyEducationTraineeController {
@RequestMapping("/update.do")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public Result update(HttpServletRequest request,SafetyEducationTrainee bean, MultipartFile file) throws IOException, ParseException {
public Result update(HttpServletRequest request, SafetyEducationTrainee bean, MultipartFile file) throws IOException, ParseException {
if (!safetyEducationTraineeService.timeRangeCheck(bean)) {
return Result.failed("培训有效期早于培训日期!");
}
SafetyEducationTrainee oldBean = safetyEducationTraineeService.selectById(bean.getId());
//如果文件id是空的代表用户重新上传的文件先删除原来的文件然后再上传新文件。
if (StringUtils.isEmpty(bean.getFileId())&&file.getSize()>0) {
List<SafetyFiles> fileBeanList = safetyFilesService.upload(request,file, SafetyFunctionEnum.EDUCATION_TRAINEE.getId(), null, bean.getId());
if (StringUtils.isEmpty(bean.getFileId()) && file.getSize() > 0) {
List<SafetyFiles> fileBeanList = safetyFilesService.upload(request, file, SafetyFunctionEnum.EDUCATION_TRAINEE.getId(), null, bean.getId());
bean.setFileId(fileBeanList.get(0).getId());
safetyEducationTraineeService.update(bean);
// 删除原来的附件记录
safetyFilesService.deleteById(oldBean.getFileId());
} else if (StringUtils.isEmpty(bean.getFileId()) && file.getSize()==0) {
} else if (StringUtils.isEmpty(bean.getFileId()) && file.getSize() == 0) {
bean.setFileId(null);
safetyEducationTraineeService.update(bean);
safetyFilesService.deleteById(oldBean.getFileId());
}else {
// safetyFilesService.deleteById(oldBean.getFileId());
} else {
safetyEducationTraineeService.update(bean);
}
return Result.success();
@ -210,6 +212,7 @@ public class SafetyEducationTraineeController {
}
return Result.success();
}
/**
* 删除附件
*
@ -223,8 +226,8 @@ public class SafetyEducationTraineeController {
SafetyEducationTrainee bean = safetyEducationTraineeService.selectById(id);
safetyFilesService.deleteById(bean.getFileId());
bean.setFileId("");
int row = safetyEducationTraineeService.update(bean);
if (row!=0) {
int row = safetyEducationTraineeService.update(bean);
if (row != 0) {
return Result.success();
}
return Result.failed("删除失败!");

View File

@ -84,13 +84,17 @@ public class SafetyCheckActivityService {
* @Date: 2022/10/10
**/
public Result audit(String nextUserId, String processInstanceId, int pass) {
Task task =
workflowService.getTaskService().createTaskQuery().processInstanceId(processInstanceId).singleResult();
List<Task> tasks = workflowService.getTaskService().createTaskQuery().processInstanceId(processInstanceId).active().list();
if (tasks == null || tasks.isEmpty()) {
return Result.failed("No active task found for process instance: " + processInstanceId);
}
Map<String, Object> map = new HashMap<>();
map.put(CommString.ACTI_KEK_Condition, pass);
map.put(CommString.ACTI_KEK_Assignee, nextUserId);
map.put(CommString.ACTI_KEK_Candidate_Users, nextUserId);
workflowService.getTaskService().complete(task.getId(), map);
for (Task task : tasks) {
workflowService.getTaskService().complete(task.getId(), map);
}
return Result.success();
}