Browse Source

增加经营报表接口

周箭河 5 years ago
parent
commit
52247b2c2e

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

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface OperatingReportDao extends BaseDAO<Integer, OperatingReport> {
+
+}

+ 238 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReport.java

@@ -0,0 +1,238 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel(value="com-ym-OperatingReport")
+public class OperatingReport {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    /**
+    * 分部id
+    */
+    @ApiModelProperty(value="分部id")
+    private Integer organId;
+
+    @ApiModelProperty(value="分部名称")
+    private String organName;
+
+    /**
+    * 学校id
+    */
+    @ApiModelProperty(value="学校id")
+    private Integer schoolId;
+
+    @ApiModelProperty(value="学校名称")
+    private String schoolName;
+
+    /**
+    * 销售收入
+    */
+    @ApiModelProperty(value="销售收入")
+    private BigDecimal sellAmount;
+
+    /**
+    * 服务收入
+    */
+    @ApiModelProperty(value="服务收入")
+    private BigDecimal serviceAmount;
+
+    /**
+    * 业务退费
+    */
+    @ApiModelProperty(value="业务退费")
+    private BigDecimal refundAmount;
+
+    /**
+    * 收入合计
+    */
+    @ApiModelProperty(value="收入合计")
+    private BigDecimal incomeTotal;
+
+    /**
+    * 销售成本
+    */
+    @ApiModelProperty(value="销售成本")
+    private BigDecimal sellCost;
+
+    /**
+    * 固定支出
+    */
+    @ApiModelProperty(value="固定支出")
+    private BigDecimal expensesAmount;
+
+    /**
+    * 变动支出
+    */
+    @ApiModelProperty(value="变动支出")
+    private BigDecimal variableCost;
+
+    /**
+    * 分摊费用
+    */
+    @ApiModelProperty(value="分摊费用")
+    private BigDecimal distributionAmount;
+
+    /**
+    * 成本费用合计
+    */
+    @ApiModelProperty(value="成本费用合计")
+    private BigDecimal costAmount;
+
+    /**
+    * 利润
+    */
+    @ApiModelProperty(value="利润")
+    private BigDecimal profit;
+
+    /**
+    * 月份
+    */
+    @ApiModelProperty(value="月份")
+    private Date month;
+
+    /**
+    * 生成时间
+    */
+    @ApiModelProperty(value="生成时间")
+    private Date createTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public BigDecimal getSellAmount() {
+        return sellAmount;
+    }
+
+    public void setSellAmount(BigDecimal sellAmount) {
+        this.sellAmount = sellAmount;
+    }
+
+    public BigDecimal getServiceAmount() {
+        return serviceAmount;
+    }
+
+    public void setServiceAmount(BigDecimal serviceAmount) {
+        this.serviceAmount = serviceAmount;
+    }
+
+    public BigDecimal getRefundAmount() {
+        return refundAmount;
+    }
+
+    public void setRefundAmount(BigDecimal refundAmount) {
+        this.refundAmount = refundAmount;
+    }
+
+    public BigDecimal getIncomeTotal() {
+        return incomeTotal;
+    }
+
+    public void setIncomeTotal(BigDecimal incomeTotal) {
+        this.incomeTotal = incomeTotal;
+    }
+
+    public BigDecimal getSellCost() {
+        return sellCost;
+    }
+
+    public void setSellCost(BigDecimal sellCost) {
+        this.sellCost = sellCost;
+    }
+
+    public BigDecimal getExpensesAmount() {
+        return expensesAmount;
+    }
+
+    public void setExpensesAmount(BigDecimal expensesAmount) {
+        this.expensesAmount = expensesAmount;
+    }
+
+    public BigDecimal getVariableCost() {
+        return variableCost;
+    }
+
+    public void setVariableCost(BigDecimal variableCost) {
+        this.variableCost = variableCost;
+    }
+
+    public BigDecimal getDistributionAmount() {
+        return distributionAmount;
+    }
+
+    public void setDistributionAmount(BigDecimal distributionAmount) {
+        this.distributionAmount = distributionAmount;
+    }
+
+    public BigDecimal getCostAmount() {
+        return costAmount;
+    }
+
+    public void setCostAmount(BigDecimal costAmount) {
+        this.costAmount = costAmount;
+    }
+
+    public BigDecimal getProfit() {
+        return profit;
+    }
+
+    public void setProfit(BigDecimal profit) {
+        this.profit = profit;
+    }
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+}

+ 16 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java

@@ -18,12 +18,18 @@ public class SellOrder {
     private Integer organId;
 
     /**
-    * 学校id
-    */
+     * 学校id
+     */
     @ApiModelProperty(value="学校id")
     private Integer schoolId;
 
     /**
+     * 学校名称
+     */
+    @ApiModelProperty(value="学校名称")
+    private String schoolName;
+
+    /**
     * 交易流水号
     */
     @ApiModelProperty(value="交易流水号")
@@ -328,4 +334,12 @@ public class SellOrder {
     public void setOrganName(String organName) {
         this.organName = organName;
     }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
 }

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

@@ -0,0 +1,62 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+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 Date month;
+
+    private Date startTime;
+
+    private Date endTime;
+
+    public String getOrganIdList() {
+        return organIdList;
+    }
+
+    public void setOrganIdList(String organIdList) {
+        this.organIdList = organIdList;
+    }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+}

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

@@ -0,0 +1,10 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.dal.entity.StudentVisit;
+import com.ym.mec.common.service.BaseService;
+
+
+public interface OperatingReportService extends BaseService<Integer, OperatingReport> {
+
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.service.OperatingReportService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, OperatingReport> implements OperatingReportService {
+
+    @Autowired
+    private OperatingReportDao operatingReportDao;
+
+
+    @Override
+    public BaseDAO<Integer, OperatingReport> getDAO() {
+        return operatingReportDao;
+    }
+
+}

+ 135 - 0
mec-biz/src/main/resources/config/mybatis/OperatingReportMapper.xml

@@ -0,0 +1,135 @@
+<?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="school_id_" property="schoolId" />
+    <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_, school_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_, school_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}, #{schoolId}, #{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="schoolId != null">
+        school_id_ = #{schoolId},
+      </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>
+
+
+  <!-- 分页查询 -->
+  <select id="queryPage" resultMap="OperatingReport" parameterType="map">
+    SELECT opr.*,o.name_ organ_name_ FROM operating_report opr
+    LEFT JOIN organization o ON o.id_ = opr.organ_id_
+    LEFT JOIN school s ON s.id_= opr.school_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>
+
+  <sql id="queryPageSql">
+    <where>
+      <if test="organIdList != null and organIdList != ''">
+        AND FIND_IN_SET(opr.organ_id_,#{organIdList})
+      </if>
+      <if test="schoolId != null">
+        AND opr.school_id_ = #{schoolId}
+      </if>
+      <if test="startTime != null">
+        AND opr.month_ >= #{startTime}
+      </if>
+      <if test="endTime != null">
+        AND opr.month_ &lt;= #{endTime}
+      </if>
+    </where>
+  </sql>
+</mapper>

+ 3 - 1
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -7,6 +7,7 @@
         <id column="id_" property="id"/>
         <result column="organ_id_" property="organId"/>
         <result column="school_id_" property="schoolId"/>
+        <result column="school_name_" property="schoolName"/>
         <result column="trans_no_" property="transNo"/>
         <result column="order_no_" property="orderNo"/>
         <result column="order_id_" property="orderId"/>
@@ -143,9 +144,10 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="SellOrder" parameterType="map">
-        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_ FROM sell_order so
+        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,s.name_ school_name_ FROM sell_order so
         LEFT JOIN sys_user su ON so.user_id_ = su.id_
         LEFT JOIN organization o ON o.id_ = so.organ_id_
+        LEFT JOIN school s ON s.id_= so.school_id_
         <include refid="queryPageSql"/>
         ORDER BY so.sell_time_ DESC
         <include refid="global.limit"/>

+ 65 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportController.java

@@ -0,0 +1,65 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.dal.page.OperatingReportQueryInfo;
+import com.ym.mec.biz.service.OperatingReportService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.date.DateUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Api(tags = "经营报表服务")
+@RequestMapping("operatingReport")
+@RestController
+public class OperatingReportController extends BaseController {
+
+    @Autowired
+    private OperatingReportService operatingReportService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private EmployeeDao employeeDao;
+
+    @ApiOperation("报表列表")
+    @GetMapping(value = "/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('sellOrder/queryPage')")
+    public HttpResponseResult<PageInfo<OperatingReport>> queryPage(OperatingReportQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganIdList())) {
+                queryInfo.setOrganIdList(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                return failed("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))) {
+                    return failed("非法请求");
+                }
+            }
+        }
+        if (queryInfo.getMonth() != null) {
+            queryInfo.setStartTime(DateUtil.getFirstDayOfMonth(queryInfo.getMonth()));
+            queryInfo.setEndTime(DateUtil.getLastDayOfMonth(queryInfo.getMonth()));
+        }
+        return succeed(operatingReportService.queryPage(queryInfo));
+    }
+}