This commit is contained in:
wulin 2020-08-19 19:57:55 +08:00
commit 777b8c8a10
8 changed files with 275 additions and 112 deletions

View File

@ -12,6 +12,7 @@ import com.lz.modules.app.service.DepartmentsStaffRelateService;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.entity.RecordAuth;
import com.lz.modules.flow.model.Auth;
import com.lz.modules.flow.req.ResultDetailReq;
import com.lz.modules.flow.service.RecordAuthService;
import com.lz.modules.sys.controller.AbstractController;
import com.lz.modules.sys.entity.SysUserEntity;
@ -19,7 +20,6 @@ import com.lz.modules.sys.entity.app.ResultDetail;
import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ResultDetailService;
import com.lz.modules.sys.service.app.ResultRecordService;
import io.jsonwebtoken.lang.Collections;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
@ -66,6 +66,7 @@ public class ResultRecordController extends AbstractController {
/**
* 列表
*/
@ -88,37 +89,76 @@ public class ResultRecordController extends AbstractController {
@RequestMapping("/getStaffResultDetail")
public R getStaffResultDetail(ResultRecordReq req) {
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
StaffEntity staffEntity = staffService.getById(resultRecord != null ? resultRecord.getStaffId() : getUserId());
List<DepartmentsStaffRelateEntity> departmentsStaffRelateEntities = departmentsStaffRelateService.selectByStaffIds(Arrays.asList(staffEntity.getId()));
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateEntities.get(0);
StaffDepartmentDto departmentDto = departmentsService.selectStaffAllDepartments(departmentsStaffRelateEntity.getDepartmentId());
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(req.getRecordResultId());
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年MM月dd");
List<ResultDetailResp> list = new ArrayList<>();
int firstRowspan = 0;
int secondRowspan = 0;
int threeRowspan = 0;
int fourRowspan = 0;
int fiveRowspan = 0;
int recordType = req.getRecordType();
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
StaffEntity staffEntity = staffService.getById(resultRecord != null ? resultRecord.getStaffId() : getUserId());
List<DepartmentsStaffRelateEntity> departmentsStaffRelateEntities = departmentsStaffRelateService.selectByStaffIds(Arrays.asList(staffEntity.getId()));
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateEntities.get(0);
StaffDepartmentDto departmentDto = departmentsService.selectStaffAllDepartments(departmentsStaffRelateEntity.getDepartmentId());
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM");
List<ResultDetailResp> list = new ArrayList<>();
Long recordResultId = req.getRecordResultId();
// 获取权限
List<RecordAuth> map = new ArrayList<>();
Long authId = 0l;
if(req.getType() == 1){ //目标新增
map = recordAuthService.selectAuthInfo(7l);
authId = 7l;
}else if(req.getType() == 2){ //业绩编辑
map = recordAuthService.selectAuthInfo(8l);
authId = 8l;
}
Auth auth = new Auth();
List<RecordAuth> listAuth = new ArrayList<>();
if (req.getRecordType() == 1) { //新增目标
listAuth = recordAuthService.selectAuthInfo(7l);
auth = getAuth(listAuth);
} else if (req.getRecordType() == 2) { //新增业绩
listAuth = recordAuthService.selectAuthInfo(8l);
auth = getAuth(listAuth);
auth.setWenHuaEdit(1);
ResultRecord resultRecordOld = resultRecordService.selectResultRecordByStaffId(getUserId());
ResultRecord resultRecordNew = null;
if (resultRecordOld != null) {
Long recordId = resultRecordOld.getId();
resultRecordOld.setId(null);
resultRecordOld.setInitRoleId(8l);
resultRecordService.insertResultRecord(resultRecordOld);
resultRecordNew = resultRecordOld;
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(recordId);
if (CollectionUtils.isNotEmpty(resultDetails)) {
// 保存业绩相关
for (ResultDetail resultDetail : resultDetails) {
resultDetail.setRecordId(resultRecordNew.getId());
resultDetail.setId(null);
resultDetailService.insertResultDetail(resultDetail);
}
}
Auth auth = getAuth(map);
if (!Collections.isEmpty(resultDetails)) {
} else {
resultRecordNew = createResultRecord(2);
}
//保存文件价值观
recordType =3;
insertWenHuaJiaZhiGua("做人:相信、包容、担当", resultRecordNew.getId(), getUserId());
insertWenHuaJiaZhiGua("做事:用户第一、求真、极致", resultRecordNew.getId(), getUserId());
recordResultId = resultRecordNew.getId();
} else if (resultRecord != null) {
listAuth = recordAuthService.selectAuthInfo(resultRecord.getInitRoleId());
auth = getAuth(listAuth);
}
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(recordResultId);
if (CollectionUtils.isNotEmpty(resultDetails)) {
Map<Integer, Long> details = resultDetails.stream().collect(Collectors.groupingBy(ResultDetail::getType, Collectors.counting()));
int type1 = NumberUtil.objToIntDefault(details.get(new Integer(1)), 0);
int type2 = NumberUtil.objToIntDefault(details.get(new Integer(2)), 0);
int tempType1 = NumberUtil.objToIntDefault(details.get(new Integer(1)), 0);
int tempType2 = NumberUtil.objToIntDefault(details.get(new Integer(2)), 0);
int type1 = tempType1;
int type2 = tempType2;
if (tempType1 == 0) {
type1 = 1 ;
list.add(getYeJi());
list.add(getYeJiKaoHe());
}
if(tempType2 == 0 ){
type2 = 2;
}
firstRowspan = type1;
secondRowspan = type1 + 1;
threeRowspan = type1 + 1 + type2;
@ -135,21 +175,20 @@ public class ResultRecordController extends AbstractController {
} else if (resultDetail.getType() == 2) {
resp.setCheckRange("文化价值观");
}
if (count == type1 || count == type1 + type2) {
if (count == type1) {
resp.setIsAdd(1);
}
if (count == type1 + 1) {
ResultDetailResp respHeader = new ResultDetailResp();
respHeader.setKeyResult("业务考核结果");
respHeader.setCheckWeight(new BigDecimal(0.7));
respHeader.setSuperScore("/");
respHeader.setAcquireScore(new BigDecimal(0));
respHeader.setScoreComment("/");
respHeader.setIsAdd(-1);
list.add(respHeader);
resp.setIsEdit(1);
if (count == type1 + 1 && tempType1 != 0) {
list.add(getYeJiKaoHe());
}
list.add(resp);
}
if (tempType2 == 0) {
list.add(getYeJiKaoHe());
list.add(getWenHuaJiaZhiGua1(auth));
list.add(getWenHuaJiaZhiGua2(auth));
}
}else{
int type1 = 1;
int type2 = 2;
@ -159,58 +198,14 @@ public class ResultRecordController extends AbstractController {
fourRowspan = type1 + 1 + type2 + 1;
fiveRowspan = type1 + 1 + type2 + 2;
ResultDetailResp result = new ResultDetailResp();
result.setCheckRange("业绩");
result.setCheckWeight(new BigDecimal(0.7));
result.setIsAdd(1);
result.setIsEdit(1);
list.add(result);
ResultDetailResp respHeader = new ResultDetailResp();
respHeader.setKeyResult("业务考核结果");
respHeader.setCheckWeight(new BigDecimal(0.7));
respHeader.setSuperScore("/");
respHeader.setAcquireScore(new BigDecimal(0));
respHeader.setScoreComment("/");
respHeader.setIsAdd(-1);
list.add(respHeader);
ResultDetailResp wenhua1 = new ResultDetailResp();
wenhua1.setCheckRange("文化价值观");
wenhua1.setTarget("做人:相信、包容、担当");
wenhua1.setCheckWeight(new BigDecimal(0.15));
list.add(wenhua1);
ResultDetailResp wenhua2 = new ResultDetailResp();
wenhua2.setCheckRange("文化价值观");
wenhua2.setTarget("做人:相信、包容、担当");
wenhua2.setCheckWeight(new BigDecimal(0.15));
list.add(wenhua2);
list.add(getYeJi());
list.add(getYeJiKaoHe());
list.add(getWenHuaJiaZhiGua1(auth));
list.add(getWenHuaJiaZhiGua2(auth));
}
ResultDetailResp tail1 = new ResultDetailResp();
tail1.setKeyResult("文化价值观考核结果");
tail1.setCheckWeight(new BigDecimal(0.3));
tail1.setSuperScore("/");
tail1.setAcquireScore(new BigDecimal(0));
tail1.setScoreComment("/");
tail1.setIsAdd(-1);
ResultDetailResp tail2 = new ResultDetailResp();
tail2.setCheckRange("文化价值观考核结果");
tail2.setAcquireScore(new BigDecimal(0));
tail2.setScoreComment("/");
tail2.setIsAdd(-1);
ResultDetailResp tail3 = new ResultDetailResp();
tail3.setCheckRange("最终绩效考核结果等级");
tail3.setAcquireScore(new BigDecimal(3.25));
tail3.setScoreComment("/");
tail3.setIsAdd(-1);
list.add(tail1);
list.add(tail2);
list.add(tail3);
list.add(getWenHuaJiaZhiGuaResult1());
list.add(getWenHuaJiaZhiGuaResult2());
list.add(getLastResult());
return R.ok()
.put("staffName", staffEntity.getName())
.put("department1", departmentDto.getDepartment1())
@ -223,10 +218,91 @@ public class ResultRecordController extends AbstractController {
.put("fourRowspan", fourRowspan)
.put("fiveRowspan", fiveRowspan)
.put("list", list)
.put("auth",auth)
.put("authId",authId);
.put("auth", auth)
.put("recordType", recordType)
.put("recordResultId", recordResultId);
}
public void insertWenHuaJiaZhiGua(String target, Long recordId, Long staffId) {
ResultDetail wenhua1 = new ResultDetail();
wenhua1.setTarget(target);
wenhua1.setType(2);
wenhua1.setCheckWeight(new BigDecimal(0.15));
wenhua1.setStaffId(staffId);
wenhua1.setRecordId(recordId);
resultDetailService.insertResultDetail(wenhua1);
}
public ResultDetailResp getYeJi() {
ResultDetailResp result = new ResultDetailResp();
result.setCheckRange("业绩");
result.setCheckWeight(new BigDecimal(0.7));
result.setIsAdd(1);
result.setIsEdit(1);
result.setType(1);
return result;
}
public ResultDetailResp getYeJiKaoHe(){
ResultDetailResp respHeader = new ResultDetailResp();
respHeader.setKeyResult("业务考核结果");
respHeader.setCheckWeight(new BigDecimal(0.7));
respHeader.setSuperScore("/");
respHeader.setAcquireScore(new BigDecimal(0));
respHeader.setScoreComment("/");
respHeader.setIsAdd(-1);
return respHeader;
}
public ResultDetailResp getWenHuaJiaZhiGua1(Auth auth) {
ResultDetailResp wenhua1 = new ResultDetailResp();
wenhua1.setCheckRange("文化价值观");
wenhua1.setTarget("做人:相信、包容、担当");
wenhua1.setType(2);
wenhua1.setIsEdit(auth.getWenHuaEdit());
wenhua1.setCheckWeight(new BigDecimal(0.15));
return wenhua1;
}
public ResultDetailResp getWenHuaJiaZhiGua2(Auth auth) {
ResultDetailResp wenhua2 = new ResultDetailResp();
wenhua2.setCheckRange("文化价值观");
wenhua2.setTarget("做事:用户第一、求真、极致");
wenhua2.setType(2);
wenhua2.setIsEdit(auth.getWenHuaEdit());
wenhua2.setCheckWeight(new BigDecimal(0.15));
return wenhua2;
}
public ResultDetailResp getWenHuaJiaZhiGuaResult1(){
ResultDetailResp tail1 = new ResultDetailResp();
tail1.setKeyResult("文化价值观考核结果");
tail1.setCheckWeight(new BigDecimal(0.3));
tail1.setSuperScore("/");
tail1.setAcquireScore(new BigDecimal(0));
tail1.setScoreComment("/");
tail1.setIsAdd(-1);
return tail1;
}
public ResultDetailResp getWenHuaJiaZhiGuaResult2(){
ResultDetailResp tail2 = new ResultDetailResp();
tail2.setCheckRange("文化价值观考核结果");
tail2.setAcquireScore(new BigDecimal(0));
tail2.setScoreComment("/");
tail2.setIsAdd(-1);
return tail2;
}
public ResultDetailResp getLastResult(){
ResultDetailResp tail3 = new ResultDetailResp();
tail3.setCheckRange("最终绩效考核结果等级");
tail3.setAcquireScore(new BigDecimal(3.25));
tail3.setScoreComment("/");
tail3.setIsAdd(-1);
return tail3;
}
public Auth getAuth(List<RecordAuth> auths) {
Map<String, Integer> map = new HashMap<>();
@ -234,19 +310,20 @@ public class ResultRecordController extends AbstractController {
map = auths.stream().collect(Collectors.toMap(RecordAuth::getIdentity, RecordAuth::getStatus));
}
Auth auth = new Auth();
auth.setAdd(NumberUtil.objToIntDefault(map.get("add"),0));
auth.setApprovel(NumberUtil.objToIntDefault(map.get("approvel"),0));
auth.setCheckResult(NumberUtil.objToIntDefault(map.get("checkResult"),0));
auth.setCheckWeight(NumberUtil.objToIntDefault(map.get("checkWeight"),0));
auth.setCommit(NumberUtil.objToIntDefault(map.get("commit"),0));
auth.setConfirmCommit(NumberUtil.objToIntDefault(map.get("confirmCommit"),0));
auth.setKeyResult(NumberUtil.objToIntDefault(map.get("keyResult"),0));
auth.setPriority(NumberUtil.objToIntDefault(map.get("priority"),0));
auth.setReject(NumberUtil.objToIntDefault(map.get("reject"),0));
auth.setScoreComment(NumberUtil.objToIntDefault(map.get("scoreComment"),0));
auth.setSuperScore(NumberUtil.objToIntDefault(map.get("superScore"),0));
auth.setTarget(NumberUtil.objToIntDefault(map.get("target"),0));
auth.setEdit(NumberUtil.objToIntDefault(map.get("edit"),0));
auth.setAdd(NumberUtil.objToIntDefault(map.get("add"), 0));
auth.setApprovel(NumberUtil.objToIntDefault(map.get("approvel"), 0));
auth.setCheckResult(NumberUtil.objToIntDefault(map.get("checkResult"), 0));
auth.setCheckWeight(NumberUtil.objToIntDefault(map.get("checkWeight"), 0));
auth.setCommit(NumberUtil.objToIntDefault(map.get("commit"), 0));
auth.setConfirmCommit(NumberUtil.objToIntDefault(map.get("confirmCommit"), 0));
auth.setKeyResult(NumberUtil.objToIntDefault(map.get("keyResult"), 0));
auth.setPriority(NumberUtil.objToIntDefault(map.get("priority"), 0));
auth.setReject(NumberUtil.objToIntDefault(map.get("reject"), 0));
auth.setScoreComment(NumberUtil.objToIntDefault(map.get("scoreComment"), 0));
auth.setSuperScore(NumberUtil.objToIntDefault(map.get("superScore"), 0));
auth.setTarget(NumberUtil.objToIntDefault(map.get("target"), 0));
auth.setEdit(NumberUtil.objToIntDefault(map.get("edit"), 0));
auth.setAcquireScore(NumberUtil.objToIntDefault(map.get("acquireScore"), 0));
return auth;
}
@ -322,24 +399,49 @@ public class ResultRecordController extends AbstractController {
* 信息
*/
@RequestMapping("/detailAddOrUpdate")
public R detailAddOrUpdate(ResultDetail resultDetail) {
ResultDetail old = resultDetailService.selectResultDetailById(resultDetail.getId());
public R detailAddOrUpdate(ResultDetailReq req) {
Long recordId = 0l;
ResultDetail old = resultDetailService.selectResultDetailById(req.getId());
if (old != null) {
com.lz.modules.app.utils.BeanUtils.copyProperty(old, resultDetail, false);
old.setKeyResult(StringUtil.decodeBase64(resultDetail.getKeyResult()));
old.setCheckResult(StringUtil.decodeBase64(resultDetail.getCheckResult()));
if (old.getType() == 2) {
old.setTarget(old.getKeyResult());
}
com.lz.modules.app.utils.BeanUtils.copyProperty(old, req, false);
old.setKeyResult(StringUtil.decodeBase64(req.getKeyResult()));
old.setCheckResult(StringUtil.decodeBase64(req.getCheckResult()));
old.setScoreComment(StringUtil.decodeBase64(req.getScoreComment()));
recordId = old.getRecordId();
resultDetailService.updateResultDetailById(old);
}else{
resultDetail.setKeyResult(StringUtil.decodeBase64(resultDetail.getKeyResult()));
resultDetail.setCheckResult(StringUtil.decodeBase64(resultDetail.getCheckResult()));
} else {
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordId());
if (resultRecord == null) {
createResultRecord(req.getRecordType());
}
recordId = resultRecord.getId();
req.setKeyResult(StringUtil.decodeBase64(req.getKeyResult()));
req.setCheckResult(StringUtil.decodeBase64(req.getCheckResult()));
req.setScoreComment(StringUtil.decodeBase64(req.getScoreComment()));
ResultDetail resultDetail = new ResultDetail();
BeanUtils.copyProperties(req, resultDetail);
resultDetail.setRecordId(resultRecord.getId());
resultDetail.setStaffId(getUserId());
resultDetailService.insertResultDetail(resultDetail);
}
return R.ok("保存成功");
return R.ok("保存成功").put("recordId", recordId);
}
public ResultRecord createResultRecord(int type ){
ResultRecord resultRecord = new ResultRecord();
resultRecord.setMonthTime(new Date());
resultRecord.setCurrentFlowStaffId(getUserId());
if (type == 1) {
resultRecord.setInitRoleId(7l);
} else {
resultRecord.setInitRoleId(8l);
}
resultRecord.setStaffId(getUserId());
resultRecord.setStatus(0);
resultRecord.setType(type);
resultRecordService.insertResultRecord(resultRecord);
return resultRecord;
}
/**
* 保存
*/

View File

@ -30,4 +30,5 @@ public class ResultRecordReq {
private Long id = new Long (0);
private Integer isSelf = 1;
private Long staffId;
private Integer recordType;
}

View File

@ -17,5 +17,9 @@ public class Auth {
private int scoreComment;
private int superScore;
private int target;
private int acquireScore;
private int wenhuaAdd;
private int wenHuaEdit;
}

View File

@ -0,0 +1,42 @@
package com.lz.modules.flow.req;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class ResultDetailReq {
private Long id;
//是否删除状态1删除0有效
private Integer isDelete;
//创建时间
private Date gmtCreate;
//最后修改时间
private Date gmtModified;
//1业绩2文化价值观
private Integer type;
//目标
private String target;
//关键结果
private String keyResult;
//考核权重
private BigDecimal checkWeight;
//考核结果
private String checkResult;
//直属上级评分
private String superScore;
//得分
private BigDecimal acquireScore;
//评分说明
private String scoreComment;
//记录id
private Long recordId;
//用户id
private Long staffId;
//优先级从大到小
private Integer priority;
private Integer recordType;
}

View File

@ -41,4 +41,6 @@ public interface ResultRecordMapper extends BaseMapper<ResultRecord> {
List<ResultRecord> selectByConditionTest(ResultRecordReq req);
ResultRecord selectResultRecordByStaffId(@Param("staffId") Long staffId);
}

View File

@ -39,4 +39,6 @@ public interface ResultRecordService extends IService<ResultRecord> {
void deleteBatchIds(List<Long> asList);
ResultRecord selectResultRecordByStaffId(Long userId);
}

View File

@ -199,5 +199,11 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
}
@Override
public ResultRecord selectResultRecordByStaffId(Long staffId) {
return resultRecordMapper.selectResultRecordByStaffId(staffId);
}
}

View File

@ -151,5 +151,9 @@
</select>
<select id="selectResultRecordByStaffId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
select * from lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = 1 order by id desc limit 1
</select>
</mapper>