提交修改

This commit is contained in:
quyixiao 2020-08-25 22:53:23 +08:00
parent 333f92eb2c
commit 0c6296917b
4 changed files with 33 additions and 4 deletions

View File

@ -21,9 +21,12 @@ import java.util.Map;
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
private boolean isSuccess;
public R() {
put("code", 0);
put("msg", "success");
this.isSuccess = true ;
}
public static R error() {
@ -38,6 +41,7 @@ public class R extends HashMap<String, Object> {
R r = new R();
r.put("code", code);
r.put("msg", msg);
r.setSuccess(false);
return r;
}
@ -61,4 +65,12 @@ public class R extends HashMap<String, Object> {
super.put(key, value);
return this;
}
public boolean isSuccess() {
return isSuccess;
}
public void setSuccess(boolean success) {
this.isSuccess = success;
}
}

View File

@ -293,7 +293,7 @@ public class ResultRecordController extends AbstractController {
R r = null;
int status = 1;
if (req.getStatus() == 2) {
r = resultRecordService.approval(req.getRecordResultId(), getUserId());
r = resultRecordService.approval(req.getRecordResultId(), getUserId());
} else if (req.getStatus() == 3) { //侍提交
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
resultRecord.setStatus(Constant.STATUS_3);

View File

@ -55,4 +55,6 @@ public interface ResultRecordService extends IService<ResultRecord> {
ResultRecord createResultRecord(Long userId, int type,Long roleId);
ResultRecord initResult(Long staffId ,Integer recordType,Long roleId) ;
R checkApproval(Long recordId);
}

View File

@ -324,12 +324,29 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
return resultRecordNew;
}
@Override
public R checkApproval(Long recordId){
List<ResultDetail> resultDetails = resultDetailService.selectByRecordId(recordId);
if (CollectionUtils.isEmpty(resultDetails)) {
return R.error("请先添加业绩");
}
double sum = resultDetails.stream().filter(p -> p.getType() == 2).mapToDouble(p -> NumberUtil.objToDoubleWithDefault(p.getCheckWeight(), 0d)).sum();
if (sum < 0.7) {
return R.error("recordId为[" + recordId + "]业绩权重之和必需大于0.7");
}
return R.ok();
}
@Override
public R approval(Long resultRecordId, Long userId) {
ResultRecord resultRecord = resultRecordService.selectResultRecordById(resultRecordId);
R r = resultRecordService.checkApproval(resultRecordId);
if (!r.isSuccess()) {
return r;
}
StaffEntity mySelf = staffService.selectStaffById(userId);
TwoTuple<Long, List<FlowDepartment>> flowInfo = getFlowInfo(resultRecord.getStaffId(),resultRecord.getType());
TwoTuple<Long, List<FlowDepartment>> flowInfo = getFlowInfo(resultRecord.getStaffId(), resultRecord.getType());
Long flowId = flowInfo.getFirst();
List<FlowDepartment> list = flowInfo.getSecond();
List<FlowRelation> flowRelations = flowRelationService.selectFlowRelationAll();
@ -348,7 +365,6 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
if (notFlowRecord != null) {
notFlowRecord.setApprovalStaffId(userId);
}
StaffEntity staff = staffService.selectStaffById(resultRecord.getStaffId());
int flowIndex = lastFlowRecord != null ? lastFlowRecord.getFlowIndex() + 1 : 1;
int index = getDepartmentLevelIndex(flows, flowIndex);
@ -443,5 +459,4 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
return index;
}
}