|
@@ -441,6 +441,22 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
list.addAll(constructUnit.get(i));
|
|
|
}
|
|
|
}
|
|
|
+ //获取当前所有岗位类型,用于统计计划人工支出
|
|
|
+ List<DictInfo> postType = baseMapper.getAllPostType();
|
|
|
+ if (postType == null || postType.size() <= 0){
|
|
|
+ throw new ServiceException("保存失败,没有配置岗位类型");
|
|
|
+ }
|
|
|
+ //根据岗位id分类
|
|
|
+ Map<Long, List<DictInfo>> map = postType.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(DictInfo::getId));
|
|
|
+ //获取当前任务类型,如果是临时任务,就不用计算人工成本
|
|
|
+ List<DictInfo> taskInfo = baseMapper.getAllTaskInfo();
|
|
|
+ if (taskInfo == null || taskInfo.size() <= 0){
|
|
|
+ throw new ServiceException("保存失败,没有配置任务类型");
|
|
|
+ }
|
|
|
+ //根据任务类型id分类
|
|
|
+ Map<Long, List<DictInfo>> map2 = taskInfo.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(DictInfo::getId));
|
|
|
List<ProjectCostBudget> childrenList = new ArrayList<>();
|
|
|
List<ProjectCostBudget> parentList = new ArrayList<>();
|
|
|
//把所有子计划分离出来,并且设置父类id
|
|
@@ -448,6 +464,14 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
List<ProjectCostBudgetVO2> vo2ChildrenList = vo2.getChildrenList();
|
|
|
if (vo2ChildrenList != null && vo2ChildrenList.size() > 0){
|
|
|
for (ProjectCostBudget budget : vo2ChildrenList) {
|
|
|
+ //如果计划正在进行中或者已经完成,则跳过
|
|
|
+ if (budget.getStatus() != null && budget.getStatus() != 1){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果保存太快,没有生成planDays,就查询
|
|
|
+ if (budget.getPlanDays() == null || budget.getPlanDays().intValue() == 0){
|
|
|
+ budget.setPlanDays(new BigDecimal( CommonUtil.getWorkDays(budget.getPlanStartTime(),budget.getPlanEndTime())));
|
|
|
+ }
|
|
|
budget.setProjectId(vo.getProjectId());
|
|
|
budget.setParentId(vo2.getId());
|
|
|
budget.setCostType(vo2.getCostType());
|
|
@@ -456,12 +480,57 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
budget.setBudgetType(vo2.getBudgetType());
|
|
|
budget.setProjectProcess(vo2.getProjectProcess());
|
|
|
budget.setTaskDetail(vo2.getTaskDetail());
|
|
|
+ budget.setPostType(vo2.getPostType());
|
|
|
+ //只计算固定计划的人工成本
|
|
|
+ if (map2.get(budget.getPlanTaskType()).get(0).getDictValue() == 1) {
|
|
|
+ //计划人工支出
|
|
|
+ budget.setPlanStaffCost(budget.getPlanDays().multiply(new BigDecimal(map.get(vo2.getPostType()).get(0).getDictValue())));
|
|
|
+ //如果跨月
|
|
|
+ if (budget.getPlanStartTime().getMonthValue() != budget.getPlanEndTime().getMonthValue()) {
|
|
|
+ budget.setPlanIsTwoMonth(1);
|
|
|
+ //计算开始到月底多少个工作日
|
|
|
+ int days = CommonUtil.getWorkDays(budget.getPlanStartTime(), LocalDate.of(vo2.getPlanStartTime().getYear(), budget.getPlanStartTime().getMonthValue(), budget.getPlanStartTime().getMonth().maxLength()));
|
|
|
+ if (days > budget.getPlanDays().intValue()){
|
|
|
+ budget.setPlanStartMoney(budget.getPlanStaffCost());
|
|
|
+ budget.setPlanEndMoney(new BigDecimal(0));
|
|
|
+ }else {
|
|
|
+ budget.setPlanStartMoney(new BigDecimal(days).multiply(new BigDecimal(map.get(budget.getPostType()).get(0).getDictValue())));
|
|
|
+ budget.setPlanEndMoney(budget.getPlanStaffCost().subtract(budget.getPlanStartMoney()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
childrenList.addAll(vo2ChildrenList);
|
|
|
}else {
|
|
|
//无子计划
|
|
|
ProjectCostBudget budget = new ProjectCostBudget();
|
|
|
BeanUtils.copyProperties(vo2, budget);
|
|
|
+ //如果主计划被清空,然后把计划金额也清空
|
|
|
+ if (budget.getPlanTaskType() == null){
|
|
|
+ budget.setPlanIsTwoMonth(0);
|
|
|
+ budget.setPlanStartMoney(new BigDecimal(0));
|
|
|
+ budget.setPlanEndMoney(new BigDecimal(0));
|
|
|
+ }else {
|
|
|
+ //存在数据,则判断是否是固定计划
|
|
|
+ if (map2.get(budget.getPlanTaskType()).get(0).getDictValue() == 1) {
|
|
|
+ //计划人工支出
|
|
|
+ budget.setPlanStaffCost(budget.getPlanDays().multiply(new BigDecimal(map.get(budget.getPostType()).get(0).getDictValue())));
|
|
|
+ //如果跨月
|
|
|
+ if (budget.getPlanStartTime().getMonthValue() != budget.getPlanEndTime().getMonthValue()) {
|
|
|
+ budget.setPlanIsTwoMonth(1);
|
|
|
+ //计算开始到月底多少个工作日
|
|
|
+ int days = CommonUtil.getWorkDays(budget.getPlanStartTime(), LocalDate.of(budget.getPlanStartTime().getYear(), budget.getPlanStartTime().getMonthValue(), budget.getPlanStartTime().getMonth().maxLength()));
|
|
|
+ if (days > budget.getPlanDays().intValue()){
|
|
|
+ budget.setPlanStartMoney(budget.getPlanStaffCost());
|
|
|
+ budget.setPlanEndMoney(new BigDecimal(0));
|
|
|
+ }else {
|
|
|
+ budget.setPlanStartMoney(new BigDecimal(days).multiply(new BigDecimal(map.get(budget.getPostType()).get(0).getDictValue())));
|
|
|
+ budget.setPlanEndMoney(budget.getPlanStaffCost().subtract(budget.getPlanStartMoney()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
parentList.add(budget);
|
|
|
}
|
|
|
}
|
|
@@ -2104,46 +2173,27 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
List<ProjectCostBudget> budgets = baseMapper.getBudgetByYear(y);
|
|
|
List<BigDecimal> list = new ArrayList<>();
|
|
|
if (budgets != null && budgets.size() > 0){
|
|
|
- //获取当前所有用户
|
|
|
-
|
|
|
for (int i = 0; i < 12; i++) {
|
|
|
BigDecimal big = new BigDecimal(0);
|
|
|
for (ProjectCostBudget budget : budgets) {
|
|
|
//如果计划实际开始时间和实际结束时间中有当月
|
|
|
if ((budget.getPracticalFinishTime().getMonthValue() == (i+1) && budget.getPracticalFinishTime().getYear() == y)
|
|
|
|| ((budget.getRealPlanStartTime().getMonthValue() == (i+1)) && budget.getRealPlanStartTime().getYear() == y)){
|
|
|
- //如果计划开始时间和结束时间在同一个月中,则直接算入当月
|
|
|
- if (budget.getPracticalFinishTime().getMonthValue() == budget.getRealPlanStartTime().getMonthValue()) {
|
|
|
- big = big.add(budget.getActualTotalMoney());
|
|
|
- }else {
|
|
|
- //计划实际开始时间和结束时间不在一个月中,
|
|
|
- // 如果实际结束时间是1月,则计算从1月1号到实际结束时间的工作日
|
|
|
- if (budget.getPracticalFinishTime().getMonthValue() == 1 && budget.getPracticalFinishTime().getYear() == y){
|
|
|
- int workDays = CommonUtil.getWorkDays(LocalDate.of(y, 1, 1), budget.getPracticalFinishTime());
|
|
|
- //如果工作日大于实际工作时间,则直接使用人工成本
|
|
|
- if (workDays > budget.getPracticalTaskDays().intValue()){
|
|
|
- big = big.add(budget.getActualTotalMoney());
|
|
|
- }else {
|
|
|
- //如果工作日小于实际工作时间,则时间乘以个人工资
|
|
|
- big = big.add(budget.getActualTotalMoney());
|
|
|
- }
|
|
|
- }else if (budget.getRealPlanStartTime().getMonthValue() == 12 && budget.getRealPlanStartTime().getYear() == y){
|
|
|
- //如果开始时间是12月,则计算结束时间为当年12月31日的工作日
|
|
|
- int workDays = CommonUtil.getWorkDays(budget.getRealPlanStartTime(), LocalDate.of(y, 12, 1));
|
|
|
- //如果工作日大于实际工作时间,则直接使用人工成本
|
|
|
- if (workDays > budget.getPracticalTaskDays().intValue()){
|
|
|
- big = big.add(budget.getActualTotalMoney());
|
|
|
- }else {
|
|
|
- //如果工作日小于实际工作时间,则时间乘以个人工资
|
|
|
- big = big.add(budget.getActualTotalMoney());
|
|
|
- }
|
|
|
+ //如果实际结束时间是当月
|
|
|
+ if ((budget.getPracticalFinishTime().getMonthValue() == (i+1) && budget.getPracticalFinishTime().getYear() == y)) {
|
|
|
+ if (budget.getIsTwoMonth() == 0){
|
|
|
+ //人工成本没跨月,证明开始时间和结束时间是同一个月,直接使用人工成本到当月
|
|
|
+ big = big.add(budget.getActualTotalMoney());
|
|
|
}else {
|
|
|
- //开始时间和结束时间不跨年
|
|
|
- //如果开始时间是当月
|
|
|
- //先获取实际开始当月的工作日,如果这个工作日大于实际工时,那么直接使用人工成本到这个月
|
|
|
- //如果工作日小于实际工时,则用工作日除以实际工时,乘以人工成本,然后下个月加上
|
|
|
- //如果结束时间是当月
|
|
|
-
|
|
|
+ big = big.add(budget.getPracticalEndMoney());
|
|
|
+ }
|
|
|
+ ////如果实际开始时间是当月
|
|
|
+ }else if ((budget.getRealPlanStartTime().getMonthValue() == (i+1)) && budget.getRealPlanStartTime().getYear() == y){
|
|
|
+ if (budget.getIsTwoMonth() == 0){
|
|
|
+ //人工成本没跨月,证明开始时间和结束时间是同一个月,直接使用人工成本到当月
|
|
|
+ big = big.add(budget.getActualTotalMoney());
|
|
|
+ }else {
|
|
|
+ big = big.add(budget.getPracticalStartMoney());
|
|
|
}
|
|
|
}
|
|
|
}
|