Commit 44cdf0b7 by levphon

首页结清统计

1 parent e52187a8
...@@ -93,18 +93,18 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> { ...@@ -93,18 +93,18 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
/** /**
* 根据权限获取该账户下 离线设备 * 根据权限获取该账户下 离线设备
* *
* @param offlineTime 离线时间 * @param search
* @param offlineSnStr 不计算离线的设备集合
* @return * @return
*/ */
@DataPerm(permTable = "tv", showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
List<StatActivatedVehicleDevice> getOfflineDeviceWithAuth(@Param("offlineTime") long offlineTime, @Param("offlineSnStr") String offlineSnStr); List<StatActivatedVehicleDevice> getOfflineDeviceWithAuth(@Param("search") StatSearch search);
VehicleDevice getVehicleDeviceByVehicleAndSn(@Param("vehicleId") Long vehicleId, @Param("sn") String sn, @Param("bindStatus") Integer bindStatus); VehicleDevice getVehicleDeviceByVehicleAndSn(@Param("vehicleId") Long vehicleId, @Param("sn") String sn, @Param("bindStatus") Integer bindStatus);
/** /**
* 车辆,设备,工单 公共信息 * 车辆,设备,工单 公共信息
*
* @param sn 设备号 * @param sn 设备号
* @return 车辆,设备,工单 公共信息 * @return 车辆,设备,工单 公共信息
*/ */
......
package cn.com.glsx.admin.modules.model.stat; package cn.com.glsx.admin.modules.model.stat;
import cn.com.glsx.admin.modules.model.param.BasicSearch;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class StatSearch { public class StatSearch extends BasicSearch {
private String statPattern; private String statPattern;
private String statScope; private String statScope;
...@@ -13,4 +14,7 @@ public class StatSearch { ...@@ -13,4 +14,7 @@ public class StatSearch {
private String statEndScope; private String statEndScope;
private String appendSql; private String appendSql;
private Long offlineTime;
private String offlineSnStr;
} }
...@@ -77,7 +77,9 @@ public class HomeService extends AbstractCommonService { ...@@ -77,7 +77,9 @@ public class HomeService extends AbstractCommonService {
// Integer activeNumForToday = activeStatList.stream().map(StatCountModel::getCnt1).filter(Objects::nonNull).reduce(0, Integer::sum); // Integer activeNumForToday = activeStatList.stream().map(StatCountModel::getCnt1).filter(Objects::nonNull).reduce(0, Integer::sum);
//方案二 //方案二
List<StatActivatedVehicleDevice> activeDeviceList = vehicleDeviceMapper.getActiveDeviceWithAuth(new StatSearch().setStatPattern("%Y-%m-%d")); StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d");
injectSettled(activeSearch);
List<StatActivatedVehicleDevice> activeDeviceList = vehicleDeviceMapper.getActiveDeviceWithAuth(activeSearch);
List<StatActivatedVehicleDevice> activeTodayList = activeDeviceList.stream().filter(device -> today.equals(device.getActiveTime())).collect(Collectors.toList()); List<StatActivatedVehicleDevice> activeTodayList = activeDeviceList.stream().filter(device -> today.equals(device.getActiveTime())).collect(Collectors.toList());
Set<Long> allBindVehicles = activeDeviceList.stream().map(StatActivatedVehicleDevice::getVehicleId).collect(Collectors.toSet()); Set<Long> allBindVehicles = activeDeviceList.stream().map(StatActivatedVehicleDevice::getVehicleId).collect(Collectors.toSet());
...@@ -104,10 +106,12 @@ public class HomeService extends AbstractCommonService { ...@@ -104,10 +106,12 @@ public class HomeService extends AbstractCommonService {
} }
} }
//设备离线计算时间 StatSearch offlineSearch = new StatSearch().setStatPattern("%Y-%m-%d");
long offlineTime = Constants.OFFLINE_TIME_OTHER; injectSettled(offlineSearch);
offlineSearch.setOfflineTime(Constants.OFFLINE_TIME_OTHER);
offlineSearch.setOfflineSnStr(offlineSnWhitelist);
//离线设备 //离线设备
List<StatActivatedVehicleDevice> offlineDeviceList = vehicleDeviceMapper.getOfflineDeviceWithAuth(offlineTime, offlineSnWhitelist); List<StatActivatedVehicleDevice> offlineDeviceList = vehicleDeviceMapper.getOfflineDeviceWithAuth(offlineSearch);
//设备离线数 //设备离线数
Set<Long> allOfflineDevices = offlineDeviceList.stream().map(StatActivatedVehicleDevice::getId).collect(Collectors.toSet()); Set<Long> allOfflineDevices = offlineDeviceList.stream().map(StatActivatedVehicleDevice::getId).collect(Collectors.toSet());
......
...@@ -115,7 +115,9 @@ ...@@ -115,7 +115,9 @@
<if test="search.appendSql != null and search.appendSql !=''"> <if test="search.appendSql != null and search.appendSql !=''">
${search.appendSql} ${search.appendSql}
</if> </if>
${settleCondition} <if test="search.settleCondition != null and search.settleCondition !=''">
${search.settleCondition}
</if>
</select> </select>
<select id="getActiveNumberWithAuth" resultType="cn.com.glsx.admin.modules.model.stat.StatCountModel"> <select id="getActiveNumberWithAuth" resultType="cn.com.glsx.admin.modules.model.stat.StatCountModel">
...@@ -135,15 +137,17 @@ ...@@ -135,15 +137,17 @@
left join t_device td on td.sn = tvd.sn left join t_device td on td.sn = tvd.sn
left join t_device_location tdl on tdl.sn = td.sn left join t_device_location tdl on tdl.sn = td.sn
WHERE tvd.del_flag = 0 and tv.del_flag = 0 and tvd.bind_status = 1 WHERE tvd.del_flag = 0 and tv.del_flag = 0 and tvd.bind_status = 1
and ((timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{offlineTime} and timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{offlineTime}) and ((timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{search.offlineTime} and timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{search.offlineTime})
or (tdl.last_gps_time is null and tdl.last_bs_time is null) or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{offlineTime}) or (tdl.last_gps_time is null and timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{search.offlineTime})
or (timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{offlineTime} and tdl.last_bs_time is null) or (timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{search.offlineTime} and tdl.last_bs_time is null)
) )
<if test="offlineSnStr != null and offlineSnStr != ''"> <if test="search.offlineSnStr != null and search.offlineSnStr != ''">
and tvd.sn not in (${offlineSnStr}) and tvd.sn not in (${search.offlineSnStr})
</if>
<if test="search.settleCondition != null and search.settleCondition != ''">
${search.settleCondition}
</if> </if>
${settleCondition}
</select> </select>
<select id="getVehicleDeviceByVehicleAndSn" resultMap="BaseResultMap"> <select id="getVehicleDeviceByVehicleAndSn" resultMap="BaseResultMap">
...@@ -202,7 +206,8 @@ ...@@ -202,7 +206,8 @@
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate} and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate}
</if> </if>
<if test="gpsBeginDate != null and gpsBeginDate != '' and gpsEndDate != null and gpsEndDate != ''"> <if test="gpsBeginDate != null and gpsBeginDate != '' and gpsEndDate != null and gpsEndDate != ''">
and (DATE_FORMAT(tdl.last_gps_time,'%Y-%m-%d') between #{gpsBeginDate} and #{gpsEndDate} or DATE_FORMAT(tdl.last_bs_time,'%Y-%m-%d') between #{gpsBeginDate} and #{gpsEndDate}) and (DATE_FORMAT(tdl.last_gps_time,'%Y-%m-%d') between #{gpsBeginDate} and #{gpsEndDate} or DATE_FORMAT(tdl.last_bs_time,'%Y-%m-%d') between #{gpsBeginDate} and
#{gpsEndDate})
</if> </if>
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and( and(
...@@ -244,7 +249,8 @@ ...@@ -244,7 +249,8 @@
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate} and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate}
</if> </if>
<if test="gpsBeginDate != null and gpsBeginDate != '' and gpsEndDate != null and gpsEndDate != ''"> <if test="gpsBeginDate != null and gpsBeginDate != '' and gpsEndDate != null and gpsEndDate != ''">
and (DATE_FORMAT(tdl.last_gps_time,'%Y-%m-%d') between #{gpsBeginDate} and #{gpsEndDate} or DATE_FORMAT(tdl.last_bs_time,'%Y-%m-%d') between #{gpsBeginDate} and #{gpsEndDate}) and (DATE_FORMAT(tdl.last_gps_time,'%Y-%m-%d') between #{gpsBeginDate} and #{gpsEndDate} or DATE_FORMAT(tdl.last_bs_time,'%Y-%m-%d') between #{gpsBeginDate} and
#{gpsEndDate})
</if> </if>
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and( and(
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!