rjuq whnt

This commit is contained in:
quyixiao 2020-08-26 11:23:18 +08:00
parent 4a5540a4f0
commit 210c1e5652
3 changed files with 45 additions and 13 deletions

View File

@ -109,7 +109,7 @@ public class ResultRecordController extends AbstractController {
req.setStaffId(user.getUserId());
} else {
StaffRole staffRole = staffRoleService.selectByStaffId(getUserId());
if (staffRole == null) {
if (staffRole == null && req.getIsChangeDepartmentrtment() == 0) {
DepartmentsStaffRelateEntity relateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(getUserId());
Map<String, String> map = departmentsService.selectUserAllDepartmentInFo(relateEntity.getDepartmentId());
int i = 0;
@ -431,14 +431,10 @@ public class ResultRecordController extends AbstractController {
return R.error("您的提交记录中有状态不为侍提交的,请重新选择。");
}
}
new Thread(new Runnable() {
@Override
public void run() {
for (ResultRecord resultRecord : resultRecords) {
resultRecordService.approval(resultRecord.getId(), getUserId());
}
}
}).start();
for (ResultRecord resultRecord : resultRecords) {
resultRecordService.approval(resultRecord.getId(), getUserId());
}
return R.ok("批量提交成功");
}
@ -479,6 +475,43 @@ public class ResultRecordController extends AbstractController {
return R.ok("验证成功");
}
/**
* 信息
*/
@RequestMapping("/preWeightCheck")
public R preWeightCheck(ResultRecordReq req) {
List<ResultDetail> resultDetails = resultDetailService.selectByRecordIdType(req.getRecordResultId(), req.getType());
double compare = 0.3; //如果类型是文化价值观
if (req.getType() == 1) { //类型是业绩
compare = 0.7;
}
if (CollectionUtils.isEmpty(resultDetails)) {
if (req.getId() > 0) { // 编辑验证
if (req.getWeight().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() > compare) {
return R.error("权重不能大于" + compare);
}
} else { // 添加验证
if (req.getWeight().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() >= compare) {
return R.error("权重不能大于" + compare);
}
}
} else {
double sum = resultDetails.stream()
.filter(p -> !p.getId().equals(req.getId()))
.mapToDouble(n -> NumberUtil.objToDoubleWithDefault(n.getCheckWeight(), 0d)).summaryStatistics().getSum();
if (req.getId() > 0) { //编辑验证
if (new BigDecimal(sum).add(req.getWeight()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() > compare) {
return R.error("权重之和不能大于" + compare);
}
} else { //添加验证
if (new BigDecimal(sum).add(req.getWeight()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() >= compare) {
return R.error("权重之和不能大于" + compare);
}
}
}
return R.ok("验证成功");
}
/**
* 信息
*/

View File

@ -38,7 +38,6 @@ public class ResultRecordReq {
private List<Long > statusList ;
private String statusStr;
private Long approvalStaffId;
private int isChangeDepartmentrtment;
}

View File

@ -324,11 +324,11 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
public R checkApproval(Long recordId){
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(recordId);
if (CollectionUtils.isEmpty(resultDetails)) {
return R.error("请先添加业绩");
return R.error("请先添加业绩");
}
double sum = resultDetails.parallelStream().filter(p -> p.getType() == 1).mapToDouble(p -> NumberUtil.objToDoubleWithDefault(p.getCheckWeight(), 0d)).sum();
if (sum < 0.7) {
return R.error("recordId为[" + recordId + "]业绩权重之和必需大于0.7");
return R.error("recordId为[" + recordId + "]业绩权重之和必需等于0.7。");
}
return R.ok();