|
|
@@ -4,10 +4,12 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelReader;
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.common.enums.enums.FileEnum;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
+import com.sckw.core.model.base.BaseModel;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.model.file.FileInfo;
|
|
|
@@ -22,6 +24,8 @@ import com.sckw.fleet.dao.*;
|
|
|
import com.sckw.fleet.model.*;
|
|
|
import com.sckw.fleet.model.dto.*;
|
|
|
import com.sckw.fleet.model.vo.*;
|
|
|
+import com.sckw.fleet.repository.KwfTruckReportRepository;
|
|
|
+import com.sckw.fleet.repository.KwfTruckRepository;
|
|
|
import com.sckw.redis.constant.RedisConstant;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
@@ -71,6 +75,12 @@ public class KwfDriverService {
|
|
|
private FileApiDubboService remoteFileService;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
|
|
|
private RemoteUserService remoteUserService;
|
|
|
+ @Autowired
|
|
|
+ KwfTruckReportRepository truckReportRepository;
|
|
|
+ @Autowired
|
|
|
+ KwfTruckRepository truckRepository;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param key 逐渐id
|
|
|
* @desc 根据主键查询
|
|
|
@@ -117,10 +127,10 @@ public class KwfDriverService {
|
|
|
qualificationVo.setTypeName(value);
|
|
|
driverDetailVo.setDriverQualification(qualificationVo);
|
|
|
|
|
|
- //车队班组
|
|
|
- KwfFleet fleet = this.findByFleetDriver(driverId, LoginUserHolder.getEntId());
|
|
|
- driverDetailVo.setFleetId(fleet != null ? fleet.getId() : null);
|
|
|
- driverDetailVo.setFleetName(fleet != null ? fleet.getName() : null);
|
|
|
+// //车队班组
|
|
|
+// KwfFleet fleet = this.findByFleetDriver(driverId, LoginUserHolder.getEntId());
|
|
|
+// driverDetailVo.setFleetId(fleet != null ? fleet.getId() : null);
|
|
|
+// driverDetailVo.setFleetName(fleet != null ? fleet.getName() : null);
|
|
|
|
|
|
//司机关联车辆(车辆上报)
|
|
|
if (LoginUserHolder.getSystemType() == SystemTypeEnum.DRIVER.getCode()) {
|
|
|
@@ -255,6 +265,11 @@ public class KwfDriverService {
|
|
|
driver.setCreateByName(user != null ? user.getName() : null);
|
|
|
driver.setFirmName(ent != null ? ent.getFirmName() : null);
|
|
|
driver.setLicenseTypeName(licenseType != null ? licenseType.getLabel() : null);
|
|
|
+
|
|
|
+ //获取车辆信息
|
|
|
+ KwfTruck truckInfo = getTruckInfo(driver.getId(), driver.getEntId());
|
|
|
+ driver.setTruckNo(truckInfo.getTruckNo());
|
|
|
+
|
|
|
}
|
|
|
return drivers;
|
|
|
}
|
|
|
@@ -287,6 +302,33 @@ public class KwfDriverService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据司机id和企业id查询车辆信息
|
|
|
+ *
|
|
|
+ * @param truck
|
|
|
+ * @param ents
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private KwfTruck getTruckInfo(String driverId, String entId) {
|
|
|
+ //查询司机关联车辆信息
|
|
|
+ KwfTruckReport truckReport = truckReportRepository.getOne(Wrappers.<KwfTruckReport>lambdaQuery()
|
|
|
+ .eq(BaseModel::getDelFlag, 0)
|
|
|
+ .eq(KwfTruckReport::getDriverId, driverId)
|
|
|
+ .eq(KwfTruckReport::getEntId, entId));
|
|
|
+ if (truckReport == null) {
|
|
|
+ return new KwfTruck();
|
|
|
+ }
|
|
|
+ //查询车辆信息
|
|
|
+ KwfTruck truck = truckRepository.getOne(Wrappers.<KwfTruck>lambdaQuery()
|
|
|
+ .eq(BaseModel::getDelFlag, 0)
|
|
|
+ .eq(KwfTruck::getId, truckReport.getTruckId())
|
|
|
+ .eq(KwfTruck::getEntId, entId));
|
|
|
+ if (truck == null) {
|
|
|
+ return new KwfTruck();
|
|
|
+ }
|
|
|
+ return truck;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 查询参数
|
|
|
* @desc 查询
|
|
|
@@ -432,7 +474,7 @@ public class KwfDriverService {
|
|
|
}
|
|
|
|
|
|
/**车队班组绑定**/
|
|
|
- driverFleetEdit(driver.getId(), params.getFleetId());
|
|
|
+// driverFleetEdit(driver.getId(), params.getFleetId());
|
|
|
|
|
|
return HttpResult.ok(result.getMsg());
|
|
|
}
|
|
|
@@ -1022,7 +1064,6 @@ public class KwfDriverService {
|
|
|
driver.setAuthStatus(Global.NUMERICAL_ONE);
|
|
|
driverDao.updateById(driver);
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 校验list中对象key值是否存在与value不一致的情况
|
|
|
* @param list 数据集
|
|
|
@@ -1040,4 +1081,39 @@ public class KwfDriverService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params 参数
|
|
|
+ * @desc 修改司机
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/6
|
|
|
+ **/
|
|
|
+ public HttpResult bindTruck(KwfBindTruckDto params) {
|
|
|
+ /**数据校验**/
|
|
|
+ if (params.getId() == null) {
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_PATTERN_ERROR_CODE,"司机主键id不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(params.getTruckId())) {
|
|
|
+ return HttpResult.ok("未选择需要绑定的车辆!");
|
|
|
+ }
|
|
|
+ //查询是否存在已有车辆司机关系数据
|
|
|
+ KwfTruckReport truckReport = truckReportRepository.getOne(Wrappers.<KwfTruckReport>lambdaQuery()
|
|
|
+ .eq(KwfTruckReport::getEntId, LoginUserHolder.getEntId())
|
|
|
+ .eq(KwfTruckReport::getDriverId, params.getId())
|
|
|
+ .eq(KwfTruckReport::getDelFlag, Global.NO));
|
|
|
+ if(truckReport == null) {
|
|
|
+ truckReport.setTruckId(params.getTruckId());
|
|
|
+ boolean saveResult = truckReportRepository.save(truckReport);
|
|
|
+ return saveResult ? HttpResult.ok("车辆绑定成功!") : HttpResult.error("车辆绑定失败!");
|
|
|
+ } else {
|
|
|
+ if (truckReport.getTruckId().equals(params.getTruckId())) {
|
|
|
+ return HttpResult.error("此车辆已与此司机绑定,请重选选择车辆");
|
|
|
+ }
|
|
|
+ truckReport.setTruckId(params.getTruckId());
|
|
|
+ boolean updateResult = truckReportRepository.updateById(truckReport);
|
|
|
+ return updateResult ? HttpResult.ok("车辆绑定成功!") : HttpResult.error("车辆绑定失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|