Ver código fonte

2022/7/12 公司级报表年度级别

guoxu 2 anos atrás
pai
commit
9ff760920f

+ 27 - 0
src/main/java/com/jeeplus/modules/statement/dao/StatementCompanyComprehensiveDao.java

@@ -319,11 +319,22 @@ public interface StatementCompanyComprehensiveDao  extends CrudDao<StatementComp
     void insertStatementDataInfo(@Param("dataList")List<StatementDataInfo> statementDataInfoList);
 
     /**
+     * 超期,未超期数据存储 年度级
+     */
+    void insertStatementDataInfoByYear(@Param("dataList")List<StatementDataInfo> statementDataInfoList);
+    /**
      * 超期、未超期数据删除
      * @param statementDataInfoList
      */
     void deleteStatementDataInfo(StatementDataInfo statementDataInfoList);
 
+
+    /**
+     * 超期、未超期数据删除
+     * @param statementDataInfoList
+     */
+    void deleteStatementDataInfoByYear(StatementDataInfo statementDataInfoList);
+
     /**
      * 查询公司级需要通知的人员信息
      * @return
@@ -550,6 +561,13 @@ public interface StatementCompanyComprehensiveDao  extends CrudDao<StatementComp
 
 
     /**
+     * 按照类型查询公司级所有报表信息 年度
+     * @param statementCompanyComprehensiveInfo
+     * @return
+     */
+    List<StatementCompanyComprehensiveInfo> selectAllByTypeByYear(StatementCompanyComprehensiveInfo statementCompanyComprehensiveInfo);
+
+    /**
      * 根据类型查询公司及所有报表信息 已年级
      * @param statementCompanyComprehensiveInfo
      * @return
@@ -699,4 +717,13 @@ public interface StatementCompanyComprehensiveDao  extends CrudDao<StatementComp
      * 从statement_company_comprehensive_info中获取当前月份的数据
      */
     List<StatementCompanyComprehensiveInfo> getMonthData(@Param("type")String type,@Param("smallDateType") Integer smallDateType);
+
+
+    /**
+     * 删除 年度级
+     */
+
+    public int deleteByYear(StatementCompanyComprehensiveInfo statementCompanyComprehensiveInfo);
+
+    public void insertByYear(StatementCompanyComprehensiveInfo statementCompanyComprehensiveInfo);
 }

+ 511 - 46
src/main/java/com/jeeplus/modules/statement/service/StatementCompanyComprehensiveService.java

@@ -174,7 +174,7 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         //公司级:项目报表总览 年度级
         //type:类型(1:项目;2:开票;3:报销;4:合同)
         statementCompanyComprehensiveInfo.setType("1");
-        List<StatementCompanyComprehensiveInfo> reportFormList5 = this.selectAllByTypeInYearReport(statementCompanyComprehensiveInfo);
+        List<StatementCompanyComprehensiveInfo> reportFormList5 = this.selectAllByTypeInYearReportByYear(statementCompanyComprehensiveInfo);
         //项目表 各列合计
         String xmnumyear1 = "0";
         String xmnumyear2 = "0";
@@ -211,7 +211,7 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         //公司级:开票报表开始
         //类型(1:项目;2:开票;3:报销;4:合同)
         statementCompanyComprehensiveInfo.setType("2");
-        List<StatementCompanyComprehensiveInfo> reportFormList6 = this.selectAllByTypeInYearReport(statementCompanyComprehensiveInfo);
+        List<StatementCompanyComprehensiveInfo> reportFormList6 = this.selectAllByTypeInYearReportByYear(statementCompanyComprehensiveInfo);
         //各列合计
         String kpyearnum1 = "0";
         String kpyearnum2 = "0";
@@ -236,7 +236,7 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
     //公司级:报销报表
         //类型(1:项目;2:开票;3:报销;4:合同)
         statementCompanyComprehensiveInfo.setType("3");
-        List<StatementCompanyComprehensiveInfo> reportFormList7 = this.selectAllByTypeInYearReport(statementCompanyComprehensiveInfo);
+        List<StatementCompanyComprehensiveInfo> reportFormList7 = this.selectAllByTypeInYearReportByYear(statementCompanyComprehensiveInfo);
         //合计
         String bxyearnum1 = "0";
         String bxyearnum2 = "0";
@@ -255,7 +255,7 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         //公司级:合同报表
         //类型(1:项目;2:开票;3:报销;4:合同)
         statementCompanyComprehensiveInfo.setType("4");
-        List<StatementCompanyComprehensiveInfo> reportFormList8= this.selectAllByTypeInYearReport(statementCompanyComprehensiveInfo);
+        List<StatementCompanyComprehensiveInfo> reportFormList8= this.selectAllByTypeInYearReportByYear(statementCompanyComprehensiveInfo);
         //合计
         String htyearnum1 = "0";
         String htyearnum2 = "0";
@@ -344,47 +344,15 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
     }
 
 
-
     /**
-     * 公司级年度信息处理
+     * 公司集信息处理 年度用
      */
-    public void disposeStatementCompanyByyear(Integer year,Integer bigDateType,Integer smallDateType){
+    public void disposeStatementCompanyByYear(Integer year,Integer bigDateType,Integer smallDateType){
         Calendar cal = Calendar.getInstance();
         //获取当前年份
         if(null == year){
             year = cal.get(Calendar.YEAR);
         }
-        int month = cal.get(Calendar.MONTH)+1;
-        List<StatementCompanyComprehensiveInfo> statementCompanyComprehensiveInfos = new ArrayList<StatementCompanyComprehensiveInfo>();
-        String xmnum1 = "0";
-        String xmnum2 = "0";
-        String xmnum3 = "0";
-        String xmnum4 = "0";
-//        获取项目月报的信息,将每个月的新增A类,B类、本月电子归档、本月上报进行增加 1为项目报告
-        for(int i =1;i<=month;i++){
-            statementCompanyComprehensiveInfos = dao.getMonthData("1",i);
-            //       从 statement_company_comprehensive_info中获取之前月份的信息,进行增加后保存到statement_company_comprehensive_info2中
-//          for(StatementCompanyComprehensiveInfo info:statementCompanyComprehensiveInfos){
-//              xmnum1 = new BigDecimal(info.getField1()).add(new BigDecimal(xmnum1)).toString();
-//              xmnum2 = new BigDecimal(info.getField2()).add(new BigDecimal(xmnum2)).toString();
-//              xmnum3 = new BigDecimal(info.getField3()).add(new BigDecimal(xmnum3)).toString();
-//              xmnum4 = new BigDecimal(info.getField4()).add(new BigDecimal(xmnum4)).toString();
-//          }
-            for(int j=0;j<statementCompanyComprehensiveInfos.size();j++){
-                xmnum1 = new BigDecimal(statementCompanyComprehensiveInfos.get(i).getField1()).add(new BigDecimal(xmnum1)).toString();
-                statementCompanyComprehensiveInfos.get(i).setField1(xmnum1);
-                xmnum2 = new BigDecimal(statementCompanyComprehensiveInfos.get(i).getField2()).add(new BigDecimal(xmnum2)).toString();
-                statementCompanyComprehensiveInfos.get(i).setField1(xmnum2);
-                xmnum3 = new BigDecimal(statementCompanyComprehensiveInfos.get(i).getField3()).add(new BigDecimal(xmnum3)).toString();
-                statementCompanyComprehensiveInfos.get(i).setField1(xmnum3);
-                xmnum4 = new BigDecimal(statementCompanyComprehensiveInfos.get(i).getField4()).add(new BigDecimal(xmnum4)).toString();
-                statementCompanyComprehensiveInfos.get(i).setField4(xmnum4);
-            }
-//          statementCompanyComprehensiveInfos
-//          dao.insertToStatementCompanyComprehensiveInfo(statementCompanyComprehensiveInfos);
-        }
-
-
 
         Map<String, String> dateMap = getDateNew(bigDateType, smallDateType, year);
         //开始时间
@@ -393,15 +361,15 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         String endDate = dateMap.get("endDate");
         String statementDate = dateMap.get("statementDate");
         //公司级项目处理
-        disposeStatementCompanyProject(year,beginDate,endDate,statementDate,bigDateType, smallDateType);
+        disposeStatementCompanyProjectByYear(year,beginDate,endDate,statementDate,bigDateType, smallDateType);
         //查询部门信息
         List<Office> officeList = dao.getAllOfficeListInfo();
         //公司级开票处理
-        disposeStatementCompanyInvoice(year,beginDate,endDate,statementDate,bigDateType, smallDateType,officeList);
+        disposeStatementCompanyInvoiceByYear(year,beginDate,endDate,statementDate,bigDateType, smallDateType,officeList);
         //公司级报销处理
-        disposeStatementCompanyReimbursement(year,beginDate,endDate,statementDate,bigDateType, smallDateType,officeList);
+        disposeStatementCompanyReimbursementByYear(year,beginDate,endDate,statementDate,bigDateType, smallDateType,officeList);
         //公司级合同处理
-        disposeStatementCompanyContract(year,beginDate,endDate,statementDate,bigDateType, smallDateType,officeList);
+        disposeStatementCompanyContractByYear(year,beginDate,endDate,statementDate,bigDateType, smallDateType,officeList);
 
         //创建utilNotifyId参数
         //参数是由 year、bigDateType、smallDateType参数设定
@@ -425,6 +393,7 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         }
     }
 
+
     /**
      * 公司级通知
      * @param statementDate
@@ -512,6 +481,7 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
 
         //查询新增A类项目数量
         List<ReportDataEntity> projectCountByAAll = dao.getInsertProjectCountByGradeAll( "2", beginDate, endDate);
+//        查询新增B类项目数量
         List<ReportDataEntity> projectCountByBAll = dao.getInsertProjectCountByGradeAll( "1", beginDate, endDate);
         List<ReportDataEntity> getProjectCountByRecordAll = dao.getProjectCountByRecordAll(beginDate, endDate);
         List<ReportDataEntity> getProjectCountByReportedAll = dao.getProjectCountByReportedAll(beginDate, endDate);
@@ -525,17 +495,18 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         List<ReportDataEntity> overDueReportedProjectIdListAll = dao.getOverDueReportedProjectAll(beginDate, endDate);
         //查询电子归档超期未归档项目数量(分组)
         Map<String, List<ReportDataEntity>> overDueNotRecordProjectIdListAllMap = dataMessageDispose(overDueNotRecordProjectIdListAll);
-        //分组
+        //分组 超期归档做分组 key 为OfficeParentIds,OfficeId  value 当前对象 field为项目id
         Map<String, List<ReportDataEntity>> overDueRecordProjectIdListAllMap = dataMessageDispose(overDueRecordProjectIdListAll);
-        //分组
+        //分组 超期未上报 同上
         Map<String, List<ReportDataEntity>> overDueNotReportedProjectIdListAllMap = dataMessageDispose(overDueNotReportedProjectIdListAll);
-        //分组
+        //分组 超期上报 同上
         Map<String, List<ReportDataEntity>> overDueReportedProjectIdListAllMap = dataMessageDispose(overDueReportedProjectIdListAll);
 
         //查询部门信息
         List<Office> officeList = dao.getOfficeListInfo();
         for (Office officeInfo : officeList) {
             StatementCompanyComprehensiveInfo comprehensiveInfo = new StatementCompanyComprehensiveInfo();
+//            代表项目
             comprehensiveInfo.setType("1");
             comprehensiveInfo.setYear(String.valueOf(year));
             comprehensiveInfo.setBigDateType(bigDateType.toString());
@@ -722,6 +693,233 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         }
     }
 
+
+    /**
+     * 年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     * @param statementDate 报表时间
+     * @param bigDateType 状态1(0:年;1:季度;2:月份)
+     * @param smallDateType 状态2(针对状态1进行精确所在指定季度或者月份)
+     */
+    @Transactional(readOnly = false)
+    public void disposeStatementCompanyProjectByYear(Integer year,String beginDate,String endDate,String statementDate,Integer bigDateType,Integer smallDateType){
+
+
+        //查询新增A类项目数量
+        List<ReportDataEntity> projectCountByAAll = dao.getInsertProjectCountByGradeAll( "2", beginDate, endDate);
+//        查询新增B类项目数量
+        List<ReportDataEntity> projectCountByBAll = dao.getInsertProjectCountByGradeAll( "1", beginDate, endDate);
+        List<ReportDataEntity> getProjectCountByRecordAll = dao.getProjectCountByRecordAll(beginDate, endDate);
+        List<ReportDataEntity> getProjectCountByReportedAll = dao.getProjectCountByReportedAll(beginDate, endDate);
+        //超期未归档
+        List<ReportDataEntity> overDueNotRecordProjectIdListAll = dao.getOverDueNotRecordProjectAll();
+        //超期归档
+        List<ReportDataEntity> overDueRecordProjectIdListAll = dao.getOverDueRecordProjectAll(beginDate, endDate);
+        //超期未上报
+        List<ReportDataEntity> overDueNotReportedProjectIdListAll = dao.getOverDueNotReportedProjectAll();
+        //超期上报
+        List<ReportDataEntity> overDueReportedProjectIdListAll = dao.getOverDueReportedProjectAll(beginDate, endDate);
+        //查询电子归档超期未归档项目数量(分组)
+        Map<String, List<ReportDataEntity>> overDueNotRecordProjectIdListAllMap = dataMessageDispose(overDueNotRecordProjectIdListAll);
+        //分组 超期归档做分组 key 为OfficeParentIds,OfficeId  value 当前对象 field为项目id
+        Map<String, List<ReportDataEntity>> overDueRecordProjectIdListAllMap = dataMessageDispose(overDueRecordProjectIdListAll);
+        //分组 超期未上报 同上
+        Map<String, List<ReportDataEntity>> overDueNotReportedProjectIdListAllMap = dataMessageDispose(overDueNotReportedProjectIdListAll);
+        //分组 超期上报 同上
+        Map<String, List<ReportDataEntity>> overDueReportedProjectIdListAllMap = dataMessageDispose(overDueReportedProjectIdListAll);
+
+        //查询部门信息
+        List<Office> officeList = dao.getOfficeListInfo();
+        for (Office officeInfo : officeList) {
+            StatementCompanyComprehensiveInfo comprehensiveInfo = new StatementCompanyComprehensiveInfo();
+//            代表项目
+            comprehensiveInfo.setType("1");
+            comprehensiveInfo.setYear(String.valueOf(year));
+            comprehensiveInfo.setBigDateType(bigDateType.toString());
+            comprehensiveInfo.setSmallDateType(smallDateType.toString());
+            comprehensiveInfo.setStatementDate(statementDate);
+            comprehensiveInfo.setOfficeId(officeInfo.getId());
+            //查询新增A类项目数量
+            /*Integer projectCountByA = dao.getInsertProjectCountByGrade(officeInfo.getId(), "2", beginDate, endDate);
+            comprehensiveInfo.setField1(projectCountByA.toString());*/
+            //遍历添加新增A类项目数量
+            for (ReportDataEntity reportData: projectCountByAAll) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField1(String.valueOf(Integer.parseInt(comprehensiveInfo.getField1()) + reportData.getCount()));
+                }
+            }
+            //查询新增B类项目数量
+            /*Integer projectCountByB = dao.getInsertProjectCountByGrade(officeInfo.getId(), "1", beginDate, endDate);
+            comprehensiveInfo.setField2(projectCountByB.toString());*/
+            for (ReportDataEntity reportData: projectCountByBAll) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField2(String.valueOf(Integer.parseInt(comprehensiveInfo.getField2()) + reportData.getCount()));
+                }
+            }
+            //查询本月电子归档项目数量
+            /*Integer getProjectCountByRecord = dao.getProjectCountByRecord(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField3(getProjectCountByRecord.toString());*/
+            for (ReportDataEntity reportData: getProjectCountByRecordAll) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField3(String.valueOf(Integer.parseInt(comprehensiveInfo.getField3()) + reportData.getCount()));
+                }
+            }
+            //查询本月上报项目数量
+            /*Integer getProjectCountByReported = dao.getProjectCountByReported(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField4(getProjectCountByReported.toString());*/
+            for (ReportDataEntity reportData: getProjectCountByReportedAll) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField4(String.valueOf(Integer.parseInt(comprehensiveInfo.getField4()) + reportData.getCount()));
+                }
+            }
+            //查询电子归档超期未归档项目数量(保存到数据库)
+            //List<String> overDueNotRecordProjectIdList = dao.getOverDueNotRecordProject(officeInfo.getId());
+            List<ReportDataEntity> overDueNotRecordProjectListAll = Lists.newArrayList();
+            for (String key : overDueNotRecordProjectIdListAllMap.keySet()) {
+                if(officeInfo.getId().equals(key) || key.contains(officeInfo.getId())){
+                    List<ReportDataEntity> reportDataEntities = overDueNotRecordProjectIdListAllMap.get(key);
+                    overDueNotRecordProjectListAll.addAll(reportDataEntities);
+                    comprehensiveInfo.setField5(String.valueOf(Integer.parseInt(comprehensiveInfo.getField5()) + reportDataEntities.size()));
+                }
+
+            }
+
+
+            List<StatementDataInfo> overDueNotRecordProjectList = Lists.newArrayList();
+            for (ReportDataEntity peportDataEntity : overDueNotRecordProjectListAll) {
+                String projectId = peportDataEntity.getFieldId();
+                StatementDataInfo info = new StatementDataInfo();
+                info.setStatementDate(statementDate);
+                info.setGradeType("1");
+                info.setType("1");
+                info.setYear(String.valueOf(year));
+                info.setBigDateType(bigDateType.toString());
+                info.setSmallDateType(smallDateType.toString());
+                info.setOfficeId(officeInfo.getId());
+                info.setField1(projectId);
+                overDueNotRecordProjectList.add(info);
+            }
+            if(overDueNotRecordProjectList.size()>0){
+                //每次删除之前存的数据
+                for (StatementDataInfo statementDataInfo: overDueNotRecordProjectList) {
+                    dao.deleteStatementDataInfoByYear(statementDataInfo);
+                }
+                dao.insertStatementDataInfoByYear(overDueNotRecordProjectList);
+            }
+
+
+            //查询电子归档超期归档项目数量(保存到数据库)
+            //List<String> overDueRecordProjectIdList = dao.getOverDueRecordProject(officeInfo.getId(), beginDate, endDate);
+            List<ReportDataEntity> overDueRecordProjectListAll = Lists.newArrayList();
+            for (String key : overDueRecordProjectIdListAllMap.keySet()) {
+                if(officeInfo.getId().equals(key) || key.contains(officeInfo.getId())){
+                    List<ReportDataEntity> reportDataEntities = overDueRecordProjectIdListAllMap.get(key);
+                    overDueRecordProjectListAll.addAll(reportDataEntities);
+                    comprehensiveInfo.setField6(String.valueOf(Integer.parseInt(comprehensiveInfo.getField6()) + reportDataEntities.size()));
+                }
+
+            }
+
+            //comprehensiveInfo.setField6(String.valueOf(overDueRecordProjectIdList.size()));
+            List<StatementDataInfo> overDueRecordProjectList = Lists.newArrayList();
+            for (ReportDataEntity peportDataEntity : overDueRecordProjectListAll) {
+                String projectId = peportDataEntity.getFieldId();
+                StatementDataInfo info = new StatementDataInfo();
+                info.setStatementDate(statementDate);
+                info.setGradeType("1");
+                info.setType("1");
+                info.setYear(String.valueOf(year));
+                info.setBigDateType(bigDateType.toString());
+                info.setSmallDateType(smallDateType.toString());
+                info.setOfficeId(officeInfo.getId());
+                info.setField2(projectId);
+                overDueRecordProjectList.add(info);
+            }
+            if(overDueRecordProjectList.size()>0){
+                //每次删除之前存的数据
+                for (StatementDataInfo statementDataInfo: overDueRecordProjectList) {
+                    dao.deleteStatementDataInfoByYear(statementDataInfo);
+                }
+                dao.insertStatementDataInfoByYear(overDueRecordProjectList);
+            }
+            //查询上报超期未上报项目数量(保存到数据库)
+            //List<String> overDueNotReportedProjectIdList = dao.getOverDueNotReportedProject(officeInfo.getId());
+            List<ReportDataEntity> overDueNotReportedProjectListAll = Lists.newArrayList();
+            for (String key : overDueNotReportedProjectIdListAllMap.keySet()) {
+                if(officeInfo.getId().equals(key) || key.contains(officeInfo.getId())){
+                    List<ReportDataEntity> reportDataEntities = overDueNotReportedProjectIdListAllMap.get(key);
+                    overDueNotReportedProjectListAll.addAll(reportDataEntities);
+                    comprehensiveInfo.setField7(String.valueOf(Integer.parseInt(comprehensiveInfo.getField7()) + reportDataEntities.size()));
+                }
+
+            }
+
+            //comprehensiveInfo.setField7(String.valueOf(overDueNotReportedProjectIdListAll.size()));
+            List<StatementDataInfo> overDueNotReportedProjectList = Lists.newArrayList();
+            for (ReportDataEntity peportDataEntity : overDueNotReportedProjectListAll) {
+                String projectId = peportDataEntity.getFieldId();
+                StatementDataInfo info = new StatementDataInfo();
+                info.setStatementDate(statementDate);
+                info.setGradeType("1");
+                info.setType("1");
+                info.setYear(String.valueOf(year));
+                info.setBigDateType(bigDateType.toString());
+                info.setSmallDateType(smallDateType.toString());
+                info.setOfficeId(officeInfo.getId());
+                info.setField3(projectId);
+                overDueNotReportedProjectList.add(info);
+            }
+            if(overDueNotReportedProjectList.size()>0){
+                //每次删除之前存的数据
+                for (StatementDataInfo statementDataInfo: overDueNotReportedProjectList) {
+                    dao.deleteStatementDataInfoByYear(statementDataInfo);
+                }
+                dao.insertStatementDataInfoByYear(overDueNotReportedProjectList);
+            }
+            //查询上报超期上报项目数量(保存到数据库)
+            //List<String> overDueReportedProjectIdList = dao.getOverDueReportedProject(officeInfo.getId(), beginDate, endDate);
+            List<ReportDataEntity> overDueReportedProjectListAll = Lists.newArrayList();
+            for (String key : overDueReportedProjectIdListAllMap.keySet()) {
+                if(officeInfo.getId().equals(key) || key.contains(officeInfo.getId())){
+                    List<ReportDataEntity> reportDataEntities = overDueReportedProjectIdListAllMap.get(key);
+                    overDueReportedProjectListAll.addAll(reportDataEntities);
+                    comprehensiveInfo.setField8(String.valueOf(Integer.parseInt(comprehensiveInfo.getField8()) + reportDataEntities.size()));
+                }
+
+            }
+
+            //comprehensiveInfo.setField8(String.valueOf(overDueReportedProjectIdList.size()));
+            List<StatementDataInfo> overDueReportedProjectList = Lists.newArrayList();
+            for (ReportDataEntity peportDataEntity : overDueReportedProjectListAll) {
+                String projectId = peportDataEntity.getFieldId();
+                StatementDataInfo info = new StatementDataInfo();
+                info.setStatementDate(statementDate);
+                info.setGradeType("1");
+                info.setType("1");
+                info.setYear(String.valueOf(year));
+                info.setBigDateType(bigDateType.toString());
+                info.setSmallDateType(smallDateType.toString());
+                info.setOfficeId(officeInfo.getId());
+                info.setField4(projectId);
+                overDueReportedProjectList.add(info);
+            }
+            if(overDueReportedProjectList.size()>0){
+                //每次删除之前存的数据
+                for (StatementDataInfo statementDataInfo: overDueReportedProjectList) {
+                    dao.deleteStatementDataInfoByYear(statementDataInfo);
+                }
+                dao.insertStatementDataInfoByYear(overDueReportedProjectList);
+            }
+
+            //数据处理并保存到数据库中
+            comprehensiveInfo.preInsert();
+            //每次都要删除之前的数据
+            dao.deleteByYear(comprehensiveInfo);
+            dao.insertByYear(comprehensiveInfo);
+        }
+    }
+
     /**
      * 公司级数据分组
      * @param dataList
@@ -869,8 +1067,90 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         }
     }
 
+
     /**
-     * 公司级报销记录月报/季报/年报汇总方法
+     * 公司级开票记录月报/季报/年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     * @param statementDate 报表时间
+     * @param bigDateType 状态1(0:年;1:季度;2:月份)
+     * @param smallDateType 状态2(针对状态1进行精确所在指定季度或者月份)
+     * @param officeList 部门信息
+     */
+    @Transactional(readOnly = false)
+    public void disposeStatementCompanyInvoiceByYear(Integer year,String beginDate,String endDate,String statementDate,Integer bigDateType,Integer smallDateType,List<Office> officeList){
+        //查询新增发票信息
+        List<ReportDataEntity> field1All = dao.getInsertInvoiceCountByOfficeAll(beginDate, endDate);
+        //查询开票金额总额
+        List<ReportDataEntity> field2All = dao.getInsertInvoiceSumMoneyByOfficeAll(beginDate, endDate);
+        //查询本月收款发票
+        List<ReportDataEntity> field3All = dao.getInsertInvoiceDetailsCountByOfficeAll(beginDate, endDate);
+        //查询本月收款
+        List<ReportDataEntity> field4All = dao.getInsertInvoiceDetailsSumMoneyByOfficeAll(beginDate, endDate);
+
+        for (Office officeInfo : officeList) {
+            StatementCompanyComprehensiveInfo comprehensiveInfo = new StatementCompanyComprehensiveInfo();
+            comprehensiveInfo.setType("2");
+            comprehensiveInfo.setYear(String.valueOf(year));
+            comprehensiveInfo.setBigDateType(bigDateType.toString());
+            comprehensiveInfo.setSmallDateType(smallDateType.toString());
+            comprehensiveInfo.setStatementDate(statementDate);
+            comprehensiveInfo.setOfficeId(officeInfo.getId());
+
+            //查询新增发票信息
+            /*Integer field1 = dao.getInsertInvoiceCountByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField1(field1.toString());*/
+            for (ReportDataEntity reportData: field1All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField1(String.valueOf(Integer.parseInt(comprehensiveInfo.getField1()) + reportData.getCount()));
+                }
+            }
+            //查询开票金额总额
+            /*String field2 = dao.getInsertInvoiceSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField2(field2);*/
+            for (ReportDataEntity reportData: field2All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField2(String.valueOf(new BigDecimal(comprehensiveInfo.getField2()).add(new BigDecimal(reportData.getVariableElement()))));
+                }
+            }
+            //查询本月收款发票
+            /*Integer field3 = dao.getInsertInvoiceDetailsCountByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField3(field3.toString());*/
+            for (ReportDataEntity reportData: field3All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField3(String.valueOf(Integer.parseInt(comprehensiveInfo.getField3()) + reportData.getCount()));
+                }
+            }
+            //查询本月收款
+            /*String field4 = dao.getInsertInvoiceDetailsSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField4(field4);*/
+            for (ReportDataEntity reportData: field4All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField4(String.valueOf(new BigDecimal(comprehensiveInfo.getField4()).add(new BigDecimal(reportData.getVariableElement()))));
+                }
+            }
+            //对金额数据进行处理和四舍五入
+            if(StringUtils.isNotBlank(comprehensiveInfo.getField2())){
+                BigDecimal b = new BigDecimal(comprehensiveInfo.getField2());
+                comprehensiveInfo.setField2(String.valueOf(b.setScale(2, BigDecimal.ROUND_HALF_UP)));
+            }
+            if(StringUtils.isNotBlank(comprehensiveInfo.getField4())){
+                BigDecimal b = new BigDecimal(comprehensiveInfo.getField4());
+                comprehensiveInfo.setField4(String.valueOf(b.setScale(2, BigDecimal.ROUND_HALF_UP)));
+            }
+
+
+            //数据处理并保存到数据库中
+            comprehensiveInfo.preInsert();
+            //每次都要删除之前的数据
+            dao.deleteByYear(comprehensiveInfo);
+            dao.insertByYear(comprehensiveInfo);
+
+        }
+    }
+
+    /**
+     * 年报汇总方法
      * @param beginDate 开始时间
      * @param endDate 结束时间
      */
@@ -920,6 +1200,58 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         }
     }
 
+
+    /**
+     * 公司级年度报销
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     */
+    @Transactional(readOnly = false)
+    public void disposeStatementCompanyReimbursementByYear(Integer year,String beginDate,String endDate,String statementDate,Integer bigDateType,Integer smallDateType,List<Office> officeList){
+
+        //查询新增报销信息
+        List<ReportDataEntity> field1All = dao.getInsertReimbursementCountByOfficeAll(beginDate, endDate);
+        //查询报销金额总额
+        List<ReportDataEntity> field2All = dao.getInsertReimbursementSumMoneyByOfficeAll(beginDate, endDate);
+
+        for (Office officeInfo : officeList) {
+            StatementCompanyComprehensiveInfo comprehensiveInfo = new StatementCompanyComprehensiveInfo();
+            comprehensiveInfo.setType("3");
+            comprehensiveInfo.setYear(String.valueOf(year));
+            comprehensiveInfo.setBigDateType(bigDateType.toString());
+            comprehensiveInfo.setSmallDateType(smallDateType.toString());
+            comprehensiveInfo.setStatementDate(statementDate);
+            comprehensiveInfo.setOfficeId(officeInfo.getId());
+            //查询新增报销信息
+            /*Integer field1 = dao.getInsertReimbursementCountByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField1(field1.toString());*/
+            for (ReportDataEntity reportData: field1All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField1(String.valueOf(Integer.parseInt(comprehensiveInfo.getField1()) + reportData.getCount()));
+                }
+            }
+            //查询报销金额总额
+            /*String field2 = dao.getInsertReimbursementSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField2(field2);*/
+            for (ReportDataEntity reportData: field2All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField2(String.valueOf(new BigDecimal(comprehensiveInfo.getField2()).add(new BigDecimal(reportData.getVariableElement()))));
+                }
+            }
+            //对金额数据进行处理和四舍五入
+            if(StringUtils.isNotBlank(comprehensiveInfo.getField2())){
+                BigDecimal b = new BigDecimal(comprehensiveInfo.getField2());
+                comprehensiveInfo.setField2(String.valueOf(b.setScale(2, BigDecimal.ROUND_HALF_UP)));
+            }
+
+            //数据处理并保存到数据库中
+            comprehensiveInfo.preInsert();
+            //每次都要删除之前的数据
+            dao.deleteByYear(comprehensiveInfo);
+            dao.insertByYear(comprehensiveInfo);
+        }
+    }
+
     /**
      * 公司级合同记录月报/季报/年报汇总方法
      * @param beginDate 开始时间
@@ -1044,6 +1376,129 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
 
 
 
+    /**
+     * 公司级合同记录年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     */
+    @Transactional(readOnly = false)
+    public void disposeStatementCompanyContractByYear(Integer year,String beginDate,String endDate,String statementDate,Integer bigDateType,Integer smallDateType,List<Office> officeList){
+
+        //查询新增合同信息
+        List<ReportDataEntity> field1All = dao.getInsertContractCountByOfficeAll( beginDate, endDate);
+        //查询本月纸质归档合同信息
+        List<ReportDataEntity> field2All = dao.getInsertContractRecordCountByOfficeAll( beginDate, endDate);
+        //查询超期未归档合同信息
+        List<ReportDataEntity> field3All = dao.getOverDueNotContractRecordCountByOfficeAll();
+        //查询超期归档合同信息
+        List<ReportDataEntity> field4All = dao.getOverDueContractRecordCountByOfficeAll( beginDate, endDate);
+        //查询电子归档超期未归档项目数量(分组)
+        Map<String, List<ReportDataEntity>> field3AllMap = dataMessageDispose(field3All);
+        //分组
+        Map<String, List<ReportDataEntity>> field4AllMap = dataMessageDispose(field4All);
+
+        for (Office officeInfo : officeList) {
+            StatementCompanyComprehensiveInfo comprehensiveInfo = new StatementCompanyComprehensiveInfo();
+            comprehensiveInfo.setType("4");
+            comprehensiveInfo.setYear(String.valueOf(year));
+            comprehensiveInfo.setBigDateType(bigDateType.toString());
+            comprehensiveInfo.setSmallDateType(smallDateType.toString());
+            comprehensiveInfo.setStatementDate(statementDate);
+            comprehensiveInfo.setOfficeId(officeInfo.getId());
+
+            //查询新增合同信息
+            /*Integer field1 = dao.getInsertContractCountByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField1(field1.toString());*/
+            for (ReportDataEntity reportData: field1All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField1(String.valueOf(Integer.parseInt(comprehensiveInfo.getField1()) + reportData.getCount()));
+                }
+            }
+            //查询本月纸质归档合同信息
+            /*Integer field2 = dao.getInsertContractRecordCountByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField2(field2.toString());*/
+            for (ReportDataEntity reportData: field2All) {
+                if(officeInfo.getId().equals(reportData.getOfficeId()) || reportData.getOfficeParentIds().contains(officeInfo.getId())){
+                    comprehensiveInfo.setField2(String.valueOf(Integer.parseInt(comprehensiveInfo.getField2()) + reportData.getCount()));
+                }
+            }
+            //查询超期未归档合同信息
+            /*List<String> overDueNotContractIdList = dao.getOverDueNotContractRecordCountByOffice(officeInfo.getId());
+            comprehensiveInfo.setField3(String.valueOf(overDueNotContractIdList.size()));*/
+            List<ReportDataEntity> field3ListAll = Lists.newArrayList();
+            for (String key : field3AllMap.keySet()) {
+                if(officeInfo.getId().equals(key) || key.contains(officeInfo.getId())){
+                    List<ReportDataEntity> reportDataEntities = field3AllMap.get(key);
+                    field3ListAll.addAll(reportDataEntities);
+                    comprehensiveInfo.setField3(String.valueOf(Integer.parseInt(comprehensiveInfo.getField3()) + reportDataEntities.size()));
+                }
+            }
+
+            List<StatementDataInfo> overDueNotContractList = Lists.newArrayList();
+            for (ReportDataEntity peportDataEntity : field3ListAll) {
+                String contract = peportDataEntity.getFieldId();
+                StatementDataInfo info = new StatementDataInfo();
+                info.setStatementDate(statementDate);
+                info.setGradeType("1");
+                info.setType("4");
+                info.setYear(String.valueOf(year));
+                info.setBigDateType(bigDateType.toString());
+                info.setSmallDateType(smallDateType.toString());
+                info.setOfficeId(officeInfo.getId());
+                info.setField1(contract);
+                overDueNotContractList.add(info);
+            }
+            if(overDueNotContractList.size()>0){
+                //每次删除之前存的数据
+                for (StatementDataInfo statementDataInfo: overDueNotContractList) {
+                    dao.deleteStatementDataInfo(statementDataInfo);
+                }
+                dao.insertStatementDataInfo(overDueNotContractList);
+            }
+
+            //查询超期归档合同信息
+            /*List<String> overDueContractIdList = dao.getOverDueContractRecordCountByOffice(officeInfo.getId(), beginDate, endDate);
+            comprehensiveInfo.setField4(String.valueOf(overDueContractIdList.size()));*/
+            List<ReportDataEntity> field4ListAll = Lists.newArrayList();
+            for (String key : field4AllMap.keySet()) {
+                if(officeInfo.getId().equals(key) || key.contains(officeInfo.getId())){
+                    List<ReportDataEntity> reportDataEntities = field4AllMap.get(key);
+                    field4ListAll.addAll(reportDataEntities);
+                    comprehensiveInfo.setField4(String.valueOf(Integer.parseInt(comprehensiveInfo.getField4()) + reportDataEntities.size()));
+                }
+            }
+            List<StatementDataInfo> overDueContractList = Lists.newArrayList();
+            for (ReportDataEntity peportDataEntity : field4ListAll) {
+                String contract = peportDataEntity.getFieldId();
+                StatementDataInfo info = new StatementDataInfo();
+                info.setStatementDate(statementDate);
+                info.setGradeType("1");
+                info.setType("4");
+                info.setYear(String.valueOf(year));
+                info.setBigDateType(bigDateType.toString());
+                info.setSmallDateType(smallDateType.toString());
+                info.setOfficeId(officeInfo.getId());
+                info.setField2(contract);
+                overDueContractList.add(info);
+            }
+            if(overDueContractList.size()>0){
+                //每次删除之前存的数据
+                for (StatementDataInfo statementDataInfo: overDueContractList) {
+                    dao.deleteStatementDataInfo(statementDataInfo);
+                }
+                dao.insertStatementDataInfo(overDueContractList);
+            }
+
+            //数据处理并保存到数据库中
+            comprehensiveInfo.preInsert();
+            //每次都要删除之前的数据
+            dao.deleteByYear(comprehensiveInfo);
+            dao.insertByYear(comprehensiveInfo);
+
+        }
+    }
+
+
 
     /**
      * 根据状态获取查询得开始和结束时间
@@ -1768,6 +2223,16 @@ public class StatementCompanyComprehensiveService extends CrudService<StatementC
         return list;
     }
 
+
+    //根据公司级报告查询所有的表内容
+    public List<StatementCompanyComprehensiveInfo> selectAllByTypeInYearReportByYear(StatementCompanyComprehensiveInfo info){
+        List<StatementCompanyComprehensiveInfo> list = dao.selectAllByTypeByYear(info);
+        return list;
+    }
+
+
+
+
     /**
      * 部门级 所有报表信息
      * @param year 年份

+ 34 - 3
src/main/java/com/jeeplus/modules/workcalendar/service/WorkCalendarTaskService.java

@@ -164,9 +164,9 @@ public class WorkCalendarTaskService  {
             logger.info("-----------公司级—月度报表(开始)------------------");
             statementCompanyComprehensiveService.disposeStatementCompany(year,2,month);
             logger.info("------------公司级—月度报表(结束)------------------");
-            logger.info("------------公司级—年度报表(开始)------------------");
-            statementCompanyComprehensiveService.disposeStatementCompanyByyear(year,0,month);
-            logger.info("------------公司级—年度报表(结束)------------------");
+//            logger.info("------------公司级—年度报表(开始)------------------");
+//            statementCompanyComprehensiveService.disposeStatementCompanyByYear(year,0,month);
+//            logger.info("------------公司级—年度报表(结束)------------------");
             logger.info("-----------部门级—月度报表(开始)------------------");
             statementCompanyComprehensiveService.disposeStatementOffice(year,2,month);
             logger.info("------------部门级—月度报表(结束)------------------");
@@ -175,6 +175,37 @@ public class WorkCalendarTaskService  {
     }
 
     /**
+     * 月度报表
+     */
+    //测试用
+    @Scheduled(cron= "*/30 * * * * ?")
+    //@Scheduled(cron= "0 0/2 * * * ?")
+    @Transactional(readOnly = false)
+    public void getStatementCompanyComprehensiveOnMonth2() {
+        final Calendar c = Calendar.getInstance();
+        Integer year = c.get(Calendar.YEAR);
+        System.out.println(c.get(Calendar.DATE));
+        System.out.println(c.getActualMaximum(Calendar.DATE));
+//        if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)){
+
+            Integer month = c.get(Calendar.MONTH)+1; //第一个月从0开始,所以得到月份+1
+            //当月最后一天
+            logger.info("-----------公司级—月度报表(开始)------------------");
+            statementCompanyComprehensiveService.disposeStatementCompany(year,2,month);
+            logger.info("------------公司级—月度报表(结束)------------------");
+        System.out.println("===========================================开始");
+            logger.info("------------公司级—年度报表(开始)------------------");
+            statementCompanyComprehensiveService.disposeStatementCompanyByYear(year,0,month);
+            logger.info("------------公司级—年度报表(结束)------------------");
+            logger.info("-----------部门级—月度报表(开始)------------------");
+//            statementCompanyComprehensiveService.disposeStatementOffice(year,2,month);
+            logger.info("------------部门级—月度报表(结束)------------------");
+//        }
+
+    }
+
+
+    /**
      * 季度报表
      */
     //每个季度最后一天晚上23点推送

+ 146 - 0
src/main/resources/mappings/modules/statement/StatementCompanyComprehensiveDao.xml

@@ -104,6 +104,44 @@
 		)
 	</insert>
 
+
+	<insert id="insertByYear">
+		INSERT INTO statement_company_comprehensive_info2(
+			create_date,
+			year,
+			type,
+			big_date_type,
+			small_date_type,
+			statement_date,
+			office_id,
+			field1,
+			field2,
+			field3,
+			field4,
+			field5,
+			field6,
+			field7,
+			field8
+		) VALUES (
+			#{createDate},
+			#{year},
+			#{type},
+			#{bigDateType},
+			#{smallDateType},
+			#{statementDate},
+			#{officeId},
+			#{field1},
+			#{field2},
+			#{field3},
+			#{field4},
+			#{field5},
+			#{field6},
+			#{field7},
+			#{field8}
+
+		)
+	</insert>
+
 	<delete id="delete">
 		delete from statement_company_comprehensive_info
 		where type = #{type}
@@ -113,6 +151,16 @@
 			and office_id = #{officeId}
 	</delete>
 
+
+	<delete id="deleteByYear">
+		delete from statement_company_comprehensive_info2
+		where type = #{type}
+		  	and year = #{year}
+			and big_date_type = #{bigDateType}
+			and small_date_type = #{smallDateType}
+			and office_id = #{officeId}
+	</delete>
+
 	<update id="update">
 		UPDATE statement_company_comprehensive_info SET
 
@@ -658,6 +706,42 @@
 		</foreach>
 	</insert>
 
+
+	<insert id="insertStatementDataInfoByYear">
+		INSERT INTO statement_data_info2
+		(
+		create_date
+		,year
+		,grade_type
+		,type
+		,big_date_type
+		,small_date_type
+		,statement_date
+		,office_id
+		,field1
+		,field2
+		,field3
+		,field4
+		)
+		VALUES
+		<foreach collection="dataList" item="data" separator=",">
+			(
+			now()
+			,#{data.year}
+			,#{data.gradeType}
+			,#{data.type}
+			,#{data.bigDateType}
+			,#{data.smallDateType}
+			,#{data.statementDate}
+			,#{data.officeId}
+			,#{data.field1}
+			,#{data.field2}
+			,#{data.field3}
+			,#{data.field4}
+			)
+		</foreach>
+	</insert>
+
 	<delete id="deleteStatementDataInfo">
 		delete from statement_data_info
 		<where >
@@ -685,6 +769,35 @@
 		</where>
 	</delete>
 
+
+	<delete id="deleteStatementDataInfoByYear">
+		delete from statement_data_info2
+		<where >
+			type = #{type}
+			and year = #{year}
+			and big_date_type = #{bigDateType}
+			and small_date_type = #{smallDateType}
+			and office_id = #{officeId}
+
+			<if test="field1 != null and field1 != ''">
+				and field1 = #{field1}
+			</if>
+
+			<if test="field2 != null and field2 != ''">
+				and field2 = #{field2}
+			</if>
+
+			<if test="field3 != null and field3 != ''">
+				and field3 = #{field3}
+			</if>
+
+			<if test="field4 != null and field4 != ''">
+				and field4 = #{field4}
+			</if>
+		</where>
+	</delete>
+
+
 	<select id="getStatementCompanyNotificationUserList" resultType="com.jeeplus.modules.sys.entity.User">
 		select su.id,su.name,su.company_id as "company.id" from statement_company_notification_user_info a
 		left join sys_user su on a.user_id = su.id
@@ -1326,6 +1439,39 @@
 
 
 
+
+	<select id="selectAllByTypeByYear" parameterType="StatementCompanyComprehensiveInfo" resultType="StatementCompanyComprehensiveInfo">
+		select
+		a.id as "id",
+		a.del_flag as "delFlag",
+		a.create_date as "createDate",
+		a.year as "year",
+		a.type as "type",
+		a.big_date_type as "bigDateType",
+		a.small_date_type as "smallDateType",
+		a.statement_date as "statementDate",
+		a.office_id as "officeId",
+		a.field1 as "field1",
+		a.field2 as "field2",
+		a.field3 as "field3",
+		a.field4 as "field4",
+		a.field5 as "field5",
+		a.field6 as "field6",
+		a.field7 as "field7",
+		a.field8 as "field8",
+		(select name from sys_office where id = office_id) officeName
+		from statement_company_comprehensive_info2 a
+		<where>
+			a.type = #{type}
+			and a.del_flag = 0
+			and a.big_date_type = #{bigDateType}
+			and a.year = #{year}
+			and a.small_date_type = #{smallDateType}
+		</where>
+	</select>
+
+
+
 	<select id="selectAllByTypeInYearReport" parameterType="StatementCompanyComprehensiveInfo" resultType="StatementCompanyComprehensiveInfo">
 		select
 		a.id as "id",