获取详情保存详情增加评分详细记录

This commit is contained in:
wulin 2020-10-29 19:33:47 +08:00
parent b92dfdb974
commit f8fc1d16c3
16 changed files with 206 additions and 5 deletions

View File

@ -40,6 +40,7 @@ import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -95,6 +96,12 @@ public class ResultRecordController extends AbstractController {
@Autowired
private ResultCalculateService resultCalculateService;
@Autowired
private ResultScoreService resultScoreService;
@Autowired
private FlowChartDetailRecordService flowChartDetailRecordService;
/**
* 列表
*/
@ -348,6 +355,50 @@ public class ResultRecordController extends AbstractController {
//获取计算公式
List<CalculateModel> calculateModels = getCalculate(resultModels.get(0).getCalculateId());
List<ResultScoreDto> scoreDtos = new ArrayList<>();
//查询所有参与评分人以及所占比重
List<FlowChartDetailRecord> flowChartDetailRecords =
flowChartDetailRecordService.selectFlowChartDetailRecordsByFlowProcess(resultRecord.getEvaluationId(), 4);//获取参与评分的人
List<StaffEntity> staffs = new ArrayList<>();
for (FlowChartDetailRecord record:flowChartDetailRecords
) {
if(record.getOptType().intValue() == -1){
//自己
StaffEntity staffEntity = new StaffEntity();
staffEntity.setId(resultRecord.getId());
staffEntity.setName(resultRecord.getStaffName());
staffs.add(staffEntity);
}else if(record.getOptType().intValue() == 0){
//指定人员
//获取人员信息
List<Long> sIds = Arrays.stream(record.getOptIds().split(",")).map(new Function<String, Long>() {
@Override
public Long apply(String s) {
return Long.parseLong(s);
}
}).collect(Collectors.toList());
staffs.addAll(staffService.selectNamesByIds(sIds));//这里不过滤离职人员因为过滤了可能涉及到评分规则的变更
}else{
//领导
DepartManagers departManagers = staffService.findLeader(resultRecord.getStaffId(), record.getOptType());
if(departManagers.getManagers().size() > 0){
staffs.addAll(departManagers.getManagers());
}
}
for (StaffEntity staff:staffs
) {
ResultScoreDto resultScore = new ResultScoreDto();
resultScore.setApprovalId(staff.getId());
resultScore.setApprovalName(staff.getName());
resultScore.setWeight(record.getWeight());
scoreDtos.add(resultScore);
}
}
resultRecordDetailDto.setGradeGroupId(resultModels.get(0).getGradeGroupId());//设置评分等级
StaffEntity staffEntity = staffService.selectStaffById(resultRecord.getStaffId());
resultRecordDetailDto.setAvatar(staffEntity.getAvatar());
@ -365,6 +416,42 @@ public class ResultRecordController extends AbstractController {
) {
dto.setCalculate(setCalculateValue(calculateModels, dto)) ;
weight = weight.add(dto.getCheckWeight());
//获取评分详细
List<ResultScore> scores =
resultScoreService.selectResultScoresByDetailIdAndOrderByStaffIds(dto.getId(), scoreDtos);
if(scores.size() > 0){
//
List<ResultScoreDto> scoreDtos1 = new ArrayList<>();
for (ResultScoreDto scoreDto: scoreDtos
) {//
//
boolean isAdd = false;
for (ResultScore score:
scores) {
if(scoreDto.getApprovalId().longValue() == score.getApprovalId().longValue()){
ResultScoreDto scoreDto1 = new ResultScoreDto();
BeanUtils.copyProperties(scoreDto1, score);
scoreDto1.setApprovalId(scoreDto.getApprovalId());
scoreDto1.setApprovalName(scoreDto.getApprovalName());
scoreDto1.setWeight(scoreDto.getWeight());
scoreDtos1.add(scoreDto1);
scores.remove(score);
isAdd = true;
break;
}
}
if(!isAdd){
ResultScoreDto scoreDto1 = new ResultScoreDto();
scoreDto1.setApprovalId(scoreDto.getApprovalId());
scoreDto1.setApprovalName(scoreDto.getApprovalName());
scoreDto1.setWeight(scoreDto.getWeight());
scoreDtos1.add(scoreDto1);
}
}
dto.setScoreDtos(scoreDtos1);
}else{
dto.setScoreDtos(scoreDtos);
}
}
//下面设置计算公式
@ -477,6 +564,11 @@ public class ResultRecordController extends AbstractController {
BeanUtils.copyProperties(dto, resultRecord);
List<ResultDetail> inserts = new ArrayList<>();
List<ResultDetail> updates = new ArrayList<>();
List<ResultScore> insertScores = new ArrayList<>();
List<ResultScore> updateScores = new ArrayList<>();
for (ResultRecortModelDto model:dto.getRecortModelDtos()
) {
int index = 0;
@ -497,13 +589,31 @@ public class ResultRecordController extends AbstractController {
inserts.add(resultDetail);
}
if(resultDetail.getIsDelete() == null || resultDetail.getIsDelete().intValue() == 0){
BigDecimal score = BigDecimal.ZERO;
for (ResultScoreDto scoreDto:detailDto.getScoreDtos()
) {
//计算得分
ResultScore resultScore = new ResultScore();
BeanUtils.copyProperties(scoreDto, resultScore);
if(scoreDto.getAcquireScore() != null){
score = score.add(scoreDto.getAcquireScore().multiply(scoreDto.getWeight()));
}
if(resultScore.getId() == null){
insertScores.add(resultScore);
}else{
updateScores.add(resultScore);
}
}
resultDetail.setAcquireScore(score);
weight = weight.add(resultDetail.getCheckWeight());
}
}
if(weight.compareTo(model.getWeight()) == 1){
return R.error(model.getName() + "的指标之和不能超过" + model.getWeight().multiply(BigDecimal.valueOf(100)) + "%");
}
}
//下面更新指标记录
if(inserts.size() > 0){
resultDetailService.saveBatch(inserts);
}
@ -511,6 +621,14 @@ public class ResultRecordController extends AbstractController {
resultDetailService.updateBatchById(updates);
}
//下面更新评分记录
if(insertScores.size() > 0){
resultScoreService.saveBatch(insertScores);
}
if(updateScores.size() > 0){
resultScoreService.updateBatchById(updateScores);
}
return R.ok();

View File

@ -94,4 +94,6 @@ public interface StaffDao extends BaseMapper<StaffEntity> {
List<StaffEntity> selectOnJobByIds(@Param("mIds") List<Long> mIds);
StaffSimpleInfo selectStaffSimpleInfo(@Param("staffId") Long staffId);
List<StaffEntity> selectNamesByIds(@Param("list") List<Long> sIds);
}

View File

@ -99,5 +99,7 @@ public interface StaffService extends IService<StaffEntity> {
List<StaffEntity> selectOnJobByIds(List<Long> mIds);
StaffSimpleInfo selectStaffSimpleInfo(Long staffId);
List<StaffEntity> selectNamesByIds(List<Long> sIds);
}

View File

@ -519,5 +519,10 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
return staffDao.selectStaffSimpleInfo(staffId);
}
@Override
public List<StaffEntity> selectNamesByIds(List<Long> sIds){
return staffDao.selectNamesByIds(sIds);
}
}

View File

@ -41,4 +41,6 @@ public interface FlowChartDetailRecordMapper extends BaseMapper<FlowChartDetailR
int insertFlowChartDetailRecords(@Param("list") List<FlowChartDetailRecord> inserts);
int updateCoverFlowChartDetailRecordByIds(@Param("list") List<FlowChartDetailRecord> updaes);
List<FlowChartDetailRecord> selectFlowChartDetailRecordsByFlowProcess(@Param("groupId") Long groupId, @Param("flowProcess") int flowProcess);
}

View File

@ -9,8 +9,12 @@ package com.lz.modules.flow.dao;
*/
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lz.modules.flow.entity.ResultScore;
import com.lz.modules.flow.model.ResultScoreDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ResultScoreMapper extends BaseMapper<ResultScore> {
@ -30,4 +34,7 @@ public interface ResultScoreMapper extends BaseMapper<ResultScore> {
int deleteResultScoreById(@Param("id")Long id);
List<ResultScore> selectResultScoresByDetailId(@Param("id") Long id);
List<ResultScore> selectResultScoresByDetailIdAndOrderByStaffIds(@Param("id") Long id, @Param("list") List<ResultScoreDto> scoreDtos);
}

View File

@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* <p>
@ -52,6 +53,9 @@ public class ResultDetailDto {
//优先级从大到小
@ApiModelProperty(value = "优先级,从小到大", name = "priority")
private Integer priority;
@ApiModelProperty(value = "评分详细", name = "scoreDtos")
private List<ResultScoreDto> scoreDtos;
/**
*
* @return

View File

@ -27,6 +27,14 @@ public class ResultScoreDto {
//审批人id
@ApiModelProperty(value = "审批人id", name = "approvalId")
private Long approvalId;
//审批人id
@ApiModelProperty(value = "审批人姓名", name = "approvalName")
private String approvalName;
//审批人id
@ApiModelProperty(value = "所占权重", name = "weight")
private BigDecimal weight;
/**
*
* @return

View File

@ -40,4 +40,6 @@ public interface FlowChartDetailRecordService extends IService<FlowChartDetailRe
int insertFlowChartDetailRecords(List<FlowChartDetailRecord> inserts);
int updateCoverFlowChartDetailRecordByIds(List<FlowChartDetailRecord> updaes);
List<FlowChartDetailRecord> selectFlowChartDetailRecordsByFlowProcess(Long groupId, int flowProcess);
}

View File

@ -2,6 +2,9 @@ package com.lz.modules.flow.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.modules.flow.entity.ResultScore;
import com.lz.modules.flow.model.ResultScoreDto;
import java.util.List;
/**
* <p>
@ -30,4 +33,7 @@ public interface ResultScoreService extends IService<ResultScore> {
int deleteResultScoreById(Long id);
List<ResultScore> selectResultScoresByDetailId(Long id);
List<ResultScore> selectResultScoresByDetailIdAndOrderByStaffIds(Long id, List<ResultScoreDto> scoreDtos);
}

View File

@ -81,6 +81,11 @@ public class FlowChartDetailRecordServiceImpl extends ServiceImpl<FlowChartDetai
return flowChartDetailRecordMapper.updateCoverFlowChartDetailRecordByIds(updaes);
}
@Override
public List<FlowChartDetailRecord> selectFlowChartDetailRecordsByFlowProcess(Long groupId, int flowProcess){
return flowChartDetailRecordMapper.selectFlowChartDetailRecordsByFlowProcess(groupId, flowProcess);
}

View File

@ -318,7 +318,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
List<EvaluationStartStaff> evaluationStartStaffs = new ArrayList<>();
//下面初始化管理人员对应关系
/*//下面初始化管理人员对应关系
for (StaffEntity entity:staffManagers
) {
EvaluationStartStaff evaluationStartStaff = new EvaluationStartStaff();
@ -329,7 +329,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
evaluationStartStaff.setType(CheckStaffType.MANAGER.getCode());
evaluationStartStaffs.add(evaluationStartStaff);
}
}*/
//下面初始化参与人员

View File

@ -3,10 +3,13 @@ package com.lz.modules.flow.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.modules.flow.dao.ResultScoreMapper;
import com.lz.modules.flow.entity.ResultScore;
import com.lz.modules.flow.model.ResultScoreDto;
import com.lz.modules.flow.service.ResultScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 业绩详情评分表 服务类
@ -58,6 +61,16 @@ public class ResultScoreServiceImpl extends ServiceImpl<ResultScoreMapper, Resul
return resultScoreMapper.deleteResultScoreById(id);
}
@Override
public List<ResultScore> selectResultScoresByDetailId(Long id){
return resultScoreMapper.selectResultScoresByDetailId(id);
}
@Override
public List<ResultScore> selectResultScoresByDetailIdAndOrderByStaffIds(Long id, List<ResultScoreDto> scoreDtos){
return resultScoreMapper.selectResultScoresByDetailIdAndOrderByStaffIds(id, scoreDtos);
}
}

View File

@ -109,9 +109,7 @@
update lz_flow_chart_detail_record set is_delete = 1 where id=#{id} limit 1
</update>
<select id="selectFlowChartDetailRecordByGroupIdAndChartId" resultType="FlowChartDetailRecord" >
select * from lz_flow_chart_detail_record where evaluation_group_id=#{groupId} and chart_id = #{chartId} and is_delete = 0 order by step_index asc
</select>
<select id="selectFlowChartDetailRecordByGroupId" resultType="FlowChartDetailRecord" >
select * from lz_flow_chart_detail_record where evaluation_group_id=#{groupId} and is_delete = 0 order by step_index asc
@ -169,5 +167,10 @@
</update>
<select id="selectFlowChartDetailRecordsByFlowProcess" resultType="FlowChartDetailRecord" >
select * from lz_flow_chart_detail_record where evaluation_group_id=(select copy_id from lz_evaluation_group where id = #{groupId})
and chart_id = (select id from lz_flow_chart where flow_process = #{flowProcess}) and is_delete = 0 order by step_index asc
</select>
</mapper>

View File

@ -79,5 +79,17 @@
update lz_result_score set is_delete = 1 where id=#{id} limit 1
</update>
<select id="selectResultScoresByDetailId" resultType="ResultScore" >
select * from lz_result_score where detail_id=#{id} and is_delete = 0
</select>
<select id="selectResultScoresByDetailIdAndOrderByStaffIds" resultType="ResultScore" >
select * from lz_result_score where detail_id=#{id} and is_delete = 0 order by field(approval_id,
<foreach collection="list" item="item" separator=",">
#{item.approvalId}
</foreach>
)
</select>
</mapper>

View File

@ -526,4 +526,16 @@
) as staffinfo left join lz_departments_staff_relate relate on staffinfo.id = relate.staff_id
) as info left join lz_departments dep on info.department_id = dep.department_id GROUP BY info.id
</select>
<select id="selectNamesByIds" resultType="com.lz.modules.app.entity.StaffEntity">
select * from lz_staff where id in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
) order by field(id,
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</select>
</mapper>