Commit 208f09f8 authored by zuoyh's avatar zuoyh

修改

parent aedd6b98
......@@ -50,7 +50,8 @@ public enum DeductionTypeEnum {
codeAndDesc.put(enumE.getCode(), enumE.getDesc());
}
lateFeeCode = Lists.newArrayList(VIOLATE_CANCEL.getCode(),
lateFeeCode = Lists.newArrayList(
VIOLATE_CANCEL.getCode(),
VIOLATE_ADVANCE.getCode(),
VIOLATE_DELAY.getCode(),
VIOLATE_CHANGE_C.getCode());
......
......@@ -52,33 +52,32 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
/**
* 租车统计处理
*
* @param startDate 开始时间
* @param endDate 结束时间
* @param startDate 开始时间
* @param endDate 结束时间
* @param companyMap 公司
*/
public List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatistics(Date startDate, Date endDate,Map<Integer,String> companyMap) {
public List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatistics(Date startDate, Date endDate, Map<Integer, String> companyMap) {
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = new ArrayList<>();
List<String> stisticsActiveState = new ArrayList<>();
//根据租车订单类型 时间查询
List<OrderDTO> orderDTOS = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_RENT_VEHICLE_TYPE), startDate, endDate);
//数据处理 状态组合 按支付状态分组 而后按组合状态
//数据处理 状态组合 按支付状态分组 而后按组合状态
Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = orderDTOS.stream().peek(x -> {
x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(),
x.getOrderOrigin(),
x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY:x.getPayWay()
,x.getHasPay()));
x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay()
, x.getHasPay()));
stisticsActiveState.add(x.getStateGroup());
})
.collect(Collectors.partitioningBy(x -> Objects.nonNull(x.getPayWay()), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList())));
}).collect(Collectors.partitioningBy(x -> Objects.nonNull(x.getPayWay()), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList())));
//订单账目信息
List<OrderAccountBo> orderAccountBoList = orderAccountBiz.selectByTypeAndDate(StatisticsStatusEnum.ORDER_RENT_VEHICLE_TYPE,startDate, endDate);
List<OrderAccountBo> orderAccountBoList = orderAccountBiz.selectByTypeAndDate(StatisticsStatusEnum.ORDER_RENT_VEHICLE_TYPE, startDate, endDate);
//账目数据处理 状态组合
Map<String, List<OrderAccountBo>> ordersMap = orderAccountBoList.stream().peek(x -> {
x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(),
x.getOrderOrigin(),
x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY:x.getPayWay(),
x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(),
x.getHasPay()));
stisticsActiveState.add(x.getStateGroup());
}).collect(Collectors.groupingBy(OrderAccountBo::getStateGroup, Collectors.toList()));
......@@ -89,7 +88,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
for (Map.Entry<String, List<OrderAccountBo>> orderEntry : ordersSet) {
String orderKey = orderEntry.getKey();
List<OrderAccountBo> orderAccountBos = orderEntry.getValue();
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, orderKey,companyMap,new OrderRentVehicleReceivedStatistics());
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, orderKey, companyMap, new OrderRentVehicleReceivedStatistics());
//订单总金额
BigDecimal totalOrderAmount = BigDecimal.ZERO;
//订单总押金
......@@ -117,7 +116,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
totalOrderAmount = totalOrderAmount.add(accountDetailEntity.getOrderAmount());
totalDepositAmount = totalDepositAmount.add(accountDetailEntity.getDepositAmount());
if (Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)){
if (Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)) {
JSONObject data = orderAccountBo.getData();
if (!data.isEmpty()) {
Object paramJson = data.get(StatisticsStatusEnum.PARMAM_JSON);
......@@ -131,33 +130,32 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
totalDepositRefundAmount = totalDepositRefundAmount.add(accountDetailEntity.getDepositAmount());
List<OrderAccountDeduction> deductions = accountDetailEntity.getDeductions();
for (OrderAccountDeduction deduction : deductions) {
if (DeductionTypeEnum.lateFeeCode.contains(deduction.getType())){
totalLateFeeAmount = totalLateFeeAmount.add(deduction.getAmount());
if (deduction.getType().equals(DeductionTypeEnum.VIOLATE_CANCEL.getCode())){
if (Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)){
JSONObject data = orderAccountBo.getData();
if(!data.isEmpty()) {
Object paramJson = data.get(StatisticsStatusEnum.PARMAM_JSON);
JSONObject jsonObject = JSONUtil.parseObj(paramJson);
BigDecimal safeAmount = jsonObject.get(StatisticsStatusEnum.NO_DEDUCTIBLE_AMOUNT, BigDecimal.class);
refundDamageSafeAmount = refundDamageSafeAmount.add(safeAmount);
}
}
}
}
if (DeductionTypeEnum.breakRulesRegulationCode.contains(deduction.getType())){
totalBreakRulesRegulationAmount = totalBreakRulesRegulationAmount.add(deduction.getAmount());
}
if (DeductionTypeEnum.lateFeeCode.contains(deduction.getType())) {
totalLateFeeAmount = totalLateFeeAmount.add(deduction.getAmount());
if (deduction.getType().equals(DeductionTypeEnum.VIOLATE_CANCEL.getCode())) {
if (Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)) {
JSONObject data = orderAccountBo.getData();
if (!data.isEmpty()) {
Object paramJson = data.get(StatisticsStatusEnum.PARMAM_JSON);
JSONObject jsonObject = JSONUtil.parseObj(paramJson);
BigDecimal safeAmount = jsonObject.get(StatisticsStatusEnum.NO_DEDUCTIBLE_AMOUNT, BigDecimal.class);
refundDamageSafeAmount = refundDamageSafeAmount.add(safeAmount);
}
}
}
}
if (DeductionTypeEnum.breakRulesRegulationCode.contains(deduction.getType())) {
totalBreakRulesRegulationAmount = totalBreakRulesRegulationAmount.add(deduction.getAmount());
}
if (DeductionTypeEnum.lossSpecifiedCode.contains(deduction.getType())){
totalLossSpecifiedAmount = totalLossSpecifiedAmount.add(deduction.getAmount());
}
if (DeductionTypeEnum.lossSpecifiedCode.contains(deduction.getType())) {
totalLossSpecifiedAmount = totalLossSpecifiedAmount.add(deduction.getAmount());
}
if (DeductionTypeEnum.consumerCode.contains(deduction.getType())){
BigDecimal extendAmount = deduction.getAmount().subtract(accountDetailEntity.getOriginOrderAmount());
totalExtendAmount = totalExtendAmount.add(extendAmount);
}
if (DeductionTypeEnum.consumerCode.contains(deduction.getType())) {
BigDecimal extendAmount = deduction.getAmount().subtract(accountDetailEntity.getOriginOrderAmount());
totalExtendAmount = totalExtendAmount.add(extendAmount);
}
}
}
}
......@@ -170,21 +168,19 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
orderRentVehicleReceivedStatistics.setDepositRefundAmount(totalDepositRefundAmount);
orderRentVehicleReceivedStatistics.setBreakRulesRegulationAmount(totalBreakRulesRegulationAmount);
orderRentVehicleReceivedStatistics.setLossSpecifiedAmount(totalLossSpecifiedAmount);
Integer totalQuantity = stateGroupMap ==null?0:stateGroupMap.get(Boolean.TRUE)==null?0:stateGroupMap.get(Boolean.TRUE).get(orderKey)==null?0:stateGroupMap.get(Boolean.TRUE).get(orderKey).size();
Integer totalQuantity = stateGroupMap == null ? 0 : stateGroupMap.get(Boolean.TRUE) == null ? 0 : stateGroupMap.get(Boolean.TRUE).get(orderKey) == null ? 0 : stateGroupMap.get(Boolean.TRUE).get(orderKey).size();
orderRentVehicleReceivedStatistics.setTotalQuantity(totalQuantity);
orderRentVehicleReceivedStatisticsList.add(orderRentVehicleReceivedStatistics);
}
//未支付单
Map<String, List<OrderDTO>> noPayOrderRentvehicleMap = stateGroupMap == null?Collections.EMPTY_MAP:stateGroupMap.get(Boolean.FALSE)==null?Collections.EMPTY_MAP:stateGroupMap.get(Boolean.FALSE);
List<OrderRentVehicleReceivedStatistics> noPayOrderRentVehicleStatisticsList = createNoPayOrderRentVehicleStatisticsList(startDate,noPayOrderRentvehicleMap,companyMap);
Map<String, List<OrderDTO>> noPayOrderRentvehicleMap = stateGroupMap == null ? Collections.EMPTY_MAP : stateGroupMap.get(Boolean.FALSE) == null ? Collections.EMPTY_MAP : stateGroupMap.get(Boolean.FALSE);
List<OrderRentVehicleReceivedStatistics> noPayOrderRentVehicleStatisticsList = createNoPayOrderRentVehicleStatisticsList(startDate, noPayOrderRentvehicleMap, companyMap);
orderRentVehicleReceivedStatisticsList.addAll(noPayOrderRentVehicleStatisticsList);
//创建剩余状态组合的租车统计对象
List<OrderRentVehicleReceivedStatistics> otherStatisticsStateGroupList = createOtherStatisticsStateGroupList(startDate,stisticsActiveState, companyMap);
List<OrderRentVehicleReceivedStatistics> otherStatisticsStateGroupList = createOtherStatisticsStateGroupList(startDate, stisticsActiveState, companyMap);
orderRentVehicleReceivedStatisticsList.addAll(otherStatisticsStateGroupList);
//保存
insertMemberReceivedStatisticsBatch(orderRentVehicleReceivedStatisticsList);
......@@ -193,14 +189,13 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
}
/**
*
* @param startDate 时间
* @param startDate 时间
* @param noPayOrdersMap 未支付单map
* @return
*/
private List<OrderRentVehicleReceivedStatistics> createNoPayOrderRentVehicleStatisticsList(Date startDate,Map<String, List<OrderDTO>> noPayOrdersMap,Map<Integer,String> companyMap) {
private List<OrderRentVehicleReceivedStatistics> createNoPayOrderRentVehicleStatisticsList(Date startDate, Map<String, List<OrderDTO>> noPayOrdersMap, Map<Integer, String> companyMap) {
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = new ArrayList<>();
if (noPayOrdersMap==null || noPayOrdersMap.isEmpty()){
if (noPayOrdersMap == null || noPayOrdersMap.isEmpty()) {
return orderRentVehicleReceivedStatisticsList;
}
Set<Map.Entry<String, List<OrderDTO>>> noPayOrderSet = noPayOrdersMap.entrySet();
......@@ -208,9 +203,9 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
String noPayOrderStateGroup = noPayOrderEntry.getKey();
List<OrderDTO> noPayOrders = noPayOrderEntry.getValue();
List<BigDecimal> damageSafeAmountList = new ArrayList<>();
BigDecimal totalNoPayAmount = noPayOrders.stream().peek(x->{
BigDecimal totalNoPayAmount = noPayOrders.stream().peek(x -> {
//免赔
if (Objects.nonNull(x.getDamageSafe()) && (x.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)){
if (Objects.nonNull(x.getDamageSafe()) && (x.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)) {
JSONObject data = x.getData();
if (!data.isEmpty()) {
Object paramJson = data.get(StatisticsStatusEnum.PARMAM_JSON);
......@@ -220,8 +215,8 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
}
}
}).map(OrderDTO::getRealAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, noPayOrderStateGroup,companyMap,new OrderRentVehicleReceivedStatistics());
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, noPayOrderStateGroup, companyMap, new OrderRentVehicleReceivedStatistics());
BigDecimal damageSafeAmount = damageSafeAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
orderRentVehicleReceivedStatistics.setNoDeductibleAmount(damageSafeAmount);
BigDecimal depositAmount = noPayOrders.stream().map(OrderDTO::getDeposit).reduce(BigDecimal.ZERO, BigDecimal::add);
......@@ -241,24 +236,24 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
/**
* 创建剩余状态数据
*
* @param startDate 时间
* @param statisticsStateGroups 状态组合 集合
* @param companyMap 公司
* @param startDate 时间
* @param statisticsStateGroups 状态组合 集合
* @param companyMap 公司
* @return
*/
private List<OrderRentVehicleReceivedStatistics> createOtherStatisticsStateGroupList(Date startDate,
List<String> statisticsStateGroups,
Map<Integer,String> companyMap) {
Map<Integer, String> companyMap) {
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = new ArrayList<>(statisticsStateGroups.size());
//获取剩余状态组合
List<Integer> companyIds = Objects.isNull(companyMap)?Collections.EMPTY_LIST:Lists.newArrayList(companyMap.keySet());
List<String> otherStatisticsStateGroup = StatisticsStatusEnum.getOtherStatisticsStateGroup(companyIds,statisticsStateGroups);
List<Integer> companyIds = Objects.isNull(companyMap) ? Collections.EMPTY_LIST : Lists.newArrayList(companyMap.keySet());
List<String> otherStatisticsStateGroup = StatisticsStatusEnum.getOtherStatisticsStateGroup(companyIds, statisticsStateGroups);
//创建租车统计克隆对象
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = new OrderRentVehicleReceivedStatistics();
//统计对象的生成
otherStatisticsStateGroup.stream().map(stateGroup -> {
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(startDate, stateGroup,companyMap,ObjectUtil.cloneByStream(orderRentVehicleReceivedStatistics));
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(startDate, stateGroup, companyMap, ObjectUtil.cloneByStream(orderRentVehicleReceivedStatistics));
orderRentVehicleReceivedStatisticsClone.setDepositAmount(BigDecimal.ZERO);
orderRentVehicleReceivedStatisticsClone.setDepositRefundAmount(BigDecimal.ZERO);
orderRentVehicleReceivedStatisticsClone.setNoDeductibleAmount(BigDecimal.ZERO);
......
package com.xxfc.platform.order.biz;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import org.springframework.stereotype.Service;
import cn.hutool.core.util.ObjectUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.util.CollectorsUtil;
import com.google.common.collect.Lists;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
import com.xxfc.platform.order.mapper.OrderTourReceivedStatisticsMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Transactional;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import com.xxfc.platform.order.pojo.order.CompanyAmountBo;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.beetl.core.parser.BeetlParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
* 旅游订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderTourReceivedStatisticsBiz extends BaseBiz<OrderTourReceivedStatisticsMapper,OrderTourReceivedStatistics> {
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j
public class OrderTourReceivedStatisticsBiz extends BaseBiz<OrderTourReceivedStatisticsMapper, OrderTourReceivedStatistics> {
private final VehicleFeign vehicleFeign;
private final BaseOrderBiz baseOrderBiz;
private final OrderAccountBiz orderAccountBiz;
private final int FINISH = 6;
private final int CANCEL = 2;
private final int UNFINISH = 3;
private final int PAY_ORDER = 101;
//提前取消违约金
private final int VIOLATE_CANCEL = 101;
public List<OrderTourReceivedStatistics> selectOrderReceivedStatistics(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO) {
return mapper.selectOrderTourReceivedStatistics(orderReceivedStatisticsFindDTO);
}
/**
* 订单统计批量插入旅游统计表
* zuoyihang
* 2019-11-12
*
* @param startDate 开始时间
* @param endDate 结束时间
*/
public List<OrderTourReceivedStatistics> orderTourInsertStatisticsNew(Date startDate, Date endDate, Map<Integer, String> companyMap) {
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = new ArrayList();
List<String> stisticsActiveState = new ArrayList<>();
//公司的收入与支出 ---》无状态
List<CompanyAmountBo> companyAmoutList = new ArrayList<>();
//根据旅游类型 时间查询
List<OrderDTO> orderDTOS = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_TOUR_TYPE), startDate, endDate);
//数据处理 状态组合 按支付状态分组 而后按组合状态
Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = orderDTOS.stream().peek(x -> {
x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(), x.getOrderOrigin(), x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(), x.getHasPay()));
stisticsActiveState.add(x.getStateGroup());
}).collect(Collectors.partitioningBy(x -> Objects.nonNull(x.getPayWay()), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList())));
//订单账目信息
List<OrderAccountBo> orderAccountBoList = orderAccountBiz.selectByTypeAndDate(StatisticsStatusEnum.ORDER_TOUR_TYPE, startDate, endDate);
//账目数据整理 状态组合
Map<String, List<OrderAccountBo>> orderMap = orderAccountBoList.stream().peek(x -> {
x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(), x.getOrderOrigin(), x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(), x.getHasPay()));
}).collect(Collectors.groupingBy(OrderAccountBo::getStateGroup, Collectors.toList()));
//已经支付订单 状态101
Set<Map.Entry<String, List<OrderAccountBo>>> orderSet = orderMap.entrySet();
for (Map.Entry<String, List<OrderAccountBo>> orderEntry : orderSet) {
String orderKey = orderEntry.getKey();
List<OrderAccountBo> orderAccountBos = orderEntry.getValue();
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal refundAmount = BigDecimal.ZERO;
OrderTourReceivedStatistics orderTourReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, orderKey, companyMap, new OrderTourReceivedStatistics());
//总违约金
BigDecimal totalLateFeeAmount = BigDecimal.ZERO;
//订单退款总金额
BigDecimal totalOrderRefundAmount = BigDecimal.ZERO;
//其它费用
BigDecimal totalExtendAmount = BigDecimal.ZERO;
for (OrderAccountBo orderAccountBo : orderAccountBos) {
OrderAccountDetail accountDetailEntity = orderAccountBo.getAccountDetailEntity();
if (orderAccountBo.getAccountType() == PAY_ORDER) {
totalAmount = totalAmount.add(accountDetailEntity.getOrderAmount());
} else {
totalOrderRefundAmount = totalOrderRefundAmount.add(accountDetailEntity.getOrderAmount());
List<OrderAccountDeduction> deductions = accountDetailEntity.getDeductions();
for (OrderAccountDeduction deduction : deductions) {
//目前旅游项目只有违约金,暂无定损、违章金等
if (deduction.getType().equals(VIOLATE_CANCEL)) {
totalLateFeeAmount = totalLateFeeAmount.add(deduction.getAmount());
}
if (DeductionTypeEnum.consumerCode.contains(deduction.getType())) {
BigDecimal extendAmount = deduction.getAmount().subtract(accountDetailEntity.getOriginOrderAmount());
totalExtendAmount = totalExtendAmount.add(extendAmount);
}
}
}
}
//插入共用字段
orderTourReceivedStatistics.setTotalAmount(totalAmount.subtract(refundAmount));
orderTourReceivedStatistics.setLateFeeAmount(totalLateFeeAmount);
orderTourReceivedStatistics.setOrderRefundAmount(totalOrderRefundAmount);
orderTourReceivedStatistics.setExtraAmount(totalExtendAmount);
Integer totalQuantity = stateGroupMap == null ? 0 : stateGroupMap.get(Boolean.TRUE) == null ? 0 : stateGroupMap.get(Boolean.TRUE).get(orderKey) == null ? 0 : stateGroupMap.get(Boolean.TRUE).get(orderKey).size();
orderTourReceivedStatistics.setTotalQuantity(totalQuantity);
orderTourReceivedStatisticsList.add(orderTourReceivedStatistics);
}
//未支付订单
Map<String, List<OrderDTO>> noPayOrderRentvehicleMap = stateGroupMap == null ? Collections.EMPTY_MAP : stateGroupMap.get(Boolean.FALSE) == null ? Collections.EMPTY_MAP : stateGroupMap.get(Boolean.FALSE);
List<OrderTourReceivedStatistics> noPayOrderTourReceivedStatisticsList = createNoPayOrderTourReceivedStatisticsListList(startDate, noPayOrderRentvehicleMap, companyMap);
orderTourReceivedStatisticsList.addAll(noPayOrderTourReceivedStatisticsList);
//创建剩余状态组合旅游统计对象
List<OrderTourReceivedStatistics> otherStatisticsStateGroupList = createOtherStatisticsStateGroupList(startDate, stisticsActiveState, companyMap);
orderTourReceivedStatisticsList.addAll(otherStatisticsStateGroupList);
//保存
insertMemberReceivedStatisticsBatch(orderTourReceivedStatisticsList);
return orderTourReceivedStatisticsList;
}
/**
*
*/
private List<OrderTourReceivedStatistics> createNoPayOrderTourReceivedStatisticsListList(Date startDate, Map<String, List<OrderDTO>> noPayOrdersMap, Map<Integer, String> companyMap) {
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = new ArrayList<>();
if (noPayOrdersMap == null || noPayOrdersMap.isEmpty()) {
return orderTourReceivedStatisticsList;
}
Set<Map.Entry<String, List<OrderDTO>>> noPayOrderSet = noPayOrdersMap.entrySet();
for (Map.Entry<String, List<OrderDTO>> noPayOrderEntry : noPayOrderSet) {
String noPayOrderStateGroup = noPayOrderEntry.getKey();
List<OrderDTO> noPayOrders = noPayOrderEntry.getValue();
List<BigDecimal> damageSafeAmountList = new ArrayList<>();
BigDecimal totalNoPayAmount = noPayOrders.stream().map(OrderDTO::getRealAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderTourReceivedStatistics orderTourReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, noPayOrderStateGroup, companyMap, new OrderTourReceivedStatistics());
BigDecimal depositAmount = noPayOrders.stream().map(OrderDTO::getDeposit).reduce(BigDecimal.ZERO, BigDecimal::add);
orderTourReceivedStatistics.setTotalQuantity(noPayOrders.size());
orderTourReceivedStatistics.setTotalAmount(totalNoPayAmount.subtract(depositAmount));
orderTourReceivedStatisticsList.add(orderTourReceivedStatistics);
}
return orderTourReceivedStatisticsList;
}
/**
* @param startDate 时间
* @param noPayOrdersMap 未支付单map
* @return
*/
private List<OrderTourReceivedStatistics> createOtherStatisticsStateGroupList(Date startDate, Map<String, List<OrderDTO>> noPayOrdersMap) {
List<OrderTourReceivedStatistics> orderOrderTourReceivedStatisticsList = new ArrayList<>();
if (noPayOrdersMap == null || noPayOrdersMap.isEmpty()) {
return orderOrderTourReceivedStatisticsList;
}
Set<Map.Entry<String, List<OrderDTO>>> noPayOrderSet = noPayOrdersMap.entrySet();
for (Map.Entry<String, List<OrderDTO>> noPayOrderEntry : noPayOrderSet) {
String noPayOrderStateGroup = noPayOrderEntry.getKey();
List<OrderDTO> noPayOrders = noPayOrderEntry.getValue();
BigDecimal totalNoPayAmount = noPayOrders.stream().map(OrderDTO::getRealAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderTourReceivedStatistics orderTourReceivedStatistics = new OrderTourReceivedStatistics();
orderTourReceivedStatistics.setTotalQuantity(noPayOrders.size());
orderTourReceivedStatistics.setTotalAmount(totalNoPayAmount);
orderOrderTourReceivedStatisticsList.add(orderTourReceivedStatistics);
}
return orderOrderTourReceivedStatisticsList;
}
/**
* 创建剩余状态数据
*
* @param startDate 时间
* @param statisticsStateGroups 状态组合 集合
* @param companyMap 公司ids
* @return
*/
private List<OrderTourReceivedStatistics> createOtherStatisticsStateGroupList(Date startDate,
List<String> statisticsStateGroups,
Map<Integer, String> companyMap) {
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = new ArrayList<>();
//获取剩余状态组合
List<Integer> companyIds = Objects.isNull(companyMap) ? Collections.EMPTY_LIST : Lists.newArrayList(companyMap.keySet());
List<String> otherStatisticsStateGroup = StatisticsStatusEnum.getOtherStatisticsStateGroup(companyIds, statisticsStateGroups);
//创建租车统计克隆对象
OrderTourReceivedStatistics orderTourReceivedStatistics = new OrderTourReceivedStatistics();
//统计对象的生成
otherStatisticsStateGroup.parallelStream().map(stateGroup -> {
OrderTourReceivedStatistics orderTourReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(startDate, stateGroup, companyMap, ObjectUtil.cloneByStream(orderTourReceivedStatistics));
orderTourReceivedStatisticsClone.setTotalAmount(BigDecimal.ZERO);
orderTourReceivedStatisticsClone.setTotalQuantity(0);
orderTourReceivedStatisticsClone.setLateFeeAmount(BigDecimal.ZERO);
orderTourReceivedStatisticsClone.setExtraAmount(BigDecimal.ZERO);
orderTourReceivedStatisticsClone.setOrderRefundAmount(BigDecimal.ZERO);
orderTourReceivedStatisticsList.add(orderTourReceivedStatisticsClone);
return orderTourReceivedStatisticsClone;
}).count();
return orderTourReceivedStatisticsList;
}
/**
* 批量插入数据 mysql sql语句默认不能超过4M
*
* @param orderTourReceivedStatistics
*/
public void insertMemberReceivedStatisticsBatch(List<OrderTourReceivedStatistics> orderTourReceivedStatistics) {
int orderSize = orderTourReceivedStatistics.size();
int sqlAdq = orderSize / StatisticsStatusEnum.DEFAULT_SQL_SIZE;
int sqlMod = orderSize % StatisticsStatusEnum.DEFAULT_SQL_SIZE;
sqlAdq = sqlMod == 0 ? sqlAdq : sqlAdq + 1;
for (int i = 0; i < sqlAdq; i++) {
int fromIndex = StatisticsStatusEnum.DEFAULT_SQL_SIZE * i;
int toIndex = StatisticsStatusEnum.DEFAULT_SQL_SIZE * (i + 1);
toIndex = toIndex > orderSize ? orderSize : toIndex;
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = orderTourReceivedStatistics.subList(fromIndex, toIndex);
mapper.insertList(orderTourReceivedStatisticsList);
}
}
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ public class OrderViolationBiz extends BaseBiz<OrderViolationMapper, OrderViolat
String filePath = ovUpload + realFileRelPath;
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
// FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return ObjectRestResponse.succ(filePath);
}
......
......@@ -7,6 +7,7 @@ package com.xxfc.platform.order.mapper;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
......@@ -22,6 +23,6 @@ public interface OrderAccountMapper extends Mapper<OrderAccount> {
List<OrderAccountDTO> getOrderAccountByOrderType(Term term);
List<OrderAccountBo> selectOrderAccountByOrderTypeAndStartTimeAndEndTime(@Param("orderType") Integer orderType,
@Param("startTime") long startTime,
@Param("endTime") long endTime);
@Param("startTime") Long startTime,
@Param("endTime") Long endTime);
}
......@@ -2,6 +2,7 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
......@@ -13,7 +14,7 @@ import java.util.List;
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
public interface OrderTourReceivedStatisticsMapper extends Mapper<OrderTourReceivedStatistics> {
public interface OrderTourReceivedStatisticsMapper extends Mapper<OrderTourReceivedStatistics>, InsertListMapper<OrderTourReceivedStatistics> {
List<OrderTourReceivedStatistics> selectOrderTourReceivedStatistics(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO);
}
......@@ -11,8 +11,10 @@ import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.order.biz.OrderTourDetailBiz;
import com.xxfc.platform.order.biz.OrderTourReceivedStatisticsBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderTourDetail;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
import com.xxfc.platform.order.pojo.order.add.AddTourDTO;
import com.xxfc.platform.order.pojo.order.TourBO;
import com.xxfc.platform.order.pojo.price.TourPriceVO;
......@@ -31,16 +33,21 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@Controller
@RequestMapping("orderTour")
@IgnoreClientToken
@Api(value="旅游订单",tags={"旅游订单"})
public class OrderTourController extends BaseController<OrderTourDetailBiz,OrderTourDetail> {
@Api(value = "旅游订单", tags = {"旅游订单"})
public class OrderTourController extends BaseController<OrderTourDetailBiz, OrderTourDetail> {
@Autowired
OrderTourService orderTourService;
@Autowired
OrderTourReceivedStatisticsBiz orderTourReceivedStatisticsBiz;
@Autowired
TourFeign tourFeign;
......@@ -50,33 +57,51 @@ public class OrderTourController extends BaseController<OrderTourDetailBiz,Order
@Autowired
UserFeign userFeign;
public AppUserDTO getUserInfo(){
return userFeign.userDetailByToken(userAuthConfig.getToken(request)).getData();
public AppUserDTO getUserInfo() {
return userFeign.userDetailByToken(userAuthConfig.getToken(request)).getData();
}
@RequestMapping(value = "/orderTourStatistics", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "旅游订单统计")
public ObjectRestResponse<OrderTourReceivedStatistics> orderTourStatistics() {
Date today = new Date();//获取今天的日期
Calendar c = Calendar.getInstance();
c.setTime(today);
c.add(Calendar.DAY_OF_MONTH, 1);
Date tomorrow = c.getTime();//这是明天
c.setTime(today);
c.add(Calendar.DAY_OF_MONTH, -1);
Date yesterday = c.getTime();//这是昨天
orderTourReceivedStatisticsBiz.orderTourInsertStatisticsNew(yesterday, tomorrow,null
);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "add",method = RequestMethod.POST)
@RequestMapping(value = "add", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "确认旅游订单")
public ObjectRestResponse<BaseOrder> add(@RequestBody AddTourDTO vo){
public ObjectRestResponse<BaseOrder> add(@RequestBody AddTourDTO vo) {
TourBO bo = BeanUtil.toBean(vo, TourBO.class);
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null);
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos()) ? Arrays.asList(vo.getTickerNos().split(",")) : null);
orderTourService.createOrder(bo);
return ObjectRestResponse.succ(bo.getOrder());
}
@RequestMapping(value = "/calculate-price",method = RequestMethod.GET)
@RequestMapping(value = "/calculate-price", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "价格计算")
@IgnoreUserToken
public ObjectRestResponse<TourPriceVO> calculatePrice(CalculatePriceVO vo){
public ObjectRestResponse<TourPriceVO> calculatePrice(CalculatePriceVO vo) {
TourBO bo = BeanUtil.toBean(vo, TourBO.class);
bo.setAppUserDTO(getUserInfo());
bo.setAdultNum(vo.getNumber());
bo.setChildNum(vo.getChildNumber());
TourGood tourGood = tourFeign.usableGet(bo.getGoodId()).getData();
bo.setTourGood(tourGood);
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null);
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos()) ? Arrays.asList(vo.getTickerNos().split(",")) : null);
return ObjectRestResponse.succ(orderTourService.calculatePrice(bo));
}
......
......@@ -369,4 +369,9 @@
LEFT JOIN (select `order_id`,`member_level` AS `memberLevel` from `order_member_detail`) AS `omd` ON
omd.order_id=bo.id;
</select>
</mapper>
\ No newline at end of file
......@@ -5,8 +5,12 @@ public class DictionaryKey {
/**
* 订单类型
*/
public static final String APP_ORDER ="APP_ORDER";
public static final String APP_ORDER = "APP_ORDER";
/**
* 用途类型
*/
public static final String VEHICE_ORDER = "VEHICE_ORDER";
/**
* 违约类型
......@@ -21,36 +25,41 @@ public class DictionaryKey {
/**
* IM类型
*/
public static final String IM_TYPE ="IM_TYPE";
public static final String IM_TYPE = "IM_TYPE";
/**
* IM限制条数
*/
public static final String MSG_LIMIT_NUMBER ="MSG_LIMIT_NUMBER";
public static final String MSG_LIMIT_NUMBER = "MSG_LIMIT_NUMBER";
/**
* 支付
*/
public static final String UNIVERSAL_PAY ="UNIVERSAL_PAY";
public static final String UNIVERSAL_PAY = "UNIVERSAL_PAY";
/**
* 租车,旅游(省内、省外)退款
* 租车,旅游(省内、省外)退款
*/
public static final String RENT_REFUND ="RENT_REFUND";
public static final String TOUR_REFUND ="TOUR_REFUND";
public static final String TOUR_IN_REFUND ="TOUR_IN_REFUND";
public static final String RENT_REFUND = "RENT_REFUND";
public static final String TOUR_REFUND = "TOUR_REFUND";
public static final String TOUR_IN_REFUND = "TOUR_IN_REFUND";
/**
* 租车:公司司机租金、免赔费用、违章预备金
*/
public static final String DRIVER_PRICE ="DRIVER_PRICE";
public static final String DAMAGE_SAFE ="DAMAGE_SAFE";
public static final String DRIVER_PRICE = "DRIVER_PRICE";
public static final String DAMAGE_SAFE = "DAMAGE_SAFE";
public static final String ILLEGAL_RESERVE = "ILLEGAL_RESERVE";
public static final String RENT_TIME_BUFFER = "RENT_TIME_BUFFER";
/**
* 旅游:保险费用
*/
public static final String INSURE_PRICE ="INSURE_PRICE";
public static final String INSURE_PRICE = "INSURE_PRICE";
/**
* 租车类型Code
*/
public static final String RESERVE="RESERVE";
/**
* 自动取消订单时间:租车、旅游
......
......@@ -108,7 +108,7 @@ public class DictionaryBiz extends BaseBiz<DictionaryMapper, Dictionary> {
List<Dictionary> dictionaries = selectListAll();
Map<String, Dictionary> dictionaryMap = dictionaries.parallelStream().collect(Collectors.toMap(dic -> dic.getType()+ "_"+ dic.getCode()
, Function.identity(), (oldValue, newValue) -> newValue));
dictionaryMap.forEach((k,v) -> {
dictionaryMap.forEach((k,v) ->{
v.setChildrens(buildTree(v.getId()));
});
return dictionaryMap;
......
......@@ -52,7 +52,7 @@ public class UploadService {
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
// FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath;
}
......
......@@ -16,7 +16,7 @@ public enum BookType {
BOOKING(7,"预约中"),
DISABLE(8,"禁用"),
CUSTOMER_APPLY(9, "客户用车"),
OTHER(10, "其他"),
OTHER(10, "其他"),
DISPATCH(11, "调度")
;
/**
......
......@@ -271,7 +271,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
// FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return RestResponse.suc(realFileRelPath);
}
......
......@@ -225,7 +225,7 @@ public class BranchCompanyStockService {
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
// FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return RestResponse.suc(realFileRelPath);
}
......
......@@ -176,7 +176,7 @@ public class CampsiteBiz extends BaseBiz<CampsiteMapper, Campsite> {
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
// FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return RestResponse.suc(realFileRelPath);
}
......
......@@ -129,7 +129,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
// FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
return RestResponse.suc(realFileRelPath);
}
......
......@@ -8,11 +8,17 @@ import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.JsonUtil;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.utils.DateUtil;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.BookType;
......@@ -39,11 +45,15 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.auth.common.constatns.CommonConstants.DATA_ALL_FALSE;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.VEHICE_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.RESERVE;
@Service
@Slf4j
......@@ -86,6 +96,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
@Autowired
VehicleBiz vehicleBiz;
@Autowired
ThirdFeign thirdFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
......@@ -200,7 +213,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
vehicleBookRecordQueryVo.setCompanyIds(companyList);
Query query = new Query(vehicleBookRecordQueryVo);
Query query = new Query(vehicleBookRecordQueryVo);
PageDataVO<VehicleBookRecordVo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getBookRecordInfo(query.getSuper()));
getupKeeps(pageDataVO.getData());
return RestResponse.suc(pageDataVO);
......@@ -219,6 +232,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
}
/**
* 获取随身物品
*/
......@@ -235,7 +249,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
if (vehicleBookRecordVo.getBookUser() != null) {
UserDTO userDTO = userFeign.userinfoByUid(vehicleBookRecordVo.getBookUser()).getData();
if(userDTO != null) {
if (userDTO != null) {
BranchCompany branchCompany = branchCompanyBiz.getById(userDTO.getCompanyId());
if (branchCompany != null) {
vehicleBookRecordVo.setUserCompanyName(branchCompany.getName());
......@@ -248,11 +262,11 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
public ObjectRestResponse update(BookRecordUpdateLog bookRecordUpdateLog) {
VehicleBookRecord vehicleBookRecord = selectById(bookRecordUpdateLog.getBookRecordId());
if(vehicleBookRecord != null) {
if (vehicleBookRecord != null) {
vehicleBookRecord.setRetCompany(bookRecordUpdateLog.getNewRetCompanyId());
int a = updateSelectiveByIdRe(vehicleBookRecord);
log.info(vehicleBookRecord.toString());
if(a <= 0) {
if (a <= 0) {
return ObjectRestResponse.createDefaultFail();
}
//出行中才修改车辆停靠分公司
......@@ -266,7 +280,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
}
......@@ -318,32 +332,32 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
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);
}
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();
}
......@@ -698,4 +712,13 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
return data.subList(fromIndex, toIndex);
}
/**
* 车辆用途字典查询
*/
public ObjectRestResponse<OrderPageVO> getOrderDetail() {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
String reserveType = dictionaryMap.get(VEHICE_ORDER + "_" +RESERVE).getName();
return ObjectRestResponse.succ(reserveType);
}
}
......@@ -34,17 +34,17 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
@Autowired
VehicleMapper vehicleMapper;
public PageInfo<VehicleDepartureLogVo> page(String numberPlate,Integer code,Integer zoneId,Integer departureId, String startTime,String endTime, Integer page, Integer limit) {
public PageInfo<VehicleDepartureLogVo> page(String numberPlate,Integer code,Integer zoneId,Integer departureId,Integer arrivalBranchCompanyId,String use,String startTime,String endTime, Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(mapper.selectVoAll(numberPlate,code,zoneId,departureId,startTime, endTime));
return new PageInfo<>(mapper.selectVoAll(numberPlate,code,zoneId,departureId,startTime, endTime,arrivalBranchCompanyId,use));
}
public PageInfo<VehicleDepartureLogVo> pageNotAllData(String numberPlate,Integer code,Integer zoneId,Integer departureId, String startTime,String endTime, Integer page, Integer limit, List<Integer> companyList) {
public PageInfo<VehicleDepartureLogVo> pageNotAllData(String numberPlate,Integer code,Integer zoneId,Integer departureId, String startTime,String endTime, Integer arrivalBranchCompanyId,String use, Integer page, Integer limit, List<Integer> companyList) {
PageHelper.startPage(page, limit);
if (companyList == null || companyList.size() == 0) {
companyList = Arrays.asList(-1);
}
return new PageInfo<>(mapper.selectVoAllNotAllData(numberPlate,code,zoneId,departureId,startTime, endTime, companyList));
return new PageInfo<>(mapper.selectVoAllNotAllData(numberPlate,code,zoneId,departureId,startTime, endTime, companyList,arrivalBranchCompanyId,use));
}
public PageInfo<VehicleDepartureLogVo> findByVehicle(String vehicleId, Integer page, Integer limit) {
......
......@@ -15,14 +15,18 @@ public interface VehicleDepartureLogMapper extends BaseMapper<VehicleDepartureLo
VehicleDepartureLog selectLastByVehicleId(String vehicleId);
List<VehicleDepartureLogVo> selectByVehicleId(String vehicleId);
List<VehicleDepartureLog> selectByVehicle(String vehicleId);
List<VehicleDepartureLogVo> selectVoAll(@Param("numberPlate") String numberPlate,
@Param("code") Integer code,
@Param("zoneId") Integer zoneId,
@Param("departureId") Integer departureId,
@Param("startTime") String startTime,
@Param("endTime") String endTime
);
@Param("endTime") String endTime,
@Param("arrivalBranchCompanyId") Integer arrivalBranchCompanyId,
@Param("use") String user
);
List<VehicleDepartureLogVo> selectVoAllNotAllData(@Param("numberPlate") String numberPlate,
@Param("code") Integer code,
......@@ -30,12 +34,15 @@ public interface VehicleDepartureLogMapper extends BaseMapper<VehicleDepartureLo
@Param("departureId") Integer departureId,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("companyList") List<Integer> companyList);
@Param("companyList") List<Integer> companyList,
@Param("arrivalBranchCompanyId") Integer arrivalBranchCompanyId,
@Param("use") String user);
Integer selectMileageByVehicleId(String vehicleId);
String selectDayByVehicleId(String vehicleId);
VehicleDepartureLogVo selectByBookRecordId(Long bookRecordId);
Integer selectAllDepartureLog(Map<String, Object> param);
}
......@@ -599,4 +599,10 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
public List<String> findbyPlateNumberAndVehicleCod(@RequestParam(value = "plateNumber",required = false) String plateNumber,@RequestParam(value = "vehicleCode",required = false) String vehicleCode){
return vehicleBiz.findbyPlateNumberAndVehicleCod(plateNumber,vehicleCode);
}
@GetMapping("/app/unauth/findDictionaryMaps")
@IgnoreUserToken
public ObjectRestResponse findbyDictionaryMaps(@RequestParam(value = "plateNumber",required = false) String plateNumber,@RequestParam(value = "vehicleCode",required = false) String vehicleCode){
return vehicleBookRecordBiz.getOrderDetail();
}
}
......@@ -44,10 +44,13 @@ public class VehicleDepartureController {
* @return
*/
@GetMapping("page")
@IgnoreUserToken
public RestResponse page(String numberPlate,
@RequestParam(value = "code", required = false) Integer code, String startTime, String endTime,
@RequestParam(value = "zoneId",required = false) Integer zoneId,
@RequestParam(value = "zoneId", required = false) Integer zoneId,
@RequestParam(value = "departureId", required = false) Integer departureId,
@RequestParam(value = "use", required = false) String use,
@RequestParam(value = "arrivalBranchCompanyId", required = false) Integer arrivalBranchCompanyId,
Integer page, Integer limit, HttpServletRequest request) {
if (page == null || limit == null) {
page = 1;
......@@ -57,15 +60,16 @@ public class VehicleDepartureController {
if (userDTO != null) {
if (userDTO.getDataAll() == 2) {
List<Integer> companyList = vehicleBiz.dataCompany(userDTO.getDataZone(), userDTO.getDataCompany());
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, zoneId,departureId, startTime, endTime, page, limit, companyList));
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, zoneId, departureId,startTime, endTime,arrivalBranchCompanyId,use,page, limit, companyList));
}
}
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, zoneId,departureId, startTime, endTime, page, limit));
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, zoneId, departureId,arrivalBranchCompanyId, use, startTime, endTime, page, limit));
}
@GetMapping("small/page")
@IgnoreUserToken
public RestResponse pageBySmall(String numberPlate, @RequestParam(value = "code", required = false) Integer code, String startTime, String endTime,Integer page, Integer limit, Integer uid, HttpServletRequest request) {
public RestResponse pageBySmall(String numberPlate, @RequestParam(value = "code", required = false)
Integer code, String startTime, String endTime, Integer page, Integer limit, Integer uid, HttpServletRequest request) {
if (page == null || limit == null) {
page = 1;
limit = 10;
......@@ -74,10 +78,10 @@ public class VehicleDepartureController {
if (userDTO != null) {
if (userDTO.getDataAll() == 2) {
List<Integer> companyList = vehicleBiz.dataCompany(userDTO.getDataZone(), userDTO.getDataCompany());
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, null,null, startTime,endTime, page, limit, companyList));
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, null, null, startTime, endTime, page, limit, companyList));
}
}
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, null,null, startTime,endTime, page, limit));
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, null, null,null ,null,startTime, endTime, page, limit));
}
/**
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.VehicleDepartureLogMapper" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.VehicleDepartureLogMapper">
<resultMap id="searchBookRecord" type="com.xxfc.platform.vehicle.pojo.DepartureLogVo">
<result column="book_record_id" property="bookRecordId" jdbcType="INTEGER" javaType="java.lang.Integer"/>
......@@ -21,14 +21,16 @@
order by create_time desc
</select>
<select id="selectByVehicle" parameterType="java.lang.String" resultType="com.xxfc.platform.vehicle.entity.VehicleDepartureLog">
<select id="selectByVehicle" parameterType="java.lang.String"
resultType="com.xxfc.platform.vehicle.entity.VehicleDepartureLog">
select vehicle_departure_log.*
from vehicle_departure_log
where vehicle_id = #{vehicleId}
order by create_time desc
</select>
<select id="selectByBookRecordId" parameterType="java.lang.Long" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
<select id="selectByBookRecordId" parameterType="java.lang.Long"
resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select v.*, bc.name as departureName,bc1.name as arrivalName
from vehicle_departure_log v
LEFT JOIN branch_company bc ON v.departure_branch_company_id = bc.id
......@@ -38,7 +40,7 @@
</select>
<select id="selectAllDepartureLog" resultType="java.lang.Integer" parameterType="Map">
SELECT
count(*)
count(*)
FROM
vehicle_departure_log v1
LEFT JOIN vehicle_book_record v2 on v1.book_record_id = v2.id
......@@ -88,15 +90,21 @@
<select id="selectVoAll" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.*,vehicle.number_plate,
/* IFNULL(DATEDIFF(vehicle_departure_log.arrival_time,vehicle_departure_log.departure_time),0)*/
CONCAT(IFNULL(floor((unix_timestamp(vehicle_departure_log.arrival_time) - unix_timestamp(vehicle_departure_log.departure_time)) / 86400),0),'天',
IFNULL(floor(IF((unix_timestamp(vehicle_departure_log.arrival_time) - unix_timestamp(vehicle_departure_log.departure_time))>86400,(unix_timestamp(vehicle_departure_log.arrival_time)
- unix_timestamp(vehicle_departure_log.departure_time)) MOD 86400/3600,(unix_timestamp(vehicle_departure_log.arrival_time) - unix_timestamp(vehicle_departure_log.departure_time))/3600)),0),'小时')
CONCAT(IFNULL(floor((unix_timestamp(vehicle_departure_log.arrival_time) -
unix_timestamp(vehicle_departure_log.departure_time)) / 86400),0),'天',
IFNULL(floor(IF((unix_timestamp(vehicle_departure_log.arrival_time) -
unix_timestamp(vehicle_departure_log.departure_time))>86400,(unix_timestamp(vehicle_departure_log.arrival_time)
- unix_timestamp(vehicle_departure_log.departure_time)) MOD
86400/3600,(unix_timestamp(vehicle_departure_log.arrival_time) -
unix_timestamp(vehicle_departure_log.departure_time))/3600)),0),'小时')
as departureDay,bc.name as departureName,bc1.name as arrivalName,
IF((IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0))>0,IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0),0) as mileage
IF((IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0))>0,IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0),0)
as mileage
from vehicle_departure_log
left join vehicle on vehicle_departure_log.vehicle_id = vehicle.id
LEFT JOIN branch_company bc ON vehicle_departure_log.departure_branch_company_id = bc.id
LEFT JOIN branch_company bc1 ON vehicle_departure_log.arrival_branch_company_id = bc1.id
LEFT JOIN vehicle_book_record bc2 ON vehicle_departure_log.book_record_id = bc2.id
<trim prefix="where">
1=1
<if test="numberPlate != null and numberPlate != ''">
......@@ -107,16 +115,22 @@
vehicle_departure_log.departure_time &gt;= str_to_date(#{startTime}, '%Y-%m-%d %H')
</if>
<if test="endTime != null and endTime != ''">
and vehicle_departure_log.arrival_time &gt;= str_to_date(#{endTime}, '%Y-%m-%d %H')
and vehicle_departure_log.arrival_time &gt;= str_to_date(#{endTime}, '%Y-%m-%d %H')
</if>
<if test="code!=null">
and vehicle.code=#{code}
and vehicle.code=#{code}
</if>
<if test="zoneId!=null">
and bc.zone_id=#{zoneId}
and bc.zone_id=#{zoneId}
</if>
<if test="departureId!=null">
and vehicle_departure_log.departure_branch_company_id=#{departureId}
and vehicle_departure_log.departure_branch_company_id=#{departureId}
</if>
<if test="use!=null">
and bc2.use=#{use}
</if>
<if test="arrivalBranchCompanyId!=null">
and vehicle_departure_log.arrival_branch_company_id=#{arrivalBranchCompanyId}
</if>
</trim>
order by create_time desc
......@@ -124,15 +138,21 @@
<select id="selectVoAllNotAllData" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.*,vehicle.number_plate,
/*IFNULL(DATEDIFF(vehicle_departure_log.arrival_time,vehicle_departure_log.departure_time),0)*/
CONCAT(IFNULL(floor((unix_timestamp(vehicle_departure_log.arrival_time) - unix_timestamp(vehicle_departure_log.departure_time)) / 86400),0),'天',
IFNULL(floor(IF((unix_timestamp(vehicle_departure_log.arrival_time) - unix_timestamp(vehicle_departure_log.departure_time))>86400,(unix_timestamp(vehicle_departure_log.arrival_time)
- unix_timestamp(vehicle_departure_log.departure_time)) MOD 86400/3600,(unix_timestamp(vehicle_departure_log.arrival_time) - unix_timestamp(vehicle_departure_log.departure_time))/3600)),0),'小时')
CONCAT(IFNULL(floor((unix_timestamp(vehicle_departure_log.arrival_time) -
unix_timestamp(vehicle_departure_log.departure_time)) / 86400),0),'天',
IFNULL(floor(IF((unix_timestamp(vehicle_departure_log.arrival_time) -
unix_timestamp(vehicle_departure_log.departure_time))>86400,(unix_timestamp(vehicle_departure_log.arrival_time)
- unix_timestamp(vehicle_departure_log.departure_time)) MOD
86400/3600,(unix_timestamp(vehicle_departure_log.arrival_time) -
unix_timestamp(vehicle_departure_log.departure_time))/3600)),0),'小时')
as departureDay,bc.name as departureName,bc1.name as arrivalName,
IF((IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0))>0,IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0),0) as mileage
IF((IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0))>0,IFNULL(vehicle_departure_log.mileage_end,0)-IFNULL(vehicle_departure_log.mileage_start,0),0)
as mileage
from vehicle_departure_log
left join vehicle on vehicle_departure_log.vehicle_id = vehicle.id
LEFT JOIN branch_company bc ON vehicle_departure_log.departure_branch_company_id = bc.id
LEFT JOIN branch_company bc1 ON vehicle_departure_log.arrival_branch_company_id = bc1.id
LEFT JOIN vehicle_book_record bc2 ON vehicle_departure_log.book_record_id = bc2.id
<trim prefix="where" suffixOverrides="and">
<if test="numberPlate != null and numberPlate != ''">
vehicle.number_plate = #{numberPlate} and
......@@ -162,18 +182,24 @@
</if>
<if test="endTime != null and endTime != ''">
and vehicle_departure_log.arrival_time >= str_to_date(#{endTime}, '%Y-%m-%d %H')
and vehicle_departure_log.arrival_time >= str_to_date(#{endTime}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.arrival_time)=TO_DAYS(str_to_date(#{endTime}, '%Y-%m-%d %H'))
or vehicle_departure_log.arrival_time is null
</if>
<if test="code!=null">
and vehicle.code=#{code}
and vehicle.code=#{code}
</if>
<if test="zoneId!=null">
and bc.zone_id=#{zoneId}
and bc.zone_id=#{zoneId}
</if>
<if test="departureId!=null">
and vehicle_departure_log.departure_branch_company_id=#{departureId}
and vehicle_departure_log.departure_branch_company_id=#{departureId}
</if>
<if test="use!=null">
and bc2.use=#{use}
</if>
<if test="arrivalBranchCompanyId!=null">
and vehicle_departure_log.arrival_branch_company_id=#{arrivalBranchCompanyId}
</if>
</trim>
order by create_time desc
......
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