This commit is contained in:
wulin 2020-08-25 14:24:04 +08:00
commit 5ced3a2b9f
12 changed files with 180 additions and 36 deletions

View File

@ -80,6 +80,15 @@ public class BigDecimalUtil {
return bigDecimal;
}
public static BigDecimal setScale(BigDecimal bigDecimal,int num){
if(bigDecimal == null){
bigDecimal = BigDecimal.ZERO;
}
bigDecimal = bigDecimal.setScale(num,BigDecimal.ROUND_HALF_UP);
return bigDecimal;
}
public static double sub(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));

View File

@ -89,16 +89,52 @@ public class ResultRecordController extends AbstractController {
@RequestMapping("/list")
@RequiresPermissions("user:lzresultrecord:list")
public R list(ResultRecordReq req) {
List<DepartmentsDto> departmentList2 = new ArrayList<>();
List<DepartmentsDto> departmentList3 = new ArrayList<>();
List<DepartmentsDto> departmentList1 = departmentsService.selectByParentDepartmentId("1");
String department1 = "";
String department2 = "";
String department3 = "";
SysUserEntity user = getUser();
if(req.getIsSelf() == 1){
if (req.getIsSelf() == 1) {
req.setStaffId(user.getUserId());
}else{
DepartmentsStaffRelateEntity relateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(getUserId());
Map<String, String> map = departmentsService.selectUserAllDepartmentInFo(relateEntity.getDepartmentId());
int i = 0;
for (Map.Entry<String, String> entry : map.entrySet()) {
i++;
}
i = i / 2;
if (i == 3) { // 表示有三级部门
departmentList2 = departmentsService.selectByParentDepartmentId(map.get("dd3"));
departmentList3 = departmentsService.selectByParentDepartmentId(map.get("dd2"));
department1 = map.get("dd3");
department2 = map.get("dd2");
department3 = map.get("dd1");
req.setDepartment3(map.get("dd1"));
} else if (i == 2) {
departmentList2 = departmentsService.selectByParentDepartmentId(map.get("dd2"));
department2 = map.get("dd1");
department1 = map.get("dd2");
req.setDepartment2(map.get("dd1"));
} else if (i == 1) {
department1 = map.get("dd1");
req.setDepartment1(map.get("dd1"));
}
}
PageUtils page = lzResultRecordService.queryPage(req, user);
List<DepartmentsDto> departmentList1 = departmentsService.selectByParentDepartmentId("0");
return R.ok().put("page", page)
.put("departmentList1", departmentList1);
.put("departmentList1", departmentList1)
.put("departmentList2", departmentList2)
.put("departmentList3", departmentList3)
.put("department1",department1)
.put("department2",department2)
.put("department3",department3);
}
@RequestMapping("/departmentQuery")
public R departmentQuery(ResultRecordReq req) {
List<DepartmentsDto> departmentList1 = departmentsService.selectByParentDepartmentId(req.getDepartmentId());
@ -146,6 +182,8 @@ public class ResultRecordController extends AbstractController {
}
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(resultRecord.getId());
BigDecimal sumWenHuaJiaZhiGuan = BigDecimal.ZERO;
BigDecimal sumYeJi = BigDecimal.ZERO;
if (CollectionUtils.isNotEmpty(resultDetails)) {
Map<Integer, Long> details = resultDetails.stream().collect(Collectors.groupingBy(ResultDetail::getType, Collectors.counting()));
int tempType1 = NumberUtil.objToIntDefault(details.get(new Integer(1)), 0);
@ -155,7 +193,7 @@ public class ResultRecordController extends AbstractController {
if (tempType1 == 0) {
yeJiCheckNum = 1;
list.add(resultDetailService.getYeJi());
list.add(resultDetailService.getYeJiKaoHe());
list.add(resultDetailService.getYeJiKaoHe(BigDecimal.ZERO));
}
int count = 0;
for (ResultDetail resultDetail : resultDetails) {
@ -171,14 +209,22 @@ public class ResultRecordController extends AbstractController {
resp.setIsAdd(1);
}
resp.setIsEdit(1);
BigDecimal checkWeight = NumberUtil.objToBigDecimalDefault(resultDetail.getCheckWeight(), BigDecimal.ZERO);
BigDecimal acquireScore = NumberUtil.objToBigDecimalDefault(resultDetail.getAcquireScore(), BigDecimal.ZERO);
BigDecimal tempSum = checkWeight.multiply(acquireScore);
if (resultDetail.getType().equals(1)) {
sumYeJi = sumYeJi.add(tempSum);
} else {
sumWenHuaJiaZhiGuan = sumWenHuaJiaZhiGuan.add(tempSum);
}
if (count == yeJiCheckNum + 1 && tempType1 != 0) {
list.add(resultDetailService.getYeJiKaoHe());
list.add(resultDetailService.getYeJiKaoHe(BigDecimalUtil.setScale(sumYeJi, 3)));
}
list.add(resp);
}
if (tempType2 == 0) {
wenHuaJiaZhiGuanNum = 2;
list.add(resultDetailService.getYeJiKaoHe());
list.add(resultDetailService.getYeJiKaoHe(BigDecimal.ZERO));
list.add(resultDetailService.getWenHuaJiaZhiGua1(auth));
list.add(resultDetailService.getWenHuaJiaZhiGua2(auth));
}
@ -186,13 +232,13 @@ public class ResultRecordController extends AbstractController {
yeJiCheckNum = 1;
wenHuaJiaZhiGuanNum = 2;
list.add(resultDetailService.getYeJi());
list.add(resultDetailService.getYeJiKaoHe());
list.add(resultDetailService.getYeJiKaoHe(BigDecimal.ZERO));
list.add(resultDetailService.getWenHuaJiaZhiGua1(auth));
list.add(resultDetailService.getWenHuaJiaZhiGua2(auth));
}
list.add(resultDetailService.getWenHuaJiaZhiGuaResult1());
list.add(resultDetailService.getWenHuaJiaZhiGuaResult1(sumWenHuaJiaZhiGuan));
list.add(resultDetailService.getWenHuaJiaZhiGuaResult2());
list.add(resultDetailService.getLastResult());
list.add(resultDetailService.getLastResult(resultRecord.getLastScore()));
List<ResultComment> comments = resultCommentService.selectByRecordId(resultRecord.getId());
if (CollectionUtils.isNotEmpty(comments)) {
@ -427,6 +473,19 @@ public class ResultRecordController extends AbstractController {
resultDetail.setStaffId(resultRecord.getStaffId());
resultDetailService.insertResultDetail(resultDetail);
}
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(resultRecord.getId());
if (CollectionUtils.isNotEmpty(resultDetails)) {
BigDecimal sum = BigDecimal.ZERO;
for (ResultDetail resultDetail : resultDetails) {
BigDecimal checkWeight = NumberUtil.objToBigDecimalDefault(resultDetail.getCheckWeight(), BigDecimal.ZERO);
BigDecimal acquireScore = NumberUtil.objToBigDecimalDefault(resultDetail.getAcquireScore(), BigDecimal.ZERO);
sum = sum.add(checkWeight.multiply(acquireScore));
}
sum = BigDecimalUtil.setScale(sum, 3);
resultRecord.setLastScore(sum);
resultRecord.setAllScore(sum);
resultRecordService.updateResultRecordById(resultRecord);
}
return R.ok("保存成功").put("recordId", resultRecord.getId());
}
@ -461,4 +520,26 @@ public class ResultRecordController extends AbstractController {
return R.ok();
}
public static void main(String[] args) {
List<DepartmentsDto> departmentList1 = new ArrayList<>();
DepartmentsDto departmentsDto1 = new DepartmentsDto();
departmentsDto1.setDepartmentId("1");
DepartmentsDto departmentsDto2 = new DepartmentsDto();
departmentsDto2.setDepartmentId("2");
DepartmentsDto departmentsDto3 = new DepartmentsDto();
departmentsDto3.setDepartmentId("3");
departmentList1.add(departmentsDto1);
departmentList1.add(departmentsDto2);
departmentList1.add(departmentsDto3);
String compare = "3";
departmentList1 = departmentList1.stream().sorted((p1, p2) -> p1.getDepartmentId().equals(compare) ? 1 : p2.getDepartmentId().equals(compare) ? 1 : 0).collect(Collectors.toList());
for (DepartmentsDto departmentsDto : departmentList1) {
System.out.println(departmentsDto.getDepartmentId());
}
}
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
/**
@ -14,7 +15,7 @@ import java.util.List;
* @date 2020-04-30 16:59:50
*/
@Data
public class DepartmentsDto implements Serializable {
public class DepartmentsDto implements Serializable{
private static final long serialVersionUID = 1L;
/**

View File

@ -40,5 +40,9 @@ public interface DepartmentsService extends IService<DepartmentsEntity> {
void updateDepartmentInfo(DepartmentInfosBo departmentInfosBo);
Map<String,String> selectUserAllDepartmentIds(String departmentId);
Map<String,String> selectUserAllDepartmentInFo(String departmentId);
}

View File

@ -167,4 +167,34 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
}
@Override
public Map<String, String> selectUserAllDepartmentInFo(String departmentId) {
DepartmentInfos departmentInfos = departmentsDao.selectUserAllDepartmentIds(departmentId);
Map<String, String> map = new HashMap<>();
if (StringUtil.isNotBlank(departmentInfos.getDd1())) {
map.put("dd1", departmentInfos.getDd1());
map.put("dn1", departmentInfos.getDn1());
}
if (StringUtil.isNotBlank(departmentInfos.getDd2())) {
map.put("dd2", departmentInfos.getDd2());
map.put("dn2", departmentInfos.getDn2());
}
if (StringUtil.isNotBlank(departmentInfos.getDd3())) {
map.put("dd3", departmentInfos.getDd3());
map.put("dn3", departmentInfos.getDn3());
}
if (StringUtil.isNotBlank(departmentInfos.getDd4())) {
map.put("dd4", departmentInfos.getDd4());
map.put("dn4", departmentInfos.getDn4());
}
if (StringUtil.isNotBlank(departmentInfos.getDd5())) {
map.put("dd5", departmentInfos.getDd5());
map.put("dn5", departmentInfos.getDn5());
}
return map;
}
}

View File

@ -132,10 +132,12 @@ public class RecordAuthServiceImpl extends ServiceImpl<RecordAuthMapper, RecordA
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffId);
if (departmentsStaffRelateEntity.getIsLeader().equals(1)) {//如果是部门领导
DepartmentsEntity department = departmentsService.selectByDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
DepartmentsStaffRelateEntity parentRelation = departmentsStaffRelateService.selectDepartmentByDepartmentId(department.getDepartmentId());
if(parentRelation !=null){
StaffEntity staffEntity = staffService.selectStaffById(parentRelation.getStaffId());
return staffEntity.getName();
if (department != null) {
DepartmentsStaffRelateEntity parentRelation = departmentsStaffRelateService.selectDepartmentByDepartmentId(department.getDepartmentParentId());
if (parentRelation != null) {
StaffEntity staffEntity = staffService.selectStaffById(parentRelation.getStaffId());
return staffEntity.getName();
}
}
return "";
} else {

View File

@ -28,7 +28,7 @@ public class ResultRecord implements java.io.Serializable {
private Date gmtModified;
//月份
private Date monthTime;
//0.新建1 提交审批中2 拒绝 , 3侍提交
//0.新建1 审批中2 己审批 , 3 侍提交 4 审批通过,5 驳回
private Integer status;
//最后得分
private BigDecimal lastScore;

View File

@ -1,10 +1,12 @@
package com.lz.modules.sys.service.app;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.common.utils.BigDecimalUtil;
import com.lz.modules.app.resp.ResultDetailResp;
import com.lz.modules.flow.model.Auth;
import com.lz.modules.sys.entity.app.ResultDetail;
import java.math.BigDecimal;
import java.util.List;
/**
@ -40,17 +42,17 @@ public interface ResultDetailService extends IService<ResultDetail> {
ResultDetailResp getYeJi();
ResultDetailResp getYeJiKaoHe();
ResultDetailResp getYeJiKaoHe(BigDecimal acquireScore);
ResultDetailResp getWenHuaJiaZhiGua2(Auth auth);
ResultDetailResp getWenHuaJiaZhiGua1(Auth auth);
ResultDetailResp getWenHuaJiaZhiGuaResult1();
ResultDetailResp getWenHuaJiaZhiGuaResult1(BigDecimal bigDecimal);
ResultDetailResp getWenHuaJiaZhiGuaResult2();
ResultDetailResp getLastResult();
ResultDetailResp getLastResult(BigDecimal bigDecimal);
void insertWenHuaJiaZhiGua(String s, Long id, Long userId);

View File

@ -2,6 +2,7 @@ package com.lz.modules.sys.service.app.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.common.utils.BigDecimalUtil;
import com.lz.modules.app.resp.ResultDetailResp;
import com.lz.modules.flow.model.Auth;
import com.lz.modules.flow.model.StaffRoleDto;
@ -87,12 +88,12 @@ public class ResultDetailServiceImpl extends ServiceImpl<ResultDetailMapper, Res
return result;
}
public ResultDetailResp getYeJiKaoHe() {
public ResultDetailResp getYeJiKaoHe(BigDecimal acquireScore) {
ResultDetailResp respHeader = new ResultDetailResp();
respHeader.setKeyResult("业务考核结果");
respHeader.setCheckWeight(new BigDecimal(0.7));
respHeader.setSuperScore("/");
respHeader.setAcquireScore(new BigDecimal(0));
respHeader.setAcquireScore(acquireScore);
respHeader.setScoreComment("/");
respHeader.setIsAdd(-1);
return respHeader;
@ -118,31 +119,33 @@ public class ResultDetailServiceImpl extends ServiceImpl<ResultDetailMapper, Res
return wenhua2;
}
public ResultDetailResp getWenHuaJiaZhiGuaResult1() {
public ResultDetailResp getWenHuaJiaZhiGuaResult1(BigDecimal sum) {
ResultDetailResp tail1 = new ResultDetailResp();
tail1.setKeyResult("文化价值观考核结果");
tail1.setCheckWeight(new BigDecimal(0.3));
tail1.setSuperScore("/");
tail1.setAcquireScore(new BigDecimal(0));
tail1.setAcquireScore(BigDecimalUtil.setScale(sum, 3));
tail1.setScoreComment("/");
tail1.setIsAdd(-1);
return tail1;
}
public ResultDetailResp getWenHuaJiaZhiGuaResult2() {
ResultDetailResp tail2 = new ResultDetailResp();
tail2.setCheckRange("文化价值观考核结果");
tail2.setAcquireScore(new BigDecimal(0));
tail2.setAcquireScore(BigDecimal.ZERO);
tail2.setScoreComment("/");
tail2.setIsAdd(-1);
return tail2;
}
public ResultDetailResp getLastResult() {
public ResultDetailResp getLastResult(BigDecimal value) {
ResultDetailResp tail3 = new ResultDetailResp();
tail3.setCheckRange("最终绩效考核结果等级");
tail3.setAcquireScore(new BigDecimal(3.25));
tail3.setAcquireScore(BigDecimalUtil.setScale(value, 3));
tail3.setScoreComment("/");
tail3.setIsAdd(-1);
return tail3;

View File

@ -74,6 +74,10 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
@Autowired
private DepartmentsService departmentsService;
@Autowired
private RecordAuthService recordAuthService;
@Autowired
@ -157,13 +161,15 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
params.setDepartmentIds(departmentIds);
String departmentLevel = Constant.ME;
FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(user.getUserId());
if (flowDepartment != null) {
departmentLevel = flowDepartment.getDepartmentLevel();
} else {
StaffRole staffRole = staffRoleService.selectByStaffId(user.getUserId());
if (staffRole != null) {
departmentLevel = staffRole.getDepartmentLevel();
if (params.getIsSelf() != 1) { // 表示点击我们审批
FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(user.getUserId());
if (flowDepartment != null) {
departmentLevel = flowDepartment.getDepartmentLevel();
} else {
StaffRole staffRole = staffRoleService.selectByStaffId(user.getUserId());
if (staffRole != null) {
departmentLevel = staffRole.getDepartmentLevel();
}
}
}
params.setDepartmentLevel(departmentLevel);
@ -172,11 +178,16 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
);
List<ResultRecord> resultRecords = pageUtils.getList();
if(CollectionUtils.isNotEmpty(resultRecords)){
if (CollectionUtils.isNotEmpty(resultRecords)) {
List<ResultRecordResp> list = new ArrayList<>();
for (ResultRecord resultRecord : resultRecords) {
ResultRecordResp resp = new ResultRecordResp();
BeanUtils.copyProperties(resultRecord, resp);
Map<Long, Long> staffRoleMap = recordAuthService.selectRoleIdByStaffRoleInfo(resultRecord.getFlowStaffIdRole());
if (resp.getStatus().equals(1) && staffRoleMap.get(user.getUserId()) == null) {
resp.setStatus(2); // 如果不是自己审批说明自己己经审批完成
}
list.add(resp);
}
pageUtils.setList(list);
@ -228,15 +239,15 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
@Override
public TwoTuple getFlowInfo(Long staffId, Integer type) {
FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(staffId);
List<FlowDepartment> list = new ArrayList<>();
Long flowId = flowDepartment != null ? TypeFlowDto.getFlowId(flowDepartment.getFlowIds(), Constant.SELF, type) : 0l; // 表示是部门主管自己
if (flowDepartment == null) {
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffId);
DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
flowDepartment = flowDepartmentService.selectByStaffId(leader.getStaffId());
flowId = TypeFlowDto.getFlowId(flowDepartment.getFlowIds(), Constant.CHILD, type);//表示是部门下的普通员工
list.add(flowDepartment);
}
List<FlowDepartment> list = new ArrayList<>();
list.add(flowDepartment);
for (int i = 0; i < 10; i++) {
if (flowDepartment.getParentId() != null && flowDepartment.getParentId() > 0) {
flowDepartment = flowDepartmentService.selectFlowDepartmentById(flowDepartment.getParentId());

View File

@ -123,6 +123,7 @@
<select id="selectByRecordId" resultType="com.lz.modules.sys.entity.app.ResultDetail">
select * from lz_result_detail where record_id=#{recordResultId} and is_delete = 0 order by type asc ,priority desc
</select>
<select id="selectByRecordIdType" resultType="com.lz.modules.sys.entity.app.ResultDetail">
select * from lz_result_detail where record_id=#{recordResultId} and type = #{type} and is_delete = 0 order by type asc ,priority desc
</select>

View File

@ -178,7 +178,7 @@
AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthBeginDate}, '%Y-%m-%d %H:%i:%S')
</if>
<if test="req.monthEndDate != null and req.monthEndDate != '' ">
AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthEndDate}, '%Y-%m-%d %H:%i:%S')
AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> DATE_FORMAT(#{req.monthEndDate}, '%Y-%m-%d %H:%i:%S')
</if>
<if test="req.status != null">
and rd.status = #{req.status}