From b83bf6316bc81ba3e0eda5e934636bd8ee4c8304 Mon Sep 17 00:00:00 2001
From: “zhuo” <“zhuo@itcast.cn”>
Date: 星期一, 08 一月 2024 17:30:19 +0800
Subject: [PATCH] 员工数据对比

---
 data-server/src/main/resources/mapper/DataReportingMapper.xml |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/data-server/src/main/resources/mapper/DataReportingMapper.xml b/data-server/src/main/resources/mapper/DataReportingMapper.xml
index 5e626cc..22ea781 100644
--- a/data-server/src/main/resources/mapper/DataReportingMapper.xml
+++ b/data-server/src/main/resources/mapper/DataReportingMapper.xml
@@ -11,7 +11,7 @@
             <result property="product" column="product" jdbcType="VARCHAR"/>
             <result property="channel" column="channel" jdbcType="VARCHAR"/>
             <result property="name" column="name" jdbcType="VARCHAR"/>
-            <result property="show" column="show" jdbcType="INTEGER"/>
+            <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"/>
@@ -45,7 +45,7 @@
         select * from (
         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
+        group by product,date_format(create_time, '%Y-%m-%d')
         ) a
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             ${ew.customSqlSegment}
@@ -53,9 +53,9 @@
     </select>
     <select id="selectRegistrantCountDtoPageList" resultType="com.yuanchu.mom.dto.RegistrantCountDto">
         select * from (
-        select id, department, registrant, product, name, sum(`show`) `show`, 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 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
         from data_reporting
-        group by registrant
+        group by registrant,date_format(create_time, '%Y-%m-%d')
         ) a
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             ${ew.customSqlSegment}
@@ -92,4 +92,36 @@
         group by product
         order by actualCost desc limit 7
     </select>
+    <select id="selectUser" resultType="java.util.Map">
+        select user.department, user.name, user.account from user
+        where id = #{userId}
+    </select>
+
+    <select id="selectDataComparisonDtoPageList" resultType="com.yuanchu.mom.dto.DataComparisonDto">
+        select a.account account,
+               a.name name,
+               a.account_consumption consumption,
+               a.create_time createTime,
+               b.account comparisonAccount,
+               b.name comparisonName,
+               b.account_consumption comparisonConsumption,
+               b.create_time comparisonCreateTime
+        from (select user.account,
+                     user.name,
+                     dr1.account_consumption,
+                     dr1.create_time
+              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 like concat('%', #{dataComparisonDto.name}, '%')) a,
+             (select user.account,
+                     user.name,
+                     dr2.account_consumption,
+                     dr2.create_time
+              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 like concat('%', #{dataComparisonDto.comparisonName}, '%')) b
+        where a.account_consumption != b.account_consumption
+    </select>
 </mapper>

--
Gitblit v1.9.3