修改数据
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.base.constant;
|
||||
|
||||
/**
|
||||
* 错误信息常量
|
||||
*/
|
||||
public interface ErrorMessageConstant {
|
||||
/**
|
||||
* "id不能为空"
|
||||
*/
|
||||
public static final String ID_NOT_NULL = "id不能为空";
|
||||
/**
|
||||
* "已启用禁用模板不能进行修改"
|
||||
*/
|
||||
public static final String ENABLE_DISABLE_TEMPLATE_NOT_MODIFY = "已启用禁用模板不能进行修改";
|
||||
}
|
@ -2,8 +2,11 @@ package com.chinaunicom.zyhy.ebtp.supplier.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserVo {
|
||||
public class UserVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.controller;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.chinaunicom.mall.ebtp.common.base.controller.BaseController;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.base.constant.ErrorMessageConstant;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.base.constant.ReviewTemplateConstant;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.entity.CoscoAnnualreviewTemplate;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.service.ICoscoAnnualreviewTemplateService;
|
||||
@ -70,11 +71,11 @@ public class CoscoAnnualreviewTemplateController extends BaseController {
|
||||
@PutMapping
|
||||
public BaseResponse edit(@RequestBody AddCoscoAnnualreviewTemplateVo coscoAnnualreviewTemplate) {
|
||||
if (coscoAnnualreviewTemplate.getId() == null) {
|
||||
return BaseResponse.fail("id不能为空");
|
||||
return BaseResponse.fail(ErrorMessageConstant.ID_NOT_NULL);
|
||||
}
|
||||
CoscoAnnualreviewTemplate coscoAnnualreviewTemplate1 = coscoAnnualreviewTemplateService.selectCoscoAnnualreviewTemplateById(coscoAnnualreviewTemplate.getId());
|
||||
if (!coscoAnnualreviewTemplate1.getStatus().equals(ReviewTemplateConstant.DRAFT_STATUS)) {
|
||||
return BaseResponse.fail("已启用禁用模板不能进行修改");
|
||||
return BaseResponse.fail(ErrorMessageConstant.ENABLE_DISABLE_TEMPLATE_NOT_MODIFY);
|
||||
}
|
||||
return BaseResponse.success(coscoAnnualreviewTemplateService.updateCoscoAnnualreviewTemplate(coscoAnnualreviewTemplate));
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AnnualAddScoreVo {
|
||||
public class AnnualAddScoreVo implements Serializable {
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
|
@ -1,12 +1,15 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 人员打分项信息
|
||||
*/
|
||||
@Data
|
||||
public class AnnualTaskIndicatorVo {
|
||||
public class AnnualTaskIndicatorVo implements Serializable {
|
||||
/**
|
||||
* 打分项id
|
||||
*/
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AnnualreviewTaskSupplierListVo {
|
||||
public class AnnualreviewTaskSupplierListVo implements Serializable {
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AnnualreviewTaskSupplierUserInfoVo {
|
||||
public class AnnualreviewTaskSupplierUserInfoVo implements Serializable {
|
||||
/**
|
||||
* 供应商
|
||||
*/
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class AnnualreviewTaskSupplierUserVo {
|
||||
public class AnnualreviewTaskSupplierUserVo implements Serializable {
|
||||
|
||||
private String id;
|
||||
/**
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AuditQuantityVo {
|
||||
public class AuditQuantityVo implements Serializable {
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class CoscoAnnualreviewTaskListVo {
|
||||
public class CoscoAnnualreviewTaskListVo implements Serializable {
|
||||
/**
|
||||
* 评价id
|
||||
*/
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoAnnualreview.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SupplierPeopleVo {
|
||||
public class SupplierPeopleVo implements Serializable {
|
||||
|
||||
private String suppliedId;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoBlack.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo.TaskUserVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -8,7 +9,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BlackSupplierVo {
|
||||
public class BlackSupplierVo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AddCategoryIdVos {
|
||||
public class AddCategoryIdVos implements Serializable {
|
||||
|
||||
/**
|
||||
* 品类id(cosco_category表主键)
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BlackApproveVo {
|
||||
public class BlackApproveVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CategoryContainListVo {
|
||||
public class CategoryContainListVo implements Serializable {
|
||||
|
||||
private String categoryLibraryId;
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 品类供应商列表
|
||||
*/
|
||||
@Data
|
||||
public class CoscoCategoryLibrarySupplierVo {
|
||||
public class CoscoCategoryLibrarySupplierVo implements Serializable {
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
|
@ -4,10 +4,11 @@ import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class CoscoCategoryLibraryVo {
|
||||
public class CoscoCategoryLibraryVo implements Serializable {
|
||||
/**
|
||||
* 品类库id
|
||||
*/
|
||||
|
@ -4,10 +4,11 @@ import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ListCoscoCategoryLibrarySupplierApplyVo {
|
||||
public class ListCoscoCategoryLibrarySupplierApplyVo implements Serializable {
|
||||
/**
|
||||
* 供应商入库审批id
|
||||
*/
|
||||
|
@ -11,10 +11,14 @@ import com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo.SupplierDimensionVo;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.alibaba.excel.EasyExcelFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@ -48,11 +52,15 @@ public class CoscoEvaluateTaskSupplierController extends BaseController {
|
||||
public void export(HttpServletResponse response, CoscoEvaluateTaskSupplier taskListVo) throws Exception {
|
||||
List<CoscoEvaluateTaskSupplier> list=coscoEvaluateTaskSupplierService.export(taskListVo);
|
||||
String fileName = URLEncoder.encode("供应评价.xlsx", "UTF-8");
|
||||
// 动态设置导出字段(忽略未标注字段)
|
||||
Set<String> includeFields = new HashSet<>(Arrays.asList(
|
||||
"supplierName", "categoryName","reviewScore", "reviewResult" // 指定要导出的字段名
|
||||
));
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
||||
EasyExcel.write(response.getOutputStream(), CoscoEvaluateTaskSupplier.class)
|
||||
EasyExcelFactory.write(response.getOutputStream(), CoscoEvaluateTaskSupplier.class)
|
||||
.includeColumnFieldNames(includeFields)
|
||||
.sheet("供应评价")
|
||||
.doWrite(list);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.entity;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
@ -50,41 +51,50 @@ public class CoscoEvaluateTaskSupplier extends BaseEntity {
|
||||
/**
|
||||
* 评价任务id(cosco_evaluate_task表主键)
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String evaluateTaskId;
|
||||
|
||||
/**
|
||||
* 供应商id(cosco_supplier_base表主键)
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String supplierId;
|
||||
|
||||
/**
|
||||
* 等级名称(A级、B级、C级、D级)
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String levelName;
|
||||
/**
|
||||
* 评级名称(优秀供应商、良好供应商、应辅导供应商、应淘汰供应商)
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String ratingName;
|
||||
|
||||
|
||||
/**
|
||||
* 删除标识(normal.正常、deleted.已删除)
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String delFlag = "normal";
|
||||
|
||||
@ExcelIgnore
|
||||
private Date createTime;
|
||||
@ExcelIgnore
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String deptId;
|
||||
/**
|
||||
* 准入部门
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String deptName = "准入部门";
|
||||
|
||||
@ApiModelProperty(value = "分页对象信息")
|
||||
@ExcelIgnore
|
||||
private BasePageRequest basePageRequest;
|
||||
}
|
||||
|
@ -121,79 +121,100 @@ public class ScheduledTasksServiceImpl implements ScheduledTasksService {
|
||||
/**
|
||||
* 计算分数
|
||||
*
|
||||
* @param calculateAndObtainScoresVos
|
||||
* @param coscoEvaluateTaskSupplier
|
||||
* @param coscoEvaluateScoringResults
|
||||
* @param coscoEvaluateTaskDeptWeightes
|
||||
* @param scores
|
||||
* @param supplier
|
||||
* @param results
|
||||
* @param weights
|
||||
* @return
|
||||
*/
|
||||
private static int getCalculateScore(List<CalculateAndObtainScoresVo> calculateAndObtainScoresVos, CoscoEvaluateTaskSupplier coscoEvaluateTaskSupplier, List<CoscoEvaluateScoringResult> coscoEvaluateScoringResults, List<CoscoEvaluateTaskDeptWeight> coscoEvaluateTaskDeptWeightes) {
|
||||
//基础百分比
|
||||
int basePercentage = 100;
|
||||
if (coscoEvaluateTaskDeptWeightes.size() > 0) {
|
||||
for (CoscoEvaluateTaskDeptWeight coscoEvaluateTaskDeptWeighte : coscoEvaluateTaskDeptWeightes) {
|
||||
BigDecimal weightValue = coscoEvaluateTaskDeptWeighte.getWeightValue();
|
||||
basePercentage -= weightValue.multiply(BigDecimal.valueOf(basePercentage)).intValue();
|
||||
}
|
||||
}
|
||||
Map<String, BigDecimal> map = coscoEvaluateTaskDeptWeightes.stream().collect(Collectors.toMap(CoscoEvaluateTaskDeptWeight::getWeightDept, CoscoEvaluateTaskDeptWeight::getWeightValue));
|
||||
//查询当前供应商的评价分数
|
||||
List<CalculateAndObtainScoresVo> suppliList = calculateAndObtainScoresVos.stream().filter(vo -> vo.getSupplierId().equals(coscoEvaluateTaskSupplier.getSupplierId())).collect(Collectors.toList());
|
||||
//根据指标id进行分组
|
||||
Map<String, List<CalculateAndObtainScoresVo>> groupedByIndicator = suppliList.stream().collect(Collectors.groupingBy(CalculateAndObtainScoresVo::getIndicatorNdId));
|
||||
//开始计算评价结果
|
||||
//根据评价结果获取评价总分数
|
||||
Double totalScore = 0.00;
|
||||
for (String id : groupedByIndicator.keySet()) {
|
||||
double indicatorScore = 0;
|
||||
List<CalculateAndObtainScoresVo> indicatorList = groupedByIndicator.get(id);
|
||||
if (coscoEvaluateTaskDeptWeightes.size() > 0) {
|
||||
//获取权重部门打分项信息
|
||||
// 假设 indicatorList 是 List<CalculateAndObtainScoresVo> 类型
|
||||
Map<String, List<CalculateAndObtainScoresVo>> groupedByDeptId = indicatorList.stream().collect(Collectors.groupingBy(CalculateAndObtainScoresVo::getDeptId));
|
||||
BigDecimal weightScore = new BigDecimal(0.00);
|
||||
BigDecimal noWeightScore = new BigDecimal(0.00);
|
||||
int noWeightDeptListI = 0;
|
||||
BigDecimal hundred = BigDecimal.valueOf(100);
|
||||
for (String deptId : groupedByDeptId.keySet()) {
|
||||
//判断是否添加权重
|
||||
BigDecimal bigDecimal = map.get(deptId);
|
||||
//获取部门打分项信息
|
||||
List<CalculateAndObtainScoresVo> calculateAndObtainScoresVos1 = groupedByDeptId.get(deptId);
|
||||
if (bigDecimal != null) {
|
||||
if (calculateAndObtainScoresVos1 != null) {
|
||||
int scoreSum = calculateAndObtainScoresVos1.stream().mapToInt(CalculateAndObtainScoresVo::getScore).sum();
|
||||
// 转换为 BigDecimal 后进行计算
|
||||
BigDecimal allSco = BigDecimal.valueOf(scoreSum);
|
||||
BigDecimal size = BigDecimal.valueOf(calculateAndObtainScoresVos1.size());
|
||||
BigDecimal result = allSco.divide(size, 2, BigDecimal.ROUND_HALF_UP)
|
||||
.multiply(bigDecimal)
|
||||
.divide(hundred, 2, BigDecimal.ROUND_HALF_UP);
|
||||
weightScore.add(result);
|
||||
}
|
||||
} else {
|
||||
if (calculateAndObtainScoresVos1 != null) {
|
||||
int scoreSum = calculateAndObtainScoresVos1.stream().mapToInt(CalculateAndObtainScoresVo::getScore).sum();
|
||||
noWeightScore.add(BigDecimal.valueOf(scoreSum));
|
||||
noWeightDeptListI += calculateAndObtainScoresVos1.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
//计算非权重部门的打分
|
||||
BigDecimal divide = noWeightScore
|
||||
.divide(BigDecimal.valueOf(noWeightDeptListI), 2, BigDecimal.ROUND_HALF_UP)
|
||||
.multiply(new BigDecimal(basePercentage)).divide(hundred, 2, BigDecimal.ROUND_HALF_UP);
|
||||
//计算分数总和
|
||||
indicatorScore = weightScore.add(divide).doubleValue();
|
||||
} else {
|
||||
//获取没有权重的打分信息
|
||||
int sScore = indicatorList.stream().mapToInt(CalculateAndObtainScoresVo::getScore).sum();
|
||||
indicatorScore = (double) sScore / indicatorList.size();
|
||||
}
|
||||
addResults(coscoEvaluateTaskSupplier, coscoEvaluateScoringResults, id, indicatorScore);
|
||||
private static int getCalculateScore(List<CalculateAndObtainScoresVo> scores,
|
||||
CoscoEvaluateTaskSupplier supplier,
|
||||
List<CoscoEvaluateScoringResult> results,
|
||||
List<CoscoEvaluateTaskDeptWeight> weights) {
|
||||
int basePercentage = calculateBasePercentage(weights);
|
||||
Map<String, BigDecimal> weightMap = weightsToMap(weights);
|
||||
List<CalculateAndObtainScoresVo> supplierScores = filterSupplierScores(scores, supplier);
|
||||
Map<String, List<CalculateAndObtainScoresVo>> groupedByIndicator = groupByIndicator(supplierScores);
|
||||
|
||||
double totalScore = 0.0;
|
||||
for (Map.Entry<String, List<CalculateAndObtainScoresVo>> entry : groupedByIndicator.entrySet()) {
|
||||
String indicatorId = entry.getKey();
|
||||
List<CalculateAndObtainScoresVo> indicatorList = entry.getValue();
|
||||
double indicatorScore = calculateIndicatorScore(indicatorList, weightMap, basePercentage);
|
||||
addResults(supplier, results, indicatorId, indicatorScore);
|
||||
totalScore += indicatorScore;
|
||||
}
|
||||
return totalScore.intValue();
|
||||
|
||||
return (int) totalScore;
|
||||
}
|
||||
|
||||
// 1. 计算基础百分比(减去有权重的部分)
|
||||
private static int calculateBasePercentage(List<CoscoEvaluateTaskDeptWeight> weights) {
|
||||
int base = 100;
|
||||
for (CoscoEvaluateTaskDeptWeight w : weights) {
|
||||
BigDecimal weightValue = w.getWeightValue();
|
||||
base -= weightValue.multiply(BigDecimal.valueOf(base)).intValue();
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
// 2. 转换权重为 Map<部门ID, 权重>
|
||||
private static Map<String, BigDecimal> weightsToMap(List<CoscoEvaluateTaskDeptWeight> weights) {
|
||||
return weights.stream().collect(Collectors.toMap(
|
||||
CoscoEvaluateTaskDeptWeight::getWeightDept,
|
||||
CoscoEvaluateTaskDeptWeight::getWeightValue
|
||||
));
|
||||
}
|
||||
|
||||
// 3. 获取当前供应商的评分数据
|
||||
private static List<CalculateAndObtainScoresVo> filterSupplierScores(List<CalculateAndObtainScoresVo> allScores,
|
||||
CoscoEvaluateTaskSupplier supplier) {
|
||||
return allScores.stream()
|
||||
.filter(vo -> vo.getSupplierId().equals(supplier.getSupplierId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 4. 按指标分组
|
||||
private static Map<String, List<CalculateAndObtainScoresVo>> groupByIndicator(List<CalculateAndObtainScoresVo> scores) {
|
||||
return scores.stream().collect(Collectors.groupingBy(CalculateAndObtainScoresVo::getIndicatorNdId));
|
||||
}
|
||||
|
||||
// 5. 计算每个指标的得分
|
||||
private static double calculateIndicatorScore(List<CalculateAndObtainScoresVo> indicatorList,
|
||||
Map<String, BigDecimal> weightMap,
|
||||
int basePercentage) {
|
||||
Map<String, List<CalculateAndObtainScoresVo>> groupedByDept = indicatorList.stream()
|
||||
.collect(Collectors.groupingBy(CalculateAndObtainScoresVo::getDeptId));
|
||||
|
||||
BigDecimal weightScore = BigDecimal.ZERO;
|
||||
BigDecimal noWeightScore = BigDecimal.ZERO;
|
||||
int noWeightCount = 0;
|
||||
BigDecimal hundred = BigDecimal.valueOf(100);
|
||||
|
||||
for (Map.Entry<String, List<CalculateAndObtainScoresVo>> entry : groupedByDept.entrySet()) {
|
||||
String deptId = entry.getKey();
|
||||
List<CalculateAndObtainScoresVo> deptScores = entry.getValue();
|
||||
BigDecimal weight = weightMap.get(deptId);
|
||||
|
||||
int sum = deptScores.stream().mapToInt(CalculateAndObtainScoresVo::getScore).sum();
|
||||
BigDecimal avg = BigDecimal.valueOf(sum).divide(BigDecimal.valueOf(deptScores.size()), 2, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
if (weight != null) {
|
||||
BigDecimal weighted = avg.multiply(weight).divide(hundred, 2, BigDecimal.ROUND_HALF_UP);
|
||||
weightScore = weightScore.add(weighted);
|
||||
} else {
|
||||
noWeightScore = noWeightScore.add(BigDecimal.valueOf(sum));
|
||||
noWeightCount += deptScores.size();
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal nonWeighted = noWeightCount > 0 ?
|
||||
noWeightScore.divide(BigDecimal.valueOf(noWeightCount), 2, BigDecimal.ROUND_HALF_UP)
|
||||
.multiply(BigDecimal.valueOf(basePercentage))
|
||||
.divide(hundred, 2, BigDecimal.ROUND_HALF_UP) :
|
||||
BigDecimal.ZERO;
|
||||
|
||||
return weightScore.add(nonWeighted).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AddScoreVo {
|
||||
public class AddScoreVo implements Serializable {
|
||||
/**
|
||||
* 打分主键
|
||||
*/
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AdduserIndicatorVo {
|
||||
public class AdduserIndicatorVo implements Serializable {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApproveVo {
|
||||
public class ApproveVo implements Serializable {
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CalculateAndObtainScoresVo {
|
||||
public class CalculateAndObtainScoresVo implements Serializable {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
@ -1,15 +1,17 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CoscoEvaluateTaskListVo {
|
||||
public class CoscoEvaluateTaskListVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
|
@ -1,13 +1,15 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class CoscoEvaluateTemplateVo {
|
||||
public class CoscoEvaluateTemplateVo implements Serializable {
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
|
@ -2,8 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class DivisionVo {
|
||||
public class DivisionVo implements Serializable {
|
||||
private String taskId;
|
||||
private String division;
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class NoTaskVo {
|
||||
public class NoTaskVo implements Serializable {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
@ -2,8 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ScoreVo {
|
||||
public class ScoreVo implements Serializable {
|
||||
/**
|
||||
* 打分项id
|
||||
*/
|
||||
|
@ -4,11 +4,13 @@ import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 供应商维度评价
|
||||
*/
|
||||
@Data
|
||||
public class SupplierDimensionVo {
|
||||
public class SupplierDimensionVo implements Serializable {
|
||||
/**
|
||||
* 人员任务id
|
||||
*/
|
||||
|
@ -5,8 +5,10 @@ import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SupplierListVo {
|
||||
public class SupplierListVo implements Serializable {
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
|
@ -2,10 +2,11 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TaskIndicatorBaseVo {
|
||||
public class TaskIndicatorBaseVo implements Serializable {
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
|
@ -2,10 +2,11 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TaskIndicatorVo {
|
||||
public class TaskIndicatorVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 基础指标
|
||||
|
@ -4,8 +4,10 @@ import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TaskPageVo {
|
||||
public class TaskPageVo implements Serializable {
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
|
@ -2,8 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TaskSubIndicatorVo {
|
||||
public class TaskSubIndicatorVo implements Serializable {
|
||||
/**
|
||||
* 打分项id
|
||||
*/
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TaskSupplierVo {
|
||||
public class TaskSupplierVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
|
@ -2,8 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TaskUserVo {
|
||||
public class TaskUserVo implements Serializable {
|
||||
/**
|
||||
* 人员ID
|
||||
*/
|
||||
|
@ -2,8 +2,10 @@ package com.chinaunicom.zyhy.ebtp.supplier.coscoEvaluate.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserNdTypeVo {
|
||||
public class UserNdTypeVo implements Serializable {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
Reference in New Issue
Block a user