|
@@ -1227,77 +1227,79 @@ public class ReportController {
|
|
targetCheckList = reportList.stream().filter(r->!passedReportList.stream().map(Report::getId).collect(Collectors.toList()).contains(r.getId())).collect(Collectors.toList());
|
|
targetCheckList = reportList.stream().filter(r->!passedReportList.stream().map(Report::getId).collect(Collectors.toList()).contains(r.getId())).collect(Collectors.toList());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- Collection<Integer> projectIds = targetCheckList.stream().map(Report::getProjectId).distinct().collect(Collectors.toList());
|
|
|
|
- List<Report> oldRelatedReportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id", projectIds).and(wrapper->wrapper.eq("state",0).or().eq("state",1).or().eq("state",3)));
|
|
|
|
- List<Project> targetProjectList = projectList.stream().filter(pl -> projectIds.contains(pl.getId())).collect(Collectors.toList());
|
|
|
|
- estimateTimeSetting = estimateTimeSettingMapper.selectById(company.getId());
|
|
|
|
- //如果没有设置过项目人天,就初始化一下
|
|
|
|
- if (estimateTimeSetting == null) {
|
|
|
|
- estimateTimeSetting = new EstimateTimeSetting();
|
|
|
|
- estimateTimeSetting.setCompanyId(company.getId());
|
|
|
|
- estimateTimeSettingMapper.insert(estimateTimeSetting);
|
|
|
|
|
|
+ if (targetCheckList.size() > 0) {
|
|
|
|
+ Collection<Integer> projectIds = targetCheckList.stream().map(Report::getProjectId).distinct().collect(Collectors.toList());
|
|
|
|
+ List<Report> oldRelatedReportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id", projectIds).and(wrapper->wrapper.eq("state",0).or().eq("state",1).or().eq("state",3)));
|
|
|
|
+ List<Project> targetProjectList = projectList.stream().filter(pl -> projectIds.contains(pl.getId())).collect(Collectors.toList());
|
|
estimateTimeSetting = estimateTimeSettingMapper.selectById(company.getId());
|
|
estimateTimeSetting = estimateTimeSettingMapper.selectById(company.getId());
|
|
- }
|
|
|
|
- for (Report report : targetCheckList) {
|
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
- Optional<Project> first = targetProjectList.stream().filter(tl -> tl.getId().equals(report.getProjectId())).findFirst();
|
|
|
|
- if(first.isPresent()){
|
|
|
|
- double nowReport = targetCheckList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
- if(first.get().getManDay()!=null){
|
|
|
|
- //已填报的工时情况
|
|
|
|
- double sum;
|
|
|
|
- if(first.get().getManDayStartDate()!=null){
|
|
|
|
- sum = oldRelatedReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
- }else {
|
|
|
|
- sum = oldRelatedReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
- }
|
|
|
|
- BigDecimal hasReport = new BigDecimal(sum).add(new BigDecimal(nowReport));
|
|
|
|
- BigDecimal multiply = new BigDecimal(first.get().getManDay()).multiply(new BigDecimal(comTimeType.getAllday()));
|
|
|
|
- if(hasReport.doubleValue()>multiply.doubleValue()){
|
|
|
|
- if (estimateTimeSetting.getProjectFronzeOnLack() == 1) {
|
|
|
|
- httpRespMsg.setError("超过当前项目["+first.get().getProjectName()+"]预算工时,无法继续提交工时");
|
|
|
|
- return httpRespMsg;
|
|
|
|
- } else {
|
|
|
|
- //仅提醒
|
|
|
|
- warningLackProjects += first.get().getProjectName() + ",";
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //检查是否超过预设的提醒百分比;设置的数值是剩余的百分比
|
|
|
|
- if (hasReport.divide(multiply, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).compareTo(new BigDecimal(100-estimateTimeSetting.getProjectWarningPercent()))>0) {
|
|
|
|
- warningPercentProjects += first.get().getProjectName() + ",";
|
|
|
|
|
|
+ //如果没有设置过项目人天,就初始化一下
|
|
|
|
+ if (estimateTimeSetting == null) {
|
|
|
|
+ estimateTimeSetting = new EstimateTimeSetting();
|
|
|
|
+ estimateTimeSetting.setCompanyId(company.getId());
|
|
|
|
+ estimateTimeSettingMapper.insert(estimateTimeSetting);
|
|
|
|
+ estimateTimeSetting = estimateTimeSettingMapper.selectById(company.getId());
|
|
|
|
+ }
|
|
|
|
+ for (Report report : targetCheckList) {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ Optional<Project> first = targetProjectList.stream().filter(tl -> tl.getId().equals(report.getProjectId())).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ double nowReport = targetCheckList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
+ if(first.get().getManDay()!=null){
|
|
|
|
+ //已填报的工时情况
|
|
|
|
+ double sum;
|
|
|
|
+ if(first.get().getManDayStartDate()!=null){
|
|
|
|
+ sum = oldRelatedReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
+ }else {
|
|
|
|
+ sum = oldRelatedReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
}
|
|
}
|
|
- //检查分组工时
|
|
|
|
- Integer targetGpId = report.getGroupId();
|
|
|
|
- if (targetGpId != null) {
|
|
|
|
- double groupSum = 0;
|
|
|
|
- if(first.get().getManDayStartDate()!=null){
|
|
|
|
- groupSum = oldRelatedReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
- }else {
|
|
|
|
- groupSum = oldRelatedReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
|
|
+ BigDecimal hasReport = new BigDecimal(sum).add(new BigDecimal(nowReport));
|
|
|
|
+ BigDecimal multiply = new BigDecimal(first.get().getManDay()).multiply(new BigDecimal(comTimeType.getAllday()));
|
|
|
|
+ if(hasReport.doubleValue()>multiply.doubleValue()){
|
|
|
|
+ if (estimateTimeSetting.getProjectFronzeOnLack() == 1) {
|
|
|
|
+ httpRespMsg.setError("超过当前项目["+first.get().getProjectName()+"]预算工时,无法继续提交工时");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ } else {
|
|
|
|
+ //仅提醒
|
|
|
|
+ warningLackProjects += first.get().getProjectName() + ",";
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //检查是否超过预设的提醒百分比;设置的数值是剩余的百分比
|
|
|
|
+ if (hasReport.divide(multiply, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).compareTo(new BigDecimal(100-estimateTimeSetting.getProjectWarningPercent()))>0) {
|
|
|
|
+ warningPercentProjects += first.get().getProjectName() + ",";
|
|
}
|
|
}
|
|
- nowReport = targetCheckList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId()) && targetGpId.equals(rl.getGroupId())).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
- hasReport = new BigDecimal(groupSum).add(new BigDecimal(nowReport));
|
|
|
|
- TaskGroup tgp = taskGroupService.getById(targetGpId);
|
|
|
|
- //设置的数值大于0时检查是否超额
|
|
|
|
- if (tgp != null && tgp.getManDay() != null && tgp.getManDay() > 0) {
|
|
|
|
- multiply = new BigDecimal(tgp.getManDay()).multiply(new BigDecimal(comTimeType.getAllday()));
|
|
|
|
- if (hasReport.doubleValue() > multiply.doubleValue()) {
|
|
|
|
- if (estimateTimeSetting.getGroupFronzeOnLack() == 1) {
|
|
|
|
- httpRespMsg.setError("超过当前项目["+first.get().getProjectName()+"]分组["+tgp.getName()+"]预算工时,无法继续提交工时");
|
|
|
|
- return httpRespMsg;
|
|
|
|
|
|
+ //检查分组工时
|
|
|
|
+ Integer targetGpId = report.getGroupId();
|
|
|
|
+ if (targetGpId != null) {
|
|
|
|
+ double groupSum = 0;
|
|
|
|
+ if(first.get().getManDayStartDate()!=null){
|
|
|
|
+ groupSum = oldRelatedReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
+ }else {
|
|
|
|
+ groupSum = oldRelatedReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
+ }
|
|
|
|
+ nowReport = targetCheckList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId()) && targetGpId.equals(rl.getGroupId())).mapToDouble(Report::getWorkingTime).sum();
|
|
|
|
+ hasReport = new BigDecimal(groupSum).add(new BigDecimal(nowReport));
|
|
|
|
+ TaskGroup tgp = taskGroupService.getById(targetGpId);
|
|
|
|
+ //设置的数值大于0时检查是否超额
|
|
|
|
+ if (tgp != null && tgp.getManDay() != null && tgp.getManDay() > 0) {
|
|
|
|
+ multiply = new BigDecimal(tgp.getManDay()).multiply(new BigDecimal(comTimeType.getAllday()));
|
|
|
|
+ if (hasReport.doubleValue() > multiply.doubleValue()) {
|
|
|
|
+ if (estimateTimeSetting.getGroupFronzeOnLack() == 1) {
|
|
|
|
+ httpRespMsg.setError("超过当前项目["+first.get().getProjectName()+"]分组["+tgp.getName()+"]预算工时,无法继续提交工时");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ } else {
|
|
|
|
+ //仅提醒
|
|
|
|
+ warningGroupLack += (tgp.getTaskGroupCode() != null?tgp.getTaskGroupCode():"")+"-"+tgp.getName() + ",";
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- //仅提醒
|
|
|
|
- warningGroupLack += (tgp.getTaskGroupCode() != null?tgp.getTaskGroupCode():"")+"-"+tgp.getName() + ",";
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //检查是否超过预设的提醒百分比;设置的数值是剩余的百分比
|
|
|
|
- if (hasReport.divide(multiply, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).compareTo(new BigDecimal(100 - estimateTimeSetting.getGroupWarningPercent())) > 0) {
|
|
|
|
- warningGroupPercent += (tgp.getTaskGroupCode() != null?tgp.getTaskGroupCode():"")+"-"+tgp.getName() + ",";
|
|
|
|
|
|
+ //检查是否超过预设的提醒百分比;设置的数值是剩余的百分比
|
|
|
|
+ if (hasReport.divide(multiply, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).compareTo(new BigDecimal(100 - estimateTimeSetting.getGroupWarningPercent())) > 0) {
|
|
|
|
+ warningGroupPercent += (tgp.getTaskGroupCode() != null?tgp.getTaskGroupCode():"")+"-"+tgp.getName() + ",";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|