|
@@ -2,15 +2,19 @@ package com.ims.eval.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.ims.eval.config.CustomException;
|
|
|
-import com.ims.eval.entity.EvaluationDeptRating;
|
|
|
+import com.ims.eval.entity.DataDictionary;
|
|
|
import com.ims.eval.entity.EvaluationNotice;
|
|
|
+import com.ims.eval.entity.custom.Path;
|
|
|
import com.ims.eval.entity.dto.result.R;
|
|
|
+import com.ims.eval.service.IDataDictionaryService;
|
|
|
import com.ims.eval.service.IEvaluationNoticeService;
|
|
|
+import com.ims.eval.util.FileUploadUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -30,6 +34,9 @@ public class NoticeManagementController {
|
|
|
@Autowired
|
|
|
private IEvaluationNoticeService evaluationNoticeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
/**
|
|
|
* 通告管理列表信息(分页)
|
|
|
*
|
|
@@ -44,6 +51,18 @@ public class NoticeManagementController {
|
|
|
@RequestParam(value = "pageSize") Integer pageSize,
|
|
|
@RequestParam(value = "noticeTitle", required = false) String noticeTitle) {
|
|
|
IPage<EvaluationNotice> list = evaluationNoticeService.listPage(pageNum, pageSize, noticeTitle);
|
|
|
+ List<EvaluationNotice> evaluationNoticeList = list.getRecords();
|
|
|
+ for (EvaluationNotice obj : evaluationNoticeList) {
|
|
|
+ StringBuilder names = new StringBuilder();
|
|
|
+ if (!"".equals(obj.getSendToContent()) && null != obj.getSendToContent()) {
|
|
|
+ String[] strings = obj.getSendToContent().split(",");
|
|
|
+ for (String str : strings) {
|
|
|
+ DataDictionary dataDictionary = dataDictionaryService.getById(str);
|
|
|
+ names.append(dataDictionary.getKeyName()).append(",");
|
|
|
+ }
|
|
|
+ obj.setDeptNames(names.toString().substring(0, names.toString().length() - 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.ok().data(list);
|
|
|
}
|
|
|
|
|
@@ -65,7 +84,7 @@ public class NoticeManagementController {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@PostMapping(value = "/save")
|
|
|
- public R addAll(EvaluationNotice evaluationNotice, @RequestParam(value ="files", required = false) MultipartFile[] files) throws IOException {
|
|
|
+ public R addAll(EvaluationNotice evaluationNotice, @RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
|
|
|
try {
|
|
|
boolean b = evaluationNoticeService.saveOrUpdate(evaluationNotice, files);
|
|
|
if (b) {
|
|
@@ -96,15 +115,15 @@ public class NoticeManagementController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 发布通告
|
|
|
+ * 修改状态
|
|
|
*
|
|
|
* @param id 主键
|
|
|
- * @param releaseState 发布状态
|
|
|
+ * @param releaseState 状态(未发布或已发布)
|
|
|
* @return 结果
|
|
|
*/
|
|
|
- @PostMapping(value = "/issueNotice")
|
|
|
- public R issueNotice(@RequestParam(value = "id") String id,
|
|
|
- @RequestParam(value = "releaseState") String releaseState) {
|
|
|
+ @PostMapping(value = "/modifiedState")
|
|
|
+ public R modifiedState(@RequestParam(value = "id") String id,
|
|
|
+ @RequestParam(value = "releaseState") String releaseState) {
|
|
|
EvaluationNotice evaluationNotice = new EvaluationNotice();
|
|
|
evaluationNotice.setId(id);
|
|
|
evaluationNotice.setReleaseState(releaseState);
|
|
@@ -112,7 +131,95 @@ public class NoticeManagementController {
|
|
|
if (b) {
|
|
|
return R.ok().data(b);
|
|
|
} else {
|
|
|
- return R.error().data("发布失败!");
|
|
|
+ return R.error().data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传附件
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @param files 附件集
|
|
|
+ * @return 结果
|
|
|
+ * @throws IOException 异常
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/uploadAttachment")
|
|
|
+ public R uploadAttachment(@RequestParam(value = "id") String id, @RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
|
|
|
+ try {
|
|
|
+ boolean b = false;
|
|
|
+ EvaluationNotice evaluationNotice = evaluationNoticeService.getById(id);
|
|
|
+ StringBuilder fileNames = new StringBuilder();
|
|
|
+ if (files.length > 0) {
|
|
|
+ for (MultipartFile file : files) {
|
|
|
+ // 上传文件路径
|
|
|
+ String filePath = Path.getNoticePath();
|
|
|
+ // 上传并返回新文件名称
|
|
|
+ String fileName = null;
|
|
|
+ fileName = FileUploadUtil.upload(filePath, file);
|
|
|
+ fileNames.append(fileName).append(",");
|
|
|
+ }
|
|
|
+ String noticeAnnex = evaluationNotice.getNoticeAnnex() + "," + fileNames.toString().substring(0, fileNames.toString().length() - 1);
|
|
|
+ evaluationNotice.setNoticeAnnex(noticeAnnex);
|
|
|
+ b = evaluationNoticeService.updateById(evaluationNotice);
|
|
|
+ }
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("上传附件失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除附件
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @param noticeAnnex 附件名称
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/deleteAttachment")
|
|
|
+ public R deleteAttachment(@RequestParam(value = "id") String id, @RequestParam(value = "noticeAnnex") String noticeAnnex) {
|
|
|
+ try {
|
|
|
+ boolean b;
|
|
|
+ EvaluationNotice evaluationNotice = evaluationNoticeService.getById(id);
|
|
|
+ String[] strings = evaluationNotice.getNoticeAnnex().split(",");
|
|
|
+ StringBuilder fileNames = new StringBuilder();
|
|
|
+ for (String str : strings) {
|
|
|
+ if (str.substring(str.lastIndexOf("/") + 1, str.length()).equals(noticeAnnex)) {
|
|
|
+ String filePath = Path.getStatementPath() + str;
|
|
|
+ File file = new File(filePath);
|
|
|
+ b = file.delete();
|
|
|
+ } else {
|
|
|
+ fileNames.append(str).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ evaluationNotice.setNoticeAnnex(fileNames.toString().substring(0, fileNames.toString().length() - 1));
|
|
|
+ b = evaluationNoticeService.updateById(evaluationNotice);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除附件失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通告展示
|
|
|
+ *
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/deptId")
|
|
|
+ public R circularDisplay(@RequestParam(value = "id") String deptId) {
|
|
|
+ List<EvaluationNotice> evaluationNoticeList = evaluationNoticeService.list();
|
|
|
+ for (EvaluationNotice evaluationNotice : evaluationNoticeList) {
|
|
|
+ if ("All".equals(evaluationNotice.getSendTo())){
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+ return R.ok().data(evaluationNoticeList);
|
|
|
}
|
|
|
}
|