|
@@ -130,26 +130,36 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
|
|
|
|
//检查今日该员工的该工序是否已经有报工
|
|
//检查今日该员工的该工序是否已经有报工
|
|
- Report existReport = reportMapper.selectOne(new QueryWrapper<Report>().eq("creator_id", token).eq("user_procedure_team_id", report.getUserProcedureTeamId()).eq("create_date", today));
|
|
|
|
|
|
+ Report todayReport = reportMapper.selectOne(new QueryWrapper<Report>().eq("creator_id", token).eq("user_procedure_team_id", report.getUserProcedureTeamId()).eq("create_date", today));
|
|
//计算工作时长
|
|
//计算工作时长
|
|
ProdProcedureTeam prodProcedureTeam = prodProcedureTeamMapper.selectById(report.getUserProcedureTeamId());
|
|
ProdProcedureTeam prodProcedureTeam = prodProcedureTeamMapper.selectById(report.getUserProcedureTeamId());
|
|
double curReportTime = 0.0;
|
|
double curReportTime = 0.0;
|
|
//查找上一次该工序的报工
|
|
//查找上一次该工序的报工
|
|
Integer lastProgress = 0;
|
|
Integer lastProgress = 0;
|
|
- Report lastReport = reportMapper.selectOne(new QueryWrapper<Report>().eq("creator_id", token).eq("user_procedure_team_id", report.getUserProcedureTeamId()).lt("create_date", today).orderByDesc("create_date").last("limit 1"));
|
|
|
|
- //查找上次是否有报工,有的话取上次报工进度,没有的话取分配下来时的报工进度
|
|
|
|
- if (lastReport != null) {
|
|
|
|
- if (report.getProgress() <= lastReport.getProgress()) {
|
|
|
|
- httpRespMsg.setError("进度必须大于上次报工进度("+lastReport.getProgress()+"%)");
|
|
|
|
|
|
+ Report beforeTodayReport = reportMapper.selectOne(new QueryWrapper<Report>().eq("creator_id", token).eq("user_procedure_team_id", report.getUserProcedureTeamId()).lt("create_date", today).orderByDesc("create_date").last("limit 1"));
|
|
|
|
+ //查找今天之前是否有报工,有的话取上次报工进度,没有的话取分配下来时的报工进度
|
|
|
|
+ if (beforeTodayReport != null) {
|
|
|
|
+ if (report.getProgress() <= beforeTodayReport.getProgress()) {
|
|
|
|
+ httpRespMsg.setError("进度必须大于上次报工进度("+beforeTodayReport.getProgress()+"%)");
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
lastProgress = report.getProgress();
|
|
lastProgress = report.getProgress();
|
|
} else {
|
|
} else {
|
|
|
|
+ //今天之前没有报过工
|
|
|
|
+ if (todayReport == null) {
|
|
|
|
+ lastProgress = prodProcedureTeam.getProgress();
|
|
|
|
+ if (report.getProgress() <= lastProgress) {
|
|
|
|
+ httpRespMsg.setError("进度必须大于上次报工进度("+lastProgress+"%)");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //今天报过工了,prodProcedureTeam中的是报过的工时,应该从0开始算才对
|
|
|
|
+ lastProgress = 0;
|
|
|
|
+ }
|
|
if (report.getProgress() <= lastProgress) {
|
|
if (report.getProgress() <= lastProgress) {
|
|
httpRespMsg.setError("进度必须大于上次报工进度("+lastProgress+"%)");
|
|
httpRespMsg.setError("进度必须大于上次报工进度("+lastProgress+"%)");
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
- lastProgress = prodProcedureTeam.getProgress();
|
|
|
|
}
|
|
}
|
|
int addProgress = report.getProgress() - lastProgress;
|
|
int addProgress = report.getProgress() - lastProgress;
|
|
curReportTime = (prodProcedureTeam.getWorkTime() * (addProgress)/100);
|
|
curReportTime = (prodProcedureTeam.getWorkTime() * (addProgress)/100);
|
|
@@ -178,14 +188,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
prodProcedureTeam.setStatus(3);//中止
|
|
prodProcedureTeam.setStatus(3);//中止
|
|
}
|
|
}
|
|
|
|
|
|
- if (existReport == null) {
|
|
|
|
|
|
+ if (todayReport == null) {
|
|
reportMapper.insert(report);
|
|
reportMapper.insert(report);
|
|
} else {
|
|
} else {
|
|
- report.setId(existReport.getId());
|
|
|
|
|
|
+ report.setId(todayReport.getId());
|
|
reportMapper.updateById(report);
|
|
reportMapper.updateById(report);
|
|
}
|
|
}
|
|
//更新自己执行的工序上的进度
|
|
//更新自己执行的工序上的进度
|
|
-
|
|
|
|
prodProcedureTeamMapper.updateById(prodProcedureTeam);
|
|
prodProcedureTeamMapper.updateById(prodProcedureTeam);
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|