Commit 405ce916 by 杨林龙

优化不在店统计逻辑,将不在店每天统计数据落库

1 parent 708d7b85
......@@ -82,5 +82,11 @@ public class ElectricInStoreDrive implements Serializable {
@Transient
private Integer instoreCnt;
/**
* 每天在店数据的年月信息
*/
@Transient
private String statDate;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import cn.com.glsx.admin.modules.entity.ElectricInStoreDrive;
import cn.com.glsx.admin.modules.mapper.ElectricInStoreDriveMapper;
import cn.com.glsx.admin.modules.model.export.ElectricInStoreExport;
import cn.com.glsx.admin.modules.model.param.ElectricInStoreSearch;
import cn.hutool.core.date.DateUtil;
import com.glsx.plat.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -73,7 +72,7 @@ public class ElectricInStoreDriveService {
// 组合每一天的数据
for (ElectricInStoreDrive inStoreDrive : inStoreDataList) {
// 设置报表统计时间
electricInStoreExport.setStatDate(DateUtil.format(inStoreDrive.getGpsTime(), "yyyy-MM"));
electricInStoreExport.setStatDate(inStoreDrive.getStatDate());
summation = summation + inStoreDrive.getInstoreCnt();
switch (inStoreDrive.getDayOfMonth()) {
case 1:
......
......@@ -19,7 +19,7 @@
<resultMap id="InStoreDataMap" type="cn.com.glsx.admin.modules.entity.ElectricInStoreDrive">
<result property="instoreCnt" column="instoreCnt" jdbcType="INTEGER"/>
<result property="gpsTime" column="gps_time" jdbcType="TIMESTAMP"/>
<result property="statDate" column="statDate" jdbcType="VARCHAR"/>
<result property="dayOfMonth" column="dayOfMonth" jdbcType="INTEGER"/>
</resultMap>
......@@ -61,19 +61,33 @@
order by tu.account
</select>
<!-- <select id="getInStoreDataList" resultMap="InStoreDataMap">-->
<!-- select-->
<!-- case when sum(case when teid.gps_state = 2 then 1 else 0 end) = count(1) then 1 else 0 end as instoreCnt,-->
<!-- teid.gps_time ,-->
<!-- day(teid.gps_time) as dayOfMonth-->
<!-- from t_electric_instore_drive teid-->
<!-- left join t_vehicle_device tvd on tvd.id = teid.vd_id-->
<!-- <where>-->
<!-- <if test="year != null and year != '' and month != null and month != '' ">-->
<!-- left(teid.gps_time,7) = CONCAT(#{year},'-',#{month})-->
<!-- </if>-->
<!-- and tvd.vehicle_id = #{vehicleId}-->
<!-- </where>-->
<!-- group by left(teid.gps_time,10)-->
<!-- </select>-->
<select id="getInStoreDataList" resultMap="InStoreDataMap">
select
case when sum(case when teid.gps_state = 2 then 1 else 0 end) = count(1) then 1 else 0 end as instoreCnt,
teid.gps_time ,
day(teid.gps_time) as dayOfMonth
from t_electric_instore_drive teid
left join t_vehicle_device tvd on tvd.id = teid.vd_id
select tsid.instore_num as instoreCnt,
left(tsid.instore_time, 7) as statDate,
day(str_to_date(tsid.instore_time, '%Y-%m-%d')) as dayOfMonth
from t_statistics_instore_drive tsid
left join t_vehicle_device tvd on tvd.id = tsid.vd_id
<where>
<if test="year != null and year != '' and month != null and month != '' ">
left(teid.gps_time,7) = CONCAT(#{year},'-',#{month})
left(tsid.instore_time,7) = CONCAT(#{year},'-',#{month})
</if>
and tvd.vehicle_id = #{vehicleId}
</where>
group by left(teid.gps_time,10)
</select>
</mapper>
......@@ -300,7 +300,7 @@ public class ElectricInStoreDriveServiceTest {
@Test
public void test03() {
ElectricInStoreSearch search = new ElectricInStoreSearch();
search.setVehicleId(5498L);
search.setVehicleId(39L);
List<ElectricInStoreDrive> inStoreDataList = inStoreDriveMapper.getInStoreDataList(search);
System.out.println("inStoreDataList = " + JSON.toJSONString(inStoreDataList));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!