Commit 6d1cd589 by 向延琳

fix:总里程计算错误

1 parent 1d7812d1
...@@ -77,6 +77,7 @@ public class JourneyService { ...@@ -77,6 +77,7 @@ public class JourneyService {
deviceJourneyMapper.insert(deviceJourney); deviceJourneyMapper.insert(deviceJourney);
//如果行程数据的设备未关联车辆 不计入从次数和总信息 //如果行程数据的设备未关联车辆 不计入从次数和总信息
log.info("vdId{}", vdId);
if(Objects.isNull(vdId)) { if(Objects.isNull(vdId)) {
log.warn("该设备没有绑定车辆" + deviceJourneyDTO.getSn()); log.warn("该设备没有绑定车辆" + deviceJourneyDTO.getSn());
log.info("同步里程总耗时{}", t4 - t1); log.info("同步里程总耗时{}", t4 - t1);
...@@ -95,7 +96,7 @@ public class JourneyService { ...@@ -95,7 +96,7 @@ public class JourneyService {
return; return;
} }
overview.setDistance(overview.getDistance() + overviewDO.getDistance()); overview.setDistance(overview.getDistance() + overviewDO.getDistance());
overview.setDistance(overview.getTotalJourneyCount() + 1); overview.setTotalJourneyCount(overview.getTotalJourneyCount() + 1);
overview.setUpdatedDate(new Date()); overview.setUpdatedDate(new Date());
deviceJourneyOverviewMapper.updateByPrimaryKeySelective(overview); deviceJourneyOverviewMapper.updateByPrimaryKeySelective(overview);
long t6 = System.currentTimeMillis(); long t6 = System.currentTimeMillis();
......
package cn.com.glsx.stdinterface.modules.mapper; package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.Application;
import lombok.extern.slf4j.Slf4j;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
...@@ -7,6 +13,9 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -7,6 +13,9 @@ import static org.junit.jupiter.api.Assertions.*;
* @author xiangyanlin * @author xiangyanlin
* @date 2022/4/8 * @date 2022/4/8
*/ */
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class DeviceJourneyOverviewMapperTest { class DeviceJourneyOverviewMapperTest {
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.Application;
import cn.com.glsx.stdinterface.dto.DeviceJourneyDTO;
import lombok.extern.slf4j.Slf4j;
import org.junit.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 static org.junit.jupiter.api.Assertions.*;
/**
* @author xiangyanlin
* @date 2022/4/20
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class JourneyServiceTest {
@Autowired
private JourneyService journeyService;
@Test
public void testSave() {
DeviceJourneyDTO deviceJourneyDTO = new DeviceJourneyDTO();
deviceJourneyDTO.setSn("1510112899");
deviceJourneyDTO.setBeginTime(new Date());
deviceJourneyDTO.setBeginTime(new Date());
deviceJourneyDTO.setBeginAddress("{\"lat\":\"22.590676\",\"lng\":\"113.987488\"}");
deviceJourneyDTO.setEndAddress("{\"lat\":\"22.590884\",\"lng\":\"113.988520\"}");
deviceJourneyDTO.setMileage(7111);
journeyService.saveDeviceJourney(deviceJourneyDTO);
}
}
\ No newline at end of file \ No newline at end of file
...@@ -35,4 +35,11 @@ public class VehicleServiceTest { ...@@ -35,4 +35,11 @@ public class VehicleServiceTest {
System.out.println("end"); System.out.println("end");
} }
@Test
public void testGetVdId() {
Long vdId = vehicleService.getVdId("1510112899");
System.out.println(vdId);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!