|
@@ -12,8 +12,10 @@ import org.springblade.control.dto.ControlProjectInfoDTO;
|
|
|
import org.springblade.control.dto.ProjectCostBudgetDTO;
|
|
|
import org.springblade.control.dto.ProjectCostBudgetStatsDTO;
|
|
|
import org.springblade.control.entity.*;
|
|
|
+import org.springblade.control.mapper.DepartmentPlanLogMapper;
|
|
|
import org.springblade.control.mapper.ProjectCostBudgetMapper;
|
|
|
import org.springblade.control.mapper.ProjectInfoMapper;
|
|
|
+import org.springblade.control.service.IDepartmentPlanLogService;
|
|
|
import org.springblade.control.service.IProjectCostBudgetService;
|
|
|
import org.springblade.control.service.IProjectInfoService;
|
|
|
import org.springblade.control.service.IProjectProcessService;
|
|
@@ -43,13 +45,15 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBudgetMapper, ProjectCostBudget> implements IProjectCostBudgetService {
|
|
|
|
|
|
-// private final IProjectInfoService projectInfoService;
|
|
|
+ private final DepartmentPlanLogMapper logMapper;
|
|
|
|
|
|
private final ProjectInfoMapper infoMapper;
|
|
|
|
|
|
private final ProjectCostBudgetMapper budgetMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 批量新增或修改预算
|
|
|
+ *
|
|
|
* @param dto
|
|
|
*/
|
|
|
@Override
|
|
@@ -57,48 +61,48 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
public ProjectCostBudgetStats batchAddOrUpdate(ProjectCostBudgetStatsDTO dto) {
|
|
|
List<ProjectCostBudget> allBudget = new ArrayList<>();
|
|
|
//施工单位
|
|
|
- if (dto.getBuildUnit() != null && dto.getBuildUnit().size() > 0){
|
|
|
- dto.getBuildUnit().stream().forEach(l->{
|
|
|
- if (l.getDeptId() == null){
|
|
|
+ if (dto.getBuildUnit() != null && dto.getBuildUnit().size() > 0) {
|
|
|
+ dto.getBuildUnit().stream().forEach(l -> {
|
|
|
+ if (l.getDeptId() == null) {
|
|
|
throw new ServiceException("请选择费用分摊部门");
|
|
|
}
|
|
|
- if (l.getCostType() == null){
|
|
|
+ if (l.getCostType() == null) {
|
|
|
throw new ServiceException("请选择费用分类");
|
|
|
}
|
|
|
- if (l.getProjectProcess() == null){
|
|
|
+ if (l.getProjectProcess() == null) {
|
|
|
throw new ServiceException("请选择项目环节");
|
|
|
}
|
|
|
- if (l.getBudgetDays() == null){
|
|
|
+ if (l.getBudgetDays() == null) {
|
|
|
throw new ServiceException("请填写预计工作量");
|
|
|
}
|
|
|
- if (l.getPostType() == null){
|
|
|
+ if (l.getPostType() == null) {
|
|
|
throw new ServiceException("请选择岗位类型");
|
|
|
}
|
|
|
- if (l.getStaffCount() == null){
|
|
|
+ if (l.getStaffCount() == null) {
|
|
|
throw new ServiceException("请填写投入人员数量");
|
|
|
}
|
|
|
- if (l.getApprove() != null && (l.getApprove() == 1 || l.getApprove() == 2)){
|
|
|
+ if (l.getApprove() != null && (l.getApprove() == 1 || l.getApprove() == 2)) {
|
|
|
return;
|
|
|
}
|
|
|
- l.setProjectId(dto.getProjectId());
|
|
|
- l.setUnitType(1);
|
|
|
- countMoney(l);
|
|
|
+ l.setProjectId(dto.getProjectId());
|
|
|
+ l.setUnitType(1);
|
|
|
+ countMoney(l);
|
|
|
});
|
|
|
allBudget.addAll(dto.getBuildUnit());
|
|
|
}
|
|
|
//监理单位
|
|
|
- if (dto.getSupervisorUnit() != null && dto.getSupervisorUnit().size() > 0){
|
|
|
- dto.getSupervisorUnit().stream().forEach(l->{
|
|
|
- if (l.getDeptId() == null){
|
|
|
+ if (dto.getSupervisorUnit() != null && dto.getSupervisorUnit().size() > 0) {
|
|
|
+ dto.getSupervisorUnit().stream().forEach(l -> {
|
|
|
+ if (l.getDeptId() == null) {
|
|
|
throw new ServiceException("请选择费用分摊部门");
|
|
|
}
|
|
|
- if (l.getCostType() == null){
|
|
|
+ if (l.getCostType() == null) {
|
|
|
throw new ServiceException("请选择费用分类");
|
|
|
}
|
|
|
- if (l.getProjectProcess() == null){
|
|
|
+ if (l.getProjectProcess() == null) {
|
|
|
throw new ServiceException("请选择项目环节");
|
|
|
}
|
|
|
- if (l.getApprove() != null && (l.getApprove() == 1 || l.getApprove() == 2)){
|
|
|
+ if (l.getApprove() != null && (l.getApprove() == 1 || l.getApprove() == 2)) {
|
|
|
return;
|
|
|
}
|
|
|
l.setProjectId(dto.getProjectId());
|
|
@@ -108,18 +112,18 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
allBudget.addAll(dto.getSupervisorUnit());
|
|
|
}
|
|
|
//建设单位
|
|
|
- if (dto.getConstructUnit() != null && dto.getConstructUnit().size() > 0){
|
|
|
- dto.getConstructUnit().stream().forEach(l->{
|
|
|
- if (l.getDeptId() == null){
|
|
|
+ if (dto.getConstructUnit() != null && dto.getConstructUnit().size() > 0) {
|
|
|
+ dto.getConstructUnit().stream().forEach(l -> {
|
|
|
+ if (l.getDeptId() == null) {
|
|
|
throw new ServiceException("请选择费用分摊部门");
|
|
|
}
|
|
|
- if (l.getCostType() == null){
|
|
|
+ if (l.getCostType() == null) {
|
|
|
throw new ServiceException("请选择费用分类");
|
|
|
}
|
|
|
- if (l.getProjectProcess() == null){
|
|
|
+ if (l.getProjectProcess() == null) {
|
|
|
throw new ServiceException("请选择项目环节");
|
|
|
}
|
|
|
- if (l.getApprove() != null && (l.getApprove() == 1 || l.getApprove() == 2)){
|
|
|
+ if (l.getApprove() != null && (l.getApprove() == 1 || l.getApprove() == 2)) {
|
|
|
return;
|
|
|
}
|
|
|
l.setProjectId(dto.getProjectId());
|
|
@@ -137,6 +141,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 项目预算列表,默认所有
|
|
|
+ *
|
|
|
* @param costBudget
|
|
|
* @return
|
|
|
*/
|
|
@@ -147,18 +152,33 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 查询项目下所有预算明细
|
|
|
+ *
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public List<ProjectCostBudget> budgetListByProjectId(Long projectId) {
|
|
|
- return this.list(new LambdaQueryWrapper<ProjectCostBudget>().eq(ProjectCostBudget::getProjectId,projectId).eq(ProjectCostBudget::getParentId,0));
|
|
|
+ return this.list(new LambdaQueryWrapper<ProjectCostBudget>().eq(ProjectCostBudget::getProjectId, projectId).eq(ProjectCostBudget::getParentId, 0));
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询项目下所有预算明细
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ProjectCostBudget> budgetListByProjectId2(List<Long> ids) {
|
|
|
+ return this.list(new LambdaQueryWrapper<ProjectCostBudget>()
|
|
|
+ .in(ProjectCostBudget::getId, ids)
|
|
|
+ .eq(ProjectCostBudget::getParentId, 0));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 根据项目id删除项目
|
|
|
+ *
|
|
|
* @param projectId
|
|
|
*/
|
|
|
@Override
|
|
@@ -169,11 +189,12 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
@Override
|
|
|
public List<ControlProjectInfoVO> page(ControlProjectInfoDTO dto, Query query) {
|
|
|
IPage page = new Page(query.getCurrent(), query.getSize());
|
|
|
- return baseMapper.page(page,dto);
|
|
|
+ return baseMapper.page(page, dto);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取项目计划
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
@@ -187,51 +208,51 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
//获取所有岗位信息
|
|
|
List<DictInfo> allPostType = baseMapper.getAllPostType();
|
|
|
Map<Long, List<DictInfo>> postMap = new HashMap<>();
|
|
|
- if (allPostType != null && allPostType.size() >0){
|
|
|
+ if (allPostType != null && allPostType.size() > 0) {
|
|
|
postMap = allPostType.parallelStream()
|
|
|
.collect(Collectors.groupingBy(DictInfo::getId));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new ServiceException("参数配置暂无岗位信息");
|
|
|
}
|
|
|
//获取所有任务信息
|
|
|
List<DictInfo> allTaskInfo = baseMapper.getAllTaskInfo();
|
|
|
Map<Long, List<DictInfo>> taskMap = new HashMap<>();
|
|
|
- if (allPostType != null && allPostType.size() >0){
|
|
|
+ if (allPostType != null && allPostType.size() > 0) {
|
|
|
taskMap = allTaskInfo.parallelStream()
|
|
|
.collect(Collectors.groupingBy(DictInfo::getId));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new ServiceException("参数配置暂无任务信息");
|
|
|
}
|
|
|
//获取项目下所有计划关联回款信息
|
|
|
List<PlanRelationReturned> allRelationInfo = baseMapper.getAllRelationInfo(id);
|
|
|
Map<Long, List<PlanRelationReturned>> relationMap = null;
|
|
|
- if (allRelationInfo != null && allRelationInfo.size() > 0){
|
|
|
+ if (allRelationInfo != null && allRelationInfo.size() > 0) {
|
|
|
relationMap = allRelationInfo.parallelStream()
|
|
|
.collect(Collectors.groupingBy(PlanRelationReturned::getPlanId));
|
|
|
}
|
|
|
//获取项目下所有回款信息
|
|
|
List<ContractReturnedInfo> allReturnedInfo = baseMapper.getAllReturnedInfo(id);
|
|
|
Map<Long, List<ContractReturnedInfo>> returnedMap = null;
|
|
|
- if (allReturnedInfo != null && allReturnedInfo.size() > 0){
|
|
|
+ if (allReturnedInfo != null && allReturnedInfo.size() > 0) {
|
|
|
returnedMap = allReturnedInfo.parallelStream()
|
|
|
.collect(Collectors.groupingBy(ContractReturnedInfo::getId));
|
|
|
}
|
|
|
//获取项目下所有已审批的计划
|
|
|
List<ProjectCostBudgetVO2> list = baseMapper.getApprovePlan(id);
|
|
|
for (ProjectCostBudgetVO2 l : list) {
|
|
|
- if (l.getPlanTaskType() != null || l.getPlanDays() != null || l.getPlanStartTime() != null || l.getPlanEndTime() != null){
|
|
|
+ if (l.getPlanTaskType() != null || l.getPlanDays() != null || l.getPlanStartTime() != null || l.getPlanEndTime() != null) {
|
|
|
l.setIsShowChildren(0);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
l.setIsShowChildren(1);
|
|
|
}
|
|
|
- if (relationMap != null){
|
|
|
+ if (relationMap != null) {
|
|
|
List<PlanRelationReturned> returnedList = relationMap.get(l.getId());
|
|
|
- if (returnedList != null && returnedList.size() > 0){
|
|
|
+ if (returnedList != null && returnedList.size() > 0) {
|
|
|
StringBuilder str = new StringBuilder();
|
|
|
int j = 1;
|
|
|
for (PlanRelationReturned returned : returnedList) {
|
|
|
ContractReturnedInfo info = returnedMap.get(returned.getReturnedId()).get(0);
|
|
|
- str.append(j+"."+info.getReturnedCondition()+"。");
|
|
|
+ str.append(j + "." + info.getReturnedCondition() + "、");
|
|
|
}
|
|
|
l.setReturnedValue(str.toString());
|
|
|
}
|
|
@@ -240,7 +261,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
//获取项目下所有的子计划
|
|
|
List<ProjectCostBudgetVO2> childrenList = baseMapper.getAllChildrenPlan(id);
|
|
|
//有子计划就插入父计划,没有子计划直接跳过
|
|
|
- if (childrenList != null && childrenList.size() >0) {
|
|
|
+ if (childrenList != null && childrenList.size() > 0) {
|
|
|
//把子计划按parentId分组
|
|
|
Map<Long, List<ProjectCostBudgetVO2>> listMap = childrenList.parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudgetVO2::getParentId));
|
|
@@ -248,7 +269,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
//循环所有父计划
|
|
|
for (ProjectCostBudgetVO2 vo2 : list) {
|
|
|
if (vo2.getTaskApprove() == 1) {
|
|
|
- vo2.setTaskFinishedStatus(2);
|
|
|
+ vo2.setTaskFinishedStatus(2);
|
|
|
}
|
|
|
//如果子计划,把子计划插入计划里
|
|
|
if (key.contains(vo2.getId())) {
|
|
@@ -264,12 +285,12 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
Boolean isFinished = true;
|
|
|
int j = 1;
|
|
|
for (ProjectCostBudgetVO2 budgetVO2 : vo2List) {
|
|
|
- if (budgetVO2.getTaskApprove() != 1){
|
|
|
+ if (budgetVO2.getTaskApprove() != 1) {
|
|
|
isFinished = false;
|
|
|
}
|
|
|
- if (budgetVO2.getStatus() == 1){
|
|
|
+ if (budgetVO2.getStatus() == 1) {
|
|
|
budgetVO2.setIsShowDelete(1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
budgetVO2.setIsShowDelete(0);
|
|
|
}
|
|
|
//计算总天数
|
|
@@ -277,20 +298,20 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
workDays = workDays.add(budgetVO2.getPlanDays());
|
|
|
}
|
|
|
//计算最大日期和最小日期
|
|
|
- if (budgetVO2.getPlanStartTime().isBefore(startDate)){
|
|
|
+ if (budgetVO2.getPlanStartTime().isBefore(startDate)) {
|
|
|
startDate = budgetVO2.getPlanStartTime();
|
|
|
}
|
|
|
- if (budgetVO2.getPlanEndTime().isAfter(endDate)){
|
|
|
+ if (budgetVO2.getPlanEndTime().isAfter(endDate)) {
|
|
|
endDate = budgetVO2.getPlanEndTime();
|
|
|
}
|
|
|
//拼接子计划的任务描述
|
|
|
- descStr.append(j + "."+budgetVO2.getPlanTaskDesc()+"。");
|
|
|
+ descStr.append(j + "." + budgetVO2.getPlanTaskDesc() + "、");
|
|
|
//拼接子计划的完成指标
|
|
|
- targetStr.append(j+"."+budgetVO2.getPlanTarget()+"。");
|
|
|
+ targetStr.append(j + "." + budgetVO2.getPlanTarget() + "、");
|
|
|
j++;
|
|
|
}
|
|
|
//所有子计划完成,设置父计划为绿色
|
|
|
- if (isFinished){
|
|
|
+ if (isFinished) {
|
|
|
vo2.setTaskFinishedStatus(2);
|
|
|
}
|
|
|
|
|
@@ -306,10 +327,10 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
vo2.setPlanStartTime(startDate);
|
|
|
vo2.setPlanEndTime(endDate);
|
|
|
//根据任务类型设置父计划的工作天数,固定任务1,临时任务2
|
|
|
- if (taskMap.get(vo2.getPlanTaskType()).get(0).getDictValue().intValue() == 1){
|
|
|
+ if (taskMap.get(vo2.getPlanTaskType()).get(0).getDictValue().intValue() == 2) {
|
|
|
vo2.setPlanDays(new BigDecimal(endDate.compareTo(startDate) + 1));
|
|
|
- }else {
|
|
|
- if (startDate.until(endDate,ChronoUnit.DAYS) > 35){
|
|
|
+ } else {
|
|
|
+ if (startDate.until(endDate, ChronoUnit.DAYS) > 35) {
|
|
|
throw new ServiceException("请不要制定超过一个月的临时计划");
|
|
|
// //工作天数,工具只能获取50天之内的
|
|
|
// int i = 0;
|
|
@@ -318,58 +339,58 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
// startDate = startDate.plusDays(36L);
|
|
|
// }
|
|
|
// vo2.setPlanDays(new BigDecimal(i));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setPlanDays(new BigDecimal(CommonUtil.getWorkDays(startDate, endDate)));
|
|
|
}
|
|
|
}
|
|
|
//如果计划已经完成,则不计算超预算
|
|
|
- if (vo2.getTaskFinishedStatus() == null && vo2.getPlanDays() != null && vo2.getBudgetDays() != null){
|
|
|
- if (workDays.intValue() > vo2.getBudgetDays().intValue()) {
|
|
|
+ if (vo2.getTaskFinishedStatus() == null && vo2.getPlanDays() != null && vo2.getBudgetDays() != null) {
|
|
|
+ if (workDays.intValue() > vo2.getBudgetDays().multiply(vo2.getStaffCount()).intValue()) {
|
|
|
vo2.setTaskFinishedStatus(1);
|
|
|
- vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长("+(workDays.intValue() - vo2.getBudgetDays().intValue())+"天)");
|
|
|
+ vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长(" + (workDays.intValue() - vo2.getBudgetDays().intValue()) + "天)");
|
|
|
}
|
|
|
}
|
|
|
vo2.setChildrenList(listMap.get(vo2.getId()));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//如果计划的status为2,3,4,或者计划有子计划,则不能编辑
|
|
|
- if (vo2.getStatus() == 1){
|
|
|
+ if (vo2.getStatus() == 1) {
|
|
|
vo2.setIsShowEdit(1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setIsShowEdit(0);
|
|
|
}
|
|
|
//没有子计划,则计算父计划成本是否超过测算,如果计划没有完成,有选择日期,有员工支出,则判断
|
|
|
- if (vo2.getTaskFinishedStatus() == null && vo2.getPlanDays() != null && vo2.getBudgetDays() != null){
|
|
|
+ if (vo2.getTaskFinishedStatus() == null && vo2.getPlanDays() != null && vo2.getBudgetDays() != null) {
|
|
|
if (vo2.getPlanDays().intValue() > vo2.getBudgetDays().intValue()) {
|
|
|
vo2.setTaskFinishedStatus(1);
|
|
|
- vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长("+(vo2.getPlanDays().intValue() - vo2.getBudgetDays().intValue())+"天)");
|
|
|
+ vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长(" + (vo2.getPlanDays().intValue() - vo2.getBudgetDays().intValue()) + "天)");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//没有子计划也要为父计划设置颜色,是否显示编辑,是否显示分解子计划
|
|
|
for (ProjectCostBudgetVO2 vo2 : list) {
|
|
|
//设置颜色,已完成绿色,并且不能编辑,不能分解子计划
|
|
|
- if (vo2.getTaskApprove() == 1){
|
|
|
+ if (vo2.getTaskApprove() == 1) {
|
|
|
vo2.setTaskFinishedStatus(2);
|
|
|
vo2.setIsShowChildren(0);
|
|
|
vo2.setIsShowEdit(0);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//如果计划正在进行就不能编辑
|
|
|
- if (vo2.getStatus() == 1){
|
|
|
+ if (vo2.getStatus() == 1) {
|
|
|
vo2.setIsShowEdit(1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setIsShowEdit(0);
|
|
|
}
|
|
|
//如果已经填写了任务类型和选择了任务时间,就不显示子计划
|
|
|
- if (vo2.getPostType() != null && vo2.getPlanDays() != null){
|
|
|
+ if (vo2.getPostType() != null && vo2.getPlanDays() != null) {
|
|
|
vo2.setIsShowChildren(0);
|
|
|
//计算是否超过预算
|
|
|
- if ((vo2.getPlanDays().multiply(new BigDecimal(postMap.get(vo2.getPostType()).get(0).getDictValue()))).compareTo(vo2.getBudgetStaffCost()) == 1){
|
|
|
+ if ((vo2.getPlanDays().multiply(new BigDecimal(postMap.get(vo2.getPostType()).get(0).getDictValue()))).compareTo(vo2.getBudgetStaffCost()) == 1) {
|
|
|
vo2.setTaskFinishedStatus(1);
|
|
|
- vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长("+(vo2.getPlanDays().intValue() - vo2.getBudgetDays().intValue())+"天)");
|
|
|
+ vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长(" + (vo2.getPlanDays().intValue() - vo2.getBudgetDays().intValue()) + "天)");
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setIsShowChildren(1);
|
|
|
}
|
|
|
|
|
@@ -381,17 +402,17 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
Map<Integer, List<ProjectCostBudgetVO2>> map = list.parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudgetVO2::getUnitType));
|
|
|
//在相同单位下,根据部门分类,1施工,2监理,3建设
|
|
|
- if (map.get(1) != null && map.get(1).size() > 0){
|
|
|
+ if (map.get(1) != null && map.get(1).size() > 0) {
|
|
|
Map<Integer, List<ProjectCostBudgetVO2>> build = map.get(1).parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudgetVO2::getCostType));
|
|
|
vo.setBuildUnit(build);
|
|
|
}
|
|
|
- if (map.get(2) != null && map.get(2).size() > 0){
|
|
|
+ if (map.get(2) != null && map.get(2).size() > 0) {
|
|
|
Map<Integer, List<ProjectCostBudgetVO2>> supervisor = map.get(2).parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudgetVO2::getCostType));
|
|
|
vo.setSupervisorUnit(supervisor);
|
|
|
}
|
|
|
- if (map.get(3) != null && map.get(3).size() > 0){
|
|
|
+ if (map.get(3) != null && map.get(3).size() > 0) {
|
|
|
Map<Integer, List<ProjectCostBudgetVO2>> construct = map.get(3).parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudgetVO2::getCostType));
|
|
|
vo.setConstructUnit(construct);
|
|
@@ -426,7 +447,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
//把所有子计划分离出来,并且设置父类id
|
|
|
for (ProjectCostBudgetVO2 vo2 : list) {
|
|
|
List<ProjectCostBudgetVO2> vo2ChildrenList = vo2.getChildrenList();
|
|
|
- if (vo2ChildrenList != null && vo2ChildrenList.size() > 0){
|
|
|
+ if (vo2ChildrenList != null && vo2ChildrenList.size() > 0) {
|
|
|
for (ProjectCostBudget budget : vo2ChildrenList) {
|
|
|
budget.setProjectId(vo.getProjectId());
|
|
|
budget.setParentId(vo2.getId());
|
|
@@ -438,7 +459,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
budget.setTaskDetail(vo2.getTaskDetail());
|
|
|
}
|
|
|
childrenList.addAll(vo2ChildrenList);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//无子计划
|
|
|
ProjectCostBudget budget = new ProjectCostBudget();
|
|
|
BeanUtils.copyProperties(vo2, budget);
|
|
@@ -455,6 +476,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 根据部门类型和日期查询计划
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @param date
|
|
|
* @return
|
|
@@ -467,28 +489,37 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
int month = Integer.parseInt(split[1]);
|
|
|
LocalDate startDate;
|
|
|
LocalDate endDate;
|
|
|
- startDate = LocalDate.of(year,month,1);
|
|
|
- if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(month)){
|
|
|
- endDate = LocalDate.of(year,month,31);
|
|
|
- }else {
|
|
|
+ startDate = LocalDate.of(year, month, 1);
|
|
|
+ if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(month)) {
|
|
|
+ endDate = LocalDate.of(year, month, 31);
|
|
|
+ } else {
|
|
|
if (month != 2) {
|
|
|
endDate = LocalDate.of(year, month, 30);
|
|
|
- }else {
|
|
|
- if (year % 4 == 0){
|
|
|
+ } else {
|
|
|
+ if (year % 4 == 0) {
|
|
|
endDate = LocalDate.of(year, month, 29);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
endDate = LocalDate.of(year, month, 28);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
List<ProjectCostBudgetVO> departmentPlan = baseMapper.getDepartmentPlan(type, startDate, endDate);
|
|
|
- if (departmentPlan != null && departmentPlan.size() > 0){
|
|
|
+ List<DictInfo> allTaskInfo = budgetMapper.getAllTaskInfo();
|
|
|
+ Map<Long, List<DictInfo>> taskMap = new HashMap<>();
|
|
|
+ if (allTaskInfo != null && allTaskInfo.size() > 0) {
|
|
|
+ taskMap = allTaskInfo.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(DictInfo::getId));
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("请选择任务类型");
|
|
|
+ }
|
|
|
+ if (departmentPlan != null && departmentPlan.size() > 0) {
|
|
|
for (ProjectCostBudgetVO vo : departmentPlan) {
|
|
|
- if (vo.getStatus() == 1 || vo.getStatus() == 4){
|
|
|
+ //如果计划未开始,或者已完成,或者是固定计划,则不显示开启暂停
|
|
|
+ if (vo.getStatus() == 1 || vo.getStatus() == 4 || taskMap.get(vo.getPlanTaskType()).get(0).getDictValue() == 2) {
|
|
|
vo.setStartOrStop(0);
|
|
|
- }else if (vo.getStatus() == 2){
|
|
|
+ } else if (vo.getStatus() == 2) {
|
|
|
vo.setStartOrStop(1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo.setStartOrStop(2);
|
|
|
}
|
|
|
}
|
|
@@ -498,23 +529,24 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 根据id修改状态
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @param status
|
|
|
*/
|
|
|
@Override
|
|
|
public void updateStatus(Long id, int status) {
|
|
|
- baseMapper.updateStatus(id,status);
|
|
|
+ baseMapper.updateStatus(id, status);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据起止日期获取工作日
|
|
|
*/
|
|
|
@Override
|
|
|
- public Integer getWorkDays(LocalDate startDate, LocalDate endDate,Long planTaskType) {
|
|
|
+ public Integer getWorkDays(LocalDate startDate, LocalDate endDate, Long planTaskType) {
|
|
|
DictInfo info = baseMapper.getTaskType(planTaskType);
|
|
|
- if (info.getDictValue().intValue() == 1){
|
|
|
- return new BigDecimal(startDate.until(endDate,ChronoUnit.DAYS)).intValue() + 1 ;
|
|
|
- }else {
|
|
|
+ if (info.getDictValue().intValue() == 2) {
|
|
|
+ return new BigDecimal(startDate.until(endDate, ChronoUnit.DAYS)).intValue() + 1;
|
|
|
+ } else {
|
|
|
return CommonUtil.getWorkDays(startDate, endDate);
|
|
|
}
|
|
|
}
|
|
@@ -542,16 +574,16 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
int month = Integer.parseInt(split[1]);
|
|
|
LocalDate startDate;
|
|
|
LocalDate endDate;
|
|
|
- startDate = LocalDate.of(year,month,1);
|
|
|
- if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(month)){
|
|
|
- endDate = LocalDate.of(year,month,31);
|
|
|
- }else {
|
|
|
+ startDate = LocalDate.of(year, month, 1);
|
|
|
+ if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(month)) {
|
|
|
+ endDate = LocalDate.of(year, month, 31);
|
|
|
+ } else {
|
|
|
if (month != 2) {
|
|
|
endDate = LocalDate.of(year, month, 30);
|
|
|
- }else {
|
|
|
- if (year % 4 == 0){
|
|
|
+ } else {
|
|
|
+ if (year % 4 == 0) {
|
|
|
endDate = LocalDate.of(year, month, 29);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
endDate = LocalDate.of(year, month, 28);
|
|
|
}
|
|
|
}
|
|
@@ -594,11 +626,11 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
for (ProjectCostBudget budget : list) {
|
|
|
//先生成总计划数组
|
|
|
if ((budget.getPlanStartTime().getMonthValue() == i && budget.getPlanStartTime().getYear() == year)
|
|
|
- || (budget.getPlanEndTime().getMonthValue() == i && budget.getPlanEndTime().getYear() == year)){
|
|
|
+ || (budget.getPlanEndTime().getMonthValue() == i && budget.getPlanEndTime().getYear() == year)) {
|
|
|
total1++;
|
|
|
- if (budget.getStatus().equals(4)){
|
|
|
+ if (budget.getStatus().equals(4)) {
|
|
|
total2++;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
total3++;
|
|
|
}
|
|
|
}
|
|
@@ -620,7 +652,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
mapList.add(vo2);
|
|
|
mapList.add(vo3);
|
|
|
return mapList;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -634,14 +666,14 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
LocalDate startDate;
|
|
|
LocalDate endDate;
|
|
|
//判断是否选择部门,如果选择了部门再判断是否选择了具体的人,如果没有选择具体的人则查询整个部门
|
|
|
- if (StringUtils.isBlank(start) || StringUtils.isBlank(end)){
|
|
|
- startDate = LocalDate.of(LocalDate.now().getYear(),1,1);
|
|
|
- endDate = LocalDate.of(LocalDate.now().getYear(),12,31);
|
|
|
- }else {
|
|
|
+ if (StringUtils.isBlank(start) || StringUtils.isBlank(end)) {
|
|
|
+ startDate = LocalDate.of(LocalDate.now().getYear(), 1, 1);
|
|
|
+ endDate = LocalDate.of(LocalDate.now().getYear(), 12, 31);
|
|
|
+ } else {
|
|
|
String[] s1 = start.split("-");
|
|
|
- startDate = LocalDate.of(Integer.parseInt(s1[0]),Integer.parseInt(s1[1]),1);
|
|
|
+ startDate = LocalDate.of(Integer.parseInt(s1[0]), Integer.parseInt(s1[1]), 1);
|
|
|
String[] s2 = end.split("-");
|
|
|
- endDate = LocalDate.of(Integer.parseInt(s2[0]),Integer.parseInt(s2[1]),1);
|
|
|
+ endDate = LocalDate.of(Integer.parseInt(s2[0]), Integer.parseInt(s2[1]), 1);
|
|
|
endDate = endDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
}
|
|
|
//获取时间段中的计划,默认是今年
|
|
@@ -692,25 +724,25 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|| (plan.getPlanEndTime().getYear() == startDate.getYear() && plan.getPlanEndTime().getMonthValue() == startDate.getMonthValue())) {
|
|
|
//计划统计图
|
|
|
total++;
|
|
|
- if (plan.getTaskApprove() == 1){
|
|
|
+ if (plan.getTaskApprove() == 1) {
|
|
|
finish++;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
unfinish++;
|
|
|
}
|
|
|
|
|
|
//风险计划统计图
|
|
|
- if (plan.getStatus() == 4){
|
|
|
- if (plan.getPlanEndTime().isBefore(plan.getPracticalFinishTime())){
|
|
|
+ if (plan.getStatus() == 4) {
|
|
|
+ if (plan.getPlanEndTime().isBefore(plan.getPracticalFinishTime())) {
|
|
|
//风险计划
|
|
|
risk++;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
normal++;
|
|
|
}
|
|
|
- }else {
|
|
|
- if (plan.getPlanEndTime().isBefore(LocalDate.now())){
|
|
|
+ } else {
|
|
|
+ if (plan.getPlanEndTime().isBefore(LocalDate.now())) {
|
|
|
//风险计划
|
|
|
risk++;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
normal++;
|
|
|
}
|
|
|
}
|
|
@@ -723,7 +755,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
l1.add(total);
|
|
|
l2.add(finish);
|
|
|
l3.add(unfinish);
|
|
|
- dateList.add(startDate.getYear()+"年"+startDate.getMonthValue()+"月");
|
|
|
+ dateList.add(startDate.getYear() + "年" + startDate.getMonthValue() + "月");
|
|
|
startDate = startDate.plusMonths(1);
|
|
|
}
|
|
|
//统计图集合
|
|
@@ -757,16 +789,18 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 获取当前项目所有预算已闭环的任务
|
|
|
+ *
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ProjectCostBudget> getProjectAllFinishedTask(Long projectId,Integer costType) {
|
|
|
- return baseMapper.getProjectAllFinishedTask(projectId,costType);
|
|
|
+ public List<ProjectCostBudget> getProjectAllFinishedTask(Long projectId, Integer costType) {
|
|
|
+ return baseMapper.getProjectAllFinishedTask(projectId, costType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取项目的所有实际费用
|
|
|
+ *
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
@@ -777,13 +811,14 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 获取一年的人工支出
|
|
|
+ *
|
|
|
* @param year
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public BigDecimal getYearStaffDisburse(int year) {
|
|
|
BigDecimal yearStaffDisburse = baseMapper.getYearStaffDisburse(year);
|
|
|
- if (yearStaffDisburse == null){
|
|
|
+ if (yearStaffDisburse == null) {
|
|
|
return new BigDecimal(0);
|
|
|
}
|
|
|
return yearStaffDisburse;
|
|
@@ -791,6 +826,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 按年查询所有支出
|
|
|
+ *
|
|
|
* @param y
|
|
|
* @return
|
|
|
*/
|
|
@@ -801,6 +837,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 按月查询所有计划支出
|
|
|
+ *
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
@@ -812,17 +849,19 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
|
|
|
/**
|
|
|
* 获取风险计划,如果参数为空获取所有
|
|
|
+ *
|
|
|
* @param projectId
|
|
|
* @param costType
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ProjectCostBudget> getRiskPlan(Long projectId,Integer costType) {
|
|
|
- return baseMapper.getRiskPlan(projectId,costType);
|
|
|
+ public List<ProjectCostBudget> getRiskPlan(Long projectId, Integer costType) {
|
|
|
+ return baseMapper.getRiskPlan(projectId, costType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据月获取计划闭环后实际金额
|
|
|
+ *
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
@@ -838,31 +877,31 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
public PlanFinishedRatioVO planFinishedRatio(Long deptId, Long userId, String start, String end) {
|
|
|
String tenantId = SecureUtil.getTenantId();
|
|
|
List<User> Employees = new ArrayList<>();
|
|
|
- if (deptId == null){
|
|
|
+ if (deptId == null) {
|
|
|
//查询所有员工
|
|
|
- Employees = baseMapper.getAllEmployees(tenantId,null,null);
|
|
|
- }else if (userId == null){
|
|
|
+ Employees = baseMapper.getAllEmployees(tenantId, null, null);
|
|
|
+ } else if (userId == null) {
|
|
|
//查询整个部门的员工
|
|
|
- Employees = baseMapper.getAllEmployees(tenantId,deptId,null);
|
|
|
- }else {
|
|
|
+ Employees = baseMapper.getAllEmployees(tenantId, deptId, null);
|
|
|
+ } else {
|
|
|
//查询指定员工
|
|
|
- Employees = baseMapper.getAllEmployees(tenantId,deptId,userId);
|
|
|
+ Employees = baseMapper.getAllEmployees(tenantId, deptId, userId);
|
|
|
}
|
|
|
- if (Employees != null && Employees.size() > 0 ){
|
|
|
+ if (Employees != null && Employees.size() > 0) {
|
|
|
PlanFinishedRatioVO vo = new PlanFinishedRatioVO();
|
|
|
List<String> names = new ArrayList<>();
|
|
|
List<Integer> ratios = new ArrayList<>();
|
|
|
LocalDate startDate;
|
|
|
LocalDate endDate;
|
|
|
//判断是否选择部门,如果选择了部门再判断是否选择了具体的人,如果没有选择具体的人则查询整个部门
|
|
|
- if (StringUtils.isBlank(start) || StringUtils.isBlank(end)){
|
|
|
- startDate = LocalDate.of(LocalDate.now().getYear(),1,1);
|
|
|
- endDate = LocalDate.of(LocalDate.now().getYear(),12,31);
|
|
|
- }else {
|
|
|
+ if (StringUtils.isBlank(start) || StringUtils.isBlank(end)) {
|
|
|
+ startDate = LocalDate.of(LocalDate.now().getYear(), 1, 1);
|
|
|
+ endDate = LocalDate.of(LocalDate.now().getYear(), 12, 31);
|
|
|
+ } else {
|
|
|
String[] s1 = start.split("-");
|
|
|
- startDate = LocalDate.of(Integer.parseInt(s1[0]),Integer.parseInt(s1[1]),1);
|
|
|
+ startDate = LocalDate.of(Integer.parseInt(s1[0]), Integer.parseInt(s1[1]), 1);
|
|
|
String[] s2 = end.split("-");
|
|
|
- endDate = LocalDate.of(Integer.parseInt(s2[0]),Integer.parseInt(s2[1]),1);
|
|
|
+ endDate = LocalDate.of(Integer.parseInt(s2[0]), Integer.parseInt(s2[1]), 1);
|
|
|
endDate = endDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
}
|
|
|
//获取员工id集合
|
|
@@ -894,7 +933,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
} else {
|
|
|
ratios.add(0);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ratios.add(0);
|
|
|
}
|
|
|
}
|
|
@@ -945,20 +984,20 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
public ProjectCostBudgetVO2 updateMainPlan(ProjectCostBudgetVO2 vo2) {
|
|
|
//先判断如果数据都没填写,则设置可以分解子计划
|
|
|
if (vo2.getPlanTaskType() == null && StringUtils.isBlank(vo2.getPlanTaskDesc()) && StringUtils.isBlank(vo2.getPlanTarget())
|
|
|
- && vo2.getPlanStartTime() == null && vo2.getPlanEndTime() == null){
|
|
|
+ && vo2.getPlanStartTime() == null && vo2.getPlanEndTime() == null) {
|
|
|
vo2.setPlanTaskTypeValue(null);
|
|
|
vo2.setPlanDays(null);
|
|
|
vo2.setIsShowChildren(1);
|
|
|
return vo2;
|
|
|
}
|
|
|
//如果填写了数据,则检查数据是否填写完成
|
|
|
- if (vo2.getPlanTaskType() == null){
|
|
|
+ if (vo2.getPlanTaskType() == null) {
|
|
|
throw new ServiceException("请选择任务类型");
|
|
|
- }else if (StringUtils.isBlank(vo2.getPlanTaskDesc())){
|
|
|
+ } else if (StringUtils.isBlank(vo2.getPlanTaskDesc())) {
|
|
|
throw new ServiceException("请填写任务描述");
|
|
|
- }else if (StringUtils.isBlank(vo2.getPlanTarget())){
|
|
|
+ } else if (StringUtils.isBlank(vo2.getPlanTarget())) {
|
|
|
throw new ServiceException("请填写完成指标");
|
|
|
- }else if (vo2.getPlanStartTime() == null || vo2.getPlanEndTime() == null){
|
|
|
+ } else if (vo2.getPlanStartTime() == null || vo2.getPlanEndTime() == null) {
|
|
|
throw new ServiceException("请选择计划起止日期");
|
|
|
}
|
|
|
//如果数据都填写完成,则根据任务类型,设置工作日,并且设置子计划不可分解
|
|
@@ -967,10 +1006,10 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
vo2.setPlanTaskTypeValue(taskType.getDictName());
|
|
|
int type = taskType.getDictValue().intValue();
|
|
|
//根据任务类型设置父计划的工作天数,固定任务1,临时任务2
|
|
|
- if (type == 1){
|
|
|
- vo2.setPlanDays(new BigDecimal(vo2.getPlanStartTime().until(vo2.getPlanEndTime(),ChronoUnit.DAYS) + 1));
|
|
|
- }else {
|
|
|
- if (vo2.getPlanStartTime().until(vo2.getPlanEndTime(),ChronoUnit.DAYS) > 35){
|
|
|
+ if (type == 2) {
|
|
|
+ vo2.setPlanDays(new BigDecimal(vo2.getPlanStartTime().until(vo2.getPlanEndTime(), ChronoUnit.DAYS) + 1));
|
|
|
+ } else {
|
|
|
+ if (vo2.getPlanStartTime().until(vo2.getPlanEndTime(), ChronoUnit.DAYS) > 35) {
|
|
|
throw new ServiceException("请不要制定超过一个月的临时计划");
|
|
|
// //工作天数,工具只能获取50天之内的
|
|
|
// LocalDate startDate = vo2.getPlanStartTime();
|
|
@@ -981,14 +1020,14 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
// startDate = startDate.plusDays(36L);
|
|
|
// }
|
|
|
// vo2.setPlanDays(new BigDecimal(i));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setPlanDays(new BigDecimal(CommonUtil.getWorkDays(vo2.getPlanStartTime(), vo2.getPlanEndTime())));
|
|
|
}
|
|
|
}
|
|
|
- if (vo2.getPlanDays().intValue() > vo2.getBudgetDays().intValue()){
|
|
|
- vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长("+(vo2.getPlanDays().intValue() - vo2.getBudgetDays().intValue())+")天");
|
|
|
+ if (vo2.getPlanDays().intValue() > vo2.getBudgetDays().intValue()) {
|
|
|
+ vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长(" + (vo2.getPlanDays().intValue() - vo2.getBudgetDays().intValue()) + ")天");
|
|
|
vo2.setTaskFinishedStatus(1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setTaskFinishedStatus(0);
|
|
|
}
|
|
|
vo2.setIsShowChildren(0);
|
|
@@ -1002,13 +1041,13 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
public ProjectCostBudgetVO2 updateChildrenPlan(ProjectCostBudgetVO2 vo2) {
|
|
|
//如果子计划为空,则清空父计划,然后修改可以编辑父计划
|
|
|
List<ProjectCostBudgetVO2> list = vo2.getChildrenList();
|
|
|
- if (list != null && list.size() > 0){
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
//获取子计划任务类型,用于判断子计划类型是否一致
|
|
|
ProjectCostBudgetVO2 budgetVO2 = list.get(0);
|
|
|
Long taskType;
|
|
|
- if (budgetVO2.getPlanTaskType() == null){
|
|
|
+ if (budgetVO2.getPlanTaskType() == null) {
|
|
|
throw new ServiceException("请选择任务类型");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
taskType = budgetVO2.getPlanTaskType();
|
|
|
}
|
|
|
DictInfo task = baseMapper.getTaskType(taskType);
|
|
@@ -1022,52 +1061,52 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
Boolean isFinished = true;
|
|
|
for (ProjectCostBudgetVO2 l : list) {
|
|
|
//校验数据
|
|
|
- if (l.getPlanTaskType() == null){
|
|
|
+ if (l.getPlanTaskType() == null) {
|
|
|
throw new ServiceException("请选择任务类型");
|
|
|
- }else if (StringUtils.isBlank(l.getPlanTaskDesc())){
|
|
|
+ } else if (StringUtils.isBlank(l.getPlanTaskDesc())) {
|
|
|
throw new ServiceException("请填写任务描述");
|
|
|
- }else if (StringUtils.isBlank(l.getPlanTarget())){
|
|
|
+ } else if (StringUtils.isBlank(l.getPlanTarget())) {
|
|
|
throw new ServiceException("请填写完成指标");
|
|
|
- }else if (l.getPlanStartTime() == null || l.getPlanEndTime() == null){
|
|
|
+ } else if (l.getPlanStartTime() == null || l.getPlanEndTime() == null) {
|
|
|
throw new ServiceException("请选择计划起止日期");
|
|
|
}
|
|
|
//校验类型
|
|
|
- if (!taskType.equals(l.getPlanTaskType())){
|
|
|
+ if (!taskType.equals(l.getPlanTaskType())) {
|
|
|
throw new ServiceException("子计划任务类型不一致");
|
|
|
}
|
|
|
- if (budgetVO2.getTaskApprove() == null || budgetVO2.getTaskApprove() != 1){
|
|
|
+ if (budgetVO2.getTaskApprove() == null || budgetVO2.getTaskApprove() != 1) {
|
|
|
isFinished = false;
|
|
|
}
|
|
|
//计算总天数
|
|
|
if (l.getPlanDays() != null) {
|
|
|
workDays = workDays.add(l.getPlanDays());
|
|
|
- }else {
|
|
|
- if (task.getDictValue().intValue() == 1) {
|
|
|
- l.setPlanDays(new BigDecimal(l.getPlanStartTime().until(l.getPlanEndTime(),ChronoUnit.DAYS) + 1));
|
|
|
+ } else {
|
|
|
+ if (task.getDictValue().intValue() == 2) {
|
|
|
+ l.setPlanDays(new BigDecimal(l.getPlanStartTime().until(l.getPlanEndTime(), ChronoUnit.DAYS) + 1));
|
|
|
} else {
|
|
|
if (l.getPlanStartTime().until(l.getPlanEndTime(), ChronoUnit.DAYS) > 35) {
|
|
|
throw new ServiceException("请不要制定超过一个月的临时计划");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
l.setPlanDays(new BigDecimal(CommonUtil.getWorkDays(budgetVO2.getPlanStartTime(), budgetVO2.getPlanEndTime())));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//计算最大日期和最小日期
|
|
|
- if (l.getPlanStartTime().isBefore(startDate)){
|
|
|
+ if (l.getPlanStartTime().isBefore(startDate)) {
|
|
|
startDate = l.getPlanStartTime();
|
|
|
}
|
|
|
- if (l.getPlanEndTime().isAfter(endDate)){
|
|
|
+ if (l.getPlanEndTime().isAfter(endDate)) {
|
|
|
endDate = l.getPlanEndTime();
|
|
|
}
|
|
|
//拼接子计划的任务描述
|
|
|
- descStr.append(j + "."+l.getPlanTaskDesc()+"。");
|
|
|
+ descStr.append(j + "." + l.getPlanTaskDesc() + "、");
|
|
|
//拼接子计划的完成指标
|
|
|
- targetStr.append(j+"."+l.getPlanTarget()+"。");
|
|
|
+ targetStr.append(j + "." + l.getPlanTarget() + "、");
|
|
|
j++;
|
|
|
}
|
|
|
|
|
|
//所有子计划完成,设置父计划为绿色
|
|
|
- if (isFinished){
|
|
|
+ if (isFinished) {
|
|
|
vo2.setTaskFinishedStatus(2);
|
|
|
}
|
|
|
//计算是否超过预算
|
|
@@ -1092,10 +1131,10 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
vo2.setPlanStartTime(startDate);
|
|
|
vo2.setPlanEndTime(endDate);
|
|
|
//根据任务类型设置父计划的工作天数,固定任务1,临时任务2
|
|
|
- if (task.getDictValue().intValue() == 1){
|
|
|
- vo2.setPlanDays(new BigDecimal(startDate.until(endDate,ChronoUnit.DAYS)+ 1));
|
|
|
- }else {
|
|
|
- if (startDate.until(endDate,ChronoUnit.DAYS) > 35){
|
|
|
+ if (task.getDictValue().intValue() == 2) {
|
|
|
+ vo2.setPlanDays(new BigDecimal(startDate.until(endDate, ChronoUnit.DAYS) + 1));
|
|
|
+ } else {
|
|
|
+ if (startDate.until(endDate, ChronoUnit.DAYS) > 35) {
|
|
|
throw new ServiceException("请不要制定超过一个月的临时计划");
|
|
|
// //工作天数,工具只能获取50天之内的
|
|
|
// int i = 0;
|
|
@@ -1104,55 +1143,117 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
// startDate = startDate.plusDays(36L);
|
|
|
// }
|
|
|
// vo2.setPlanDays(new BigDecimal(i));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setPlanDays(new BigDecimal(CommonUtil.getWorkDays(startDate, endDate)));
|
|
|
}
|
|
|
}
|
|
|
vo2.setIsShowEdit(0);
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
vo2.setPlanTaskTypeValue(null);
|
|
|
- vo2.setPlanTaskType(null);
|
|
|
- vo2.setPlanTaskDesc(null);
|
|
|
- vo2.setPlanTarget(null);
|
|
|
- vo2.setPlanStartTime(null);
|
|
|
- vo2.setPlanEndTime(null);
|
|
|
- vo2.setPlanDays(null);
|
|
|
- vo2.setIsShowEdit(1);
|
|
|
- return vo2;
|
|
|
+ vo2.setPlanTaskType(null);
|
|
|
+ vo2.setPlanTaskDesc(null);
|
|
|
+ vo2.setPlanTarget(null);
|
|
|
+ vo2.setPlanStartTime(null);
|
|
|
+ vo2.setPlanEndTime(null);
|
|
|
+ vo2.setPlanDays(null);
|
|
|
+ vo2.setIsShowEdit(1);
|
|
|
+ return vo2;
|
|
|
}
|
|
|
return vo2;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 任务完成之后统计工作时间和人工成本
|
|
|
+ *
|
|
|
+ * @param PlanId 计划id
|
|
|
+ * @param practicalFinishTime 实际完成时间
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void taskFinishedStats(Long PlanId, LocalDate practicalFinishTime) {
|
|
|
+ //先获取当前计划
|
|
|
+ ProjectCostBudget budget = this.getById(PlanId);
|
|
|
+ budget.setStatus(4);
|
|
|
+ budget.setTaskApprove(1);
|
|
|
+ budget.setPracticalFinishTime(practicalFinishTime);
|
|
|
+ DictInfo dictInfo = baseMapper.getTaskType(budget.getPlanTaskType());
|
|
|
+ int taskType = dictInfo.getDictValue().intValue();
|
|
|
+ //计划为临时计划,则不计算金额直接闭环
|
|
|
+ if (taskType == 2) {
|
|
|
+ this.updateById(budget);
|
|
|
+ } else {
|
|
|
+ //获取任务人工资
|
|
|
+ User userInfo = baseMapper.getUserInfo(budget.getTaskUser());
|
|
|
+ if (userInfo.getOneMoney() == null) {
|
|
|
+ throw new ServiceException("没有为任务人设置工资");
|
|
|
+ }
|
|
|
+ Double money = userInfo.getOneMoney();
|
|
|
+ //为固定计划,则获取最后一条任务日志
|
|
|
+ DepartmentPlanLog planLog = logMapper.getNewestPlanLog(PlanId);
|
|
|
+ Integer realWorkDays = 0;
|
|
|
+ //日志类型为暂停,和status=3则 直接用实际工作时间
|
|
|
+ if (planLog.getStatus() == 0) {
|
|
|
+ //实际工作时间
|
|
|
+ realWorkDays = planLog.getRealWorkDays();
|
|
|
+ } else {
|
|
|
+ //日志类型为开启,和status=2则 计算计划结束时间到中途开启时间 + 实际工作时间
|
|
|
+ if (planLog.getOpenPlanStartTime() == null) {
|
|
|
+ //中途没暂停,开启过任务
|
|
|
+ if (planLog.getRealPlanStartTime().until(practicalFinishTime, ChronoUnit.DAYS) > 35) {
|
|
|
+ throw new ServiceException("固定计划完成周期超过一个月,请联系管理员");
|
|
|
+ } else {
|
|
|
+ realWorkDays = CommonUtil.getWorkDays(planLog.getRealPlanStartTime(), practicalFinishTime);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //中途暂停,开启过任务
|
|
|
+ //获取上次暂停时实际工作日
|
|
|
+ Integer days = planLog.getRealWorkDays();
|
|
|
+ //计算这次开启后到任务完成之间的工作日
|
|
|
+ if (planLog.getOpenPlanStartTime().until(practicalFinishTime, ChronoUnit.DAYS) > 35) {
|
|
|
+ throw new ServiceException("固定计划完成周期超过一个月,请联系管理员");
|
|
|
+ } else {
|
|
|
+ int day = CommonUtil.getWorkDays(planLog.getOpenPlanStartTime(), practicalFinishTime);
|
|
|
+ realWorkDays = days + day;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置status=4,taskAPP=1,实际工资,实际工资天数,实际完成时间,如果计划处于暂停中,那么实际完成时间就是暂停时间
|
|
|
+ }
|
|
|
+ budget.setPracticalTaskDays(new BigDecimal(realWorkDays));
|
|
|
+ //实际人工支出
|
|
|
+ budget.setActualTotalMoney(new BigDecimal(realWorkDays).multiply(new BigDecimal(money)));
|
|
|
+ this.updateById(budget);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统计一行的几个总金额
|
|
|
*/
|
|
|
- public void countMoney(ProjectCostBudget budget){
|
|
|
+ public void countMoney(ProjectCostBudget budget) {
|
|
|
BigDecimal postMoney;
|
|
|
- if (budget.getPostType() != null && budget.getPostType() > 0){
|
|
|
+ if (budget.getPostType() != null && budget.getPostType() > 0) {
|
|
|
Double money = baseMapper.getPostMoney(budget.getPostType());
|
|
|
- postMoney = new BigDecimal(money+"");
|
|
|
- }else {
|
|
|
+ postMoney = new BigDecimal(money + "");
|
|
|
+ } else {
|
|
|
postMoney = new BigDecimal("0");
|
|
|
}
|
|
|
//人工成本 = 人员数量 * 单价 * 天数
|
|
|
if (budget.getStaffCount() != null && budget.getBudgetDays() != null) {
|
|
|
budget.setBudgetStaffCost(budget.getStaffCount().multiply(postMoney).multiply(budget.getBudgetDays()));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
budget.setBudgetStaffCost(new BigDecimal("0"));
|
|
|
}
|
|
|
//外包金额 = 外包单价 * 外包数量
|
|
|
if (budget.getOutsourcePeopleCount() != null && budget.getOutsourceUnitPrice() != null) {
|
|
|
budget.setOutsourceCountMoney(budget.getOutsourceUnitPrice().multiply(budget.getOutsourcePeopleCount()));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
budget.setOutsourceCountMoney(new BigDecimal("0"));
|
|
|
}
|
|
|
//判断差旅费
|
|
|
- if (budget.getBudgetTravelExpense() == null){
|
|
|
+ if (budget.getBudgetTravelExpense() == null) {
|
|
|
budget.setBudgetTravelExpense(new BigDecimal("0"));
|
|
|
}
|
|
|
//判断其他预算金额
|
|
|
- if (budget.getOtherBudgetMoney() == null){
|
|
|
+ if (budget.getOtherBudgetMoney() == null) {
|
|
|
budget.setOtherBudgetMoney(new BigDecimal("0"));
|
|
|
}
|
|
|
//总预算 = 人工成本 + 外包金额 + 差旅费 + 其他费用
|