From fd7979f9109aea3922d158b13700b1f1e99b9408 Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期五, 17 五月 2024 15:19:27 +0800
Subject: [PATCH] 功能调整
---
data-server/src/main/resources/mapper/DataReportingMapper.xml | 155 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 117 insertions(+), 38 deletions(-)
diff --git a/data-server/src/main/resources/mapper/DataReportingMapper.xml b/data-server/src/main/resources/mapper/DataReportingMapper.xml
index 9a931e2..0d77edc 100644
--- a/data-server/src/main/resources/mapper/DataReportingMapper.xml
+++ b/data-server/src/main/resources/mapper/DataReportingMapper.xml
@@ -5,37 +5,37 @@
<mapper namespace="com.yuanchu.mom.mapper.DataReportingMapper">
<resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.DataReporting">
- <id property="id" column="id" jdbcType="INTEGER"/>
- <result property="department" column="department" jdbcType="VARCHAR"/>
- <result property="registrant" column="registrant" jdbcType="VARCHAR"/>
- <result property="product" column="product" jdbcType="VARCHAR"/>
- <result property="channel" column="channel" jdbcType="VARCHAR"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="showNum" column="show_num" jdbcType="INTEGER"/>
- <result property="click" column="click" jdbcType="INTEGER"/>
- <result property="accountConsumption" column="account_consumption" jdbcType="DECIMAL"/>
- <result property="rebateConsumption" column="rebate_consumption" jdbcType="DECIMAL"/>
- <result property="consumption" column="consumption" jdbcType="DECIMAL"/>
- <result property="discountedConsumption" column="discounted_consumption" jdbcType="DECIMAL"/>
- <result property="fansAdd" column="fans_add" jdbcType="INTEGER"/>
- <result property="actualCost" column="actual_cost" jdbcType="DECIMAL"/>
- <result property="internalCosts" column="internal_costs" jdbcType="DECIMAL"/>
- <result property="customerCosts" column="customer_costs" jdbcType="DECIMAL"/>
- <result property="profit" column="profit" jdbcType="DECIMAL"/>
- <result property="agentRebate" column="agent_rebate" jdbcType="DECIMAL"/>
- <result property="customerRebate" column="customer_rebate" jdbcType="DECIMAL"/>
- <result property="remark" column="remark" jdbcType="DECIMAL"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
- <result property="createUser" column="create_user" jdbcType="VARCHAR"/>
- <result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
+ <id property="id" column="id" jdbcType="INTEGER"/>
+ <result property="department" column="department" jdbcType="VARCHAR"/>
+ <result property="registrant" column="registrant" jdbcType="VARCHAR"/>
+ <result property="product" column="product" jdbcType="VARCHAR"/>
+ <result property="channel" column="channel" jdbcType="VARCHAR"/>
+ <result property="name" column="name" jdbcType="VARCHAR"/>
+ <result property="showNum" column="show_num" jdbcType="INTEGER"/>
+ <result property="click" column="click" jdbcType="INTEGER"/>
+ <result property="accountConsumption" column="account_consumption" jdbcType="DECIMAL"/>
+ <result property="rebateConsumption" column="rebate_consumption" jdbcType="DECIMAL"/>
+ <result property="consumption" column="consumption" jdbcType="DECIMAL"/>
+ <result property="discountedConsumption" column="discounted_consumption" jdbcType="DECIMAL"/>
+ <result property="fansAdd" column="fans_add" jdbcType="INTEGER"/>
+ <result property="actualCost" column="actual_cost" jdbcType="DECIMAL"/>
+ <result property="internalCosts" column="internal_costs" jdbcType="DECIMAL"/>
+ <result property="customerCosts" column="customer_costs" jdbcType="DECIMAL"/>
+ <result property="profit" column="profit" jdbcType="DECIMAL"/>
+ <result property="agentRebate" column="agent_rebate" jdbcType="DECIMAL"/>
+ <result property="customerRebate" column="customer_rebate" jdbcType="DECIMAL"/>
+ <result property="remark" column="remark" jdbcType="DECIMAL"/>
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+ <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+ <result property="createUser" column="create_user" jdbcType="VARCHAR"/>
+ <result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
</resultMap>
<select id="selectDataReportingDtoPageList" resultType="com.yuanchu.mom.dto.DataReportingPageDto">
select * from (
select dr.*,u1.name create_user_name,u2.name update_user_name from data_reporting dr
- left join user u1 on dr.create_user = u1.id
- left join user u2 on dr.update_user = u2.id
+ left join user u1 on dr.create_user = u1.id
+ left join user u2 on dr.update_user = u2.id
) a
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
@@ -43,7 +43,8 @@
</select>
<select id="selectProductCountDtoPageList" resultType="com.yuanchu.mom.dto.ProductCountDto">
select * from (
- select update_time, create_time, product, sum(consumption) consumption, sum(fans_add) fans_add, sum(customer_costs) customer_costs, create_user
+ select update_time, create_time, product, sum(consumption) consumption, sum(fans_add) fans_add,
+ sum(customer_costs) customer_costs, create_user
from data_reporting
group by product,date_format(create_time, '%Y-%m-%d')
) a
@@ -53,47 +54,125 @@
</select>
<select id="selectRegistrantCountDtoPageList" resultType="com.yuanchu.mom.dto.RegistrantCountDto">
select * from (
- select id, department, registrant, product, name, sum(show_num) show_num, sum(click) click, sum(account_consumption)account_consumption, sum(rebate_consumption) rebate_consumption,(sum(rebate_consumption)+sum(remark)) rebate_consumption2, sum(discounted_consumption) discounted_consumption, sum(fans_add) fans_add, sum(actual_cost) actual_cost, sum(customer_costs) customer_costs, sum(profit) profit, sum(agent_rebate) agent_rebate, sum(customer_rebate) customer_rebate, sum(remark) remark, create_time, update_time, create_user
+ select department,
+ registrant,
+ name2,
+ product,
+ name,
+ sum(show_num) show_num,
+ sum(click) click,
+ sum(account_consumption) account_consumption,
+ sum(rebate_consumption)
+ rebate_consumption,
+ (sum(rebate_consumption) + sum(remark)) rebate_consumption2,
+ sum(discounted_consumption)
+ discounted_consumption,
+ sum(fans_add) fans_add,
+ sum(actual_cost) actual_cost,
+ sum(customer_costs)
+ customer_costs,
+ sum(profit) profit,
+ sum(agent_rebate) agent_rebate,
+ sum(customer_rebate) customer_rebate,
+ sum(remark) remark,
+ date_format(create_time, '%Y-%m-%d') create_time,
+ create_user
from data_reporting
- group by registrant,date_format(create_time, '%Y-%m-%d')
+ where create_time >= #{startTime} and create_time <= #{endTime}
+ group by department,product,name2,date_format(create_time, '%Y-%m')
) a
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
</if>
</select>
<select id="getDataFor1" resultType="java.util.Map">
- select COALESCE(sum(account_consumption), 0) data1, COALESCE(sum(consumption), 0) data2, COALESCE(sum(customer_costs),0) data3, COALESCE(sum(actual_cost), 0) data4
+ select COALESCE(sum(account_consumption), 0) data1,
+ COALESCE(sum(consumption), 0) data2,
+ COALESCE(sum(customer_costs), 0) data3,
+ COALESCE(sum(actual_cost), 0) data4
from data_reporting
- where date(create_time) like CURDATE()
+ where date(create_time) like (CURDATE() - INTERVAL 1 DAY)
</select>
<select id="getDataFor2" resultType="java.util.Map">
- SELECT sum(account_consumption) account_consumptions, DATE_FORMAT(create_time, '%m-%d') `date`, DATE_FORMAT(create_time, '%y-%m-%d') time
+ SELECT sum(account_consumption) account_consumptions,
+ DATE_FORMAT(create_time, '%m-%d') `date`,
+ DATE_FORMAT(create_time, '%y-%m-%d') time
FROM data_reporting
group by DATE_FORMAT(create_time, '%y-%m-%d')
having DATE_SUB(CURDATE(), INTERVAL 7 DAY) < time
- and time <= CURDATE()
+ and time < CURDATE()
</select>
<select id="getDataFor3" resultType="java.util.Map">
- SELECT sum(consumption) consumption, DATE_FORMAT(create_time, '%m-%d') `date`, DATE_FORMAT(create_time, '%y-%m-%d') time
+ SELECT sum(consumption) consumption,
+ DATE_FORMAT(create_time, '%m-%d') `date`,
+ DATE_FORMAT(create_time, '%y-%m-%d') time
FROM data_reporting
group by DATE_FORMAT(create_time, '%y-%m-%d')
having DATE_SUB(CURDATE(), INTERVAL 7 DAY) < time
- and time <= CURDATE()
+ and time < CURDATE()
</select>
<select id="getDataFor4" resultType="java.util.Map">
select product, sum(customer_costs) customerCosts
from data_reporting
group by product
- order by customerCosts desc limit 7
+ order by customerCosts desc
+ limit 7
</select>
<select id="getDataFor5" resultType="java.util.Map">
select product, sum(actual_cost) actualCost
from data_reporting
group by product
- order by actualCost desc limit 7
+ order by actualCost desc
+ limit 7
</select>
<select id="selectUser" resultType="java.util.Map">
- select user.department, user.name, user.account from user
+ select user.department, user.name, user.account
+ from user
where id = #{userId}
</select>
+
+ <select id="selectDataComparisonDtoPageList" resultType="com.yuanchu.mom.dto.DataComparisonDto">
+ select a.uName account,
+ a.name name,
+ a.account_consumption consumption,
+ a.product,
+ COALESCE(b.uName, #{dataComparisonDto.comparisonName}) comparisonAccount,
+ b.name comparisonName,
+ b.account_consumption comparisonConsumption,
+ b.uDepartment,
+ b.uCompany
+ from (select dr1.*, user.id uId, user.name uName, user.account
+ from data_reporting dr1
+ join user on dr1.create_user = user.id
+ where date_format(dr1.create_time, '%Y-%m-%d') =
+ date_format(#{dataComparisonDto.createTime}, '%Y-%m-%d')
+ and user.name = #{dataComparisonDto.name}) a
+ left join (select dr2.*, user.id uId, user.name uName, user.account,user.department uDepartment,user.company uCompany
+ from data_reporting dr2
+ join user on dr2.create_user = user.id
+ where date_format(dr2.create_time, '%Y-%m-%d') =
+ date_format(#{dataComparisonDto.createTime}, '%Y-%m-%d')
+ and user.name = #{dataComparisonDto.comparisonName}) b
+ on a.name = b.name
+ and a.product = b.product
+ where (a.account_consumption != b.account_consumption
+ or b.account_consumption is null)
+ </select>
+ <select id="selectDataReportingForCreateUserNames" resultType="java.lang.String">
+ select distinct u1.name from data_reporting dr
+ left join user u1 on dr.create_user = u1.id
+ where dr.create_time like concat('%', #{time}, '%')
+ </select>
+
+ <select id="selectDataReportingForProduct" resultType="java.lang.String">
+ select distinct product from data_reporting
+ where create_time like concat('%', #{time}, '%')
+ </select>
+
+ <select id="getUserNameById" resultType="java.lang.String">
+ select account from user where id = #{id}
+ </select>
+ <select id="getUserDepartmentById" resultType="java.lang.String">
+ select department from user where id = #{id}
+ </select>
</mapper>
--
Gitblit v1.9.3