|
|
@@ -2,6 +2,7 @@
|
|
|
package com.wx.blink.backend.manager;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -9,10 +10,7 @@ import com.wx.blink.backend.domain.dataobject.MateDeliveryDayReportDO;
|
|
|
import com.wx.blink.backend.domain.dto.*;
|
|
|
import com.wx.blink.backend.domain.qry.MateDeliveryCommonQry;
|
|
|
import com.wx.blink.backend.domain.qry.MateDeliveryDayReportQry;
|
|
|
-import com.wx.blink.backend.domain.vo.MateDeliveryDayCostStructureVO;
|
|
|
-import com.wx.blink.backend.domain.vo.MateDeliveryDayReportSummary;
|
|
|
-import com.wx.blink.backend.domain.vo.MateDeliveryDayReportUnSubmitVO;
|
|
|
-import com.wx.blink.backend.domain.vo.MateEmployeeDaySalaryVO;
|
|
|
+import com.wx.blink.backend.domain.vo.*;
|
|
|
import com.wx.blink.backend.objectmapper.MateDeliveryDayReportMapper;
|
|
|
import com.wx.blink.backend.repository.MateDeliveryDayReportRepository;
|
|
|
import com.wx.blink.backend.repository.MateDeliveryTaskRepository;
|
|
|
@@ -33,6 +31,7 @@ import java.math.RoundingMode;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -285,23 +284,211 @@ public class MateDeliveryDayReportServiceImpl extends ServiceImpl<MateDeliveryDa
|
|
|
//计算人员的薪资成本
|
|
|
List<MateEmployeeDaySalaryVO> daySalaryList = baseMapper.queryEmployeeDaySalaryList(date, yearMonth);
|
|
|
BigDecimal totalSalary = BigDecimal.ZERO;
|
|
|
- BigDecimal eight = BigDecimal.valueOf(8);
|
|
|
+ BigDecimal salaryDays = BigDecimal.valueOf(days);
|
|
|
+ BigDecimal eight = BigDecimal.valueOf(8);
|
|
|
+
|
|
|
for (MateEmployeeDaySalaryVO daySalary : daySalaryList) {
|
|
|
- BigDecimal workHour = BigDecimal.valueOf(daySalary.getWorkHour());
|
|
|
- BigDecimal oneDaySalary = daySalary.getSalary()
|
|
|
- .multiply(workHour)
|
|
|
+ BigDecimal dailySalary = daySalary.getSalary()
|
|
|
+ .divide(salaryDays, 2, RoundingMode.HALF_UP);
|
|
|
+ // 当天工资 = 日薪 * 实际工时 / 8
|
|
|
+ BigDecimal oneDaySalary = dailySalary
|
|
|
+ .multiply(BigDecimal.valueOf(daySalary.getWorkHour()))
|
|
|
.divide(eight, 2, RoundingMode.HALF_UP);
|
|
|
-
|
|
|
totalSalary = totalSalary.add(oneDaySalary);
|
|
|
}
|
|
|
vo.setSalaryCost(totalSalary);
|
|
|
//计算当天的人员驻场补贴
|
|
|
+ BigDecimal residentFixedSubsidy = baseMapper.queryResidentFixedSubsidyByDate(date);
|
|
|
+ vo.setResidentFixedSubsidy(residentFixedSubsidy == null ? BigDecimal.ZERO : residentFixedSubsidy);
|
|
|
//计算当天办结的报销
|
|
|
+ BigDecimal expenseAmount = baseMapper.queryExpenseAmountByDate(date);
|
|
|
+ vo.setCostExpense(expenseAmount == null ? BigDecimal.ZERO : expenseAmount);
|
|
|
//计算各类项目的预计产值
|
|
|
+ List<MateDeliveryCategorySubmitDaysVO> categorySubmitDaysList = baseMapper.queryCategorySubmitDaysList(date);
|
|
|
+ for (MateDeliveryCategorySubmitDaysVO categorySubmitDaysVO : categorySubmitDaysList) {
|
|
|
+ String category = categorySubmitDaysVO.getDeliveryCategory();
|
|
|
+ BigDecimal origin = categorySubmitDaysVO.getSubmitDays();
|
|
|
+ BigDecimal result;
|
|
|
+ if ("01".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(800));
|
|
|
+ vo.setJecnExpectOutput(result);
|
|
|
+ } else if ("02".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(1000));
|
|
|
+ vo.setAuthineExpectOutput(result);
|
|
|
+ } else if ("03".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(800));
|
|
|
+ vo.setSeaconExpectOutput(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
//计算办公地租金
|
|
|
BigDecimal totalRent = new BigDecimal("10000");
|
|
|
BigDecimal dailyRent = totalRent.divide(new BigDecimal(days), 2, RoundingMode.HALF_UP);
|
|
|
- vo.setRent(dailyRent);
|
|
|
- return null;
|
|
|
+ vo.setRent(dailyRent == null ? BigDecimal.ZERO : dailyRent);
|
|
|
+ //计算盈利金额
|
|
|
+ vo.setProfitAmount(vo.getJecnExpectOutput().add(vo.getAuthineExpectOutput()).add(vo.getSeaconExpectOutput())
|
|
|
+ .subtract(vo.getCostExpense()).subtract(vo.getResidentFixedSubsidy()).subtract(vo.getRent()).subtract(vo.getSalaryCost()));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MateDeliveryMonthCostStructureVO supportsDeliveryMonthCostStructure(String month) {
|
|
|
+ MateDeliveryMonthCostStructureVO vo = new MateDeliveryMonthCostStructureVO(BigDecimal.ZERO, BigDecimal.ZERO,
|
|
|
+ BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
|
|
|
+ BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
|
|
|
+ //如果选择的是当前的月份
|
|
|
+ DateTime currentMonth = DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM"), "yyyy-MM");
|
|
|
+ DateTime paramMonth;
|
|
|
+ if (StringUtils.isEmpty(month)) {
|
|
|
+ paramMonth = currentMonth;
|
|
|
+ } else {
|
|
|
+ paramMonth = DateUtil.parse(month, "yyyy-MM");
|
|
|
+ }
|
|
|
+ //第一个日期区间 前
|
|
|
+ String firstDayThisMonth;
|
|
|
+ //第二个日期区间 后
|
|
|
+ String firstDayNextMonth;
|
|
|
+ //计算人员的薪资成本 //计算当天的人员驻场补贴 //计算当天办结的报销 //计算各类项目的预计产值 //计算办公地租金 //计算盈利金额
|
|
|
+ if (currentMonth.compareTo(paramMonth) > 0) {
|
|
|
+ firstDayThisMonth = DateUtil.beginOfMonth(paramMonth).toDateStr();
|
|
|
+ firstDayNextMonth = DateUtil.endOfMonth(paramMonth).toDateStr();
|
|
|
+ } else {
|
|
|
+ firstDayThisMonth = DateUtil.beginOfMonth(currentMonth).toDateStr();
|
|
|
+ firstDayNextMonth = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ long differDays = DateUtil.betweenDay(
|
|
|
+ DateUtil.parse(firstDayThisMonth, "yyyy-MM-dd"),
|
|
|
+ DateUtil.parse(firstDayNextMonth, "yyyy-MM-dd"),
|
|
|
+ false);
|
|
|
+ int daysInMonth = java.time.LocalDate.parse(firstDayThisMonth).lengthOfMonth();
|
|
|
+ //计算人员的薪资成本
|
|
|
+ List<MateEmployeeDaySalaryVO> monthSalaryList = baseMapper.queryEmployeeSalaryListByMonth(firstDayThisMonth,firstDayNextMonth,paramMonth.toString("yyyy-MM"));
|
|
|
+ BigDecimal totalSalary = BigDecimal.ZERO;
|
|
|
+ for (MateEmployeeDaySalaryVO daySalary : monthSalaryList) {
|
|
|
+ BigDecimal dailySalary = daySalary.getSalary()
|
|
|
+ .divide(new BigDecimal(daysInMonth), 2, RoundingMode.HALF_UP);
|
|
|
+ // 当天工资 = 日薪 * 实际工时 / 8
|
|
|
+ BigDecimal oneDaySalary = dailySalary
|
|
|
+ .multiply(BigDecimal.valueOf(daySalary.getWorkHour()))
|
|
|
+ .divide(new BigDecimal("8"), 2, RoundingMode.HALF_UP);
|
|
|
+ totalSalary = totalSalary.add(oneDaySalary);
|
|
|
+ }
|
|
|
+ vo.setSalaryCost(totalSalary);
|
|
|
+ //计算日期范围内的人员驻场补贴
|
|
|
+ BigDecimal residentFixedSubsidy = baseMapper.queryResidentFixedSubsidyByDateRange(firstDayThisMonth, firstDayNextMonth);
|
|
|
+ vo.setResidentFixedSubsidy(residentFixedSubsidy == null ? BigDecimal.ZERO : residentFixedSubsidy);
|
|
|
+ //计算日期范围内办结的报销
|
|
|
+ BigDecimal expenseAmount = baseMapper.queryExpenseAmountByDateRange(firstDayThisMonth, firstDayNextMonth);
|
|
|
+ vo.setCostExpense(expenseAmount == null ? BigDecimal.ZERO : expenseAmount);
|
|
|
+ //计算日期范围内各类项目的预计产值
|
|
|
+ List<MateDeliveryCategorySubmitDaysVO> categorySubmitDaysList = baseMapper.queryCategorySubmitDaysListByDateRange(firstDayThisMonth, firstDayNextMonth);
|
|
|
+ for (MateDeliveryCategorySubmitDaysVO categorySubmitDaysVO : categorySubmitDaysList) {
|
|
|
+ String category = categorySubmitDaysVO.getDeliveryCategory();
|
|
|
+ BigDecimal origin = categorySubmitDaysVO.getSubmitDays();
|
|
|
+ BigDecimal result;
|
|
|
+ if ("01".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(800));
|
|
|
+ vo.setJecnExpectOutput(result);
|
|
|
+ } else if ("02".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(1000));
|
|
|
+ vo.setAuthineExpectOutput(result);
|
|
|
+ } else if ("03".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(800));
|
|
|
+ vo.setSeaconExpectOutput(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算办公地租金
|
|
|
+ BigDecimal totalRent = new BigDecimal("10000");
|
|
|
+ BigDecimal dailyRent = totalRent
|
|
|
+ .multiply(BigDecimal.valueOf(differDays))
|
|
|
+ .divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP);
|
|
|
+ vo.setRent(dailyRent == null ? BigDecimal.ZERO : dailyRent);
|
|
|
+ //计算盈利金额
|
|
|
+ vo.setProfitAmount(vo.getJecnExpectOutput().add(vo.getAuthineExpectOutput()).add(vo.getSeaconExpectOutput())
|
|
|
+ .subtract(vo.getCostExpense()).subtract(vo.getResidentFixedSubsidy()).subtract(vo.getRent()).subtract(vo.getSalaryCost()));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<MateEmployeeRankVO> supportsDeliveryEmployeeRank(String date) {
|
|
|
+ //获取在岗天数
|
|
|
+ List<MateEmployeeRankVO> rankList = baseMapper.queryEmployeeDutyDays(date);
|
|
|
+ //任务类提报人天数 非任务类提报人天数 非任务类情况说明 固定补贴
|
|
|
+ List<MateEmployeeRankVO> item1List = baseMapper.queryEmployeeSubmitDays(date);
|
|
|
+ //薪资成本
|
|
|
+ int days = java.time.LocalDate.parse(date).lengthOfMonth();
|
|
|
+ String yearMonth = DateUtil.format(DateUtil.parse(date, "yyyy-MM-dd"), "yyyy-MM");
|
|
|
+ List<MateEmployeeDaySalaryVO> daySalaryList = baseMapper.queryEmployeeDaySalaryList(date, yearMonth);
|
|
|
+ BigDecimal salaryDays = BigDecimal.valueOf(days);
|
|
|
+ BigDecimal eight = BigDecimal.valueOf(8);
|
|
|
+
|
|
|
+ for (MateEmployeeDaySalaryVO daySalary : daySalaryList) {
|
|
|
+ BigDecimal dailySalary = daySalary.getSalary()
|
|
|
+ .divide(salaryDays, 2, RoundingMode.HALF_UP);
|
|
|
+ // 当天工资 = 日薪 * 实际工时 / 8
|
|
|
+ BigDecimal oneDaySalary = dailySalary
|
|
|
+ .multiply(BigDecimal.valueOf(daySalary.getWorkHour()))
|
|
|
+ .divide(eight, 2, RoundingMode.HALF_UP);
|
|
|
+ daySalary.setDaySalary(oneDaySalary);
|
|
|
+ }
|
|
|
+ //租金
|
|
|
+ BigDecimal totalRent = new BigDecimal("10000");
|
|
|
+ BigDecimal dailyRent = totalRent.divide(new BigDecimal(days), 2, RoundingMode.HALF_UP)
|
|
|
+ .divide(BigDecimal.valueOf(rankList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ //费用报销 暂时不算
|
|
|
+ //杰成类预计产值 奥哲类预计产值 船务类预计产值
|
|
|
+ List<MateDeliveryCategoryEmployeeSubmitDaysVO> employeeList = baseMapper.queryCategoryEmployeeSubmitDaysList(date);
|
|
|
+ //拼接数据
|
|
|
+ for (int i = 0; i < rankList.size(); i++) {
|
|
|
+ MateEmployeeRankVO rank = rankList.get(i);
|
|
|
+ //任务类提报人天数 非任务类提报人天数 非任务类情况说明 固定补贴
|
|
|
+ Optional<MateEmployeeRankVO> item1 = item1List.stream()
|
|
|
+ .filter(item -> rank.getPositionStaff().equals(item.getPositionStaff()))
|
|
|
+ .findFirst();
|
|
|
+ item1.ifPresent(item -> {
|
|
|
+ rank.setNormalSubmitDays(item.getNormalSubmitDays());
|
|
|
+ rank.setUnNormalSubmitDays(item.getUnNormalSubmitDays());
|
|
|
+ rank.setUnNormalSubmitDaysDescribe(item.getUnNormalSubmitDaysDescribe());
|
|
|
+ rank.setResidentFixedSubsidy(item.getResidentFixedSubsidy());
|
|
|
+ });
|
|
|
+ //薪资成本
|
|
|
+ Optional<MateEmployeeDaySalaryVO> item2 = daySalaryList.stream()
|
|
|
+ .filter(item -> rank.getPositionStaff().equals(item.getPositionStaff()))
|
|
|
+ .findFirst();
|
|
|
+ item2.ifPresent(item -> {
|
|
|
+ rank.setSalaryCost(item.getDaySalary());
|
|
|
+ });
|
|
|
+ //租金
|
|
|
+ rank.setRent(dailyRent);
|
|
|
+ //杰成类预计产值 奥哲类预计产值 船务类预计产值
|
|
|
+ List<MateDeliveryCategoryEmployeeSubmitDaysVO> item3 = employeeList.stream().filter(item->item.getPositionStaff().equals(rank.getPositionStaff())).collect(Collectors.toList());
|
|
|
+ for (MateDeliveryCategoryEmployeeSubmitDaysVO categorySubmitDaysVO : item3) {
|
|
|
+ String category = categorySubmitDaysVO.getDeliveryCategory();
|
|
|
+ BigDecimal origin = categorySubmitDaysVO.getSubmitDays();
|
|
|
+ BigDecimal result;
|
|
|
+ if ("01".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(800));
|
|
|
+ rank.setJecnExpectOutput(result);
|
|
|
+ } else if ("02".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(1000));
|
|
|
+ rank.setAuthineExpectOutput(result);
|
|
|
+ } else if ("03".equals(category)) {
|
|
|
+ result = origin.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(800));
|
|
|
+ rank.setSeaconExpectOutput(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rank.setProfitAmount(rank.getJecnExpectOutput().add(rank.getAuthineExpectOutput()).add(rank.getSeaconExpectOutput())
|
|
|
+ .subtract(rank.getCostExpense()).subtract(rank.getResidentFixedSubsidy()).subtract(rank.getRent()).subtract(rank.getSalaryCost()));
|
|
|
+ }
|
|
|
+ rankList.sort(Comparator.comparing(MateEmployeeRankVO::getProfitAmount).reversed());
|
|
|
+ return rankList;
|
|
|
}
|
|
|
}
|