Commit a522072c authored by unset's avatar unset

Merge branch 'master-vehicle-price' into dev-tiande

parents ef208a09 c8cc269c
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember; import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
...@@ -66,7 +64,6 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM ...@@ -66,7 +64,6 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
if (vehicle == null) { if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "车辆不存在!"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "车辆不存在!");
} }
Integer festivalId = getMaxFestivalId() + 1;
vehicleHolidayPriceInfo.setCompanyId(vehicle.getSubordinateBranch()); vehicleHolidayPriceInfo.setCompanyId(vehicle.getSubordinateBranch());
List<Vehicle> vehicleList = null; List<Vehicle> vehicleList = null;
if (vehicleHolidayPriceInfo.getAllVehicleUse() != null && vehicleHolidayPriceInfo.getAllVehicleUse() == 1) {//所有车辆可用 if (vehicleHolidayPriceInfo.getAllVehicleUse() != null && vehicleHolidayPriceInfo.getAllVehicleUse() == 1) {//所有车辆可用
...@@ -76,41 +73,29 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM ...@@ -76,41 +73,29 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
vehicleList = vehicleBiz.getAllVehicleByCompanyId(vehicle.getSubordinateBranch(), null); vehicleList = vehicleBiz.getAllVehicleByCompanyId(vehicle.getSubordinateBranch(), null);
} }
if (vehicleList == null || vehicleList.size() <= 0) { //单个车辆可用 if (vehicleList == null || vehicleList.size() <= 0) { //单个车辆可用
deleteAllVehiclePrice(vehicleHolidayPriceInfo.getVehicleId(), vehicleHolidayPriceInfo.getFestivalId());
Integer festivalId = getMaxFestivalId() + 1;
for(String date : getAllDate(vehicleHolidayPriceInfo.getStartTime(), vehicleHolidayPriceInfo.getEndTime())) { for(String date : getAllDate(vehicleHolidayPriceInfo.getStartTime(), vehicleHolidayPriceInfo.getEndTime())) {
vehicleHolidayPriceInfo.setFestivalDate(DateTime.parse(date, DATE_TIME_FORMATTER).toDate()); vehicleHolidayPriceInfo.setFestivalDate(DateTime.parse(date, DATE_TIME_FORMATTER).toDate());
VehicleHolidayPriceInfo oldValue = getByVehicleId(vehicleHolidayPriceInfo.getVehicleId(), date);
if (oldValue == null) {
vehicleHolidayPriceInfo.setId(null); vehicleHolidayPriceInfo.setId(null);
vehicleHolidayPriceInfo.setFestivalId(festivalId); vehicleHolidayPriceInfo.setFestivalId(festivalId);
insertSelectiveRe(vehicleHolidayPriceInfo); insertSelectiveRe(vehicleHolidayPriceInfo);
} else {
BeanUtil.copyProperties(vehicleHolidayPriceInfo, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
updateSelectiveByIdRe(oldValue);
}
} }
} else { } else {
Integer festivalId = getMaxFestivalId() + 1;
vehicleList.parallelStream().forEach(vehicleInfo -> { vehicleList.parallelStream().forEach(vehicleInfo -> {
if (vehicleInfo != null) { if (vehicleInfo != null) {
deleteAllVehiclePrice(vehicleInfo.getId(), vehicleHolidayPriceInfo.getFestivalId());
for(String date : getAllDate(vehicleHolidayPriceInfo.getStartTime(), vehicleHolidayPriceInfo.getEndTime())) { for(String date : getAllDate(vehicleHolidayPriceInfo.getStartTime(), vehicleHolidayPriceInfo.getEndTime())) {
VehicleHolidayPriceInfo oldValue = getByVehicleId(vehicleInfo.getId(), date); VehicleHolidayPriceInfo oldValue = new VehicleHolidayPriceInfo();
if (oldValue == null ) {
oldValue = new VehicleHolidayPriceInfo();
oldValue.setFestivalDate(DateTime.parse(date, DATE_TIME_FORMATTER).toDate()); oldValue.setFestivalDate(DateTime.parse(date, DATE_TIME_FORMATTER).toDate());
oldValue.setVehicleId(vehicleInfo.getId()); oldValue.setVehicleId(vehicleInfo.getId());
oldValue.setCompanyId(vehicleInfo.getSubordinateBranch()); oldValue.setCompanyId(vehicleInfo.getSubordinateBranch());
oldValue.setModelId(vehicleInfo.getModelId()); oldValue.setModelId(vehicleInfo.getModelId());
oldValue.setId(null); oldValue.setId(null);
oldValue.setFestivalId(festivalId); oldValue.setFestivalId(festivalId);
insertSelectiveRe(vehicleHolidayPriceInfo); insertSelectiveRe(oldValue);
} else {
BeanUtil.copyProperties(vehicleHolidayPriceInfo, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
oldValue.setFestivalDate(DateTime.parse(date, DATE_TIME_FORMATTER).toDate());
oldValue.setVehicleId(vehicleInfo.getId());
oldValue.setCompanyId(vehicleInfo.getSubordinateBranch());
oldValue.setModelId(vehicleInfo.getModelId());
updateSelectiveByIdRe(oldValue);
}
} }
} }
...@@ -129,6 +114,15 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM ...@@ -129,6 +114,15 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
return mapper.selectOneByExample(example); return mapper.selectOneByExample(example);
} }
public void deleteAllVehiclePrice(String vehicleId, Integer festivalId) {
List<VehicleHolidayPriceInfo> list = getByVehicleIdAndFestivalId(vehicleId, festivalId);
if (list != null && list.size() > 0) {
list.parallelStream().forEach(vehicleHolidayPriceInfo -> {
deleteById(vehicleHolidayPriceInfo.getId());
});
}
}
//获取所有车的价格 //获取所有车的价格
public ObjectRestResponse<List<VehicleHolidayPriceInfo>> getAllByVehicleIds(List<VehicleHolidayPriceInfo> list) { public ObjectRestResponse<List<VehicleHolidayPriceInfo>> getAllByVehicleIds(List<VehicleHolidayPriceInfo> list) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment