|
@@ -1,5 +1,6 @@
|
|
|
package com.sckw.fleet.service;
|
|
package com.sckw.fleet.service;
|
|
|
|
|
|
|
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
import com.sckw.core.utils.BeanUtils;
|
|
@@ -8,16 +9,14 @@ import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
-import com.sckw.fleet.dao.KwfTransportLicenseMapper;
|
|
|
|
|
-import com.sckw.fleet.dao.KwfTruckEntMapper;
|
|
|
|
|
-import com.sckw.fleet.dao.KwfTruckLicenseMapper;
|
|
|
|
|
-import com.sckw.fleet.dao.KwfTruckMapper;
|
|
|
|
|
|
|
+import com.sckw.fleet.dao.*;
|
|
|
import com.sckw.fleet.model.*;
|
|
import com.sckw.fleet.model.*;
|
|
|
import com.sckw.fleet.model.dto.*;
|
|
import com.sckw.fleet.model.dto.*;
|
|
|
import com.sckw.fleet.model.vo.KwfTableTopCount;
|
|
import com.sckw.fleet.model.vo.KwfTableTopCount;
|
|
|
import com.sckw.fleet.model.vo.KwfTruckVo;
|
|
import com.sckw.fleet.model.vo.KwfTruckVo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
|
|
+import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -45,6 +44,8 @@ public class KwfTruckService {
|
|
|
KwfTruckLicenseMapper truckLicenseDao;
|
|
KwfTruckLicenseMapper truckLicenseDao;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwfTransportLicenseMapper transportLicenseDao;
|
|
KwfTransportLicenseMapper transportLicenseDao;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwfFleetTruckMapper fleetTruckDao;
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
private RemoteSystemService remoteSystemService;
|
|
|
|
|
|
|
@@ -99,11 +100,18 @@ public class KwfTruckService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**获取查询数据**/
|
|
/**获取查询数据**/
|
|
|
|
|
+ String prefix = Global.REDIS_SYS_DICT_PREFIX, pound = Global.POUND;
|
|
|
List<Long> createBys = new ArrayList<>();
|
|
List<Long> createBys = new ArrayList<>();
|
|
|
List<Long> entIds = new ArrayList<>();
|
|
List<Long> entIds = new ArrayList<>();
|
|
|
|
|
+ List<String> dictKey = new ArrayList<>();
|
|
|
|
|
+
|
|
|
for (KwfTruckVo truck:trucks) {
|
|
for (KwfTruckVo truck:trucks) {
|
|
|
createBys.add(Long.parseLong(truck.getCreateBy()));
|
|
createBys.add(Long.parseLong(truck.getCreateBy()));
|
|
|
entIds.add(Long.parseLong(truck.getEntId()));
|
|
entIds.add(Long.parseLong(truck.getEntId()));
|
|
|
|
|
+ dictKey.add(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getColor());
|
|
|
|
|
+ dictKey.add(prefix + DictTypeEnum.TRUCK_TYPE.getType() + pound + truck.getType());
|
|
|
|
|
+ dictKey.add(prefix + DictTypeEnum.USE_TYPE.getType() + pound + truck.getUseType());
|
|
|
|
|
+ dictKey.add(prefix + DictTypeEnum.ENERGY_TYPE.getType() + pound + truck.getEnergyType());
|
|
|
}
|
|
}
|
|
|
//用户数据集
|
|
//用户数据集
|
|
|
createBys = createBys.stream().distinct().collect(Collectors.toList());
|
|
createBys = createBys.stream().distinct().collect(Collectors.toList());
|
|
@@ -111,13 +119,24 @@ public class KwfTruckService {
|
|
|
//企业数据集
|
|
//企业数据集
|
|
|
entIds = entIds.stream().distinct().collect(Collectors.toList());
|
|
entIds = entIds.stream().distinct().collect(Collectors.toList());
|
|
|
Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
|
|
|
+ //数据字典
|
|
|
|
|
+ dictKey = dictKey.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
+ Map<Long, SysDictResDto> dicts = null;//remoteSystemService.queryDictByType(dictKey);
|
|
|
|
|
|
|
|
/**数据组装**/
|
|
/**数据组装**/
|
|
|
for (KwfTruckVo truck:trucks) {
|
|
for (KwfTruckVo truck:trucks) {
|
|
|
UserCacheResDto user = users == null ? null : users.get(Long.parseLong(truck.getCreateBy()));
|
|
UserCacheResDto user = users == null ? null : users.get(Long.parseLong(truck.getCreateBy()));
|
|
|
EntCacheResDto ent = ents == null ? null : ents.get(Long.parseLong(truck.getEntId()));
|
|
EntCacheResDto ent = ents == null ? null : ents.get(Long.parseLong(truck.getEntId()));
|
|
|
|
|
+ SysDictResDto color = dicts == null ? null : dicts.get(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getColor());
|
|
|
|
|
+ SysDictResDto type = dicts == null ? null : dicts.get(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getType());
|
|
|
|
|
+ SysDictResDto useType = dicts == null ? null : dicts.get(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getUseType());
|
|
|
|
|
+ SysDictResDto energyType = dicts == null ? null : dicts.get(prefix + DictTypeEnum.COLOR_TYPE.getType() + pound + truck.getEnergyType());
|
|
|
truck.setCreateByName(user != null ? user.getName() : null);
|
|
truck.setCreateByName(user != null ? user.getName() : null);
|
|
|
truck.setFirmName(ent != null ? ent.getFirmName() : null);
|
|
truck.setFirmName(ent != null ? ent.getFirmName() : null);
|
|
|
|
|
+ truck.setColorName(color != null ? color.getLabel() : null);
|
|
|
|
|
+ truck.setTruckTypeName(type != null ? type.getLabel() : null);
|
|
|
|
|
+ truck.setUseTypeName(useType != null ? useType.getLabel() : null);
|
|
|
|
|
+ truck.setEnergyTypeName(energyType != null ? energyType.getLabel() : null);
|
|
|
}
|
|
}
|
|
|
return trucks;
|
|
return trucks;
|
|
|
}
|
|
}
|
|
@@ -174,12 +193,16 @@ public class KwfTruckService {
|
|
|
/**车辆行驶证信息**/
|
|
/**车辆行驶证信息**/
|
|
|
KwfTransportLicenseDto transportLicenseDto = params.getTransportLicense();
|
|
KwfTransportLicenseDto transportLicenseDto = params.getTransportLicense();
|
|
|
if (transportLicenseDto != null) {
|
|
if (transportLicenseDto != null) {
|
|
|
- truckLicenseDto.setTruckId(truck.getId());
|
|
|
|
|
|
|
+ transportLicenseDto.setTruckId(truck.getId());
|
|
|
transportLicenseEdit(transportLicenseDto);
|
|
transportLicenseEdit(transportLicenseDto);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**车辆信息与企业关联信息**/
|
|
/**车辆信息与企业关联信息**/
|
|
|
truckEntEdit(truck);
|
|
truckEntEdit(truck);
|
|
|
|
|
+
|
|
|
|
|
+ /**车队班组绑定**/
|
|
|
|
|
+ truckFleetEdit(truck.getId(), params.getFleetId());
|
|
|
|
|
+
|
|
|
return HttpResult.ok("车辆信息新增成功!");
|
|
return HttpResult.ok("车辆信息新增成功!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -221,9 +244,12 @@ public class KwfTruckService {
|
|
|
/**车辆行驶证信息**/
|
|
/**车辆行驶证信息**/
|
|
|
KwfTransportLicenseDto transportLicenseDto = params.getTransportLicense();
|
|
KwfTransportLicenseDto transportLicenseDto = params.getTransportLicense();
|
|
|
if (transportLicenseDto != null) {
|
|
if (transportLicenseDto != null) {
|
|
|
- truckLicenseDto.setTruckId(truck.getId());
|
|
|
|
|
|
|
+ transportLicenseDto.setTruckId(truck.getId());
|
|
|
transportLicenseEdit(transportLicenseDto);
|
|
transportLicenseEdit(transportLicenseDto);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**车队班组绑定**/
|
|
|
|
|
+ truckFleetEdit(truck.getId(), params.getFleetId());
|
|
|
return HttpResult.ok("车辆信息修改成功!");
|
|
return HttpResult.ok("车辆信息修改成功!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -281,7 +307,7 @@ public class KwfTruckService {
|
|
|
//校验list中对象key值是否存在与value不一致的情况
|
|
//校验list中对象key值是否存在与value不一致的情况
|
|
|
boolean bool = CollectionUtils.listByKeyValueV1(trucks, "id", String.valueOf(params.getId()));
|
|
boolean bool = CollectionUtils.listByKeyValueV1(trucks, "id", String.valueOf(params.getId()));
|
|
|
if (bool) {
|
|
if (bool) {
|
|
|
- return HttpResult.error("车辆信息已存在!");
|
|
|
|
|
|
|
+ return HttpResult.error("车牌号已存在!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**更新**/
|
|
/**更新**/
|
|
@@ -376,6 +402,35 @@ public class KwfTruckService {
|
|
|
truckEntDao.insert(truckEnt);
|
|
truckEntDao.insert(truckEnt);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param truckId 车辆档案主键id fleetId 车队班组主键id
|
|
|
|
|
+ * @desc 车队班组绑定
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/7/7
|
|
|
|
|
+ **/
|
|
|
|
|
+ public HttpResult truckFleetEdit(Long truckId, Long fleetId) {
|
|
|
|
|
+ /**数据校验**/
|
|
|
|
|
+ if (fleetId == null) {
|
|
|
|
|
+ return HttpResult.ok("未选择车队班组!");
|
|
|
|
|
+ }
|
|
|
|
|
+ KwfFleetTruck queryFleetTruck = new KwfFleetTruck();
|
|
|
|
|
+ queryFleetTruck.setEntId(LoginUserHolder.getEntId());
|
|
|
|
|
+ queryFleetTruck.setTruckId(truckId);
|
|
|
|
|
+ KwfFleetTruck fleetTruck = fleetTruckDao.findByTruckFleet(queryFleetTruck);
|
|
|
|
|
+
|
|
|
|
|
+ /**数据更新**/
|
|
|
|
|
+ queryFleetTruck.setFleetId(fleetId);
|
|
|
|
|
+ if (fleetTruck == null) {
|
|
|
|
|
+ int count = fleetTruckDao.insert(queryFleetTruck);
|
|
|
|
|
+ return count > 0 ? HttpResult.ok("车队班组绑定成功!") : HttpResult.error("车队班组绑定失败!");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ queryFleetTruck.setId(fleetTruck.getId());
|
|
|
|
|
+ int count = fleetTruckDao.updateById(queryFleetTruck);
|
|
|
|
|
+ return count > 0 ? HttpResult.ok("车队班组绑定成功!") : HttpResult.error("车队班组绑定失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @param params 参数
|
|
* @param params 参数
|
|
|
* @desc 校验车辆是否有证书
|
|
* @desc 校验车辆是否有证书
|