gufj 3 mesi fa
parent
commit
e240de1a48
13 ha cambiato i file con 919 aggiunte e 20 eliminazioni
  1. 15 2
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/controller/MateDeliveryDayReportController.java
  2. 28 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryCategoryEmployeeSubmitDaysVO.java
  3. 23 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryCategorySubmitDaysVO.java
  4. 5 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryDayCostStructureVO.java
  5. 84 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryMonthCostStructureVO.java
  6. 64 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryMonthCurrentStructureVO.java
  7. 10 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateEmployeeDaySalaryVO.java
  8. 211 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateEmployeeRankVO.java
  9. 198 11
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/manager/MateDeliveryDayReportServiceImpl.java
  10. 97 3
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/repository/MateDeliveryDayReportRepository.java
  11. 20 0
      bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/service/IMateDeliveryDayReportService.java
  12. 2 2
      bound-link-api/blink-backend/src/main/resources/mapper/BlinkExpenseRepositoryMapper.xml
  13. 162 2
      bound-link-api/blink-backend/src/main/resources/mapper/MateDeliveryDayReportMapper.xml

+ 15 - 2
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/controller/MateDeliveryDayReportController.java

@@ -5,8 +5,7 @@ import com.wx.blink.backend.domain.dto.MateDeliveryDayReportDTO;
 import com.wx.blink.backend.domain.dto.MateDeliveryDayReportNormalDTO;
 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.*;
 import com.wx.blink.backend.service.IMateDeliveryDayReportService;
 import com.wx.blink.base.common.domain.PageResult;
 import com.wx.blink.base.common.domain.ResponseDTO;
@@ -73,4 +72,18 @@ public class MateDeliveryDayReportController {
     public ResponseDTO<MateDeliveryDayCostStructureVO> supportsDeliveryCostStructure(String date) {
         return ResponseDTO.ok(dayReportService.supportsDeliveryCostStructure(date));
     }
+
+    @Operation(summary = "计算当月的成本构成")
+    @GetMapping("/supports/delivery/month/cost/structure")
+    public ResponseDTO<MateDeliveryMonthCostStructureVO> supportsDeliveryMonthCostStructure(String month) {
+        return ResponseDTO.ok(dayReportService.supportsDeliveryMonthCostStructure(month));
+    }
+
+    //----------------------------员工排名----------------------------
+
+    @Operation(summary = "每天的员工排名")
+    @GetMapping("/supports/delivery/employee/rank")
+    public ResponseDTO<List<MateEmployeeRankVO>> supportsDeliveryEmployeeRank(String date) {
+        return ResponseDTO.ok(dayReportService.supportsDeliveryEmployeeRank(date));
+    }
 }

+ 28 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryCategoryEmployeeSubmitDaysVO.java

@@ -0,0 +1,28 @@
+
+package com.wx.blink.backend.domain.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ *
+ */
+@Data
+public class MateDeliveryCategoryEmployeeSubmitDaysVO {
+
+    /**
+     * 岗位人员
+     */
+    private String positionStaff;
+
+    /**
+     * 项目大类
+     */
+    private String deliveryCategory;
+
+    /**
+     * 提报人天数
+     */
+    private BigDecimal submitDays;
+}

+ 23 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryCategorySubmitDaysVO.java

@@ -0,0 +1,23 @@
+
+package com.wx.blink.backend.domain.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 每天的薪资
+ */
+@Data
+public class MateDeliveryCategorySubmitDaysVO {
+
+    /**
+     * 项目大类
+     */
+    private String deliveryCategory;
+
+    /**
+     * 提报人天数
+     */
+    private BigDecimal submitDays;
+}

+ 5 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryDayCostStructureVO.java

@@ -59,4 +59,9 @@ public class MateDeliveryDayCostStructureVO {
      * 船务类确认产值
      */
     private BigDecimal seaconActualOutput;
+
+    /**
+     * 盈利金额
+     */
+    private BigDecimal profitAmount;
 }

+ 84 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryMonthCostStructureVO.java

@@ -0,0 +1,84 @@
+package com.wx.blink.backend.domain.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 时间维度的成本构成
+ */
+@Data
+public class MateDeliveryMonthCostStructureVO {
+
+    /**
+     * 薪资成本
+     */
+    private BigDecimal salaryCost;
+
+    /**
+     * 驻场固定补贴
+     */
+    private BigDecimal residentFixedSubsidy;
+
+    /**
+     * 租金
+     */
+    private BigDecimal rent;
+
+    /**
+     * 费用报销
+     */
+    private BigDecimal costExpense;
+
+    /**
+     * 杰成类预计产值
+     */
+    private BigDecimal jecnExpectOutput;
+
+    /**
+     * 杰成类确认产值
+     */
+    private BigDecimal jecnActualOutput;
+
+    /**
+     * 奥哲类预计产值
+     */
+    private BigDecimal authineExpectOutput;
+
+    /**
+     * 奥哲类确认产值
+     */
+    private BigDecimal authineActualOutput;
+
+    /**
+     * 船务类预计产值
+     */
+    private BigDecimal seaconExpectOutput;
+
+    /**
+     * 船务类确认产值
+     */
+    private BigDecimal seaconActualOutput;
+
+    /**
+     * 盈利金额
+     */
+    private BigDecimal profitAmount;
+
+    public MateDeliveryMonthCostStructureVO() {
+    }
+
+    public MateDeliveryMonthCostStructureVO(BigDecimal salaryCost, BigDecimal residentFixedSubsidy, BigDecimal rent, BigDecimal costExpense, BigDecimal jecnExpectOutput, BigDecimal jecnActualOutput, BigDecimal authineExpectOutput, BigDecimal authineActualOutput, BigDecimal seaconExpectOutput, BigDecimal seaconActualOutput, BigDecimal profitAmount) {
+        this.salaryCost = salaryCost;
+        this.residentFixedSubsidy = residentFixedSubsidy;
+        this.rent = rent;
+        this.costExpense = costExpense;
+        this.jecnExpectOutput = jecnExpectOutput;
+        this.jecnActualOutput = jecnActualOutput;
+        this.authineExpectOutput = authineExpectOutput;
+        this.authineActualOutput = authineActualOutput;
+        this.seaconExpectOutput = seaconExpectOutput;
+        this.seaconActualOutput = seaconActualOutput;
+        this.profitAmount = profitAmount;
+    }
+}

+ 64 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateDeliveryMonthCurrentStructureVO.java

@@ -0,0 +1,64 @@
+package com.wx.blink.backend.domain.vo;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Admin
+ * @date 2025/8/6 17:52
+ */
+public class MateDeliveryMonthCurrentStructureVO {
+    /**
+     * 薪资成本
+     */
+    private BigDecimal salaryCost;
+
+    /**
+     * 驻场固定补贴
+     */
+    private BigDecimal residentFixedSubsidy;
+
+    /**
+     * 租金
+     */
+    private BigDecimal rent;
+
+    /**
+     * 费用报销
+     */
+    private BigDecimal costExpense;
+
+    /**
+     * 杰成类预计产值
+     */
+    private BigDecimal jecnExpectOutput;
+
+    /**
+     * 杰成类确认产值
+     */
+    private BigDecimal jecnActualOutput;
+
+    /**
+     * 奥哲类预计产值
+     */
+    private BigDecimal authineExpectOutput;
+
+    /**
+     * 奥哲类确认产值
+     */
+    private BigDecimal authineActualOutput;
+
+    /**
+     * 船务类预计产值
+     */
+    private BigDecimal seaconExpectOutput;
+
+    /**
+     * 船务类确认产值
+     */
+    private BigDecimal seaconActualOutput;
+
+    /**
+     * 盈利金额
+     */
+    private BigDecimal profitAmount;
+}

+ 10 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateEmployeeDaySalaryVO.java

@@ -11,6 +11,11 @@ import java.math.BigDecimal;
 @Data
 public class MateEmployeeDaySalaryVO {
 
+    /**
+     * 岗位人员
+     */
+    private String positionStaff;
+
     /**
      * 工作时长
      */
@@ -20,4 +25,9 @@ public class MateEmployeeDaySalaryVO {
      * 薪资
      */
     private BigDecimal salary;
+
+    /**
+     * 日薪
+     */
+    private BigDecimal daySalary;
 }

+ 211 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/domain/vo/MateEmployeeRankVO.java

@@ -0,0 +1,211 @@
+
+package com.wx.blink.backend.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 绩效排行
+ */
+@Data
+public class MateEmployeeRankVO {
+
+    /**
+     * 提报日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date submitDay;
+
+    /**
+     * 姓名
+     */
+    private String positionStaff;
+
+    /**
+     * 姓名
+     */
+    private String employeeName;
+
+    /**
+     * 提报人天数
+     */
+    private BigDecimal normalSubmitDays;
+
+    /**
+     * 提报人天数
+     */
+    private BigDecimal unNormalSubmitDays;
+
+    /**
+     * 提报人天数
+     */
+    private BigDecimal unNormalSubmitDaysDescribe;
+
+    /**
+     * 在岗时长
+     */
+    private BigDecimal dutyDays;
+
+    /**
+     * 薪资成本
+     */
+    private BigDecimal salaryCost;
+
+    /**
+     * 驻场固定补贴
+     */
+    private BigDecimal residentFixedSubsidy;
+
+    /**
+     * 租金
+     */
+    private BigDecimal rent;
+
+    /**
+     * 费用报销
+     */
+    private BigDecimal costExpense;
+
+    /**
+     * 杰成类预计产值
+     */
+    private BigDecimal jecnExpectOutput;
+
+    /**
+     * 杰成类确认产值
+     */
+    private BigDecimal jecnActualOutput;
+
+    /**
+     * 奥哲类预计产值
+     */
+    private BigDecimal authineExpectOutput;
+
+    /**
+     * 奥哲类确认产值
+     */
+    private BigDecimal authineActualOutput;
+
+    /**
+     * 船务类预计产值
+     */
+    private BigDecimal seaconExpectOutput;
+
+    /**
+     * 船务类确认产值
+     */
+    private BigDecimal seaconActualOutput;
+
+    /**
+     * 盈利金额
+     */
+    private BigDecimal profitAmount;
+
+    public BigDecimal getNormalSubmitDays() {
+        if (normalSubmitDays == null) {
+            return BigDecimal.ZERO;
+        }
+        return normalSubmitDays;
+    }
+
+    public BigDecimal getUnNormalSubmitDays() {
+        if (unNormalSubmitDays == null) {
+            return BigDecimal.ZERO;
+        }
+        return unNormalSubmitDays;
+    }
+
+    public BigDecimal getUnNormalSubmitDaysDescribe() {
+        if (unNormalSubmitDaysDescribe == null) {
+            return BigDecimal.ZERO;
+        }
+        return unNormalSubmitDaysDescribe;
+    }
+
+    public BigDecimal getDutyDays() {
+        if (dutyDays == null) {
+            return BigDecimal.ZERO;
+        }
+        return dutyDays;
+    }
+
+    public BigDecimal getSalaryCost() {
+        if (salaryCost == null) {
+            return BigDecimal.ZERO;
+        }
+        return salaryCost;
+    }
+
+    public BigDecimal getResidentFixedSubsidy() {
+        if (residentFixedSubsidy == null) {
+            return BigDecimal.ZERO;
+        }
+        return residentFixedSubsidy;
+    }
+
+    public BigDecimal getRent() {
+        if (rent == null) {
+            return BigDecimal.ZERO;
+        }
+        return rent;
+    }
+
+    public BigDecimal getCostExpense() {
+        if (costExpense == null) {
+            return BigDecimal.ZERO;
+        }
+        return costExpense;
+    }
+
+    public BigDecimal getJecnExpectOutput() {
+        if (jecnExpectOutput == null) {
+            return BigDecimal.ZERO;
+        }
+        return jecnExpectOutput;
+    }
+
+    public BigDecimal getJecnActualOutput() {
+        if (jecnActualOutput == null) {
+            return BigDecimal.ZERO;
+        }
+        return jecnActualOutput;
+    }
+
+    public BigDecimal getAuthineExpectOutput() {
+        if (authineExpectOutput == null) {
+            return BigDecimal.ZERO;
+        }
+        return authineExpectOutput;
+    }
+
+    public BigDecimal getAuthineActualOutput() {
+        if (authineActualOutput == null) {
+            return BigDecimal.ZERO;
+        }
+        return authineActualOutput;
+    }
+
+    public BigDecimal getSeaconExpectOutput() {
+        if (seaconExpectOutput == null) {
+            return BigDecimal.ZERO;
+        }
+        return seaconExpectOutput;
+    }
+
+    public BigDecimal getSeaconActualOutput() {
+        if (seaconActualOutput == null) {
+            return BigDecimal.ZERO;
+        }
+        return seaconActualOutput;
+    }
+
+    public BigDecimal getProfitAmount() {
+        if (profitAmount == null) {
+            return BigDecimal.ZERO;
+        }
+        return profitAmount;
+    }
+}

+ 198 - 11
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/manager/MateDeliveryDayReportServiceImpl.java

@@ -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;
     }
 }

+ 97 - 3
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/repository/MateDeliveryDayReportRepository.java

@@ -9,13 +9,12 @@ import com.wx.blink.backend.domain.dto.MateDeliveryDayReportDTO;
 import com.wx.blink.backend.domain.dto.MateDeliveryDayReportNormalDTO;
 import com.wx.blink.backend.domain.qry.MateDeliveryCommonQry;
 import com.wx.blink.backend.domain.qry.MateDeliveryDayReportQry;
-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 org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 
@@ -179,4 +178,99 @@ public interface MateDeliveryDayReportRepository extends BaseMapper<MateDelivery
      * @return
      */
     List<MateEmployeeDaySalaryVO> queryEmployeeDaySalaryList(@Param("date") String date, @Param("yearMonth") String yearMonth);
+
+
+    /**
+     * 计算当天办结的报销
+     *
+     * @param date
+     * @return
+     */
+    BigDecimal queryExpenseAmountByDate(String date);
+
+
+    /**
+     * 计算当天的人员驻场补贴
+     *
+     * @param date
+     * @return
+     */
+    BigDecimal queryResidentFixedSubsidyByDate(String date);
+
+
+    /**
+     * 计算各类项目的预计产值
+     *
+     * @param date
+     * @return
+     */
+    List<MateDeliveryCategorySubmitDaysVO> queryCategorySubmitDaysList(String date);
+
+
+    /**
+     * 计算人员的薪资成本
+     *
+     * @param firstDayThisMonth
+     * @param firstDayNextMonth
+     * @param paramMonth
+     * @return
+     */
+    List<MateEmployeeDaySalaryVO> queryEmployeeSalaryListByMonth(@Param("firstDayThisMonth") String firstDayThisMonth, @Param("firstDayNextMonth") String firstDayNextMonth, @Param("paramMonth") String paramMonth);
+
+
+    /**
+     * 计算日期范围内的人员驻场补贴
+     *
+     * @param firstDayThisMonth
+     * @param firstDayNextMonth
+     * @return
+     */
+    BigDecimal queryResidentFixedSubsidyByDateRange(@Param("firstDayThisMonth") String firstDayThisMonth, @Param("firstDayNextMonth") String firstDayNextMonth);
+
+
+    /**
+     * 计算日期范围内办结的报销
+     *
+     * @param firstDayThisMonth
+     * @param firstDayNextMonth
+     * @return
+     */
+    BigDecimal queryExpenseAmountByDateRange(@Param("firstDayThisMonth") String firstDayThisMonth, @Param("firstDayNextMonth") String firstDayNextMonth);
+
+
+    /**
+     * 计算日期范围内各类项目的预计产值
+     *
+     * @param firstDayThisMonth
+     * @param firstDayNextMonth
+     * @return
+     */
+    List<MateDeliveryCategorySubmitDaysVO> queryCategorySubmitDaysListByDateRange(@Param("firstDayThisMonth") String firstDayThisMonth, @Param("firstDayNextMonth") String firstDayNextMonth);
+
+
+    /**
+     * 获取在岗天数
+     *
+     * @param date
+     * @return
+     */
+    List<MateEmployeeRankVO> queryEmployeeDutyDays(String date);
+
+
+    /**
+     * 任务类提报人天数 非任务类提报人天数 非任务类情况说明
+     *
+     * @param date
+     * @return
+     */
+    List<MateEmployeeRankVO> queryEmployeeSubmitDays(String date);
+
+
+    /**
+     * 杰成类预计产值 奥哲类预计产值 船务类预计产值
+     *
+     * @param date
+     * @return
+     */
+    List<MateDeliveryCategoryEmployeeSubmitDaysVO> queryCategoryEmployeeSubmitDaysList(String date);
 }

+ 20 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/service/IMateDeliveryDayReportService.java

@@ -8,6 +8,8 @@ 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.MateDeliveryMonthCostStructureVO;
+import com.wx.blink.backend.domain.vo.MateEmployeeRankVO;
 import com.wx.blink.base.common.domain.PageResult;
 import com.wx.blink.base.common.domain.ResponseDTO;
 import org.apache.ibatis.annotations.Param;
@@ -83,4 +85,22 @@ public interface IMateDeliveryDayReportService extends IService<MateDeliveryDayR
      * @return
      */
     MateDeliveryDayCostStructureVO supportsDeliveryCostStructure(String date);
+
+
+    /**
+     * 计算本月累计
+     *
+     * @param month
+     * @return
+     */
+    MateDeliveryMonthCostStructureVO supportsDeliveryMonthCostStructure(String month);
+
+
+    /**
+     * 每天的员工排名
+     *
+     * @param date
+     * @return
+     */
+    List<MateEmployeeRankVO> supportsDeliveryEmployeeRank(String date);
 }

+ 2 - 2
bound-link-api/blink-backend/src/main/resources/mapper/BlinkExpenseRepositoryMapper.xml

@@ -16,7 +16,7 @@
         from l_loan_apply t1
                  left join st_instance t2 on t1.flow_id = t2.biz_objectid
         where t2.state <![CDATA[<>]]> 5
-        order by t1.create_time desc
+        order by t2.finish_time desc
     </select>
 
     <select id="supportsExpenseStatementQueryPage" resultType="com.wx.blink.backend.domain.vo.BlinkExpenseStatementVO">
@@ -34,6 +34,6 @@
         from l_expense_statement t1
                  left join st_instance t2 on t1.flow_id = t2.biz_objectid
         where t2.state <![CDATA[<>]]> 5
-        order by t1.create_time desc
+        order by t2.finish_time desc
     </select>
 </mapper>

+ 162 - 2
bound-link-api/blink-backend/src/main/resources/mapper/MateDeliveryDayReportMapper.xml

@@ -304,11 +304,171 @@
     </select>
 
     <select id="queryEmployeeDaySalaryList" resultType="com.wx.blink.backend.domain.vo.MateEmployeeDaySalaryVO">
-        select grant_month, work_hour, salary
+        select t1.position_staff, grant_month, work_hour, salary + insurance + accumulation_fund salary
         from mate_delivery_day_report_require t1
-                 left join mate_employee_salary t2 on t1.position_staff = t2.position_staff and grant_month = #{yearMonth}
+                 left join mate_employee_salary t2
+                           on t1.position_staff = t2.position_staff and grant_month = #{yearMonth}
         where require_state = 0
           and work_state = 0
           and t1.submit_day = #{date}
     </select>
+
+    <select id="queryExpenseAmountByDate" resultType="java.math.BigDecimal">
+        select sum(expense_amount) expenseAmount
+        from l_expense_statement t1
+                 left join st_instance t2 on t1.flow_id = t2.biz_objectid
+        where state = 4
+          and DATE_FORMAT(finish_time, '%Y-%m-%d') = #{date}
+    </select>
+
+    <select id="queryResidentFixedSubsidyByDate" resultType="java.math.BigDecimal">
+        select sum(subsidy_amount) subsidyAmount
+        from mate_delivery_day_report t1
+                 left join mate_delivery t2 on t2.id = t1.delivery_id
+        where site_state = 1
+          and t1.submit_date = #{date}
+          and t1.deleted_flag = '0'
+          and t2.deleted_flag = '0'
+    </select>
+
+    <select id="queryCategorySubmitDaysList"
+            resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategorySubmitDaysVO">
+        SELECT t2.delivery_category deliveryCategory, sum(t1.submit_days) submitDays
+        FROM mate_delivery_day_report o1
+                 left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
+                 left join mate_delivery t2 on t1.project_id = t2.id
+                 INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
+                             FROM mate_delivery_day_report
+                             GROUP BY position_staff, submit_date) o2
+                            ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
+        where o1.submit_date = #{date}
+          and t1.id is not null
+        group by t2.delivery_category
+    </select>
+
+    <select id="queryEmployeeSalaryListByMonth" resultType="com.wx.blink.backend.domain.vo.MateEmployeeDaySalaryVO">
+        select grant_month, work_hour, salary + insurance + accumulation_fund salary
+        from mate_delivery_day_report_require t1
+        left join mate_employee_salary t2
+        on t1.position_staff = t2.position_staff and grant_month = #{paramMonth}
+        where require_state = 0
+        and work_state = 0
+        <if test="firstDayThisMonth != null  and firstDayThisMonth != ''">
+            and t1.submit_day >= #{firstDayThisMonth}
+        </if>
+        <if test="firstDayNextMonth != null  and firstDayNextMonth != ''">
+            and t1.submit_day <![CDATA[<=]]> #{firstDayNextMonth}
+        </if>
+    </select>
+
+    <select id="queryResidentFixedSubsidyByDateRange" resultType="java.math.BigDecimal">
+        select sum(subsidy_amount) subsidyAmount
+        from mate_delivery_day_report t1
+        left join mate_delivery t2 on t2.id = t1.delivery_id
+        where site_state = 1
+        <if test="firstDayThisMonth != null  and firstDayThisMonth != ''">
+            and t1.submit_date >= #{firstDayThisMonth}
+        </if>
+        <if test="firstDayNextMonth != null  and firstDayNextMonth != ''">
+            and t1.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
+        </if>
+        and t1.deleted_flag = '0'
+        and t2.deleted_flag = '0'
+    </select>
+
+    <select id="queryExpenseAmountByDateRange" resultType="java.math.BigDecimal">
+        select sum(expense_amount) expenseAmount
+        from l_expense_statement t1
+        left join st_instance t2 on t1.flow_id = t2.biz_objectid
+        where state = 4
+        <if test="firstDayThisMonth != null  and firstDayThisMonth != ''">
+            and DATE_FORMAT(finish_time, '%Y-%m-%d') >= #{firstDayThisMonth}
+        </if>
+        <if test="firstDayNextMonth != null  and firstDayNextMonth != ''">
+            and DATE_FORMAT(finish_time, '%Y-%m-%d') <![CDATA[<=]]> #{firstDayNextMonth}
+        </if>
+    </select>
+
+    <select id="queryCategorySubmitDaysListByDateRange"
+            resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategorySubmitDaysVO">
+        SELECT t2.delivery_category deliveryCategory,sum(t1.submit_days) submitDays
+        FROM mate_delivery_day_report o1
+        left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
+        left join mate_delivery t2 on t1.project_id = t2.id
+        INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
+        FROM mate_delivery_day_report
+        GROUP BY position_staff, submit_date) o2
+        ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
+        where
+        t1.id is not null
+        <if test="firstDayThisMonth != null  and firstDayThisMonth != ''">
+            and o1.submit_date >= #{firstDayThisMonth}
+        </if>
+        <if test="firstDayNextMonth != null  and firstDayNextMonth != ''">
+            and o1.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
+        </if>
+        group by t2.delivery_category
+    </select>
+
+    <select id="queryEmployeeDutyDays" resultType="com.wx.blink.backend.domain.vo.MateEmployeeRankVO">
+        select submit_day, position_staff, actual_name employeeName, work_hour dutyDays
+        from mate_delivery_day_report_require t1
+                 left join mate_employee t2 on t1.position_staff = t2.login_name
+        where require_state = 0
+          and work_state = 0
+          and submit_day = #{date}
+    </select>
+
+    <select id="queryEmployeeSubmitDays" resultType="com.wx.blink.backend.domain.vo.MateEmployeeRankVO">
+        SELECT  o1.position_staff,
+                SUM(IFNULL(t1.submit_days,0))                 AS normal_days,
+                COALESCE(
+                        ( SELECT SUM(ab.submit_days)
+                          FROM mate_delivery_day_report_abnormal ab
+                                   JOIN mate_delivery_day_report r ON r.id = ab.report_id
+                          WHERE r.position_staff = o1.position_staff
+                            AND r.submit_date   = #{date}
+                        ),0)                                         AS abnormal_days,
+                COALESCE(
+                        ( SELECT GROUP_CONCAT(
+                                         CONCAT(ab.submit_days,':',ab.submit_describe)
+                                             ORDER BY ab.id
+                     SEPARATOR '|')
+                          FROM mate_delivery_day_report_abnormal ab
+                                   JOIN mate_delivery_day_report r ON r.id = ab.report_id
+                          WHERE r.position_staff = o1.position_staff
+                            AND r.submit_date   = #{date}
+                        ),'')                                        AS abnormal_desc,
+
+                CASE WHEN ANY_VALUE(o1.site_state) = 1
+                         THEN ANY_VALUE(t2.subsidy_amount)
+                     ELSE 0 END                                AS residentFixedSubsidy
+        FROM mate_delivery_day_report o1
+                 LEFT JOIN mate_delivery_day_report_normal   t1 ON t1.report_id = o1.id
+                 LEFT JOIN mate_delivery                     t2 ON t2.id       = o1.delivery_id
+                 JOIN (
+            SELECT position_staff, submit_date, MAX(create_time) AS latest_date
+            FROM mate_delivery_day_report
+            GROUP BY position_staff, submit_date
+        ) o2
+                      ON o1.position_staff = o2.position_staff
+                          AND o1.create_time   = o2.latest_date
+        WHERE o1.submit_date = #{date}
+        GROUP BY o1.position_staff
+    </select>
+
+    <select id="queryCategoryEmployeeSubmitDaysList"
+            resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategoryEmployeeSubmitDaysVO">
+        SELECT o1.position_staff, t2.delivery_category deliveryCategory, sum(t1.submit_days) submitDays
+        FROM mate_delivery_day_report o1
+                 left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
+                 left join mate_delivery t2 on t1.project_id = t2.id
+                 INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
+                             FROM mate_delivery_day_report
+                             GROUP BY position_staff, submit_date) o2
+                            ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
+        where o1.submit_date = #{date}
+          and t1.id is not null
+        group by t2.delivery_category,o1.position_staff
+    </select>
 </mapper>