Parcourir la source

Merge branch 'feature-operating-report' of http://git.dayaedu.com/yonge/mec into feature-operating-report

# Conflicts:
#	mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml
zouxuan il y a 4 ans
Parent
commit
c58427869d

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportDao.java

@@ -2,7 +2,12 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.OperatingReport;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 public interface OperatingReportDao extends BaseDAO<Integer, OperatingReport> {
 
+    OperatingReport getReport(Map<String, Object> params);
 }

+ 26 - 12
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReport.java

@@ -32,61 +32,67 @@ public class OperatingReport {
     * 销售收入
     */
     @ApiModelProperty(value="销售收入")
-    private BigDecimal sellAmount;
+    private BigDecimal sellAmount = BigDecimal.ZERO;
 
     /**
-    * 服务收入
-    */
+     * 不确定收入
+     */
+    @ApiModelProperty(value="不确定收入")
+    private BigDecimal otherIncome = BigDecimal.ZERO;
+
+    /**
+     * 服务收入
+     */
     @ApiModelProperty(value="服务收入")
-    private BigDecimal serviceAmount;
+    private BigDecimal serviceAmount = BigDecimal.ZERO;
 
     /**
     * 业务退费
     */
     @ApiModelProperty(value="业务退费")
-    private BigDecimal refundAmount;
+    private BigDecimal refundAmount = BigDecimal.ZERO;
 
     /**
     * 收入合计
     */
     @ApiModelProperty(value="收入合计")
-    private BigDecimal incomeTotal;
+    private BigDecimal incomeTotal = BigDecimal.ZERO;
 
     /**
     * 销售成本
     */
     @ApiModelProperty(value="销售成本")
-    private BigDecimal sellCost;
+    private BigDecimal sellCost = BigDecimal.ZERO;
 
     /**
     * 固定支出
     */
     @ApiModelProperty(value="固定支出")
-    private BigDecimal expensesAmount;
+    private BigDecimal expensesAmount = BigDecimal.ZERO;
 
     /**
     * 变动支出
     */
     @ApiModelProperty(value="变动支出")
-    private BigDecimal variableCost;
+    private BigDecimal variableCost = BigDecimal.ZERO;
 
     /**
     * 分摊费用
     */
     @ApiModelProperty(value="分摊费用")
-    private BigDecimal distributionAmount;
+    private BigDecimal distributionAmount = BigDecimal.ZERO;
 
     /**
     * 成本费用合计
     */
     @ApiModelProperty(value="成本费用合计")
-    private BigDecimal costAmount;
+    private BigDecimal costAmount = BigDecimal.ZERO;
 
     /**
     * 利润
     */
     @ApiModelProperty(value="利润")
-    private BigDecimal profit;
+    private BigDecimal profit = BigDecimal.ZERO;
 
     /**
     * 月份
@@ -235,4 +241,12 @@ public class OperatingReport {
     public void setSchoolName(String schoolName) {
         this.schoolName = schoolName;
     }
+
+    public BigDecimal getOtherIncome() {
+        return otherIncome;
+    }
+
+    public void setOtherIncome(BigDecimal otherIncome) {
+        this.otherIncome = otherIncome;
+    }
 }

+ 6 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OperatingReportQueryInfo.java

@@ -10,8 +10,8 @@ public class OperatingReportQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "分部id", required = false)
     private String organIdList;
 
-    @ApiModelProperty(value = "学校id", required = false)
-    private Integer schoolId;
+    @ApiModelProperty(value = "合作机构", required = false)
+    private Integer cooperationOrganId;
 
     @ApiModelProperty(value = "月份", required = false)
     private Date month;
@@ -28,12 +28,12 @@ public class OperatingReportQueryInfo extends QueryInfo {
         this.organIdList = organIdList;
     }
 
-    public Integer getSchoolId() {
-        return schoolId;
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
     }
 
-    public void setSchoolId(Integer schoolId) {
-        this.schoolId = schoolId;
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
     }
 
     public Date getMonth() {

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportService.java

@@ -8,6 +8,6 @@ import java.util.List;
 
 public interface OperatingReportService extends BaseService<Integer, OperatingReport> {
 
-    List<OperatingReport> statistics();
+    Boolean statistics();
 
 }

+ 184 - 31
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportServiceImpl.java

@@ -3,19 +3,17 @@ package com.ym.mec.biz.service.impl;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.OrganFullJobResourceNumDto;
 import com.ym.mec.biz.dal.entity.FinancialExpenditure;
-import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.OperatingReport;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.ExpenditureTypeEnum;
 import com.ym.mec.biz.service.OperatingReportService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.date.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.SpringApplication;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 @Service
@@ -23,11 +21,14 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
 
     @Autowired
     private OperatingReportDao operatingReportDao;
-    private StudentPaymentOrderDao studentPaymentOrderDao;
-    private MusicGroupDao musicGroupDao;
+    @Autowired
     private SellOrderDao sellOrderDao;
+    @Autowired
     private CooperationOrganDao cooperationOrganDao;
+    @Autowired
     private FinancialExpenditureDao financialExpenditureDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
 
     @Override
@@ -36,57 +37,209 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
     }
 
     @Override
-    public List<OperatingReport> statistics() {
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean statistics() {
         Date nowDate = new Date();
         Date startTime = DateUtil.addDays1(nowDate, -1);
         Date endTime = DateUtil.getLastDayOfMonth(startTime);
 
-        /**
-         * 	MUSIC("乐团课"),
-         * 	VIP("VIP课"),
-         * 	DEMO("试听课"),
-         * 	SPORADIC("零星收费"),
-         * 	PRACTICE("网管课"),
-         * 	COMM("对外课程"),
-         * 	REPAIR("乐器维修"),
-         * 	OUTORDER("外部订单");
-         */
-        /**
-         *         分摊费用计算公式:全职资源数*全职资源公摊金额/12
-         *
-         *         成本费用合计:销售成本+固定支出+变动支出+业务退费+分摊费用
-         *
-         *         利润:收入合计-成本费用合计
-         *
-         *        【全职资源数】*【全职资源公摊金额】/12,该公式得出的值为【学校】【每月】的公摊费用
-         */
         Map<Integer, OperatingReport> cooperationOperating = new HashMap<>();
         Map<Integer, OperatingReport> organOperating = new HashMap<>();
 
         //1、获取分部的全职资源数的分摊费用
-        List<OrganFullJobResourceNumDto> organFullJobResourceNum = cooperationOrganDao.getOrganFullJobResourceNum();
+        BigDecimal fullJobFee = new BigDecimal(sysConfigDao.findConfigValue("full_job_fee"));
+        List<OrganFullJobResourceNumDto> organFullJobResources = cooperationOrganDao.getOrganFullJobResourceNum();
+        for (OrganFullJobResourceNumDto organFullJobResource : organFullJobResources) {
+            OperatingReport operatingReport = new OperatingReport();
+            operatingReport.setOrganId(organFullJobResource.getOrganId());
+            operatingReport.setDistributionAmount(new BigDecimal(organFullJobResource.getNum()).multiply(fullJobFee));
+            organOperating.put(organFullJobResource.getOrganId(), operatingReport);
+        }
 
         //2、获取支出费用
         List<FinancialExpenditure> cooperationExpenditures = financialExpenditureDao.getCooperationExpenditure();
+        for (FinancialExpenditure cooperationExpenditure : cooperationExpenditures) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(cooperationExpenditure.getOrganId())) {
+                organOperatingReport = organOperating.get(cooperationExpenditure.getOrganId());
+            }
+
+            OperatingReport cooperationOperatingReport = new OperatingReport();
+            if (cooperationExpenditure.getCooperationOrganId() != null && cooperationOperating.containsKey(cooperationExpenditure.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(cooperationExpenditure.getCooperationOrganId());
+            }
+
+            organOperatingReport.setOrganId(cooperationExpenditure.getOrganId());
+            if (cooperationExpenditure.getType().equals(ExpenditureTypeEnum.FIXED)) {
+                organOperatingReport.setExpensesAmount(organOperatingReport.getExpensesAmount().add(cooperationExpenditure.getAmount()));
+                cooperationOperatingReport.setExpensesAmount(cooperationExpenditure.getAmount());
+            } else if (cooperationExpenditure.getType().equals(ExpenditureTypeEnum.VARIABLE)) {
+                organOperatingReport.setVariableCost(organOperatingReport.getVariableCost().add(cooperationExpenditure.getAmount()));
+                cooperationOperatingReport.setVariableCost(cooperationExpenditure.getAmount());
+            } else if (cooperationExpenditure.getType().equals(ExpenditureTypeEnum.REFUND)) {
+                organOperatingReport.setRefundAmount(organOperatingReport.getRefundAmount().add(cooperationExpenditure.getAmount()));
+                cooperationOperatingReport.setRefundAmount(cooperationExpenditure.getAmount());
+            }
+            organOperating.put(cooperationExpenditure.getOrganId(), organOperatingReport);
+
+            if (cooperationExpenditure.getCooperationOrganId() != null) {
+                cooperationOperating.put(cooperationExpenditure.getCooperationOrganId(), cooperationOperatingReport);
+            }
+        }
 
         //3.1、乐团订单的统计
         List<OperatingReport> musicReports = sellOrderDao.getMusicGroupMonthReport(startTime, endTime);
+        for (OperatingReport musicReport : musicReports) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(musicReport.getOrganId())) {
+                organOperatingReport = organOperating.get(musicReport.getOrganId());
+            }
+
+            OperatingReport cooperationOperatingReport = new OperatingReport();
+            if (cooperationOperating.containsKey(musicReport.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(musicReport.getCooperationOrganId());
+            }
+
+            if (musicReport.getSellAmount() == null) {
+                musicReport.setSellAmount(BigDecimal.ZERO);
+                musicReport.setSellCost(BigDecimal.ZERO);
+            }
+            BigDecimal serviceAmount = musicReport.getIncomeTotal().subtract(musicReport.getSellAmount());
+
+            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(serviceAmount));
+            organOperatingReport.setSellAmount(organOperatingReport.getSellAmount().add(musicReport.getSellAmount()));
+            organOperatingReport.setSellCost(organOperatingReport.getSellCost().add(musicReport.getSellCost()));
+            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(serviceAmount));
+            cooperationOperatingReport.setSellAmount(cooperationOperatingReport.getSellAmount().add(musicReport.getSellAmount()));
+            cooperationOperatingReport.setSellCost(cooperationOperatingReport.getSellCost().add(musicReport.getSellCost()));
+            organOperating.put(cooperationOperatingReport.getOrganId(), organOperatingReport);
+            cooperationOperating.put(cooperationOperatingReport.getCooperationOrganId(), cooperationOperatingReport);
+        }
 
         //3.2、VIP、网管课订单的统计(关联学生注册取一条记录)
         List<OperatingReport> VPReports = sellOrderDao.getMusicVipPracticeMonthReport(startTime, endTime);
+        for (OperatingReport vpReport : VPReports) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(vpReport.getOrganId())) {
+                organOperatingReport = organOperating.get(vpReport.getOrganId());
+            }
+
+            OperatingReport cooperationOperatingReport = new OperatingReport();
+            if (vpReport.getCooperationOrganId() != null && cooperationOperating.containsKey(vpReport.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(vpReport.getCooperationOrganId());
+            }
+            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(vpReport.getIncomeTotal()));
+            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(vpReport.getIncomeTotal()));
+
+
+            organOperating.put(vpReport.getOrganId(), organOperatingReport);
+
+            if (vpReport.getCooperationOrganId() != null) {
+                cooperationOperating.put(vpReport.getCooperationOrganId(), cooperationOperatingReport);
+            }
+        }
 
         //3.3、外部添加订单
         List<OperatingReport> outOrderReports = sellOrderDao.getOutOrderMonthReport(startTime, endTime);
+        for (OperatingReport outOrderReport : outOrderReports) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(outOrderReport.getOrganId())) {
+                organOperatingReport = organOperating.get(outOrderReport.getOrganId());
+            }
+
+            OperatingReport cooperationOperatingReport = new OperatingReport();
+            if (cooperationOperating.containsKey(outOrderReport.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(outOrderReport.getCooperationOrganId());
+            }
+
+            if (outOrderReport.getSellAmount() == null) {
+                outOrderReport.setSellAmount(BigDecimal.ZERO);
+                outOrderReport.setSellCost(BigDecimal.ZERO);
+            }
+            BigDecimal serviceAmount = outOrderReport.getIncomeTotal().subtract(outOrderReport.getSellAmount());
+
+            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(serviceAmount));
+            organOperatingReport.setSellAmount(organOperatingReport.getSellAmount().add(outOrderReport.getSellAmount()));
+            organOperatingReport.setSellCost(organOperatingReport.getSellCost().add(outOrderReport.getSellCost()));
+            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(serviceAmount));
+            cooperationOperatingReport.setSellAmount(cooperationOperatingReport.getSellAmount().add(outOrderReport.getSellAmount()));
+            cooperationOperatingReport.setSellCost(cooperationOperatingReport.getSellCost().add(outOrderReport.getSellCost()));
+            organOperating.put(cooperationOperatingReport.getOrganId(), organOperatingReport);
+            if (outOrderReport.getCooperationOrganId() != null) {
+                cooperationOperating.put(cooperationOperatingReport.getCooperationOrganId(), cooperationOperatingReport);
+            }
+        }
 
         //3.4、乐器维修
 
         //3.5、零星支付充值
         List<OperatingReport> rechargeReports = sellOrderDao.getRechargeMonthReport(startTime, endTime);
+        for (OperatingReport rechargeReport : rechargeReports) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(rechargeReport.getOrganId())) {
+                organOperatingReport = organOperating.get(rechargeReport.getOrganId());
+            }
+
+            OperatingReport cooperationOperatingReport = new OperatingReport();
+            if (rechargeReport.getCooperationOrganId() != null && cooperationOperating.containsKey(rechargeReport.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(rechargeReport.getCooperationOrganId());
+            }
+            organOperatingReport.setOtherIncome(organOperatingReport.getOtherIncome().add(rechargeReport.getIncomeTotal()));
+            cooperationOperatingReport.setOtherIncome(cooperationOperatingReport.getIncomeTotal().add(rechargeReport.getIncomeTotal()));
+
+            organOperating.put(rechargeReport.getOrganId(), organOperatingReport);
+
+            if (rechargeReport.getCooperationOrganId() != null) {
+                cooperationOperating.put(rechargeReport.getCooperationOrganId(), cooperationOperatingReport);
+            }
+        }
 
         //3.6、零星收费(不是充值部分的)
         List<OperatingReport> sporadicReports = sellOrderDao.getSporadicMonthReport(startTime, endTime);
-
-        return null;
-
+        for (OperatingReport sporadicReport : sporadicReports) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(sporadicReport.getOrganId())) {
+                organOperatingReport = organOperating.get(sporadicReport.getOrganId());
+            }
+
+            OperatingReport cooperationOperatingReport = new OperatingReport();
+            if (sporadicReport.getCooperationOrganId() != null && cooperationOperating.containsKey(sporadicReport.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(sporadicReport.getCooperationOrganId());
+            }
+            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(sporadicReport.getIncomeTotal()));
+            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(sporadicReport.getIncomeTotal()));
+
+
+            organOperating.put(sporadicReport.getOrganId(), organOperatingReport);
+
+            if (sporadicReport.getCooperationOrganId() != null) {
+                cooperationOperating.put(sporadicReport.getCooperationOrganId(), cooperationOperatingReport);
+            }
+        }
+
+        organOperating.putAll(cooperationOperating);
+        Map<String, Object> params = new HashMap<>();
+        params.put("startTime", startTime);
+        params.put("endTime", endTime);
+        organOperating.forEach((organId, operatingReport) -> {
+            operatingReport.setMonth(startTime);
+            operatingReport.setCreateTime(nowDate);
+            //收入合计:销售收入+服务收入-业务退费
+            BigDecimal incomeTotal = operatingReport.getSellAmount().add(operatingReport.getServiceAmount()).subtract(operatingReport.getRefundAmount());
+            operatingReport.setIncomeTotal(incomeTotal);
+            //成本费用合计:销售成本+固定支出+变动支出+分摊费用
+            BigDecimal costAmount = operatingReport.getSellCost().add(operatingReport.getExpensesAmount()).add(operatingReport.getVariableCost()).add(operatingReport.getDistributionAmount());
+            operatingReport.setCostAmount(costAmount);
+            //利润:收入合计-成本费用合计
+            operatingReport.setProfit(incomeTotal.subtract(costAmount));
+            params.put("organId", operatingReport.getOrganId());
+            params.put("cooperationOrganId", operatingReport.getCooperationOrganId());
+            if (operatingReportDao.getReport(params) == null) {
+                operatingReportDao.insert(operatingReport);
+            } else {
+                operatingReportDao.update(operatingReport);
+            }
+        });
+        return true;
     }
 }

+ 156 - 127
mec-biz/src/main/resources/config/mybatis/OperatingReportMapper.xml

@@ -1,135 +1,164 @@
 <?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.ym.mec.biz.dal.dao.OperatingReportDao">
-  <resultMap id="OperatingReport" type="com.ym.mec.biz.dal.entity.OperatingReport">
-    <!--@mbg.generated-->
-    <!--@Table operating_report-->
-    <id column="id_" property="id" />
-    <result column="organ_id_" property="organId" />
-    <result column="organ_name_" property="organName"/>
-    <result column="cooperation_organ_id_" property="cooperationOrganId" />
-    <result column="school_name_" property="schoolName"/>
-    <result column="sell_amount_" property="sellAmount" />
-    <result column="service_amount_" property="serviceAmount" />
-    <result column="refund_amount_" property="refundAmount" />
-    <result column="income_total_" property="incomeTotal" />
-    <result column="sell_cost_" property="sellCost" />
-    <result column="expenses_amount_" property="expensesAmount" />
-    <result column="variable_cost_" property="variableCost" />
-    <result column="distribution_amount_" property="distributionAmount" />
-    <result column="cost_amount_" property="costAmount" />
-    <result column="profit_" property="profit" />
-    <result column="month_" property="month" />
-    <result column="create_time_" property="createTime" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id_, organ_id_, cooperation_organ_id_, sell_amount_, service_amount_, refund_amount_, income_total_, 
-    sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, cost_amount_, 
-    profit_, month_, create_time_
-  </sql>
-  <select id="get" parameterType="java.lang.Integer" resultMap="OperatingReport">
-    <!--@mbg.generated-->
-    select 
-    <include refid="Base_Column_List" />
-    from operating_report
-    where id_ = #{id}
-  </select>
-  <delete id="delete" parameterType="java.lang.Integer">
-    <!--@mbg.generated-->
-    delete from operating_report
-    where id_ = #{id}
-  </delete>
-  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.OperatingReport" useGeneratedKeys="true">
-    <!--@mbg.generated-->
-      insert into operating_report (organ_id_, cooperation_organ_id_, sell_amount_, service_amount_, refund_amount_,
-      income_total_, sell_cost_, expenses_amount_, variable_cost_, distribution_amount_,
-      cost_amount_, profit_, month_, create_time_)
-      values (#{organId}, #{cooperationOrganId}, #{sellAmount}, #{serviceAmount}, #{refundAmount},
-      #{incomeTotal}, #{sellCost}, #{expensesAmount}, #{variableCost}, #{distributionAmount},
-      #{costAmount}, #{profit}, #{month}, #{createTime})
-  </insert>
-  <update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReport">
-    <!--@mbg.generated-->
-    update operating_report
-    <set>
-      <if test="organId != null">
-        organ_id_ = #{organId},
-      </if>
-      <if test="cooperationOrganId != null">
-          cooperation_organ_id_ = #{cooperationOrganId},
-      </if>
-      <if test="sellAmount != null">
-        sell_amount_ = #{sellAmount},
-      </if>
-      <if test="serviceAmount != null">
-        service_amount_ = #{serviceAmount},
-      </if>
-      <if test="refundAmount != null">
-        refund_amount_ = #{refundAmount},
-      </if>
-      <if test="incomeTotal != null">
-        income_total_ = #{incomeTotal},
-      </if>
-      <if test="sellCost != null">
-        sell_cost_ = #{sellCost},
-      </if>
-      <if test="expensesAmount != null">
-        expenses_amount_ = #{expensesAmount},
-      </if>
-      <if test="variableCost != null">
-        variable_cost_ = #{variableCost},
-      </if>
-      <if test="distributionAmount != null">
-        distribution_amount_ = #{distributionAmount},
-      </if>
-      <if test="costAmount != null">
-        cost_amount_ = #{costAmount},
-      </if>
-      <if test="profit != null">
-        profit_ = #{profit},
-      </if>
-      <if test="month != null">
-        month_ = #{month},
-      </if>
-      <if test="createTime != null">
-        create_time_ = #{createTime},
-      </if>
-    </set>
-    where id_ = #{id}
-  </update>
+    <resultMap id="OperatingReport" type="com.ym.mec.biz.dal.entity.OperatingReport">
+        <!--@mbg.generated-->
+        <!--@Table operating_report-->
+        <id column="id_" property="id"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="organ_name_" property="organName"/>
+        <result column="cooperation_organ_id_" property="cooperationOrganId"/>
+        <result column="school_name_" property="schoolName"/>
+        <result column="sell_amount_" property="sellAmount"/>
+        <result column="service_amount_" property="serviceAmount"/>
+        <result column="other_income_" property="otherIncome"/>
+        <result column="refund_amount_" property="refundAmount"/>
+        <result column="income_total_" property="incomeTotal"/>
+        <result column="sell_cost_" property="sellCost"/>
+        <result column="expenses_amount_" property="expensesAmount"/>
+        <result column="variable_cost_" property="variableCost"/>
+        <result column="distribution_amount_" property="distributionAmount"/>
+        <result column="cost_amount_" property="costAmount"/>
+        <result column="profit_" property="profit"/>
+        <result column="month_" property="month"/>
+        <result column="create_time_" property="createTime"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id_, organ_id_, cooperation_organ_id_, sell_amount_, service_amount_,other_income_, refund_amount_,
+        income_total_,
+        sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, cost_amount_,
+        profit_, month_, create_time_
+    </sql>
+    <select id="get" parameterType="java.lang.Integer" resultMap="OperatingReport">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from operating_report
+        where id_ = #{id}
+    </select>
+    <delete id="delete" parameterType="java.lang.Integer">
+        <!--@mbg.generated-->
+        delete from operating_report
+        where id_ = #{id}
+    </delete>
+    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.OperatingReport"
+            useGeneratedKeys="true">
+        <!--@mbg.generated-->
+        insert into operating_report (organ_id_, cooperation_organ_id_, sell_amount_, service_amount_,other_income_,
+        refund_amount_,
+        income_total_, sell_cost_, expenses_amount_, variable_cost_, distribution_amount_,
+        cost_amount_, profit_, month_, create_time_)
+        values (#{organId}, #{cooperationOrganId}, #{sellAmount}, #{serviceAmount},#{otherIncome}, #{refundAmount},
+        #{incomeTotal}, #{sellCost}, #{expensesAmount}, #{variableCost}, #{distributionAmount},
+        #{costAmount}, #{profit}, #{month}, #{createTime})
+    </insert>
 
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReport">
+        <!--@mbg.generated-->
+        update operating_report
+        <set>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+            <if test="cooperationOrganId != null">
+                cooperation_organ_id_ = #{cooperationOrganId},
+            </if>
+            <if test="sellAmount != null">
+                sell_amount_ = #{sellAmount},
+            </if>
+            <if test="serviceAmount != null">
+                service_amount_ = #{serviceAmount},
+            </if>
+            <if test="otherIncome != null">
+                other_income_ = #{otherIncome},
+            </if>
+            <if test="refundAmount != null">
+                refund_amount_ = #{refundAmount},
+            </if>
+            <if test="incomeTotal != null">
+                income_total_ = #{incomeTotal},
+            </if>
+            <if test="sellCost != null">
+                sell_cost_ = #{sellCost},
+            </if>
+            <if test="expensesAmount != null">
+                expenses_amount_ = #{expensesAmount},
+            </if>
+            <if test="variableCost != null">
+                variable_cost_ = #{variableCost},
+            </if>
+            <if test="distributionAmount != null">
+                distribution_amount_ = #{distributionAmount},
+            </if>
+            <if test="costAmount != null">
+                cost_amount_ = #{costAmount},
+            </if>
+            <if test="profit != null">
+                profit_ = #{profit},
+            </if>
+            <if test="month != null">
+                month_ = #{month},
+            </if>
+            <if test="createTime != null">
+                create_time_ = #{createTime},
+            </if>
+        </set>
+        where id_ = #{id}
+    </update>
 
-  <!-- 分页查询 -->
-  <select id="queryPage" resultMap="OperatingReport" parameterType="map">
-    SELECT opr.*,o.name_ organ_name_,co.name_ school_name_ FROM operating_report opr
-    LEFT JOIN organization o ON o.id_ = opr.organ_id_
-    LEFT JOIN cooperation_organ co ON co.id_= opr.cooperation_organ_id_
-    <include refid="queryPageSql"/>
-    ORDER BY opr.month_ DESC,opr.organ_id_ ASC
-    <include refid="global.limit"/>
-  </select>
 
-  <!-- 查询当前表的总记录数 -->
-  <select id="queryCount" resultType="int">
-    SELECT COUNT(*) FROM operating_report opr
-    <include refid="queryPageSql"/>
-  </select>
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="OperatingReport" parameterType="map">
+        SELECT opr.*,o.name_ organ_name_,co.name_ school_name_ FROM operating_report opr
+        LEFT JOIN organization o ON o.id_ = opr.organ_id_
+        LEFT JOIN cooperation_organ co ON co.id_= opr.cooperation_organ_id_
+        <include refid="queryPageSql"/>
+        ORDER BY opr.month_ DESC,opr.organ_id_ ASC
+        <include refid="global.limit"/>
+    </select>
 
-  <sql id="queryPageSql">
-    <where>
-      <if test="organIdList != null and organIdList != ''">
-        AND FIND_IN_SET(opr.organ_id_,#{organIdList})
-      </if>
-      <if test="cooperationOrganId != null">
-        AND opr.cooperation_organ_id_ = #{cooperationOrganId}
-      </if>
-      <if test="startTime != null">
-        AND opr.month_ >= #{startTime}
-      </if>
-      <if test="endTime != null">
-        AND opr.month_ &lt;= #{endTime}
-      </if>
-    </where>
-  </sql>
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*) FROM operating_report opr
+        <include refid="queryPageSql"/>
+    </select>
+
+    <sql id="queryPageSql">
+        <where>
+            <if test="organIdList != null and organIdList != ''">
+                AND FIND_IN_SET(opr.organ_id_,#{organIdList})
+            </if>
+            <if test="cooperationOrganId != null">
+                AND opr.cooperation_organ_id_ = #{cooperationOrganId}
+            </if>
+            <if test="startTime != null">
+                AND opr.month_ >= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND opr.month_ &lt;= #{endTime}
+            </if>
+        </where>
+    </sql>
+    <select id="getReport" resultMap="OperatingReport" parameterType="map">
+        SELECT * FROM operating_report opr
+        <where>
+            <if test="organId != null">
+                AND organ_id_ = #{organId}
+            </if>
+            <if test="cooperationOrganId != null">
+                AND cooperation_organ_id_ = #{cooperationOrganId}
+            </if>
+            <if test="cooperationOrganId == null">
+                AND cooperation_organ_id_ IS NULL
+            </if>
+            <if test="startTime != null">
+                AND month_ >= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND month_ &lt;= #{endTime}
+            </if>
+        </where>
+        LIMIT 1
+    </select>
 </mapper>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -129,4 +129,8 @@ public interface TaskRemoteService {
 	@GetMapping("task/studentServeRemind")
 	void studentServeRemind();
 
+	//经营报表
+	@GetMapping("task/operatingReport")
+	void operatingReport();
+
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -160,4 +160,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 	public void studentServeRemind() {
 		logger.info("本周应布置课外训练推送失败");
 	}
+
+	@Override
+	public void operatingReport() {
+		logger.info("经营报表生成失败");
+	}
 }

+ 20 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/OperatingReportTask.java

@@ -0,0 +1,20 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class OperatingReportTask extends BaseTask {
+
+    @Autowired
+    private TaskRemoteService taskRemoteService;
+
+    @Override
+    public void execute() throws TaskException {
+        taskRemoteService.operatingReport();
+    }
+}

+ 9 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -74,6 +74,9 @@ public class TaskController extends BaseController {
 	@Autowired
 	private StudentServeService studentServeService;
 
+	@Autowired
+	private OperatingReportService operatingReportService;
+
 	@GetMapping(value = "/refreshUserMusicGroupPaymentStatusTask")
 	// 刷新学员乐团付费状态
 	public void refreshUserMusicGroupPaymentStatusTask(){
@@ -260,4 +263,10 @@ public class TaskController extends BaseController {
 	public void studentServeRemind(){
 		extracurricularExercisesService.studentServeRemind();
 	}
+
+	//经营报表
+	@GetMapping("/operatingReport")
+	public void operatingReport(){
+		operatingReportService.statistics();
+	}
 }