Commit 44682271 authored by 周健威's avatar 周健威

统计

parent 0eea3127
package com.github.wxiaoqi.security.common.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.mockito.internal.util.collections.Sets;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_JSON_TRUE;
@Slf4j
public class AssertUtils {
public static<T> T isBlank(T object, BaseException baseException, String name) throws BaseException {
log.info(" AssertUtils.isBlank : {}", object);
if(object instanceof Collection) {
if (CollUtil.isEmpty((List)object)) {
throwException(baseException, name);
}
}else if (object == null) {
throwException(baseException, name);
}
return object;
}
public static<T> T isNotBlank(T object, BaseException baseException, String name) throws BaseException {
log.info(" AssertUtils.isNotBlank : {}", object);
if (object != null ) {
//如果是集合 并且 为空 着不抛异常
if (object instanceof Collection && CollUtil.isEmpty((List)object)) {
return object;
}else {
throwException(baseException, name);
}
}
return object;
}
public static<T> T isBlank(T object, BaseException baseException) throws BaseException {
return isBlank(object, baseException, null);
}
public static<T> T isNotBlank(T object, BaseException baseException) throws BaseException {
return isNotBlank(object, baseException, null);
}
public static void isBlankMulti(Object... objects) throws BaseException {
log.info(" AssertUtils.isBlank : {}", objects);
isBlank(objects);
for (Object object : objects) {
isBlank(object);
}
}
// public static void isEqual(Object a, Object b, BaseException bex) throws BaseException {
// log.info(" AssertUtils.isEqual : {} {}", a, b);
// if(a.equals(b)) {
// if(null != bex) {
// throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
// }else {
// throw bex;
// }
// }
// }
public static<T> T isBlank(T object) throws BaseException {
return isBlank(object, null, null);
}
public static<T> T isBlankBean(T object) throws BaseException {
Map<String, Object> beanMap = BeanUtil.beanToMap(object);
isBlank(object);
for(String key : beanMap.keySet()) {
isBlank(beanMap.get(key), null, null);
}
return object;
}
public static<T> T isBlank(T object, String attrName) throws BaseException {
return isBlank(object, null, attrName);
}
public static Integer isDBSucc(Integer flag, BaseException baseException) throws BaseException {
log.info(" AssertUtils.isDBSucc : {}", flag);
if(SYS_FALSE.equals(flag)) {
throwDBException(baseException);
}
return flag;
}
public static Integer isDBSucc(Integer flag) throws BaseException {
return isDBSucc(flag, null);
}
public static<T> ObjectRestResponse<T> isFeignSucc(ObjectRestResponse<T> orr) throws BaseException {
log.info(" AssertUtils.isFeignSucc : {}", orr);
if(!SYS_JSON_TRUE.equals(orr.getStatus())) {
throw new BaseException(orr.getMessage(), orr.getStatus());
}
return orr;
}
public static<T,E> ObjectRestResponse<T> isFeignSuccGetObj(E dto, Function<Map, ObjectRestResponse<T>> function) throws BaseException {
log.info(" AssertUtils.isFeignSucc : {}", dto);
ObjectRestResponse<T> orr = function.apply(DepthBeanToMap.objectToMap(dto));
//ObjectRestResponse<T> orr = function.apply( BeanUtil.beanToMap(dto, false, false));
if(!SYS_JSON_TRUE.equals(orr.getStatus())) {
throw new BaseException(orr.getMessage(), orr.getStatus());
}
return orr;
}
public static<T,E> List<T> isFeignSuccGetDataList(E dto, Function<Map, ObjectRestResponse<List<T>>> function, Class<T> tClass) throws BaseException {
log.info(" AssertUtils.isFeignSucc : {}", dto);
ObjectRestResponse<List<T>> orr = function.apply(DepthBeanToMap.objectToMap(dto));
//ObjectRestResponse<List<T>> orr = function.apply(BeanUtil.beanToMap(dto, false, false));
if(!SYS_JSON_TRUE.equals(orr.getStatus())) {
throw new BaseException(orr.getMessage(), orr.getStatus());
}
orr.setData(orr.getData().parallelStream().map(t -> BeanUtil.toBean(t, tClass)).collect(Collectors.toList()));
return orr.getData();
}
public static<T,E> T isFeignSuccGetData(E dto, Function<Map, ObjectRestResponse<T>> function) throws BaseException {
return isFeignSuccGetObj(dto, function).getData();
}
private static void throwException(BaseException baseException, String name) {
if(null != baseException) {
throw baseException;
}else {
throw new BaseException(ResultCode.NOTEXIST_CODE, Sets.newSet(name));
}
}
private static void throwDBException(BaseException baseException) {
if(null != baseException) {
throw baseException;
}else {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
}
}
package com.github.wxiaoqi.security.common.util;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class DepthBeanToMap {
public static Map objectToMap(Object obj){
try{
Class type = obj.getClass();
Map returnMap = new HashMap();
BeanInfo beanInfo = Introspector.getBeanInfo(type);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (int i = 0; i< propertyDescriptors.length; i++) {
PropertyDescriptor descriptor = propertyDescriptors[i];
String propertyName = descriptor.getName();
if (!propertyName.equals("class")) {
Method readMethod = descriptor.getReadMethod();
Object result = readMethod.invoke(obj, new Object[0]);
if(result == null){
continue;
}
//判断是否为 基础类型 String,Boolean,Byte,Short,Integer,Long,Float,Double
//判断是否集合类,COLLECTION,MAP
if(result instanceof String
|| result instanceof Boolean
|| result instanceof Byte
|| result instanceof Short
|| result instanceof Integer
|| result instanceof Long
|| result instanceof Float
|| result instanceof Double
|| result instanceof Enum
){
if (result != null) {
returnMap.put(propertyName, result);
}
}else if(result instanceof Collection){
Collection<?> lstObj = arrayToMap((Collection<?>)result);
returnMap.put(propertyName, lstObj);
}else if(result instanceof Map){
Map<Object,Object> lstObj = mapToMap((Map<Object,Object>)result);
returnMap.put(propertyName, lstObj);
} else {
Map mapResult = objectToMap(result);
returnMap.put(propertyName, mapResult);
}
}
}
return returnMap;
}catch(Exception e){
throw new RuntimeException(e);
}
}
private static Map<Object, Object> mapToMap(Map<Object, Object> orignMap) {
Map<Object,Object> resultMap = new HashMap<Object,Object>();
for(Map.Entry<Object, Object> entry:orignMap.entrySet()){
Object key = entry.getKey();
Object resultKey = null;
if(key instanceof Collection){
resultKey = arrayToMap((Collection)key);
}else if(key instanceof Map){
resultKey = mapToMap((Map)key);
}
else{
if(key instanceof String
|| key instanceof Boolean
|| key instanceof Byte
|| key instanceof Short
|| key instanceof Integer
|| key instanceof Long
|| key instanceof Float
|| key instanceof Double
|| key instanceof Enum
){
if (key != null) {
resultKey = key;
}
}else{
resultKey = objectToMap(key);
}
}
Object value = entry.getValue();
Object resultValue = null;
if(value instanceof Collection){
resultValue = arrayToMap((Collection)value);
}else if(value instanceof Map){
resultValue = mapToMap((Map)value);
}
else{
if(value instanceof String
|| value instanceof Boolean
|| value instanceof Byte
|| value instanceof Short
|| value instanceof Integer
|| value instanceof Long
|| value instanceof Float
|| value instanceof Double
|| value instanceof Enum
){
if (value != null) {
resultValue = value;
}
}else{
resultValue = objectToMap(value);
}
}
resultMap.put(resultKey, resultValue);
}
return resultMap;
}
private static Collection arrayToMap(Collection lstObj){
ArrayList arrayList = new ArrayList();
for (Object t : lstObj) {
if(t instanceof Collection){
Collection result = arrayToMap((Collection)t);
arrayList.add(result);
}else if(t instanceof Map){
Map result = mapToMap((Map)t);
arrayList.add(result);
} else {
if(t instanceof String
|| t instanceof Boolean
|| t instanceof Byte
|| t instanceof Short
|| t instanceof Integer
|| t instanceof Long
|| t instanceof Float
|| t instanceof Double
|| t instanceof Enum
){
if (t != null) {
arrayList.add(t);
}
}else{
Object result = objectToMap(t);
arrayList.add(result);
}
}
}
return arrayList;
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.common.vo;
import lombok.Data;
import java.util.List;
@Data
public class DataInterBean implements DataInter {
private List<Integer> DataCompanyIds;
private List<Integer> DataCorporationIds;
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.DataInterBean;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
......@@ -84,4 +85,14 @@ public interface UserRestInterface {
}
}
default void setPowerData(DataInter dataInter){
setPowerData(dataInter, Boolean.TRUE);
}
default DataInterBean getDataInter() {
DataInterBean dataInterBean = new DataInterBean();
setPowerData(dataInterBean);
return dataInterBean;
}
}
package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.order.entity.BaseOrder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import java.util.List;
@Data
public class OrderFullDTO extends BaseOrder {
private List<String> vehicleIds;
private String multiNotStatus;
private String multiStatus;
/**
* 开始时间 需要大于等于
*/
private Long startTimeGte;
/**
* 开始时间 需要小于等于
*/
private Long startTimeLte;
/**
* 结束时间 需要大于等于
*/
private Long endTimeGte;
/**
* 结束时间 需要小于等于
*/
private Long endTimeLte;
}
package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderMemberDetail;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.OrderTourDetail;
import lombok.Data;
@Data
public class OrderFullVO extends BaseOrder {
OrderRentVehicleDetail orderRentVehicleDetail;
OrderTourDetail orderTourDetail;
OrderMemberDetail orderMemberDetail;
}
......@@ -8,6 +8,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {
......@@ -22,6 +23,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableFeignClients(value = {"com.github.wxiaoqi.security.auth.client.feign", "com.github.wxiaoqi.security.admin.feign", "com.xxfc.platform"},defaultConfiguration = HeaderConfig.class)
@EnableAceCache
@AddBasicConfiguration
@EnableAspectJAutoProxy(exposeProxy = true)
@tk.mybatis.spring.annotation.MapperScan(basePackages = "com.xxfc.platform.order.mapper")
public class OrderApplication {
public static void main(String[] args) {
......
......@@ -10,6 +10,8 @@ import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.mapper.OrderRentVehicleDetailMapper;
import com.xxfc.platform.order.pojo.order.OrderFullDTO;
import com.xxfc.platform.order.pojo.order.OrderFullVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.vehicle.entity.BranchCompany;
......@@ -145,5 +147,9 @@ public class OrderRentVehicleBiz extends BaseBiz<OrderRentVehicleDetailMapper, O
return bo;
}
public List<OrderFullVO> selectListFull(OrderFullDTO dto) {
return mapper.selectListFull(dto);
}
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -8,14 +12,21 @@ import com.github.wxiaoqi.security.common.msg.auth.PageResult;
import com.google.common.collect.Maps;
import com.xxfc.platform.order.Utils.OrderDateUtils;
import com.xxfc.platform.order.contant.enumerate.OrderInquiryType;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundStatusEnum;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderStatisticsMapper;
import com.xxfc.platform.order.pojo.*;
import com.xxfc.platform.order.pojo.order.OrderFullDTO;
import com.xxfc.platform.order.pojo.order.OrderFullVO;
import com.xxfc.platform.order.rest.background.BgStatisticsController;
import com.xxfc.platform.vehicle.constant.RedisKey;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -26,6 +37,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
/**
* @author Administrator
......@@ -46,6 +59,9 @@ public class OrderStatisticsBiz extends BaseBiz<OrderStatisticsMapper, OrderStat
private DailyTravelOrderStatisticsBiz travelStatisticsBiz;
@Autowired
private DailyMembersOrderStatisticsBiz membersStatisticsBiz;
@Autowired
OrderRentVehicleBiz orderRentVehicleBiz;
public HomePageOrderData getTotalOrder(List<Integer> companyIds, Integer dataAll) {
HomePageOrderData result = new HomePageOrderData();
......@@ -378,4 +394,72 @@ public class OrderStatisticsBiz extends BaseBiz<OrderStatisticsMapper, OrderStat
map.put(memberLevel.getName() + "购买量", number);
map.put("支付金额(" + memberLevel.getName() + ")", amount);
}
@Cache(key = RedisKey.STATISTICS_ORDER_DAY+"{1}{2}")
public BgStatisticsController.IndexOrderVO handleStatistics(String companyIds, String timeStr, List<String> vehicleIds) {
//清空 RedisKey.STATISTICS_ORDER_DAY+"{1}"
getMyBiz().getMyBiz().cacheClearStatistics(companyIds);
BgStatisticsController.IndexOrderVO indexOrderVO = new BgStatisticsController.IndexOrderVO();
OrderFullDTO orderFullDTO = new OrderFullDTO(){{
setCrtTime(DateUtil.beginOfDay(DateUtil.date()));
setHasPay(SYS_TRUE);
setVehicleIds(vehicleIds);
setMultiNotStatus(OrderStatusEnum.ORDER_CANCEL.getCode().toString());
}};
List<OrderFullVO> orderFullVOS = orderRentVehicleBiz.selectListFull(orderFullDTO);
//今天订单金额
BigDecimal allAmount = orderFullVOS.parallelStream().map(BaseOrder::getRealAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
//今天订单数量
Long allNum = Long.valueOf(orderFullVOS.size());
//获取今天出发订单
OrderFullDTO orderFullDTO2 = new OrderFullDTO(){{
setStartTimeGte(DateUtil.beginOfDay(DateUtil.date()).getTime());
setStartTimeLte(DateUtil.endOfDay(DateUtil.date()).getTime());
setVehicleIds(vehicleIds);
setMultiStatus(OrderStatusEnum.ORDER_TOSTART.getCode().toString());
}};
List<OrderFullVO> orderFullVOS2 = orderRentVehicleBiz.selectListFull(orderFullDTO2);
//今天出发车辆数量
Long toLiftNum = Long.valueOf(orderFullVOS2.size());
//获取今天归还订单
OrderFullDTO orderFullDTO3 = new OrderFullDTO(){{
setEndTimeGte(DateUtil.beginOfDay(DateUtil.date()).getTime());
setEndTimeLte(DateUtil.endOfDay(DateUtil.date()).getTime());
setVehicleIds(vehicleIds);
setMultiStatus(OrderStatusEnum.ORDER_WAIT.getCode().toString());
}};
List<OrderFullVO> orderFullVOS3 = orderRentVehicleBiz.selectListFull(orderFullDTO3);
//今天归还车辆数量
Long toReturnNum = Long.valueOf(orderFullVOS3.size());
//获取今天归还订单
OrderFullDTO orderFullDTO4 = new OrderFullDTO(){{
setVehicleIds(vehicleIds);
setMultiStatus(OrderStatusEnum.ORDER_FINISH.getCode().toString());
setRefundStatus(RefundStatusEnum.RESIDUE_ILLEGAL.getCode());
}};
List<OrderFullVO> orderFullVOS4 = orderRentVehicleBiz.selectListFull(orderFullDTO4);
//今天归还车辆数量
Long toDealTrafficNum = Long.valueOf(orderFullVOS4.size());
indexOrderVO.setCurrDayOrderAmount(allAmount);
indexOrderVO.setCurrDayOrderNum(allNum);
indexOrderVO.setCurrDayToLiftVehicleNum(toLiftNum);
indexOrderVO.setCurrDayToReturnVehicleNum(toReturnNum);
indexOrderVO.setToDealTrafficPay(toDealTrafficNum);
return indexOrderVO;
}
@CacheClear(pre = RedisKey.STATISTICS_ORDER_DAY+"{1}")
public void cacheClearStatistics(String companyIds) {;}
private OrderStatisticsBiz getMyBiz() {
return AopContext.currentProxy() != null ? (OrderStatisticsBiz) AopContext.currentProxy() : this;
}
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.order.OrderFullDTO;
import com.xxfc.platform.order.pojo.order.OrderFullVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
......@@ -16,5 +18,6 @@ import java.util.List;
public interface OrderRentVehicleDetailMapper extends Mapper<OrderRentVehicleDetail> {
public List<OrderRentVehicleDetail> listByOrderId(@Param("orderId") Integer orderId);
public Integer getPScore(@Param("modelId") Integer modelId);
public List<OrderFullVO> selectListFull(OrderFullDTO dto);
}
package com.xxfc.platform.order.rest.background;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.ace.cache.annotation.Cache;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.AssertUtils;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.biz.DailyMembersOrderStatisticsBiz;
import com.xxfc.platform.order.biz.DailyTravelOrderStatisticsBiz;
import com.xxfc.platform.order.biz.DailyVehicleOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.DataInterBean;
import com.xxfc.platform.order.biz.*;
import com.xxfc.platform.order.contant.enumerate.DepositRefundStatus;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.RefundStatusEnum;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.pojo.MembersOrderDto;
import com.xxfc.platform.order.pojo.OrderQuery;
import com.xxfc.platform.order.pojo.order.OrderFullDTO;
import com.xxfc.platform.order.pojo.order.OrderFullVO;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -30,8 +45,12 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
/**
* @author Administrator
......@@ -40,19 +59,45 @@ import java.util.List;
@RestController
@RequestMapping("/background/statistics")
@Api(description = "每月总的订单统计")
public class BgStatisticsController extends BaseController<OrderStatisticsBiz, OrderStatistics> {
public class BgStatisticsController extends BaseController<OrderStatisticsBiz, OrderStatistics> implements UserRestInterface {
@Autowired
BaseOrderBiz baseOrderBiz;
@Autowired
OrderRentVehicleBiz orderRentVehicleBiz;
@Autowired
UserFeign userFeign;
@Autowired
VehicleFeign vehicleFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@GetMapping("/indexOrder")
@ApiOperation(value = "首页订单统计")
public ObjectRestResponse<IndexOrderVO> indexOrder() {
IndexOrderVO indexOrderVO = new IndexOrderVO();
indexOrderVO.setCurrDayOrderAmount(new BigDecimal("1000000000.00"));
indexOrderVO.setCurrDayOrderNum(2L);
indexOrderVO.setCurrDayToLiftVehicleNum(3L);
indexOrderVO.setCurrDayToReturnVehicleNum(4L);
indexOrderVO.setToDealTrafficPay(5L);
//获取当前用户所在的公司
if (StrUtil.isBlank(getCurrentUserId())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
DataInterBean dataInterBean = getDataInter();
//获取公司对应的车的id
String companyIds = StrUtil.join(",", dataInterBean.getDataCompanyIds());
String timeStr = DatePattern.NORM_DATETIME_MINUTE_FORMAT.format(new DateTime());
if(companyIds == null || "null".equals(companyIds)) {
companyIds = "0";
}
ObjectRestResponse<List<Vehicle>> feignResponse = vehicleFeign.vehicleSelectByCompanyIds(companyIds);
List<String> vehicleIds = feignResponse.getData().parallelStream().map(Vehicle::getId).collect(Collectors.toList());
//获取会员订单统计信息
return ObjectRestResponse.succ(indexOrderVO);
return ObjectRestResponse.succ(baseBiz.handleStatistics(companyIds, timeStr, vehicleIds));
}
@Data
......
......@@ -35,4 +35,51 @@
</where>
order by crt_time desc
</select>
<select id="selectListFull" parameterType="com.xxfc.platform.order.pojo.order.OrderFullDTO" resultType="com.xxfc.platform.order.pojo.order.OrderFullVO">
select bo.*
from order_rent_vehicle_detail orvd
left join base_order bo on
orvd.order_id = bo.id
<where>
<if test="crtTime != null">
and bo.crt_time &gt;= #{crtTime}
</if>
<if test="startTimeGte != null">
and orvd.start_time &gt;= #{startTimeGte}
</if>
<if test="startTimeLte != null">
and orvd.start_time &lt;= #{startTimeLte}
</if>
<if test="endTimeGte != null">
and orvd.end_time &gt;= #{endTimeGte}
</if>
<if test="endTimeLte != null">
and orvd.end_time &lt;= #{endTimeLte}
</if>
<if test="hasPay != null">
and bo.has_pay = #{hasPay}
</if>
<if test="vehicleIds != null">
and orvd.vehicle_id in
<foreach collection="vehicleIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="multiNotStatus != null">
and bo.status not in
<foreach collection="multiNotStatus.split(',')" item="notStatus" open="(" separator="," close=")">
#{notStatus}
</foreach>
</if>
<if test="multiStatus != null">
and bo.status not in
<foreach collection="multiStatus.split(',')" item="status" open="(" separator="," close=")">
#{status}
</foreach>
</if>
</where>
order by crt_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -116,4 +116,6 @@ public class RedisKey {
public static final String BRANCH_COMPANY_CATA_LIST = BRANCH_CATA_CACHE + ":list";
// 每日统计cache cache:statistics:order:day:[vehicleIds]:202009121322:
public static final String STATISTICS_ORDER_DAY ="cache:statistics:order:day";
}
......@@ -236,4 +236,11 @@ public interface VehicleFeign {
@GetMapping(value = "/vehicleHolidayPriceInfo/getByVehicleIdFeign")
public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getByVehicleIdFeign(
@RequestParam("vehicleId") String vehicleId, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("userId") Integer userId, @RequestParam("companyId") Integer companyId);
@RequestMapping(value = "/vehicleInfo/selectByParam", method = RequestMethod.GET)
public RestResponse<List<Vehicle>> vehicleSelectByParam(@RequestParam(value = "vehicle")Map<String, Object> vehicleMap);
@RequestMapping(value = "/vehicleInfo/selectByCompanyIds", method = RequestMethod.GET)
public ObjectRestResponse<List<Vehicle>> vehicleSelectByCompanyIds(@RequestParam("companyIds") String companyIds);
}
......@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
......@@ -670,6 +671,15 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return RestResponse.data(vehicleVO);
}
@RequestMapping(value = "/selectByCompanyIds", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<List<Vehicle>> selectByCompanyIds(String companyIds) {
if(StrUtil.isBlank(companyIds) || "0".equals(companyIds)) {
return ObjectRestResponse.succ(baseBiz.selectListAlls());
}else {
return ObjectRestResponse.succ(baseBiz.selectByAttrs(Vehicle::getSubordinateBranch, CollUtil.toList(companyIds.split(","))));
}
}
@Data
static public class VehicleVO extends Vehicle {
......
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