Commit 6f22d9ea authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents ec78f01a 6d0a4388
package com.github.wxiaoqi.security.admin.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 16:41
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "user_profile_display")
public class UserProfileDisplay {
@Id
@GeneratedValue(generator = "JDBC")
@JsonIgnore
private Integer id;
/**
* 省份code
*/
@Column(name = "province_code")
private Integer provinceCode;
/**
* 省份名
*/
@Column(name = "province_name")
private String provinceName;
/**
* 用户数
*/
@Column(name = "users_num")
private Integer usersNum;
@Transient
@JsonIgnore
private long memberNums;
}
package com.github.wxiaoqi.security.admin.vo;
import com.github.wxiaoqi.security.admin.entity.UserProfileDisplay;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 9:43
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserProfileDisplayVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户数
*/
private long usersNum;
/**
* 会员数
*/
private long membersNum;
/**
* 会员占比数
*/
private String membershipRatio;
/**
* 用户统计
*/
private List<UserProfileDisplay> userProfileDisplays;
}
......@@ -41,13 +41,13 @@ public class AppShareholderDetailChangeRecordBiz extends BaseBiz<AppShareholderD
* 查询员工信息变更记录表
*/
public List<AppShareholderDetailChangeRecord> findShareholderChangeRecord(AppShareholderDetail appShareholderDetail) {
Example example = new Example(AppShareholderDetailChangeRecord.class);
/* Example example = new Example(AppShareholderDetailChangeRecord.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userId", appShareholderDetail.getId());
if (appShareholderDetail.getPhone() != null) {
criteria.andEqualTo("phone", appShareholderDetail.getPhone());
}
List<AppShareholderDetailChangeRecord > list = mapper.selectByExample(example);
}*/
List<AppShareholderDetailChangeRecord> list = mapper.selectAppshareholderUserOrPhoneOrUserId(appShareholderDetail.getId(), appShareholderDetail.getPhone());
return list;
}
}
......@@ -13,7 +13,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;
......@@ -229,4 +228,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
* @version 1.0
* @description
* @data 2019/12/24 17:06
*/
@Transactional(rollbackFor = Exception.class)
@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();
//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;
}
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppShareholderDetailChangeRecord;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface AppShareholderDetailChangeRecordMapper extends Mapper<AppShareholderDetailChangeRecord> {
List<AppShareholderDetailChangeRecord> selectAppshareholderUserOrPhoneOrUserId(@Param("userId") Integer userId, @Param("phone") String phone);
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.UserProfileDisplay;
import tk.mybatis.mapper.common.Mapper;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 17:03
*/
public interface UserProfileDisplayMapper extends Mapper<UserProfileDisplay> {
}
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.UserProfileDisplayBiz;
import com.github.wxiaoqi.security.admin.vo.UserProfileDisplayVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 10:11
*/
@RestController
@RequestMapping("/large_screen/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LargeScreenDisplayUserController {
private final UserProfileDisplayBiz userProfileDisplayBiz;
/**
* 用户概况
*
* @return
*/
@GetMapping("/user_profile_display")
public ObjectRestResponse<UserProfileDisplayVo> findUserProfileData() {
UserProfileDisplayVo userProfileDisplayVo = userProfileDisplayBiz.findUserProfileData();
return ObjectRestResponse.succ(userProfileDisplayVo);
}
}
<?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.github.wxiaoqi.security.admin.mapper.AppShareholderDetailChangeRecordMapper">
<resultMap id="appShareholderDetailMap" type="com.github.wxiaoqi.security.admin.entity.AppShareholderDetailChangeRecord">
<resultMap id="appShareholderDetailMap"
type="com.github.wxiaoqi.security.admin.entity.AppShareholderDetailChangeRecord">
<result property="id" column="id"/>
<result property="companyName" column="company_name"/>
<result property="userId" column="user_id"/>
......@@ -13,6 +14,20 @@
<result property="relTime" column="rel_time"/>
</resultMap>
<select id="selectAppshareholderUserOrPhoneOrUserId"
resultType="com.github.wxiaoqi.security.admin.entity.AppShareholderDetailChangeRecord">
SELECT *from
app_shareholder_detail_change_record
WHERE
1=1
<if test="userId!=null">
and user_id=#{userId}
</if>
<if test="phone!=null">
or phone=#{phone}
</if>
ORDER BY crt_time DESC
</select>
</mapper>
<?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.github.wxiaoqi.security.admin.mapper.UserProfileDisplayMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.github.wxiaoqi.security.admin.entity.UserProfileDisplay" id="userProfileDisplayMap">
<result property="id" column="id"/>
<result property="provinceCode" column="province_code"/>
<result property="provinceName" column="province_name"/>
<result property="usersNum" column="users_num"/>
</resultMap>
</mapper>
\ No newline at end of file
package com.xxfc.platform.order.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description 大屏展示的基础数据
* @data 2019/12/24 16:21
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LargeScreenDisplayConstantDataBo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单金额基础金额
*/
private BigDecimal baseOrderAmount = BigDecimal.ZERO;
/**
* 订单基础单量
*/
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;
}
package com.xxfc.platform.order.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description 订单概况
* @data 2019/12/24 16:33
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "order_profile_display")
public class OrderProfileDisplay {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
/**
* 订单日期
*/
@Column(name = "order_date")
private Date orderDate;
/**
* 订单金额
*/
@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;
}
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) ? payDate : DateUtil.beginOfDay(new Date(payTime));
}
public Integer getOrderNum() {
return Objects.isNull(orderNum) ? 1 : orderNum;
}
}
package com.xxfc.platform.order.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description 运营中心订单
* @data 2019/12/24 17:33
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CenterOrderProfileDisplayVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单金额
*/
private BigDecimal areaAmount = BigDecimal.ZERO;
/**
* 区域名称
*/
private String areaName;
/**
* 区域id
*/
private Integer areaId;
}
package com.xxfc.platform.order.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Objects;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 9:21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LargeScreenDisplayDataVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单相关数据
*/
private OrderProfileDispayVo orderProfileDispayData;
public OrderProfileDispayVo getOrderProfileDispayData() {
return Objects.isNull(orderProfileDispayData)?new OrderProfileDispayVo():orderProfileDispayData;
}
}
package com.xxfc.platform.order.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description 订单支付视图
* @data 2019/12/24 17:39
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderPayProfileDispalyVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 微信支付金额
*/
private BigDecimal wxPayAmount = BigDecimal.ZERO;
/**
* 支付宝支付金额
*/
private BigDecimal aliPayAmount = BigDecimal.ZERO;
/**
* app支付金额
*/
private BigDecimal androidPayAmount = BigDecimal.ZERO;
/**
* ios支付金额
*/
private BigDecimal iosPayAmount = BigDecimal.ZERO;
/**
* 微信占比
*/
private String wxPayRatio;
/**
* 支付宝占比
*/
private String aliPayRatio;
/**
* 安卓支付占比
*/
private String androidPayRatio;
/**
* ios支付占比
*/
private String iosPayRatio;
}
package com.xxfc.platform.order.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* @author libin
* @version 1.0
* @description 订单概况视图
* @data 2019/12/24 17:41
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderProfileDispayVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 累计订单金额
*/
private BigDecimal orderAmount = BigDecimal.ZERO;
/**
* 累计订单量
*/
private long orderNum;
/**
* 今日订单金额
*/
private BigDecimal todayOrderAmount = BigDecimal.ZERO;
/**
* 今日订单量
*/
private long todayOrderNum;
/**
* 十大运营中心的租车订单统计
*/
private List<CenterOrderProfileDisplayVo> centerOrderProfileDisplays;
/**
* 某个时间段的订单统计
*/
private List<OrderProfileVo> orderProfiles;
/**
* 订单支付方式|终端
*/
private OrderPayProfileDispalyVo orderPayProfileDisplay;
public List<CenterOrderProfileDisplayVo> getCenterOrderProfileDisplays() {
return CollectionUtils.isEmpty(centerOrderProfileDisplays) ? Collections.EMPTY_LIST : centerOrderProfileDisplays;
}
public OrderPayProfileDispalyVo getOrderPayProfileDisplay() {
return Objects.isNull(orderPayProfileDisplay) ? new OrderPayProfileDispalyVo() : orderPayProfileDisplay;
}
public List<OrderProfileVo> getOrderProfiles() {
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);
}
}
package com.xxfc.platform.order.pojo.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 9:32
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderProfileVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单日期
*/
@JsonIgnore
private Date orderDate;
/**
* 订单金额
*/
private BigDecimal orderAmount = BigDecimal.ZERO;
/**
* 显示日期
*/
private String date;
}
package com.xxfc.platform.order.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 10:17
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderReceivedStatisticsBaseVo {
/**
* 年月日
*/
private Date date;
/**
* 订单总额
*/
private BigDecimal totalAmount;
/**
*租车订单总额
*/
private BigDecimal rentVehicleAmount;
/**
* 订单总量(包含押金,不计免赔)
*/
private Integer totalQuantity;
/**
* 租车订单量
*/
private Integer rentVehicleQuantity;
/**
* 支付方式 '1:微信公众号支付 2.支付宝即时到账,3,银联'
*/
private Integer payWay;
/***
* 分公司id
*/
private Integer companyId;
/**
* 分公司名称
*/
private String companyName;
}
......@@ -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;
......@@ -32,6 +33,7 @@ import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
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.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
......@@ -926,6 +928,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return userFeign;
}
/**
* 订单查询类
*/
......@@ -980,5 +984,12 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return PageInfo.of(achievements);
}
public List<BaseOrderDTO> findOrdersByDate(Date startDate, Date 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>>(){});
}
}
package com.xxfc.platform.order.biz;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.util.CollectorsUtil;
import com.xxfc.platform.order.bo.LargeScreenDisplayConstantDataBo;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderProfileDisplay;
import com.xxfc.platform.order.mapper.OrderProfileDisplayMapper;
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.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;
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.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 17:06
*/
@Slf4j
@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;
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;
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);
CountDownLatch latch = new CountDownLatch(3);
//3. 十大运营中心订单数据
executor.execute(() -> {
try {
analyticStatisticsCenterOrder(baseOrders, orderProfileDispayVo);
} catch (Exception ex) {
log.error("十大运营中心订单统计失败【{}】", ex);
} finally {
latch.countDown();
}
});
//4.总的订单数据
executor.execute(() -> {
try {
analyticStatisticsOrderProfiles(baseOrders, orderProfileDisplays, orderProfileDispayVo);
} catch (Exception ex) {
log.error("总订单数据解析失败【{}】", ex);
} finally {
latch.countDown();
}
});
//5.支付方式|支付终端数据处理
LargeScreenDisplayConstantDataBo finalLargeScreenDisplayConstantDataBo = largeScreenDisplayConstantDataBo;
executor.execute(() -> {
try {
analyticStatisticsOrderPayWayProfiles(baseOrders, orderProfileDisplays, finalLargeScreenDisplayConstantDataBo,orderProfileDispayVo);
} catch (Exception ex) {
log.error("支付方式|支付终端数据处理失败【{}】", ex);
} finally {
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException e) {
log.error("统计出错:【{}】", e);
}
//1.基础金额 + 真实金额 基础订单量+真实订单量
long totalOrderNum = orderProfileDispayVo.getOrderNum() + largeScreenDisplayConstantDataBo.getBaseOrderNum();
BigDecimal totalOrderAmount = orderProfileDispayVo.getOrderAmount().add(largeScreenDisplayConstantDataBo.getBaseOrderAmount());
orderProfileDispayVo.setOrderAmount(totalOrderAmount);
orderProfileDispayVo.setOrderNum(totalOrderNum);
largeScreenDisplayDataVo.setOrderProfileDispayData(orderProfileDispayVo);
return largeScreenDisplayDataVo;
}
/**
* 支付方式|终端的统计
*
* @param orderProfileDispayVo
* @param largeScreenDisplayConstantDataBo
* @param baseOrders
* @return
*/
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(baseOrders, orderAmountConstant, largeScreenDisplayConstantDataBo, orderPayProfileDispalyVo);
//2.支付终端统计
wrapToPayProfileWithPayTerminal(baseOrders, orderAmountConstant, largeScreenDisplayConstantDataBo, orderPayProfileDispalyVo);
orderProfileDispayVo.setOrderPayProfileDisplay(orderPayProfileDispalyVo);
return orderProfileDispayVo;
}
/**
* 支付方式统计
*
* @param baseOrders
* @param orderAmountConstant
* @param orderPayProfileDispalyVo
* @return
*/
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 baseOrders
* @param orderPayProfileDispalyVo
* @return
*/
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;
}
/**
* 订单统计解析
*
* @param
* @param orderProfileDispayVo
* @return
*/
private OrderProfileDispayVo analyticStatisticsOrderProfiles(List<BaseOrderDTO> baseOrders,
List<OrderProfileDisplay> orderProfileDisplays,
OrderProfileDispayVo orderProfileDispayVo) {
//包装数据
List<BaseOrderDTO> baseOrderDTOS = wrapToBaseOrder(orderProfileDisplays);
baseOrderDTOS.addAll(baseOrders);
//1.真实数据按时间分组
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(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);
orderProfileDispayVo.setTodayOrderAmount(todayOrderAmount);
orderProfileDispayVo.setOrderProfiles(orderProfileVos);
return orderProfileDispayVo;
}
/**
* 包装基础数据 订单金额 与订单量
*
* @param orderProfileDispayVo
* @return
*/
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);
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());
orderProfileVo.setDate(DateUtil.format(orderProfileVo.getOrderDate(),"MM.dd"));
orderProfileVos.add(orderProfileVo);
}
orderProfileVos.sort(Comparator.comparing(OrderProfileVo::getOrderDate));
return orderProfileVos;
}
/**
* 运营中心订单统计
*
* @param orderProfileDispayVo
* @return
*/
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, 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);
return orderProfileDispayVo;
}
/**
* 区域统计处理
*
* @param areaAmountMap
* @return
*/
private List<CenterOrderProfileDisplayVo> createCenterOrderProfileDisplay(Map<Integer, BigDecimal> areaAmountMap) {
List<CenterOrderProfileDisplayVo> centerOrderProfileDisplayVos = new ArrayList<>();
//查询全部区域
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);
areaAmount = areaAmount.add(centerOrderProfileDisplay.getAreaAmount());
centerOrderProfileDisplay.setAreaAmount(areaAmount);
centerOrderProfileDisplayVos.add(centerOrderProfileDisplay);
}
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.setRealAmount(x.getOrderAmount());
baseOrderDTO.setPayDate(x.getOrderDate());
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;
}
}
......@@ -3,6 +3,8 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
......@@ -12,6 +14,7 @@ import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderReceivedStatisticsMapper;
import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsBaseVo;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -530,4 +533,12 @@ public class OrderReceivedStatisticsBiz extends BaseBiz<OrderReceivedStatisticsM
}
public List<OrderReceivedStatisticsBaseVo> findOrderReceivedStatisticsByDate(Date startDate, Date endDate) {
List<OrderReceivedStatistics> orderReceivedStatisticsList = mapper.findOrderReceivedStatisticsByDate(startDate,endDate);
if (CollectionUtils.isEmpty(orderReceivedStatisticsList)){
return Collections.emptyList();
}
return JSON.parseObject(JSON.toJSONString(orderReceivedStatisticsList),new TypeReference<List<OrderReceivedStatisticsBaseVo>>(){});
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.Achievement;
import com.xxfc.platform.order.pojo.QueryCriteria;
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.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
......@@ -51,4 +52,8 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
List<OrderDTO> selectBaeOrderByOrderIds(@Param("orderIds") List<Integer> orderIds);
List<Achievement> selectTotalStatistical(QueryCriteria queryCriteria);
List<BaseOrderDTO> findOrdersByDate(@Param("startDate") Date startDate,
@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> {
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderProfileDisplay;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 17:05
*/
public interface OrderProfileDisplayMapper extends Mapper<OrderProfileDisplay> {
List<OrderProfileDisplay> findOrderProfileDisplayDatabyDate(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
}
......@@ -4,9 +4,11 @@ import com.xxfc.platform.order.bo.CompanyPerformanceBo;
import com.xxfc.platform.order.entity.OrderReceivedStatistics;
import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/**
......@@ -31,4 +33,7 @@ public interface OrderReceivedStatisticsMapper extends Mapper<OrderReceivedStati
int selectCountByDate(CompanyPerformanceFindDTO companyPerformanceFindDTO);
int selectCountByMonth(CompanyPerformanceFindDTO companyPerformanceFindDTO);
int selectCountByWeekOfYear(CompanyPerformanceFindDTO companyPerformanceFindDTO);
List<OrderReceivedStatistics> findOrderReceivedStatisticsByDate(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
}
package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.order.biz.OrderProfileDisplayBiz;
import com.xxfc.platform.order.pojo.vo.LargeScreenDisplayDataVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 16:29
*/
@RestController
@RequestMapping("/large_screen/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LargeScreenDisplayController {
private final OrderProfileDisplayBiz orderProfileDisplayBiz;
/**
* 基础数据 与 订单概况
*
* @param startDate
* @param endDate
* @return
*/
@GetMapping("/order_profile_display")
public ObjectRestResponse<LargeScreenDisplayDataVo> findLargeScreenDisplayData(@RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate) {
LargeScreenDisplayDataVo largeScreenDisplayDataVo = orderProfileDisplayBiz.findLargeScreenDisplayDataByDate(startDate, endDate);
return ObjectRestResponse.succ(largeScreenDisplayDataVo);
}
}
......@@ -3,6 +3,28 @@
<mapper namespace="com.xxfc.platform.order.mapper.BaseOrderMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.BaseOrder" id="baseOrderMap">
<result property="id" column="id"/>
<result property="no" column="no"/>
<result property="type" column="type"/>
<result property="detailId" column="detail_id"/>
<result property="status" column="status"/>
<result property="productAmount" column="product_amount"/>
<result property="orderAmount" column="order_amount"/>
<result property="detailJson" column="detail_json"/>
<result property="thirdType" column="third_type"/>
<result property="outTradeNo" column="out_trade_no"/>
<result property="crtTime" column="crt_time"/>
<result property="crtUser" column="crt_user"/>
<result property="crtName" column="crt_name"/>
<result property="crtHost" column="crt_host"/>
<result property="updTime" column="upd_time"/>
<result property="updUser" column="upd_user"/>
<result property="updName" column="upd_name"/>
<result property="updHost" column="upd_host"/>
</resultMap>
<resultMap type="com.xxfc.platform.order.pojo.order.OrderPageVO" id="orderPageMap">
<result javaType="Integer" column="type" property="type"></result>
<discriminator javaType="Integer" column="type">
......@@ -68,9 +90,6 @@
<if test="type != null">
and type = #{type}
</if>
<if test="invoiceStatus != null">
and invoice_status = #{invoiceStatus}
</if>
<if test="hasMemberRight != null">
and has_member_right = #{hasMemberRight}
</if>
......@@ -132,9 +151,6 @@
<if test="no != null and no != '' ">
and no like CONCAT ("%", #{no}, "%")
</if>
<if test="oneNo != null and oneNo != '' ">
and no =#{oneNo}
</if>
<if test="name != null">
and b.name like CONCAT ("%", #{name}, "%")
</if>
......@@ -276,7 +292,6 @@
order by crtTime desc
</select>
<select id="getTourList" parameterType="Map" resultMap="orderPageMap">
select b.*
from base_order b
......@@ -308,7 +323,7 @@
(
(
orv.start_time &gt; #{startTime}
AND orv.start_time &lt; #{endTime}
AND orv.start_time &lt; #{startTime}
AND orv.end_time &gt; #{endTime}
)
OR (
......@@ -317,7 +332,7 @@
)
OR (
orv.start_time &lt; #{startTime}
AND orv.end_time &gt; #{startTime}
AND orv.end_time &gt; #{endTime}
AND orv.end_time &lt; #{endTime}
)
OR (
......@@ -420,20 +435,24 @@
</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"
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
......@@ -447,6 +466,7 @@
</foreach>
</select>
<select id="selectTotalStatistical" parameterType="com.xxfc.platform.order.pojo.QueryCriteria"
resultType="com.xxfc.platform.order.pojo.Achievement">
select
......@@ -478,4 +498,21 @@
order by crt_time DESC
</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
<?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.OrderProfileDisplayMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.OrderProfileDisplay" id="orderProfileDisplayMap">
<result property="id" column="id"/>
<result property="orderAmount" column="order_amount"/>
<result property="orderDate" column="order_date"/>
</resultMap>
<select id="findOrderProfileDisplayDatabyDate" resultMap="orderProfileDisplayMap">
select * from `order_profile_display` where `order_date` between #{startDate} and #{endDate}
</select>
</mapper>
\ No newline at end of file
......@@ -15,9 +15,9 @@
<result property="depositAmount" column="deposit_amount"/>
<result property="depositRefundAmount" column="deposit_refund_amount"/>
<result property="extraAmount" column="extra_amount"/>
<result property="lateFeeAmount" column="late_fee_amount" />
<result property="lossSpecifiedAmount" column="loss_specified_amount" />
<result property="memberAmount" column="member_amount" />
<result property="lateFeeAmount" column="late_fee_amount"/>
<result property="lossSpecifiedAmount" column="loss_specified_amount"/>
<result property="memberAmount" column="member_amount"/>
<result property="travelAmount" column="travel_amount"/>
<result property="rentVehicleAmount" column="rent_vehicle_amount"/>
<result property="noDeductibleAmount" column="no_deductible_amount"/>
......@@ -31,8 +31,10 @@
<result property="crtTime" column="crt_time"/>
</resultMap>
<select id="selectOrderReceivedStatisticsDateList" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`date`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<select id="selectOrderReceivedStatisticsDateList"
resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`date`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as
`totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -60,8 +62,10 @@
order by null
</select>
<select id="selectOrderReceivedStatisticsMonthList" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`month`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<select id="selectOrderReceivedStatisticsMonthList"
resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`month`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as
`totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -89,8 +93,10 @@
order by null
</select>
<select id="selectOrderReceivedStatisticsWeekOfYearList" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`week_of_year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<select id="selectOrderReceivedStatisticsWeekOfYearList"
resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`week_of_year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as
`totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -467,4 +473,26 @@
`week_of_year`
) as `ds`
</select>
<select id="findOrderReceivedStatisticsByDate" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
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`=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>
</mapper>
\ No newline at end of file
......@@ -12,6 +12,7 @@ import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
......@@ -178,7 +179,7 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
String [] userIdList=userIds.split(",");
audience=Audience.alias(userIdList);
}else {
if (debug){
if (!debug){
String [] userIdList=userIds.split(",");
audience=Audience.alias(userIdList);
}
......@@ -187,7 +188,7 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
if (StringUtils.isNotBlank(messagePush.getIntent())){
intent= getJsonObject(messagePush.getIntent());
}
Map<String, String> extras = new HashMap<String, String>();
Map<String, String> extras = new HashMap<>();
extras.put("onclickType",messagePush.getJumpType()+"");
if (StringUtils.isNotBlank(orderNo)){
extras.put("orderNo",orderNo);
......@@ -206,13 +207,20 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
.setIntent(intent)
.addExtras(extras)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.setAlert(messagePush.getAlert())
.setBadge(1)
.setSound("default")
.setMutableContent(true)
.addExtras(setExtras(extras,messagePush))
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(audience)
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setApnsProduction(debug)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
......@@ -225,6 +233,21 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
}
public Map<String, String> setExtras(Map<String, String> extras,MessagePush messagePush){
Integer style=messagePush.getStyle();
switch (style){
case 1:
extras.put("push_title",messagePush.getTitle());
case 2:
extras.put("push_title",messagePush.getTitle());
case 3:
extras.put("push_title",messagePush.getTitle());
extras.put("big_pic_path",messagePush.getBigPicPath());
}
return extras;
}
//编辑推送内容
public ObjectRestResponse updMessagePush(MessagePush messagePush){
Integer id= messagePush.getId();
......
package com.xxfc.platform.vehicle.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* @author libin
* @version 1.0
* @description 车型概况
* @data 2019/12/24 16:32
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "vehicle_profile_display")
public class VehicleProfileDisplay {
@Id
@GeneratedValue(generator = "JDBC")
@JsonIgnore
private Integer id;
/**
* 省份code
*/
@Column(name = "province_code")
private Integer provinceCode;
/**
* 省份名
*/
@Column(name = "province_name")
private String provinceName;
/**
* 车辆数量
*/
@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;
......@@ -138,7 +139,7 @@ public interface VehicleFeign {
public RestResponse<List<AccompanyingItemVo>> listAccompanyingItem();
@GetMapping("/branchCompany/findByAreaId")
List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId",required = false) Integer areaId);
List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId);
@GetMapping("/branchCompany/company")
Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(@RequestParam(value = "companyIds") List<Integer> companyIds);
......@@ -211,6 +212,9 @@ public interface VehicleFeign {
@GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap();
/* @RequestMapping(value ="/branchCompany/{id}",method = RequestMethod.GET)
RestResponse<BranchCompany> get(@PathVariable Integer id);*/
@GetMapping("/area/areas")
List<Area> findAllAreas();
@GetMapping("/branchCompany/compnays_area")
public List<BranchCompanyAreaDTO> findBranchCompnayAreaByIds(@RequestParam("companyIds") List<Integer> compnayIds);
}
......@@ -92,27 +92,44 @@ public class ResultVehicleVo {
*/
private String vin;
/**
* 险公司,见常量表
* 商业险公司,见常量表
*/
private Integer insuranceCompany;
/**
* 险单号
* 商业险单号
*/
private String insuranceNo;
/**
* 险开始时间
* 商业险开始时间
*/
private Date insuranceStartDate;
/**
* 险结束时间
* 商业险结束时间
*/
private Date insuranceEndDate;
/**
* 交强险公司
*/
private Integer strongInsuranceCompany;
/**
* 交强险单号
*/
private String strongInsuranceNo;
/**
* 交强险时间
*/
private Date strongInsuranceEndDate;
/**
* 年审时间
*/
......
......@@ -5,6 +5,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -64,6 +65,53 @@ public class VehicleExcelVo {
*/
private String belongToName;
/**
* 车架号
*/
private String vin;
/**
* 发动机号
*/
private String engineNum;
/**
* 商业险公司,见常量表
*/
private String insuranceCompany;
/**
* 商业险单号
*/
private String insuranceNo;
/**
* 商业险结束时间
*/
private Date insuranceEndDate;
/**
* 交强险公司
*/
private String strongInsuranceCompany;
/**
* 交强险单号
*/
private String strongInsuranceNo;
/**
* 交强险时间
*/
private Date strongInsuranceEndDate;
public String getStatus() {
return map.get(status);
......
package com.xxfc.platform.vehicle.pojo.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 9:45
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LargeScreenDisplayCCTConstantDataBo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 公司数量
*/
private int companyNum;
/**
* 营地数量
*/
private int campsiteNum;
/**
* 旅游路线数量
*/
private int tourNum;
}
package com.xxfc.platform.vehicle.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 11:09
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BranchCompanyAreaDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer companyId;
private String companyName;
private Integer areaId;
}
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.pojo.bo.LargeScreenDisplayCCTConstantDataBo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Objects;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 8:44
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LargeScreenDisplayBaseDataVo implements Serializable {
private static final long serialVersionUID = 1L;
private LargeScreenDisplayCCTConstantDataBo largeScreenDisplayCCTConstantDataBo;
private VehicleProfileDisplayVo vehicleProfileDisplayVo;
public LargeScreenDisplayCCTConstantDataBo getLargeScreenDisplayCCTConstantDataBo() {
return Objects.isNull(largeScreenDisplayCCTConstantDataBo)?new LargeScreenDisplayCCTConstantDataBo():largeScreenDisplayCCTConstantDataBo;
}
public VehicleProfileDisplayVo getVehicleProfileDisplayVo() {
return Objects.isNull(vehicleProfileDisplayVo)?new VehicleProfileDisplayVo():vehicleProfileDisplayVo;
}
}
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.VehicleProfileDisplay;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 9:50
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class VehicleProfileDisplayVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 每个省份车辆概况数据
*/
private List<VehicleProfileDisplay> vehicleProfileDisplays;
public List<VehicleProfileDisplay> getVehicleProfileDisplays() {
return CollectionUtils.isEmpty(vehicleProfileDisplays) ? Collections.EMPTY_LIST : vehicleProfileDisplays;
}
}
......@@ -8,10 +8,12 @@ import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.Area;
import com.xxfc.platform.vehicle.mapper.AreaMapper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
......@@ -24,25 +26,27 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {return userFeign;}
public UserFeign getUserFeign() {
return userFeign;
}
public RestResponse<List<Area>> findAll() {
UserDTO userDTO = getAdminUserInfo();
if(userDTO == null) {
if (userDTO == null) {
return RestResponse.suc();
}
String ids = null;
if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
if(StringUtils.isNotBlank(userDTO.getDataZone())) {
if (DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
if (StringUtils.isNotBlank(userDTO.getDataZone())) {
ids = userDTO.getDataZone();
} else {
ids = userDTO.getZoneId() + "";
}
if(ids.contains(",")) {
if (ids.contains(",")) {
String[] array = ids.split(",");
List<Integer> list = Lists.newArrayList();
for(int i = 0; i < array.length; i++) {
if(StringUtils.isNotBlank(array[i])) {
for (int i = 0; i < array.length; i++) {
if (StringUtils.isNotBlank(array[i])) {
list.add(Integer.parseInt(array[i]));
}
}
......@@ -50,7 +54,7 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf
} else {
Area area = mapper.selectByPrimaryKey(ids);
if (Objects.isNull(area)){
if (Objects.isNull(area)) {
return null;
}
List<Area> areas = Lists.newArrayList();
......@@ -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,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;
......@@ -447,4 +448,9 @@ 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;
}
}
package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.admin.entity.Group;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.Constant;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.ResultVehicleVo;
......@@ -22,6 +24,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
......@@ -29,7 +32,8 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
@Autowired
private VehicleBiz vehicleBiz;
@Autowired
private ConstantBiz constantBiz;
@Autowired
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
......@@ -83,14 +87,15 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
public List<VehicleExcelVo> getList(String vehiclePageQueryVoJson, UserDTO userDTO) throws Exception {
List<Constant> constants = constantBiz.selectList(new Constant() {{
setType(3);
}});
Map<Integer, List<Constant>> map = constants.parallelStream().collect(Collectors.groupingBy(Constant::getCode));
List<ResultVehicleVo> resultVehicleVoList = getResultVehicleVoList(vehiclePageQueryVoJson, userDTO);
ArrayList<VehicleExcelVo> arrayList = Lists.newArrayList();
resultVehicleVoList.stream().forEach(result->{
try {
Integer belongTo = result.getBelongTo();
if (belongTo!=null&& belongTo==1) {
System.out.println(belongTo);
}
VehicleExcelVo build = VehicleExcelVo.builder()
.code(result.getCode())
.numberPlate(result.getNumberPlate())
......@@ -99,6 +104,14 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
.useTypeName(result.getUseTypeName())
.vehicleType(result.getVehicleType())
.belongToName(result.getBelongTo()!=null&&result.getBelongTo()==1?"欣新房车有限公司":result.getBelongToName())
.vin(result.getVin())
.engineNum(result.getEngineNum())
.insuranceCompany(result.getInsuranceCompany()!=null?map.get(result.getInsuranceCompany()).get(0).getVal():null)
.insuranceNo(result.getInsuranceNo())
.insuranceEndDate(result.getInsuranceEndDate())
.strongInsuranceCompany(result.getStrongInsuranceCompany()!=null?map.get(result.getStrongInsuranceCompany()).get(0).getVal():null)
.strongInsuranceNo(result.getInsuranceNo())
.strongInsuranceEndDate(result.getStrongInsuranceEndDate())
.build();
arrayList.add(build);
} catch (Exception e) {
......
package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.entity.VehicleProfileDisplay;
import com.xxfc.platform.vehicle.mapper.VehicleProfileDisplayMapper;
import com.xxfc.platform.vehicle.pojo.bo.LargeScreenDisplayCCTConstantDataBo;
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.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.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 17:06
*/
@Slf4j
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VehicleProfileDisplayBiz extends BaseBiz<VehicleProfileDisplayMapper, VehicleProfileDisplay> {
/**
* 字典查询type
*/
@Value("${large.screen.type:LARGE_SCREEN_DISPLAY}")
private String largeScreenType;
/**
* 字典查询code
*/
@Value("${large.screen.cct.code:LARGE_SCREEN_DISPLAY_CCT_CONSTANT}")
private String largeScreenCode;
private final ThirdFeign thirdFeign;
public LargeScreenDisplayBaseDataVo findVehicleProfileDisplayData() {
LargeScreenDisplayBaseDataVo largeScreenDisplayBaseDataVo = new LargeScreenDisplayBaseDataVo();
VehicleProfileDisplayVo vehicleProfileDisplayVo = new VehicleProfileDisplayVo();
//1.查询全部固定数据
List<VehicleProfileDisplay> vehicleProfileDisplays = mapper.selectAll();
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(largeScreenType, largeScreenCode);
if (dictionary != null && StringUtils.hasText(dictionary.getDetail())) {
LargeScreenDisplayCCTConstantDataBo largeScreenDisplayConstantDataBo = JSON.parseObject(dictionary.getDetail(), LargeScreenDisplayCCTConstantDataBo.class);
largeScreenDisplayBaseDataVo.setLargeScreenDisplayCCTConstantDataBo(largeScreenDisplayConstantDataBo);
}
vehicleProfileDisplayVo.setVehicleProfileDisplays(vehicleProfileDisplays);
largeScreenDisplayBaseDataVo.setVehicleProfileDisplayVo(vehicleProfileDisplayVo);
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;
......@@ -22,4 +23,7 @@ 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")
List<JSONObject> getList();
List<BranchCompanyAreaDTO> findBranchCompanyAreaByIds(@Param("companyIds") List<Integer> compnayIds);
}
\ No newline at end of file
package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.VehicleProfileDisplay;
import tk.mybatis.mapper.common.Mapper;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/24 17:05
*/
public interface VehicleProfileDisplayMapper extends Mapper<VehicleProfileDisplay> {
}
......@@ -30,4 +30,9 @@ public class AreaController extends BaseController<AreaBiz, Area> {
}
@GetMapping("/areas")
public List<Area> findAllAreas(){
return baseBiz.findAllAreas();
}
}
......@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.AreaBiz;
import com.xxfc.platform.vehicle.biz.BranchCompanyBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
......@@ -18,26 +19,22 @@ 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.github.wxiaoqi.security.common.vo.PageDataVO;
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;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/branchCompany")
......@@ -232,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);
}
}
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleProfileDisplayBiz;
import com.xxfc.platform.vehicle.pojo.vo.LargeScreenDisplayBaseDataVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/12/26 9:41
*/
@RestController
@RequestMapping("/large_screen/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LargeScreenDisplayCCTVehicleController {
private final VehicleProfileDisplayBiz vehicleProfileDisplayBiz;
/**
* 车辆概况
*
* @return
*/
@GetMapping("/base_cct_vehicle_profile_display")
public ObjectRestResponse<LargeScreenDisplayBaseDataVo> findLargeScreenDisplayData() {
LargeScreenDisplayBaseDataVo largeScreenDisplayBaseDataVo = vehicleProfileDisplayBiz.findVehicleProfileDisplayData();
return ObjectRestResponse.succ(largeScreenDisplayBaseDataVo);
}
}
......@@ -60,6 +60,15 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
writer.addHeaderAlias("parkBranchCompanyName", "停靠分公司");
writer.addHeaderAlias("useTypeName", "用途");
writer.addHeaderAlias("belongToName", "托管人");
writer.addHeaderAlias("vin", "车架号");
writer.addHeaderAlias("engineNum", "发动机号");
writer.addHeaderAlias("insuranceCompany", "商业险公司");
writer.addHeaderAlias("insuranceNo", "商业险单号");
writer.addHeaderAlias("insuranceEndDate", "商业险结束时间");
writer.addHeaderAlias("strongInsuranceCompany", "交强险公司");
writer.addHeaderAlias("strongInsuranceNo", "交强险单号");
writer.addHeaderAlias("strongInsuranceEndDate", "交强险时间");
// 一次性写出内容,使用默认样式,强制输出标题
......
......@@ -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
......@@ -191,8 +191,6 @@
ELSE v.status END) status ,
v.number_plate,
v.brand,
-- IFNULL(v.park_branch_company_id,v.expect_destination_branch_company_id) AS subordinate_branch,
-- IFNULL(bc.name,bc1.name) AS subBranchName,
v.park_branch_company_id,
bc.name as parkBranchCompanyName,
v.expect_destination_branch_company_id,
......@@ -207,6 +205,9 @@
v.insurance_no,
v.insurance_start_date,
v.insurance_end_date,
v.strong_insurance_company,
v.strong_insurance_no,
v.strong_insurance_end_date,
v.annual_verification_date,
v.maintenance_date,
v.maintenance_mileage,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.vehicle.mapper.VehicleProfileDisplayMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.vehicle.entity.VehicleProfileDisplay" id="vehicleProfileDisplayMap">
<result property="id" column="id"/>
<result property="provinceName" column="province_name"/>
<result property="provinceCode" column="province_code"/>
<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