|
@@ -0,0 +1,243 @@
|
|
|
+package com.ims.eval.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.ims.eval.config.CustomException;
|
|
|
+import com.ims.eval.entity.DeptAssessmentDeclaration;
|
|
|
+import com.ims.eval.entity.DeptAssessmentDeclarationContent;
|
|
|
+import com.ims.eval.entity.dto.result.R;
|
|
|
+import com.ims.eval.service.IDeptAssessmentDeclarationContentService;
|
|
|
+import com.ims.eval.service.IDeptAssessmentDeclarationService;
|
|
|
+import com.ims.eval.util.ExcelUtil;
|
|
|
+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.InputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 绩效结果考核申报
|
|
|
+ *
|
|
|
+ * @author hlf
|
|
|
+ * @date 2023/5/29 15:15
|
|
|
+ * 文件说明:
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("//evaluation-dept-ad")
|
|
|
+public class DeptAssessmentDeclarationController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDeptAssessmentDeclarationService deptAssessmentDeclarationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDeptAssessmentDeclarationContentService deptAssessmentDeclarationContentService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绩效结果考核申报列表信息(分页)
|
|
|
+ *
|
|
|
+ * @param pageNum 当前记录起始索引
|
|
|
+ * @param pageSize 每页显示记录数
|
|
|
+ * @param orderNumber 单号
|
|
|
+ * @param deptId 部门主键
|
|
|
+ * @param annual 年度
|
|
|
+ * @param declarationMonth 申报月份
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public R list(
|
|
|
+ @RequestParam(value = "pageNum") Integer pageNum,
|
|
|
+ @RequestParam(value = "pageSize") Integer pageSize,
|
|
|
+ @RequestParam(value = "orderNumber", required = false) String orderNumber,
|
|
|
+ @RequestParam(value = "deptId", required = false) String deptId,
|
|
|
+ @RequestParam(value = "annual", required = false) String annual,
|
|
|
+ @RequestParam(value = "declarationMonth", required = false) String declarationMonth) {
|
|
|
+ IPage<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.listPage(pageNum, pageSize, orderNumber, deptId, annual, declarationMonth);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绩效结果考核申报信息
|
|
|
+ *
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/listAll")
|
|
|
+ public R listAll() {
|
|
|
+ List<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.list();
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增绩效结果考核申报信息
|
|
|
+ *
|
|
|
+ * @param deptAssessmentDeclaration 绩效结果考核申报实体
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/save")
|
|
|
+ public R addAll(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration) {
|
|
|
+ try {
|
|
|
+ boolean b = deptAssessmentDeclarationService.save(deptAssessmentDeclaration);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改绩效结果考核申报信息
|
|
|
+ *
|
|
|
+ * @param deptAssessmentDeclaration 绩效结果考核申报实体
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/modify")
|
|
|
+ public R modify(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration) {
|
|
|
+ try {
|
|
|
+ boolean b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("修改失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除绩效结果考核申报信息
|
|
|
+ *
|
|
|
+ * @param ids 主键s
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/removeAll/{ids}")
|
|
|
+ public R deleteAll(@PathVariable("ids") String ids) {
|
|
|
+ String[] strings = ids.split(",");
|
|
|
+ boolean b = deptAssessmentDeclarationService.removeByIds(Arrays.asList(strings));
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情-头部信息
|
|
|
+ *
|
|
|
+ * @param id 业务主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/detailsHead/{id}")
|
|
|
+ public R detailsHead(@PathVariable("id") String id) {
|
|
|
+ DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
|
|
|
+ return R.ok().data(deptAssessmentDeclaration);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ *
|
|
|
+ * @param id 业务主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/details/{id}")
|
|
|
+ public R details(@PathVariable("id") String id) {
|
|
|
+ List<DeptAssessmentDeclarationContent> list = deptAssessmentDeclarationContentService.detailsList(id);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情-修改/新增
|
|
|
+ *
|
|
|
+ * @param deptAssessmentDeclarationContentList 修改内容
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/update")
|
|
|
+ public R update(@RequestBody List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList) {
|
|
|
+ try {
|
|
|
+ boolean b = deptAssessmentDeclarationContentService.saveOrUpdateBatch(deptAssessmentDeclarationContentList);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("修改失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/import")
|
|
|
+ public R importData(@RequestParam("file") MultipartFile file) {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ try {
|
|
|
+ //获取原始的文件名
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ //获取文件类型
|
|
|
+ String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
|
|
|
+ //默认从第一行开始读取
|
|
|
+ int startRows = 1;
|
|
|
+ //获取输入流
|
|
|
+ InputStream is = file.getInputStream();
|
|
|
+ List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = new ArrayList<>();
|
|
|
+ //Excel导入导出的单元类
|
|
|
+ List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
|
|
|
+ //遍历Excel表每一行的数据
|
|
|
+ for (String[] str : strings) {
|
|
|
+ DeptAssessmentDeclarationContent deptAssessmentDeclarationContent = new DeptAssessmentDeclarationContent();
|
|
|
+ deptAssessmentDeclarationContent.setId(str[0]);
|
|
|
+ deptAssessmentDeclarationContent.setAssessmentDeclarationId(str[1]);
|
|
|
+ deptAssessmentDeclarationContent.setSerialNumber(str[2]);
|
|
|
+ deptAssessmentDeclarationContent.setEmployeeId(str[3]);
|
|
|
+ deptAssessmentDeclarationContent.setEmployeeName(str[4]);
|
|
|
+ deptAssessmentDeclarationContent.setSuggestedValue(str[5]);
|
|
|
+ deptAssessmentDeclarationContentList.add(deptAssessmentDeclarationContent);
|
|
|
+ }
|
|
|
+ boolean b = deptAssessmentDeclarationContentService.saveOrUpdateBatch(deptAssessmentDeclarationContentList);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("错误", e);
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.customError("上传文件为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改状态
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @param stage 状态
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/targetStart")
|
|
|
+ public R targetStart(@RequestParam(value = "id") String id,
|
|
|
+ @RequestParam(value = "stage") String stage) {
|
|
|
+ try {
|
|
|
+ DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
|
|
|
+ deptAssessmentDeclaration.setStage(stage);
|
|
|
+ boolean b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|