提交 f8b54194 authored 作者: 刘海泉's avatar 刘海泉

Merge remote-tracking branch 'origin/es_add_truck_new_pos_20240606' into test

# Conflicts: # performance-web/src/main/java/com/clx/performance/controller/temp/TempTraceController.java
......@@ -2,6 +2,7 @@ package com.clx.performance.controller.temp;
import com.clx.performance.dto.gd.GdRouteDTO;
import com.clx.performance.param.mq.trace.TruckTraceSyncMqParam;
import com.clx.performance.esplus.model.TruckLatestPosESPlus;
import com.clx.performance.param.temp.DriverTraceAddParam;
import com.clx.performance.param.temp.TruckTraceAddParam;
import com.clx.performance.service.trace.TruckTraceMqHandlerService;
......@@ -123,8 +124,12 @@ public class TempTraceController {
}
@ApiOperation(value = "获取车辆最新位置信息", notes = "<br>By:刘海泉")
@GetMapping("/getTruckLatestPos")
public Result<TruckLatestPosESPlus> getTruckLatestPos(@Param("truckNo")
@NotBlank(message = "车牌号不能为空") String truckNo) {
return Result.ok( truckTraceService.getTruckLatestPos(truckNo));
}
}
package com.clx.performance.esplus.mapper;
import com.clx.performance.esplus.model.TruckLatestPosESPlus;
import org.dromara.easyes.core.kernel.BaseEsMapper;
public interface TruckLastPosESPlusMapper extends BaseEsMapper<TruckLatestPosESPlus> {
}
\ No newline at end of file
package com.clx.performance.esplus.model;
import lombok.Data;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;
import java.math.BigDecimal;
@Data
@IndexName(value = "clx_truck_latest_pos")
public class TruckLatestPosESPlus {
@IndexId(type= IdType.UUID)
private String id;
@IndexField(fieldType = FieldType.KEYWORD)
private String truckNo; //车辆编号
private BigDecimal angle; //agl
private BigDecimal speed; //速度
private BigDecimal mileage; //里程
private BigDecimal height; //海拔
private BigDecimal[] location; //位置
@IndexField(fieldType = FieldType.DATE)
private String gpsTime; //时间
private String createTime;
}
\ No newline at end of file
package com.clx.performance.service.impl.trace;
import com.clx.performance.dto.zjxl.TruckTraceDTO;
import com.clx.performance.esplus.mapper.TruckLastPosESPlusMapper;
import com.clx.performance.esplus.mapper.TruckTraceESPlusMapper;
import com.clx.performance.esplus.model.TruckLatestPosESPlus;
import com.clx.performance.esplus.model.TruckTraceESPlus;
import com.clx.performance.param.mq.trace.TruckTraceSyncMqParam;
import com.clx.performance.service.trace.TruckTraceMqHandlerService;
import com.clx.performance.struct.trace.TruckTraceStruct;
import com.clx.performance.utils.LocalDateTimeUtils;
import com.clx.performance.utils.zjxl.ZjxlGpsService;
import lombok.extern.slf4j.Slf4j;
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -15,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Slf4j
@Service
......@@ -25,6 +30,12 @@ public class TruckTraceMqHandlerServiceImpl implements TruckTraceMqHandlerServic
@Autowired
private TruckTraceESPlusMapper truckTraceESPlusMapper;
@Autowired
TruckLastPosESPlusMapper truckLastPosESPlusMapper;
@Autowired
TruckTraceStruct truckTraceStruct;
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -50,6 +61,20 @@ public class TruckTraceMqHandlerServiceImpl implements TruckTraceMqHandlerServic
// 保存
truckTraceESPlusMapper.insertBatch(esList);
//保存车辆最新的位置信息
TruckTraceESPlus trace = esList.get(esList.size() - 1);
TruckLatestPosESPlus truckLatestPos = truckLastPosESPlusMapper.selectOne(
new LambdaEsQueryWrapper<TruckLatestPosESPlus>().eq(TruckLatestPosESPlus::getTruckNo, trace.getTruckNo()));
log.info("通过车牌号:{},查询车辆最新位置信息:{}",trace.getTruckNo(),truckLatestPos);
TruckLatestPosESPlus item = truckTraceStruct.convert2LatestPos(trace);
if(Objects.nonNull(truckLatestPos)){
truckLastPosESPlusMapper.update(item,new LambdaEsQueryWrapper<TruckLatestPosESPlus>().
eq(TruckLatestPosESPlus::getTruckNo, trace.getTruckNo()));
}else{
truckLastPosESPlusMapper.insert(item);
}
}
}
package com.clx.performance.service.impl.trace;
import com.clx.performance.esplus.mapper.DriverTraceESPlusMapper;
import com.clx.performance.esplus.mapper.TruckLastPosESPlusMapper;
import com.clx.performance.esplus.mapper.TruckTraceESPlusMapper;
import com.clx.performance.esplus.model.DriverTraceESPlus;
import com.clx.performance.esplus.model.TruckLatestPosESPlus;
import com.clx.performance.esplus.model.TruckTraceESPlus;
import com.clx.performance.param.temp.DriverTraceAddParam;
import com.clx.performance.param.temp.TruckTraceAddParam;
......@@ -38,6 +40,9 @@ public class TruckTraceServiceImpl implements TruckTraceService {
@Autowired
private DriverTraceESPlusMapper driverTraceESPlusMapper;
@Autowired
TruckLastPosESPlusMapper truckLastPosESPlusMapper;
@Autowired
private TruckTraceStruct truckTraceStruct;
@Autowired
......@@ -407,6 +412,11 @@ public class TruckTraceServiceImpl implements TruckTraceService {
truckTraceESPlusMapper.insertBatch(esList);
}
@Override
public TruckLatestPosESPlus getTruckLatestPos(String truckNo) {
TruckLatestPosESPlus truckLatestPos = truckLastPosESPlusMapper.selectOne(
new LambdaEsQueryWrapper<TruckLatestPosESPlus>().eq(TruckLatestPosESPlus::getTruckNo, truckNo));
log.info("通过车牌号:{},查询车辆最新位置信息:{}",truckNo,truckLatestPos);
return truckLatestPos;
}
}
package com.clx.performance.service.trace;
import com.clx.performance.esplus.model.TruckLatestPosESPlus;
import com.clx.performance.param.temp.DriverTraceAddParam;
import com.clx.performance.param.temp.TruckTraceAddParam;
import com.clx.performance.vo.pc.trace.DriverTraceVO;
......@@ -38,4 +39,8 @@ public interface TruckTraceService {
void saveTruckTrace(String truckNo,Integer size,String gpsTime);
TruckLatestPosESPlus getTruckLatestPos(String truckNo);
}
......@@ -2,6 +2,7 @@ package com.clx.performance.struct.trace;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.esplus.model.TruckLatestPosESPlus;
import com.clx.performance.esplus.model.TruckTraceESPlus;
import com.clx.performance.vo.pc.trace.DriverTruckTraceVO;
import com.msl.common.utils.DateStructUtil;
......@@ -20,4 +21,7 @@ public interface TruckTraceStruct {
List<DriverTruckTraceVO> convert(List<TruckTraceESPlus> list);
Page<DriverTruckTraceVO> convertPage(IPage<TruckTraceESPlus> page);
TruckLatestPosESPlus convert2LatestPos(TruckTraceESPlus item);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论