Browse Source

公司级报表相关部分代码

user5 3 years ago
parent
commit
b66356d27d

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

@@ -0,0 +1,143 @@
+package com.jeeplus.modules.statement.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.statement.entity.StatementCompanyComprehensiveInfo;
+import com.jeeplus.modules.sys.entity.Office;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author: 大猫
+ * @create: 2022-01-11 10:02
+ **/
+@MyBatisDao
+public interface StatementCompanyComprehensiveDao  extends CrudDao<StatementCompanyComprehensiveInfo> {
+
+    /**
+     * 查询项目相关的部门信息
+     * @return
+     */
+    List<Office> getOfficeListInfo();
+
+    /**
+     * 查询所有一级部门信息
+     * @return
+     */
+    List<Office> getAllOfficeListInfo();
+
+    /**
+     * 公司级根据项目等级查询项目信息数量
+     * @param officeId 部门id
+     * @param grade 项目等级
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     * @return
+     */
+    Integer getInsertProjectCountByGrade(@Param("officeId") String officeId, @Param("grade")String grade, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+
+    /**
+     * 公司级查询项目归档信息数量
+     * @param officeId 部门id
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     * @return
+     */
+    Integer getProjectCountByRecord(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+    /**
+     * 公司级查询项目上报信息数量
+     * @param officeId 部门id
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     * @return
+     */
+    Integer getProjectCountByReported(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+    /**
+     * 公司级查询发票信息数量
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    Integer getInsertInvoiceCountByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+    /**
+     * 公司级查询发票信息开票金额总和
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    String getInsertInvoiceSumMoneyByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+    /**
+     * 公司级查询收款发票数量
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    Integer getInsertInvoiceDetailsCountByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+
+    /**
+     * 公司级查询收款发票金额总和
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    String getInsertInvoiceDetailsSumMoneyByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+
+    /**
+     * 查询新增报销信息
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    Integer getInsertReimbursementCountByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+
+    /**
+     * 查询报销金额总额
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    String getInsertReimbursementSumMoneyByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+    /**
+     * 公司级新增合同信息数量
+     * @param officeId
+     * @param beginDate
+     * @param endDate
+     * @return
+     */
+    Integer getInsertContractCountByOffice(@Param("officeId") String officeId, @Param("beginDate")String beginDate, @Param("endDate")String endDate);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 129 - 0
src/main/java/com/jeeplus/modules/statement/entity/StatementCompanyComprehensiveInfo.java

@@ -0,0 +1,129 @@
+package com.jeeplus.modules.statement.entity;
+
+import com.jeeplus.common.persistence.DataEntity;
+
+
+/**
+ * 公司级报表信息表
+ * @author: 徐滕
+ * @create: 2022-01-11 09:32
+ **/
+public class StatementCompanyComprehensiveInfo extends DataEntity<StatementCompanyComprehensiveInfo> {
+    private String year;            //年份
+    private String type;            //类型(1:项目;2:开票;3:报销;4:合同)
+    private String bigDateType;     //状态1(0:年;1:季度;2:月份)
+    private String smallDateType;   //状态2(针对状态1进行精确所在指定季度或者月份)
+    private String statementDate;   //报表时间
+    private String officeName;      //部门名称
+    private String officeId;        //部门id
+    private String field1;          //可变字段1(项目:新增A类;    开票:新增发票;   报销:新增报销;合同:新增合同)
+    private String field2;          //可变字段2(项目:新增B类;    开票:开票金额;   报销:报销金额;合同:未电子归档)
+    private String field3;          //可变字段3(项目:本月电子归档;开票:本月收款发票;             合同:未纸质归档)
+    private String field4;          //可变字段4(项目:本月上报;   开票:本月收款金额;)
+    private String field5;          //可变字段5(项目:电子归档超期)
+    private String field6;          //可变字段6(项目:上报超期)
+
+    public String getYear() {
+        return year;
+    }
+
+    public void setYear(String year) {
+        this.year = year;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getBigDateType() {
+        return bigDateType;
+    }
+
+    public void setBigDateType(String bigDateType) {
+        this.bigDateType = bigDateType;
+    }
+
+    public String getSmallDateType() {
+        return smallDateType;
+    }
+
+    public void setSmallDateType(String smallDateType) {
+        this.smallDateType = smallDateType;
+    }
+
+    public String getStatementDate() {
+        return statementDate;
+    }
+
+    public void setStatementDate(String statementDate) {
+        this.statementDate = statementDate;
+    }
+
+    public String getOfficeName() {
+        return officeName;
+    }
+
+    public void setOfficeName(String officeName) {
+        this.officeName = officeName;
+    }
+
+    public String getOfficeId() {
+        return officeId;
+    }
+
+    public void setOfficeId(String officeId) {
+        this.officeId = officeId;
+    }
+
+    public String getField1() {
+        return field1;
+    }
+
+    public void setField1(String field1) {
+        this.field1 = field1;
+    }
+
+    public String getField2() {
+        return field2;
+    }
+
+    public void setField2(String field2) {
+        this.field2 = field2;
+    }
+
+    public String getField3() {
+        return field3;
+    }
+
+    public void setField3(String field3) {
+        this.field3 = field3;
+    }
+
+    public String getField4() {
+        return field4;
+    }
+
+    public void setField4(String field4) {
+        this.field4 = field4;
+    }
+
+    public String getField5() {
+        return field5;
+    }
+
+    public void setField5(String field5) {
+        this.field5 = field5;
+    }
+
+    public String getField6() {
+        return field6;
+    }
+
+    public void setField6(String field6) {
+        this.field6 = field6;
+    }
+}

+ 204 - 0
src/main/java/com/jeeplus/modules/statement/service/StatementCompanyComprehensiveService.java

@@ -0,0 +1,204 @@
+package com.jeeplus.modules.statement.service;
+
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.statement.dao.StatementCompanyComprehensiveDao;
+import com.jeeplus.modules.statement.entity.StatementCompanyComprehensiveInfo;
+import com.jeeplus.modules.sys.entity.Office;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 公司级报表Service
+ * @author: 徐滕
+ * @create: 2022-01-11 10:01
+ **/
+
+@Service
+@Transactional(readOnly = true)
+public class StatementCompanyComprehensiveService extends CrudService<StatementCompanyComprehensiveDao, StatementCompanyComprehensiveInfo> {
+
+    /**
+     * 公司级信息处理
+     * @param bigDateType 状态1(0:年;1:季度;2:月份)
+     * @param smallDateType 状态2(针对状态1进行精确所在指定季度或者月份)
+     */
+    public void disposeStatementCompany(Integer bigDateType,Integer smallDateType){
+        Map<String, String> dateMap = getDate(bigDateType, smallDateType);
+        //开始时间
+        String beginDate = dateMap.get("beginDate");
+        //结束时间
+        String endDate = dateMap.get("endDate");
+        disposeStatementCompanyProject(beginDate,endDate);
+
+        //查询部门信息
+        List<Office> officeList = dao.getAllOfficeListInfo();
+
+    }
+
+    /**
+     * 公司级项目月报/季报/年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     */
+    private void disposeStatementCompanyProject(String beginDate,String endDate){
+
+        //查询部门信息
+        List<Office> officeList = dao.getOfficeListInfo();
+        for (Office officeInfo : officeList) {
+            //查询新增A类项目数量
+            Integer projectCountByA = dao.getInsertProjectCountByGrade(officeInfo.getId(), "2", beginDate, endDate);
+            //查询新增B类项目数量
+            Integer projectCountByB = dao.getInsertProjectCountByGrade(officeInfo.getId(), "1", beginDate, endDate);
+            //查询本月电子归档项目数量
+            Integer getProjectCountByRecord = dao.getProjectCountByRecord(officeInfo.getId(), beginDate, endDate);
+            //查询本月上报项目数量
+            Integer getProjectCountByReported = dao.getProjectCountByReported(officeInfo.getId(), beginDate, endDate);
+            //查询电子归档超期项目数量(保存到数据库)
+            //查询上报超期项目数量(保存到数据库)
+
+
+            //数据处理并保存到数据库中
+
+        }
+    }
+
+    /**
+     * 公司级开票记录月报/季报/年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     */
+    private void disposeStatementCompanyInvoice(String beginDate,String endDate,List<Office> officeList){
+
+        for (Office officeInfo : officeList) {
+            //查询新增发票信息
+            dao.getInsertInvoiceCountByOffice(officeInfo.getId(), beginDate, endDate);
+            //查询开票金额总额
+            dao.getInsertInvoiceSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+            //查询本月收款发票
+            dao.getInsertInvoiceDetailsCountByOffice(officeInfo.getId(), beginDate, endDate);
+            //查询本月收款
+            dao.getInsertInvoiceDetailsSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+
+            //数据处理并保存到数据库中
+
+        }
+    }
+
+    /**
+     * 公司级报销记录月报/季报/年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     */
+    private void disposeStatementCompanyReimbursement(String beginDate,String endDate,List<Office> officeList){
+
+        for (Office officeInfo : officeList) {
+            //查询新增报销信息
+            dao.getInsertReimbursementCountByOffice(officeInfo.getId(), beginDate, endDate);
+            //查询报销金额总额
+            dao.getInsertReimbursementSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+
+            //数据处理并保存到数据库中
+
+        }
+    }
+
+    /**
+     * 公司级合同记录月报/季报/年报汇总方法
+     * @param beginDate 开始时间
+     * @param endDate 结束时间
+     */
+    private void disposeStatementCompanyContract(String beginDate,String endDate,List<Office> officeList){
+
+        for (Office officeInfo : officeList) {
+            //查询新增合同信息
+            dao.getInsertContractCountByOffice(officeInfo.getId(), beginDate, endDate);
+            //查询未电子归档合同信息
+            dao.getInsertReimbursementSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+            //查询未纸质归档合同信息
+            dao.getInsertReimbursementSumMoneyByOffice(officeInfo.getId(), beginDate, endDate);
+
+            //数据处理并保存到数据库中
+
+        }
+    }
+
+
+
+
+    /**
+     * 根据状态获取查询得开始和结束时间
+     * @param bigDateType
+     * @param smallDateType
+     * @return
+     */
+    private Map<String,String> getDate(Integer bigDateType,Integer smallDateType){
+        Map<String,String> map = new HashMap();
+        Calendar cal = Calendar.getInstance();
+        //获取当前年份
+        int year = cal.get(Calendar.YEAR);
+        String beginDate = "";
+        String endDate = "";
+        switch (bigDateType){
+            //年度汇总
+            case 0:
+                beginDate = year + "-01-01 00:00:00";
+                endDate = year + "-12-31 23:59:59";
+                break;
+            //季度汇总
+            case 1:
+                //smallDateType  为季度时候
+                switch (smallDateType){
+                    case 1:
+                        beginDate = year + "-01-01 00:00:00";
+                        endDate = year + "-03-31 23:59:59";
+                        break;
+                    case 2:
+                        beginDate = year + "-04-01 00:00:00";
+                        endDate = year + "-06-30 23:59:59";
+                        break;
+                    case 3:
+                        beginDate = year + "-07-01 00:00:00";
+                        endDate = year + "-09-30 23:59:59";
+                        break;
+                    case 4:
+                        beginDate = year + "-10-01 00:00:00";
+                        endDate = year + "-12-31 23:59:59";
+                        break;
+                }
+                break;
+            //月度汇总
+            case 2:
+                //smallDateType  为月度时候
+                switch (smallDateType){
+                    case 1:
+                    case 2:
+                    case 3:
+                    case 4:
+                    case 5:
+                    case 6:
+                    case 7:
+                    case 8:
+                    case 9:
+                        beginDate = year + "-0" + smallDateType + "-01 00:00:00";
+                        endDate = year + "-0" + smallDateType + "-31 23:59:59";
+                        break;
+                    case 10:
+                    case 11:
+                    case 12:
+                        beginDate = year + "-" + smallDateType + "-01 00:00:00";
+                        endDate = year + "-" + smallDateType + "-31 23:59:59";
+                        break;
+                }
+
+                break;
+        }
+        map.put("beginDate",beginDate);
+        map.put("endDate",endDate);
+        return map;
+    }
+}

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

@@ -0,0 +1,263 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jeeplus.modules.statement.dao.StatementCompanyComprehensiveDao">
+
+	<sql id="projectRecordsColumns">
+		distinct(a.id) AS "id",
+		a.create_date AS "createDate",
+		a.del_flag AS "delFlag",
+		a.office_id AS "officeId",
+		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"
+	</sql>
+
+	<select id="findList" resultType="RuralProjectRecords" >
+		SELECT
+			<include refid="projectRecordsColumns"/>
+		,o.name AS "officeName"
+		FROM statement_company_comprehensive_info a
+		LEFT JOIN sys_office o ON o.id = a.office_id
+		<where>
+			<if test="year != null and year != ''">
+				AND a.year = #{year}
+			</if>
+			<if test="type != null and type != ''">
+				AND a.type = #{type}
+			</if>
+			<if test="bigDateType != null and bigDateType != ''">
+				AND a.big_date_type = #{bigDateType}
+			</if>
+			<if test="smallDateType != null and smallDateType != ''">
+				AND a.small_date_type = #{smallDateType}
+			</if>
+		</where>
+
+		ORDER BY o.offcie_name asc
+	</select>
+
+    <select id="queryCount" resultType="int" >
+        SELECT count(DISTINCT a.id)
+        FROM statement_company_comprehensive_info a
+		LEFT JOIN sys_office o ON o.id = a.office_id
+		<where>
+            <if test="year != null and year != ''">
+                AND a.year = #{year}
+            </if>
+            <if test="type != null and type != ''">
+                AND a.type = #{type}
+            </if>
+            <if test="bigDateType != null and bigDateType != ''">
+                AND a.big_date_type = #{bigDateType}
+            </if>
+            <if test="smallDateType != null and smallDateType != ''">
+                AND a.small_date_type = #{smallDateType}
+            </if>
+        </where>
+    </select>
+
+	<insert id="insert">
+		INSERT INTO statement_company_comprehensive_info(
+			id,
+			create_date,
+			year,
+			type,
+			big_date_type,
+			small_date_type,
+			statement_date,
+			office_id,
+			field1,
+			field2,
+			field3,
+			field4,
+			field5,
+			field6
+		) VALUES (
+			#{id},
+			#{createDate},
+			#{year},
+			#{type},
+			#{bigDateType},
+			#{smallDateType},
+			#{statementDate},
+			#{officeId},
+			#{field1},
+			#{field2},
+			#{field3},
+			#{field4},
+			#{field5},
+			#{field6}
+
+		)
+	</insert>
+
+	<update id="update">
+		UPDATE statement_company_comprehensive_info SET
+
+			year = #{year},
+			year = #{year},
+			big_date_type = #{bigDateType},
+			small_date_type = #{smallDateType},
+			statement_date = #{statementDate},
+			office_id = #{officeId},
+			field1 = #{field1},
+			field2 = #{field2},
+			field3 = #{field3},
+			field4 = #{field4},
+			field5 = #{field5},
+			field6 = #{field6}
+		WHERE id = #{id}
+	</update>
+
+	<select id="getOfficeListInfo" resultType="Office">
+		select o.id,o.name from statement_office_info a
+		left join sys_office o on o.id = a.office_id
+		ORDER BY o.code
+	</select>
+
+	<select id="getAllOfficeListInfo" resultType="Office">
+		select a.id,a.name from sys_office a
+		<where>
+			a.parent_id = 'ffe5af5b557e46f28b000c94716e228a'
+		</where>
+		ORDER BY a.code
+	</select>
+
+	<select id="getInsertProjectCountByGrade" resultType="java.lang.Integer">
+		select count(1) from rural_project_records a
+		<where>
+			a.del_flag=0
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and a.submit_money = #{grade}
+			and a.create_date >= #{beginDate}
+			and a.create_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getProjectCountByRecord" resultType="java.lang.Integer">
+		select count(1) from rural_project_records a
+		left join project_report_data prd on a.id = prd.project_id
+		left join rural_project_report_record rprr on prd.id = rprr.report_id
+		<where>
+			a.del_flag=0
+			and a.record_state = 5
+			and a.over_record_status = 0
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and rprr.status = 5
+			and rprr.del_flag = 0
+			and rprr.accomplish_date >= #{beginDate}
+			and rprr.accomplish_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getProjectCountByReported" resultType="java.lang.Integer">
+		select count(1) from rural_project_records a
+		left join rural_project_records_reported rprr on a.id = rprr.id
+		<where>
+			a.del_flag=0
+			and a.reported_state = 5
+			and a.over_due_status = 0
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and rprr.report_status = 5
+			and rprr.del_flag = 0
+			and rprr.accomplish_date >= #{beginDate}
+			and rprr.accomplish_date &lt;= #{endDate}
+		</where>
+	</select>
+
+
+
+	<select id="getInsertInvoiceCountByOffice" resultType="java.lang.Integer">
+		select count(1) from work_invoice a
+		<where>
+			a.del_flag=0
+			and a.invoice_state = 5
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and a.invoice_date >= #{beginDate}
+			and a.invoice_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getInsertInvoiceSumMoneyByOffice" resultType="java.lang.String">
+		select round(sum(money),2) from work_invoice a
+		<where>
+			a.del_flag=0
+			and a.invoice_state = 5
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and a.invoice_date >= #{beginDate}
+			and a.invoice_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getInsertInvoiceDetailsCountByOffice" resultType="java.lang.Integer">
+		select count(1) from work_invoice_detail a
+		left join work_invoice wi on a.invoice_id = wi.id
+		<where>
+			wi.del_flag=0
+			and a.del_flag=0
+			and wi.invoice_state = 5
+			and wi.receipt_money = '1'
+			and wi.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and wi.receipt_money_date >= #{beginDate}
+			and wi.receipt_money_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getInsertInvoiceDetailsSumMoneyByOffice" resultType="java.lang.String">
+		select round(sum(a.total_money),2) from work_invoice_detail a
+		left join work_invoice wi on a.invoice_id = wi.id
+		<where>
+			wi.del_flag=0
+			and a.del_flag=0
+			and wi.invoice_state = 5
+			and wi.receipt_money = '1'
+			and wi.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and wi.receipt_money_date >= #{beginDate}
+			and wi.receipt_money_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getInsertReimbursementCountByOffice" resultType="java.lang.Integer">
+		select count(1) from work_reimbursement a
+		<where>
+			and a.del_flag=0
+			and a.status = 5
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and a.accomplish_date >= #{beginDate}
+			and a.accomplish_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getInsertReimbursementSumMoneyByOffice" resultType="java.lang.String">
+		select round(sum(a.money),2) from work_reimbursement a
+		<where>
+			a.del_flag=0
+			and a.status = 5
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and a.accomplish_date >= #{beginDate}
+			and a.accomplish_date &lt;= #{endDate}
+		</where>
+	</select>
+
+	<select id="getInsertContractCountByOffice" resultType="java.lang.Integer">
+		select count(1) from work_contract_info a
+		<where>
+			and a.del_flag=0
+			and a.contract_state = 5
+			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
+			and a.accomplish_date >= #{beginDate}
+			and a.accomplish_date &lt;= #{endDate}
+		</where>
+	</select>
+
+
+</mapper>