|
@@ -1294,6 +1294,22 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
budget.setPracticalTaskDays(new BigDecimal(realWorkDays));
|
|
|
//实际人工支出
|
|
|
budget.setActualTotalMoney(new BigDecimal(realWorkDays).multiply(new BigDecimal(money)));
|
|
|
+ //判断是否跨月
|
|
|
+ if (budget.getRealPlanStartTime().getMonthValue() != budget.getPracticalFinishTime().getMonthValue()){
|
|
|
+ budget.setIsTwoMonth(1);
|
|
|
+ int day = CommonUtil.getWorkDays(budget.getRealPlanStartTime(),LocalDate.of(budget.getRealPlanStartTime().getYear(),budget.getRealPlanStartTime().getMonthValue(),budget.getRealPlanStartTime().getMonth().maxLength()));
|
|
|
+ if (day < realWorkDays){
|
|
|
+ budget.setPracticalStartMoney(new BigDecimal(day).multiply(new BigDecimal(money)));
|
|
|
+ budget.setPracticalEndMoney(budget.getActualTotalMoney().subtract(budget.getPracticalStartMoney()));
|
|
|
+ }else {
|
|
|
+ budget.setPracticalStartMoney(budget.getActualTotalMoney());
|
|
|
+ budget.setPracticalEndMoney(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ budget.setIsTwoMonth(0);
|
|
|
+ }
|
|
|
+ //如果跨月,则计算开始月人工成本和结束月人工成本
|
|
|
+ //
|
|
|
baseMapper.updateByBudgetId(budget);
|
|
|
}
|
|
|
}
|
|
@@ -2084,14 +2100,52 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
*/
|
|
|
@Override
|
|
|
public List<BigDecimal> getAllMonthStaffCostByYear(int y) {
|
|
|
+ //获取已经闭环的任务
|
|
|
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)){
|
|
|
- big = big.add(budget.getActualTotalMoney());
|
|
|
+ //如果计划实际开始时间和实际结束时间中有当月
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //开始时间和结束时间不跨年
|
|
|
+ //如果开始时间是当月
|
|
|
+ //先获取实际开始当月的工作日,如果这个工作日大于实际工时,那么直接使用人工成本到这个月
|
|
|
+ //如果工作日小于实际工时,则用工作日除以实际工时,乘以人工成本,然后下个月加上
|
|
|
+ //如果结束时间是当月
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
list.add(big);
|