seyason 3 éve
szülő
commit
845e63eac0
16 módosított fájl, 374 hozzáadás és 321 törlés
  1. 6 0
      fhKeeper/formulahousekeeper/buildAll.bat
  2. 3 2
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceController.java
  3. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/FinanceProjects.java
  4. 5 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ProjectSumItem.java
  5. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceService.java
  6. 3 2
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/BusinessTripServiceImpl.java
  7. 28 16
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceImportServiceImpl.java
  8. 245 224
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java
  9. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/LeaveSheetServiceImpl.java
  10. 0 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  11. 38 42
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  12. 5 3
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml
  13. 1 0
      fhKeeper/formulahousekeeper/timesheet/build.bat
  14. 19 4
      fhKeeper/formulahousekeeper/timesheet/src/views/project/finance.vue
  15. 16 25
      fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue
  16. 1 0
      fhKeeper/formulahousekeeper/timesheet_h5/build.bat

+ 6 - 0
fhKeeper/formulahousekeeper/buildAll.bat

@@ -0,0 +1,6 @@
+cd timesheet
+call build.bat
+cd ../timesheet_h5
+call build.bat
+cd ../management-platform
+call build_package.bat

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceController.java

@@ -66,8 +66,9 @@ public class FinanceController {
     }
 
     @RequestMapping("/exportData")
-    public HttpRespMsg exportData(@RequestParam String date, Boolean assignNoProUser,HttpServletRequest request) {
-        return financeService.exportData(date, assignNoProUser, request);
+    public HttpRespMsg exportData(@RequestParam(required = false, defaultValue = "0") Integer groupByCategory,
+                                  @RequestParam String date, Boolean assignNoProUser,HttpServletRequest request) {
+        return financeService.exportData(groupByCategory, date, assignNoProUser, request);
     }
 
     @RequestMapping("/exportFinance")

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/FinanceProjects.java

@@ -54,6 +54,8 @@ public class FinanceProjects extends Model<FinanceProjects> {
     @TableField("project_code")
     private String projectCode;
 
+    @TableField(exist = false)
+    private String categoryName;
 
     @Override
     protected Serializable pkVal() {

+ 5 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ProjectSumItem.java

@@ -1,9 +1,14 @@
 package com.management.platform.entity;
 
+import lombok.Data;
+
 import java.math.BigDecimal;
 
+@Data
 public class ProjectSumItem {
     public String project;
+    //项目分类
+    public String categoryName;
     public String projectCode;
     public Integer projectId;
     public double workingTime;

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceService.java

@@ -21,7 +21,7 @@ public interface FinanceService extends IService<Finance> {
 
     HttpRespMsg importData(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile multipartFile, HttpServletRequest request);
 
-    HttpRespMsg exportData(String date, Boolean assignNoProUser, HttpServletRequest request);
+    HttpRespMsg exportData(Integer groupByCategory, String date, Boolean assignNoProUser, HttpServletRequest request);
 
     HttpRespMsg getTimeCost(String yearMonth, Boolean assignNoProUser, HttpServletRequest request);
 

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/BusinessTripServiceImpl.java

@@ -56,13 +56,14 @@ public class BusinessTripServiceImpl extends ServiceImpl<BusinessTripMapper, Bus
             //检查该时间段是否已经有按天请假
             QueryWrapper<BusinessTrip> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("owner_id", sheet.getOwnerId());
-            queryWrapper.and(wrapper->wrapper.between("start_date", sheet.getStartDate(), sheet.getEndDate()).or().between("end_date", sheet.getStartDate(), sheet.getEndDate()));
+            queryWrapper.le("start_date", sheet.getEndDate()).ge("end_date", sheet.getStartDate());
 
             int count = businessTripMapper.selectCount(queryWrapper);
             if (count > 0) {
                 msg.setError("该时间段已有出差申请,不能重复提交");
+            } else {
+                businessTripMapper.insert(sheet);
             }
-            businessTripMapper.insert(sheet);
         } else {
             businessTripMapper.updateById(sheet);
         }

+ 28 - 16
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceImportServiceImpl.java

@@ -3,11 +3,8 @@ package com.management.platform.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
-import com.management.platform.service.FinanceImportService;
+import com.management.platform.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.management.platform.service.FinanceService;
-import com.management.platform.service.ReportService;
-import com.management.platform.service.UserService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.UserNotFoundException;
@@ -41,6 +38,8 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
     @Value(value = "${upload.path}")
     private String path;
 
+    @Resource
+    private FinanceFixedcolnameService financeFixedcolnameService;
     @Resource
     private UserMapper userMapper;
     @Resource
@@ -300,7 +299,19 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
                 }
 
                 List<FinanceTblcuscol> cusColList = financeTblcuscolMapper.selectList(new QueryWrapper<FinanceTblcuscol>().eq("company_id", companyId));
-
+                FinanceFixedcolname financeConfig = financeFixedcolnameService.getFixed(companyId);
+                if (cusColList.size() > 0) {
+                    financeConfig.setField1(cusColList.get(0).getFieldName());
+                    financeConfig.setField1Calculate(cusColList.get(0).getNeedCalculate());
+                }
+                if (cusColList.size() > 1) {
+                    financeConfig.setField2(cusColList.get(1).getFieldName());
+                    financeConfig.setField2Calculate(cusColList.get(1).getNeedCalculate());
+                }
+                if (cusColList.size() > 2) {
+                    financeConfig.setField3(cusColList.get(2).getFieldName());
+                    financeConfig.setField3Calculate(cusColList.get(2).getNeedCalculate());
+                }
                 //由于第一行需要指明列对应的标题
                 int rowNum = sheet.getLastRowNum();
                 for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
@@ -350,7 +361,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
                             String item = salaryCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setMonthCost(value);
-                            total = total.add(value);
+                            if (financeConfig.getMonthCostCalculate()==1) total = total.add(value);
                         }
 
                         //按姓名做匹配
@@ -364,70 +375,71 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
                             String bonusString = bonusCell.getStringCellValue();
                             BigDecimal bonus = bonusString != null ? new BigDecimal(bonusString.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setBonus(bonus);
-                            total = total.add(bonus);
+                            if (financeConfig.getBonusCalculate()==1) total = total.add(bonus);
                         }
                         if (allowanceCell != null) {
                             allowanceCell.setCellType(CellType.STRING);
                             String item = allowanceCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setAllowance(value);
-                            total = total.add(value);
+                            if (financeConfig.getAllowanceCalculate()==1) total = total.add(value);
                         }
                         if (inJobCell != null) {
                             inJobCell.setCellType(CellType.STRING);
                             String item = inJobCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setInsuranceLosejob(value);
-                            total = total.add(value);
+                            if (financeConfig.getInsuranceLosejobCalculate()==1) total = total.add(value);
                         }
                         if (inMedicalCell != null) {
                             inMedicalCell.setCellType(CellType.STRING);
                             String item = inMedicalCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setInsuranceMedical(value);
-                            total = total.add(value);
+                            if (financeConfig.getInsuranceMedicalCalculate()==1) total = total.add(value);
                         }
                         if (inOldCell != null) {
                             inOldCell.setCellType(CellType.STRING);
                             String item = inOldCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setInsuranceOld(value);
-                            total = total.add(value);
+                            if (financeConfig.getInsuranceOldCalculate()==1) total = total.add(value);
                         }
                         if (injuryCell != null) {
                             injuryCell.setCellType(CellType.STRING);
                             String item = injuryCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setInsuranceInjury(value);
-                            total = total.add(value);
+                            if (financeConfig.getInsuranceInjuryCalculate()==1) total = total.add(value);
                         }
                         if (houseFundCell != null) {
                             houseFundCell.setCellType(CellType.STRING);
                             String item = houseFundCell.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setHouseFund(value);
-                            total = total.add(value);
+                            if (financeConfig.getHouseFundCalculate()==1) total = total.add(value);
                         }
+
                         if (field1 != null) {
                             field1.setCellType(CellType.STRING);
                             String item = field1.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setCustomField1(value);
-                            total = total.add(value);
+                            if (financeConfig.getField1Calculate() != null && financeConfig.getField1Calculate()==1) total = total.add(value);
                         }
                         if (field2 != null) {
                             field2.setCellType(CellType.STRING);
                             String item = field2.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setCustomField2(value);
-                            total = total.add(value);
+                            if (financeConfig.getField2Calculate() != null && financeConfig.getField2Calculate()==1) total = total.add(value);
                         }
                         if (field3 != null) {
                             field3.setCellType(CellType.STRING);
                             String item = field3.getStringCellValue();
                             BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
                             finance.setCustomField3(value);
-                            total = total.add(value);
+                            if (financeConfig.getField3Calculate() != null && financeConfig.getField3Calculate()==1) total = total.add(value);
                         }
                         finance.setTotalCost(total);
 

+ 245 - 224
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -441,12 +441,12 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     }
 
     @Override
-    public HttpRespMsg exportData(String yearMonth, Boolean assignNoProUser, HttpServletRequest request) {
+    public HttpRespMsg exportData(Integer groupByCategory, String yearMonth, Boolean assignNoProUser, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
             final List<FinanceTblcuscol> cusColList = financeTblcuscolMapper.selectList(new QueryWrapper<FinanceTblcuscol>().eq("company_id", companyId));
-
+            List<Project> allProjects = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
             Map<String, Object> resultMap = new HashMap<>();
             double totalCostTime = 0;
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
@@ -464,18 +464,15 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             BigDecimal totalField3 = cusColList.size() > 2?BigDecimal.valueOf(0):null;
 
             List<String> headList = new ArrayList<String>();
-            headList.add("项目编号");
-            headList.add("项目名称");
-            headList.add("人员");
-            headList.add("工时(h)");
-//            headList.add("工资(元)");
-//            headList.add("奖金(元)");
-//            headList.add("津贴(元)");
-//            headList.add("养老保险(元)");
-//            headList.add("医疗保险(元)");
-//            headList.add("失业保险(元)");
-//            headList.add("工伤保险(元)");
-//            headList.add("住房公积金(元)");
+            if (groupByCategory == 0) {
+                headList.add("项目编号");
+                headList.add("项目名称");
+                headList.add("人员");
+                headList.add("工时(h)");
+            } else {
+                headList.add("项目分类");
+            }
+
             FinanceFixedcolname fixedItem = financeFixedcolnameService.getFixed(companyId);
             headList.add(fixedItem.getMonthCost()+"(元)");
             headList.add(fixedItem.getBonus()+"(元)");
@@ -541,6 +538,20 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
             ProjectPercentage percentage = null;
             List<FinanceProjects> financeProjects = financeProjectsMapper.selectList(new QueryWrapper<FinanceProjects>().eq("company_id", companyId).eq("ymonth", yearMonth));
+            //填充项目分类
+            financeProjects.forEach(f->{
+                Optional<Project> curP = allProjects.stream().filter(p->p.getId().equals(f.getProjectId())).findFirst();
+                if (curP.isPresent()) {
+                    String name = curP.get().getCategoryName();
+                    if (name == null) name = "其他";
+                    f.setCategoryName(name);
+                } else {
+                    httpRespMsg.setError("项目["+f.getProjectName()+"]已不存在");
+                }
+            });
+            if (httpRespMsg.code.equals("error")) {
+                return httpRespMsg;
+            }
             //无项目工时人员的分配比例设置
             List<Map> noPUserDataList = new ArrayList<>();
             if (assignNoProUser != null && assignNoProUser && noProjectUser.size() > 0) {
@@ -571,10 +582,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                             userCostMap.put("project", f.getProjectId());
                             userCostMap.put("projectId", f.getProjectId());
                             userCostMap.put("projectCode", f.getProjectCode());
+                            userCostMap.put("categoryName", f.getCategoryName());
                             noPUserDataList.add(userCostMap);
                         }
                     });
-
                 }
             }
 
@@ -582,6 +593,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             for (Map<String, Object> map : projectTimeList) {
                 Integer projectId = (Integer) map.get("projectId");
                 String curProjectCode = (String) map.get("projectCode");
+                String categoryName = (String) map.get("categoryName");
                 String curProject = (String) map.get("project");
                 String creatorId = (String) map.get("creatorId");
                 Optional<Finance> first = finances.stream().filter(f -> f.getUserId().equals(creatorId)).findFirst();
@@ -595,7 +607,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                 BigDecimal loseJob = new BigDecimal(0);
                 BigDecimal injury = new BigDecimal(0);
                 BigDecimal house = new BigDecimal(0);
-//                BigDecimal other = new BigDecimal(0);
                 BigDecimal field1Item = new BigDecimal(0);
                 BigDecimal field2Item = new BigDecimal(0);
                 BigDecimal field3Item = new BigDecimal(0);
@@ -610,11 +621,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                     loseJob = userFinance.getInsuranceLosejob().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
                     injury = userFinance.getInsuranceInjury().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
                     house = userFinance.getHouseFund().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-//                    if (userFinance.getOthers() == null) {
-//                        other = new BigDecimal(0);
-//                    } else {
-//                        other = userFinance.getOthers().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-//                    }
                     if (userFinance.getCustomField1() != null) {
                         field1Item = userFinance.getCustomField1().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
                     }
@@ -650,6 +656,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                     item.project = curProject;
                     item.projectId = projectId;
                     item.projectCode = curProjectCode;
+                    item.categoryName = categoryName;
                     item.workingTime = workingTime;
                     item.cost = cost;
                     item.salary = salary;
@@ -660,7 +667,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                     item.loseJob = loseJob;
                     item.injury = injury;
                     item.house = house;
-//                    item.other = other;
                     item.field1 = field1Item;
                     item.field2 = field2Item;
                     item.field3 = field3Item;
@@ -700,6 +706,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                         ProjectSumItem npItem = new ProjectSumItem();
                         npItem.project = np.getProjectName();
                         npItem.projectCode = np.getProjectCode();
+                        npItem.categoryName = np.getCategoryName();
                         npItem.projectId = np.getProjectId();
                         //初始设置为0
                         npItem.cost = new BigDecimal(0);
@@ -735,7 +742,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                         p.loseJob = p.loseJob.add(newFinance.getInsuranceLosejob());
                         p.injury = p.injury.add(newFinance.getInsuranceInjury());
                         p.house = p.house.add(newFinance.getHouseFund());
-//                    item.other = item.other.add(other);
                         p.field1 = p.field1.add(newFinance.getCustomField1());
                         p.field2 = p.field2.add(newFinance.getCustomField2());
                         p.field3 = p.field3.add(newFinance.getCustomField3());
@@ -783,216 +789,232 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             if (totalField3 != null) {
                 totalField3 = totalField3.setScale(2, BigDecimal.ROUND_HALF_UP);
             }
-
-
-//            if (assignNoProUser != null && assignNoProUser) {
-                //按比例分摊
-                
-                //均摊各项成本到项目
-//                for (Finance npu : noProjectUser) {
-//                    pList.forEach(p->{
-//                        p.cost = p.cost.add(npu.getTotalCost().divide(new BigDecimal(pList.size())));
-//                        p.salary = p.salary.add(npu.getMonthCost().divide(new BigDecimal(pList.size())));
-//                        p.bonus = p.bonus.add(npu.getBonus().divide(new BigDecimal(pList.size())));
-//                        p.allowance = p.allowance.add(npu.getAllowance().divide(new BigDecimal(pList.size())));
-//                        p.old = p.old.add(npu.getInsuranceOld().divide(new BigDecimal(pList.size())));
-//                        p.medical = p.medical.add(npu.getInsuranceMedical().divide(new BigDecimal(pList.size())));
-//                        p.loseJob = p.loseJob.add(npu.getInsuranceLosejob().divide(new BigDecimal(pList.size())));
-//                        p.injury = p.injury.add(npu.getInsuranceInjury().divide(new BigDecimal(pList.size())));
-//                        p.house = p.house.add(npu.getHouseFund().divide(new BigDecimal(pList.size())));
-//                        //处理自定义字段的数据累加
-//                        if (npu.getCustomField1() != null) {
-//                            p.field1 = p.field1.add(npu.getCustomField1().divide(new BigDecimal(pList.size())));
-//                        }
-//                        if (npu.getCustomField2() != null) {
-//                            p.field2 = p.field2.add(npu.getCustomField2().divide(new BigDecimal(pList.size())));
-//                        }
-//                        if (npu.getCustomField3() != null) {
-//                            p.field3 = p.field3.add(npu.getCustomField3().divide(new BigDecimal(pList.size())));
-//                        }
-//                    });
-//                    totalMoneyCost = totalMoneyCost.add(npu.getTotalCost());
-//                    totalSalary = totalSalary.add(npu.getMonthCost());
-//                    totalBonus = totalBonus.add(npu.getBonus());
-//                    totalAllowance = totalAllowance.add(npu.getAllowance());
-//                    totalOld = totalOld.add(npu.getInsuranceOld());
-//                    totalMedical = totalMedical.add(npu.getInsuranceMedical());
-//                    totalLoseJob = totalLoseJob.add(npu.getInsuranceLosejob());
-//                    totalInjury = totalInjury.add(npu.getInsuranceInjury());
-//                    totalHouse = totalHouse.add(npu.getHouseFund());
-////                totalOther = totalOther.add(other);
-//                    if (totalField1 != null && npu.getCustomField1() != null) {
-//                        totalField1 = totalField1.add(npu.getTotalCost());
-//                    }
-//                    if (totalField2 != null && npu.getCustomField2() != null) {
-//                        totalField2 = totalField2.add(npu.getCustomField2());
-//                    }
-//                    if (totalField3 != null && npu.getCustomField3() != null) {
-//                        totalField3 = totalField3.add(npu.getCustomField3());
-//                    }
-//                }
-//            }
-            pList.forEach(p->{
-                p.cost = p.cost.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.salary = p.salary.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.bonus = p.bonus.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.allowance = p.allowance.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.old = p.old.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.medical = p.medical.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.loseJob = p.loseJob.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.injury = p.injury.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.house = p.house.setScale(2, BigDecimal.ROUND_HALF_UP);
-//                p.other = p.other.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.field1 = p.field1.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.field2 = p.field2.setScale(2, BigDecimal.ROUND_HALF_UP);
-                p.field3 = p.field3.setScale(2, BigDecimal.ROUND_HALF_UP);
-
-                //组装写入excel文件的数据,从项目开始,项目下面挂成员
-                List<String> rowData = new ArrayList<String>();
-                rowData.add(p.projectCode);
-                rowData.add(p.project);
-                rowData.add("");
-                rowData.add(p.workingTime+"");
-                rowData.add(p.salary.toPlainString());
-                rowData.add(p.bonus.toPlainString());
-                rowData.add(p.allowance.toPlainString());
-                rowData.add(p.old.toPlainString());
-                rowData.add(p.medical.toPlainString());
-                rowData.add(p.loseJob.toPlainString());
-                rowData.add(p.injury.toPlainString());
-                rowData.add(p.house.toPlainString());
-//                rowData.add(p.other.toPlainString());
-                if (cusColList.size() > 0) {
-                    rowData.add(p.field1.toPlainString());
-                }
-                if (cusColList.size() > 1) {
-                    rowData.add(p.field2.toPlainString());
-                }
-                if (cusColList.size() > 2) {
-                    rowData.add(p.field3.toPlainString());
-                }
-                rowData.add(p.cost.toPlainString());
-                allList.add(rowData);
-
-                //获取成员
-                for (Map<String, Object> membMap : projectTimeList) {
-                    if (membMap.get("project").equals(p.project)) {
-                        //匹配到项目了
-                        List<String> membRowData = new ArrayList<String>();
-                        membRowData.add("");
-                        membRowData.add("");
-                        Double workingTime = (Double) membMap.get("workingTime");
-                        String creatorId = (String) membMap.get("creatorId");
-                        User us = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst().get();
-                        Optional<Finance> first = finances.stream().filter(f -> f.getUserId().equals(creatorId)).findFirst();
-                        if (!first.isPresent()) {
-                            logger.info("用户["+us.getName()+"]在财务报表中不存在,请重新导入");
-                            continue;
-                        }
-                        Finance userFinance = first.get();
-
-                        BigDecimal cost = userFinance.getTotalCost().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal salary = userFinance.getMonthCost().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal bonus = userFinance.getBonus().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal allowance = userFinance.getAllowance().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal old = userFinance.getInsuranceOld().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal medical = userFinance.getInsuranceMedical().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal loseJob = userFinance.getInsuranceLosejob().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal injury = userFinance.getInsuranceInjury().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal house = userFinance.getHouseFund().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-//                        BigDecimal other = userFinance.getOthers() == null?new BigDecimal(0):userFinance.getOthers().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal field1 = userFinance.getCustomField1() == null? new BigDecimal(0):userFinance.getCustomField1().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal field2 = userFinance.getCustomField2() == null? new BigDecimal(0):userFinance.getCustomField2().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal field3 = userFinance.getCustomField3() == null? new BigDecimal(0):userFinance.getCustomField3().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
-                        membRowData.add(us.getName());
-                        membRowData.add(workingTime+"");
-                        membRowData.add(salary.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(bonus.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(allowance.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(old.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(medical.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(loseJob.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(injury.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        membRowData.add(house.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-//                        membRowData.add(other.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        //自定义字段
-                        if (cusColList.size() > 0) {
-                            membRowData.add(field1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        }
-                        if (cusColList.size() > 1) {
-                            membRowData.add(field2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        }
-                        if (cusColList.size() > 2) {
-                            membRowData.add(field3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+            //按项目名称分组
+            if (groupByCategory == 0) {
+                pList.forEach(p->{
+                    p.cost = p.cost.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.salary = p.salary.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.bonus = p.bonus.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.allowance = p.allowance.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.old = p.old.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.medical = p.medical.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.loseJob = p.loseJob.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.injury = p.injury.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.house = p.house.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.field1 = p.field1.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.field2 = p.field2.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.field3 = p.field3.setScale(2, BigDecimal.ROUND_HALF_UP);
+
+                    //组装写入excel文件的数据,从项目开始,项目下面挂成员
+                    List<String> rowData = new ArrayList<String>();
+                    rowData.add(p.projectCode);
+                    rowData.add(p.project);
+                    rowData.add("");
+                    rowData.add(p.workingTime+"");
+                    rowData.add(p.salary.toPlainString());
+                    rowData.add(p.bonus.toPlainString());
+                    rowData.add(p.allowance.toPlainString());
+                    rowData.add(p.old.toPlainString());
+                    rowData.add(p.medical.toPlainString());
+                    rowData.add(p.loseJob.toPlainString());
+                    rowData.add(p.injury.toPlainString());
+                    rowData.add(p.house.toPlainString());
+                    if (cusColList.size() > 0) {
+                        rowData.add(p.field1.toPlainString());
+                    }
+                    if (cusColList.size() > 1) {
+                        rowData.add(p.field2.toPlainString());
+                    }
+                    if (cusColList.size() > 2) {
+                        rowData.add(p.field3.toPlainString());
+                    }
+                    rowData.add(p.cost.toPlainString());
+                    allList.add(rowData);
+
+                    //获取成员
+                    for (Map<String, Object> membMap : projectTimeList) {
+                        if (membMap.get("project").equals(p.project)) {
+                            //匹配到项目了
+                            List<String> membRowData = new ArrayList<String>();
+                            membRowData.add("");
+                            membRowData.add("");
+                            Double workingTime = (Double) membMap.get("workingTime");
+                            String creatorId = (String) membMap.get("creatorId");
+                            User us = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst().get();
+                            Optional<Finance> first = finances.stream().filter(f -> f.getUserId().equals(creatorId)).findFirst();
+                            if (!first.isPresent()) {
+                                logger.info("用户["+us.getName()+"]在财务报表中不存在,请重新导入");
+                                continue;
+                            }
+                            Finance userFinance = first.get();
+
+                            BigDecimal cost = userFinance.getTotalCost().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal salary = userFinance.getMonthCost().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal bonus = userFinance.getBonus().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal allowance = userFinance.getAllowance().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal old = userFinance.getInsuranceOld().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal medical = userFinance.getInsuranceMedical().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal loseJob = userFinance.getInsuranceLosejob().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal injury = userFinance.getInsuranceInjury().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal house = userFinance.getHouseFund().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal field1 = userFinance.getCustomField1() == null? new BigDecimal(0):userFinance.getCustomField1().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal field2 = userFinance.getCustomField2() == null? new BigDecimal(0):userFinance.getCustomField2().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal field3 = userFinance.getCustomField3() == null? new BigDecimal(0):userFinance.getCustomField3().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
+                            membRowData.add(us.getName());
+                            membRowData.add(workingTime+"");
+                            membRowData.add(salary.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(bonus.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(allowance.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(old.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(medical.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(loseJob.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(injury.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            membRowData.add(house.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            //自定义字段
+                            if (cusColList.size() > 0) {
+                                membRowData.add(field1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            }
+                            if (cusColList.size() > 1) {
+                                membRowData.add(field2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            }
+                            if (cusColList.size() > 2) {
+                                membRowData.add(field3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            }
+                            membRowData.add(cost.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                            allList.add(membRowData);
                         }
-                        membRowData.add(cost.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                        allList.add(membRowData);
                     }
-                }
 
-                //无项目人员成本
-                if (assignNoProUser != null && assignNoProUser) {
-                    for (Finance npu : noProjectUser) {
-                        List<String> membRowData = new ArrayList<String>();
-                        membRowData.add("");
-                        membRowData.add("");
-                        Double workingTime = new Double(0);
-                        Finance userFinance = npu;
-                        Optional<Map> op = noPUserDataList.stream().filter(map->((Integer)map.get("projectId")).equals(p.projectId) && ((String)map.get("creatorId")).equals(npu.getUserId())).findFirst();
-                        if (op.isPresent()) {
-                            Map percentMap = op.get();
-                            double percent = (double)percentMap.get("percent");
-                            if (percent > 0) {
-                                //各项收入按比例计算,累加到当前项目上
-                                Finance newFinance = Finance.getByPercent(npu, percent);
-
-                                BigDecimal cost = newFinance.getTotalCost();
-                                BigDecimal salary = newFinance.getMonthCost();
-                                BigDecimal bonus = newFinance.getBonus();
-                                BigDecimal allowance = newFinance.getAllowance();
-                                BigDecimal old = newFinance.getInsuranceOld();
-                                BigDecimal medical = newFinance.getInsuranceMedical();
-                                BigDecimal loseJob = newFinance.getInsuranceLosejob();
-                                BigDecimal injury = newFinance.getInsuranceInjury();
-                                BigDecimal house = newFinance.getHouseFund();
-                                BigDecimal field1 = newFinance.getCustomField1() == null? new BigDecimal(0):newFinance.getCustomField1();
-                                BigDecimal field2 = newFinance.getCustomField2() == null? new BigDecimal(0):newFinance.getCustomField2();
-                                BigDecimal field3 = newFinance.getCustomField3() == null? new BigDecimal(0):newFinance.getCustomField3();
-
-                                membRowData.add(npu.getName());
-                                membRowData.add(workingTime+"");
-                                membRowData.add(salary.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(bonus.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(allowance.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(old.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(medical.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(loseJob.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(injury.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                membRowData.add(house.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                //自定义字段
-                                if (cusColList.size() > 0) {
-                                    membRowData.add(field1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                }
-                                if (cusColList.size() > 1) {
-                                    membRowData.add(field2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                }
-                                if (cusColList.size() > 2) {
-                                    membRowData.add(field3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                    //无项目人员成本
+                    if (assignNoProUser != null && assignNoProUser) {
+                        for (Finance npu : noProjectUser) {
+                            List<String> membRowData = new ArrayList<String>();
+                            membRowData.add("");
+                            membRowData.add("");
+                            Double workingTime = new Double(0);
+                            Finance userFinance = npu;
+                            Optional<Map> op = noPUserDataList.stream().filter(map->((Integer)map.get("projectId")).equals(p.projectId) && ((String)map.get("creatorId")).equals(npu.getUserId())).findFirst();
+                            if (op.isPresent()) {
+                                Map percentMap = op.get();
+                                double percent = (double)percentMap.get("percent");
+                                if (percent > 0) {
+                                    //各项收入按比例计算,累加到当前项目上
+                                    Finance newFinance = Finance.getByPercent(npu, percent);
+
+                                    BigDecimal cost = newFinance.getTotalCost();
+                                    BigDecimal salary = newFinance.getMonthCost();
+                                    BigDecimal bonus = newFinance.getBonus();
+                                    BigDecimal allowance = newFinance.getAllowance();
+                                    BigDecimal old = newFinance.getInsuranceOld();
+                                    BigDecimal medical = newFinance.getInsuranceMedical();
+                                    BigDecimal loseJob = newFinance.getInsuranceLosejob();
+                                    BigDecimal injury = newFinance.getInsuranceInjury();
+                                    BigDecimal house = newFinance.getHouseFund();
+                                    BigDecimal field1 = newFinance.getCustomField1() == null? new BigDecimal(0):newFinance.getCustomField1();
+                                    BigDecimal field2 = newFinance.getCustomField2() == null? new BigDecimal(0):newFinance.getCustomField2();
+                                    BigDecimal field3 = newFinance.getCustomField3() == null? new BigDecimal(0):newFinance.getCustomField3();
+
+                                    membRowData.add(npu.getName());
+                                    membRowData.add(workingTime+"");
+                                    membRowData.add(salary.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(bonus.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(allowance.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(old.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(medical.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(loseJob.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(injury.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    membRowData.add(house.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    //自定义字段
+                                    if (cusColList.size() > 0) {
+                                        membRowData.add(field1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    }
+                                    if (cusColList.size() > 1) {
+                                        membRowData.add(field2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    }
+                                    if (cusColList.size() > 2) {
+                                        membRowData.add(field3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    }
+                                    membRowData.add(cost.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
+                                    allList.add(membRowData);
                                 }
-                                membRowData.add(cost.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
-                                allList.add(membRowData);
                             }
                         }
                     }
+                });
+            } else {
+                //按项目分类分组,需要重组pList为一个项目分组一条
+                Map<String, List<ProjectSumItem>> categoryMap = pList.stream().collect(Collectors.groupingBy(ProjectSumItem::getCategoryName));
+                Iterator<String> keySet = categoryMap.keySet().iterator();
+                pList.clear();
+                while (keySet.hasNext()) {
+                    String cateName = keySet.next();
+                    List<ProjectSumItem> curList = categoryMap.get(cateName);
+                    ProjectSumItem p = curList.get(0);
+                    for (int i=1; i<curList.size(); i++) {
+                        ProjectSumItem nextItem = curList.get(i);
+                        p.cost = p.cost.add(nextItem.cost);
+                        p.salary = p.salary.add(nextItem.salary);
+                        p.bonus = p.bonus.add(nextItem.bonus);
+                        p.allowance = p.allowance.add(nextItem.allowance);
+                        p.old = p.old.add(nextItem.old);
+                        p.medical = p.medical.add(nextItem.medical);
+                        p.loseJob = p.loseJob.add(nextItem.loseJob);
+                        p.injury = p.injury.add(nextItem.injury);
+                        p.house = p.house.add(nextItem.house);
+                        p.field1 = p.field1.add(nextItem.field1);
+                        p.field2 = p.field2.add(nextItem.field2);
+                        p.field3 = p.field3.add(nextItem.field3);
+                    }
+                    //添加按分类汇总的项
+                    pList.add(p);
                 }
-            });
+                pList.forEach(p->{
+                    p.cost = p.cost.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.salary = p.salary.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.bonus = p.bonus.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.allowance = p.allowance.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.old = p.old.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.medical = p.medical.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.loseJob = p.loseJob.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.injury = p.injury.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.house = p.house.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.field1 = p.field1.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.field2 = p.field2.setScale(2, BigDecimal.ROUND_HALF_UP);
+                    p.field3 = p.field3.setScale(2, BigDecimal.ROUND_HALF_UP);
+
+                    List<String> rowData = new ArrayList<String>();
+                    rowData.add(p.categoryName);
+                    rowData.add(p.salary.toPlainString());
+                    rowData.add(p.bonus.toPlainString());
+                    rowData.add(p.allowance.toPlainString());
+                    rowData.add(p.old.toPlainString());
+                    rowData.add(p.medical.toPlainString());
+                    rowData.add(p.loseJob.toPlainString());
+                    rowData.add(p.injury.toPlainString());
+                    rowData.add(p.house.toPlainString());
+                    if (cusColList.size() > 0) {
+                        rowData.add(p.field1.toPlainString());
+                    }
+                    if (cusColList.size() > 1) {
+                        rowData.add(p.field2.toPlainString());
+                    }
+                    if (cusColList.size() > 2) {
+                        rowData.add(p.field3.toPlainString());
+                    }
+                    rowData.add(p.cost.toPlainString());
+                    allList.add(rowData);
+                });
+            }
+
 
             //合计
             List<String> sumRow = new ArrayList<String>();
             sumRow.add("合计");
-            sumRow.add("");
-            sumRow.add("");
-            sumRow.add(""+totalCostTime);
+            if (groupByCategory == 0) {
+                sumRow.add("");
+                sumRow.add("");
+                sumRow.add(""+totalCostTime);
+            }
             sumRow.add(totalSalary.toString());
             sumRow.add(totalBonus.toString());
             sumRow.add(totalAllowance.toString());
@@ -1001,7 +1023,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             sumRow.add(totalLoseJob.toString());
             sumRow.add(totalInjury.toString());
             sumRow.add(totalHouse.toString());
-//            sumRow.add(totalOther.toString());
 
             if (cusColList.size() > 0) sumRow.add(totalField1.toString());
             if (cusColList.size() > 1) sumRow.add(totalField2.toString());
@@ -1009,13 +1030,13 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             sumRow.add(totalMoneyCost.toString());
             allList.add(sumRow);
             //生成excel文件导出
-            String fileName = "财务人员成本_"+System.currentTimeMillis();
+            String fileName = yearMonth+(groupByCategory==0?"财务人员成本_":"财务项目分类成本_")+System.currentTimeMillis();
             String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , allList, path);
 
             httpRespMsg.data = resp;
         } catch (NullPointerException e) {
             e.printStackTrace();
-            httpRespMsg.setError("验证失败");
+            httpRespMsg.setError("验证失败:"+e.getMessage());
             return httpRespMsg;
         }
         return httpRespMsg;

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/LeaveSheetServiceImpl.java

@@ -62,7 +62,7 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
             //检查该时间段是否已经有按天请假
             QueryWrapper<LeaveSheet> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("owner_id", sheet.getOwnerId());
-            queryWrapper.nested(wrapper->wrapper.between("start_date", sheet.getStartDate(), sheet.getEndDate()).or().between("end_date", sheet.getStartDate(), sheet.getEndDate()));
+            queryWrapper.le("start_date", sheet.getEndDate()).ge("end_date", sheet.getStartDate());
 
             int count = leaveSheetMapper.selectCount(queryWrapper);
             if (count > 0) {

+ 0 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -1435,7 +1435,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 String projectId = ""+ (Integer) map.get("id");
                 String exeId = ""+ (Integer) map.get("exe_id");
                 String taskId = ""+ (Integer) map.get("task_id");
-                System.out.println(map.get("task_name")+", "+start_date+", "+end_date);
 
                 GanttDataItem curItem = new GanttDataItem();;
                 if (type == 0) {

+ 38 - 42
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -276,53 +276,49 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                         }
                     }
                 } else {
-                    //非部门经理,检查是否是项目经理
-                    int cnt = projectMapper.selectCount(new QueryWrapper<Project>().eq("incharger_id", leaderId));
-                    if (cnt > 0) {
-                        //担任项目经理,查找相关的人员的日报
-                        List<Map<String, Object>> puserNames = reportMapper.getReportNameByDate(date, user.getCompanyId(), leaderId);
-                        List<Map<String, Object>> inchargeReportList= reportMapper.getInchargeReportByDate(date, leaderId, null);
-
-                        for (Map<String, Object> map2 : puserNames) {
-                            if (nameList.size() > 0) {
-                                String myUserId = (String)nameList.get(0).get("id");
-                                if (myUserId.equals(map2.get("id"))) {
-                                    //自己的报告,之前已经添加过了,排重
-                                    continue;
-                                }
+                    //担任项目经理或者日报审核人,查找相关的人员的日报
+                    List<Map<String, Object>> puserNames = reportMapper.getReportNameByDate(date, user.getCompanyId(), leaderId);
+                    List<Map<String, Object>> inchargeReportList= reportMapper.getInchargeReportByDate(date, leaderId, null);
+
+                    for (Map<String, Object> map2 : puserNames) {
+                        if (nameList.size() > 0) {
+                            String myUserId = (String)nameList.get(0).get("id");
+                            if (myUserId.equals(map2.get("id"))) {
+                                //自己的报告,之前已经添加过了,排重
+                                continue;
                             }
-                            nameList.add(map2);
-                            //再根据人分别获取当天的报告
-                            List<Map<String, Object>> list2 =
-                                    inchargeReportList.stream().filter(i->i.get("creatorId").equals(map2.get("id"))).collect(Collectors.toList());
-                            map2.put("data", list2);
-
-                            double reportTime = 0;
-                            BigDecimal total = new BigDecimal(0);
-                            int state = 1;
-                            for (Map<String, Object> m : list2) {
-                                double t = (double) m.get("time");
-                                reportTime += t;
-                                total = total.add((BigDecimal)m.get("cost"));
-                                //取最低的状态
-                                if (state == 2) {
-                                    continue;
-                                }
-                                if (state == 0) {
-                                    if ((int)m.get("state") == 2) {
-                                        state = 2;
-                                    } else {
-                                        continue;
-                                    }
+                        }
+                        nameList.add(map2);
+                        //再根据人分别获取当天的报告
+                        List<Map<String, Object>> list2 =
+                                inchargeReportList.stream().filter(i->i.get("creatorId").equals(map2.get("id"))).collect(Collectors.toList());
+                        map2.put("data", list2);
+
+                        double reportTime = 0;
+                        BigDecimal total = new BigDecimal(0);
+                        int state = 1;
+                        for (Map<String, Object> m : list2) {
+                            double t = (double) m.get("time");
+                            reportTime += t;
+                            total = total.add((BigDecimal)m.get("cost"));
+                            //取最低的状态
+                            if (state == 2) {
+                                continue;
+                            }
+                            if (state == 0) {
+                                if ((int)m.get("state") == 2) {
+                                    state = 2;
                                 } else {
-                                    state = (int)m.get("state");
+                                    continue;
                                 }
+                            } else {
+                                state = (int)m.get("state");
                             }
-                            DecimalFormat df = new DecimalFormat("0.00");
-                            map2.put("reportTime", df.format(reportTime));
-                            map2.put("cost", total);
-                            map2.put("state", state);
                         }
+                        DecimalFormat df = new DecimalFormat("0.00");
+                        map2.put("reportTime", df.format(reportTime));
+                        map2.put("cost", total);
+                        map2.put("state", state);
                     }
                 }
             } else {

+ 5 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -224,7 +224,7 @@
         <if test="state != null">
             AND a.state=#{state}
         </if>
-        AND b.incharger_id = #{id}
+        AND (b.incharger_id = #{id} or a.project_auditor_id = #{id})
         ORDER BY a.creator_id ASC
     </select>
 
@@ -335,6 +335,7 @@
         SELECT DISTINCT b.id, b.name, a.state, a.department_audit_state as departmentAuditState
         FROM report AS a
         JOIN user AS b ON a.creator_id=b.id
+        left join project on project.id = a.project_id
         WHERE 1=1
         <if test="date != null and date != ''">
             AND a.create_date=#{date}
@@ -343,7 +344,7 @@
             AND b.company_id=#{companyId}
         </if>
         <if test="leaderId != null and leaderId != ''">
-            AND a.project_auditor_id = #{leaderId}
+            AND (a.project_auditor_id = #{leaderId} or project.incharger_id = #{leaderId})
         </if>
     </select>
 
@@ -432,7 +433,8 @@
     </select>
 
     <select id="getRealProjectTime" resultType="java.util.Map">
-        SELECT project.id as projectId, project.project_code as projectCode, IFNULL(project.project_name,'未知') as project,report.creator_id AS creatorId,sum(working_time) as workingTime, SUM(cost) as cost
+        SELECT project.id as projectId, project.project_code as projectCode, IFNULL(project.category_name,'其他') as categoryName,
+        IFNULL(project.project_name,'其他') as project,report.creator_id AS creatorId,sum(working_time) as workingTime, SUM(cost) as cost
         FROM report
         left join project on project.id = report.project_id
         WHERE report.creator_id IN

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet/build.bat

@@ -0,0 +1 @@
+npm run build

+ 19 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/project/finance.vue

@@ -212,7 +212,7 @@
             </el-form-item>
 
             <el-form-item style="float:right;margin-right:20px;" v-if="permissions.financialShare">
-                <el-link type="primary" :underline="false" @click="exportData">导出分摊数据</el-link>
+                <el-link type="primary" :underline="false" @click="exportFinanceDialog=true">导出分摊数据</el-link>
             </el-form-item>
             
             <!-- <el-form-item style="float:right;margin-right:30px;" v-if="hasNoProjectUsers">
@@ -495,6 +495,18 @@
                 <el-button type="primary" @click="showImportResult=false">确定</el-button>
             </span>
         </el-dialog>
+
+        <el-dialog title="分摊数据导出" v-if="exportFinanceDialog" :visible.sync="exportFinanceDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
+            <div style="margin:30px;">
+            <el-radio-group v-model="groupByCategory" >
+                <el-radio :label="0">按项目导出</el-radio>
+                <el-radio :label="1">按项目分类导出</el-radio>
+            </el-radio-group>
+            </div>
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="exportData" :loading="exportDataProcessing" type="primary">导出</el-button>
+            </div>
+        </el-dialog>
     </section>
 </template>
 <style scoped>
@@ -521,6 +533,8 @@ import { error } from 'dingtalk-jsapi';
     export default {
         data() {
             return {
+                groupByCategory:0,
+                exportFinanceDialog:false,
                 exportMonth:null,
                 exportDialog:false,
                 headerCols:['monthCost','bonus', 'allowance', 'insuranceOld', 'insuranceMedical', 'insuranceLosejob', 'insuranceInjury', 'houseFund', 'customField1','customField2','customField3'],
@@ -1160,13 +1174,14 @@ import { error } from 'dingtalk-jsapi';
             },
             //导出财务数据
             exportData() {
-                this.listLoading = true;
+                this.exportDataProcessing = true;
                 this.http.post('/finance/exportData', {
-                    date: this.date, assignNoProUser: this.assignNoProUser
+                    date: this.date, assignNoProUser: this.assignNoProUser, groupByCategory: this.groupByCategory
                 },
                 res => {
-                    this.listLoading = false;
+                    this.exportDataProcessing = false;
                     if (res.code == "ok") {
+                        this.exportFinanceDialog = false;
                         var aTag = document.createElement('a');
                         aTag.download = "财务成本统计.xls";
                         aTag.href = res.data;

+ 16 - 25
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -1884,23 +1884,19 @@
         },
         (res) => {
           if (res.code == "ok") {
-              this.tbload = false
+            this.tbload = false;
             this.pickDateArray = res.data.days;
             this.monthworkDate = res.data.list;
             // this.monthworkDateS = this.monthworkDate
             this.monthworkDateS1 = res.data.list
             this.monthTotal = res.data.list.length
-            // console.log('列表的总数据', this.monthworkDateS)
-            var infoList = []
-
             if (this.monthworkDateS1.length > 20) {
-                this.monthworkDateS1.forEach((val ,i) => {
-                if (i < 20) {
-                    infoList.push(val)
-                }
-                })
+                this.monthworkDateS = this.monthworkDateS1.slice(0,20);
+            }else{
+                this.monthworkDateS = this.monthworkDateS1 
             }
-            this.monthworkDateS = infoList
+            
+            // this.monthworkDateS = infoList
             // 判断
             if (this.monthworkDateS1.length > 0) {
                 setTimeout(() => {
@@ -1935,7 +1931,7 @@
             if (scrollDistance < 2) {
               if (that.monthworkDateS.length < that.monthworkDateS1.length) {
                 that.monthTotalPage++; //当前页数自增
-                // console.log(that.monthworkDateS1.length, that.monthworkDateS.length, that.monthTotalPage, that.monthTotalLages, that.monthTotalPage * that.monthTotalLages)
+                console.log(that.monthworkDateS1.length, that.monthworkDateS.length, that.monthTotalPage, that.monthTotalLages, that.monthTotalPage * that.monthTotalLages)
                 var arrList = JSON.parse(JSON.stringify(that.monthworkDateS1))
                 var infoList = arrList.splice(
                   that.monthTotalPage * that.monthTotalLages,
@@ -1965,21 +1961,16 @@
               this.tbload = false
             this.monthNotWorkDate = res.data;
             // this.monthNotWorkDateS = this.monthNotWorkDate
-            
+            // console.log("data",res.data);
             // console.log("monthNotWorkDate", this.monthNotWorkDate);
             this.monthnotworkDateS1 = res.data
             this.monthnotTotal = res.data.length
-            // console.log('列表的总数据', this.monthworkDateS)
-            var infoList = []
-
             if (this.monthnotworkDateS1.length > 20) {
-                this.monthnotworkDateS1.forEach((val ,i) => {
-                if (i < 20) {
-                    infoList.push(val)
-                }
-                })
+                this.monthNotWorkDateS = this.monthnotworkDateS1.slice(0,20);
+            } else {
+                this.monthNotWorkDateS = monthnotworkDateS1
             }
-            this.monthNotWorkDateS = infoList
+            
             // 判断
             if (this.monthnotworkDateS1.length > 0) {
                 setTimeout(() => {
@@ -1988,7 +1979,7 @@
             }
             // this.$forceUpdate();
             this.$nextTick(function(){
-                this.$refs.hasworkTbl.doLayout();
+                this.$refs.hasworkTbl2.doLayout();
             });
           }
         },
@@ -2004,12 +1995,12 @@
     tableListenernot(){
       let that = this;
       // this.$refs.maTable.bodyWarpper 
-      let dom2 = that.$refs.hasworkTbl2.bodyWrapper;
+      let dom = that.$refs.hasworkTbl2.bodyWrapper;
     //   console.log(dom2)
       	  // 添加scroll监听事件
-          dom2.addEventListener("scroll", function () {
+          dom.addEventListener("scroll", function () {
           // scrollHeight-scrollTop-clientHeight=0 用来判断滚动条到底部
-            const scrollDistance2 = dom2.scrollHeight - dom2.scrollTop - dom2.clientHeight;
+            const scrollDistance2 = dom.scrollHeight - dom.scrollTop - dom.clientHeight;
             if (scrollDistance2 < 2) {
               if (that.monthNotWorkDateS.length < that.monthnotworkDateS1.length) {
                 that.monthnotTotalPage++; //当前页数自增

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet_h5/build.bat

@@ -0,0 +1 @@
+npm run build