|
|
@@ -6,17 +6,23 @@ import com.alibaba.excel.read.metadata.ReadSheet;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+import com.sckw.core.common.enums.enums.ErrorCodeEnum;
|
|
|
import com.sckw.core.common.enums.enums.FileEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
+import com.sckw.core.exception.BusinessPlatfromException;
|
|
|
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.EntTypeEnum;
|
|
|
+import com.sckw.core.model.enums.ForkliftStatusEnum;
|
|
|
import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.model.file.FileInfo;
|
|
|
import com.sckw.core.utils.*;
|
|
|
@@ -25,6 +31,7 @@ import com.sckw.core.web.context.LoginEntHolder;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.request.HttpClientUtil;
|
|
|
import com.sckw.core.web.response.BaseIotResult;
|
|
|
+import com.sckw.core.web.response.BaseResult;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.core.web.response.result.PageDataResult;
|
|
|
import com.sckw.excel.easyexcel.ExcelImportListener;
|
|
|
@@ -33,6 +40,11 @@ import com.sckw.fleet.config.UrlConfigProperties;
|
|
|
import com.sckw.fleet.dao.*;
|
|
|
import com.sckw.fleet.model.*;
|
|
|
import com.sckw.fleet.model.dto.*;
|
|
|
+import com.sckw.fleet.model.enums.TruckStatusEnum;
|
|
|
+import com.sckw.fleet.model.reponse.TruckBlacklistParam;
|
|
|
+import com.sckw.fleet.model.reponse.TruckQueryParam;
|
|
|
+import com.sckw.fleet.model.reponse.TruckResp;
|
|
|
+import com.sckw.fleet.model.reponse.TruckUpdateStatusParam;
|
|
|
import com.sckw.fleet.model.request.BatchTruckValidateReq;
|
|
|
import com.sckw.fleet.model.request.CapacityStatusReq;
|
|
|
import com.sckw.fleet.model.request.TruckInfoReq;
|
|
|
@@ -2026,4 +2038,153 @@ public class KwfTruckService {
|
|
|
|
|
|
return builder.build();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询铲车订单
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PageDataResult<TruckResp> pageQueryTruck(TruckQueryParam param) {
|
|
|
+ log.info("查询司机信息列表:{}", JSON.toJSONString(param));
|
|
|
+ List<Long> validTruckIds = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(param.getDriverName())) {
|
|
|
+ //1.1 先根据司机名字模糊查询司机ID
|
|
|
+ List<KwfDriver> drivers = kwfDriverRepository.list(Wrappers.<KwfDriver>lambdaQuery()
|
|
|
+ .like(KwfDriver::getName, param.getDriverName())
|
|
|
+ .eq(BaseModel::getDelFlag, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(drivers)) {
|
|
|
+ List<Long> driverIds = drivers.stream().map(KwfDriver::getId).collect(Collectors.toList());
|
|
|
+ // 1.2 拿着司机ID去关联表(kwf_truck_report)查车辆ID
|
|
|
+ List<KwfTruckReport> reports = kwfTruckReportRepository.list(
|
|
|
+ Wrappers.<KwfTruckReport>lambdaQuery()
|
|
|
+ .in(KwfTruckReport::getDriverId, driverIds)
|
|
|
+ .eq(KwfTruckReport::getEntId, LoginUserHolder.getEntId())
|
|
|
+ .eq(BaseModel::getDelFlag, 0)
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isNotEmpty(reports)) {
|
|
|
+ //1.3 提取出车辆ID列表
|
|
|
+ validTruckIds = reports.stream()
|
|
|
+ .map(KwfTruckReport::getTruckId)
|
|
|
+ .distinct() // 去重
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ return PageDataResult.empty(param.getPageNum(), param.getPageSize());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return PageDataResult.empty(param.getPageNum(), param.getPageSize());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<KwfTruck> wrapper = Wrappers.<KwfTruck>lambdaQuery()
|
|
|
+ .like(StringUtils.isNotBlank(param.getTruckNo()), KwfTruck::getTruckNo, param.getTruckNo())
|
|
|
+ .eq(KwfTruck::getType, param.getType())
|
|
|
+ .eq(KwfTruck::getCarAxis, param.getCarAxis())
|
|
|
+ .eq(KwfTruck::getEnergyType, param.getEnergyTyp())
|
|
|
+ .eq(KwfTruck::getEev, param.getEev())
|
|
|
+ .eq(KwfTruck::getStatus, param.getStatus());
|
|
|
+ // 查询该你了司机
|
|
|
+ if (CollectionUtils.isNotEmpty(validTruckIds)) {
|
|
|
+ wrapper.in(KwfTruck::getId, validTruckIds);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(KwfTruck::getCreateTime)
|
|
|
+ .orderByDesc(KwfTruck::getId);
|
|
|
+
|
|
|
+ //查询铲车订单
|
|
|
+ Page<KwfTruck> pageByStatus = kwfTruckRepository.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
+ List<KwfTruck> records = pageByStatus.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
+ log.info("无车辆信息,param:{}", param);
|
|
|
+ return PageDataResult.empty(param.getPageNum(), param.getPageSize());
|
|
|
+ }
|
|
|
+ List<TruckResp> truckPageResult = getTruckResp(records);
|
|
|
+ return PageDataResult.success(param.getPageNum(), param.getPageSize(), pageByStatus.getTotal(), truckPageResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param records
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<TruckResp> getTruckResp(List<KwfTruck> trucks) {
|
|
|
+ List<TruckResp> truckResps = new ArrayList<>();
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRUCK_TYPE.getType()));
|
|
|
+ Map<String, String> truckTypeMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
+ truckTypeMap = dict.get(DictTypeEnum.TRUCK_TYPE.getType());
|
|
|
+ }
|
|
|
+ for (KwfTruck truck : trucks) {
|
|
|
+ TruckResp truckResp = new TruckResp();
|
|
|
+ truckResp.setId(truck.getId());
|
|
|
+ truckResp.setTruckNo(truck.getTruckNo());
|
|
|
+ truckResp.setType(truck.getType());
|
|
|
+ truckResp.setTypeDesc(CollectionUtils.isNotEmpty(truckTypeMap) ? truckTypeMap.get(String.valueOf(truck.getType())) : null);
|
|
|
+ truckResp.setBrand(truck.getBrand());
|
|
|
+ truckResp.setStatus(truck.getStatus());
|
|
|
+ truckResp.setStatusDesc(TruckStatusEnum.getName(truck.getStatus()));
|
|
|
+ truckResp.setCreateTime(truck.getCreateTime());
|
|
|
+
|
|
|
+ //查询车辆轴数
|
|
|
+ TmsTruckAxleNum axleNum = getCarAxisInfo(truck.getCarAxis());
|
|
|
+ truckResp.setCarAxis(truck.getCarAxis());
|
|
|
+ truckResp.setCarAxisName(axleNum.getName());
|
|
|
+
|
|
|
+ //查询司机信息
|
|
|
+ KwfDriver driver = getDriverInfo(truck.getId(), LoginUserHolder.getEntId());
|
|
|
+ truckResp.setDriverName(driver.getName());
|
|
|
+
|
|
|
+ truckResps.add(truckResp);
|
|
|
+ }
|
|
|
+ return truckResps;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询铲车订单
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void batchUpdateStatus(TruckUpdateStatusParam param) {
|
|
|
+ log.info("车辆停用/启用,param:{}", JSON.toJSONString(param));
|
|
|
+ // 1. 校验状态合法性
|
|
|
+ if (param.getStatus() != 0 && param.getStatus() != 1) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.TRUCK_STATUS_ERROR, "仅支持修改为正常(0)或停用(1)状态");
|
|
|
+ }
|
|
|
+ if (param.getStatus() == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.TRUCK_STATUS_ERROR, "状态参数不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<KwfTruck> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.in(KwfTruck::getId, param.getIds());
|
|
|
+ updateWrapper.set(KwfTruck::getStatus, param.getStatus());
|
|
|
+ kwfTruckRepository.update(updateWrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 黑名单
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void toggleBlacklist(TruckBlacklistParam param) {
|
|
|
+ log.info("黑名单业务:{}", JSON.toJSONString(param));
|
|
|
+ if (param.getId() == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DRIVER_NOT_FOUND, "车辆不存在");
|
|
|
+ }
|
|
|
+ int targetStatus;
|
|
|
+ if (param.getStatus() == 4) {
|
|
|
+ // 如果当前已经是黑名单,则操作为“移出”,目标状态设为正常(0)
|
|
|
+ targetStatus = 0;
|
|
|
+ } else {
|
|
|
+ // 如果当前不是黑名单,则操作为“加入”,目标状态设为黑名单(4)
|
|
|
+ targetStatus = 4;
|
|
|
+ }
|
|
|
+ kwfTruckRepository.update(Wrappers.<KwfTruck>lambdaUpdate()
|
|
|
+ .eq(KwfTruck::getId, param.getId())
|
|
|
+ .set(KwfTruck::getStatus, targetStatus));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|