Commit b1cafa25 authored by libin's avatar libin

大屏订单概况统计与车辆概况统计

parent 78da90c8
package com.xxfc.platform.order.pojo.dto;
import cn.hutool.core.date.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 14:53
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseOrderDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单类型 1:租车 2:旅游 3:会员
*/
private Integer type;
/**
* 实际支付金额
*/
private BigDecimal realAmount;
/**
* 公司id(租车的出发公司)
*/
private Integer companyId;
/**
* 支付方式
*/
private Integer payWay;
/**
* 支付终端
*/
private Integer payOrigin;
/**
* 支付时间
*/
private Long payTime;
/**
* 支付时间转化日期
*/
private Date payDate;
/**
* 区域id
*/
private Integer areaId;
/**
* 订单量
*/
private Integer orderNum;
public Date getPayDate() {
return Objects.isNull(payTime) ? null : DateUtil.beginOfDay(new Date(payTime));
}
public Integer getOrderNum() {
return Objects.isNull(orderNum) ? 1 : orderNum;
}
}
...@@ -34,4 +34,12 @@ public class OrderPayProfileDispalyVo implements Serializable { ...@@ -34,4 +34,12 @@ public class OrderPayProfileDispalyVo implements Serializable {
* ios支付金额 * ios支付金额
*/ */
private BigDecimal iosPayAmount = BigDecimal.ZERO; private BigDecimal iosPayAmount = BigDecimal.ZERO;
/**
* 小程序支付金额
*/
private BigDecimal appletPayAmount = BigDecimal.ZERO;
/**
* 公众号支付金额
*/
private BigDecimal weChatOfficialAccountPayAmount = BigDecimal.ZERO;
} }
...@@ -55,11 +55,15 @@ public class OrderProfileDispayVo implements Serializable { ...@@ -55,11 +55,15 @@ public class OrderProfileDispayVo implements Serializable {
return CollectionUtils.isEmpty(centerOrderProfileDisplays) ? Collections.EMPTY_LIST : centerOrderProfileDisplays; return CollectionUtils.isEmpty(centerOrderProfileDisplays) ? Collections.EMPTY_LIST : centerOrderProfileDisplays;
} }
public OrderPayProfileDispalyVo getOrderPayProfileDispal() { public OrderPayProfileDispalyVo getOrderPayProfileDisplay() {
return Objects.isNull(orderPayProfileDisplay) ? new OrderPayProfileDispalyVo() : orderPayProfileDisplay; return Objects.isNull(orderPayProfileDisplay) ? new OrderPayProfileDispalyVo() : orderPayProfileDisplay;
} }
public List<OrderProfileVo> getOrderProfiles() { public List<OrderProfileVo> getOrderProfiles() {
return CollectionUtils.isEmpty(orderProfiles) ? Collections.EMPTY_LIST : orderProfiles; return CollectionUtils.isEmpty(orderProfiles) ? Collections.EMPTY_LIST : orderProfiles;
} }
public BigDecimal getOrderAmount() {
return CollectionUtils.isEmpty(orderProfiles)?BigDecimal.ZERO:orderProfiles.stream().map(OrderProfileVo::getOrderAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
}
} }
...@@ -32,6 +32,7 @@ import com.xxfc.platform.order.pojo.DedDetailDTO; ...@@ -32,6 +32,7 @@ import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.QueryCriteria; import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.dto.BaseOrderDTO;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo; import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO; import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO; import com.xxfc.platform.order.pojo.dto.OrderDTO;
...@@ -912,7 +913,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -912,7 +913,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return userFeign; return userFeign;
} }
/**
/**
* 订单查询类 * 订单查询类
*/ */
@Data @Data
...@@ -966,5 +969,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -966,5 +969,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return PageInfo.of(achievements); return PageInfo.of(achievements);
} }
public List<BaseOrderDTO> findOrdersByDate(Date startDate, Date endDate) {
List<BaseOrderDTO> baseOrderDTOS = mapper.findOrdersByDate(startDate,endDate);
return CollectionUtils.isEmpty(baseOrderDTOS)?Collections.emptyList():baseOrderDTOS;
}
} }
\ No newline at end of file
package com.xxfc.platform.order.biz; package com.xxfc.platform.order.biz;
import com.alibaba.fastjson.JSON; import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.alibaba.fastjson.JSON;
import com.xxfc.platform.order.bo.LargeScreenDisplayConstantDataBo; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.order.entity.OrderProfileDisplay; import com.github.wxiaoqi.security.common.util.CollectorsUtil;
import com.xxfc.platform.order.mapper.OrderProfileDisplayMapper; import com.xxfc.platform.order.bo.LargeScreenDisplayConstantDataBo;
import com.xxfc.platform.order.pojo.vo.LargeScreenDisplayDataVo; import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.pojo.vo.OrderProfileDispayVo; import com.xxfc.platform.order.entity.OrderProfileDisplay;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsBaseVo; import com.xxfc.platform.order.mapper.OrderProfileDisplayMapper;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.order.pojo.dto.BaseOrderDTO;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.order.pojo.vo.*;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.universal.entity.Dictionary;
import lombok.RequiredArgsConstructor; import com.xxfc.platform.universal.feign.ThirdFeign;
import org.springframework.beans.factory.annotation.Autowired; import com.xxfc.platform.vehicle.entity.Area;
import org.springframework.beans.factory.annotation.Value; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.util.Date; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.List; import org.springframework.stereotype.Service;
import java.util.Objects; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/** import org.springframework.util.StringUtils;
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 17:06
*/
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, OrderProfileDisplay> {
/**
* 字典查询type
*/
@Value("large.screen.type:LARGE_SCREEN_DISPLAY")
private String largeScreenType;
/**
* 字典查询code
*/
@Value("large.screen.code:LARGE_SCREEN_DISPLAY_CONSTANT")
private String largeScreenCode;
private final ThirdFeign thirdFeign; import java.math.BigDecimal;
private final OrderReceivedStatisticsBiz orderReceivedStatisticsBiz; import java.util.*;
private final VehicleFeign vehicleFeign; import java.util.concurrent.CountDownLatch;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @param startDate 开始时间 * @author libin
* @param endDate 结束时间 * @version 1.0
* @return * @description
* @data 2019/12/24 17:06
*/ */
public LargeScreenDisplayDataVo findLargeScreenDisplayDataByDate(Date startDate, Date endDate) { @Slf4j
LargeScreenDisplayDataVo largeScreenDisplayDataVo = new LargeScreenDisplayDataVo(); @Transactional(rollbackFor = Exception.class)
//创建订单常量数据对象 @Service
LargeScreenDisplayConstantDataBo largeScreenDisplayConstantDataBo = new LargeScreenDisplayConstantDataBo(); @RequiredArgsConstructor(onConstructor = @__(@Autowired))
//创建订单数据统计对象 public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, OrderProfileDisplay> {
OrderProfileDispayVo orderProfileDispayVo = new OrderProfileDispayVo(); /**
* 字典查询type
//1.查询基础常量数据 */
Dictionary largeScreenConstantDictionary = thirdFeign.findDictionaryByTypeAndCode(largeScreenType, largeScreenCode); @Value("large.screen.type:LARGE_SCREEN_DISPLAY")
if (Objects.nonNull(largeScreenConstantDictionary) && StringUtils.hasText(largeScreenConstantDictionary.getDetail())){ private String largeScreenType;
largeScreenDisplayConstantDataBo = JSON.parseObject(largeScreenConstantDictionary.getDetail(), LargeScreenDisplayConstantDataBo.class); /**
* 字典查询code
*/
@Value("large.screen.code:LARGE_SCREEN_DISPLAY_CONSTANT")
private String largeScreenCode;
private final ThirdFeign thirdFeign;
private final VehicleFeign vehicleFeign;
private final BaseOrderBiz baseOrderBiz;
private final ThreadPoolTaskExecutor executor;
private static final Integer WX_PAY_STATE = 1;
private static final Integer ALI_PAY_STATE = 2;
private static final Integer APP_PAY_STATE = 1;
private static final Integer APPLET_PAY_STATE = 2;
private static final Integer WECHAT_OFFICIAL_ACCOUNT_PAY_STATE = 3;
private static final Integer IOS_PAY_STATE = 4;
/**
* @param startDate 开始时间
* @param endDate 结束时间
* @return
*/
public LargeScreenDisplayDataVo findLargeScreenDisplayDataByDate(Date startDate, Date endDate) {
LargeScreenDisplayDataVo largeScreenDisplayDataVo = new LargeScreenDisplayDataVo();
//创建订单常量数据对象
LargeScreenDisplayConstantDataBo largeScreenDisplayConstantDataBo = new LargeScreenDisplayConstantDataBo();
//创建订单数据统计对象
OrderProfileDispayVo orderProfileDispayVo = new OrderProfileDispayVo();
//1.查询基础常量数据
Dictionary largeScreenConstantDictionary = thirdFeign.findDictionaryByTypeAndCode(largeScreenType, largeScreenCode);
if (Objects.nonNull(largeScreenConstantDictionary) && StringUtils.hasText(largeScreenConstantDictionary.getDetail())) {
largeScreenDisplayConstantDataBo = JSON.parseObject(largeScreenConstantDictionary.getDetail(), LargeScreenDisplayConstantDataBo.class);
}
//2.1查询订单数据
List<BaseOrderDTO> baseOrders = baseOrderBiz.findOrdersByDate(startDate, endDate);
//2.2查询固定数据
List<OrderProfileDisplay> orderProfileDisplays = findOrderProfileDisplayDataByDate(startDate, endDate);
//包装成基础订单
List<BaseOrderDTO> wrapBaseOrders = wrapToBaseOrder(orderProfileDisplays);
wrapBaseOrders.addAll(baseOrders);
Supplier<Stream<BaseOrderDTO>> orderSupplier = () -> wrapBaseOrders.stream();
CountDownLatch latch = new CountDownLatch(3);
//3. 十大运营中心订单数据
executor.execute(() -> {
analyticStatisticsCenterOrder(orderSupplier, latch, orderProfileDispayVo);
});
//4.总的订单数据
executor.execute(() -> {
analyticStatisticsOrderProfiles(orderSupplier, latch, orderProfileDispayVo);
});
//5.支付方式|支付终端数据处理
executor.execute(() -> {
analyticStatisticsOrderPayWayProfiles(orderSupplier, latch, orderProfileDispayVo);
});
try {
latch.await();
} catch (InterruptedException e) {
log.error("统计出错:【{}】", e);
}
//6.基础金额 + 真实金额 基础订单量+真实订单量
long totalOrderNum = orderProfileDispayVo.getOrderNum() + largeScreenDisplayConstantDataBo.getBaseOrderNum();
BigDecimal totalOrderAmount = orderProfileDispayVo.getOrderAmount().add(largeScreenDisplayConstantDataBo.getBaseOrderAmount());
orderProfileDispayVo.setOrderNum(totalOrderNum);
orderProfileDispayVo.setOrderAmount(totalOrderAmount);
largeScreenDisplayDataVo.setLargeScreenDisplayConstantData(largeScreenDisplayConstantDataBo);
largeScreenDisplayDataVo.setOrderProfileDispayData(orderProfileDispayVo);
return largeScreenDisplayDataVo;
}
/**
* 支付方式|终端的统计
*
* @param orderSuppiler
* @param latch
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo analyticStatisticsOrderPayWayProfiles(Supplier<Stream<BaseOrderDTO>> orderSuppiler,
CountDownLatch latch,
OrderProfileDispayVo orderProfileDispayVo) {
OrderPayProfileDispalyVo orderPayProfileDispalyVo = new OrderPayProfileDispalyVo();
//1.支付方式统计
wrapToPayProfileWithPayWay(orderSuppiler, orderPayProfileDispalyVo);
//2.支付终端统计
wrapToPayProfileWithPayTerminal(orderSuppiler, orderPayProfileDispalyVo);
orderProfileDispayVo.setOrderPayProfileDisplay(orderPayProfileDispalyVo);
latch.countDown();
return orderProfileDispayVo;
}
/**
* 支付方式统计
*
* @param orderSupplier
* @param orderPayProfileDispalyVo
* @return
*/
private OrderPayProfileDispalyVo wrapToPayProfileWithPayWay(Supplier<Stream<BaseOrderDTO>> orderSupplier, OrderPayProfileDispalyVo orderPayProfileDispalyVo) {
Map<Integer, BigDecimal> payWayMap = orderSupplier.get().collect(Collectors.groupingBy(BaseOrderDTO::getPayWay, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
boolean isNull = payWayMap == null;
BigDecimal wxPayAmount = isNull ? BigDecimal.ZERO : payWayMap.get(WX_PAY_STATE) == null ? BigDecimal.ZERO : payWayMap.get(WX_PAY_STATE);
BigDecimal aliPayAmount = isNull ? BigDecimal.ZERO : payWayMap.get(ALI_PAY_STATE) == null ? BigDecimal.ZERO : payWayMap.get(ALI_PAY_STATE);
orderPayProfileDispalyVo.setWxPayAmount(wxPayAmount);
orderPayProfileDispalyVo.setAliPayAmount(aliPayAmount);
return orderPayProfileDispalyVo;
}
/**
* 支付终端统计
*
* @param orderSupplier
* @param orderPayProfileDispalyVo
* @return
*/
private OrderPayProfileDispalyVo wrapToPayProfileWithPayTerminal(Supplier<Stream<BaseOrderDTO>> orderSupplier, OrderPayProfileDispalyVo orderPayProfileDispalyVo) {
Map<Integer, BigDecimal> payTerminalMap = orderSupplier.get().collect(Collectors.groupingBy(BaseOrderDTO::getPayOrigin, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
boolean isNull = payTerminalMap == null;
BigDecimal appPayAmount = isNull ? BigDecimal.ZERO : payTerminalMap.get(APP_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(APP_PAY_STATE);
BigDecimal appletPayAmount = isNull ? BigDecimal.ZERO : payTerminalMap.get(APPLET_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(APPLET_PAY_STATE);
BigDecimal weChatOfficialAccountPayAmount = isNull ? BigDecimal.ZERO : payTerminalMap.get(WECHAT_OFFICIAL_ACCOUNT_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(WECHAT_OFFICIAL_ACCOUNT_PAY_STATE);
BigDecimal iosPayAmount = isNull ? BigDecimal.ZERO : payTerminalMap.get(IOS_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(IOS_PAY_STATE);
orderPayProfileDispalyVo.setAppletPayAmount(appPayAmount);
orderPayProfileDispalyVo.setAppletPayAmount(appletPayAmount);
orderPayProfileDispalyVo.setWeChatOfficialAccountPayAmount(weChatOfficialAccountPayAmount);
orderPayProfileDispalyVo.setIosPayAmount(iosPayAmount);
return orderPayProfileDispalyVo;
}
/**
* 订单统计解析
*
* @param
* @param latch
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo analyticStatisticsOrderProfiles(Supplier<Stream<BaseOrderDTO>> orderSuppiler,
CountDownLatch latch,
OrderProfileDispayVo orderProfileDispayVo) {
//1.真实数据按时间分组
Map<Date, BigDecimal> orderAmountMap = orderSuppiler.get().collect(Collectors.groupingBy(BaseOrderDTO::getPayDate, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
//2.某个时间段的订单统计
//2.1 订单金额
List<OrderProfileVo> orderProfileVos = createOrderProfiles(orderAmountMap);
//2.2 订单量
wrapBaseDateToOrderProfileDispay(orderSuppiler, orderProfileDispayVo);
//3.今日金额
Date date = DateUtil.beginOfDay(new Date()).toJdkDate();
BigDecimal todayOrderAmount = orderAmountMap == null ? BigDecimal.ZERO : orderAmountMap.get(date) == null ? BigDecimal.ZERO : orderAmountMap.get(date);
orderProfileDispayVo.setTodayOrderAmount(todayOrderAmount);
orderProfileDispayVo.setOrderProfiles(orderProfileVos);
latch.countDown();
return orderProfileDispayVo;
}
/**
* 包装基础数据 订单金额 与订单量
*
* @param orderSuppiler
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo wrapBaseDateToOrderProfileDispay(Supplier<Stream<BaseOrderDTO>> orderSuppiler, OrderProfileDispayVo orderProfileDispayVo) {
Map<Date, Long> orderNumMap = orderSuppiler.get().collect(Collectors.groupingBy(BaseOrderDTO::getPayDate, Collectors.counting()));
if (orderNumMap == null || orderNumMap.isEmpty()) {
return orderProfileDispayVo;
}
Date date = DateUtil.beginOfDay(new Date()).toJdkDate();
//今日订单量
long todayOrderNum = orderNumMap.get(date) == null ? 0 : orderNumMap.get(date);
Set<Map.Entry<Date, Long>> orderNumEntrySet = orderNumMap.entrySet();
Iterator<Map.Entry<Date, Long>> orderNumIterator = orderNumEntrySet.iterator();
//总订单量累计
long totalOrderNum = 0;
while (orderNumIterator.hasNext()) {
Map.Entry<Date, Long> orderNumMapEntry = orderNumIterator.next();
totalOrderNum = +orderNumMapEntry.getValue();
}
orderProfileDispayVo.setOrderNum(totalOrderNum);
orderProfileDispayVo.setTodayOrderNum(todayOrderNum);
return orderProfileDispayVo;
}
/**
* 组装对象
*
* @param orderAmountMap
* @return
*/
private List<OrderProfileVo> createOrderProfiles(Map<Date, BigDecimal> orderAmountMap) {
List<OrderProfileVo> orderProfileVos = new ArrayList<>();
if (orderAmountMap == null || orderAmountMap.isEmpty()) {
return orderProfileVos;
}
Set<Map.Entry<Date, BigDecimal>> orderAmountEntrySet = orderAmountMap.entrySet();
Iterator<Map.Entry<Date, BigDecimal>> orderAmountIterator = orderAmountEntrySet.iterator();
OrderProfileVo orderProfileVo;
while (orderAmountIterator.hasNext()) {
Map.Entry<Date, BigDecimal> orderAmountMapEntry = orderAmountIterator.next();
orderProfileVo = new OrderProfileVo();
orderProfileVo.setOrderDate(orderAmountMapEntry.getKey());
orderProfileVo.setOrderAmount(orderAmountMapEntry.getValue());
orderProfileVos.add(orderProfileVo);
}
return orderProfileVos;
} }
//2.1查询订单统计数据
List<OrderReceivedStatisticsBaseVo> orderReceivedStatisticsBaseVos = orderReceivedStatisticsBiz.findOrderReceivedStatisticsByDate(startDate,endDate);
//2.2查询固定编者数据
//3. /**
* 运营中心订单统计
*
* @param orderSuppiler
* @param latch
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo analyticStatisticsCenterOrder(Supplier<Stream<BaseOrderDTO>> orderSuppiler,
CountDownLatch latch,
OrderProfileDispayVo orderProfileDispayVo) {
largeScreenDisplayDataVo.setLargeScreenDisplayConstantData(largeScreenDisplayConstantDataBo); //筛选出租车订单
largeScreenDisplayDataVo.setOrderProfileDispayData(orderProfileDispayVo); Map<Integer, BigDecimal> areaAmountMap = orderSuppiler.get().filter(x -> Objects.equals(x.getType(), OrderTypeEnum.RENT_VEHICLE.getCode()))
return largeScreenDisplayDataVo; .collect(Collectors.groupingBy(BaseOrderDTO::getAreaId, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
List<CenterOrderProfileDisplayVo> centerOrderProfileDisplayVos = createCenterOrderProfileDisplay(areaAmountMap);
orderProfileDispayVo.setCenterOrderProfileDisplays(centerOrderProfileDisplayVos);
latch.countDown();
return orderProfileDispayVo;
}
/**
* 区域统计处理
*
* @param areaAmountMap
* @return
*/
private List<CenterOrderProfileDisplayVo> createCenterOrderProfileDisplay(Map<Integer, BigDecimal> areaAmountMap) {
List<CenterOrderProfileDisplayVo> centerOrderProfileDisplayVos = new ArrayList<>();
//查询全部区域
List<Area> areas = vehicleFeign.findAllAreas();
if (CollectionUtils.isEmpty(areas)) {
return centerOrderProfileDisplayVos;
}
CenterOrderProfileDisplayVo centerOrderProfileDisplayVo;
//区域统计组装
for (Area area : areas) {
centerOrderProfileDisplayVo = new CenterOrderProfileDisplayVo();
Integer areaId = area.getId();
BigDecimal areaAmount = areaAmountMap == null ? BigDecimal.ZERO : areaAmountMap.get(areaId) == null ? BigDecimal.ZERO : areaAmountMap.get(areaId);
centerOrderProfileDisplayVo.setAreaId(areaId);
centerOrderProfileDisplayVo.setAreaName(area.getName());
centerOrderProfileDisplayVo.setOrderAmount(areaAmount);
centerOrderProfileDisplayVos.add(centerOrderProfileDisplayVo);
}
return centerOrderProfileDisplayVos;
}
/**
* 包装成baseOrder
*
* @param orderProfileDisplays
* @return
*/
private List<BaseOrderDTO> wrapToBaseOrder(List<OrderProfileDisplay> orderProfileDisplays) {
List<BaseOrderDTO> baseOrderDTOS = orderProfileDisplays.stream().map(x -> {
BaseOrderDTO baseOrderDTO = new BaseOrderDTO();
baseOrderDTO.setPayOrigin(x.getPayTerminal());
baseOrderDTO.setPayWay(x.getPayWay());
baseOrderDTO.setRealAmount(x.getOrderAmount());
baseOrderDTO.setOrderNum(x.getOrderNum());
baseOrderDTO.setAreaId(x.getAreaId());
return baseOrderDTO;
}).collect(Collectors.toList());
return CollectionUtils.isEmpty(baseOrderDTOS) ? new ArrayList<>() : baseOrderDTOS;
}
/**
* 根据开始时间与结束时间查询
*
* @param startDate
* @param endDate
* @return
*/
public List<OrderProfileDisplay> findOrderProfileDisplayDataByDate(Date startDate, Date endDate) {
List<OrderProfileDisplay> orderProfileDisplays = mapper.findOrderProfileDisplayDatabyDate(startDate, endDate);
return CollectionUtils.isEmpty(orderProfileDisplays) ? Collections.emptyList() : orderProfileDisplays;
}
} }
}
...@@ -5,10 +5,13 @@ import com.xxfc.platform.order.entity.VehicleProfileDisplay; ...@@ -5,10 +5,13 @@ import com.xxfc.platform.order.entity.VehicleProfileDisplay;
import com.xxfc.platform.order.mapper.VehicleProfileDisplayMapper; import com.xxfc.platform.order.mapper.VehicleProfileDisplayMapper;
import com.xxfc.platform.order.pojo.vo.VehicleProfileDisplayVo; import com.xxfc.platform.order.pojo.vo.VehicleProfileDisplayVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
...@@ -22,7 +25,25 @@ public class VehicleProfileDisplayBiz extends BaseBiz<VehicleProfileDisplayMappe ...@@ -22,7 +25,25 @@ public class VehicleProfileDisplayBiz extends BaseBiz<VehicleProfileDisplayMappe
public VehicleProfileDisplayVo findVehicleProfileDisplayData() { public VehicleProfileDisplayVo findVehicleProfileDisplayData() {
VehicleProfileDisplayVo vehicleProfileDisplayVo = new VehicleProfileDisplayVo(); VehicleProfileDisplayVo vehicleProfileDisplayVo = new VehicleProfileDisplayVo();
//todo //1.查询全部固定数据
List<VehicleProfileDisplay> vehicleProfileDisplays = mapper.selectAll();
if (CollectionUtils.isEmpty(vehicleProfileDisplays)) {
return vehicleProfileDisplayVo;
}
long travelNum = 0;
long toTravelNum = 0;
long maintenanceNum = 0;
long inMaintenanceNum = 0;
for (VehicleProfileDisplay vehicleProfileDisplay : vehicleProfileDisplays) {
travelNum = +vehicleProfileDisplay.getTravelNum();
toTravelNum = +vehicleProfileDisplay.getToTravelNum();
maintenanceNum = +vehicleProfileDisplay.getMaintenanceNum();
inMaintenanceNum = +vehicleProfileDisplay.getInMaintenanceNum();
}
vehicleProfileDisplayVo.setTravelNum(travelNum);
vehicleProfileDisplayVo.setToTravelNum(toTravelNum);
vehicleProfileDisplayVo.setMaintenanceNum(maintenanceNum);
vehicleProfileDisplayVo.setInMaintenanceNum(inMaintenanceNum);
return vehicleProfileDisplayVo; return vehicleProfileDisplayVo;
} }
} }
...@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.BaseOrder; ...@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.Achievement; import com.xxfc.platform.order.pojo.Achievement;
import com.xxfc.platform.order.pojo.QueryCriteria; import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.pojo.bg.BgOrderListVo; import com.xxfc.platform.order.pojo.bg.BgOrderListVo;
import com.xxfc.platform.order.pojo.dto.BaseOrderDTO;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo; import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO; import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO; import com.xxfc.platform.order.pojo.dto.OrderDTO;
...@@ -51,4 +52,6 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> { ...@@ -51,4 +52,6 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
List<OrderDTO> selectBaeOrderByOrderIds(@Param("orderIds") List<Integer> orderIds); List<OrderDTO> selectBaeOrderByOrderIds(@Param("orderIds") List<Integer> orderIds);
List<Achievement> selectTotalStatistical(QueryCriteria queryCriteria); List<Achievement> selectTotalStatistical(QueryCriteria queryCriteria);
List<BaseOrderDTO> findOrdersByDate(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
} }
package com.xxfc.platform.order.mapper; package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderProfileDisplay; import com.xxfc.platform.order.entity.OrderProfileDisplay;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
...@@ -9,4 +14,6 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -9,4 +14,6 @@ import tk.mybatis.mapper.common.Mapper;
* @data 2019/12/24 17:05 * @data 2019/12/24 17:05
*/ */
public interface OrderProfileDisplayMapper extends Mapper<OrderProfileDisplay> { public interface OrderProfileDisplayMapper extends Mapper<OrderProfileDisplay> {
List<OrderProfileDisplay> findOrderProfileDisplayDatabyDate(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
} }
...@@ -494,4 +494,8 @@ ...@@ -494,4 +494,8 @@
order by crt_time DESC order by crt_time DESC
</select> </select>
<select id="findOrdersByDate" resultType="com.xxfc.platform.order.pojo.dto.BaseOrderDTO">
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -15,4 +15,8 @@ ...@@ -15,4 +15,8 @@
<result property="payTerminal" column="pay_terminal"/> <result property="payTerminal" column="pay_terminal"/>
<result property="payWay" column="pay_way"/> <result property="payWay" column="pay_way"/>
</resultMap> </resultMap>
<select id="findOrderProfileDisplayDatabyDate" resultMap="orderProfileDisplayMap">
select * from `order_profile_display` where `order_date` between #{startDate} and #{endDate}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -463,8 +463,24 @@ ...@@ -463,8 +463,24 @@
</select> </select>
<select id="findOrderReceivedStatisticsByDate" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics"> <select id="findOrderReceivedStatisticsByDate" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `date`,(`total_amount`+`deposit_amount`+`no_deductible_amount`) as `totalAmount`,`total_quantity` as `totalQuantity`,(`rent_vehicle_amount`+`deposit_amount`+`no_deductible_amount`) as `rentVehicleAmount`,`rent_vehicle_quantity` as `rentVehicleQuantity`, select
`company_id` as `companyId`,`pay_way` as `payWay`,`company_name` as `companyName` from `order_received_statistics` where `has_pay`=1 `company_id` as `companyId`,`date`,
and `date` between #{startDate} and #{endDate} sum((`total_amount`+`deposit_amount`+`no_deductible_amount`)) as `totalAmount`,
sum(`total_quantity`) as `totalQuantity`,
sum((`rent_vehicle_amount`+`deposit_amount`+`no_deductible_amount`)) as `rentVehicleAmount`,
sum(`rent_vehicle_quantity`) as `rentVehicleQuantity`,
`pay_way` as `payWay`,
`company_name` as `companyName` from `order_received_statistics` where `has_pay`=1 and `pay_way`=1
and `date` between #{startDate} and #{endDate} group by `company_id`,`date`
union all
select
`company_id` as `companyId`,`date`,
sum((`total_amount`+`deposit_amount`+`no_deductible_amount`)) as `totalAmount`,
sum(`total_quantity`) as `totalQuantity`,
sum((`rent_vehicle_amount`+`deposit_amount`+`no_deductible_amount`)) as `rentVehicleAmount`,
sum(`rent_vehicle_quantity`) as `rentVehicleQuantity`,
`pay_way` as `payWay`,
`company_name` as `companyName` from `order_received_statistics` where `has_pay`=1 and `pay_way`=2
and `date` between #{startDate} and #{endDate} group by `company_id`,`date`
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -6,7 +6,6 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO; ...@@ -6,7 +6,6 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.pojo.*; import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo; import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
...@@ -214,6 +213,6 @@ public interface VehicleFeign { ...@@ -214,6 +213,6 @@ public interface VehicleFeign {
@GetMapping("/branchCompany/company_info") @GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap(); Map<Integer, String> findCompanyMap();
@GetMapping("/branchCompany/company_area") @GetMapping("/area/areas")
List<BranchCompanyAreaDTO> findBranchCompanyAreas(); List<Area> findAllAreas();
} }
...@@ -8,10 +8,12 @@ import com.google.common.collect.Lists; ...@@ -8,10 +8,12 @@ import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.Area; import com.xxfc.platform.vehicle.entity.Area;
import com.xxfc.platform.vehicle.mapper.AreaMapper; import com.xxfc.platform.vehicle.mapper.AreaMapper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -24,25 +26,27 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf ...@@ -24,25 +26,27 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf
UserFeign userFeign; UserFeign userFeign;
@Override @Override
public UserFeign getUserFeign() {return userFeign;} public UserFeign getUserFeign() {
return userFeign;
}
public RestResponse<List<Area>> findAll() { public RestResponse<List<Area>> findAll() {
UserDTO userDTO = getAdminUserInfo(); UserDTO userDTO = getAdminUserInfo();
if(userDTO == null) { if (userDTO == null) {
return RestResponse.suc(); return RestResponse.suc();
} }
String ids = null; String ids = null;
if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据 if (DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
if(StringUtils.isNotBlank(userDTO.getDataZone())) { if (StringUtils.isNotBlank(userDTO.getDataZone())) {
ids = userDTO.getDataZone(); ids = userDTO.getDataZone();
} else { } else {
ids = userDTO.getZoneId() + ""; ids = userDTO.getZoneId() + "";
} }
if(ids.contains(",")) { if (ids.contains(",")) {
String[] array = ids.split(","); String[] array = ids.split(",");
List<Integer> list = Lists.newArrayList(); List<Integer> list = Lists.newArrayList();
for(int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
if(StringUtils.isNotBlank(array[i])) { if (StringUtils.isNotBlank(array[i])) {
list.add(Integer.parseInt(array[i])); list.add(Integer.parseInt(array[i]));
} }
} }
...@@ -50,7 +54,7 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf ...@@ -50,7 +54,7 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf
} else { } else {
Area area = mapper.selectByPrimaryKey(ids); Area area = mapper.selectByPrimaryKey(ids);
if (Objects.isNull(area)){ if (Objects.isNull(area)) {
return null; return null;
} }
List<Area> areas = Lists.newArrayList(); List<Area> areas = Lists.newArrayList();
...@@ -64,5 +68,8 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf ...@@ -64,5 +68,8 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf
} }
public List<Area> findAllAreas() {
List<Area> areas = mapper.selectAll();
return CollectionUtils.isEmpty(areas) ? Collections.emptyList() : areas;
}
} }
...@@ -24,7 +24,6 @@ import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper; ...@@ -24,7 +24,6 @@ import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO; import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo; import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
...@@ -33,7 +32,6 @@ import com.xxfc.platform.vehicle.util.excel.ExcelImport; ...@@ -33,7 +32,6 @@ import com.xxfc.platform.vehicle.util.excel.ExcelImport;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
...@@ -448,8 +446,4 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -448,8 +446,4 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,BranchCompany::getName)); return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,BranchCompany::getName));
} }
public List<BranchCompanyAreaDTO> findBranchCompanyAreas() {
List<BranchCompanyAreaDTO> branchCompanyAreaDTOS = mapper.findBranchCompanyAreas();
return CollectionUtils.isEmpty(branchCompanyAreaDTOS)?Collections.emptyList():branchCompanyAreaDTOS;
}
} }
...@@ -2,7 +2,6 @@ package com.xxfc.platform.vehicle.mapper; ...@@ -2,7 +2,6 @@ package com.xxfc.platform.vehicle.mapper;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -24,6 +23,5 @@ public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdLi ...@@ -24,6 +23,5 @@ public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdLi
@Select("SELECT `code`,count(id) cd FROM `vehicle` WHERE is_del=0 and number_plate LIKE '%测试%' GROUP BY code HAVING cd>=2") @Select("SELECT `code`,count(id) cd FROM `vehicle` WHERE is_del=0 and number_plate LIKE '%测试%' GROUP BY code HAVING cd>=2")
List<JSONObject> getList(); List<JSONObject> getList();
List<BranchCompanyAreaDTO> findBranchCompanyAreas();
} }
\ No newline at end of file
...@@ -30,4 +30,9 @@ public class AreaController extends BaseController<AreaBiz, Area> { ...@@ -30,4 +30,9 @@ public class AreaController extends BaseController<AreaBiz, Area> {
} }
@GetMapping("/areas")
public List<Area> findAllAreas(){
return baseBiz.findAllAreas();
}
} }
...@@ -19,7 +19,6 @@ import com.xxfc.platform.vehicle.entity.BranchCompany; ...@@ -19,7 +19,6 @@ import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO; import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo; import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO; import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
...@@ -229,8 +228,4 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -229,8 +228,4 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
return baseBiz.selectCompanyMap(); return baseBiz.selectCompanyMap();
} }
@GetMapping("/company_area")
public List<BranchCompanyAreaDTO> findBranchCompanyAreas(){
return baseBiz.findBranchCompanyAreas();
}
} }
...@@ -97,8 +97,4 @@ ...@@ -97,8 +97,4 @@
</if> </if>
) AS `cb` ON cb.id = bc.company_base_id ORDER BY bc.id ) AS `cb` ON cb.id = bc.company_base_id ORDER BY bc.id
</select> </select>
<select id="findBranchCompanyAreas" resultType="com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO">
select `id` as `compnayId`,`name` as `companyName`,`zone_id` as `areaId`,`area`.name as `areaName` from `branch_company` as `bc` inner join `area` on bc.zone_id=area.id
</select>
</mapper> </mapper>
\ No newline at end of file
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