Commit c5544e9e authored by libin's avatar libin

大屏数据调试

parent e2ef45c1
......@@ -38,9 +38,8 @@ public class UserProfileDisplay {
*/
@Column(name = "users_num")
private Integer usersNum;
/**
* 会员数
*/
@Column(name = "members_num")
private Integer membersNum;
@Transient
@JsonIgnore
private long memberNums;
}
......@@ -30,7 +30,7 @@ public class UserProfileDisplayVo implements Serializable {
/**
* 会员占比数
*/
private int membershipRatio;
private String membershipRatio;
/**
* 用户统计
*/
......
......@@ -12,7 +12,6 @@ import com.github.wxiaoqi.security.admin.vo.AppUserInfoVo;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.im.utils.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
......@@ -222,4 +221,12 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
}
return null;
}
public List<AppUserDetail> findAllUsers() {
Example example = new Example(AppUserDetail.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isdel",0);
List<AppUserDetail> userDetails = mapper.selectByExample(example);
return CollectionUtils.isEmpty(userDetails)?Collections.emptyList():userDetails;
}
}
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.UserProfileDisplay;
import com.github.wxiaoqi.security.admin.mapper.UserProfileDisplayMapper;
import com.github.wxiaoqi.security.admin.vo.UserProfileDisplayVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author libin
......@@ -19,9 +29,97 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserProfileDisplayBiz extends BaseBiz<UserProfileDisplayMapper, UserProfileDisplay> {
/**
* 字典查询type
*/
@Value("${large.screen.type:LARGE_SCREEN_DISPLAY}")
private String largeScreenType;
/**
* 字典查询code
*/
@Value("${large.screen.member.code:LARGE_SCREEN_DISPLAY_EMEMBER_CONSTANT}")
private String largeScreenCode;
private final AppUserDetailBiz appUserDetailBiz;
private final ThirdFeign thirdFeign;
private static final Integer GUANG_DONG_CODE = 440000;
public UserProfileDisplayVo findUserProfileData() {
UserProfileDisplayVo userProfileDisplayVo = new UserProfileDisplayVo();
//todo
//1.查询固定数据
List<UserProfileDisplay> userProfileDisplays = mapper.selectAll();
//2.查询真实数据
List<AppUserDetail> appUserDetails = appUserDetailBiz.findAllUsers();
//3.包装数据
List<UserProfileDisplay> wrapUserProfileDisplays = wrapToUserProfileDisplay(appUserDetails);
if (CollectionUtils.isNotEmpty(wrapUserProfileDisplays)) {
wrapUserProfileDisplays = aggreationForUserProfileDisplayData(userProfileDisplays, wrapUserProfileDisplays);
}
//4.查询固定会员数
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(largeScreenType, largeScreenCode);
if (Objects.nonNull(dictionary) && StringUtils.hasText(dictionary.getDetail())) {
String memberNumStr = dictionary.getDetail();
long memberNums = Integer.valueOf(memberNumStr);
userProfileDisplayVo.setMembersNum(memberNums);
}
wrapUserProfileDisplay(wrapUserProfileDisplays, userProfileDisplayVo);
userProfileDisplayVo.setUserProfileDisplays(wrapUserProfileDisplays);
return userProfileDisplayVo;
}
private List<UserProfileDisplay> aggreationForUserProfileDisplayData(List<UserProfileDisplay> baseuserProfileDisplays, List<UserProfileDisplay> wrapUserProfileDisplays) {
Map<Integer, UserProfileDisplay> userProfileMap = wrapUserProfileDisplays.stream().collect(Collectors.toMap(UserProfileDisplay::getProvinceCode, Function.identity()));
for (UserProfileDisplay baseuserProfileDisplay : baseuserProfileDisplays) {
Integer provinceCode = baseuserProfileDisplay.getProvinceCode();
UserProfileDisplay userProfileDisplay = userProfileMap.get(provinceCode);
if (Objects.isNull(userProfileDisplay)) {
continue;
}
int userNums = baseuserProfileDisplay.getUsersNum() + userProfileDisplay.getUsersNum();
long memberNums = baseuserProfileDisplay.getMemberNums() + userProfileDisplay.getMemberNums();
baseuserProfileDisplay.setUsersNum(userNums);
baseuserProfileDisplay.setMemberNums(memberNums);
}
return baseuserProfileDisplays;
}
private UserProfileDisplayVo wrapUserProfileDisplay(List<UserProfileDisplay> userProfileDisplays, UserProfileDisplayVo userProfileDisplayVo) {
long membersNum = 0;
long usersNum = 0;
for (UserProfileDisplay userProfileDisplay : userProfileDisplays) {
usersNum = usersNum + userProfileDisplay.getUsersNum();
membersNum = membersNum + userProfileDisplay.getMemberNums();
}
membersNum = membersNum + userProfileDisplayVo.getMembersNum();
userProfileDisplayVo.setUsersNum(usersNum);
userProfileDisplayVo.setMembersNum(membersNum);
double ratio = membersNum / (usersNum * 1.0);
userProfileDisplayVo.setMembershipRatio(String.format("%.2f",ratio));
return userProfileDisplayVo;
}
private List<UserProfileDisplay> wrapToUserProfileDisplay(List<AppUserDetail> appUserDetails) {
List<UserProfileDisplay> userProfileDisplays = new ArrayList<>();
if (CollectionUtils.isEmpty(appUserDetails)) {
return userProfileDisplays;
}
Map<Integer, List<AppUserDetail>> appUserDetailMap = appUserDetails.stream().peek(x -> {
if (x.getProvinceCode() == null || x.getProvinceCode() == 0) {
x.setProvinceCode(GUANG_DONG_CODE);
}
}).collect(Collectors.groupingBy(AppUserDetail::getProvinceCode, Collectors.toList()));
UserProfileDisplay userProfileDisplay;
Set<Map.Entry<Integer, List<AppUserDetail>>> appUserDetailEntrySet = appUserDetailMap.entrySet();
for (Map.Entry<Integer, List<AppUserDetail>> appUserMapEntry : appUserDetailEntrySet) {
userProfileDisplay = new UserProfileDisplay();
Integer provinceCode = appUserMapEntry.getKey();
userProfileDisplay.setProvinceCode(provinceCode);
List<AppUserDetail> appUserDetailList = appUserMapEntry.getValue();
userProfileDisplay.setUsersNum(appUserDetailList.size());
long members = appUserDetailList.stream().filter(x -> Objects.equals(x.getIsMember(), 1)).count();
userProfileDisplay.setMemberNums(members);
userProfileDisplays.add(userProfileDisplay);
}
return userProfileDisplays;
}
}
......@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
* @data 2019/12/26 10:11
*/
@RestController
@RequestMapping("/large_screen")
@RequestMapping("/large_screen/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LargeScreenDisplayUserController {
private final UserProfileDisplayBiz userProfileDisplayBiz;
......
......@@ -6,7 +6,6 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.github.wxiaoqi.security.admin.entity.UserProfileDisplay" id="userProfileDisplayMap">
<result property="id" column="id"/>
<result property="membersNum" column="travel_num"/>
<result property="provinceCode" column="province_code"/>
<result property="provinceName" column="province_name"/>
<result property="usersNum" column="users_num"/>
......
......@@ -26,4 +26,21 @@ public class LargeScreenDisplayConstantDataBo implements Serializable {
* 订单基础单量
*/
private int baseOrderNum;
/**
* 微信支付占比率
*/
private double wxPayRatio;
/**
* 支付宝支付占比率
*/
private double aliPayRatio;
/**
* 安卓终端支付占比率
*/
private double androidPayRatio;
/**
* ios终端支付占比率
*/
private double iosPayRatio;
}
package com.xxfc.platform.order.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 15:43
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "center_order_profile_display")
@Entity
public class CenterOrderProfileDisplay implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
/**
* 区域id
*/
@Column(name = "area_id")
private Integer areaId;
/**
* 区域名称
*/
@Column(name = "area_name")
private String areaName;
/**
* 区域订单金额
*/
@Column(name = "area_amount")
private BigDecimal areaAmount;
}
......@@ -23,16 +23,7 @@ public class OrderProfileDisplay {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
/**
* 区域id
*/
@Column(name = "area_id")
private Integer areaId;
/**
* 区域名称
*/
@Column(name = "area_name")
private String areaName;
/**
* 订单日期
*/
......@@ -43,25 +34,25 @@ public class OrderProfileDisplay {
*/
@Column(name = "order_amount")
private BigDecimal orderAmount;
/**
* 订单量
*/
@Column(name = "order_num")
private Integer orderNum;
/**
* 支付方式 1:微信 2:支付宝
*/
@Column(name = "pay_way")
private Integer payWay;
/**
* 支付终端 1:app 2:小程序 3:公众号 4:ios
*/
@Column(name = "pay_terminal")
private Integer payTerminal;
/**
* 订单类型 1:租车 2:旅游 3:会员
*/
@Column(name = "order_type")
private Integer orderType;
// /**
// * 订单量
// */
// @Column(name = "order_num")
// private Integer orderNum;
// /**
// * 支付方式 1:微信 2:支付宝
// */
// @Column(name = "pay_way")
// private Integer payWay;
// /**
// * 支付终端 1:app 2:小程序 3:公众号 4:ios
// */
// @Column(name = "pay_terminal")
// private Integer payTerminal;
// /**
// * 订单类型 1:租车 2:旅游 3:会员
// */
// @Column(name = "order_type")
// private Integer orderType;
}
......@@ -60,7 +60,7 @@ public class BaseOrderDTO implements Serializable {
public Date getPayDate() {
return Objects.isNull(payTime) ? null : DateUtil.beginOfDay(new Date(payTime));
return Objects.isNull(payTime) ? payDate : DateUtil.beginOfDay(new Date(payTime));
}
public Integer getOrderNum() {
......
......@@ -21,7 +21,7 @@ public class CenterOrderProfileDisplayVo implements Serializable {
/**
* 订单金额
*/
private BigDecimal orderAmount = BigDecimal.ZERO;
private BigDecimal areaAmount = BigDecimal.ZERO;
/**
* 区域名称
*/
......
package com.xxfc.platform.order.pojo.vo;
import com.xxfc.platform.order.bo.LargeScreenDisplayConstantDataBo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -23,16 +22,8 @@ public class LargeScreenDisplayDataVo implements Serializable {
* 订单相关数据
*/
private OrderProfileDispayVo orderProfileDispayData;
/**
* 常量数据
*/
private LargeScreenDisplayConstantDataBo largeScreenDisplayConstantData;
public OrderProfileDispayVo getOrderProfileDispayData() {
return Objects.isNull(orderProfileDispayData)?new OrderProfileDispayVo():orderProfileDispayData;
}
public LargeScreenDisplayConstantDataBo getLargeScreenDisplayConstantData() {
return Objects.isNull(largeScreenDisplayConstantData)?new LargeScreenDisplayConstantDataBo():largeScreenDisplayConstantData;
}
}
......@@ -29,17 +29,25 @@ public class OrderPayProfileDispalyVo implements Serializable {
/**
* app支付金额
*/
private BigDecimal appPayAmount = BigDecimal.ZERO;
private BigDecimal androidPayAmount = BigDecimal.ZERO;
/**
* ios支付金额
*/
private BigDecimal iosPayAmount = BigDecimal.ZERO;
/**
* 小程序支付金额
* 微信占比
*/
private BigDecimal appletPayAmount = BigDecimal.ZERO;
private String wxPayRatio;
/**
* 公众号支付金额
* 支付宝占比
*/
private BigDecimal weChatOfficialAccountPayAmount = BigDecimal.ZERO;
private String aliPayRatio;
/**
* 安卓支付占比
*/
private String androidPayRatio;
/**
* ios支付占比
*/
private String iosPayRatio;
}
package com.xxfc.platform.order.pojo.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -22,9 +23,14 @@ public class OrderProfileVo implements Serializable {
/**
* 订单日期
*/
@JsonIgnore
private Date orderDate;
/**
* 订单金额
*/
private BigDecimal orderAmount = BigDecimal.ZERO;
/**
* 显示日期
*/
private String date;
}
......@@ -2,6 +2,7 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
......@@ -970,7 +971,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
}
public List<BaseOrderDTO> findOrdersByDate(Date startDate, Date endDate) {
List<BaseOrderDTO> baseOrderDTOS = mapper.findOrdersByDate(startDate,endDate);
startDate = DateUtil.beginOfDay(startDate);
endDate = DateUtil.endOfDay(endDate);
long startTime = startDate.getTime();
long endTime = endDate.getTime();
List<BaseOrderDTO> baseOrderDTOS = mapper.findOrdersByDate(startDate,endDate,startTime,endTime);
return CollectionUtils.isEmpty(baseOrderDTOS)?Collections.emptyList():baseOrderDTOS;
}
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.order.entity.CenterOrderProfileDisplay;
import com.xxfc.platform.order.mapper.CenterOrderProfileDisplayMapper;
import com.xxfc.platform.order.pojo.vo.CenterOrderProfileDisplayVo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 15:48
*/
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor =@__(@Autowired))
public class CenterOrderProfileDisplayBiz extends BaseBiz<CenterOrderProfileDisplayMapper, CenterOrderProfileDisplay> {
public List<CenterOrderProfileDisplayVo> findCenterOrderProfileDisplays(){
List<CenterOrderProfileDisplayVo> centerOrderProfileDisplayVos = new ArrayList<>();
List<CenterOrderProfileDisplay> centerOrderProfileDisplays = mapper.selectAll();
if (CollectionUtils.isEmpty(centerOrderProfileDisplays)){
return centerOrderProfileDisplayVos;
}
return JSON.parseObject(JSON.toJSONString(centerOrderProfileDisplays),new TypeReference<List<CenterOrderProfileDisplayVo>>(){});
}
}
......@@ -12,8 +12,8 @@ import com.xxfc.platform.order.pojo.dto.BaseOrderDTO;
import com.xxfc.platform.order.pojo.vo.*;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.entity.Area;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,9 +27,8 @@ import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.function.Supplier;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author libin
......@@ -45,17 +44,18 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
/**
* 字典查询type
*/
@Value("large.screen.type:LARGE_SCREEN_DISPLAY")
@Value("${large.screen.type:LARGE_SCREEN_DISPLAY}")
private String largeScreenType;
/**
* 字典查询code
*/
@Value("large.screen.code:LARGE_SCREEN_DISPLAY_CONSTANT")
@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 VehicleFeign vehicleFeign;
private final CenterOrderProfileDisplayBiz centerOrderProfileDisplayBiz;
private final ThreadPoolTaskExecutor executor;
private static final Integer WX_PAY_STATE = 1;
private static final Integer ALI_PAY_STATE = 2;
......@@ -87,16 +87,11 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
//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(() -> {
try {
analyticStatisticsCenterOrder(orderSupplier, orderProfileDispayVo);
analyticStatisticsCenterOrder(baseOrders, orderProfileDispayVo);
} catch (Exception ex) {
log.error("十大运营中心订单统计失败【{}】", ex);
} finally {
......@@ -106,7 +101,7 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
//4.总的订单数据
executor.execute(() -> {
try {
analyticStatisticsOrderProfiles(orderSupplier, orderProfileDispayVo);
analyticStatisticsOrderProfiles(baseOrders, orderProfileDisplays, orderProfileDispayVo);
} catch (Exception ex) {
log.error("总订单数据解析失败【{}】", ex);
} finally {
......@@ -114,9 +109,10 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
}
});
//5.支付方式|支付终端数据处理
LargeScreenDisplayConstantDataBo finalLargeScreenDisplayConstantDataBo = largeScreenDisplayConstantDataBo;
executor.execute(() -> {
try {
analyticStatisticsOrderPayWayProfiles(orderSupplier, orderProfileDispayVo);
analyticStatisticsOrderPayWayProfiles(baseOrders, orderProfileDisplays, finalLargeScreenDisplayConstantDataBo,orderProfileDispayVo);
} catch (Exception ex) {
log.error("支付方式|支付终端数据处理失败【{}】", ex);
} finally {
......@@ -128,13 +124,13 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
} catch (InterruptedException e) {
log.error("统计出错:【{}】", e);
}
//6.基础金额 + 真实金额 基础订单量+真实订单量
//1.基础金额 + 真实金额 基础订单量+真实订单量
long totalOrderNum = orderProfileDispayVo.getOrderNum() + largeScreenDisplayConstantDataBo.getBaseOrderNum();
BigDecimal totalOrderAmount = orderProfileDispayVo.getOrderAmount().add(largeScreenDisplayConstantDataBo.getBaseOrderAmount());
orderProfileDispayVo.setOrderNum(totalOrderNum);
orderProfileDispayVo.setOrderAmount(totalOrderAmount);
largeScreenDisplayDataVo.setLargeScreenDisplayConstantData(largeScreenDisplayConstantDataBo);
orderProfileDispayVo.setOrderNum(totalOrderNum);
largeScreenDisplayDataVo.setOrderProfileDispayData(orderProfileDispayVo);
return largeScreenDisplayDataVo;
}
......@@ -142,17 +138,22 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
/**
* 支付方式|终端的统计
*
* @param orderSuppiler
* @param orderProfileDispayVo
* @param largeScreenDisplayConstantDataBo
* @param baseOrders
* @return
*/
private OrderProfileDispayVo analyticStatisticsOrderPayWayProfiles(Supplier<Stream<BaseOrderDTO>> orderSuppiler,
private OrderProfileDispayVo analyticStatisticsOrderPayWayProfiles(List<BaseOrderDTO> baseOrders,
List<OrderProfileDisplay> orderProfileDisplays,
LargeScreenDisplayConstantDataBo largeScreenDisplayConstantDataBo,
OrderProfileDispayVo orderProfileDispayVo) {
OrderPayProfileDispalyVo orderPayProfileDispalyVo = new OrderPayProfileDispalyVo();
BigDecimal orderAmountConstant = CollectionUtils.isEmpty(orderProfileDisplays) ? BigDecimal.ZERO :
orderProfileDisplays.stream().map(OrderProfileDisplay::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
//1.支付方式统计
wrapToPayProfileWithPayWay(orderSuppiler, orderPayProfileDispalyVo);
wrapToPayProfileWithPayWay(baseOrders, orderAmountConstant, largeScreenDisplayConstantDataBo, orderPayProfileDispalyVo);
//2.支付终端统计
wrapToPayProfileWithPayTerminal(orderSuppiler, orderPayProfileDispalyVo);
wrapToPayProfileWithPayTerminal(baseOrders, orderAmountConstant, largeScreenDisplayConstantDataBo, orderPayProfileDispalyVo);
orderProfileDispayVo.setOrderPayProfileDisplay(orderPayProfileDispalyVo);
return orderProfileDispayVo;
......@@ -161,39 +162,69 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
/**
* 支付方式统计
*
* @param orderSupplier
* @param baseOrders
* @param orderAmountConstant
* @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);
private OrderPayProfileDispalyVo wrapToPayProfileWithPayWay(List<BaseOrderDTO> baseOrders,
BigDecimal orderAmountConstant,
LargeScreenDisplayConstantDataBo largeScreenDisplayConstantDataBo,
OrderPayProfileDispalyVo orderPayProfileDispalyVo) {
Map<Integer, BigDecimal> payWayMap = CollectionUtils.isEmpty(baseOrders) ? Collections.EMPTY_MAP :
baseOrders.stream().collect(Collectors.groupingBy(BaseOrderDTO::getPayWay, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
boolean isEmpty = payWayMap.isEmpty();
BigDecimal wxPayAmount = isEmpty ? BigDecimal.ZERO : payWayMap.get(WX_PAY_STATE) == null ? BigDecimal.ZERO : payWayMap.get(WX_PAY_STATE);
BigDecimal aliPayAmount = isEmpty ? BigDecimal.ZERO : payWayMap.get(ALI_PAY_STATE) == null ? BigDecimal.ZERO : payWayMap.get(ALI_PAY_STATE);
//基础金额 * 占比率
wxPayAmount = wxPayAmount.add(orderAmountConstant.multiply(new BigDecimal(String.valueOf(largeScreenDisplayConstantDataBo.getWxPayRatio()))));
aliPayAmount = aliPayAmount.add(orderAmountConstant.multiply(new BigDecimal(String.valueOf(largeScreenDisplayConstantDataBo.getAliPayRatio()))));
BigDecimal totalAmount = wxPayAmount.add(aliPayAmount);
String wxPayRatio = wxPayAmount.divide(totalAmount,2,BigDecimal.ROUND_HALF_UP).toString();
String aliPayRatio = aliPayAmount.divide(totalAmount,2,BigDecimal.ROUND_HALF_UP).toString();
orderPayProfileDispalyVo.setWxPayRatio(wxPayRatio);
orderPayProfileDispalyVo.setAliPayRatio(aliPayRatio);
orderPayProfileDispalyVo.setWxPayAmount(wxPayAmount.setScale(2));
orderPayProfileDispalyVo.setAliPayAmount(aliPayAmount.setScale(2));
return orderPayProfileDispalyVo;
}
/**
* 支付终端统计
*
* @param orderSupplier
* @param baseOrders
* @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);
private OrderPayProfileDispalyVo wrapToPayProfileWithPayTerminal(List<BaseOrderDTO> baseOrders,
BigDecimal orderAmountConstant,
LargeScreenDisplayConstantDataBo largeScreenDisplayConstantDataBo,
OrderPayProfileDispalyVo orderPayProfileDispalyVo) {
Map<Integer, BigDecimal> payTerminalMap = CollectionUtils.isEmpty(baseOrders) ? Collections.EMPTY_MAP :
baseOrders.stream().collect(Collectors.groupingBy(BaseOrderDTO::getPayOrigin, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
boolean isEmpty = payTerminalMap.isEmpty();
BigDecimal androidPayAmount = isEmpty ? BigDecimal.ZERO : payTerminalMap.get(APP_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(APP_PAY_STATE);
BigDecimal appletPayAmount = isEmpty ? BigDecimal.ZERO : payTerminalMap.get(APPLET_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(APPLET_PAY_STATE);
BigDecimal weChatOfficialAccountPayAmount = isEmpty ? BigDecimal.ZERO : payTerminalMap.get(WECHAT_OFFICIAL_ACCOUNT_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(WECHAT_OFFICIAL_ACCOUNT_PAY_STATE);
BigDecimal iosPayAmount = isEmpty ? BigDecimal.ZERO : payTerminalMap.get(IOS_PAY_STATE) == null ? BigDecimal.ZERO : payTerminalMap.get(IOS_PAY_STATE);
//applet 公众号 划为ios支付
iosPayAmount = iosPayAmount.add(appletPayAmount).add(weChatOfficialAccountPayAmount);
//基础金额 * 占比率
androidPayAmount = androidPayAmount.add(orderAmountConstant.multiply(new BigDecimal(String.valueOf(largeScreenDisplayConstantDataBo.getAndroidPayRatio()))));
iosPayAmount = iosPayAmount.add(orderAmountConstant.multiply(new BigDecimal(String.valueOf(largeScreenDisplayConstantDataBo.getIosPayRatio()))));
BigDecimal totalAmount = androidPayAmount.add(iosPayAmount);
String androidPayRatio = androidPayAmount.divide(totalAmount, 2, BigDecimal.ROUND_HALF_UP).toString();
String iosPayRatio = iosPayAmount.divide(totalAmount, 2, BigDecimal.ROUND_HALF_UP).toString();
orderPayProfileDispalyVo.setAndroidPayRatio(androidPayRatio);
orderPayProfileDispalyVo.setIosPayRatio(iosPayRatio);
orderPayProfileDispalyVo.setAndroidPayAmount(androidPayAmount.setScale(2));
orderPayProfileDispalyVo.setIosPayAmount(iosPayAmount.setScale(2));
return orderPayProfileDispalyVo;
}
......@@ -204,15 +235,19 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo analyticStatisticsOrderProfiles(Supplier<Stream<BaseOrderDTO>> orderSuppiler,
private OrderProfileDispayVo analyticStatisticsOrderProfiles(List<BaseOrderDTO> baseOrders,
List<OrderProfileDisplay> orderProfileDisplays,
OrderProfileDispayVo orderProfileDispayVo) {
//包装数据
List<BaseOrderDTO> baseOrderDTOS = wrapToBaseOrder(orderProfileDisplays);
baseOrderDTOS.addAll(baseOrders);
//1.真实数据按时间分组
Map<Date, BigDecimal> orderAmountMap = orderSuppiler.get().collect(Collectors.groupingBy(BaseOrderDTO::getPayDate, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
Map<Date, BigDecimal> orderAmountMap = baseOrderDTOS.stream().collect(Collectors.groupingBy(BaseOrderDTO::getPayDate, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
//2.某个时间段的订单统计
//2.1 订单金额
List<OrderProfileVo> orderProfileVos = createOrderProfiles(orderAmountMap);
//2.2 订单量
wrapBaseDateToOrderProfileDispay(orderSuppiler, orderProfileDispayVo);
wrapBaseDateToOrderProfileDispay(baseOrders, orderProfileDispayVo);
//3.今日金额
Date date = DateUtil.beginOfDay(new Date()).toJdkDate();
BigDecimal todayOrderAmount = orderAmountMap == null ? BigDecimal.ZERO : orderAmountMap.get(date) == null ? BigDecimal.ZERO : orderAmountMap.get(date);
......@@ -224,27 +259,18 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
/**
* 包装基础数据 订单金额 与订单量
*
* @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()));
private OrderProfileDispayVo wrapBaseDateToOrderProfileDispay(List<BaseOrderDTO> baseOrderDTOS, OrderProfileDispayVo orderProfileDispayVo) {
Map<Date, Long> orderNumMap = CollectionUtils.isEmpty(baseOrderDTOS) ? Collections.EMPTY_MAP :
baseOrderDTOS.stream().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;
}
......@@ -268,23 +294,39 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
orderProfileVo = new OrderProfileVo();
orderProfileVo.setOrderDate(orderAmountMapEntry.getKey());
orderProfileVo.setOrderAmount(orderAmountMapEntry.getValue());
orderProfileVo.setDate(DateUtil.format(orderProfileVo.getOrderDate(),"MM.dd"));
orderProfileVos.add(orderProfileVo);
}
orderProfileVos.sort(Comparator.comparing(OrderProfileVo::getOrderDate));
return orderProfileVos;
}
/**
* 运营中心订单统计
*
* @param orderSuppiler
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo analyticStatisticsCenterOrder(Supplier<Stream<BaseOrderDTO>> orderSuppiler,
private OrderProfileDispayVo analyticStatisticsCenterOrder(List<BaseOrderDTO> baseOrders,
OrderProfileDispayVo orderProfileDispayVo) {
//根据公司id查询公司区域
Map<Integer,BranchCompanyAreaDTO> companyAreaDTOMap = new HashMap<>(100);
if (!CollectionUtils.isEmpty(baseOrders)){
List<Integer> companyIds = baseOrders.stream().map(BaseOrderDTO::getCompanyId).collect(Collectors.toList());
List<BranchCompanyAreaDTO> branchCompnays = vehicleFeign.findBranchCompnayAreaByIds(companyIds);
companyAreaDTOMap = branchCompnays.stream().collect(Collectors.toMap(BranchCompanyAreaDTO::getCompanyId, Function.identity()));
}
//筛选出租车订单
Map<Integer, BigDecimal> areaAmountMap = orderSuppiler.get().filter(x -> Objects.equals(x.getType(), OrderTypeEnum.RENT_VEHICLE.getCode()))
.collect(Collectors.groupingBy(BaseOrderDTO::getAreaId, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
Map<Integer, BranchCompanyAreaDTO> finalCompanyAreaDTOMap = companyAreaDTOMap;
Map<Integer, BigDecimal> areaAmountMap = CollectionUtils.isEmpty(baseOrders) ? Collections.EMPTY_MAP :
baseOrders.stream().filter(x -> Objects.equals(x.getType(), OrderTypeEnum.RENT_VEHICLE.getCode()))
.peek(x->{
BranchCompanyAreaDTO branchCompanyAreaDTO = finalCompanyAreaDTOMap.get(x.getCompanyId());
x.setAreaId(branchCompanyAreaDTO.getAreaId());
})
.collect(Collectors.groupingBy(BaseOrderDTO::getAreaId, CollectorsUtil.summingBigDecimal(BaseOrderDTO::getRealAmount)));
List<CenterOrderProfileDisplayVo> centerOrderProfileDisplayVos = createCenterOrderProfileDisplay(areaAmountMap);
orderProfileDispayVo.setCenterOrderProfileDisplays(centerOrderProfileDisplayVos);
......@@ -300,20 +342,14 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
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();
List<CenterOrderProfileDisplayVo> centerOrderProfileDisplays = centerOrderProfileDisplayBiz.findCenterOrderProfileDisplays();
for (CenterOrderProfileDisplayVo centerOrderProfileDisplay : centerOrderProfileDisplays) {
Integer areaId = centerOrderProfileDisplay.getAreaId();
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);
areaAmount = areaAmount.add(centerOrderProfileDisplay.getAreaAmount());
centerOrderProfileDisplay.setAreaAmount(areaAmount);
centerOrderProfileDisplayVos.add(centerOrderProfileDisplay);
}
return centerOrderProfileDisplayVos;
}
......@@ -327,11 +363,8 @@ public class OrderProfileDisplayBiz extends BaseBiz<OrderProfileDisplayMapper, O
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());
baseOrderDTO.setPayDate(x.getOrderDate());
return baseOrderDTO;
}).collect(Collectors.toList());
return CollectionUtils.isEmpty(baseOrderDTOS) ? new ArrayList<>() : baseOrderDTOS;
......
......@@ -53,5 +53,7 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
List<Achievement> selectTotalStatistical(QueryCriteria queryCriteria);
List<BaseOrderDTO> findOrdersByDate(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
@Param("endDate") Date endDate,
@Param("startTime") Long startTime,
@Param("endTime") Long endTime);
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.CenterOrderProfileDisplay;
import tk.mybatis.mapper.common.Mapper;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 15:49
*/
public interface CenterOrderProfileDisplayMapper extends Mapper<CenterOrderProfileDisplay> {
}
......@@ -19,7 +19,7 @@ import java.util.Date;
* @data 2019/12/24 16:29
*/
@RestController
@RequestMapping("/large_screen")
@RequestMapping("/large_screen/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LargeScreenDisplayController {
......
......@@ -116,14 +116,14 @@
<select id="listOrder" parameterType="Map" resultMap="orderListMap">
select b.*
<if test="type==1">
,i.detail as carArticlesJson
,i.detail as carArticlesJson
</if>
from base_order b
LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id
LEFT JOIN order_tour_detail t on t.order_id = b.id
LEFT JOIN order_member_detail m on m.order_id = b.id
<if test="type==1">
LEFT JOIN (select * from order_item where type = 104) i on b.id = i.order_id
LEFT JOIN (select * from order_item where type = 104) i on b.id = i.order_id
</if>
<where>
<if test="crtUser != null">
......@@ -372,7 +372,7 @@
</select>
<select id="findMemberOrders" resultType="com.xxfc.platform.order.pojo.dto.MemberOrderBo">
select bo.*,omd.member_level AS `memberLevel` from (
select bo.*,omd.member_level AS `memberLevel` from (
SELECT
`id`,
`no` AS `orderNo`,
......@@ -426,29 +426,33 @@
</foreach>
</if>
) AS `bo`
INNER JOIN (select * from `order_member_detail` where 1=1
INNER JOIN (select * from `order_member_detail` where 1=1
<if test="level!=null">
and `member_level`=#{level}
and `member_level`=#{level}
</if>
) AS `omd` ON omd.order_id=bo.id
ORDER BY bo.`creatTime` DESC
</select>
<select id="selectOrdersByTypeAndTime" resultType="com.xxfc.platform.order.pojo.dto.OrderDTO">
select bo.id,bo.type,bo.status,bo.order_amount,bo.real_amount,bo.order_origin,bo.parent_user_id as `userId`,bo.parent_position_id as `postionId`,
bo.has_pay,bo.pay_way,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),`parent_user_company_id`) AS `companyId`,
select bo.id,bo.type,bo.status,bo.order_amount,bo.real_amount,bo.order_origin,bo.parent_user_id as
`userId`,bo.parent_position_id as `postionId`,
bo.has_pay,bo.pay_way,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),`parent_user_company_id`)
AS `companyId`,
orvd.deposit,orvd.cost_detail AS `costDetail`
from (select * from `base_order` where 1=1
<if test="hasPay!=null">
and `has_pay`=#{hasPay}
</if>
and (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreach collection="types"
item="type"
open="(" close=")"
separator=",">
<if test="hasPay!=null">
and `has_pay`=#{hasPay}
</if>
and (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and
`type` IN <foreach collection="types"
item="type"
open="(" close=")"
separator=",">
#{type}
</foreach> ) AS `bo`
LEFT JOIN (select `order_id`,`start_company_id`,`deposit`,`cost_detail` from `order_rent_vehicle_detail`) AS `orvd` ON
LEFT JOIN (select `order_id`,`start_company_id`,`deposit`,`cost_detail` from `order_rent_vehicle_detail`) AS
`orvd` ON
orvd.order_id=bo.id
LEFT JOIN (select `order_id`,`start_company_id` from `order_tour_detail`) AS `otd` ON otd.order_id=bo.id
LEFT JOIN (select `order_id`,`member_level` AS `memberLevel` from `order_member_detail`) AS `omd` ON
......@@ -466,7 +470,8 @@
<select id="selectTotalStatistical" parameterType="com.xxfc.platform.order.pojo.QueryCriteria"
resultType="com.xxfc.platform.order.pojo.Achievement">
select
crt_time,no,type,order_amount,real_amount,realname,username,parentRealname,positionName,parentUsername,companyName,pay_way,company_id,(order_amount-real_amount) as favorablePrice
crt_time,no,type,order_amount,real_amount,realname,username,parentRealname,positionName,parentUsername,companyName,pay_way,company_id,(order_amount-real_amount)
as favorablePrice
from order_user_position_company
<where>
<if test="startDate != null">
......@@ -495,7 +500,20 @@
</select>
<select id="findOrdersByDate" resultType="com.xxfc.platform.order.pojo.dto.BaseOrderDTO">
SELECT bo.*,orvd.start_company_id as `companyId`,orvd.`start_zone_id` as `areaId` FROM(
SELECT
`id`,
`type`,
`real_amount`,
`pay_way`,
`pay_origin`,
`pay_time`
FROM
`base_order`
WHERE
has_pay = 1 and `pay_time` BETWEEN #{startTime} AND #{endTime}
) as bo
left join order_rent_vehicle_detail as orvd on orvd.order_id=bo.id;
</select>
</mapper>
\ No newline at end of file
<?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.order.mapper.CenterOrderProfileDisplayMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.CenterOrderProfileDisplay" id="centerOrderProfileDisplayMap">
<result property="id" column="id"/>
<result property="areaId" column="area_id"/>
<result property="areaName" column="area_name"/>
<result property="areaAmount" column="area_amount"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -6,14 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.OrderProfileDisplay" id="orderProfileDisplayMap">
<result property="id" column="id"/>
<result property="areaId" column="area_id"/>
<result property="areaName" column="area_name"/>
<result property="orderAmount" column="order_amount"/>
<result property="orderDate" column="order_date"/>
<result property="orderNum" column="order_num"/>
<result property="orderType" column="order_num"/>
<result property="payTerminal" column="pay_terminal"/>
<result property="payWay" column="pay_way"/>
</resultMap>
<select id="findOrderProfileDisplayDatabyDate" resultMap="orderProfileDisplayMap">
......
package com.xxfc.platform.vehicle.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -20,6 +21,7 @@ import javax.persistence.*;
public class VehicleProfileDisplay {
@Id
@GeneratedValue(generator = "JDBC")
@JsonIgnore
private Integer id;
/**
* 省份code
......@@ -32,26 +34,9 @@ public class VehicleProfileDisplay {
@Column(name = "province_name")
private String provinceName;
/**
* 出行中
* 车辆数量
*/
@Column(name = "travel_num")
private Integer travelNum;
/**
* 待出行
*/
@Column(name = "to_travel_num")
private Integer toTravelNum;
/**
* 保养中
*/
@Column(name = "maintenance_num")
private Integer maintenanceNum;
/**
* 维修中
*/
@Column(name = "in_maintenance_num")
private Integer inMaintenanceNum;
@Column(name = "vehicle_num")
private Integer vehicleNum;
}
......@@ -6,6 +6,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.*;
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.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
......@@ -215,4 +216,7 @@ public interface VehicleFeign {
@GetMapping("/area/areas")
List<Area> findAllAreas();
@GetMapping("/branchCompany/compnays_area")
public List<BranchCompanyAreaDTO> findBranchCompnayAreaByIds(@RequestParam("companyIds") List<Integer> compnayIds);
}
......@@ -17,8 +17,7 @@ import java.io.Serializable;
@AllArgsConstructor
public class BranchCompanyAreaDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer compnayId;
private Integer companyId;
private String companyName;
private Integer areaId;
private String areaName;
}
......@@ -21,24 +21,6 @@ import java.util.List;
@AllArgsConstructor
public class VehicleProfileDisplayVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 出行中
*/
private long travelNum;
/**
* 待出行
*/
private long toTravelNum;
/**
* 保养中
*/
private long maintenanceNum;
/**
* 维修中
*/
private long inMaintenanceNum;
/**
* 每个省份车辆概况数据
*/
......
......@@ -24,6 +24,7 @@ import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
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.BranchCompanyListDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
......@@ -446,4 +447,8 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,BranchCompany::getName));
}
public List<BranchCompanyAreaDTO> findBranchCompanyAreaByIds(List<Integer> compnayIds) {
List<BranchCompanyAreaDTO> branchCompanyAreaDTOS = mapper.findBranchCompanyAreaByIds(compnayIds);
return CollectionUtils.isEmpty(branchCompanyAreaDTOS)?Collections.EMPTY_LIST:branchCompanyAreaDTOS;
}
}
......@@ -11,16 +11,13 @@ import com.xxfc.platform.vehicle.pojo.vo.LargeScreenDisplayBaseDataVo;
import com.xxfc.platform.vehicle.pojo.vo.VehicleProfileDisplayVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.concurrent.CountDownLatch;
/**
* @author libin
......@@ -36,65 +33,28 @@ public class VehicleProfileDisplayBiz extends BaseBiz<VehicleProfileDisplayMappe
/**
* 字典查询type
*/
@Value("large.screen.type:LARGE_SCREEN_DISPLAY")
@Value("${large.screen.type:LARGE_SCREEN_DISPLAY}")
private String largeScreenType;
/**
* 字典查询code
*/
@Value("large.screen.cct.code:LARGE_SCREEN_DISPLAY_CCT_CONSTANT")
@Value("${large.screen.cct.code:LARGE_SCREEN_DISPLAY_CCT_CONSTANT}")
private String largeScreenCode;
private final ThirdFeign thirdFeign;
private final ThreadPoolTaskExecutor executor;
public LargeScreenDisplayBaseDataVo findVehicleProfileDisplayData() {
LargeScreenDisplayBaseDataVo largeScreenDisplayBaseDataVo = new LargeScreenDisplayBaseDataVo();
VehicleProfileDisplayVo vehicleProfileDisplayVo = new VehicleProfileDisplayVo();
//1.查询全部固定数据
List<VehicleProfileDisplay> vehicleProfileDisplays = mapper.selectAll();
CountDownLatch latch = new CountDownLatch(1);
executor.execute(()->{
try {
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(largeScreenType, largeScreenType);
if (dictionary != null && StringUtils.hasText(dictionary.getDetail())) {
LargeScreenDisplayCCTConstantDataBo largeScreenDisplayConstantDataBo = JSON.parseObject(dictionary.getDetail(), LargeScreenDisplayCCTConstantDataBo.class);
largeScreenDisplayBaseDataVo.setLargeScreenDisplayCCTConstantDataBo(largeScreenDisplayConstantDataBo);
}
}catch (Exception ex){
log.error("字典数据查询失败【{}】",ex);
}finally {
latch.countDown();
}
});
if (CollectionUtils.isEmpty(vehicleProfileDisplays)) {
try {
latch.await();
} catch (InterruptedException e) {
log.error("查询失败【{}】",e);
}
return largeScreenDisplayBaseDataVo;
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(largeScreenType, largeScreenCode);
if (dictionary != null && StringUtils.hasText(dictionary.getDetail())) {
LargeScreenDisplayCCTConstantDataBo largeScreenDisplayConstantDataBo = JSON.parseObject(dictionary.getDetail(), LargeScreenDisplayCCTConstantDataBo.class);
largeScreenDisplayBaseDataVo.setLargeScreenDisplayCCTConstantDataBo(largeScreenDisplayConstantDataBo);
}
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);
vehicleProfileDisplayVo.setVehicleProfileDisplays(vehicleProfileDisplays);
largeScreenDisplayBaseDataVo.setVehicleProfileDisplayVo(vehicleProfileDisplayVo);
try {
latch.await();
} catch (InterruptedException e) {
log.error("查询失败【{}】",e);
}
return largeScreenDisplayBaseDataVo;
}
}
......@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.mapper;
import com.alibaba.fastjson.JSONObject;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -24,4 +25,5 @@ public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdLi
List<JSONObject> getList();
List<BranchCompanyAreaDTO> findBranchCompanyAreaByIds(@Param("companyIds") List<Integer> compnayIds);
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
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.vo.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
......@@ -228,4 +229,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
return baseBiz.selectCompanyMap();
}
@GetMapping("/compnays_area")
public List<BranchCompanyAreaDTO> findBranchCompnayAreaByIds(@RequestParam("companyIds") List<Integer> compnayIds){
return baseBiz.findBranchCompanyAreaByIds(compnayIds);
}
}
......@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
* @data 2019/12/26 9:41
*/
@RestController
@RequestMapping("/large_screen")
@RequestMapping("/large_screen/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LargeScreenDisplayCCTVehicleController {
private final VehicleProfileDisplayBiz vehicleProfileDisplayBiz;
......
......@@ -97,4 +97,15 @@
</if>
) AS `cb` ON cb.id = bc.company_base_id ORDER BY bc.id
</select>
<select id="findBranchCompanyAreaByIds"
resultType="com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO">
select `id` as `companyId`,`name` as `companyName`,`zone_id` as `areaId` from `branch_company`
<if test="companyIds != null and companyIds.size() != 0">
where `id` in
<foreach collection="companyIds" item="companyId" open="(" close=")" separator=",">
#{companyId}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -8,9 +8,6 @@
<result property="id" column="id"/>
<result property="provinceName" column="province_name"/>
<result property="provinceCode" column="province_code"/>
<result property="inMaintenanceNum" column="in_maintenance_num"/>
<result property="maintenanceNum" column="maintenance_num"/>
<result property="toTravelNum" column="to_travel_num"/>
<result property="travelNum" column="travel_num"/>
<result property="vehicleNum" column="vehicle_num"/>
</resultMap>
</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