package com.ruoyi.system.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.common.core.web.page.PageInfo;
|
import com.ruoyi.dataInterchange.api.feignClient.UPExgMsgReportDriverInfoClient;
|
import com.ruoyi.dataInterchange.api.vo.UPExgMsgReportDriverInfoVo;
|
import com.ruoyi.system.api.model.Driver;
|
import com.ruoyi.system.api.model.Enterprise;
|
import com.ruoyi.system.mapper.DriverMapper;
|
import com.ruoyi.system.query.DriverListReq;
|
import com.ruoyi.system.query.DriverListResp;
|
import com.ruoyi.system.service.IDriverService;
|
import com.ruoyi.system.service.IEnterpriseService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.time.LocalDateTime;
|
import java.time.ZoneOffset;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @author zhibing.pu
|
* @Date 2025/3/17 16:26
|
*/
|
@Service
|
public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService {
|
|
@Resource
|
private UPExgMsgReportDriverInfoClient upExgMsgReportDriverInfoClient;
|
|
@Resource
|
private IDriverService driverService;
|
|
@Resource
|
private IEnterpriseService enterpriseService;
|
|
|
/**
|
* 定时任务获取新驾驶员数据
|
*/
|
@Override
|
public void taskSaveNewDriver() {
|
Driver driver = driverService.getOne(new LambdaQueryWrapper<Driver>().eq(Driver::getStatus, 1).orderByDesc(Driver::getUpdateTime).last(" limit 0, 1"));
|
Long createTime = -1L;
|
if (null != driver) {
|
createTime = driver.getUpdateTime().toEpochSecond(ZoneOffset.ofHours(8));
|
}
|
List<UPExgMsgReportDriverInfoVo> list = upExgMsgReportDriverInfoClient.getUPExgMsgReportDriverInfoListIsAfterCreateTime(createTime).getData();
|
if (null == list || list.isEmpty()) {
|
return;
|
}
|
List<Enterprise> list1 = enterpriseService.list();
|
List<Driver> driverList = new ArrayList<>();
|
for (UPExgMsgReportDriverInfoVo vo : list) {
|
driver = new Driver();
|
driver.setName(vo.getDriverName());
|
driver.setDrivingLicenseNumber(vo.getDriverId());
|
driver.setCertification(vo.getLicence());
|
driver.setOrgName(vo.getOrgName());
|
Enterprise enterprise = list1.stream().filter(s -> s.getCode().equals(vo.getInferiorPlatformId().toString())).findFirst().get();
|
driver.setEnterpriseId(enterprise.getId());
|
driver.setContractingCompany(enterprise.getName());
|
driver.setStatus(1);
|
driver.setFlag(1);
|
driver.setUpdateTime(LocalDateTime.now());
|
driver.setVehicleNumber(vo.getVehicleNo());
|
driverList.add(driver);
|
}
|
if (driverList.size() > 0) {
|
this.saveBatch(driverList);
|
}
|
}
|
|
|
/**
|
* 获取司机列表
|
*
|
* @param driverListReq
|
* @return
|
*/
|
@Override
|
public PageInfo<DriverListResp> getDriverList(DriverListReq driverListReq) {
|
PageInfo<DriverListResp> pageInfo = new PageInfo<>(driverListReq.getPageCurr(), driverListReq.getPageSize());
|
return this.baseMapper.getDriverList(pageInfo, driverListReq);
|
}
|
}
|