Commit 6ec636de by 杨林龙

Merge remote-tracking branch 'origin/develop' into develop

2 parents 391aea73 7019cd8e
......@@ -41,7 +41,7 @@ public class OpereportController extends AbstractController {
@GetMapping(value = "/vehicle/export")
public R vehicleExport(ReportVehicleSearch search) {
List<ReportVehicleExport> list = opereportService.vehicleExport(search);
String url = super.uploadExcel(list, "车辆列表_" + DateUtils.formatSerial(new Date()), ReportVehicleExport.class);
String url = super.uploadExcel(list, "运营统计报表(车辆维度)_" + DateUtils.formatSerial(new Date()), ReportVehicleExport.class);
return R.ok().data(url);
}
......@@ -56,7 +56,7 @@ public class OpereportController extends AbstractController {
@GetMapping(value = "/device/export")
public R deviceExport(ReportDeviceSearch search) {
List<ReportDeviceExport> list = opereportService.deviceExport(search);
String url = super.uploadExcel(list, "设备列表_" + DateUtils.formatSerial(new Date()), ReportDeviceExport.class);
String url = super.uploadExcel(list, "运营统计报表(设备维度)_" + DateUtils.formatSerial(new Date()), ReportDeviceExport.class);
return R.ok().data(url);
}
......
......@@ -93,18 +93,18 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
/**
* 根据权限获取该账户下 离线设备
*
* @param offlineTime 离线时间
* @param offlineSnStr 不计算离线的设备集合
* @param search
* @return
*/
@DataPerm(permTable = "tv", 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 设备号
* @return 车辆,设备,工单 公共信息
*/
......
......@@ -13,21 +13,21 @@ public class ReportDeviceSearch extends BasicSearch {
/**
* 激活开始时间
*/
private String activateBeginTime;
private String activateBeginDate;
/**
* 激活结束时间
*/
private String activateEndTime;
private String activateEndDate;
/**
* 定位开始时间
*/
private String gpsBeginTime;
private String gpsBeginDate;
/**
* 定位截至时间
*/
private String gpsEndTime;
private String gpsEndDate;
}
......@@ -13,21 +13,21 @@ public class ReportVehicleSearch extends BasicSearch {
/**
* 激活开始时间
*/
private String activateBeginTime;
private String activateBeginDate;
/**
* 激活结束时间
*/
private String activateEndTime;
private String activateEndDate;
/**
* 工单接收开始时间
*/
private String orderBeginTime;
private String orderBeginDate;
/**
* 工单接收截至时间
*/
private String orderEndTime;
private String orderEndDate;
}
package cn.com.glsx.admin.modules.model.stat;
import cn.com.glsx.admin.modules.model.param.BasicSearch;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class StatSearch {
public class StatSearch extends BasicSearch {
private String statPattern;
private String statScope;
......@@ -13,4 +14,7 @@ public class StatSearch {
private String statEndScope;
private String appendSql;
private Long offlineTime;
private String offlineSnStr;
}
......@@ -2,8 +2,8 @@ package cn.com.glsx.admin.modules.remote;
import cn.com.glsx.admin.modules.entity.Device;
import cn.com.glsx.admin.modules.mapper.DeviceMapper;
import cn.com.glsx.devicemonitor.api.dto.request.GpsBsFirstBatchRequest;
import cn.com.glsx.devicemonitor.api.dto.LngLatDTO;
import cn.com.glsx.devicemonitor.api.dto.request.GpsBsFirstBatchRequest;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import cn.com.glsx.devicemonitor.api.dto.response.LngLatAddressDTO;
import cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum;
......
......@@ -77,7 +77,9 @@ public class HomeService extends AbstractCommonService {
// 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());
Set<Long> allBindVehicles = activeDeviceList.stream().map(StatActivatedVehicleDevice::getVehicleId).collect(Collectors.toSet());
......@@ -104,10 +106,12 @@ public class HomeService extends AbstractCommonService {
}
}
//设备离线计算时间
long offlineTime = Constants.OFFLINE_TIME_OTHER;
StatSearch offlineSearch = new StatSearch().setStatPattern("%Y-%m-%d");
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());
......
......@@ -185,7 +185,7 @@ public class OpereportService extends AbstractCommonService {
log.info("总处理条数:{},总处理批次:{},开始处理第{}批({})", dataList.size(), partList.size(), i, subSnList.size());
CompletableFuture<Map<String, GpsBsData>> completableFuture = CompletableFuture.supplyAsync(() -> remoteGpsBsService.getLastGpsBsBySns(subSnList), threadPoolTaskExecutor)
CompletableFuture<Map<String, GpsBsData>> completableFuture = CompletableFuture.supplyAsync(() -> remoteGpsBsService.getLastGpsBsBatchBySns(subSnList))
.exceptionally(Error -> Maps.newHashMap());
futures[i] = completableFuture;
......
......@@ -61,7 +61,7 @@ public class VehicleDeviceService {
*/
public void saveSnToVehicleId(String sn, Vehicle vehicle) {
DeviceDTO deviceDTO = new DeviceDTO();
deviceDTO.setActivateTime((vehicle!=null && vehicle.getCreatedDate()!=null)?vehicle.getCreatedDate():new Date());
deviceDTO.setActivateTime((vehicle != null && vehicle.getCreatedDate() != null) ? vehicle.getCreatedDate() : new Date());
linkSnToVehicleId(sn, vehicle, deviceDTO, false);
}
......@@ -157,6 +157,7 @@ public class VehicleDeviceService {
/**
* 查询车辆绑定了哪些设备
*
* @param vehicleId
* @return
*/
......@@ -182,6 +183,7 @@ public class VehicleDeviceService {
/**
* 车辆,设备,工单 公共信息
*
* @param sn 设备号
* @return 车辆,设备,工单 公共信息
*/
......
......@@ -509,7 +509,7 @@ public class VehicleMonitorService {
case ConstantsVehicle.RESIDENT_TYPE_THREE:
startDate = DateUtil.formatDate(DateUtil.getDayBefore(90, now));
break;
//前半个月
//前半年
case ConstantsVehicle.RESIDENT_TYPE_SIX:
startDate = DateUtil.formatDate(DateUtil.getDayBefore(180, now));
break;
......
......@@ -1217,6 +1217,8 @@ public class VehicleService extends AbstractCommonService {
public void addVehicleInfo(VehicleInfoVo vehicleInfoVo) {
Vehicle vehicle = new Vehicle();
BeanUtils.copyProperties(vehicleInfoVo, vehicle);
// 默认未结清
vehicle.setSettleFlag(vehicleInfoVo.getSettleFlag() == null ? 0 : vehicleInfoVo.getSettleFlag());
// 设置车辆品牌
vehicle.setTypeId(vehicleInfoVo.getModelId());
setVehicleType(vehicle);
......
......@@ -115,7 +115,9 @@
<if test="search.appendSql != null and search.appendSql !=''">
${search.appendSql}
</if>
${settleCondition}
<if test="search.settleCondition != null and search.settleCondition !=''">
${search.settleCondition}
</if>
</select>
<select id="getActiveNumberWithAuth" resultType="cn.com.glsx.admin.modules.model.stat.StatCountModel">
......@@ -135,15 +137,17 @@
left join t_device td on td.sn = tvd.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
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 timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{offlineTime})
or (timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{offlineTime} and tdl.last_bs_time is null)
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; #{search.offlineTime} and tdl.last_bs_time is null)
)
<if test="offlineSnStr != null and offlineSnStr != ''">
and tvd.sn not in (${offlineSnStr})
<if test="search.offlineSnStr != null and search.offlineSnStr != ''">
and tvd.sn not in (${search.offlineSnStr})
</if>
<if test="search.settleCondition != null and search.settleCondition != ''">
${search.settleCondition}
</if>
${settleCondition}
</select>
<select id="getVehicleDeviceByVehicleAndSn" resultMap="BaseResultMap">
......@@ -176,6 +180,7 @@
<select id="searchReportDevice" resultType="cn.com.glsx.admin.modules.model.ReportDeviceDTO">
select tvd.id,
tv.id vehicleId,
td.id deviceId,
tv.workorder_id workOrderId,
tw.partner_order_no bizOrderNo,
tvd.sn sns,
......@@ -198,12 +203,12 @@
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="activateBeginTime != null and activateBeginTime != '' and activateEndTime != null and activateEndTime != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginTime} and #{activateEndTime}
<if test="activateBeginDate != null and activateBeginDate != '' and activateEndDate != null and activateEndDate != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate}
</if>
<if test="gpsBeginTime != null and gpsBeginTime != '' and gpsEndTime != null and gpsEndTime != ''">
and (DATE_FORMAT(tdl.last_gps_time,'%Y-%m-%d') between #{gpsEndTime} and #{gpsEndTime} or DATE_FORMAT(tdl.last_bs_time,'%Y-%m-%d') between #{gpsEndTime} and
#{gpsEndTime})
<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})
</if>
<if test="term != null and term !=''">
and(
......@@ -213,12 +218,13 @@
or tw.partner_order_no like '%${term}%'
)
</if>
order by tv.created_date desc, vehicleId, tvd.id
order by tv.created_date desc, deviceId desc
</select>
<select id="exportReportDevice" resultType="cn.com.glsx.admin.modules.model.export.ReportDeviceExport">
select tvd.id,
tv.id vehicleId,
td.id deviceId,
tv.workorder_id workOrderId,
tw.partner_order_no bizOrderNo,
tvd.sn sns,
......@@ -241,12 +247,12 @@
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="activateBeginTime != null and activateBeginTime != '' and activateEndTime != null and activateEndTime != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginTime} and #{activateEndTime}
<if test="activateBeginDate != null and activateBeginDate != '' and activateEndDate != null and activateEndDate != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate}
</if>
<if test="gpsBeginTime != null and gpsBeginTime != '' and gpsEndTime != null and gpsEndTime != ''">
and (DATE_FORMAT(tdl.last_gps_time,'%Y-%m-%d') between #{gpsEndTime} and #{gpsEndTime} or DATE_FORMAT(tdl.last_bs_time,'%Y-%m-%d') between #{gpsEndTime} and
#{gpsEndTime})
<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})
</if>
<if test="term != null and term !=''">
and(
......@@ -256,7 +262,7 @@
or tw.partner_order_no like '%${term}%'
)
</if>
order by tv.created_date desc, vehicleId, tvd.id
order by tv.created_date desc, deviceId desc
</select>
</mapper>
\ No newline at end of file
......@@ -1287,11 +1287,11 @@
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="activateBeginTime != null and activateBeginTime != '' and activateEndTime != null and activateEndTime != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginTime} and #{activateEndTime}
<if test="activateBeginDate != null and activateBeginDate != '' and activateEndDate != null and activateEndDate != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate}
</if>
<if test="orderBeginTime != null and orderBeginTime != '' and orderEndTime != null and orderEndTime != ''">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{orderBeginTime} and #{orderEndTime}
<if test="orderBeginDate != null and orderBeginDate != '' and orderEndDate != null and orderEndDate != ''">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{orderBeginDate} and #{orderEndDate}
</if>
<if test="term != null and term !=''">
and(
......@@ -1339,11 +1339,11 @@
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="activateBeginTime != null and activateBeginTime != '' and activateEndTime != null and activateEndTime != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginTime} and #{activateEndTime}
<if test="activateBeginDate != null and activateBeginDate != '' and activateEndDate != null and activateEndDate != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginDate} and #{activateEndDate}
</if>
<if test="orderBeginTime != null and orderBeginTime != '' and orderEndTime != null and orderEndTime != ''">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{orderBeginTime} and #{orderEndTime}
<if test="orderBeginDate != null and orderBeginDate != '' and orderEndDate != null and orderEndDate != ''">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{orderBeginDate} and #{orderEndDate}
</if>
<if test="term != null and term !=''">
and(
......
package cn.com.glsx.admin.modules.remote;
import cn.com.glsx.Application;
import cn.com.glsx.devicemonitor.api.dto.request.StayPointRequest;
import cn.com.glsx.devicemonitor.api.dto.response.StayPointRecordDTO;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Date;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author xiangyanlin
* @date 2022/5/17
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RemoteFeignStayPointServiceTest {
@Autowired
private RemoteFeignStayPointService remoteFeignStayPointService;
@Test
public void testGet() {
StayPointRequest request = new StayPointRequest();
request.setSn("60907150063");
request.setBeginTime(new Date(1640966400000L));
request.setEndTime(new Date(1652716800000L));
request.setPeriodType(0);
List<StayPointRecordDTO> stayPointRecord = remoteFeignStayPointService.getStayPointRecord(request);
System.out.println(JSON.toJSONString(stayPointRecord));
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!