Commit 5e6155db authored by jiaorz's avatar jiaorz

Merge branch 'master-count-vehicle' into dev

# Conflicts:
#	xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/feign/VehicleFeign.java
parents fe434696 c9cde665
...@@ -7,6 +7,7 @@ import java.util.Map; ...@@ -7,6 +7,7 @@ import java.util.Map;
public enum OrderViolateEnum { public enum OrderViolateEnum {
BEFORE(1, "提前"), BEFORE(1, "提前"),
AFTER(2, "延期"), AFTER(2, "延期"),
CHANGE(3, "更换还车公司"),
; ;
/** /**
* 编码 * 编码
......
...@@ -32,7 +32,7 @@ public class DedDetailDTO { ...@@ -32,7 +32,7 @@ public class DedDetailDTO {
//作为:DedDetail :2、车辆损坏 3、其他 //作为:DedDetail :2、车辆损坏 3、其他
//作为:violate_amount_detail 1--提前还车 2--延期还车 3--消费超额 //作为:violate_amount_detail 1--提前还车 2--延期还车 3--更换还车公司费用
Integer type; Integer type;
//小雨都不知道什么东西 //小雨都不知道什么东西
......
...@@ -2,6 +2,7 @@ package com.xxfc.platform.order.pojo.order; ...@@ -2,6 +2,7 @@ package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense; import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import lombok.Data; import lombok.Data;
...@@ -21,6 +22,9 @@ public class OrderPageVO extends BaseOrder { ...@@ -21,6 +22,9 @@ public class OrderPageVO extends BaseOrder {
List<VehicleUserLicense> vehicleUserLicenses; List<VehicleUserLicense> vehicleUserLicenses;
//更换还车公司记录
List<BookRecordUpdateLog> bookRecordUpdateLogs;
/** /**
* 用户名 * 用户名
*/ */
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO; import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
...@@ -48,6 +49,7 @@ import com.xxfc.platform.vehicle.entity.Vehicle; ...@@ -48,6 +49,7 @@ import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense; import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.util.DistanceUtil;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -59,6 +61,7 @@ import org.springframework.stereotype.Service; ...@@ -59,6 +61,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.awt.geom.Point2D;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -66,6 +69,7 @@ import java.util.stream.Collectors; ...@@ -66,6 +69,7 @@ import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*; import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.*; import static com.github.wxiaoqi.security.common.constant.CommonConstants.*;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER; import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.ILLEGAL_TYPE;
/** /**
* @author zjw * @author zjw
...@@ -315,8 +319,57 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -315,8 +319,57 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder); initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder);
} }
} }
orderPageVO.setDedDetailDTO(JSONObject.toJSONString(dedDetailDTO)); JSONArray jsonArray = new JSONArray();
if (dedDetailDTO.getCost().intValue() != 0 || dedDetailDTO.getExcessCost().intValue() != 0) {
jsonArray.add(dedDetailDTO);
}
DedDetailDTO dedDetailDTO1 = new DedDetailDTO();
//添加更改还车公司计算费用
if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getBookRecordId() != null) {
//查询是否有更换还车记录
List<BookRecordUpdateLog> bookRecordUpdateLogs = vehicleFeign.get(orderPageVO.getOrderRentVehicleDetail().getBookRecordId()).getData();
if(bookRecordUpdateLogs != null && bookRecordUpdateLogs.size() > 0) {
orderPageVO.setBookRecordUpdateLogs(bookRecordUpdateLogs);
//有更换记录,则需要计算更换费用
//原始公司经纬度,列表中最后一个 bookRecordUpdateLogs.get(bookRecordUpdateLogs.size -1 ) 最后还车公司是列表中的第一条中的getNewRetCompanyId
BookRecordUpdateLog oldCompany = bookRecordUpdateLogs.get(bookRecordUpdateLogs.size() -1);
BookRecordUpdateLog newCompany = bookRecordUpdateLogs.get(0);
if (oldCompany != null && newCompany != null) {
CompanyDetail oldCompanyDetail = vehicleFeign.getCompanyDetail(oldCompany.getOldRetCompanyId()).getData();
CompanyDetail newCompanyDetail = vehicleFeign.getCompanyDetail(newCompany.getNewRetCompanyId()).getData();
if (oldCompanyDetail.getLatitude() != null && oldCompanyDetail.getLongitude() != null && newCompanyDetail.getLongitude() != null && newCompanyDetail.getLatitude() != null) {
//根据经纬度获取两个公司的距离
double distance = DistanceUtil.getDistance(oldCompanyDetail.getLongitude().doubleValue(), oldCompanyDetail.getLatitude().doubleValue(), newCompanyDetail.getLongitude().doubleValue(), newCompanyDetail.getLatitude().doubleValue());
log.info("两个公司的距离为(米): {}", distance);
BigDecimal distanceNum = new BigDecimal(distance + "").divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_UP);
//取出费用计算的单价
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
BigDecimal illegalReserve = new BigDecimal(dictionaryMap.get(ILLEGAL_TYPE + "_" + DictionaryKey.ILLEGAL_FEE_PRICE).getDetail());
BigDecimal totalCost = distanceNum.multiply(illegalReserve);
log.info("更换两个公司的总费用为: {}", totalCost);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(illegalReserve);
stringBuilder.append(" x ");
stringBuilder.append(distanceNum);
stringBuilder.append("(KM)");
stringBuilder.append(" = ");
stringBuilder.append(totalCost);
stringBuilder.append("元");
dedDetailDTO1.setCost(totalCost);
initDedDetail(dedDetailDTO1, OrderViolateEnum.CHANGE.getCode(), totalCost, stringBuilder);
}
}
}
}
if (dedDetailDTO1.getCost().intValue() != 0) {
jsonArray.add(dedDetailDTO1);
}
orderPageVO.setDedDetailDTO(jsonArray.toJSONString());
} }
public void initDedDetail(DedDetailDTO dedDetailDTO, Integer type, BigDecimal cost, StringBuilder stringBuilder) { public void initDedDetail(DedDetailDTO dedDetailDTO, Integer type, BigDecimal cost, StringBuilder stringBuilder) {
String detailName = null; String detailName = null;
if (type == OrderViolateEnum.BEFORE.getCode()) { if (type == OrderViolateEnum.BEFORE.getCode()) {
...@@ -325,6 +378,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -325,6 +378,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
} else if (type == OrderViolateEnum.AFTER.getCode()) { } else if (type == OrderViolateEnum.AFTER.getCode()) {
dedDetailDTO.setType(OrderViolateEnum.AFTER.getCode()); dedDetailDTO.setType(OrderViolateEnum.AFTER.getCode());
detailName = "延期还车违约金"; detailName = "延期还车违约金";
} else if (type == OrderViolateEnum.CHANGE.getCode()) {
dedDetailDTO.setType(OrderViolateEnum.CHANGE.getCode());
detailName = "更换还车公司";
} }
//900元+违约金(¥900x2天=)1800元 //900元+违约金(¥900x2天=)1800元
dedDetailDTO.setDeductions(stringBuilder.toString()); dedDetailDTO.setDeductions(stringBuilder.toString());
......
...@@ -35,7 +35,6 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo; ...@@ -35,7 +35,6 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -264,13 +263,16 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -264,13 +263,16 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} }
//延期扣除费用 //延期扣除费用
if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) { if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) {
JSONObject jsonObject = JSONObject.parseObject(orderVehicleCrosstownDto.getViolateDetail()); JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getViolateDetail());
if (jsonObject != null) { if(jsonArray != null && jsonArray.size() > 0) {
if (jsonObject.getString("cost") != null) { for (int i = 0; i < jsonArray.size(); i++) {
cost += Double.parseDouble(jsonObject.getString("cost")); JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
} if (jsonObject.getString("cost") != null) {
if (jsonObject.getString("excessCost") != null) { cost += Double.parseDouble(jsonObject.getString("cost"));
cost += Double.parseDouble(jsonObject.getString("excessCost")); }
if (jsonObject.getString("excessCost") != null) {
cost += Double.parseDouble(jsonObject.getString("excessCost"));
}
} }
} }
} }
......
...@@ -7,6 +7,17 @@ public class DictionaryKey { ...@@ -7,6 +7,17 @@ public class DictionaryKey {
*/ */
public static final String APP_ORDER ="APP_ORDER"; public static final String APP_ORDER ="APP_ORDER";
/**
* 违约类型
*/
public static final String ILLEGAL_TYPE = "ILLEGAL_TYPE";
/**
* 更换还车公司费用计算单价
*/
public static final String ILLEGAL_FEE_PRICE = "ILLEGAL_FEE_PRICE";
/** /**
* IM类型 * IM类型
*/ */
......
...@@ -16,7 +16,8 @@ public enum BookType { ...@@ -16,7 +16,8 @@ public enum BookType {
BOOKING(7,"预约中"), BOOKING(7,"预约中"),
DISABLE(8,"禁用"), DISABLE(8,"禁用"),
CUSTOMER_APPLY(9, "客户用车"), CUSTOMER_APPLY(9, "客户用车"),
OTHER(10, "其他") OTHER(10, "其他"),
DISPATCH(11, "调度")
; ;
/** /**
* 编码 * 编码
......
...@@ -52,4 +52,10 @@ public class BookRecordUpdateLog { ...@@ -52,4 +52,10 @@ public class BookRecordUpdateLog {
*/ */
@Column(name = "create_time") @Column(name = "create_time")
private Date createTime; private Date createTime;
@Transient
private String oldCompanyName;
@Transient
private String newCompanyName;
} }
\ No newline at end of file
...@@ -196,4 +196,7 @@ public interface VehicleFeign { ...@@ -196,4 +196,7 @@ public interface VehicleFeign {
@RequestParam(value = "vehicleModelId") Integer vehicleModelId, @RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId); @RequestParam(value = "userId") Integer userId);
@GetMapping(value = "/bookRecord/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(@RequestParam(value = "bookRecordId")Long bookRecordId);
} }
package com.xxfc.platform.vehicle.util;
import java.awt.geom.Point2D;
import java.math.BigDecimal;
public class DistanceUtil {
private static final double EARTH_RADIUS = 6371393; // 平均半径,单位:m
/**
* 通过AB点经纬度获取距离
* @param pointA A点(经,纬)
* @param pointB B点(经,纬)
* @return 距离(单位:米)
*/
public static double getDistance(Point2D pointA, Point2D pointB) {
// 经纬度(角度)转弧度。弧度用作参数,以调用Math.cos和Math.sin
double radiansAX = Math.toRadians(pointA.getX()); // A经弧度
double radiansAY = Math.toRadians(pointA.getY()); // A纬弧度
double radiansBX = Math.toRadians(pointB.getX()); // B经弧度
double radiansBY = Math.toRadians(pointB.getY()); // B纬弧度
// 公式中“cosβ1cosβ2cos(α1-α2)+sinβ1sinβ2”的部分,得到∠AOB的cos值
double cos = Math.cos(radiansAY) * Math.cos(radiansBY) * Math.cos(radiansAX - radiansBX)
+ Math.sin(radiansAY) * Math.sin(radiansBY);
// System.out.println("cos = " + cos); // 值域[-1,1]
double acos = Math.acos(cos); // 反余弦值
// System.out.println("acos = " + acos); // 值域[0,π]
// System.out.println("∠AOB = " + Math.toDegrees(acos)); // 球心角 值域[0,180]
return EARTH_RADIUS * acos; // 最终结果
}
public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
Point2D pointDD = new Point2D.Double(longitude1, latitude1);
// 北京 西单地铁站
Point2D pointXD = new Point2D.Double(longitude2, latitude2);
return getDistance(pointDD, pointXD);
}
public static void main(String[] args) {
// 北京 东单地铁站
Point2D pointDD = new Point2D.Double(113.906121, 22.985271);
// 北京 西单地铁站
Point2D pointXD = new Point2D.Double(114.42078, 23.05989);
System.out.println(getDistance(pointDD, pointXD));
BigDecimal distanceNum = new BigDecimal(getDistance(pointDD, pointXD) + "").divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_UP);
BigDecimal bigDecimal = new BigDecimal(2);
System.out.println(distanceNum.multiply(bigDecimal));
}
}
...@@ -3,12 +3,20 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,12 +3,20 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog; import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.mapper.BookRecordUpdateLogMapper; import com.xxfc.platform.vehicle.mapper.BookRecordUpdateLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@Service @Service
public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, BookRecordUpdateLog> { public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, BookRecordUpdateLog> {
@Autowired
BranchCompanyBiz branchCompanyBiz;
public ObjectRestResponse save(BookRecordUpdateLog bookRecordUpdateLog) { public ObjectRestResponse save(BookRecordUpdateLog bookRecordUpdateLog) {
BookRecordUpdateLog oldValue = mapper.selectOne(bookRecordUpdateLog); BookRecordUpdateLog oldValue = mapper.selectOne(bookRecordUpdateLog);
if (oldValue != null) { if (oldValue != null) {
...@@ -18,4 +26,22 @@ public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, B ...@@ -18,4 +26,22 @@ public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, B
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse<List<BookRecordUpdateLog>> selectByBookRecordId(Long bookRecordId) {
Example example = new Example(BookRecordUpdateLog.class);
example.createCriteria().andEqualTo("bookRecordId", bookRecordId);
example.setOrderByClause("create_time desc");
List<BookRecordUpdateLog> bookRecordUpdateLogs = selectByExample(example);
for (BookRecordUpdateLog bookRecordUpdateLog : bookRecordUpdateLogs) {
BranchCompany oldCompany = branchCompanyBiz.getById(bookRecordUpdateLog.getOldRetCompanyId());
if (oldCompany != null) {
bookRecordUpdateLog.setOldCompanyName(oldCompany.getName());
}
BranchCompany newCompany = branchCompanyBiz.getById(bookRecordUpdateLog.getNewRetCompanyId());
if (newCompany != null) {
bookRecordUpdateLog.setNewCompanyName(newCompany.getName());
}
}
return ObjectRestResponse.succ(bookRecordUpdateLogs);
}
} }
...@@ -215,7 +215,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -215,7 +215,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
@Cache(key = RedisKey.BRANCH_COMPANY_CACHE_ALL) @Cache(key = RedisKey.BRANCH_COMPANY_CACHE_ALL)
public List<BranchCompany> getAll() { public List<BranchCompany> getAll() {
return mapper.selectAll(); Example example = new Example(BranchCompany.class);
example.createCriteria().andEqualTo("isDel", 0);
return mapper.selectByExample(example);
} }
/** /**
......
...@@ -309,6 +309,10 @@ public class VehicleActiveService { ...@@ -309,6 +309,10 @@ public class VehicleActiveService {
} }
} }
public void save(VehicleDepartureLog vehicleDepartureLog){
vehicleDepartureLogMapper.insertSelective(vehicleDepartureLog);
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态 //添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
public void checkDateInvalid(VehicleDepartureVo arrivalVo) { public void checkDateInvalid(VehicleDepartureVo arrivalVo) {
if (arrivalVo.getBookRecordId() != null) { if (arrivalVo.getBookRecordId() != null) {
......
...@@ -19,11 +19,8 @@ import com.google.common.collect.Lists; ...@@ -19,11 +19,8 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException; import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ConstantType; import com.xxfc.platform.vehicle.constant.*;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.constant.VehicleStatus;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper; import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper;
import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper; import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper;
...@@ -275,10 +272,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -275,10 +272,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/ */
@Transactional @Transactional
public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception { public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception {
if (addOrUpdateVehicleVoList.size() > MAX_BATCH_SIZE_VEHICLE) { if (addOrUpdateVehicleVoList != null && addOrUpdateVehicleVoList.size() > MAX_BATCH_SIZE_VEHICLE) {
throw new BaseException(ResultCode.ADD_VEHICLE_MORE); throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
} }
UserDTO userDTO = getAdminUserInfo();
if (userDTO == null) {
throw new BaseException(ResultCode.RSTOKEN_EXPIRED_CODE);
}
for (AddOrUpdateVehicleVo addOrUpdateVehicleVo : addOrUpdateVehicleVoList) { for (AddOrUpdateVehicleVo addOrUpdateVehicleVo : addOrUpdateVehicleVoList) {
Vehicle vehicle = new Vehicle(); Vehicle vehicle = new Vehicle();
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo); BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
...@@ -291,7 +291,35 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -291,7 +291,35 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
if (CollectionUtils.isNotEmpty(exitsVehicles)) { if (CollectionUtils.isNotEmpty(exitsVehicles)) {
for (Vehicle exitsVehicle : exitsVehicles) { for (Vehicle exitsVehicle : exitsVehicles) {
if (exitsVehicle.getId().equals(addOrUpdateVehicleVo.getId())) { if (exitsVehicle.getId().equals(addOrUpdateVehicleVo.getId())) {
continue; //如果修改的有停靠分公司,需要添加一条调度记录
Vehicle vehicle1 = selectById(exitsVehicle.getId());
if (vehicle1 != null) {
if (vehicle1.getParkBranchCompanyId() != addOrUpdateVehicleVo.getParkBranchCompanyId()) {
VehicleBookRecord vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setRetCompany(addOrUpdateVehicleVo.getParkBranchCompanyId());
vehicleBookRecord.setLiftCompany(vehicle1.getParkBranchCompanyId());
vehicleBookRecord.setRemark("后台修改停靠公司,调度车辆");
vehicleBookRecord.setBookStartDate(new Date());
vehicleBookRecord.setBookEndDate(new Date());
vehicleBookRecord.setActualEndDate(new Date());
vehicleBookRecord.setActualStartDate(new Date());
vehicleBookRecord.setBookUser(userDTO.getId());
vehicleBookRecord.setBookUserName(userDTO.getUsername());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode());
vehicleBookRecord.setBookType(BookType.DISPATCH.getCode());
vehicleBookRecord.setVehicleId(vehicle1.getId());
vehicleBookRecord.setVehicleUsername(userDTO.getUsername());
vehicleBookRecord.setVehicleUserPhone(userDTO.getUsername());
ObjectRestResponse objectRestResponse = addVehicleBookRecord(vehicleBookRecord);
if(objectRestResponse.isRel()) {
continue;
} else {
return RestResponse.codeAndMessage(objectRestResponse.getStatus(), objectRestResponse.getMessage());
}
}
}
} }
return RestResponse.codeAndMessage(ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getCode(), return RestResponse.codeAndMessage(ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getCode(),
ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getDesc()); ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getDesc());
...@@ -309,6 +337,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -309,6 +337,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return RestResponse.suc(); return RestResponse.suc();
} }
public ObjectRestResponse addVehicleBookRecord(VehicleBookRecord vehicleBookRecord) {
return vehicleBookRecordBiz.addBookRecord(vehicleBookRecord);
}
/** /**
* 废弃车辆(状态设置为废弃) * 废弃车辆(状态设置为废弃)
* *
...@@ -326,95 +358,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -326,95 +358,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return RestResponse.suc(); return RestResponse.suc();
} }
// /**
// * 申请汽车预定(内部)
// * 检查是否可预定,修改相关预定记录状态
// * @param userId
// * @param bookVehicleVo
// * @return
// */
// @Transactional
// public VehicleBookRecord applyVehicle4Employee(Integer userId, BookVehicleVO bookVehicleVo, String userName) throws Exception{
// //检查车辆信息是否合法
// checkIfVehicleExists(bookVehicleVo.getVehicleId());
// //提取日期和相应的预定目标日期
// Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
// //预定时间不能为空
// if(StringUtils.isBlank(bookVehicleVo.getBookStartDate()) || StringUtils.isBlank(bookVehicleVo.getBookEndDate())){
// throw new BaseException(ResultCode.DATE_TIME_IS_NULL);
// }
// String[] bookStartDateArray = bookVehicleVo.getBookStartDate().split(" ");
// String[] bookEndDateArray = bookVehicleVo.getBookEndDate().split(" ");
//
// DateTime startDay =DateTime.parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER);
// DateTime endDay =DateTime.parse(bookEndDateArray[0], DEFAULT_DATE_TIME_FORMATTER);
//
//
// //转换日期范围为列表,并检查是否合法
// fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
// if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
// throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
// }
// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
// //检查车辆是否可以预定
// for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
// Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
// if(Boolean.FALSE.equals(rsEach)){
// throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
// }
// }
//
// //加入预定申请记录
// VehicleBookRecord vehicleBookRecord = new VehicleBookRecord();
// vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId());
// vehicleBookRecord.setBookType(bookVehicleVo.getBookType());
// vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
// vehicleBookRecord.setBookUser(userId);
// vehicleBookRecord.setBookUserName(userName);
// vehicleBookRecord.setBookStartDate(DateTime.
// parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
// vehicleBookRecord.setBookEndDate(DateTime.
// parse(bookEndDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
// vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
// vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
// vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
// vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
// vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
// vehicleBookRecord.setOrderNo(bookVehicleVo.getOrderNo());
// vehicleBookRecordBiz.save(vehicleBookRecord);
//// //添加预定时间记录
////
//// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
//// for(Map.Entry<String, Integer> entry : map.entrySet()) {
//// VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
//// vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
//// vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
//// vehicleBookHourInfoDto.setBookedHour(entry.getValue());
//// vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto);
//// }
//
// //修改相关车辆预定记录
// Boolean hasSuc = bookedVehicle(bookVehicleVo);
// if(!hasSuc){
// throw new BaseException(ResultCode.BOOKED_FAILED_CODE);
// }
//
// //添加随车物品
// List<Map<String,Object>> params = Lists.newArrayList();
// if(MapUtils.isNotEmpty(bookVehicleVo.getSelectedAccItem())){
// for(Map.Entry<Integer,Integer> idAndAmount : bookVehicleVo.getSelectedAccItem().entrySet()){
// Map<String,Object> row = Maps.newHashMap();
// row.put("id",idAndAmount.getKey());
// row.put("amount",idAndAmount.getValue());
// row.put("bookRecordId",vehicleBookRecord.getId());
// params.add(row);
// }
// bookRecordAccItemMapper.batchAdd(params);
// }
//
// return vehicleBookRecord;
// }
/** /**
* 不需要审核 * 不需要审核
* *
......
...@@ -29,7 +29,6 @@ import org.apache.commons.beanutils.BeanUtils; ...@@ -29,7 +29,6 @@ import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
...@@ -81,6 +80,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -81,6 +80,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
@Autowired @Autowired
BookRecordUpdateLogBiz bookRecordUpdateLogBiz; BookRecordUpdateLogBiz bookRecordUpdateLogBiz;
@Autowired
VehicleActiveService vehicleActiveService;
@Override @Override
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
...@@ -389,6 +391,38 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -389,6 +391,38 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return RestResponse.suc(); return RestResponse.suc();
} }
public ObjectRestResponse addBookRecord(VehicleBookRecord vehicleBookRecord) {
if (vehicleBookRecord == null) {
return ObjectRestResponse.paramIsEmpty();
}
save(vehicleBookRecord);
if (vehicleBookRecord != null) {
//添加交还车记录
VehicleDepartureLog vehicleDepartureLog = new VehicleDepartureLog();
vehicleDepartureLog.setBookRecordId(vehicleBookRecord.getId());
vehicleDepartureLog.setArrivalBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleDepartureLog.setArrivalRemark("后台修改停靠分公司,车辆调度");
vehicleDepartureLog.setArrivalTime(new Date());
vehicleDepartureLog.setCheckMan(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setCheckManTel(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany());
vehicleDepartureLog.setDepartureRemark("后台修改停靠分公司,车辆调度");
vehicleDepartureLog.setDepartureTime(new Date());
vehicleDepartureLog.setRecycleMan(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setRecycleManTel(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setState(1);
vehicleDepartureLog.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleDepartureLog.setUse("调度");
vehicleDepartureLog.setUser(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setUserTel(vehicleBookRecord.getBookUserName());
vehicleActiveService.save(vehicleDepartureLog);
}
return ObjectRestResponse.succ();
}
/** /**
* 按页查询 * 按页查询
* *
......
...@@ -6,6 +6,8 @@ import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog; ...@@ -6,6 +6,8 @@ import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController @RestController
@RequestMapping("/bookRecord") @RequestMapping("/bookRecord")
public class BookRecordUpdateLogController { public class BookRecordUpdateLogController {
...@@ -17,4 +19,10 @@ public class BookRecordUpdateLogController { ...@@ -17,4 +19,10 @@ public class BookRecordUpdateLogController {
public ObjectRestResponse save(@RequestBody BookRecordUpdateLog bookRecordUpdateLog) { public ObjectRestResponse save(@RequestBody BookRecordUpdateLog bookRecordUpdateLog) {
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog); return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} }
@GetMapping(value = "/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(Long bookRecordId) {
return bookRecordUpdateLogBiz.selectByBookRecordId(bookRecordId);
}
} }
...@@ -126,6 +126,11 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -126,6 +126,11 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return RestResponse.suc(vehicles); return RestResponse.suc(vehicles);
} }
@PostMapping(value = "/test")
public ObjectRestResponse test(@RequestBody VehicleBookRecord vehicleBookRecord) {
return vehicleBiz.addVehicleBookRecord(vehicleBookRecord);
}
@RequestMapping(value = "/page", method = RequestMethod.GET) @RequestMapping(value = "/page", method = RequestMethod.GET)
public RestResponse<PageDataVO<ResultVehicleVo>> getByPage(@RequestParam String vehiclePageQueryVoJson) throws Exception { public RestResponse<PageDataVO<ResultVehicleVo>> getByPage(@RequestParam String vehiclePageQueryVoJson) throws Exception {
VehiclePageQueryVo vehiclePageQueryVo = null; VehiclePageQueryVo vehiclePageQueryVo = null;
......
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