Browse Source

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

zhouyy 3 months ago
parent
commit
a7408aec24
12 changed files with 578 additions and 111 deletions
  1. 16 8
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java
  2. 4 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java
  3. 1 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ExcelExportService.java
  4. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectMainService.java
  5. 4 4
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java
  6. 125 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java
  7. 25 17
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java
  8. 9 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectMainServiceImpl.java
  9. 184 80
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  10. 169 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ExcelUtil.java
  11. 37 1
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  12. 2 0
      fhKeeper/formulahousekeeper/timesheet/index.html

+ 16 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -9,6 +9,7 @@ import com.management.platform.entity.vo.OvertimeListVO;
 import com.management.platform.mapper.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.OperationRecordService;
 import com.management.platform.service.OperationRecordService;
 import com.management.platform.service.ParticipationService;
 import com.management.platform.service.ParticipationService;
+import com.management.platform.service.ProjectMainService;
 import com.management.platform.service.ProjectService;
 import com.management.platform.service.ProjectService;
 import com.management.platform.util.DockWithMLD;
 import com.management.platform.util.DockWithMLD;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.HttpRespMsg;
@@ -74,6 +75,8 @@ public class ProjectController {
     private ParticipationService participationService;
     private ParticipationService participationService;
     @Resource
     @Resource
     private ReportExtraDegreeMapper reportExtraDegreeMapper;
     private ReportExtraDegreeMapper reportExtraDegreeMapper;
+    @Resource
+    private ProjectMainService projectMainService;
 
 
 
 
     @RequestMapping("/testRead")
     @RequestMapping("/testRead")
@@ -99,8 +102,8 @@ public class ProjectController {
      * 获取项目列表
      * 获取项目列表
      */
      */
     @RequestMapping("/getProjectList")
     @RequestMapping("/getProjectList")
-    public HttpRespMsg getProjectList(@RequestParam(required = false, defaultValue = "0") Integer forReport, String userId) {
-        return projectService.getProjectList(forReport, userId, request);
+    public HttpRespMsg getProjectList(@RequestParam(required = false, defaultValue = "0") Integer forReport, String userId,@RequestParam(required = false) Integer projectMainId) {
+        return projectService.getProjectList(forReport, userId,projectMainId, request);
     }
     }
 
 
     /**
     /**
@@ -123,6 +126,11 @@ public class ProjectController {
                                       Integer status, Integer category,Integer projectMainId,Integer deptId, String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate) {
                                       Integer status, Integer category,Integer projectMainId,Integer deptId, String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate) {
         return projectService.getProjectPage(pageIndex, pageSize, keyword,searchField, status, category, projectId,projectMainId,deptId, sortProp, sortOrder,inchagerId,participation,startDate,endDate, request);
         return projectService.getProjectPage(pageIndex, pageSize, keyword,searchField, status, category, projectId,projectMainId,deptId, sortProp, sortOrder,inchagerId,participation,startDate,endDate, request);
     }
     }
+    @RequestMapping("/getAllMainProject")
+    public HttpRespMsg getAllMainProject() {
+        return projectMainService.getAllMainProject(request);
+    }
+
 
 
     /**
     /**
      * 预估工时表
      * 预估工时表
@@ -457,8 +465,8 @@ public class ProjectController {
 
 
     //导出项目报表
     //导出项目报表
     @RequestMapping("/exportProject")
     @RequestMapping("/exportProject")
-    public HttpRespMsg exportProject() {
-        return projectService.exportProject(request);
+    public HttpRespMsg exportProject(@RequestParam(required = false) Integer projectId, @RequestParam(required = false) Integer projectMainId) {
+        return projectService.exportProject(projectId,projectMainId,request);
     }
     }
 
 
     //分页查询项目任务报表
     //分页查询项目任务报表
@@ -522,8 +530,8 @@ public class ProjectController {
 
 
     //分页查询项目收支平衡表
     //分页查询项目收支平衡表
     @RequestMapping("/getProjectInAndOut")
     @RequestMapping("/getProjectInAndOut")
-    public HttpRespMsg getProjectInAndOut(@RequestParam Integer pageIndex, @RequestParam Integer pageSize, Integer projectId) {
-        return projectService.getProjectInAndOut(pageIndex, pageSize, projectId, request);
+    public HttpRespMsg getProjectInAndOut(@RequestParam Integer pageIndex, @RequestParam Integer pageSize, Integer projectId,@RequestParam(required = false)Integer projectMainId) {
+        return projectService.getProjectInAndOut(pageIndex, pageSize, projectId,projectMainId, request);
     }
     }
 
 
     //分页查询项目收支平衡表
     //分页查询项目收支平衡表
@@ -533,8 +541,8 @@ public class ProjectController {
     }
     }
     //导出项目收支平衡表
     //导出项目收支平衡表
     @RequestMapping("/exportProjectInAndOut")
     @RequestMapping("/exportProjectInAndOut")
-    public HttpRespMsg exportProjectInAndOut() {
-        return projectService.exportProjectInAndOut(request);
+    public HttpRespMsg exportProjectInAndOut(@RequestParam(required = false)Integer projectId,@RequestParam(required = false)Integer projectMainId) {
+        return projectService.exportProjectInAndOut(projectId,projectMainId,request);
     }
     }
 
 
     //分页查询客户项目统计报表
     //分页查询客户项目统计报表

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -57,7 +57,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
 
     List<Map<String,Object>> getAllProjectCost(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId,List<Integer> inchagerIds);
     List<Map<String,Object>> getAllProjectCost(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId,List<Integer> inchagerIds);
 
 
-    List<Project> getProjectInAndOut(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId,List<Integer> inchagerIds);
+    List<Project> getProjectInAndOut(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId,List<Integer> inchagerIds,Integer projectMainId);
     List<Map<String,Object>> getProjectExpenseFee(Integer companyId, List<Integer> projectIds);
     List<Map<String,Object>> getProjectExpenseFee(Integer companyId, List<Integer> projectIds);
 
 
     List<CustomerProject> getCustomerProjectInAndOut(Integer companyId, Integer pageStart, Integer pageSize,Integer customerId,Integer projectId);
     List<CustomerProject> getCustomerProjectInAndOut(Integer companyId, Integer pageStart, Integer pageSize,Integer customerId,Integer projectId);
@@ -235,4 +235,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     @Update("update project set plan_end_date=null where id=#{id}")
     @Update("update project set plan_end_date=null where id=#{id}")
     void updateProjectEndDateToNull(@Param("id") Integer id);
     void updateProjectEndDateToNull(@Param("id") Integer id);
 
 
+    List<Map<String, Object>> getParticipatedProjectWithMainProjectId(@Param("userId") String userId, @Param("companyId") Integer companyId,@Param("projectMainId") Integer projectMainId);
+
+    int getProjectInAndOutTotal(Integer companyId, Integer projectId, List<Integer> inchagerIds,Integer projectMainId);
 }
 }

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

@@ -10,6 +10,7 @@ import java.util.Map;
 public interface ExcelExportService {
 public interface ExcelExportService {
     public void testRead(String jobId);
     public void testRead(String jobId);
     public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
+    public HttpRespMsg exportGeneralExcelByTitleAndListByZheZhong(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
     public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
     public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
     public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectMainService.java

@@ -19,4 +19,6 @@ public interface ProjectMainService extends IService<ProjectMain> {
     HttpRespMsg addOrMod(HttpServletRequest request,ProjectMain projectMain);
     HttpRespMsg addOrMod(HttpServletRequest request,ProjectMain projectMain);
 
 
     HttpRespMsg getListByCategory(Integer categoryId);
     HttpRespMsg getListByCategory(Integer categoryId);
+
+    HttpRespMsg getAllMainProject(HttpServletRequest request);
 }
 }

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -21,7 +21,7 @@ import java.time.LocalDate;
  * @since 2020-01-03
  * @since 2020-01-03
  */
  */
 public interface ProjectService extends IService<Project> {
 public interface ProjectService extends IService<Project> {
-    HttpRespMsg getProjectList(Integer forReport, String userId, HttpServletRequest request);
+    HttpRespMsg getProjectList(Integer forReport, String userId,Integer projectMainId, HttpServletRequest request);
 
 
     HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
     HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
                                Integer status, Integer category, Integer projectId,Integer projectMainId,Integer deptId, String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate, HttpServletRequest request);
                                Integer status, Integer category, Integer projectId,Integer projectMainId,Integer deptId, String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate, HttpServletRequest request);
@@ -93,7 +93,7 @@ public interface ProjectService extends IService<Project> {
 
 
     HttpRespMsg exportProfit(HttpServletRequest request);
     HttpRespMsg exportProfit(HttpServletRequest request);
 
 
-    HttpRespMsg exportProject(HttpServletRequest request);
+    HttpRespMsg exportProject(Integer projectId, Integer projectMainId,HttpServletRequest request);
 
 
     HttpRespMsg getProjectTask(Integer pageIndex, Integer pageSize, Integer projectId,Integer groupId, HttpServletRequest request,Integer taskType);
     HttpRespMsg getProjectTask(Integer pageIndex, Integer pageSize, Integer projectId,Integer groupId, HttpServletRequest request,Integer taskType);
 
 
@@ -105,9 +105,9 @@ public interface ProjectService extends IService<Project> {
 
 
     HttpRespMsg exportProjectEstimatedWorkTime(HttpServletRequest request,Integer projectId);
     HttpRespMsg exportProjectEstimatedWorkTime(HttpServletRequest request,Integer projectId);
 
 
-    HttpRespMsg getProjectInAndOut(Integer pageIndex, Integer pageSize, Integer projectId, HttpServletRequest request);
+    HttpRespMsg getProjectInAndOut(Integer pageIndex, Integer pageSize, Integer projectId,Integer projectMainId, HttpServletRequest request);
 
 
-    HttpRespMsg exportProjectInAndOut(HttpServletRequest request);
+    HttpRespMsg exportProjectInAndOut(Integer projectId,Integer projectMainId,HttpServletRequest request);
 
 
     HttpRespMsg importData(String userId, MultipartFile file,Integer key,@RequestParam(defaultValue = "0") Integer changeParticipation, HttpServletRequest request);
     HttpRespMsg importData(String userId, MultipartFile file,Integer key,@RequestParam(defaultValue = "0") Integer changeParticipation, HttpServletRequest request);
 
 

+ 125 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -321,6 +321,131 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return httpRespMsg;
         return httpRespMsg;
     }
     }
 
 
+    @Override
+    public HttpRespMsg exportGeneralExcelByTitleAndListByZheZhong(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        if (title.contains("/")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("/", "@");
+        }
+        if (title.contains("\\")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("\\", "@");
+        }
+        String resp = ExcelUtil.exportGeneralExcelToZheZhong(title, list, downloadPath);
+        String fileUrlSuffix = title + ".xlsx";
+        if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
+            FileSystemResource fileSystemResource = new FileSystemResource(path+fileUrlSuffix);
+//            String md5 = DigestUtils.md5Hex(FileUtil.readBytes(fileSystemResource.getFile()));
+
+            Long checkSize = 20L*1024*1024;
+            if(fileSystemResource.getFile().length() >= checkSize){
+                httpRespMsg.setError("文件过大,请缩短查询日期范围");
+                return httpRespMsg;
+            }
+            String jobId = "";
+            String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+            jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//            if(fileSystemResource.getFile().length() >= checkSize){
+//                String tmpFileJobId = wxCorpInfoService.getTranslationJobId(fileUrlSuffix,md5,wxCorpInfo);
+//                if(!StringUtils.isEmpty(tmpFileJobId)){
+//                    String mediaId = wxCorpInfoService.getAsyncJobResult(tmpFileJobId,wxCorpInfo);
+//                    jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//                }
+//            }else{
+//                String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+//                jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//            }
+
+            System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
+//            if(StringUtils.isEmpty(jobId)){
+//                httpRespMsg.setError("转义jobId为空,请联系管理员");
+//                return httpRespMsg;
+//            }
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 40) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
+                if (corpwxJobResult != null) {
+                    if (corpwxJobResult.getErrCode() == 0) {
+                        syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        corpwxJobCenter.remove(jobId);
+                    } else {
+                        long t2 = System.currentTimeMillis();
+                        System.out.println("222企业微信转译报错:"+corpwxJobResult.getErrMsg()+",耗时:" + (t2 - t) + "ms");
+                        httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                        return httpRespMsg;
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
+            System.out.println("上传待转译文件到钉钉, jobId==" + jobId);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 30) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else {
+            httpRespMsg.data = resp;
+        }
+        return httpRespMsg;
+    }
+
     public HttpRespMsg exportGeneralExcelByTitleAndListNew(String userId,WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
     public HttpRespMsg exportGeneralExcelByTitleAndListNew(String userId,WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         if (title.contains("/")) {
         if (title.contains("/")) {

+ 25 - 17
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -114,19 +114,25 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         boolean isAuditor = functionDeptList.size() > 0;
         boolean isAuditor = functionDeptList.size() > 0;
         boolean isNew = false;
         boolean isNew = false;
         if (sheet.getId() == null) {
         if (sheet.getId() == null) {
-            if (auditSetting == null || auditSetting.getAuditType() == 0) {
-                //默认系统中设置的有审核权限的人审核
-                if (isAuditor) {
-                    sheet.setStatus(0);
-                } else {
+            //柘中公司
+            if (user.getCompanyId()==4811){
+                sheet.setStatus(4);//未填写
+                sheet.setReviewProcess(3);//未提交
+            }else {
+                if (auditSetting == null || auditSetting.getAuditType() == 0) {
+                    //默认系统中设置的有审核权限的人审核
+                    if (isAuditor) {
+                        sheet.setStatus(0);
+                    } else {
+                        sheet.setStatus(1);
+                    }
+                } else if (auditSetting.getAuditType() == 1) {
+                    //项目经理审核,默认为待审核状态
                     sheet.setStatus(1);
                     sheet.setStatus(1);
-                }
-            } else if (auditSetting.getAuditType() == 1) {
-                //项目经理审核,默认为待审核状态
-                sheet.setStatus(1);
-            }else if(auditSetting.getAuditType()==2){
-                if (sheet.getStatus() == null) {
-                    sheet.setStatus(1);//默认提交时为待审核状态
+                } else if (auditSetting.getAuditType() == 2) {
+                    if (sheet.getStatus() == null) {
+                        sheet.setStatus(1);//默认提交时为待审核状态
+                    }
                 }
                 }
             }
             }
 
 
@@ -194,11 +200,13 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     msg.setError("项目【"+p.getProjectName()+"】没有下拨"+settingName+"的预算");
                     msg.setError("项目【"+p.getProjectName()+"】没有下拨"+settingName+"的预算");
                     return msg;
                     return msg;
                 }
                 }
-                //计算该项目当前已经填报的费用报销的金额
-                Double sumAmount = expenseItemMapper.selectSumAmountByProjectAndType(projectId, type);
-                if (amount + sumAmount > pCurCost.getBaseAmount()) {
-                    msg.setError("项目【"+p.getProjectName()+"】的"+settingName+"费用预算不足,无法提交");
-                    return msg;
+                if (user.getCompanyId()!=4811){
+                    //计算该项目当前已经填报的费用报销的金额
+                    Double sumAmount = expenseItemMapper.selectSumAmountByProjectAndType(projectId, type);
+                    if (amount + sumAmount > pCurCost.getBaseAmount()) {
+                        msg.setError("项目【"+p.getProjectName()+"】的"+settingName+"费用预算不足,无法提交");
+                        return msg;
+                    }
                 }
                 }
             }
             }
         }
         }

+ 9 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectMainServiceImpl.java

@@ -106,4 +106,13 @@ public class ProjectMainServiceImpl extends ServiceImpl<ProjectMainMapper, Proje
         httpRespMsg.data=projectMainList;
         httpRespMsg.data=projectMainList;
         return httpRespMsg;
         return httpRespMsg;
     }
     }
+
+    @Override
+    public HttpRespMsg getAllMainProject(HttpServletRequest request) {
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        List<ProjectMain> list = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
+        httpRespMsg.setData(list);
+        return httpRespMsg;
+    }
 }
 }

+ 184 - 80
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -690,7 +690,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
 
     //获取项目列表
     //获取项目列表
     @Override
     @Override
-    public HttpRespMsg getProjectList(Integer forReport, String userId, HttpServletRequest request) {
+    public HttpRespMsg getProjectList(Integer forReport, String userId,Integer projectMainId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
         try {
             System.out.println("userId===="+userId);
             System.out.println("userId===="+userId);
@@ -708,15 +708,26 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     queryWrapper.eq("company_id", user.getCompanyId())
                     queryWrapper.eq("company_id", user.getCompanyId())
                             .eq("status", 1)
                             .eq("status", 1)
                             .orderByDesc("is_public").orderByAsc("id");
                             .orderByDesc("is_public").orderByAsc("id");
+                    if (projectMainId!=null){
+                        queryWrapper.eq("project_main_id",projectMainId);
+                    }
                     httpRespMsg.data = projectMapper.selectList(queryWrapper);
                     httpRespMsg.data = projectMapper.selectList(queryWrapper);
                 }
                 }
             } else {
             } else {
                 if (!sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部项目")) {
                 if (!sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部项目")) {
-                    //只能看本人相关的项目
-                    httpRespMsg.data = projectMapper.getParticipatedProject(user.getId(), user.getCompanyId());
+                    if (projectMainId!=null){
+                        httpRespMsg.data = projectMapper.getParticipatedProjectWithMainProjectId(user.getId(), user.getCompanyId(),projectMainId);
+                    }else {
+                        //只能看本人相关的项目
+                        httpRespMsg.data = projectMapper.getParticipatedProject(user.getId(), user.getCompanyId());
+                    }
                 } else {
                 } else {
-                    //有权限的看全部的
-                    httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()).orderByDesc("is_public").orderByAsc("id"));
+                    if (projectMainId!=null){
+                        httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("project_main_id",projectMainId).eq("company_id", user.getCompanyId()).orderByDesc("is_public").orderByAsc("id"));
+                    }else {
+                        //有权限的看全部的
+                        httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()).orderByDesc("is_public").orderByAsc("id"));
+                    }
                 }
                 }
             }
             }
         } catch (NullPointerException e) {
         } catch (NullPointerException e) {
@@ -1480,6 +1491,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 }
                 }
 
 
                 BeanUtils.copyProperties(project, projectVO);
                 BeanUtils.copyProperties(project, projectVO);
+                System.out.println("==========>主任务id"+project.getProjectMainId()==null?"空":project.getProjectMainId());
+                System.out.println("==========>主任务名称"+project.getProjectMainName()==null?"空":project.getProjectMainName());
                 long dt0 = System.currentTimeMillis();
                 long dt0 = System.currentTimeMillis();
                 Optional<Department> optional = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(projectVO.getDeptId())).findFirst();
                 Optional<Department> optional = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(projectVO.getDeptId())).findFirst();
                 if(optional.isPresent()){
                 if(optional.isPresent()){
@@ -1673,6 +1686,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         Company company = companyMapper.selectById(companyId);
         Company company = companyMapper.selectById(companyId);
         boolean isNew = true;
         boolean isNew = true;
+        if (companyId==4811&&projectMainId==null){
+            httpRespMsg.setError("请选择主项目");
+            return httpRespMsg;
+        }
         //检查负责人要在参与人中
         //检查负责人要在参与人中
         if (!StringUtils.isEmpty(inchargerId)) {
         if (!StringUtils.isEmpty(inchargerId)) {
             if (userIds == null || userIds.length == 0) {
             if (userIds == null || userIds.length == 0) {
@@ -3818,7 +3835,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
     }
 
 
     @Override
     @Override
-    public HttpRespMsg exportProject(HttpServletRequest request) {
+    public HttpRespMsg exportProject(Integer projectId, Integer projectMainId,  HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         //通过公司id获取该公司所有的项目列表
         //通过公司id获取该公司所有的项目列表
         User user = userMapper.selectById(request.getHeader("Token"));
         User user = userMapper.selectById(request.getHeader("Token"));
@@ -3827,6 +3844,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
         CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
         //判断用户的角色,如果是管理员和负责人,查看全部的。如果是普通员工,只能是看到参与的项目
         //判断用户的角色,如果是管理员和负责人,查看全部的。如果是普通员工,只能是看到参与的项目
         QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
         QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
+        if (projectMainId!=null){
+            queryWrapper.eq("project_main_id",projectMainId);
+        }
+        if (projectId!=null){
+            queryWrapper.eq("id",projectId);
+        }
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         List<Project> projectList = projectMapper.selectList(queryWrapper);
         List<Project> projectList = projectMapper.selectList(queryWrapper);
         List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
         List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
@@ -3835,15 +3858,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         //String[] statusNames = {"-","进行中","已完成","已撤销","暂停"};
         //String[] statusNames = {"-","进行中","已完成","已撤销","暂停"};
         String[] statusNames = {"-",MessageUtils.message("excel.onGoing"),MessageUtils.message("excel.complete"),MessageUtils.message("excel.revoke"),MessageUtils.message("excel.pause")};
         String[] statusNames = {"-",MessageUtils.message("excel.onGoing"),MessageUtils.message("excel.complete"),MessageUtils.message("excel.revoke"),MessageUtils.message("excel.pause")};
         List<List<String>> exportList = new ArrayList<>();
         List<List<String>> exportList = new ArrayList<>();
-        //String[] titles = {"项目编号", "项目名称", "负责人", "项目金额(元)", "状态","计划开始时间", "计划结束时间", "完成度"};
-        String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"),
-                MessageUtils.message("excel.charge"), MessageUtils.message("excel.projectAmount")+"(元)", MessageUtils.message("leave.status")
-                ,MessageUtils.message("excel.planStart"), MessageUtils.message("excel.planEnd"),
-                MessageUtils.message("excel.minFillDate"), MessageUtils.message("excel.maxFillDate"),MessageUtils.message("excel.degree")};
-        exportList.add(Lists.list(titles));
+        List<ProjectMain> projectMainList=new ArrayList<>();
+        if (user.getCompanyId()==4811){
+            String[] titles = {MessageUtils.message("entry.projectId"),"主项目", MessageUtils.message("entry.projectName"),
+                    MessageUtils.message("excel.charge"), MessageUtils.message("excel.projectAmount")+"(元)", MessageUtils.message("leave.status")
+                    ,MessageUtils.message("excel.planStart"), MessageUtils.message("excel.planEnd"),
+                    MessageUtils.message("excel.minFillDate"), MessageUtils.message("excel.maxFillDate"),MessageUtils.message("excel.degree")};
+            exportList.add(Lists.list(titles));
+
+            projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
+
+        }else {
+            //String[] titles = {"项目编号", "项目名称", "负责人", "项目金额(元)", "状态","计划开始时间", "计划结束时间", "完成度"};
+            String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"),
+                    MessageUtils.message("excel.charge"), MessageUtils.message("excel.projectAmount")+"(元)", MessageUtils.message("leave.status")
+                    ,MessageUtils.message("excel.planStart"), MessageUtils.message("excel.planEnd"),
+                    MessageUtils.message("excel.minFillDate"), MessageUtils.message("excel.maxFillDate"),MessageUtils.message("excel.degree")};
+            exportList.add(Lists.list(titles));
+        }
         for (Project project : projectList) {
         for (Project project : projectList) {
             List<String> data = new ArrayList<>();
             List<String> data = new ArrayList<>();
             data.add(project.getProjectCode() == null?"":project.getProjectCode());
             data.add(project.getProjectCode() == null?"":project.getProjectCode());
+            if (user.getCompanyId()==4811){
+                Optional<ProjectMain> first = projectMainList.stream().filter(pm -> project.getProjectMainId() != null && pm.getId().equals(project.getProjectMainId())).findFirst();
+                if (first.isPresent()){
+                    data.add(org.apache.commons.lang3.StringUtils.isEmpty(first.get().getName())?"":first.get().getName());
+                }else {
+                    data.add("");
+                }
+            }
             data.add(project.getProjectName() == null?"":project.getProjectName());
             data.add(project.getProjectName() == null?"":project.getProjectName());
             Optional<User> first = userList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
             Optional<User> first = userList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
             if (first.isPresent()) {
             if (first.isPresent()) {
@@ -4309,7 +4352,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
     }
 
 
     @Override
     @Override
-    public HttpRespMsg getProjectInAndOut(Integer pageIndex, Integer pageSize, Integer projectId, HttpServletRequest request) {
+    public HttpRespMsg getProjectInAndOut(Integer pageIndex, Integer pageSize, Integer projectId,Integer projectMainId, HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));
         User user = userMapper.selectById(request.getHeader("Token"));
         Integer companyId = user.getCompanyId();
         Integer companyId = user.getCompanyId();
         List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
         List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
@@ -4333,14 +4376,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
         List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
 
 
         //撤销的项目不算
         //撤销的项目不算
-        QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
+        /*QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
         queryWrapper.and(wrapper->wrapper.isNull("status").or().ne("status", 3));
         queryWrapper.and(wrapper->wrapper.isNull("status").or().ne("status", 3));
         if(inchagerIds!=null){
         if(inchagerIds!=null){
             queryWrapper.in("id",inchagerIds);
             queryWrapper.in("id",inchagerIds);
         }
         }
-        int total = projectMapper.selectCount(queryWrapper);
+        int total = projectMapper.selectCount(queryWrapper);*/
         int pageStart = (pageIndex -1) * pageSize;
         int pageStart = (pageIndex -1) * pageSize;
-        List<Project> projectTask = projectMapper.getProjectInAndOut(companyId, pageStart, pageSize, projectId,inchagerIds);
+        List<Project> projectTask = projectMapper.getProjectInAndOut(companyId, pageStart, pageSize, projectId,inchagerIds,projectMainId);
+        int total = projectMapper.getProjectInAndOutTotal(companyId, projectId,inchagerIds,projectMainId);
         List<Integer> collect = projectTask.stream().map(Project::getId).collect(Collectors.toList());
         List<Integer> collect = projectTask.stream().map(Project::getId).collect(Collectors.toList());
         if (collect.size() > 0) {
         if (collect.size() > 0) {
             List<Map<String, Object>> projectExpenseFee = projectMapper.getProjectExpenseFee(companyId, collect);
             List<Map<String, Object>> projectExpenseFee = projectMapper.getProjectExpenseFee(companyId, collect);
@@ -4381,7 +4425,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
     }
 
 
     @Override
     @Override
-    public HttpRespMsg exportProjectInAndOut(HttpServletRequest request) {
+    public HttpRespMsg exportProjectInAndOut(Integer projectId,Integer projectMainId,HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         //通过公司id获取该公司所有的项目列表
         //通过公司id获取该公司所有的项目列表
         User user = userMapper.selectById(request.getHeader("Token"));
         User user = userMapper.selectById(request.getHeader("Token"));
@@ -4408,7 +4452,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         }
         }
         //获取表头
         //获取表头
         List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
         List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
-        List<Project> projectList = projectMapper.getProjectInAndOut(companyId, null, null, null,inchagerIds);
+        List<Project> projectList=new ArrayList<>();
+        if (user.getCompanyId()==4811){
+            projectList = projectMapper.getProjectInAndOut(companyId, null, null, projectId,inchagerIds,projectMainId);
+        }else {
+            projectList = projectMapper.getProjectInAndOut(companyId, null, null, null,inchagerIds,null);
+        }
         List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
         List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
         if (collect.size() > 0) {
         if (collect.size() > 0) {
             List<Map<String, Object>> projectExpenseFee = projectMapper.getProjectExpenseFee(companyId, collect);
             List<Map<String, Object>> projectExpenseFee = projectMapper.getProjectExpenseFee(companyId, collect);
@@ -4420,80 +4469,135 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         }
         }
 
 
         List<List<String>> exportList = new ArrayList<>();
         List<List<String>> exportList = new ArrayList<>();
-        //String[] titles = {"项目编号", "项目名称", "合同金额", "人工成本", "自定义费用类型"...};
-        String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.contract")};
-        ArrayList<String> strings = Lists.newArrayList(titles);
-        if (company.getPackageContract() == 1) {
-            strings.add("已回款金额");
-        }
-        strings.add(MessageUtils.message("entry.laborCost"));
-        mainTypeList.forEach(m->{
-            strings.add(m.getName());
-        });
-        strings.add(MessageUtils.message("excel.totalExp"));
-        if (company.getPackageContract() == 1) {
-            strings.add("已回款利润");
-            strings.add("已回款利润率");
-        }
-        strings.add(MessageUtils.message("excel.profit"));
-        strings.add(MessageUtils.message("excel.profitMargin"));
-        titles = strings.toArray(new String[0]);
+        if (user.getCompanyId()==4811){
+            String[] titles = {"项目编号","主项目","项目名称","合同金额(元)","总费用","利润","利润率","","人工成本"};
+            ArrayList<String> strings = Lists.newArrayList(titles);
 
 
-        exportList.add(Lists.list(titles));
-        for (Project project : projectList) {
-            List<String> data = new ArrayList<>();
-            data.add(project.getProjectCode());
-            data.add(project.getProjectName());
-            data.add(project.getContractAmount() != null?project.getContractAmount().toString():"");
-            if (company.getPackageContract() == 1) {
-                data.add(project.getPayment() != null?project.getPayment().toString():"");
-            }
-            data.add(project.getFeeMan().toString());
-            for (ExpenseMainType mainType : mainTypeList) {
-                if (project.getProjectExpenseFeeList() != null) {
-                    Optional<Map<String, Object>> first = project.getProjectExpenseFeeList().stream().filter(pef -> pef.get("typeId").equals(mainType.getId())).findFirst();
-                    if (first.isPresent()) {
-                        data.add(first.get().get("amount").toString());
+            mainTypeList.forEach(m->{
+                strings.add(m.getName());
+            });
+            exportList.add(strings);
+
+            for (Project project : projectList) {
+                List<String> data = new ArrayList<>();
+                data.add(project.getProjectCode());
+                data.add(project.getProjectMainName());
+                data.add(project.getProjectName());
+                data.add(project.getContractAmount() != null?project.getContractAmount().toString():"");
+
+                double totalFee = project.getBudget();
+                data.add(new java.text.DecimalFormat("#0.00").format(totalFee));
+                if (project.getContractAmount() != null && project.getContractAmount() > 0) {
+                    double profitAmt = project.getContractAmount() - totalFee;
+                    data.add(profitAmt+"");
+                    data.add(new java.text.DecimalFormat("#0.0").format((100*profitAmt/project.getContractAmount()))+"%");
+                } else {
+                    double profitAmt = 0 -totalFee;
+                    data.add(profitAmt+"");
+                    data.add("");
+                }
+
+                data.add("总费用明细");
+
+                data.add(project.getFeeMan().toString());
+                for (ExpenseMainType mainType : mainTypeList) {
+                    if (project.getProjectExpenseFeeList() != null) {
+                        Optional<Map<String, Object>> first = project.getProjectExpenseFeeList().stream().filter(pef -> pef.get("typeId").equals(mainType.getId())).findFirst();
+                        if (first.isPresent()) {
+                            data.add(first.get().get("amount").toString());
+                        } else {
+                            data.add("");
+                        }
                     } else {
                     } else {
                         data.add("");
                         data.add("");
                     }
                     }
-                } else {
-                    data.add("");
                 }
                 }
+
+                exportList.add(data);
+            }
+            String fileName = MessageUtils.message("fileName.profitSta")+System.currentTimeMillis();
+            try {
+                return excelExportService.exportGeneralExcelByTitleAndListByZheZhong(wxCorpInfo,dingding,fileName, exportList, path);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            httpRespMsg.data =  pathPrefix + fileName+".xlsx";
+        }else {
+            //String[] titles = {"项目编号", "项目名称", "合同金额", "人工成本", "自定义费用类型"...};
+            String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.contract")};
+            ArrayList<String> strings = Lists.newArrayList(titles);
+            if (company.getPackageContract() == 1) {
+                strings.add("已回款金额");
             }
             }
-            double totalFee = project.getBudget();
-            data.add(new java.text.DecimalFormat("#0.00").format(totalFee));
+            strings.add(MessageUtils.message("entry.laborCost"));
+            mainTypeList.forEach(m->{
+                strings.add(m.getName());
+            });
+            strings.add(MessageUtils.message("excel.totalExp"));
             if (company.getPackageContract() == 1) {
             if (company.getPackageContract() == 1) {
-                //已回款利润
-                double profitPayment = project.getPayment().doubleValue() - totalFee;
-                double profitRate = profitPayment / project.getPayment().doubleValue();
-                data.add(new java.text.DecimalFormat("#0.00").format(profitPayment));
-                if (profitRate > 0) {
-                    data.add(new java.text.DecimalFormat("#0.0").format(100*profitRate)+"%");
+                strings.add("已回款利润");
+                strings.add("已回款利润率");
+            }
+            strings.add(MessageUtils.message("excel.profit"));
+            strings.add(MessageUtils.message("excel.profitMargin"));
+            titles = strings.toArray(new String[0]);
+
+            exportList.add(Lists.list(titles));
+            for (Project project : projectList) {
+                List<String> data = new ArrayList<>();
+                data.add(project.getProjectCode());
+                data.add(project.getProjectName());
+                data.add(project.getContractAmount() != null?project.getContractAmount().toString():"");
+                if (company.getPackageContract() == 1) {
+                    data.add(project.getPayment() != null?project.getPayment().toString():"");
+                }
+                data.add(project.getFeeMan().toString());
+                for (ExpenseMainType mainType : mainTypeList) {
+                    if (project.getProjectExpenseFeeList() != null) {
+                        Optional<Map<String, Object>> first = project.getProjectExpenseFeeList().stream().filter(pef -> pef.get("typeId").equals(mainType.getId())).findFirst();
+                        if (first.isPresent()) {
+                            data.add(first.get().get("amount").toString());
+                        } else {
+                            data.add("");
+                        }
+                    } else {
+                        data.add("");
+                    }
+                }
+                double totalFee = project.getBudget();
+                data.add(new java.text.DecimalFormat("#0.00").format(totalFee));
+                if (company.getPackageContract() == 1) {
+                    //已回款利润
+                    double profitPayment = project.getPayment().doubleValue() - totalFee;
+                    double profitRate = profitPayment / project.getPayment().doubleValue();
+                    data.add(new java.text.DecimalFormat("#0.00").format(profitPayment));
+                    if (profitRate > 0) {
+                        data.add(new java.text.DecimalFormat("#0.0").format(100*profitRate)+"%");
+                    } else {
+                        data.add("-");
+                    }
+                }
+
+                if (project.getContractAmount() != null && project.getContractAmount() > 0) {
+                    double profitAmt = project.getContractAmount() - totalFee;
+                    data.add(profitAmt+"");
+                    data.add(new java.text.DecimalFormat("#0.0").format((100*profitAmt/project.getContractAmount()))+"%");
                 } else {
                 } else {
-                    data.add("-");
+                    double profitAmt = 0 -totalFee;
+                    data.add(profitAmt+"");
+                    data.add("");
                 }
                 }
+                exportList.add(data);
             }
             }
-
-            if (project.getContractAmount() != null && project.getContractAmount() > 0) {
-                double profitAmt = project.getContractAmount() - totalFee;
-                data.add(profitAmt+"");
-                data.add(new java.text.DecimalFormat("#0.0").format((100*profitAmt/project.getContractAmount()))+"%");
-            } else {
-                double profitAmt = 0 -totalFee;
-                data.add(profitAmt+"");
-                data.add("");
+            //String fileName = "项目收支平衡报表(利润表)_"+System.currentTimeMillis();
+            String fileName = MessageUtils.message("fileName.profitSta")+System.currentTimeMillis();
+            try {
+                return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,fileName, exportList, path);
+            } catch (Exception e) {
+                e.printStackTrace();
             }
             }
-            exportList.add(data);
+            httpRespMsg.data =  pathPrefix + fileName+".xlsx";
         }
         }
-        //String fileName = "项目收支平衡报表(利润表)_"+System.currentTimeMillis();
-        String fileName = MessageUtils.message("fileName.profitSta")+System.currentTimeMillis();
-        try {
-            return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,fileName, exportList, path);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        httpRespMsg.data =  pathPrefix + fileName+".xlsx";
         return httpRespMsg;
         return httpRespMsg;
     }
     }
 
 

+ 169 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ExcelUtil.java

@@ -2,6 +2,7 @@ package com.management.platform.util;
 
 
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.RegionUtil;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFColor;
 import org.apache.poi.xssf.usermodel.XSSFColor;
@@ -462,6 +463,174 @@ public class ExcelUtil {
 //        return "";
 //        return "";
     }
     }
 
 
+    public static String exportGeneralExcelToZheZhong(String title, List<List<String>> list, String downloadPath) {
+        String result="系统提示:Excel文件导出成功!";
+        String fileName= title+".xlsx";
+        try {
+//            response.reset();
+//            response.setHeader("Content-disposition",
+//                "attachment;filename="+ URLEncoder.encode(fileName, "UTF-8"));
+//            //设置文件头编码格式
+//            response.setContentType("APPLICATION/OCTET-STREAM;charset=UTF-8");//设置类型
+//            response.setHeader("Cache-Control","no-cache");//设置头
+//            response.setDateHeader("Expires", 0);//设置日期头
+            // 创建工作簿, 换成XSSSF 来支持万以上的数据
+            SXSSFWorkbook workBook = new SXSSFWorkbook();
+//            HSSFWorkbook workBook = new HSSFWorkbook();
+            // 创建工作类
+            Sheet sheet = workBook.createSheet();
+            //设置首行冻结
+            sheet.createFreezePane(0, 1);
+            sheet.setDefaultColumnWidth(16);
+            //设置字体样式
+            Font headFont = workBook.createFont();
+            headFont.setBold(true);
+            headFont.setFontHeightInPoints((short) 10);
+            headFont.setFontName("黑体");
+
+            Font titleFont = workBook.createFont();
+            titleFont.setBold(true);
+            titleFont.setFontHeightInPoints((short) 10);
+            titleFont.setFontName("黑体");
+
+            Font font = workBook.createFont();
+            font.setFontHeightInPoints((short) 10);
+            font.setFontName("宋体");
+
+            //设置单元格样式
+            XSSFCellStyle  headStyle = (XSSFCellStyle) workBook.createCellStyle();
+            headStyle.setFont(headFont);
+            headStyle.setAlignment(HorizontalAlignment.CENTER);
+            headStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
+            headStyle.setWrapText(true);
+            headStyle.setBorderBottom(BorderStyle.THIN); //下边框
+            headStyle.setBorderLeft(BorderStyle.THIN);//左边框
+            headStyle.setBorderTop(BorderStyle.THIN);//上边框
+            headStyle.setBorderRight(BorderStyle.THIN);//右边框
+
+            String color = "c0c0c0";    //此处得到的color为16进制的字符串
+            //转为RGB码
+            int r = Integer.parseInt((color.substring(0,2)),16);   //转为16进制
+            int g = Integer.parseInt((color.substring(2,4)),16);
+            int b = Integer.parseInt((color.substring(4,6)),16);
+
+            //自定义cell颜色
+//            HSSFPalette palette = workBook.getCustomPalette();
+            //这里的9是索引
+//            palette.setColorAtIndex((short)9, (byte) r, (byte) g, (byte) b);
+
+            //设置自定义颜色
+            XSSFColor xssfColor = new XSSFColor();
+            byte[] colorRgb = { (short)9, (byte) r, (byte) g, (byte) b };
+            xssfColor.setRGB(colorRgb);
+
+            headStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
+            headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);// 填充模式(和背景颜色成对使用)
+            /*headStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());*/ //设置自带的颜色
+
+            CellStyle titleStyle = workBook.createCellStyle();
+            titleStyle.setFont(titleFont);
+            titleStyle.setAlignment(HorizontalAlignment.CENTER);
+            titleStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
+            titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);  //填充单元格
+            titleStyle.setFillForegroundColor((short)9);    //填色
+            titleStyle.setWrapText(true);
+            titleStyle.setBorderBottom(BorderStyle.THIN); //下边框
+            titleStyle.setBorderLeft(BorderStyle.THIN);//左边框
+            titleStyle.setBorderTop(BorderStyle.THIN);//上边框
+            titleStyle.setBorderRight(BorderStyle.THIN);//右边框
+
+            CellStyle cellStyle = workBook.createCellStyle();
+            cellStyle.setFont(font);
+            cellStyle.setAlignment(HorizontalAlignment.CENTER);
+            cellStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
+            cellStyle.setWrapText(true);
+            cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
+            cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
+            cellStyle.setBorderTop(BorderStyle.THIN);//上边框
+            cellStyle.setBorderRight(BorderStyle.THIN);//右边框
+            DataFormat dataFormat = workBook.createDataFormat();
+            cellStyle.setDataFormat(dataFormat.getFormat("@"));
+
+            if(list.size() > 0) {
+                //标题(如果需要在EXCEL内容最上面加标题,请打开下面的注释,修改start)
+                /*
+                HSSFRow titleRow = sheet.createRow(0);
+                titleRow.setHeightInPoints(30);
+                HSSFCell titleCell = titleRow.createCell(0);
+                titleCell.setCellStyle(headStyle);
+                titleCell.setCellValue(title);
+                //合并单元格
+                CellRangeAddress cellRangeAddress = new CellRangeAddress(0,0,0, list.get(0).size() - 1);
+                //加入合并单元格对象
+                sheet.addMergedRegion(cellRangeAddress);
+                //使用RegionUtil类为合并后的单元格添加边框
+			    RegionUtil.setBorderBottom(BorderStyle.THIN, cellRangeAddress, sheet); // 下边框
+                RegionUtil.setBorderLeft(BorderStyle.THIN, cellRangeAddress, sheet); // 左边框
+                RegionUtil.setBorderRight(BorderStyle.THIN, cellRangeAddress, sheet); // 有边框
+                RegionUtil.setBorderTop(BorderStyle.THIN, cellRangeAddress, sheet); // 上边框
+                */
+                int start = 0;
+                for (int j = 0; j < list.size(); j++) {
+                    List<String> rowList = list.get(j);
+                    Row row = sheet.createRow(start);
+                    row.setHeightInPoints(24);
+                    for(int i = 0; i < rowList.size(); i++) {
+                        Cell cell = row.createCell(i);
+                        if(start == 0) {
+                            cell.setCellStyle(headStyle);
+                        }else {
+                            cell.setCellStyle(cellStyle);
+                        }
+                        cell.setCellValue(rowList.get(i));
+                    }
+                    start++;
+                }
+                //合并单元格
+                CellRangeAddress cellRangeAddress = new CellRangeAddress(1,list.size()-1,7, 7);
+                //加入合并单元格对象
+                sheet.addMergedRegion(cellRangeAddress);
+
+//                for(List<String> rowList : list) {
+//                    Row row = sheet.createRow(start);
+//                    row.setHeightInPoints(24);
+//
+//                    for(int i = 0; i < rowList.size(); i++) {
+//                        Cell cell = row.createCell(i);
+//                        if(start == 0) {
+//                            cell.setCellStyle(headStyle);
+//                        }else {
+//                            cell.setCellStyle(cellStyle);
+//                        }
+//                        cell.setCellValue(rowList.get(i));
+//                    }
+//                    start++;
+//                }
+            }
+            //用于非传统ajax;
+//            String headStr = "attachment; filename=\"" + fileName + "\"";
+//            response.setContentType("APPLICATION/OCTET-STREAM");//返回格式为流
+//            response.setHeader("Content-Disposition", headStr);
+//            //普通下载不需要以上三行,注掉即可
+//            OutputStream os = response.getOutputStream();//在线下载
+            File dir = null;
+            dir = new File(downloadPath);
+            // D://cloud/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            FileOutputStream os = new FileOutputStream(downloadPath+fileName);//保存到本地
+            workBook.write(os);
+            os.flush();
+            os.close();
+        }catch(Exception e) {
+            System.out.println(result);
+            e.printStackTrace();
+        }
+        return "/upload/"+fileName;
+//        return "";
+    }
+
 
 
 
 
     public static String exportGeneralExcelByTitleAndList2(String title, List<List<String>> list, String downloadPath) {
     public static String exportGeneralExcelByTitleAndList2(String title, List<List<String>> list, String downloadPath) {

+ 37 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -639,15 +639,19 @@
     </select>
     </select>
     <!--分页获取项目收支平衡 -->
     <!--分页获取项目收支平衡 -->
     <select id="getProjectInAndOut" resultMap="BaseResultMap">
     <select id="getProjectInAndOut" resultMap="BaseResultMap">
-        SELECT project.id, project_code, project_name,contract_amount, IFNULL(contract.payment, 0) as payment,
+        SELECT project.id, project_code, project_name,contract_amount, IFNULL(contract.payment, 0) as payment,project_main.name  as project_main_name,
         (SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id) AS fee_man
         (SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id) AS fee_man
         FROM project
         FROM project
         left join contract on contract.project_id = project.id
         left join contract on contract.project_id = project.id
+        left join project_main on project_main.id = project.project_main_id
         WHERE project.`company_id` = #{companyId}
         WHERE project.`company_id` = #{companyId}
         and (project.status &lt;&gt; 3 or project.status is null)
         and (project.status &lt;&gt; 3 or project.status is null)
         <if test="projectId != null">
         <if test="projectId != null">
             and project.id = #{projectId}
             and project.id = #{projectId}
         </if>
         </if>
+        <if test="projectMainId != null">
+            and project.project_main_id = #{projectMainId}
+        </if>
         <if test="inchagerIds!=null and inchagerIds.size()>0">
         <if test="inchagerIds!=null and inchagerIds.size()>0">
             and project.id in
             and project.id in
             <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
             <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
@@ -2671,5 +2675,37 @@
         </if>
         </if>
             ) a
             ) a
     </select>
     </select>
+    <select id="getParticipatedProjectWithMainProjectId" resultType="java.util.Map">
+        SELECT id, project_code AS projectCode, project_name AS projectName, status, task_gp_incharge as taskGpIncharge, project_desc as projectDesc,is_public as isPublic, plan_end_date as planEndDate
+        FROM project
+        WHERE id IN (
+            SELECT project_id
+            FROM participation
+            WHERE user_id = #{userId}
+        ) or incharger_id = #{userId}
+           or creator_id = #{userId}
+           or (is_public = 1 and company_id = #{companyId})
+           and project_main_id = #{projectMainId}
+        ORDER BY is_public DESC, id DESC
+    </select>
+    <select id="getProjectInAndOutTotal" resultType="java.lang.Integer">
+        SELECT count(*) total
+        FROM project
+        left join contract on contract.project_id = project.id
+        WHERE project.`company_id` = #{companyId}
+        and (project.status &lt;&gt; 3 or project.status is null)
+        <if test="projectId != null">
+            and project.id = #{projectId}
+        </if>
+        <if test="projectMainId != null">
+            and project.project_main_id = #{projectMainId}
+        </if>
+        <if test="inchagerIds!=null and inchagerIds.size()>0">
+            and project.id in
+            <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 
 
 </mapper>
 </mapper>

+ 2 - 0
fhKeeper/formulahousekeeper/timesheet/index.html

@@ -13,6 +13,8 @@
     <script src="https://auth.dingtalk.com/opendata-1.1.0.js"></script>
     <script src="https://auth.dingtalk.com/opendata-1.1.0.js"></script>
     <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
     <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
     <link href="./static/css/public.css" rel="stylesheet" type="text/css" />
     <link href="./static/css/public.css" rel="stylesheet" type="text/css" />
+    <!-- <script async defer src="http://47.101.180.183:9999/api/application/embed?protocol=http&host=47.101.180.183:9999&token=56c5bbad807f9a14"></script> -->
+    <script async defer src="https://chatai.ttkuaiban.com/api/application/embed?protocol=https&host=chatai.ttkuaiban.com&token=56c5bbad807f9a14"></script>
     <!-- 引入样式 -->
     <!-- 引入样式 -->
     <!-- <link
     <!-- <link
       href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css"
       href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css"