Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

yusm 4 mēneši atpakaļ
vecāks
revīzija
7b9c5ac5d1
42 mainītis faili ar 1519 papildinājumiem un 556 dzēšanām
  1. 1 1
      fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/components/common/foldingPanel.vue
  2. 1 0
      fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/hooks/useApi.js
  3. 107 7
      fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/contract/addEditor.vue
  4. 1 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ProductController.java
  5. 23 4
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/SalesOrderController.java
  6. 3 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/TaskController.java
  7. 6 7
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Information.java
  8. 3 3
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/BusinessTripServiceImpl.java
  9. 2 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java
  10. 5 5
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java
  11. 3 3
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/InformationServiceImpl.java
  12. 3 6
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/LeaveSheetServiceImpl.java
  13. 3 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  14. 2 3
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java
  15. 4 4
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/VisitPlanServiceImpl.java
  16. 3 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/time/VisitPlanTask.java
  17. 3 3
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ClueMapper.xml
  18. 1 1
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/CustomMapper.xml
  19. 165 115
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java
  20. 304 100
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskFilesController.java
  21. 9 10
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Project.java
  22. 50 58
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Task.java
  23. 52 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TaskFiles.java
  24. 10 6
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeType.java
  25. 1 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/bo/QueryTaskChargePage.java
  26. 14 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/ProjectTaskTimeCostVO.java
  27. 12 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/ProjectTimeCostVO.java
  28. 26 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/TaskFileChargePageVO.java
  29. 4 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/TaskCommentMapper.java
  30. 10 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/TaskFilesMapper.java
  31. 11 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/TaskMapper.java
  32. 8 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/TaskFilesService.java
  33. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/TaskService.java
  34. 15 5
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java
  35. 21 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DingDingServiceImpl.java
  36. 50 4
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  37. 199 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TaskFilesServiceImpl.java
  38. 170 126
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java
  39. 44 52
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java
  40. 7 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskCommentMapper.xml
  41. 34 2
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskFilesMapper.xml
  42. 128 22
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskMapper.xml

+ 1 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/components/common/foldingPanel.vue

@@ -80,7 +80,7 @@ const handleBox = () => {
     }
 
     .expand {
-      max-height: 1000px;
+      max-height: 800px;
     }
   }
 

+ 1 - 0
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/hooks/useApi.js

@@ -119,3 +119,4 @@ export const OBTAIN_SALES_ORDER_RECEIPTS = `/order/paymentCollectionList` // 获
 export const NEW_SALES_ORDER_PAYMENT_COLLECTION = `/order/paymentCollection` // 新建销售订单收款
 export const SALES_ORDER_COLLECTION_EDITING = `/order/editPayment` // 编辑销售订单收款
 export const DELETE_SALES_ORDER_PAYMENT_RECORDS = `/order/deletePayment` // 删除销售订单收款记录
+export const OBTAIN_THE_CONTRACT_REMITTANCE_LIST = `/contract-payment/getList` // 获取合同打款列表

+ 107 - 7
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/contract/addEditor.vue

@@ -2,28 +2,65 @@
   <div class="w-full h-full flex flex-col">
     <div class="flex-1 overflow-y-auto">
       <CustomerForm ref="formFormRef" :formJson="formJson" :formValue="formVal"></CustomerForm>
+      <template v-for="(item, index) in paymentPlanList">
+        <FoldingPanel :title="`回款计划(${index + 1})`" class="mb-4">
+          <template #foldingRight>
+            <div class="flex items-center">
+              <div class="pr-3 themeTextColor" @click="addPaymentCollection(index)">添加</div>
+              <div class="text-[red]" @click="deletePaymentCollection(index)">删除</div>
+            </div>
+          </template>
+          <template #foldContainer>
+            <div>
+              <van-cell title="是否已回款">
+                <template #default>
+                  <div class="flex justify-end">
+                    <van-checkbox v-model="item.isPayed">已回款</van-checkbox>
+                  </div>
+                </template>
+              </van-cell>
+              <van-cell title="回款日期" @click="showDatePicker(index)">
+                <template #default>
+                  <van-field v-model="item.payDate" input-align="right" placeholder="请选择日期" class="resetStyles" readonly />
+                </template>
+              </van-cell>
+              <van-cell title="回款金额">
+                <template #default>
+                  <van-field v-model="item.amount" type="digit" input-align="right" placeholder="请输入金额"
+                    class="resetStyles" />
+                </template>
+              </van-cell>
+            </div>
+          </template>
+        </FoldingPanel>
+      </template>
     </div>
     <div class="mar-20px ">
       <van-button type="primary" @click="onSubmit" class="w-full">
         {{ Object.keys(formVal).length > 0 ? '确定修改' : '确定添加' }}
       </van-button>
     </div>
+
+    <!-- 日期选择器 -->
+    <van-popup v-model:show="showPicker" destroy-on-close position="bottom" :style="{ height: '50%' }">
+      <van-date-picker v-model="pickerValue" @confirm="showPickerConfirm" @cancel="showPicker = false" />
+    </van-popup>
   </div>
 </template>
 
 <script setup>
-import { ref, onActivated } from 'vue';
+import { ref, onActivated, watch } from 'vue';
 import { useLifecycle } from '@hooks/useCommon.js';
 import CustomerForm from '@components/common/formForm/formView.vue'
 import requests from "@common/requests";
 import useToast from "@hooks/useToast"
-import { CONTRACT_ADDITION_EDITING, CONTRACT_EDITING } from "@hooks/useApi"
+import { CONTRACT_ADDITION_EDITING, CONTRACT_EDITING, OBTAIN_THE_CONTRACT_REMITTANCE_LIST } from "@hooks/useApi"
 import useRouterStore from "@store/useRouterStore.js";
+import FoldingPanel from '@components/common/foldingPanel.vue';
+import dayjs from 'dayjs';
 
 const router = useRouterStore()
-
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
-
 const props = defineProps({
   formJson: { required: true },
   formValue: { required: true },
@@ -31,14 +68,45 @@ const props = defineProps({
 
 const formFormRef = ref(null)
 const formVal = ref({})
+const paymentPlanList = ref([{}])
+const showPicker = ref(false)
+const pickerValue = ref([])
+const rowIndex = ref(0)
+
+watch(() => formVal.value, (newValue) => {
+  console.log(newValue, '<==== 看看')
+  if (!newValue.id) {
+    paymentPlanList.value = [{}]
+    return
+  }
+
+  getPaymentCollectionList(newValue.id)
+})
+
 
 function onSubmit() {
   formFormRef.value.getJsonData().then((res) => {
-    if(!res.data) {
+    if (!res.data) {
       return
     }
+
+    for(let i in paymentPlanList.value) {
+      const row = paymentPlanList.value[i]
+      if(!row.payDate) {
+        toastText('回款日期不能为空')
+        return
+      }
+      if(!row.amount || row.amount == 0) {
+        toastText('回款金额不能为空和0')
+        return
+      }
+      if(formVal.value.id) {
+        paymentPlanList.value[i].contractId = formVal.value.id
+      }
+    }
+
     toastLoading('保存中', 0)
-    requests.post(props.formValue?.id ? CONTRACT_EDITING : CONTRACT_ADDITION_EDITING, { ...props.formValue, ...res.data }).then(() => {
+    requests.post(props.formValue?.id ? CONTRACT_EDITING : CONTRACT_ADDITION_EDITING, { ...props.formValue, ...res.data, paymentListStr: JSON.stringify(paymentPlanList.value) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({
@@ -53,20 +121,52 @@ function onSubmit() {
   })
 }
 
+function addPaymentCollection(index) {
+  paymentPlanList.value.splice(index + 1, 0, { isPayed: false, payDate: dayjs(new Date()).format('YYYY-MM-DD'), amount: null })
+}
+
+function deletePaymentCollection(index) {
+  paymentPlanList.value.splice(index, 1)
+}
+
+function showDatePicker(index) {
+  const { payDate } = paymentPlanList.value[index];
+  rowIndex.value = index;
+  const currentDate = dayjs(payDate ? new Date(payDate) : new Date()).format('YYYY-MM-DD').split('-');
+  pickerValue.value = currentDate;
+  showPicker.value = true;
+}
+
+function showPickerConfirm({ selectedValues }) {
+  paymentPlanList.value[rowIndex.value].payDate = selectedValues.join("-");
+  showPicker.value = false;
+}
+
+function getPaymentCollectionList(id) {
+  requests.post(OBTAIN_THE_CONTRACT_REMITTANCE_LIST, { contractId: id }).then((res) => {
+    paymentPlanList.value = res.data.length > 0 ? res.data : [{}]
+  })
+}
+
 useLifecycle({
   load: () => {
     formVal.value = props.formValue
+    paymentPlanList.value = [{}]
   },
   init: () => {
     formVal.value = props.formValue
+    paymentPlanList.value = [{}]
   }
 });
 
 onActivated(() => {
-  
+
 })
 </script>
 
 <style lang='scss' scoped>
 /* 样式代码 */
+.resetStyles {
+  padding: 0;
+}
 </style>

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ProductController.java

@@ -167,7 +167,7 @@ public class ProductController {
                 msg.setError("存在已绑定到相关任务的产品,删除失败");
                 return msg;
             }
-            if(orderProductDetailService.count(new LambdaQueryWrapper<OrderProductDetail>().in(OrderProductDetail::getOrderId,idList))>0){
+            if(orderProductDetailService.count(new LambdaQueryWrapper<OrderProductDetail>().in(OrderProductDetail::getProductId,idList))>0){
                 msg.setError("存在关联订单的产品,删除失败");
                 return msg;
             }

+ 23 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/SalesOrderController.java

@@ -235,6 +235,10 @@ public class SalesOrderController {
                 msg.setError("存在关联产品的订单,删除失败");
                 return msg;
             }
+            if(taskService.count(new LambdaQueryWrapper<Task>().eq(Task::getIsDelete,0).in(Task::getOrderId,idList))>0){
+                msg.setError("存在关联任务的订单,删除失败");
+                return msg;
+            }
             orderList.forEach(o->{
                 o.setIsDelete(1);
                 o.setUpdateTime(LocalDateTime.now());
@@ -513,7 +517,17 @@ public class SalesOrderController {
         SalesOrderPayment payment = salesOrderPaymentService.getById(paymentId);
         SalesOrder salesOrder = salesOrderService.getById(payment.getOrderId());
         List<SalesOrderPayment> list = salesOrderPaymentService.list(new LambdaQueryWrapper<SalesOrderPayment>().eq(SalesOrderPayment::getOrderId, salesOrder.getId()).orderByAsc(SalesOrderPayment::getCreateTime));
-        int i = list.indexOf(payment);
+//        int i = list.indexOf(payment);
+        int i = 0;
+        for (SalesOrderPayment salesOrderPayment : list) {
+            if(salesOrderPayment.getId().equals(paymentId)){
+                break;
+            }
+            i++;
+        }
+
+        System.out.println("i==="+i);
+
         if(money!=null){
             if(salesOrder.getReceivedStatus()==2){
                 msg.setError("当前订单已完全回款");
@@ -532,9 +546,14 @@ public class SalesOrderController {
             BigDecimal nowMoney = new BigDecimal(money);
             BigDecimal oldMoney = payment.getMoney();
             //离当前回款数据最近一次回款的未回款数据作为依据
-            SalesOrderPayment salesOrderPayment =list.size()>1?list.get(i-1):list.get(i);
-            BigDecimal unReceivedPayment = salesOrderPayment.getUnReceivedPayment();
-            unReceivedPayment=unReceivedPayment.add(oldMoney).subtract(nowMoney);
+            BigDecimal unReceivedPayment = new BigDecimal(0);
+            if(i ==0){
+                unReceivedPayment = salesOrder.getPrice().subtract(payment.getMoney());
+            }else{
+                SalesOrderPayment salesOrderPayment =list.size()>1?list.get(i-1):list.get(i);
+                unReceivedPayment = salesOrderPayment.getUnReceivedPayment();
+                unReceivedPayment=unReceivedPayment.add(oldMoney).subtract(nowMoney);
+            }
             payment.setMoney(new BigDecimal(money));
             payment.setUnReceivedPayment(unReceivedPayment);
             if(!salesOrderPaymentService.updateById(payment)){

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

@@ -316,7 +316,8 @@ public class TaskController {
             for (String userId : executorIdList) {
                 Information information = new Information();
                 information.setUserId(userId).setMsg(msg)
-                        .setTime(new Date()).setChecked(0);
+                        .setTime(new Date()).setChecked(0)
+                        .setPath("/tasks");
                 informationArrayList.add(information);
             }
             informationService.saveBatch(informationArrayList);
@@ -335,7 +336,7 @@ public class TaskController {
             for (String userId : executorIdList) {
                 Information information = new Information();
                 information.setUserId(userId).setMsg(msg)
-                        .setTime(new Date()).setChecked(0);
+                        .setTime(new Date()).setChecked(0).setPath("/tasks");
                 informationArrayList.add(information);
                 User user = userMapper.selectById(userId);
                 WxCorpInfo corpinfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));

+ 6 - 7
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Information.java

@@ -1,17 +1,16 @@
 package com.management.platform.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-import java.util.Date;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import java.io.Serializable;
+import java.util.Date;
+
 /**
  * <p>
  * 提示消息
@@ -66,7 +65,7 @@ public class Information extends Model<Information> {
     @TableField("msg")
     private String msg;
 
-    @TableField(exist = false)
+    @TableField("path")
     private String path;
 
 

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

@@ -1,17 +1,15 @@
 package com.management.platform.service.impl;
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.controller.AuditWorkflowSettingController;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
 import com.management.platform.service.AuditWorkflowSettingService;
 import com.management.platform.service.BusinessTripService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.service.DepartmentService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
@@ -353,6 +351,7 @@ public class BusinessTripServiceImpl extends ServiceImpl<BusinessTripMapper, Bus
                 +(auditor.getCorpwxUserid() != null ? ("$userName="+auditor.getCorpwxUserid()+"$"):auditor.getName()));
         information.setType(5);
         information.setContent(sheet.getId()+"");
+        information.setPath("/business-trip");
         informationMapper.insert(information);
     }
 
@@ -365,6 +364,7 @@ public class BusinessTripServiceImpl extends ServiceImpl<BusinessTripMapper, Bus
         information.setMsg("出差待审核, 申请人:" + (owner.getCorpwxUserid() != null?("$userName="+owner.getCorpwxUserid()+"$"):owner.getName()));
         information.setType(5);
         information.setContent(sheet.getId()+"");
+        information.setPath("/business-trip");
         informationMapper.insert(information);
     }
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java

@@ -1116,6 +1116,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
             information.setUserId(target.getCreatorId());
             information.setType(6);
             information.setMsg("您提交的合同[" + target.getName() + "]由[" + user.getName() + "]审核通过。");
+            information.setPath("/contract");
             informationMapper.insert(information);
         }else if (status.equals(2)){
             contractLog.setType(3);
@@ -1130,6 +1131,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
             int i = item.indexOf("原因:");
             String substring = item.substring(i, item.length());
             information.setMsg("您提交的合同[" + target.getName() + "]被[" + user.getName() + "]驳回," + substring + "。");
+            information.setPath("/contract");
             informationMapper.insert(information);
         }
         contractLogMapper.insert(contractLog);

+ 5 - 5
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -5,11 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.jayway.jsonpath.internal.function.numeric.Sum;
-import com.management.platform.constant.Constant;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
@@ -20,7 +17,6 @@ import com.management.platform.util.MessageUtils;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.CellType;
-import org.apache.poi.ss.usermodel.Header;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -37,7 +33,6 @@ import java.io.*;
 import java.math.BigDecimal;
 import java.time.Instant;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -251,6 +246,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                         information.setMsg("费用报销待审核");
                         information.setType(3);
                         information.setContent(sheet.getCreateDate()+"");
+                        information.setPath("/expense-sheet");
                         informationList.add(information);
                     }
                     informationService.saveBatch(informationList);
@@ -346,6 +342,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                         information.setMsg("费用报销待审核");
                         information.setType(3);
                         information.setContent(sheet.getCreateDate()+"");
+                        information.setPath("/expense-sheet");
                         informationList.add(information);
                     }
                     informationService.saveBatch(informationList);
@@ -398,6 +395,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 information.setMsg("费用报销待审核");
                 information.setType(3);
                 information.setContent(sheet.getCreateDate()+"");
+                information.setPath("/expense-sheet");
                 informationList.add(information);
             }
             informationService.saveBatch(informationList);
@@ -680,6 +678,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     information.setMsg("费用报销待审核");
                     information.setType(3);
                     information.setContent(sheet.getCreateDate()+"");
+                    information.setPath("/expense-sheet");
                     informationList.add(information);
                 }
                 informationService.saveBatch(informationList);
@@ -794,6 +793,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 +(auditor.getCorpwxUserid() != null ? ("$userName="+auditor.getCorpwxUserid()+"$"):auditor.getName()));
         information.setType(3);//费用报销模块
         information.setContent(sheet.getId()+"");
+        information.setPath("/expense-sheet");
         informationMapper.insert(information);
     }
 

+ 3 - 3
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/InformationServiceImpl.java

@@ -69,9 +69,9 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
                 }
             }
 
-            information.forEach(i->{
-                i.setPath("/tasks");
-            });
+//            information.forEach(i->{
+//                i.setPath("/tasks");
+//            });
             httpRespMsg.data = information;
         } catch (NullPointerException e) {
             //httpRespMsg.setError("验证失败");

+ 3 - 6
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/LeaveSheetServiceImpl.java

@@ -5,13 +5,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.controller.AuditWorkflowSettingController;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import com.management.platform.util.WorkDayCalculateUtils;
@@ -19,15 +18,11 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import javax.xml.transform.Source;
 import java.math.BigDecimal;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -214,6 +209,7 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
                 +(auditor.getCorpwxUserid() != null ? ("$userName="+auditor.getCorpwxUserid()+"$"):auditor.getName()));
         information.setType(4);
         information.setContent(sheet.getId()+"");
+        information.setPath("/leave-sheet");
         informationMapper.insert(information);
     }
 
@@ -226,6 +222,7 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
         information.setMsg("请假待审核, 请假人:" + (owner.getCorpwxUserid() != null?("$userName="+owner.getCorpwxUserid()+"$"):owner.getName()));
         information.setType(4);
         information.setContent(sheet.getId()+"");
+        information.setPath("/leave-sheet");
         informationMapper.insert(information);
     }
 

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

@@ -2598,6 +2598,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             information.setContent(format);//日报的日期
             //information.setMsg(projectName+"项目,日报审批通过");
             information.setMsg(projectName + MessageUtils.message("other.proDailyRep"));
+            information.setPath("/report");
             informationList.add(information);
 
             userIdList.add(n.getUserId());
@@ -2819,7 +2820,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             fillUserId = oneReport.getCreatorId();
         }
 
-        informationMapper.insert(new Information().setType(0).setContent(date).setUserId(fillUserId).setMsg(str));
+        informationMapper.insert(new Information().setType(0).setContent(date).setUserId(fillUserId).setMsg(str).setPath("/report"));
         //对导入审核,添加记录
         int channel = oldState == -1 ? 0 : 1; //0-导入审核, 项目报告审核
         ReportAuditLog log = new ReportAuditLog();
@@ -6259,7 +6260,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             String str = MessageUtils.message("report.dailyReject", createDate, pNames, user.getName(), reason);
             String fillUserId = oneReport.getCreatorId();
 
-            informationMapper.insert(new Information().setType(0).setContent(createDate).setUserId(fillUserId).setMsg(str));
+            informationMapper.insert(new Information().setType(0).setContent(createDate).setUserId(fillUserId).setMsg(str).setPath("/report"));
 
             //发送企业微信通知消息
             User reporter = userMapper.selectById(fillUserId);

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

@@ -14,7 +14,6 @@ import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
-import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.xssf.usermodel.XSSFCell;
@@ -171,7 +170,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 taskExecutorMapper.insert(taskExecutor);
                 information.setUserId(executorId);
             }
-            information.setTime(new Date()).setChecked(0).setMsg("你有新的任务");
+            information.setTime(new Date()).setChecked(0).setMsg("你有新的任务").setPath("/tasks");
             informationArrayList.add(information);
             informationService.saveBatch(informationArrayList);
             if (wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
@@ -865,7 +864,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
 
                                 Information information = new Information();
                                 information.setUserId(userList.stream().filter(u -> u.getId().equals(userId)).collect(Collectors.toList()).get(0).getId());
-                                information.setMsg("你有新的任务").setTime(new Date()).setChecked(0);
+                                information.setMsg("你有新的任务").setTime(new Date()).setChecked(0).setPath("/tasks");
                                 informationArrayList.add(information);
                             }
                         }

+ 4 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/VisitPlanServiceImpl.java

@@ -244,10 +244,10 @@ public class VisitPlanServiceImpl extends ServiceImpl<VisitPlanMapper, VisitPlan
             return httpRespMsg;
         }
         VisitPlan taskPlan = visitPlanMapper.selectById(planId);
-        if(1 == taskPlan.getFinishState()){
-            httpRespMsg.setError("无法修改已完成的计划");
-            return httpRespMsg;
-        }
+//        if(1 == taskPlan.getFinishState()){
+//            httpRespMsg.setError("无法修改已完成的计划");
+//            return httpRespMsg;
+//        }
         Date oldVisitTime = taskPlan.getVisitTime();
         long milliCosts = oldVisitTime.getTime() - now.getTime();
         if(milliCosts <= 30 * 60 * 1000 && milliCosts > 0){

+ 3 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/time/VisitPlanTask.java

@@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -41,6 +42,7 @@ public class VisitPlanTask {
     public void checkRemindMessage() {
         Date now = new Date();
         System.out.println("===开始检查该分钟需提醒的访客计划==="+now);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         List<VisitPlan> visitPlans = visitPlanMapper.getMinuteVisitPlans(now);
         System.out.println("需提醒计划数量为: "+visitPlans.size());
         List<WxCorpInfo> wxCorpInfos = wxCorpInfoMapper.selectList(null);
@@ -65,6 +67,7 @@ public class VisitPlanTask {
                 String join = StringUtils.join(wxIds, '|');
                 if (wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&StringUtils.isNotBlank(join)){
                     // getCorpwxUserid  以 | 隔开 可分割开放
+                    System.out.println("公司:"+companyId+"在时刻"+sdf.format(now)+"的访客ids=== "+entry.getValue().stream().map(VisitPlan::getId).collect(Collectors.toList()));
                     wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,join,"访客计划提醒",null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_VISIT_PLAN);
                 }
 

+ 3 - 3
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ClueMapper.xml

@@ -518,13 +518,13 @@
         </if>
         order by c.need_pin desc,c.pin_time desc
         <choose>
-            <when test="isDesc == null">
+            <when test="clue.isDesc == null">
                 ,c.id DESC
             </when>
-            <when test="isDesc == 0">
+            <when test="clue.isDesc == 0">
                 ,sd.seq ASC, c.id DESC
             </when>
-            <when test="isDesc == 1">
+            <when test="clue.isDesc == 1">
                 ,sd.seq DESC, c.id DESC
             </when>
             <otherwise>

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/CustomMapper.xml

@@ -547,7 +547,7 @@
         incharger_id,
         (select `name` from `user` where id = incharger_id) inchargerName,
         creator_id,
-        (select `name` from `user` where id = creator_id) creatorName,c.need_pin,c.pin_time
+        (select `name` from `user` where id = creator_id) creatorName,need_pin,pin_time
         from custom
         where company_id = #{companyId}
         and is_delete =#{isDelete}

+ 165 - 115
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java

@@ -112,23 +112,21 @@ public class TaskController {
     @Value(value = "${upload.path}")
     private String path;
 
-    //用于控制线程锁
-    public static HashMap<String, CorpwxJobResult> corpwxJobCenter = new HashMap();
-    public static HashMap<String, Integer> corpddJobCenter = new HashMap();
-    @Autowired
-    private ProjectCategoryMapper projectCategoryMapper;
-
     @Resource
-    private TimeTypeMapper timeTypeMapper;
+    private TaskFilesMapper taskFilesMapper;
 
     @Resource
-    private DepartmentMapper departmentMapper;
-    @Autowired
-    private TaskFilesMapper taskFilesMapper;
+    private TimeTypeMapper timeTypeMapper;
 
     @Resource
     private WxCorpInfoMapper wxCorpInfoMapper;
 
+    //用于控制线程锁
+    public static HashMap<String, CorpwxJobResult> corpwxJobCenter = new HashMap();
+    public static HashMap<String, Integer> corpddJobCenter = new HashMap();
+    @Autowired
+    private ProjectCategoryMapper projectCategoryMapper;
+
     @PostMapping("/getTaskChargePage")
     public HttpRespMsg getTaskChargePage(
             QueryTaskChargePage queryBO, HttpServletRequest request) {
@@ -145,23 +143,23 @@ public class TaskController {
     }
 
 
-    /***
-     * 文件审核
-     * @param taskId 任务id
-     * @param projectId 项目id
-     * @param auditStatus 审核状态 1通过 2驳回
-     * @param reason 驳回理由
-     * @param request
-     * @return
-     */
-    @PostMapping("/auditFile")
-    public HttpRespMsg auditFile(@RequestParam("taskId")Integer taskId
-            ,@RequestParam("projectId")String projectId
-            ,@RequestParam("auditStatus")Integer auditStatus
-            ,@RequestParam(value = "reason",required = false)String reason
-            ,HttpServletRequest request) {
-        return taskService.auditFile(taskId,projectId,auditStatus,reason,request);
-    }
+//    /***
+//     * 文件审核
+//     * @param taskId 任务id
+//     * @param projectId 项目id
+//     * @param auditStatus 审核状态 1通过 2驳回
+//     * @param reason 驳回理由
+//     * @param request
+//     * @return
+//     */
+//    @PostMapping("/auditFile")
+//    public HttpRespMsg auditFile(@RequestParam("taskId")Integer taskId
+//            ,@RequestParam("projectId")String projectId
+//            ,@RequestParam("auditStatus")Integer auditStatus
+//            ,@RequestParam(value = "reason",required = false)String reason
+//            ,HttpServletRequest request) {
+//        return taskService.auditFile(taskId,projectId,auditStatus,reason,request);
+//    }
 
     @RequestMapping("/save")
     @Transactional
@@ -180,24 +178,24 @@ public class TaskController {
             task.setCreaterName(user.getName());
             task.setCreatorColor(user.getColor());
             task.setCompanyId(user.getCompanyId());
-            TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-            Integer taskFileCharge = timeType.getTaskFileCharge();
-            if(1 == taskFileCharge){
-                //主管: 员工所在部门[department]的manager_id 阶段一
-                //项目经理:project表的in_charge_id 阶段二
-                Department department = departmentMapper.selectById(user.getDepartmentId());
-                Project project = projectMapper.selectById(task.getProjectId());
-                if(org.apache.commons.lang3.StringUtils.isBlank(department.getManagerId())){
-                    msg.setError("员工所在部门无负责人,请重新设置");
-                    return msg;
-                }
-                if(org.apache.commons.lang3.StringUtils.isBlank(project.getInchargerId())){
-                    msg.setError("该项目未设置项目经理,请重新设置");
-                    return msg;
-                }
-                task.setChargeOneId(department.getManagerId());
-                task.setChargeTwoId(project.getInchargerId());
-            }
+//            TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
+//            Integer taskFileCharge = timeType.getTaskFileCharge();
+//            if(1 == taskFileCharge){
+//                //主管: 员工所在部门[department]的manager_id 阶段一
+//                //项目经理:project表的in_charge_id 阶段二
+//                Department department = departmentMapper.selectById(user.getDepartmentId());
+//                Project project = projectMapper.selectById(task.getProjectId());
+//                if(org.apache.commons.lang3.StringUtils.isBlank(department.getManagerId())){
+//                    msg.setError("员工所在部门无负责人,请重新设置");
+//                    return msg;
+//                }
+//                if(org.apache.commons.lang3.StringUtils.isBlank(project.getInchargerId())){
+//                    msg.setError("该项目未设置项目经理,请重新设置");
+//                    return msg;
+//                }
+//                task.setChargeOneId(department.getManagerId());
+//                task.setChargeTwoId(project.getInchargerId());
+//            }
         }
         if (!StringUtils.isEmpty(executorListStr)) {
             List<User> allUsers = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
@@ -332,15 +330,15 @@ public class TaskController {
                 needRecalculateProgress = true;
             }
         } else {
-            task.setChargeOneId(null);
-            task.setChargeStage(null);
-            task.setChargeOneStatus(null);
-            task.setChargeOneTime(null);
-            task.setChargeTwoId(null);
-            task.setChargeTwoStatus(null);
-            task.setChargeTwoTime(null);
-            task.setFinalChargeStatus(null);
-            task.setFileRejectReason(null);
+//            task.setChargeOneId(null);
+//            task.setChargeStage(null);
+//            task.setChargeOneStatus(null);
+//            task.setChargeOneTime(null);
+//            task.setChargeTwoId(null);
+//            task.setChargeTwoStatus(null);
+//            task.setChargeTwoTime(null);
+//            task.setFinalChargeStatus(null);
+//            task.setFileRejectReason(null);
             //更新的情况,需要对比是否修改了任务标题,更新子任务的parentTname
             Task oldTask = taskService.getById(task.getId());
             if (!oldTask.getName().equals(task.getName())) {
@@ -1368,77 +1366,129 @@ public class TaskController {
         List<Integer> collect = list.stream().map(l -> l.getId()).distinct().collect(Collectors.toList());
         collect.add(-1);
         List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().in("task_id", collect));
-        List<TaskFiles> taskFilesList = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>().in(TaskFiles::getTaskId, collect));
+        List<TaskFiles> taskFilesList = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>().eq(TaskFiles::getNeedFileCharge,1).in(TaskFiles::getTaskId, collect));
         List<Integer> pids = list.stream().map(Task::getProjectId).collect(Collectors.toList());
         pids.add(-1);
         List<Project> projectList = projectService.list(new QueryWrapper<Project>().in("id", pids));
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
-        CompanyDingding dingding = companyDingdingService.getOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
+//        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
+//        CompanyDingding dingding = companyDingdingService.getOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
         if(1 == timeType.getTaskFileCharge()){
-            List<String> userIds = new ArrayList<>();
-            List<String> chargeOneIds = list.stream().filter(t-> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeOneId()))
-                    .map(Task::getChargeOneId).collect(Collectors.toList());
-            List<String> chargeTwoIds = list.stream().filter(t-> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeTwoId()))
-                    .map(Task::getChargeTwoId).collect(Collectors.toList());
-            userIds.addAll(chargeOneIds);
-            userIds.addAll(chargeTwoIds);
-
-            Map<String, User> userIdMap = new HashMap<>();
-            if(CollectionUtils.isNotEmpty(userIds)){
-                userIds = userIds.stream().distinct().collect(Collectors.toList());
-                List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
-                                .select(User::getId,User::getName)
-                        .in(User::getId, userIds)
-                );
-                userIdMap = users.stream().collect(Collectors.toMap(User::getId, t->t));
-            }
-            Map<Integer, List<TaskFiles>> taskFilesMap = new HashMap<>();
-            if(CollectionUtils.isNotEmpty(taskFilesList)){
-                taskFilesMap  = taskFilesList.stream().collect(Collectors.groupingBy(TaskFiles::getTaskId));
-            }
+            //根据该任务下的文件所处的状态判断
             for (Task task : list) {
-                List<TaskFiles> tmp = taskFilesMap.get(task.getId());
-                if(CollectionUtils.isEmpty(tmp)){
-                    continue;
-                }
-                if(org.apache.commons.lang3.StringUtils.isBlank(task.getChargeOneId()) || org.apache.commons.lang3.StringUtils.isBlank(task.getChargeTwoId())){
-                    continue;
-                }
-                if(1 == task.getFinalChargeStatus()){
-                    task.setFinalChargeStatusText("审核通过");
-                    task.setFileChargeStatus(1);
-                } else if (0 == task.getFinalChargeStatus()) {
-                    String name = "";
-                    String statusText = "";
-                    String userWxId = "";
-                    String fileChargeStatusText = "";
-                    int finalStatus = 1==task.getChargeStage()?task.getChargeOneStatus():task.getChargeTwoStatus();
-                    String tmpUserId = 1==task.getChargeStage()?task.getChargeOneId():task.getChargeTwoId();
-                    User chargeUser = userIdMap.get(tmpUserId);
-                    if(null != chargeUser){
-                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                            userWxId = chargeUser.getCorpwxRealUserid();
-                        }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
-                            userWxId = chargeUser.getDingdingUserid();
-                        }
-                        name = chargeUser.getName();
-                    }
-                    switch (finalStatus)
-                    {
-                        case 0:  statusText = "待审核"; task.setFileChargeStatus(0);break;
-                        case 1:  statusText = "通过";break;
-                        case 2:  statusText = "驳回"; task.setFileChargeStatus(2);break;
-                    }
-                    if(org.apache.commons.lang3.StringUtils.isBlank(userWxId)){
-                        fileChargeStatusText = statusText+"("+name+")";
-                    }else{
-                        fileChargeStatusText = statusText+"("+("$userName=" + userWxId + "$")+")";
+                /**
+                 * 1、是否存在驳回文件
+                 *      过滤出上传人为当前登录人或审核人为当前登录人的任务文件
+                 *      若存在驳回文件,则显示存在驳回文件
+                 * 2、审核通过
+                 *      过滤出上传人为当前登录人或审核人为当前登录人的任务文件
+                 *      若都审核通过,则显示审核通过
+                 * 3、待审核
+                 *      过滤出上传人为当前登录人或审核人为当前登录人的任务文件
+                 *      若都是待审核或部分审核通过状态,则显示审核中
+                 **/
+                List<TaskFiles> currentTaskFiles = taskFilesList.stream().filter(tmp -> tmp.getTaskId().equals(task.getId()))
+                        .filter(t->{
+                            if(userId.equals(t.getCreatorId())){
+                                return true;
+                            } else if (userId.equals(t.getChargeOneId())) {
+                                return true;
+                            } else if (userId.equals(t.getChargeTwoId())) {
+                                return true;
+                            }else {
+                                return false;
+                            }
+                        })
+                        .collect(Collectors.toList());
+                if(CollectionUtils.isNotEmpty(currentTaskFiles)){
+                    //是否存在驳回
+                    long rejectCount = currentTaskFiles.stream().filter(tmp -> {
+                                if (2 == tmp.getChargeOneStatus() || 2 == tmp.getChargeTwoStatus()) {
+                                    return true;
+                                } else {
+                                    return false;
+                                }
+                            }).count();
+                    //是否都是全部通过
+                    long allPassCount = currentTaskFiles.stream().filter(tmp -> 1 == tmp.getFinalChargeStatus()).count();
+                    if(rejectCount > 0 ){
+                        task.setFileChargeStatus(2);
+                        task.setFinalChargeStatusText("存在驳回文件");
+                    } else if (allPassCount == currentTaskFiles.size()) {
+                        task.setFileChargeStatus(3);
+                        task.setFinalChargeStatusText("审核通过");
+                    }else {
+                        task.setFileChargeStatus(1);
+                        task.setFinalChargeStatusText("审核中");
                     }
-                    task.setFinalChargeStatusText(fileChargeStatusText);
+
                 }
+
             }
+
         }
+//            List<String> userIds = new ArrayList<>();
+//            List<String> chargeOneIds = list.stream().filter(t-> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeOneId()))
+//                    .map(Task::getChargeOneId).collect(Collectors.toList());
+//            List<String> chargeTwoIds = list.stream().filter(t-> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeTwoId()))
+//                    .map(Task::getChargeTwoId).collect(Collectors.toList());
+//            userIds.addAll(chargeOneIds);
+//            userIds.addAll(chargeTwoIds);
+//            Map<String, User> userIdMap = new HashMap<>();
+//            if(CollectionUtils.isNotEmpty(userIds)){
+//                userIds = userIds.stream().distinct().collect(Collectors.toList());
+//                List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
+//                                .select(User::getId,User::getName)
+//                        .in(User::getId, userIds)
+//                );
+//                userIdMap = users.stream().collect(Collectors.toMap(User::getId, t->t));
+//            }
+//            Map<Integer, List<TaskFiles>> taskFilesMap = new HashMap<>();
+//            if(CollectionUtils.isNotEmpty(taskFilesList)){
+//                taskFilesMap  = taskFilesList.stream().collect(Collectors.groupingBy(TaskFiles::getTaskId));
+//            }
+//            for (Task task : list) {
+//                List<TaskFiles> tmp = taskFilesMap.get(task.getId());
+//                if(CollectionUtils.isEmpty(tmp)){
+//                    continue;
+//                }
+//                if(org.apache.commons.lang3.StringUtils.isBlank(task.getChargeOneId()) || org.apache.commons.lang3.StringUtils.isBlank(task.getChargeTwoId())){
+//                    continue;
+//                }
+//                if(1 == task.getFinalChargeStatus()){
+//                    task.setFinalChargeStatusText("审核通过");
+//                    task.setFileChargeStatus(1);
+//                } else if (0 == task.getFinalChargeStatus()) {
+//                    String name = "";
+//                    String statusText = "";
+//                    String userWxId = "";
+//                    String fileChargeStatusText = "";
+//                    int finalStatus = 1==task.getChargeStage()?task.getChargeOneStatus():task.getChargeTwoStatus();
+//                    String tmpUserId = 1==task.getChargeStage()?task.getChargeOneId():task.getChargeTwoId();
+//                    User chargeUser = userIdMap.get(tmpUserId);
+//                    if(null != chargeUser){
+//                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+//                            userWxId = chargeUser.getCorpwxRealUserid();
+//                        }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
+//                            userWxId = chargeUser.getDingdingUserid();
+//                        }
+//                        name = chargeUser.getName();
+//                    }
+//                    switch (finalStatus)
+//                    {
+//                        case 0:  statusText = "待审核"; task.setFileChargeStatus(0);break;
+//                        case 1:  statusText = "通过";break;
+//                        case 2:  statusText = "驳回"; task.setFileChargeStatus(2);break;
+//                    }
+//                    if(org.apache.commons.lang3.StringUtils.isBlank(userWxId)){
+//                        fileChargeStatusText = statusText+"("+name+")";
+//                    }else{
+//                        fileChargeStatusText = statusText+"("+("$userName=" + userWxId + "$")+")";
+//                    }
+//                    task.setFinalChargeStatusText(fileChargeStatusText);
+//                }
+//            }
+//        }
         list.forEach(l->{
             List<TaskExecutor> executorList = taskExecutorList.stream().filter(tl -> tl.getTaskId().equals(l.getId())&&tl.getExecutorId()!=null).collect(Collectors.toList());
             l.setExecutorList(executorList);

+ 304 - 100
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskFilesController.java

@@ -3,11 +3,11 @@ package com.management.platform.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.CompanyDingdingService;
 import com.management.platform.service.ProjectDocumentService;
+import com.management.platform.service.TaskFilesService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.task.SFTPAsyncUploader;
 import com.management.platform.util.DocumentTypeUtil;
@@ -18,6 +18,7 @@ import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -29,8 +30,8 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.IOException;
 import java.time.LocalDateTime;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -75,6 +76,154 @@ public class TaskFilesController {
     @Resource
     private CompanyDingdingService companyDingdingService;
 
+    @Resource
+    private DepartmentMapper departmentMapper;
+
+    @Resource
+    private ProjectMapper projectMapper;
+
+    @Resource
+    private TaskFilesService taskFilesService;
+
+    @PostMapping("/reUploadFile")
+    public HttpRespMsg reUploadFile(@RequestParam Integer projectId,
+                                    @RequestParam Integer taskId,
+                                    @RequestParam Integer taskFileId,
+                                    @RequestParam("file") MultipartFile file,
+                                    HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("Token"));
+        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
+        Department department = departmentMapper.selectById(user.getDepartmentId());
+        Project project = projectMapper.selectById(projectId);
+        TaskFiles oldTaskFile = taskFilesMapper.selectById(taskFileId);
+
+        if(!oldTaskFile.getCreatorId().equals(user.getId())){
+            msg.setError("您非文件上传人,无法重新上传");
+            return msg;
+        }
+        if (oldTaskFile.getDocumentId() == null) {
+            //仅当前任务上传的,需要把文件删掉
+            File dir = new File(uploadPath);
+            File targetFile = new File(dir, oldTaskFile.getServerName());
+            if (targetFile.exists()) {
+                targetFile.delete();
+            }
+        }
+
+//        StringBuilder fileNames = new StringBuilder();
+        TaskFiles record = new TaskFiles();
+        record.setId(taskFileId);
+        record.setCreatorId(user.getId());
+        record.setCreatorName(user.getName());
+        record.setDocumentName(file.getOriginalFilename());
+        record.setTaskId(taskId);
+        record.setProjectId(projectId);
+        if(1 == timeType.getTaskFileCharge()){
+            record.setNeedFileCharge(1);
+            if(org.apache.commons.lang3.StringUtils.isBlank(department.getManagerId())){
+                msg.setError("员工所在部门无负责人,请重新设置");
+                return msg;
+            }
+            if(org.apache.commons.lang3.StringUtils.isBlank(project.getInchargerId())){
+                msg.setError("该项目未设置项目经理,请重新设置");
+                return msg;
+            }
+            record.setChargeOneId(department.getManagerId());
+            record.setChargeTwoId(project.getInchargerId());
+            //根据老阶段重置任务状态
+            record.setFinalChargeStatus(0);
+            if(1 == oldTaskFile.getChargeStage()){
+                record.setChargeOneStatus(0);
+            }else if(2 == oldTaskFile.getChargeStage()){
+                record.setChargeTwoStatus(0);
+            } else if (3 == oldTaskFile.getChargeStage()) {
+                record.setChargeStage(1);
+                record.setChargeOneStatus(0);
+                record.setChargeTwoStatus(0);
+            }
+        }
+        if (file != null && !file.isEmpty()) {
+            //截取文件后缀
+            String fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
+            record.setDocumentType(DocumentTypeUtil.DocumentType(fileSuffix));
+            //处理文件
+            File dir = new File(uploadPath);
+            if (!dir.exists()) {
+                dir.mkdir();
+            }
+            String fileName= "";
+            if (file!=null && !file.isEmpty()) {
+                fileName = file.getOriginalFilename();
+
+                int pos = fileName.lastIndexOf(".");
+                String suffix = fileName.substring(pos).toLowerCase();
+                //用uuid替换原始的文件名
+                String purFName = UUID.randomUUID().toString().replaceAll("-", "");
+                fileName = purFName + suffix;
+                File saveFile = new File(dir, fileName);
+                try {
+                    saveFile.createNewFile();
+                    file.transferTo(saveFile);
+                    //异步上传到备份服务器
+                    sftpAsyncUploader.uploadFileAsync(saveFile);
+                    //计算文件大小
+                    long fileSize = saveFile.length();
+                    String fileLength = FileUtil.getReadableFileSize(fileSize);
+                    record.setServerName(uploadPath + fileName);
+                    record.setSize(fileLength);
+                    String pathPrefix = "/upload/";
+                    record.setUrl(pathPrefix + fileName);
+
+                    taskFilesMapper.updateById(record);
+                    //生成原文件名称与服务器文件名称对应
+                    msg.data = record;
+
+
+                    //添加动态消息
+                    Task task = taskMapper.selectById(taskId);
+                    String content = user.getName()+"在任务【"+task.getName()+"】中重新上传了文件【"+file.getOriginalFilename()+"】";
+                    TaskComment comment =  new TaskComment();
+                    comment.setTaskId(taskId);
+                    comment.setUserId(user.getId());
+                    comment.setContent(content);
+                    comment.setCreateTime(LocalDateTime.now());
+                    comment.setUserColor(user.getColor());
+                    comment.setUserName(user.getName());
+                    taskCommentMapper.insert(comment);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    fileName = null;
+                    msg.setError(e.getMessage()+", path="+dir.getAbsolutePath());
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    fileName = null;
+                    msg.setError(e.getMessage()+", path="+dir.getAbsolutePath());
+                }
+            } else {
+                //msg.setError("文件不存在");
+                msg.setError(MessageUtils.message("file.nonExistentError"));
+            }
+        }
+
+        return msg;
+
+    }
+
+
+    @PostMapping("/approveFile")
+    public HttpRespMsg approveFile(@RequestParam("taskFileIds")String taskFileIds
+            ,HttpServletRequest request) {
+        return taskFilesService.approveFile(taskFileIds,request);
+    }
+
+    @PostMapping("/rejectFile")
+    public HttpRespMsg rejectFile(@RequestParam("taskFileIds")String taskFileIds
+            ,@RequestParam(value = "reason",required = false)String reason
+            ,HttpServletRequest request) {
+        return taskFilesService.rejectFile(taskFileIds,reason,request);
+    }
+
     /**
      * 获取该项目下的所有有效的文件列表
      * @param keyword
@@ -114,17 +263,32 @@ public class TaskFilesController {
         record.setSize(document.getSize());
         record.setServerName(document.getServerName());
         record.setUrl(document.getUrl());
-        taskFilesMapper.insert(record);
-
-        //判断文件阶段做回退处理
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         if(1 == timeType.getTaskFileCharge()){
-            this.resetTaskChargeStatus(taskId);
+            record.setNeedFileCharge(1);
+            Department department = departmentMapper.selectById(user.getDepartmentId());
+            Project project = projectMapper.selectById(taskId);
+            if(org.apache.commons.lang3.StringUtils.isBlank(department.getManagerId())){
+                msg.setError("员工所在部门无负责人,请重新设置");
+                return msg;
+            }
+            if(org.apache.commons.lang3.StringUtils.isBlank(project.getInchargerId())){
+                msg.setError("该项目未设置项目经理,请重新设置");
+                return msg;
+            }
+            record.setChargeOneId(department.getManagerId());
+            record.setChargeTwoId(project.getInchargerId());
         }
+        taskFilesMapper.insert(record);
+
+//        //判断文件阶段做回退处理[修改为对文件,废弃]
+//        if(1 == timeType.getTaskFileCharge()){
+//            this.resetTaskChargeStatus(taskId);
+//        }
 
         //添加动态消息
         Task task = taskMapper.selectById(taskId);
-        String content = user.getName()+"在任务:"+task.getName()+"中关联了文件:"+document.getDocumentName();
+        String content = user.getName()+"在任务【"+task.getName()+"】中关联了文件【"+document.getDocumentName()+"】";
         TaskComment comment =  new TaskComment();
         comment.setTaskId(taskId);
         comment.setUserId(user.getId());
@@ -164,6 +328,9 @@ public class TaskFilesController {
             HttpServletResponse response) throws Exception {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("Token"));
+        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
+        Department department = departmentMapper.selectById(user.getDepartmentId());
+        Project project = projectMapper.selectById(projectId);
         StringBuilder fileNames = new StringBuilder();
         for (MultipartFile file : files) {
             TaskFiles record = new TaskFiles();
@@ -173,6 +340,19 @@ public class TaskFilesController {
             fileNames.append(file.getOriginalFilename()).append(",");
             record.setTaskId(taskId);
             record.setProjectId(projectId);
+            if(1 == timeType.getTaskFileCharge()){
+                record.setNeedFileCharge(1);
+                if(org.apache.commons.lang3.StringUtils.isBlank(department.getManagerId())){
+                    msg.setError("员工所在部门无负责人,请重新设置");
+                    return msg;
+                }
+                if(org.apache.commons.lang3.StringUtils.isBlank(project.getInchargerId())){
+                    msg.setError("该项目未设置项目经理,请重新设置");
+                    return msg;
+                }
+                record.setChargeOneId(department.getManagerId());
+                record.setChargeTwoId(project.getInchargerId());
+            }
             if (file != null && !file.isEmpty()) {
                 //截取文件后缀
                 String fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
@@ -244,16 +424,16 @@ public class TaskFilesController {
             }
         }
 
-        //判断文件阶段做回退处理
-        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-        if(1 == timeType.getTaskFileCharge()){
-            this.resetTaskChargeStatus(taskId);
-        }
+        //判断文件阶段做回退处理[修改为对文件,废弃]
+//        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
+//        if(1 == timeType.getTaskFileCharge()){
+//            this.resetTaskChargeStatus(taskId);
+//        }
 
         //添加动态消息
         String resFileNames = fileNames.deleteCharAt(fileNames.length() - 1).toString();
         Task task = taskMapper.selectById(taskId);
-        String content = user.getName()+"在任务:"+task.getName()+"中上传了文件:"+resFileNames;
+        String content = user.getName()+"在任务【"+task.getName()+"】中上传了文件【"+resFileNames+"】";
         TaskComment comment =  new TaskComment();
         comment.setTaskId(taskId);
         comment.setUserId(user.getId());
@@ -294,16 +474,15 @@ public class TaskFilesController {
         }
         taskFilesMapper.deleteById(id);
 
-        //判断文件阶段做回退处理
-
-        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-        if(1 == timeType.getTaskFileCharge()){
-            this.resetTaskChargeStatus(taskFiles.getTaskId());
-        }
+        //判断文件阶段做回退处理[修改为对文件,废弃]
+//        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
+//        if(1 == timeType.getTaskFileCharge()){
+//            this.resetTaskChargeStatus(taskFiles.getTaskId());
+//        }
 
         //添加动态消息
         Task task = taskMapper.selectById(taskFiles.getTaskId());
-        String content = user.getName()+"删除了任务:"+task.getName()+"中的文件:"+taskFiles.getDocumentName();
+        String content = user.getName()+"删除了任务【"+task.getName()+"】中的文件【"+taskFiles.getDocumentName()+"】";
         TaskComment comment =  new TaskComment();
         comment.setTaskId(taskFiles.getTaskId());
         comment.setUserId(user.getId());
@@ -350,53 +529,72 @@ public class TaskFilesController {
     @RequestMapping(value="getTaskFiles")
     public HttpRespMsg getTaskFiles(Integer taskId,HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));
-        Task task = taskMapper.selectById(taskId);
+//        Task task = taskMapper.selectById(taskId);
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
         CompanyDingding dingding = companyDingdingService.getOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
-        String fileChargeStatusText = "";
-        int fileChargeStatus = 0;
-        if(1 == timeType.getTaskFileCharge()){
-            if(org.apache.commons.lang3.StringUtils.isNotBlank(task.getChargeOneId())
-                    &&org.apache.commons.lang3.StringUtils.isNotBlank(task.getChargeTwoId())){
-                if(1 == task.getFinalChargeStatus()){
-                    fileChargeStatusText = "审核通过";
-                    fileChargeStatus = 1;
-                } else if (0 == task.getFinalChargeStatus()) {
-                    String name = "";
-                    String statusText = "";
-                    String userWxId = "";
-                    int finalStatus = 1==task.getChargeStage()?task.getChargeOneStatus():task.getChargeTwoStatus();
-                    String userId = 1==task.getChargeStage()?task.getChargeOneId():task.getChargeTwoId();
-                    User chargeUser = userMapper.selectById(userId);
-                    if(null != chargeUser){
-                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                            userWxId = chargeUser.getCorpwxRealUserid();
-                        }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
-                            userWxId = chargeUser.getDingdingUserid();
-                        }
-                        name = chargeUser.getName();
-                    }
-                    switch (finalStatus)
-                    {
-                        case 0:  statusText = "待审核";fileChargeStatus = 0;break;
-                        case 1:  statusText = "通过";break;
-                        case 2:  statusText = "驳回";fileChargeStatus = 2;break;
-                    }
-                    if(org.apache.commons.lang3.StringUtils.isBlank(userWxId)){
-                        fileChargeStatusText = statusText+"("+name+")";
-                    }else{
-                        fileChargeStatusText = statusText+"("+("$userName=" + userWxId + "$")+")";
-                    }
 
-                }
+        //审核通过的  或者是老文件 所有人都能看到
+        //审核不通过的需要判断 登录人 是否是 文件上传人/审核人一、二中的一个 ,能则可以看到
+        List<TaskFiles> list = taskFilesMapper.getTaskFiles(taskId,user.getId());
+
+        List<String> allIds = new ArrayList<>();
+        List<String> chargeOneIds = list.stream().filter(t -> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeOneId()))
+                .map(TaskFiles::getChargeOneId).collect(Collectors.toList());
+        List<String> chargeTwoIds = list.stream().filter(t -> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeTwoId()))
+                .map(TaskFiles::getChargeTwoId).collect(Collectors.toList());
+        allIds.addAll(chargeOneIds);
+        allIds.addAll(chargeTwoIds);
+        Map<String,User> userIdMap = new HashMap<>();
+        if(CollectionUtils.isNotEmpty(allIds)){
+            List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getId, allIds));
+            if(CollectionUtils.isNotEmpty(users)){
+                userIdMap = users.stream().collect(Collectors.toMap(User::getId,t->t));
             }
         }
-        List<TaskFiles> list = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>()
-                .eq(TaskFiles::getTaskId,taskId)
-        );
         if(CollectionUtils.isNotEmpty(list)){
             for (TaskFiles taskFiles : list) {
+                String fileChargeStatusText = "";
+                int fileChargeStatus = 0;
+                if(1 == timeType.getTaskFileCharge()){
+                    if(0 == taskFiles.getNeedFileCharge()){
+                        fileChargeStatusText = "无审核状态";
+                        fileChargeStatus = 3;
+                    }else{
+                        if(1 == taskFiles.getFinalChargeStatus()){
+                            fileChargeStatusText = "审核通过";
+                            fileChargeStatus = 1;
+                        } else if (0 == taskFiles.getFinalChargeStatus()) {
+                            String name = "";
+                            String statusText = "";
+                            String userWxId = "";
+                            int finalStatus = 1==taskFiles.getChargeStage()?taskFiles.getChargeOneStatus():taskFiles.getChargeTwoStatus();
+                            String userId = 1==taskFiles.getChargeStage()?taskFiles.getChargeOneId():taskFiles.getChargeTwoId();
+                            User chargeUser = userIdMap.get(userId);
+                            if(null != chargeUser){
+                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                    userWxId = chargeUser.getCorpwxRealUserid();
+                                }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
+                                    userWxId = chargeUser.getDingdingUserid();
+                                }
+                                name = chargeUser.getName();
+                            }
+                            switch (finalStatus)
+                            {
+                                case 0:  statusText = "待审核";fileChargeStatus = 0;break;
+                                case 1:  statusText = "通过";break;
+                                case 2:  statusText = "驳回";fileChargeStatus = 2;break;
+                            }
+                            if(org.apache.commons.lang3.StringUtils.isBlank(userWxId)){
+                                fileChargeStatusText = statusText+"("+name+")";
+                            }else{
+                                fileChargeStatusText = statusText+"("+("$userName=" + userWxId + "$")+")";
+                            }
+
+                        }
+                    }
+
+                }
                 taskFiles.setFileChargeStatusText(fileChargeStatusText);
                 taskFiles.setFileChargeStatus(fileChargeStatus);
             }
@@ -407,47 +605,53 @@ public class TaskFilesController {
     }
 
 
-    public void resetTaskChargeStatus(Integer taskId){
-        Task task = taskMapper.selectById(taskId);
-        if(1 == task.getFinalChargeStatus()){
-            //重置阶段一、二的时间、状态、理由
-            //重置 文件审核阶段为 1 阶段一  最终审核状态为 0未通过
-            taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                    .set(Task::getFinalChargeStatus, 0)
-                    .set(Task::getChargeStage,1)
-                    .set(Task::getChargeOneStatus,0)
-                    .set(Task::getChargeTwoStatus,0)
-                    .set(Task::getChargeOneTime,null)
-                    .set(Task::getChargeTwoTime,null)
-                    .set(Task::getFileRejectReason,null)
-//                    .set(Task::getChargeOneReason,null)
-//                    .set(Task::getChargeTwoReason,null)
-                    .eq(Task::getId,task.getId())
-            );
-        } else if (0 == task.getFinalChargeStatus()) {
-            //判断当前阶段
-            if(1==task.getChargeStage()){
-                //重置阶段一的时间、状态、理由
-                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                        .set(Task::getChargeOneStatus,0)
-                        .set(Task::getChargeOneTime,null)
-                        .set(Task::getFileRejectReason,null)
-                        .eq(Task::getId,task.getId())
-                );
-            } else if (2 == task.getChargeStage()) {
-                //重置阶段二的时间、状态、理由
-                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                        .set(Task::getChargeStage,1)
-                        .set(Task::getChargeOneStatus,0)
-                        .set(Task::getChargeOneTime,null)
-                        .set(Task::getChargeTwoStatus,0)
-                        .set(Task::getChargeTwoTime,null)
-                        .set(Task::getFileRejectReason,null)
-                        .eq(Task::getId,task.getId())
-                );
-            }
-        }
+
+    @RequestMapping(value = "/getUnChargedFilesByTaskId")
+    public HttpRespMsg getUnChargedFilesByTaskId(Integer taskId,HttpServletRequest request){
+        return taskFilesService.getUnChargedFilesByTaskId(taskId,request);
     }
 
+//    public void resetTaskChargeStatus(Integer taskId){
+//        Task task = taskMapper.selectById(taskId);
+//        if(1 == task.getFinalChargeStatus()){
+//            //重置阶段一、二的时间、状态、理由
+//            //重置 文件审核阶段为 1 阶段一  最终审核状态为 0未通过
+//            taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                    .set(Task::getFinalChargeStatus, 0)
+//                    .set(Task::getChargeStage,1)
+//                    .set(Task::getChargeOneStatus,0)
+//                    .set(Task::getChargeTwoStatus,0)
+//                    .set(Task::getChargeOneTime,null)
+//                    .set(Task::getChargeTwoTime,null)
+//                    .set(Task::getFileRejectReason,null)
+////                    .set(Task::getChargeOneReason,null)
+////                    .set(Task::getChargeTwoReason,null)
+//                    .eq(Task::getId,task.getId())
+//            );
+//        } else if (0 == task.getFinalChargeStatus()) {
+//            //判断当前阶段
+//            if(1==task.getChargeStage()){
+//                //重置阶段一的时间、状态、理由
+//                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                        .set(Task::getChargeOneStatus,0)
+//                        .set(Task::getChargeOneTime,null)
+//                        .set(Task::getFileRejectReason,null)
+//                        .eq(Task::getId,task.getId())
+//                );
+//            } else if (2 == task.getChargeStage()) {
+//                //重置阶段二的时间、状态、理由
+//                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                        .set(Task::getChargeStage,1)
+//                        .set(Task::getChargeOneStatus,0)
+//                        .set(Task::getChargeOneTime,null)
+//                        .set(Task::getChargeTwoStatus,0)
+//                        .set(Task::getChargeTwoTime,null)
+//                        .set(Task::getFileRejectReason,null)
+//                        .eq(Task::getId,task.getId())
+//                );
+//            }
+//        }
+//    }
+
 }
 

+ 9 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Project.java

@@ -1,17 +1,9 @@
 package com.management.platform.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-
-import java.math.BigDecimal;
-import java.time.LocalDate;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.management.platform.config.PropertyMsg;
@@ -21,6 +13,13 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 

+ 50 - 58
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Task.java

@@ -15,6 +15,11 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.List;
+
 /**
  * <p>
  * 
@@ -213,63 +218,47 @@ public class Task extends Model<Task> {
     @TableField("sap_task_code")
     private String sapTaskCode;
 
-    /**
-     * 文件审核人一id
-     */
-    @TableField("charge_one_id")
-    private String chargeOneId;
-
-    /**
-     * 文件审核人一的审核状态 0待审核 1通过 2驳回
-     */
-    @TableField("charge_one_status")
-    private Integer chargeOneStatus;
-
-    /**
-     * 文件审核人一的审核时间
-     */
-    @TableField("charge_one_time")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime chargeOneTime;
-
-    /**
-     * 文件审核人二id
-     */
-    @TableField("charge_two_id")
-    private String chargeTwoId;
-
-    /**
-     * 文件审核人二的审核状态 0待审核 1通过 2驳回
-     */
-    @TableField("charge_two_status")
-    private Integer chargeTwoStatus;
-
-    /**
-     * 文件审核人二的审核时间
-     */
-    @TableField("charge_two_time")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime chargeTwoTime;
-
-    /**
-     * 文件最终审核状态 0未通过 1通过
-     */
-    @TableField("final_charge_status")
-    private Integer finalChargeStatus;
-
-    /**
-     * 文件审核阶段 1审核人一 2审核人二 3都审核通过
-     */
-    @TableField("charge_stage")
-    private Integer chargeStage;
-
-    /**
-     * 文件审核驳回原因
-     */
-    @TableField("file_reject_reason")
-    private String fileRejectReason;
+//    /**文件审核人一[部门负责人]id*/
+//    @TableField("charge_one_id")
+//    private String chargeOneId;
+//
+//
+//    /**文件审核人一的审核状态 0待审核 1通过 2驳回*/
+//    @TableField("charge_one_status")
+//    private Integer chargeOneStatus;
+//
+//    /**文件审核人一的审核时间*/
+//    @TableField("charge_one_time")
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    private Date chargeOneTime;
+//
+//    /**文件审核人二[项目审核人]id*/
+//    @TableField("charge_two_id")
+//    private String chargeTwoId;
+//
+//
+//    /**文件审核人二的审核状态 0待审核 1通过 2驳回*/
+//    @TableField("charge_two_status")
+//    private Integer chargeTwoStatus;
+//
+//    /**文件审核人二的审核时间*/
+//    @TableField("charge_two_time")
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    private Date chargeTwoTime;
+//
+//    /**文件审核阶段 1审核人一 2审核人二 3都审核通过*/
+//    @TableField("charge_stage")
+//    private Integer chargeStage;
+//
+//    /**文件最终审核状态  0未通过 1通过*/
+//    @TableField("final_charge_status")
+//    private Integer finalChargeStatus;
+//
+//    /**文件审核驳回原因*/
+//    @TableField("file_reject_reason")
+//    private String fileRejectReason;
 
     /**
      * 任务预估成本
@@ -311,7 +300,10 @@ public class Task extends Model<Task> {
     private List<User> userList;
 
     @TableField(exist = false)
-    /**0 待审核 1通过 2驳回*/
+    /**0 待审核 1通过 2驳回
+     * 2025-01-03 修改为
+     * 任务的外置状态显示 1审核中[待审核+(审核通过)] 2驳回[存在驳回文件]  3审核通过[全部审核通过]
+     * */
     private int fileChargeStatus;
 
     @Override

+ 52 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TaskFiles.java

@@ -78,10 +78,61 @@ public class TaskFiles extends Model<TaskFiles> {
     @TableField(exist = false)
     private String fileChargeStatusText;
 
-    /**0 待审核 1通过 2驳回*/
+    /**0 待审核 1通过 2驳回 3老文件无审核状态 前端用*/
     @TableField(exist = false)
     private Integer fileChargeStatus;
 
+    /**创建文件时是否开启审核功能 0否1是*/
+    @TableField("need_file_charge")
+    private Integer needFileCharge;
+
+    /**文件审核人一[部门负责人]id*/
+    @TableField("charge_one_id")
+    private String chargeOneId;
+
+    /**部门主管的审核状态 0待审核 1通过 2驳回*/
+    @TableField("charge_one_status")
+    private Integer chargeOneStatus;
+
+    /**部门主管的审核时间*/
+    @TableField("charge_one_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date chargeOneTime;
+
+    /**文件审核人二[项目审核人]id*/
+    @TableField("charge_two_id")
+    private String chargeTwoId;
+
+    /**项目经理的审核状态 0待审核 1通过 2驳回*/
+    @TableField("charge_two_status")
+    private Integer chargeTwoStatus;
+
+    /**项目经理的审核时间*/
+    @TableField("charge_two_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date chargeTwoTime;
+
+    /**文件审核阶段 1审核人一 2审核人二/项目经理 3都审核通过*/
+    @TableField("charge_stage")
+    private Integer chargeStage;
+
+    /**文件最终审核状态  0未通过 1通过*/
+    @TableField("final_charge_status")
+    private Integer finalChargeStatus;
+
+    /**文件审核驳回原因*/
+    @TableField("file_reject_reason")
+    private String fileRejectReason;
+
+
+    @TableField(exist = false)
+    private Integer companyId;
+
+    @TableField(exist = false)
+    private String taskName;
+
 
     @Override
     protected Serializable pkVal() {

+ 10 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeType.java

@@ -1,16 +1,16 @@
 package com.management.platform.entity;
 
-import java.math.BigDecimal;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-import java.util.List;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * <p>
  * 
@@ -632,6 +632,10 @@ public class TimeType extends Model<TimeType> {
     @TableField("task_plan_cost")
     private Integer taskPlanCost;
 
+    /**项目进度判断依据,0-默认字段,1-根据任务工时*/
+    @TableField("project_progress_check")
+    private Integer projectProgressCheck;
+
 
     @TableField(exist = false)
     private List<User> userList;

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/bo/QueryTaskChargePage.java

@@ -11,4 +11,5 @@ public class QueryTaskChargePage {
     private Integer pageIndex = 1;
     private Integer pageSize;
     private String userId;
+    private Integer companyId;
 }

+ 14 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/ProjectTaskTimeCostVO.java

@@ -0,0 +1,14 @@
+package com.management.platform.entity.vo;
+
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class ProjectTaskTimeCostVO {
+    private Integer taskId;
+    private String executorId;
+    private Integer planHours;
+    private BigDecimal realHours;
+}

+ 12 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/ProjectTimeCostVO.java

@@ -0,0 +1,12 @@
+package com.management.platform.entity.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class ProjectTimeCostVO {
+    private Integer projectId;
+    private BigDecimal planHoursSum;
+    private BigDecimal realHoursSum;
+}

+ 26 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/TaskFileChargePageVO.java

@@ -0,0 +1,26 @@
+package com.management.platform.entity.vo;
+
+import com.management.platform.entity.TaskExecutor;
+import com.management.platform.entity.TaskFiles;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TaskFileChargePageVO {
+    private Integer taskId;
+    private String taskName;
+    private Integer projectId;
+    private String projectName;
+    private String executorId;//执行人id 多个
+    private List<TaskExecutor> executorList;
+    private Integer groupId;
+//    private String finalChargeId;
+//    private String finalChargeName;
+
+    /**任务的外置状态显示 1审核中[待审核+(审核通过)] 2驳回[存在驳回文件]  3审核通过[全部审核通过]*/
+//    private Integer taskChargeStatus;
+
+    private List<TaskFiles> childFiles;
+
+}

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/TaskCommentMapper.java

@@ -2,6 +2,9 @@ package com.management.platform.mapper;
 
 import com.management.platform.entity.TaskComment;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TaskCommentMapper extends BaseMapper<TaskComment> {
 
+    void insertBatch(@Param("commentList") List<TaskComment> commentList);
 }

+ 10 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/TaskFilesMapper.java

@@ -2,6 +2,7 @@ package com.management.platform.mapper;
 
 import com.management.platform.entity.TaskFiles;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,5 +16,13 @@ import java.util.List;
  */
 public interface TaskFilesMapper extends BaseMapper<TaskFiles> {
 
-    List<Integer> getAllTaskIds();
+    List<Integer> getAllNeedChargeTaskIds();
+
+    List<TaskFiles> getTaskFiles(@Param("taskId") Integer taskId, @Param("userId") String userId);
+
+    List<TaskFiles> getAllNeedChargeTaskFiles();
+
+    List<TaskFiles> getUnChargedFilesByTaskId(@Param("taskId") Integer taskId, @Param("userId") String userId);
+
+    List<Integer> getTaskFilesByCreatorDeptId(@Param("departmentId") Integer departmentId);
 }

+ 11 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/TaskMapper.java

@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.management.platform.entity.Task;
 import com.management.platform.entity.TimeTask;
 import com.management.platform.entity.bo.QueryTaskChargePage;
+import com.management.platform.entity.vo.ProjectTaskTimeCostVO;
+import com.management.platform.entity.vo.ProjectTimeCostVO;
 import com.management.platform.entity.vo.TaskChargePageVO;
+import com.management.platform.entity.vo.TaskFileChargePageVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
 
@@ -75,4 +78,12 @@ public interface TaskMapper extends BaseMapper<Task> {
 
     int getTaskPlanRealCount(Integer companyId, Integer projectId, Integer taskType, List<Integer> inchagerIds);
 
+
+    List<TaskFileChargePageVO> getTaskFileChargePage(@Param("queryBO") QueryTaskChargePage queryBO, @Param("deptIds")List<Integer> branchDepartment);
+
+    int getTaskFileChargePageTotal(@Param("queryBO") QueryTaskChargePage queryBO, @Param("deptIds")List<Integer> branchDepartment);
+
+    List<ProjectTaskTimeCostVO> getProjectAllTaskTimeCost(@Param("projectId") Integer projectId);
+
+    List<ProjectTimeCostVO> getProjectTaskTimeCostByIds(@Param("projectIds")List<Integer> projectIds);
 }

+ 8 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/TaskFilesService.java

@@ -2,6 +2,9 @@ package com.management.platform.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.TaskFiles;
+import com.management.platform.util.HttpRespMsg;
+
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * <p>
@@ -13,4 +16,9 @@ import com.management.platform.entity.TaskFiles;
  */
 public interface TaskFilesService extends IService<TaskFiles> {
 
+    HttpRespMsg approveFile(String taskFileIds,HttpServletRequest request);
+
+    HttpRespMsg rejectFile(String taskFileIds,String reason, HttpServletRequest request);
+
+    HttpRespMsg getUnChargedFilesByTaskId(Integer taskId, HttpServletRequest request);
 }

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

@@ -55,7 +55,7 @@ public interface TaskService extends IService<Task> {
 
     HttpRespMsg getTaskByUserId(String startDate, String endDate, String userId, Integer pageIndex, Integer pageSize);
 
-    HttpRespMsg auditFile(Integer taskId, String projectId, Integer auditStatus, String reason, HttpServletRequest request);
+//    HttpRespMsg auditFile(Integer taskId, String projectId, Integer auditStatus, String reason, HttpServletRequest request);
 
     HttpRespMsg getFileRejectReason(String taskId, HttpServletRequest request);
 

+ 15 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -1,8 +1,7 @@
 package com.management.platform.service.impl;
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.DepartmentMasterVO;
@@ -12,16 +11,15 @@ import com.management.platform.mapper.*;
 import com.management.platform.service.DepartmentService;
 import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.WxCorpInfoService;
-import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.ListUtil;
 import com.management.platform.util.MessageUtils;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.*;
 import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -82,6 +80,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     private String corpId;
     @Value("${providerSecret}")
     private String providerSecret;
+    @Autowired
+    private TaskFilesMapper taskFilesMapper;
+
     //新增部门
     @Override
     public HttpRespMsg insertDepartment(String departmentName, Integer superiorId, String managerId, String reportAuditUserid,String otherManagerIds,  HttpServletRequest request) {
@@ -243,6 +244,15 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                         departmentOtherManagerMapper.delete(new QueryWrapper<DepartmentOtherManager>().eq("department_id",departmentId));
                     }
                 }
+
+                //修改任务文件审核人
+                List<Integer> taskFileIds = taskFilesMapper.getTaskFilesByCreatorDeptId(departmentId);
+                if(CollectionUtils.isNotEmpty(taskFileIds)){
+                    taskFilesMapper.update(null,new LambdaUpdateWrapper<TaskFiles>()
+                            .set(TaskFiles::getChargeOneId,managerId)
+                            .in(TaskFiles::getId,taskFileIds)
+                    );
+                }
             }
         } catch (NullPointerException e) {
             e.printStackTrace();

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 21 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DingDingServiceImpl.java


+ 50 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -11,12 +11,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.ImmutableMap;
 import com.management.platform.entity.*;
-import com.management.platform.entity.Task;
 import com.management.platform.entity.vo.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.management.platform.util.*;
-import com.management.platform.webservice.po.*;
+import com.management.platform.webservice.po.ProjectQueryResponse;
+import com.management.platform.webservice.po.ProjectTask;
+import com.management.platform.webservice.po.ServiceProduct;
+import com.management.platform.webservice.po.XmlResponseData;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -30,7 +33,6 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.ss.formula.functions.T;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.streaming.SXSSFCell;
@@ -55,7 +57,9 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLDecoder;
 import java.sql.Timestamp;
-import java.text.*;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.chrono.ChronoLocalDate;
 import java.time.format.DateTimeFormatter;
@@ -1584,6 +1588,28 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 }
             }
 
+            //以里程碑完成度来算还是按任务工时完成度
+            if(1== timeType.getProjectProgressCheck()){
+                List<ProjectTimeCostVO> projectTimeCostList = taskMapper.getProjectTaskTimeCostByIds(projectIds);
+                if(CollectionUtils.isNotEmpty(projectTimeCostList)){
+                    Map<Integer, ProjectTimeCostVO> projectTimeMap = projectTimeCostList.stream()
+                            .collect(Collectors.toMap(ProjectTimeCostVO::getProjectId, t -> t));
+                    for (ProjectVO projectVO : list) {
+                        ProjectTimeCostVO tmpVO = projectTimeMap.get(projectVO.getId());
+                        if(null != tmpVO){
+                            int percentRes = 0;
+                            if(tmpVO.getPlanHoursSum().compareTo(new BigDecimal(0)) > 0){
+                                percentRes = tmpVO.getRealHoursSum().multiply(new BigDecimal(100))
+                                        .divide(tmpVO.getPlanHoursSum(),0, RoundingMode.HALF_UP).intValue();
+                            }
+                            projectVO.setProgress(percentRes);
+                        }
+                    }
+
+                }
+            }
+
+
             //stringList.add("未分类");
             stringList.add(MessageUtils.message("excel.unclassified"));
             Long total = projectIPage.getTotal();
@@ -3258,6 +3284,26 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         Integer companyId = user.getCompanyId();
         TimeType timeType = timeTypeMapper.selectById(companyId);
         Project project = projectMapper.selectById(id);
+
+        //以里程碑完成度来算还是按任务工时完成度
+        if(1 == timeType.getProjectProgressCheck()){
+            List<ProjectTaskTimeCostVO> allTaskCosts = taskMapper.getProjectAllTaskTimeCost(id);
+            if(CollectionUtils.isNotEmpty(allTaskCosts)){
+                BigDecimal planHourSum = new BigDecimal(0);
+                BigDecimal realHourSum = new BigDecimal(0);
+                for (ProjectTaskTimeCostVO taskCost : allTaskCosts) {
+                    planHourSum = planHourSum.add(new BigDecimal(String.valueOf(taskCost.getPlanHours())));
+                    realHourSum = realHourSum.add(new BigDecimal(String.valueOf(taskCost.getRealHours())));
+                }
+                int percentRes = 0;
+                if(planHourSum.compareTo(new BigDecimal(0)) > 0){
+                    BigDecimal bg = realHourSum.multiply(new BigDecimal(100)).divide(planHourSum, 0, BigDecimal.ROUND_HALF_UP);
+                    percentRes = bg.intValue();
+                }
+                project.setProgress(percentRes);
+            }
+        }
+
         List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
         if (project.getInchargerId() != null) {
             User incharger = userMapper.selectById(project.getInchargerId());

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

@@ -1,10 +1,27 @@
 package com.management.platform.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.management.platform.entity.TaskFiles;
+import com.management.platform.entity.*;
+import com.management.platform.mapper.TaskCommentMapper;
 import com.management.platform.mapper.TaskFilesMapper;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.mapper.WxCorpInfoMapper;
+import com.management.platform.service.CompanyDingdingService;
 import com.management.platform.service.TaskFilesService;
+import com.management.platform.service.WxCorpInfoService;
+import com.management.platform.util.HttpRespMsg;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -17,4 +34,185 @@ import org.springframework.stereotype.Service;
 @Service
 public class TaskFilesServiceImpl extends ServiceImpl<TaskFilesMapper, TaskFiles> implements TaskFilesService {
 
+    @Resource
+    private TaskFilesMapper taskFilesMapper;
+
+    @Resource
+    private WxCorpInfoMapper wxCorpInfoMapper;
+
+    @Resource
+    private UserMapper userMapper;
+
+    @Resource
+    private WxCorpInfoService wxCorpInfoService;
+
+    @Resource
+    private TaskCommentMapper taskCommentMapper;
+
+    @Resource
+    private CompanyDingdingService companyDingdingService;
+
+
+    @Override
+    @Transactional
+    public HttpRespMsg approveFile(String taskFileIds,HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("Token"));
+        String[] array = taskFileIds.split(",");
+        if(0 != array.length){
+            List<String> ids = Arrays.stream(array).collect(Collectors.toList());
+            //审核文件
+            List<TaskFiles> taskFilesList = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>()
+                            .eq(TaskFiles::getFinalChargeStatus,0)
+                            .eq(TaskFiles::getNeedFileCharge,1)
+                    .in(TaskFiles::getId,ids));
+            //通过
+            List<Integer> stageOneToUpdateList = new ArrayList<>();
+            List<Integer> stageTwoToUpdateList = new ArrayList<>();
+            List<TaskComment> commentList = new ArrayList<>();
+            for (TaskFiles taskFiles : taskFilesList) {
+                //判断所处阶段
+                if(1 == taskFiles.getChargeStage()){
+                    stageOneToUpdateList.add(taskFiles.getId());
+                } else if (2 == taskFiles.getChargeStage()) {
+                    stageTwoToUpdateList.add(taskFiles.getId());
+                }
+                String content = user.getName()+"审核通过了任务文件【"+taskFiles.getDocumentName()+"】";
+                TaskComment comment =  new TaskComment();
+                comment.setTaskId(taskFiles.getTaskId());
+                comment.setUserId(user.getId());
+                comment.setContent(content);
+                comment.setCreateTime(LocalDateTime.now());
+                comment.setUserColor(user.getColor());
+                comment.setUserName(user.getName());
+                commentList.add(comment);
+            }
+            if(CollectionUtils.isNotEmpty(stageOneToUpdateList)){
+                taskFilesMapper.update(null,new LambdaUpdateWrapper<TaskFiles>()
+                        .set(TaskFiles::getChargeStage,2)
+                        .set(TaskFiles::getChargeOneStatus,1)
+                        .set(TaskFiles::getChargeOneTime,new Date())
+                        .set(TaskFiles::getFileRejectReason,null)
+                        .in(TaskFiles::getId,stageOneToUpdateList)
+                );
+            }
+            if(CollectionUtils.isNotEmpty(stageTwoToUpdateList)){
+                taskFilesMapper.update(null,new LambdaUpdateWrapper<TaskFiles>()
+                        .set(TaskFiles::getChargeStage,3)
+                        .set(TaskFiles::getFinalChargeStatus,1)
+                        .set(TaskFiles::getChargeTwoStatus,1)
+                        .set(TaskFiles::getChargeTwoTime,new Date())
+                        .set(TaskFiles::getFileRejectReason,null)
+                        .in(TaskFiles::getId,stageTwoToUpdateList)
+                );
+            }
+            if(CollectionUtils.isNotEmpty(commentList)){
+                taskCommentMapper.insertBatch(commentList);
+            }
+        }
+
+        return httpRespMsg;
+    }
+
+    @Override
+    @Transactional
+    public HttpRespMsg rejectFile(String taskFileIds,String reason, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("Token"));
+        String[] array = taskFileIds.split(",");
+        if(0 != array.length){
+            List<String> ids = Arrays.stream(array).collect(Collectors.toList());
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+//            CompanyDingding dingding = companyDingdingService.getOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
+            List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id",user.getCompanyId()));
+            Map<String, User> companyUserMap = users.stream().collect(Collectors.toMap(User::getId, t -> t));
+
+            List<TaskFiles> taskFiles = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>()
+                    .eq(TaskFiles::getNeedFileCharge,1)
+                    .eq(TaskFiles::getFinalChargeStatus,0)
+                    .in(TaskFiles::getId,ids)
+            );
+            List<Integer> stageOneToUpdateList = new ArrayList<>();
+            List<Integer> stageTwoToUpdateList = new ArrayList<>();
+//            StringBuilder userNames = new StringBuilder();
+            Map<String,String> remindMap = new HashMap<>();
+            List<TaskComment> commentList = new ArrayList<>();
+            for (TaskFiles taskFile : taskFiles) {
+                if(1 == taskFile.getChargeStage()){
+                    //阶段一,更新阶段一状态
+                    stageOneToUpdateList.add(taskFile.getId());
+                } else if (2 == taskFile.getChargeStage()) {
+                    stageTwoToUpdateList.add(taskFile.getId());
+                }
+                User tmpUser = companyUserMap.get(taskFile.getCreatorId());
+//                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+//                    userNames.append("$userName=").append(tmpUser.getCorpwxRealUserid()).append("$,");
+//                }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
+//                    userNames.append("$userName=").append(tmpUser.getDingdingUserid()).append("$,");
+//                }else{
+//                    userNames.append(tmpUser.getName()).append(",");
+//                }
+                remindMap.put(tmpUser.getCorpwxUserid(),"任务文件【"+taskFile.getDocumentName()+"】因【"+reason+"】被驳回,请及时处理");
+                String content = user.getName()+"审核驳回了任务文件【"+taskFile.getDocumentName()+"】";
+                TaskComment comment =  new TaskComment();
+                comment.setTaskId(taskFile.getTaskId());
+                comment.setUserId(user.getId());
+                comment.setContent(content);
+                comment.setCreateTime(LocalDateTime.now());
+                comment.setUserColor(user.getColor());
+                comment.setUserName(user.getName());
+                commentList.add(comment);
+            }
+            if(CollectionUtils.isNotEmpty(stageOneToUpdateList)){
+                //阶段一,更新阶段一状态
+                taskFilesMapper.update(null,new LambdaUpdateWrapper<TaskFiles>()
+                        .set(TaskFiles::getFileRejectReason,reason)
+                        .set(TaskFiles::getChargeOneTime,new Date())
+                        .set(TaskFiles::getChargeOneStatus,2)
+                        .in(TaskFiles::getId,stageOneToUpdateList)
+                );
+            }
+            if(CollectionUtils.isNotEmpty(stageTwoToUpdateList)){
+                taskFilesMapper.update(null,new LambdaUpdateWrapper<TaskFiles>()
+                        .set(TaskFiles::getFileRejectReason,reason)
+                        .set(TaskFiles::getChargeTwoTime,new Date())
+                        .set(TaskFiles::getChargeTwoStatus,2)
+                        .in(TaskFiles::getId,stageTwoToUpdateList)
+                );
+            }
+
+            if(CollectionUtils.isNotEmpty(commentList)){
+                taskCommentMapper.insertBatch(commentList);
+            }
+
+//            String names = userNames.deleteCharAt(userNames.length() - 1).toString();
+//            String content = user.getName()+"因【"+reason+"】驳回了【"+names+"】的任务文件";
+//            TaskComment comment =  new TaskComment();
+//            comment.setTaskId(taskFiles.get(0).getTaskId());
+//            comment.setUserId(user.getId());
+//            comment.setContent(content);
+//            comment.setCreateTime(LocalDateTime.now());
+//            comment.setUserColor(user.getColor());
+//            comment.setUserName(user.getName());
+//            taskCommentMapper.insert(comment);
+
+            for (Map.Entry<String, String> entry : remindMap.entrySet()) {
+                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,entry.getKey(),entry.getValue(),null
+                        , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_REJECT);
+            }
+
+        }
+
+        return httpRespMsg;
+    }
+
+    @Override
+    public HttpRespMsg getUnChargedFilesByTaskId(Integer taskId, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("Token"));
+        //状态为待审核、负责人为当前登录人
+        List<TaskFiles> taskFiles = taskFilesMapper.getUnChargedFilesByTaskId(taskId,user.getId());
+        httpRespMsg.setData(taskFiles);
+        return httpRespMsg;
+    }
 }

+ 170 - 126
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -5,19 +5,17 @@ import com.aliyun.dingtalkcontact_1_0.models.SearchUserResponse;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.util.StringUtil;
 import com.management.platform.entity.*;
 import com.management.platform.entity.bo.QueryTaskChargePage;
-import com.management.platform.entity.vo.TaskChargePageVO;
+import com.management.platform.entity.vo.TaskFileChargePageVO;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.xssf.usermodel.XSSFCell;
@@ -36,7 +34,6 @@ import java.io.*;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -781,109 +778,130 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         return msg;
     }
 
-    @Override
-    @Transactional
-    public HttpRespMsg auditFile(Integer taskId, String projectId, Integer auditStatus, String reason, HttpServletRequest request) {
-        HttpRespMsg msg = new HttpRespMsg();
-        User user = userMapper.selectById(request.getHeader("Token"));
-        //获取该任务的文件审核阶段
-        Task task = taskMapper.selectById(taskId);
-        if(1 == auditStatus){
-            //通过
-            if(1 == task.getChargeStage()){
-                //阶段一,更新阶段一状态
-                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                        .set(Task::getChargeStage,2)
-                        .set(Task::getChargeOneStatus,1)
-                        .set(Task::getChargeOneTime,new Date())
-                        .eq(Task::getId,taskId)
-                );
-            } else if (2 == task.getChargeStage()) {
-                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                        .set(Task::getChargeStage,3)
-                        .set(Task::getFinalChargeStatus,1)
-                        .set(Task::getChargeTwoStatus,1)
-                        .set(Task::getChargeTwoTime,new Date())
-                        .eq(Task::getId,taskId)
-                );
-            }
-            //添加动态消息
-            String content = user.getName()+"审核通过了任务:"+task.getName();
-            TaskComment comment =  new TaskComment();
-            comment.setTaskId(taskId);
-            comment.setUserId(user.getId());
-            comment.setContent(content);
-            comment.setCreateTime(LocalDateTime.now());
-            comment.setUserColor(user.getColor());
-            comment.setUserName(user.getName());
-            taskCommentMapper.insert(comment);
-
-        } else if (2 == auditStatus) {
-            //驳回
-            WxCorpInfo info = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
-            if(1 == task.getChargeStage()){
-                //阶段一,更新阶段一状态
-                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                        .set(Task::getFileRejectReason,reason)
-                        .set(Task::getChargeOneTime,new Date())
-                        .set(Task::getChargeOneStatus,2)
-                        .eq(Task::getId,taskId)
-                );
-            } else if (2 == task.getChargeStage()) {
-                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
-                        .set(Task::getFileRejectReason,reason)
-                        .set(Task::getChargeTwoTime,new Date())
-                        .set(Task::getChargeTwoStatus,2)
-                        .eq(Task::getId,taskId)
-                );
-            }
-            List<TaskFiles> taskFiles = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>()
-                    .eq(TaskFiles::getTaskId, task.getId())
-            );
-            List<String> creatorIds = taskFiles.stream().filter(t -> StringUtils.isNotBlank(t.getCreatorId()))
-                    .map(TaskFiles::getCreatorId).collect(Collectors.toList());
-            if(CollectionUtils.isNotEmpty(creatorIds)){
-                List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
-                        .eq(User::getIsActive, 1)
-                        .in(User::getId, creatorIds)
-                );
-                if(CollectionUtils.isNotEmpty(users)){
-                    List<String> wxCorpIds = users.stream().filter(t -> StringUtils.isNotBlank(t.getCorpwxUserid()))
-                            .map(User::getCorpwxUserid).collect(Collectors.toList());
-                    if(CollectionUtils.isNotEmpty(wxCorpIds)){
-                        String join = StringUtils.join(wxCorpIds, ",");
-                        wxCorpInfoService.sendWXCorpMsg(info,join,"任务:"+task.getName()+"的文件因【"+reason+"】被驳回,请及时处理",null
-                                , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_REJECT);
-                    }
-                }
-            }
-            String content = user.getName()+"审核驳回了任务:"+task.getName();
-            TaskComment comment =  new TaskComment();
-            comment.setTaskId(taskId);
-            comment.setUserId(user.getId());
-            comment.setContent(content);
-            comment.setCreateTime(LocalDateTime.now());
-            comment.setUserColor(user.getColor());
-            comment.setUserName(user.getName());
-            taskCommentMapper.insert(comment);
-        }
-
-        return msg;
-    }
+//    @Override
+//    @Transactional
+//    public HttpRespMsg auditFile(Integer taskId, String projectId, Integer auditStatus, String reason, HttpServletRequest request) {
+//        HttpRespMsg msg = new HttpRespMsg();
+//        User user = userMapper.selectById(request.getHeader("Token"));
+//        //获取该任务的文件审核阶段
+//        Task task = taskMapper.selectById(taskId);
+//        if(1 == auditStatus){
+//            //通过
+//            if(1 == task.getChargeStage()){
+//                //阶段一,更新阶段一状态
+//                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                        .set(Task::getChargeStage,2)
+//                        .set(Task::getChargeOneStatus,1)
+//                        .set(Task::getChargeOneTime,new Date())
+//                        .eq(Task::getId,taskId)
+//                );
+//            } else if (2 == task.getChargeStage()) {
+//                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                        .set(Task::getChargeStage,3)
+//                        .set(Task::getFinalChargeStatus,1)
+//                        .set(Task::getChargeTwoStatus,1)
+//                        .set(Task::getChargeTwoTime,new Date())
+//                        .eq(Task::getId,taskId)
+//                );
+//            }
+//            //添加动态消息
+//            String content = user.getName()+"审核通过了任务:"+task.getName();
+//            TaskComment comment =  new TaskComment();
+//            comment.setTaskId(taskId);
+//            comment.setUserId(user.getId());
+//            comment.setContent(content);
+//            comment.setCreateTime(LocalDateTime.now());
+//            comment.setUserColor(user.getColor());
+//            comment.setUserName(user.getName());
+//            taskCommentMapper.insert(comment);
+//
+//        } else if (2 == auditStatus) {
+//            //驳回
+//            WxCorpInfo info = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+//            if(1 == task.getChargeStage()){
+//                //阶段一,更新阶段一状态
+//                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                        .set(Task::getFileRejectReason,reason)
+//                        .set(Task::getChargeOneTime,new Date())
+//                        .set(Task::getChargeOneStatus,2)
+//                        .eq(Task::getId,taskId)
+//                );
+//            } else if (2 == task.getChargeStage()) {
+//                taskMapper.update(null,new LambdaUpdateWrapper<Task>()
+//                        .set(Task::getFileRejectReason,reason)
+//                        .set(Task::getChargeTwoTime,new Date())
+//                        .set(Task::getChargeTwoStatus,2)
+//                        .eq(Task::getId,taskId)
+//                );
+//            }
+//            List<TaskFiles> taskFiles = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>()
+//                    .eq(TaskFiles::getTaskId, task.getId())
+//            );
+//            List<String> creatorIds = taskFiles.stream().filter(t -> StringUtils.isNotBlank(t.getCreatorId()))
+//                    .map(TaskFiles::getCreatorId).collect(Collectors.toList());
+//            if(CollectionUtils.isNotEmpty(creatorIds)){
+//                List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
+//                        .eq(User::getIsActive, 1)
+//                        .in(User::getId, creatorIds)
+//                );
+//                if(CollectionUtils.isNotEmpty(users)){
+//                    List<String> wxCorpIds = users.stream().filter(t -> StringUtils.isNotBlank(t.getCorpwxUserid()))
+//                            .map(User::getCorpwxUserid).collect(Collectors.toList());
+//                    if(CollectionUtils.isNotEmpty(wxCorpIds)){
+//                        String join = StringUtils.join(wxCorpIds, ",");
+//                        wxCorpInfoService.sendWXCorpMsg(info,join,"任务:"+task.getName()+"的文件因【"+reason+"】被驳回,请及时处理",null
+//                                , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_REJECT);
+//                    }
+//                }
+//            }
+//            String content = user.getName()+"审核驳回了任务:"+task.getName();
+//            TaskComment comment =  new TaskComment();
+//            comment.setTaskId(taskId);
+//            comment.setUserId(user.getId());
+//            comment.setContent(content);
+//            comment.setCreateTime(LocalDateTime.now());
+//            comment.setUserColor(user.getColor());
+//            comment.setUserName(user.getName());
+//            taskCommentMapper.insert(comment);
+//        }
+//
+//        return msg;
+//    }
 
     @Override
     public HttpRespMsg getFileRejectReason(String taskId, HttpServletRequest request) {
         HttpRespMsg msg=new HttpRespMsg();
-        Task task = taskMapper.selectById(taskId);
-        String reason = "";
-        if(null != task){
-            reason = task.getFileRejectReason();
-        }
-//        switch (task.getChargeStage()){
-//            case 1 : reason = task.getChargeOneReason();break;
-//            case 2 : reason = task.getChargeTwoReason();break;
+        User user = userMapper.selectById(request.getHeader("Token"));
+        //文件创建人、审核人为自己
+        //文件开启审核功能、最终审核状态为未通过
+        List<TaskFiles> taskFiles = taskFilesMapper.selectList(new LambdaQueryWrapper<TaskFiles>()
+                .eq(TaskFiles::getTaskId, taskId)
+                .eq(TaskFiles::getNeedFileCharge, 1)
+                .eq(TaskFiles::getFinalChargeStatus, 0)
+                .and(wrapper -> wrapper.eq(TaskFiles::getCreatorId, user.getId())
+                        .or().eq(TaskFiles::getChargeOneId, user.getId())
+                        .or().eq(TaskFiles::getChargeTwoId, user.getId()))
+        );
+        List<TaskFiles> collect = taskFiles.stream().filter(t -> {
+            if (1 == t.getChargeStage()) {
+                return 2 == t.getChargeOneStatus();
+            } else if (2 == t.getChargeStage()) {
+                return 2 == t.getChargeTwoStatus();
+            }else {
+                return false;
+            }
+        }).collect(Collectors.toList());
+        msg.setData(collect);
+//        Task task = taskMapper.selectById(taskId);
+//        String reason = "";
+//        if(null != task){
+//            reason = task.getFileRejectReason();
 //        }
-        msg.setData(reason);
+////        switch (task.getChargeStage()){
+////            case 1 : reason = task.getChargeOneReason();break;
+////            case 2 : reason = task.getChargeTwoReason();break;
+////        }
+//        msg.setData(reason);
         return msg;
     }
 
@@ -894,6 +912,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         User user = userMapper.selectById(userId);
         Integer companyId = user.getCompanyId();
         queryBO.setUserId(userId);
+        queryBO.setCompanyId(companyId);
 
         queryBO.setPageIndex((queryBO.getPageIndex()-1)*queryBO.getPageSize());
 
@@ -903,41 +922,66 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             branchDepartment= getBranchDepartment(queryBO.getDeptId(), departmentList);
         }
 
-        List<TaskChargePageVO> taskChargePage = taskMapper.getTaskChargePage(queryBO, branchDepartment);
-        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
-        CompanyDingding dingding = companyDingdingService.getOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
-        List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id",user.getCompanyId()));
-        Map<String, User> companyUserMap = users.stream().collect(Collectors.toMap(User::getId, t -> t));
+        //文件处于审核阶段,且该阶段审核人为当前登录人
+//        List<TaskChargePageVO> taskChargePage = taskMapper.getTaskChargePage(queryBO, branchDepartment);
 
-        if(CollectionUtils.isNotEmpty(taskChargePage)){
-            List<Integer> collect = taskChargePage.stream()
-                    .map(TaskChargePageVO::getTaskId).distinct().collect(Collectors.toList());
+        List<TaskFileChargePageVO> taskFileChargePageList = taskMapper.getTaskFileChargePage(queryBO,branchDepartment);
+
+//        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
+//        CompanyDingding dingding = companyDingdingService.getOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
+//        List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id",user.getCompanyId()));
+//        Map<String, User> companyUserMap = users.stream().collect(Collectors.toMap(User::getId, t -> t));
+
+        if(CollectionUtils.isNotEmpty(taskFileChargePageList)){
+            List<Integer> collect = taskFileChargePageList.stream()
+                    .map(TaskFileChargePageVO::getTaskId).distinct().collect(Collectors.toList());
 
             List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().in("task_id", collect));
 
-            taskChargePage.forEach(t->{
+            taskFileChargePageList.forEach(t->{
                 List<TaskExecutor> executorList = taskExecutorList.stream()
                         .filter(te -> te.getTaskId().equals(t.getTaskId())&&te.getExecutorId()!=null).collect(Collectors.toList());
                 t.setExecutorList(executorList);
-                String userWxId = "";
-                User tmpUser = companyUserMap.get(t.getFinalChargeId());
-                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                    userWxId = tmpUser.getCorpwxRealUserid();
-                }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
-                    userWxId = tmpUser.getDingdingUserid();
-                }
-                if(StringUtils.isNotBlank(userWxId)){
-                    t.setFinalChargeName("$userName=" + userWxId + "$");
-                }
-                int finalStatus = 1==t.getChargeStage()?t.getChargeOneStatus():t.getChargeTwoStatus();
-                t.setFileChargeStatus(finalStatus);
+//                String userWxId = "";
+//                User tmpUser = companyUserMap.get(t.getFinalChargeId());
+//                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+//                    userWxId = tmpUser.getCorpwxRealUserid();
+//                }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
+//                    userWxId = tmpUser.getDingdingUserid();
+//                }
+//                if(StringUtils.isNotBlank(userWxId)){
+//                    t.setFinalChargeName("$userName=" + userWxId + "$");
+//                }else{
+//                    t.setFinalChargeName(tmpUser.getName());
+//                }
+//                List<TaskFiles> childFiles = t.getChildFiles();
+//                //是否存在驳回
+//                long rejectCount = childFiles.stream().filter(tmp -> {
+//                    if (2 == tmp.getChargeOneStatus() || 2 == tmp.getChargeTwoStatus()) {
+//                        return true;
+//                    } else {
+//                        return false;
+//                    }
+//                }).count();
+//                //是否都是全部通过
+//                long allPassCount = childFiles.stream().filter(tmp -> 1 == tmp.getFinalChargeStatus()).count();
+//                if(rejectCount > 0 ){
+//                    t.setTaskChargeStatus(2);
+//                } else if (allPassCount == childFiles.size()) {
+//                    t.setTaskChargeStatus(3);
+//                }else {
+//                    t.setTaskChargeStatus(1);
+//                }
+
+//                int finalStatus = 1==t.getChargeStage()?t.getChargeOneStatus():t.getChargeTwoStatus();
+//                t.setFileChargeStatus(finalStatus);
             });
         }
 
-
-        int total = taskMapper.getTaskChargePageTotal(queryBO,branchDepartment);
+//        int total = taskMapper.getTaskChargePageTotal(queryBO,branchDepartment);
+        int total = taskMapper.getTaskFileChargePageTotal(queryBO,branchDepartment);
         Map<String, Object> map = new HashMap<>();
-        map.put("records", taskChargePage);
+        map.put("records", taskFileChargePageList);
         map.put("total", total);
         msg.data = map;
         return msg;

+ 44 - 52
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -2313,10 +2313,12 @@ public class TimingTask {
         }
     }
 
-    @Scheduled(cron = "0 30 9 ? * *")
+    @Scheduled(cron = "0 30 09 ? * *")
     public void remindTaskFile(){
-        List<Integer> taskIds =  taskFilesMapper.getAllTaskIds();
-        if(CollectionUtils.isNotEmpty(taskIds)){
+//        List<Integer> taskIds =  taskFilesMapper.getAllNeedChargeTaskIds();
+        List<TaskFiles> taskFiles = taskFilesMapper.getAllNeedChargeTaskFiles();
+        if(CollectionUtils.isNotEmpty(taskFiles)){
+            Map<Integer, List<TaskFiles>> companyTaskFileMap = taskFiles.stream().collect(Collectors.groupingBy(TaskFiles::getCompanyId));
             List<WxCorpInfo> wxCorpInfos = wxCorpInfoMapper.selectList(new LambdaQueryWrapper<WxCorpInfo>()
                     .eq(WxCorpInfo::getSaasSyncContact,1)
             );
@@ -2330,60 +2332,50 @@ public class TimingTask {
             if(CollectionUtils.isNotEmpty(timeTypes)){
                 companyTimeTypeMap = timeTypes.stream().collect(Collectors.toMap(TimeType::getCompanyId,t->t));
             }
-
-            List<Task> tasks = taskMapper.selectList(new LambdaQueryWrapper<Task>()
-                    .eq(Task::getTaskStatus, 0)
-                    .eq(Task::getFinalChargeStatus,0)
-                    .isNotNull(Task::getChargeOneId)
-                    .ne(Task::getChargeStage,3)
-                    .in(Task::getId, taskIds)
-            );
-            if(CollectionUtils.isNotEmpty(tasks)){
-                Map<Integer, List<Task>> companyTaskMap = tasks.stream().collect(Collectors.groupingBy(Task::getCompanyId));
-                for (Map.Entry<Integer, List<Task>> entry : companyTaskMap.entrySet()) {
-                    if(0 == companyTimeTypeMap.get(entry.getKey()).getTaskFileCharge()){
-                        continue;
-                    }
-                    WxCorpInfo wxCorpInfo = companyWXCorpMap.get(entry.getKey());
-                    List<Task> companyTasks = entry.getValue();
-                    List<String> userIds = new ArrayList<>();
-                    List<String> chargeOneIds = companyTasks.stream().map(Task::getChargeOneId).collect(Collectors.toList());
-                    List<String> chargeTwoIds = companyTasks.stream().filter(t -> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeTwoId()))
-                            .map(Task::getChargeTwoId).collect(Collectors.toList());
-                    userIds.addAll(chargeOneIds);
-                    userIds.addAll(chargeTwoIds);
-                    Map<String, String> userIdCorpWxMap = new HashMap<>();
-                    if(CollectionUtils.isNotEmpty(userIds)){
-                        userIds = userIds.stream().distinct().collect(Collectors.toList());
-                        List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
-                                .select(User::getId,User::getCorpwxUserid)
-                                .in(User::getId, userIds)
-                        );
-                        userIdCorpWxMap = users.stream().filter(t-> org.apache.commons.lang3.StringUtils.isNotBlank(t.getCorpwxUserid()))
-                                .collect(Collectors.toMap(User::getId, User::getCorpwxUserid));
-                    }
-                    if(null != wxCorpInfo){
-                        for (Task companyTask : companyTasks) {
-                            if(1==companyTask.getChargeStage()){
-                                //阶段一的审核人提示
-                                String corpWxId = userIdCorpWxMap.get(companyTask.getChargeOneId());
-                                if(org.apache.commons.lang3.StringUtils.isNotBlank(corpWxId)){
-                                    wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,corpWxId,"任务:"+companyTask.getName()+"的文件需审核,请及时处理",null
-                                            , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_UPDATE);
-                                }
-                            } else if (2 == companyTask.getChargeStage()) {
-                                //阶段二的审核人提示
-                                String corpWxId = userIdCorpWxMap.get(companyTask.getChargeTwoId());
-                                if(org.apache.commons.lang3.StringUtils.isNotBlank(corpWxId)){
-                                    wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,corpWxId,"任务:"+companyTask.getName()+"的文件需审核,请及时处理",null
-                                            , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_UPDATE);
-                                }
+            for (Map.Entry<Integer, List<TaskFiles>> entry : companyTaskFileMap.entrySet()) {
+                if(0 == companyTimeTypeMap.get(entry.getKey()).getTaskFileCharge()){
+                    continue;
+                }
+                List<TaskFiles> companyTaskFiles = entry.getValue();
+                WxCorpInfo wxCorpInfo = companyWXCorpMap.get(entry.getKey());
+                List<String> userIds = new ArrayList<>();
+                List<String> chargeOneIds = companyTaskFiles.stream().filter(t -> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeOneId()))
+                        .map(TaskFiles::getChargeOneId).collect(Collectors.toList());
+                List<String> chargeTwoIds = companyTaskFiles.stream().filter(t -> org.apache.commons.lang3.StringUtils.isNotBlank(t.getChargeTwoId()))
+                        .map(TaskFiles::getChargeTwoId).collect(Collectors.toList());
+                userIds.addAll(chargeOneIds);
+                userIds.addAll(chargeTwoIds);
+                Map<String, String> userIdCorpWxMap = new HashMap<>();
+                if(CollectionUtils.isNotEmpty(userIds)){
+                    userIds = userIds.stream().distinct().collect(Collectors.toList());
+                    List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
+                            .select(User::getId,User::getCorpwxUserid)
+                            .in(User::getId, userIds)
+                    );
+                    userIdCorpWxMap = users.stream().filter(t-> org.apache.commons.lang3.StringUtils.isNotBlank(t.getCorpwxUserid()))
+                            .collect(Collectors.toMap(User::getId, User::getCorpwxUserid));
+                }
+                if(null != wxCorpInfo){
+                    for (TaskFiles companyTaskFile : companyTaskFiles) {
+                        if(1==companyTaskFile.getChargeStage()){
+                            //阶段一的审核人提示
+                            String corpWxId = userIdCorpWxMap.get(companyTaskFile.getChargeOneId());
+                            if(org.apache.commons.lang3.StringUtils.isNotBlank(corpWxId)){
+                                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,corpWxId,"任务:"+companyTaskFile.getTaskName()+"的文件需审核,请及时处理",null
+                                        , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_UPDATE);
+                            }
+                        } else if (2 == companyTaskFile.getChargeStage()) {
+                            //阶段二的审核人提示
+                            String corpWxId = userIdCorpWxMap.get(companyTaskFile.getChargeTwoId());
+                            if(org.apache.commons.lang3.StringUtils.isNotBlank(corpWxId)){
+                                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,corpWxId,"任务:"+companyTaskFile.getTaskName()+"的文件需审核,请及时处理",null
+                                        , WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_FILE_UPDATE);
                             }
                         }
-
                     }
                 }
             }
+
         }
     }
 }

+ 7 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskCommentMapper.xml

@@ -18,5 +18,12 @@
     <sql id="Base_Column_List">
         id, task_id, user_id, user_name, content, create_time, user_color, type
     </sql>
+    <insert id="insertBatch">
+        insert into task_comment(task_id, user_id, user_name, content, create_time, user_color)
+        VALUES
+            <foreach collection="commentList" item="comment" separator=",">
+            (#{comment.taskId},#{comment.userId},#{comment.userName},#{comment.content},#{comment.createTime},#{comment.userColor})
+            </foreach>
+    </insert>
 
 </mapper>

+ 34 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskFilesMapper.xml

@@ -22,11 +22,43 @@
     <sql id="Base_Column_List">
         id, task_id, project_id, document_name, server_name, url, indate, size, document_type, creator_id, creator_name, document_id
     </sql>
-    <select id="getAllTaskIds" resultType="java.lang.Integer">
+    <select id="getAllNeedChargeTaskIds" resultType="java.lang.Integer">
         select task_id
         from task_files
-        where task_id is not null
+        where task_id is not null and need_file_charge = 1 and final_charge_status = 0
         group by task_id
     </select>
+    <select id="getTaskFiles" resultType="com.management.platform.entity.TaskFiles">
+        select *
+        from task_files
+        where task_id = #{taskId}
+          and (
+            charge_one_id = #{userId} or charge_two_id = #{userId} or creator_id = #{userId}
+                or need_file_charge = 0
+                or final_charge_status = 1
+            )
+        ORDER BY indate desc
+    </select>
+    <select id="getAllNeedChargeTaskFiles" resultType="com.management.platform.entity.TaskFiles">
+        select task_files.*,task.company_id,task.name as taskName
+        from task_files
+                 left join task on task_files.task_id = task.id
+        where task_files.task_id is not null and task_files.need_file_charge = 1 and task_files.final_charge_status = 0
+    </select>
+    <select id="getUnChargedFilesByTaskId" resultType="com.management.platform.entity.TaskFiles">
+        select *
+        from task_files
+        where task_id = #{taskId} and need_file_charge = 1 and final_charge_status = 0
+          and case charge_stage
+                  when 1 then charge_one_id = #{userId} and charge_one_status = 0
+                  when 2 then charge_two_id = #{userId} and charge_two_status = 0
+            end
+    </select>
+    <select id="getTaskFilesByCreatorDeptId" resultType="com.management.platform.entity.TaskFiles">
+        select tf.id
+        from task_files tf
+                 left join user on tf.creator_id = user.id
+        where user.department_id = #{departmentId}
+    </select>
 
 </mapper>

+ 128 - 22
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskMapper.xml

@@ -32,15 +32,6 @@
         <result column="meeting_id" property="meetingId" />
         <result column="ahead_tid" property="aheadTid" />
         <result column="sap_task_code" property="sapTaskCode" />
-        <result column="charge_one_id" property="chargeOneId" />
-        <result column="charge_one_status" property="chargeOneStatus" />
-        <result column="charge_one_time" property="chargeOneTime" />
-        <result column="charge_two_id" property="chargeTwoId" />
-        <result column="charge_two_status" property="chargeTwoStatus" />
-        <result column="charge_two_time" property="chargeTwoTime" />
-        <result column="final_charge_status" property="finalChargeStatus" />
-        <result column="charge_stage" property="chargeStage" />
-        <result column="file_reject_reason" property="fileRejectReason" />
         <result column="plan_cost" property="planCost" />
     </resultMap>
     <resultMap id="timeResultMap" type="com.management.platform.entity.TimeTask" >
@@ -107,19 +98,19 @@
         <result column="stages_name" property="stagesName" />
         <result column="department_name" property="departmentName" />
 
-        <result column="charge_one_id" property="chargeOneId" />
-        <result column="charge_one_status" property="chargeOneStatus" />
-        <result column="charge_one_time" property="chargeOneTime" />
-        <result column="charge_two_id" property="chargeTwoId" />
-        <result column="charge_two_status" property="chargeTwoStatus" />
-        <result column="charge_two_time" property="chargeTwoTime" />
-        <result column="charge_stage" property="chargeStage" />
-        <result column="final_charge_status" property="finalChargeStatus" />
-        <result column="reject_reason" property="rejectReason"></result>
+<!--        <result column="charge_one_id" property="chargeOneId" />-->
+<!--        <result column="charge_one_status" property="chargeOneStatus" />-->
+<!--        <result column="charge_one_time" property="chargeOneTime" />-->
+<!--        <result column="charge_two_id" property="chargeTwoId" />-->
+<!--        <result column="charge_two_status" property="chargeTwoStatus" />-->
+<!--        <result column="charge_two_time" property="chargeTwoTime" />-->
+<!--        <result column="charge_stage" property="chargeStage" />-->
+<!--        <result column="final_charge_status" property="finalChargeStatus" />-->
+<!--        <result column="file_reject_reason" property="fileRejectReason"></result>-->
     </resultMap>
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, name, task_desc, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date, meeting_id, ahead_tid, sap_task_code, charge_one_id, charge_one_status, charge_one_time, charge_two_id, charge_two_status, charge_two_time, final_charge_status, charge_stage, file_reject_reason, plan_cost
+        id, name, task_desc, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date, meeting_id, ahead_tid, sap_task_code, plan_cost
     </sql>
     <select id="simpleList" resultMap="BaseResultMap">
         select id, name, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date
@@ -243,7 +234,7 @@
         </if>
     </select>
     <select id="getTaskPlanRealData" resultType="java.util.Map">
-        SELECT task.id,task.`name`,task_executor.id as teId, DATE_FORMAT(task.`end_date`, '%Y-%m-%d') as endDate, task.`plan_hours` as planHours,task.plan_cost as planCost,
+        SELECT task.id,task.`name`,task_executor.id as teId, DATE_FORMAT(task.`end_date`, '%Y-%m-%d') as endDate, task_executor.`plan_hours` as planHours,task.plan_cost as planCost,
         (SELECT IFNULL(SUM(working_time),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1) AS realHours,
         task_executor.executor_id as executorId,task_executor.executor_name AS executorName,
         IF(task_executor.real_cost = 0, task.plan_cost, task_executor.real_cost) AS realCost,
@@ -290,7 +281,7 @@
     <select id="getTaskWithProjectName" resultMap="RichResultMap">
         SELECT task.id, task.project_id, task.name, task.executor_name, task.start_date, task.`end_date`,task.create_date, task.`creater_id`, task.`creater_name`, task.group_id,
         task.plan_hours, task.task_type, task.task_level, task.task_status, task.`finish_date`, project.`project_name`, stages.stages_name,department.department_name
-        ,task.charge_one_id,task.charge_one_status,task.charge_two_id,task.charge_two_status,task.charge_stage,task.final_charge_status
+        <!-- ,task.charge_one_id,task.charge_one_status,task.charge_two_id,task.charge_two_status,task.charge_stage,task.final_charge_status -->
         FROM task LEFT JOIN project ON project.id = task.`project_id`
         left join stages on stages.id = task.stages_id
         left join department on department.department_id=project.dept_id
@@ -428,7 +419,7 @@
     <select id="getTaskWithProjectNameWithCharge" resultMap="RichResultMap">
         SELECT task.id, task.project_id, task.name, task.executor_name, task.start_date, task.`end_date`,task.create_date, task.`creater_id`, task.`creater_name`, task.group_id,
         task.plan_hours, task.task_type, task.task_level, task.task_status, task.`finish_date`, project.`project_name`, stages.stages_name,department.department_name
-        ,task.charge_one_id,task.charge_one_status,task.charge_two_id,task.charge_two_status,task.charge_stage,task.final_charge_status
+        <!-- ,task.charge_one_id,task.charge_one_status,task.charge_two_id,task.charge_two_status,task.charge_stage,task.final_charge_status-->
         FROM task LEFT JOIN project ON project.id = task.`project_id`
         left join stages on stages.id = task.stages_id
         left join department on department.department_id=project.dept_id
@@ -628,4 +619,119 @@
         group by tmp1.task_id
         )tmpAll
     </select>
+
+    <resultMap id="taskFileChargeMap" type="com.management.platform.entity.vo.TaskFileChargePageVO">
+        <result property="taskId" column="task_id"></result>
+        <result property="taskName" column="taskName"></result>
+        <result property="groupId" column="group_id"></result>
+        <result property="executorId" column="executor_id"></result>
+        <result property="projectId" column="projectId"></result>
+        <result property="projectName" column="project_name"></result>
+        <collection property="childFiles" ofType="com.management.platform.entity.TaskFiles">
+            <result property="id" column="id"></result>
+            <result property="documentName" column="document_name"></result>
+            <result property="creatorId" column="creator_id"></result>
+            <result property="creatorName" column="creator_name"></result>
+            <result property="chargeOneId" column="charge_one_id"></result>
+            <result property="chargeOneStatus" column="charge_one_status"></result>
+            <result property="chargeOneTime" column="charge_one_time"></result>
+            <result property="chargeTwoId" column="charge_two_id"></result>
+            <result property="chargeTwoStatus" column="charge_two_status"></result>
+            <result property="chargeTwoTime" column="charge_two_time"></result>
+            <result property="chargeStage" column="charge_stage"></result>
+            <result property="finalChargeStatus" column="final_charge_status"></result>
+            <result property="fileRejectReason" column="file_reject_reason"></result>
+            <result property="needFileCharge" column="need_file_charge"></result>
+        </collection>
+    </resultMap>
+
+    <select id="getTaskFileChargePage" resultMap="taskFileChargeMap">
+        select tf.task_id,task.name as taskName,task.group_id,task.executor_id
+        ,p.id as projectId,p.project_name
+        from task_files tf
+        left join task on tf.task_id = task.id
+        left join project p on task.project_id = p.id
+        <where>
+            tf.need_file_charge = 1
+            and tf.final_charge_status = 0
+            and task.task_status = 0
+            and task.company_id = #{queryBO.companyId}
+            and case tf.charge_stage
+            when 1 then tf.charge_one_id = #{queryBO.userId} and tf.charge_one_status = 0
+            when 2 then tf.charge_two_id = #{queryBO.userId} and tf.charge_two_status = 0
+            end
+            <if test="queryBO.taskName != null and queryBO.taskName != ''">
+                and task.name like concat('%',#{queryBO.taskName},'%')
+            </if>
+            <if test="deptIds!=null and deptIds.size()>0">
+                and p.dept_id in
+                <foreach collection="deptIds" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        group by tf.task_id
+        ORDER BY tf.task_id desc
+        <if test="queryBO.pageIndex != null and queryBO.pageSize != null">
+            limit #{queryBO.pageIndex}, #{queryBO.pageSize}
+        </if>
+    </select>
+    <select id="getTaskFileChargePageTotal" resultType="java.lang.Integer">
+        select count(*)
+        from
+            (
+                select tf.task_id
+                from task_files tf
+                         left join task on tf.task_id = task.id
+                         left join project p on task.project_id = p.id
+                <where>
+                    tf.need_file_charge = 1
+                    and tf.final_charge_status = 0
+                    and task.task_status = 0
+                    and task.company_id = #{queryBO.companyId}
+                    and case tf.charge_stage
+                    when 1 then tf.charge_one_id = #{queryBO.userId} and tf.charge_one_status = 0
+                    when 2 then tf.charge_two_id = #{queryBO.userId} and tf.charge_two_status = 0
+                    end
+                    <if test="queryBO.taskName != null and queryBO.taskName != ''">
+                        and task.name like concat('%',#{queryBO.taskName},'%')
+                    </if>
+                    <if test="deptIds!=null and deptIds.size()>0">
+                        and p.dept_id in
+                        <foreach collection="deptIds" open="(" close=")" separator="," item="item">
+                            #{item}
+                        </foreach>
+                    </if>
+                </where>
+                group by tf.task_id
+            )tmp1
+    </select>
+    <select id="getProjectAllTaskTimeCost"
+            resultType="com.management.platform.entity.vo.ProjectTaskTimeCostVO">
+        SELECT task.id as taskId,ifnull(task_executor.`plan_hours`,0) as planHours,
+        (SELECT IFNULL(SUM(working_time),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1) AS realHours,
+        task_executor.executor_id as executorId
+        FROM task
+        LEFT JOIN project ON project.id = task.`project_id`
+        left join task_executor on task_executor.task_id=task.id
+        WHERE task.project_id = #{projectId}
+          and project.id = #{projectId}
+    </select>
+    <select id="getProjectTaskTimeCostByIds" resultType="com.management.platform.entity.vo.ProjectTimeCostVO">
+        select project_id,sum(planHours) as planHoursSum,sum(realHours) as realHoursSum
+        from
+            (
+                SELECT task.project_id,task.id as taskId,ifnull(task_executor.`plan_hours`,0) as planHours,
+                       (SELECT IFNULL(SUM(working_time),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1) AS realHours,
+                       task_executor.executor_id as executorId
+                FROM task
+                         LEFT JOIN project ON project.id = task.`project_id`
+                         left join task_executor on task_executor.task_id=task.id
+                WHERE task.project_id in
+                      <foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
+                            #{projectId}
+                        </foreach>
+            )tmp1
+        group by project_id
+    </select>
 </mapper>