提交 0dcf5400 编写于 作者: Hello 码上秃's avatar Hello 码上秃

功能开发__获取首页基础数据信息(今日简报部分数据)

上级 86c71149
package com.huike.web.controller.report;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -29,4 +30,13 @@ public class IndexController {
@RequestParam("endCreateTime") String endCreateTime){
return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
}
/**
* 今日简报数据展示
* @return
*/
@GetMapping("/getTodayInfo")
public AjaxResult getTodayInfo() {
return AjaxResult.success(reportService.getTodayInfo());
}
}
\ No newline at end of file
......@@ -57,8 +57,39 @@ public interface ReportMapper {
@Param("endTime") String endCreateTime,
@Param("username") String username);
/**=========================================今日简报========================================*/
/**
* 获取线索数量
* @param today 当前日期
* @param userId 用户Id
* @return
*/
Integer getTodayCluesNum(@Param("today") String today, @Param("userId") Long userId);
/**
* 获取商机数量
* @param today 当前日期
* @param userId 用户Id
* @return
*/
Integer getTodayBusinessNum(@Param("today") String today, @Param("userId") Long userId);
/**
* 获取合同数量
* @param today 当前日期
* @param username 用户名称
* @return
*/
Integer getTodayContractNum(@Param("today") String today, @Param("username") String username);
/**
* 获取合同金额
* @param today 当前日期
* @param username 用户名称
* @return
*/
Double getTodaySalesAmount(@Param("today") String today, @Param("username") String username);
/**=========================================待办========================================*/
......
......@@ -107,5 +107,9 @@ public interface IReportService {
*/
IndexBaseInfoVO getBaseInfo(String beginCreateTime, String endCreateTime);
/**
* 今日简报数据展示
* @return
*/
IndexTodayInfoVO getTodayInfo();
}
......@@ -12,6 +12,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import com.huike.common.utils.DateUtils;
import com.huike.report.domain.vo.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -368,4 +369,34 @@ public class ReportServiceImpl implements IReportService {
return result;
}
/**
* 今日简报数据展示
* @return
*/
@Override
public IndexTodayInfoVO getTodayInfo() {
// 1 构建一个空的结果集对象
IndexTodayInfoVO result = new IndexTodayInfoVO();
// 2.1 查询需要用到用户ID 调用工具类获取用户ID
Long userId = SecurityUtils.getUserId();
// 2.2 查询需要用到用户ID 调用工具类获取用户ID
String username = SecurityUtils.getUsername();
// 2.3 查询需要用到当前日期
String today = DateUtils.getDate();
try {
//3 封装结果集对象
result.setTodayCluesNum(reportMpper.getTodayCluesNum(today,userId));
result.setTodayBusinessNum(reportMpper.getTodayBusinessNum(today,userId));
result.setTodayContractNum(reportMpper.getTodayContractNum(today,username));
result.setTodaySalesAmount(reportMpper.getTodaySalesAmount( today,username));
}catch (Exception e) {
e.printStackTrace();
return null;
}
//4 返回结果集对象
return result;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huike.report.mapper.ReportMapper">
<!--=========================================基本数据========================================-->
<select id="getCluesNum" resultType="Integer">
SELECT COUNT(id) AS cluesNum FROM `tb_clue`
WHERE id IN (
......@@ -65,4 +66,60 @@
AND #{endTime}
</select>
<!--=========================================今日简报========================================-->
<select id="getTodayCluesNum" resultType="Integer">
SELECT
COUNT( id ) AS cluesNum
FROM
`tb_clue`
WHERE id IN (
SELECT
assign_id
FROM
tb_assign_record
WHERE
type = 0
AND latest = 1
AND DATE_FORMAT( create_time, "%y-%-%d" ) = DATE_FORMAT( #{today}, "%y-%-%d" )
AND user_id = #{userId}
)
</select>
<select id="getTodayBusinessNum" resultType="Integer">
SELECT
COUNT( id ) AS businessNum
FROM
`tb_business`
WHERE id IN (
SELECT
assign_id
FROM
tb_assign_record
WHERE
type = 1
AND latest = 1
AND DATE_FORMAT( create_time, "%y-%-%d" ) = DATE_FORMAT( #{today}, "%y-%-%d" )
AND user_id = #{userId}
)
</select>
<select id="getTodayContractNum" resultType="Integer">
SELECT
COUNT(DISTINCT(id)) AS contractNum
FROM
`tb_contract`
WHERE
create_by = #{username}
AND DATE_FORMAT(tb_contract.`create_time`, '%Y-%m-%d') = DATE_FORMAT(#{today}, '%Y-%m-%d')
</select>
<select id="getTodaySalesAmount" resultType="Double">
SELECT
CAST(IFNULL(SUM(tb_contract.contract_order),0) AS DECIMAL (30, 2)) AS salesAmount
FROM
tb_contract
WHERE
create_by = 'lisi'
AND DATE_FORMAT(tb_contract.`create_time`, '%Y-%m-%d') = DATE_FORMAT(#{today}, '%Y-%m-%d')
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册