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

View File

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