|
@@ -2,25 +2,36 @@ package com.ims.eval.controller;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ims.eval.cache.CacheContext;
|
|
|
import com.ims.eval.config.CustomException;
|
|
|
+import com.ims.eval.dao.OrganizationEvaluationInfoMapper;
|
|
|
+import com.ims.eval.entity.OrganizationEvaluation;
|
|
|
import com.ims.eval.entity.OrganizationRating;
|
|
|
+import com.ims.eval.entity.dto.response.MyuserResDTO;
|
|
|
import com.ims.eval.entity.dto.result.R;
|
|
|
+import com.ims.eval.service.IOrganizationEvaluationService;
|
|
|
import com.ims.eval.service.IOrganizationRatingService;
|
|
|
+import com.ims.eval.service.custom.PostUserService;
|
|
|
import com.ims.eval.util.ExcelUtil;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -37,6 +48,41 @@ public class OrganizationRatingController {
|
|
|
@Autowired
|
|
|
private IOrganizationRatingService organizationRatingService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PostUserService postUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrganizationEvaluationService organizationEvaluationService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrganizationEvaluationInfoMapper organizationEvaluationInfoMapper;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/save-info")
|
|
|
+ public R save(@RequestBody List<OrganizationRating> orgRating) {
|
|
|
+ try {
|
|
|
+ boolean b = organizationRatingService.updateBatchById(orgRating);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 动态获取评级的业务阶段
|
|
|
+ */
|
|
|
+ @GetMapping(value = "bin-section")
|
|
|
+ public R binSection(@RequestParam(value = "organizationYearRatingId") String organizationYearRatingId) {
|
|
|
+ return organizationRatingService.binSection(organizationYearRatingId);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -51,6 +97,7 @@ public class OrganizationRatingController {
|
|
|
|
|
|
/**
|
|
|
* 查询
|
|
|
+ *
|
|
|
* @param pageNum
|
|
|
* @param pageSize
|
|
|
* @param id
|
|
@@ -60,25 +107,49 @@ public class OrganizationRatingController {
|
|
|
*/
|
|
|
@GetMapping(value = "list")
|
|
|
public R list(@RequestParam(value = "pageNum") Integer pageNum,
|
|
|
- @RequestParam(value = "pageSize") Integer pageSize,
|
|
|
- @RequestParam(value = "id", required = false) String id,
|
|
|
- @RequestParam(value = "organizationYearRatingId", required = false) String organizationYearRatingId,
|
|
|
- @RequestParam(value = "binSection", required = false) String binSection,
|
|
|
- @RequestParam(value = "year", required = false) String year,
|
|
|
- @RequestParam(value = "organizationShortName", required = false) String organizationShortName,
|
|
|
- @RequestParam(value = "organizationId", required = false) String organizationId,
|
|
|
- @RequestParam(value = "safetyEnvProtection", required = false) String safetyEnvProtection,
|
|
|
- @RequestParam(value = "veto", required = false) String veto,
|
|
|
- @RequestParam(value = "netProfit", required = false) String netProfit,
|
|
|
- @RequestParam(value = "compositeScore", required = false) String compositeScore,
|
|
|
- @RequestParam(value = "annualTarget", required = false) String annualTarget,
|
|
|
- @RequestParam(value = "bonusPoint", required = false) String bonusPoint,
|
|
|
- @RequestParam(value = "compositeScoreRaking", required = false) String compositeScoreRaking,
|
|
|
- @RequestParam(value = "projectLevel", required = false) String projectLevel,
|
|
|
- @RequestParam(value = "score", required = false) String score) {
|
|
|
- IPage<OrganizationRating> list = organizationRatingService.list(pageNum, pageSize, id, organizationYearRatingId, binSection, year, organizationShortName, organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel,score);
|
|
|
- if (list.getRecords().isEmpty()) {
|
|
|
- return R.ok().data("");
|
|
|
+ @RequestParam(value = "pageSize") Integer pageSize,
|
|
|
+ @RequestParam(value = "id", required = false) String id,
|
|
|
+ @RequestParam(value = "organizationYearRatingId", required = false) String organizationYearRatingId,
|
|
|
+ @RequestParam(value = "binSection", required = false) String binSection,
|
|
|
+ @RequestParam(value = "year", required = false) String year,
|
|
|
+ @RequestParam(value = "organizationShortName", required = false) String organizationShortName,
|
|
|
+ @RequestParam(value = "organizationId", required = false) String organizationId,
|
|
|
+ @RequestParam(value = "safetyEnvProtection", required = false) String safetyEnvProtection,
|
|
|
+ @RequestParam(value = "veto", required = false) String veto,
|
|
|
+ @RequestParam(value = "netProfit", required = false) String netProfit,
|
|
|
+ @RequestParam(value = "compositeScore", required = false) String compositeScore,
|
|
|
+ @RequestParam(value = "annualTarget", required = false) String annualTarget,
|
|
|
+ @RequestParam(value = "bonusPoint", required = false) String bonusPoint,
|
|
|
+ @RequestParam(value = "compositeScoreRaking", required = false) String compositeScoreRaking,
|
|
|
+ @RequestParam(value = "projectLevel", required = false) String projectLevel,
|
|
|
+ @RequestParam(value = "score", required = false) String score) {
|
|
|
+ LambdaQueryWrapper<OrganizationEvaluation> qw = new LambdaQueryWrapper<>();
|
|
|
+ qw.eq(OrganizationEvaluation::getId, organizationYearRatingId);
|
|
|
+ List<OrganizationEvaluation> orgEva = organizationEvaluationService.list(qw);
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append("NDKP_").append(orgEva.get(0).getYear()).append("_1");
|
|
|
+
|
|
|
+ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
+ HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
|
|
|
+ JSONObject json = postUserService.getSysUser(request.getHeader("code"), request.getHeader("Blade-Auth"), request);
|
|
|
+ MyuserResDTO user = JSONObject.parseObject(json.getJSONObject("data").toJSONString(), MyuserResDTO.class);
|
|
|
+
|
|
|
+ IPage<OrganizationRating> list = organizationRatingService.list(pageNum, pageSize, id, organizationYearRatingId, binSection, year, organizationShortName, organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel, score);
|
|
|
+ List<OrganizationRating> ls = null;
|
|
|
+ organizationEvaluationInfoMapper.selectEvaluationInfoList();
|
|
|
+ String s = CacheContext.childCompanyId.get(user.getId());
|
|
|
+ if (s != null) {
|
|
|
+ Set<String> childList = CacheContext.getChildList(s, sb.toString());
|
|
|
+ ls = list.getRecords().stream().filter(a -> childList.contains(a.getOrganizationId())).collect(Collectors.toList());
|
|
|
+ if (ls.isEmpty()) {
|
|
|
+ return R.ok().data("");
|
|
|
+ }
|
|
|
+ int f = (pageNum - 1) * pageSize;
|
|
|
+ int tol = Math.min(f + pageSize, ls.size());
|
|
|
+ List<OrganizationRating> lsPage = ls.subList(f, tol);
|
|
|
+ IPage<OrganizationRating> lor = new Page<>(pageNum, pageSize, ls.size());
|
|
|
+ lor.setRecords(lsPage);
|
|
|
+ return R.ok().data(lor);
|
|
|
}
|
|
|
return R.ok().data(list);
|
|
|
}
|
|
@@ -196,17 +267,40 @@ public class OrganizationRatingController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 导出文件
|
|
|
*/
|
|
|
@GetMapping(value = "exportExcel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
public R exportExcel(HttpServletResponse response,
|
|
|
- @RequestParam(value = "binSection", required = false) String binSection,
|
|
|
- @RequestParam(value = "year", required = false) String year) throws IOException {
|
|
|
+ @RequestParam(value = "organizationYearRatingId", required = false) String organizationYearRatingId,
|
|
|
+ @RequestParam(value = "binSection", required = false) String binSection,
|
|
|
+ @RequestParam(value = "year", required = false) String year) throws IOException {
|
|
|
|
|
|
- organizationRatingService.exportExcel(response,binSection,year);
|
|
|
- return R.ok();
|
|
|
+ LambdaQueryWrapper<OrganizationEvaluation> qw = new LambdaQueryWrapper<>();
|
|
|
+ qw.eq(OrganizationEvaluation::getId, organizationYearRatingId);
|
|
|
+ List<OrganizationEvaluation> orgEva = organizationEvaluationService.list(qw);
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append("NDKP_").append(orgEva.get(0).getYear()).append("_1");
|
|
|
+
|
|
|
+ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
+ HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
|
|
|
+ JSONObject json = postUserService.getSysUser(request.getHeader("code"), request.getHeader("Blade-Auth"), request);
|
|
|
+ MyuserResDTO user = JSONObject.parseObject(json.getJSONObject("data").toJSONString(), MyuserResDTO.class);
|
|
|
+
|
|
|
+ IPage<OrganizationRating> listData = organizationRatingService.list(1, 100000, null, organizationYearRatingId, binSection, year,
|
|
|
+ null, null,
|
|
|
+ null, null, null, null, null, null, null, null, null);
|
|
|
+
|
|
|
+ List<OrganizationRating> ls = null;
|
|
|
+ organizationEvaluationInfoMapper.selectEvaluationInfoList();
|
|
|
+ String s = CacheContext.childCompanyId.get(user.getId());
|
|
|
+ if (s != null) {
|
|
|
+ Set<String> childList = CacheContext.getChildList(s, sb.toString());
|
|
|
+ ls = listData.getRecords().stream().filter(a -> childList.contains(a.getOrganizationId())).collect(Collectors.toList());
|
|
|
+ return organizationRatingService.exportExcel(response,ls,binSection,year);
|
|
|
+ }
|
|
|
+ ls = listData.getRecords();
|
|
|
+ return organizationRatingService.exportExcel(response,ls,binSection,year);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -217,7 +311,7 @@ public class OrganizationRatingController {
|
|
|
public R importExcel(@RequestParam("file") MultipartFile file,
|
|
|
@RequestParam(value = "binSection") String binSection,
|
|
|
@RequestParam(value = "year") String year
|
|
|
- ) {
|
|
|
- return organizationRatingService.importExcel(file,binSection,year);
|
|
|
+ ) {
|
|
|
+ return organizationRatingService.importExcel(file, binSection, year);
|
|
|
}
|
|
|
}
|