Commit ce03b87a authored by jiaorz's avatar jiaorz

Merge branch 'master-vehicle-bg' into dev

parents 0ba2555c 626738d6
......@@ -674,12 +674,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay>{
orderPayVo.setAmount(3);
orderPayVo.setBody("扣除租车订单费用");
orderPayVo.setSubject("租车订单交易费用");
orderPayBiz.testTradeRefund("216584713656209408", 105000, "退还违约金1050元", "2165847136562094081050");
//orderPayBiz.testTradeRefund("216584713656209408", 105000, "退还违约金1050元", "2165847136562094081050");
//orderPayBiz.fundAuthOrderUnFreeze(orderPayVo, "");
//orderPayBiz.alipayOrderRefund("20191024153859000003","2019102422001421530513773694", 2, "xxxx", "");
//orderPayBiz.tradePay(orderPayVo, "");
//orderPayBiz.fundAuthCancel(orderPayVo, "");
//orderPayBiz.tradePay("20191114182254000019", "2019111410002001530505959461", 1,"扣除违约金", "扣除违约金");
orderPayBiz.fundAuthQuery("20191115092455000004");
orderPayBiz.fundAuthQuery("20191031172653000026");
}
}
package com.xxfc.platform.vehicle.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 分公司停靠车辆统计
*/
@Table(name = "branch_company_vehicle_count")
@Data
public class BranchCompanyVehicleCount {
@Id
private Long id;
/**
* 公司名称
*/
@Column(name = "company_name")
private String companyName;
/**
* 当前停靠车辆数量
*/
@Column(name = "vehicle_num")
private Integer vehicleNum;
/**
* 统计日期
*/
@Column(name = "count_date")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd"
)
private Date countDate;
}
\ No newline at end of file
......@@ -3,7 +3,8 @@ package com.xxfc.platform.vehicle.pojo;
import lombok.Data;
@Data
public class BranchCompanyVehicleCount {
public class BranchCompanyVehicleCountVo {
private String parkBranchCompanyName;
private Integer count;
private Integer companyId;
}
package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
@Data
public class BranchCompanyVehicleCountDTO extends PageParam {
//开始时间 yyyy-MM-dd
private String startTime;
//结束时间
private String endTime;
private String companyName;
//统计类型,日月年, 1、日,2、月,3、年
private Integer type;
//需要除去的天数
private Integer dayNum;
}
package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Calendar;
@Service
@Slf4j
public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCountMapper, BranchCompanyVehicleCount> {
@Autowired
VehicleInformationDownloadBiz vehicleInformationDownloadBiz;
public ObjectRestResponse add(BranchCompanyVehicleCount branchCompanyVehicleCount) {
if (branchCompanyVehicleCount == null) {
return ObjectRestResponse.paramIsEmpty();
}
BranchCompanyVehicleCount oldValue = selectOne(branchCompanyVehicleCount);
if (oldValue == null) {
insertSelectiveRe(branchCompanyVehicleCount);
}
return ObjectRestResponse.succ();
}
public ObjectRestResponse<PageDataVO<BranchCompanyVehicleCount>> findAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
vehicleInformationDownloadBiz.addAll();
Integer pageNo = branchCompanyVehicleCountDTO.getPage() == null ? 1 : branchCompanyVehicleCountDTO.getPage();
Integer pageSize = branchCompanyVehicleCountDTO.getLimit() == null ? 10 : branchCompanyVehicleCountDTO.getLimit();
Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType();
branchCompanyVehicleCountDTO.setPage(pageNo);
branchCompanyVehicleCountDTO.setLimit(pageSize);
branchCompanyVehicleCountDTO.setType(type);
if (type == 1) {
branchCompanyVehicleCountDTO.setDayNum(1);
} else if (type == 2) {
branchCompanyVehicleCountDTO.setDayNum(7);
} else if (type == 3) {
branchCompanyVehicleCountDTO.setDayNum(getCurrentMonthLastDay());
}
Query query = new Query(branchCompanyVehicleCountDTO);
PageDataVO<BranchCompanyVehicleCount> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getAllByParam(query.getSuper()));
return ObjectRestResponse.succ();
}
public int getCurrentMonthLastDay() {
Calendar a = Calendar.getInstance();
a.set(Calendar.DATE, 1);//把日期设置为当月第一天
a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天
int maxDate = a.get(Calendar.DATE);
return maxDate;
}
}
......@@ -1516,8 +1516,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList());
}
public List<BranchCompanyVehicleCount> getAllVehicleInfo() {
return mapper.getAllVehicleInfo();
public List<BranchCompanyVehicleCountVo> getAllVehicleInfo(Map<String, Object> param) {
return mapper.getAllVehicleInfo(param);
}
}
......@@ -4,23 +4,25 @@ import com.alibaba.fastjson.JSON;
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.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.ResultVehicleVo;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.VehiclePageQueryVo;
import com.xxfc.platform.vehicle.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
@Slf4j
......@@ -29,7 +31,11 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
@Autowired
private VehicleBiz vehicleBiz;
@Autowired
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public List getByPageNotAllData(VehiclePageQueryVo vehiclePageQueryVo, List<Integer> companyList) throws Exception {
......@@ -94,8 +100,41 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
}
public List<BranchCompanyVehicleCount> getAllVehicleInfo() {
return vehicleBiz.getAllVehicleInfo();
public void getAllVehicleInfo() {
Map<String, Object> map = new HashMap<>();
map.put("startTime", DateTime.now().withMillis(DateUtils.getStartOfDay()).toString(DEFAULT_DATE_TIME_FORMATTER));
map.put("endTime", DateTime.now().withMillis(DateUtils.getEndOfDay()).toString(DEFAULT_DATE_TIME_FORMATTER));
add(map);
}
public void addAll() {
DateTime dateTime = DateTime.parse("2019-10-01 00:00:00", DEFAULT_DATE_TIME_FORMATTER);
DateTime dateTime1 = DateTime.parse("2019-10-01 23:59:59", DEFAULT_DATE_TIME_FORMATTER);
for (int i = 0; i < 52; i++) {
Map<String, Object> map = new HashMap<>();
map.put("startTime", dateTime.plusDays(i).toString(DEFAULT_DATE_TIME_FORMATTER));
map.put("endTime", dateTime1.plusDays(i).toString(DEFAULT_DATE_TIME_FORMATTER));
add(map);
}
}
public void add(Map<String, Object> param) {
List<BranchCompanyVehicleCountVo> branchCompanyVehicleCountVos = vehicleBiz.getAllVehicleInfo(param);
branchCompanyVehicleCountVos.forEach(result->{
try {
if (result != null) {
BranchCompanyVehicleCount branchCompanyVehicleCount = new BranchCompanyVehicleCount();
branchCompanyVehicleCount.setCompanyName(result.getParkBranchCompanyName());
branchCompanyVehicleCount.setVehicleNum(result.getCount());
branchCompanyVehicleCount.setCountDate(DateTime.parse(param.get("startTime").toString().split(" ")[0]).toDate());
branchCompanyVehicleCountBiz.add(branchCompanyVehicleCount);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
}
}
package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
public interface BranchCompanyVehicleCountMapper extends Mapper<BranchCompanyVehicleCount> {
List<BranchCompanyVehicleCount> getAllByParam(Map<String, Object> param);
}
\ No newline at end of file
......@@ -54,5 +54,5 @@ public interface VehicleMapper extends Mapper<Vehicle> {
@Select("select `id` from `vehicle` where `is_del`=0")
List<String> findExistVehicleIds();
List<BranchCompanyVehicleCount> getAllVehicleInfo();
List<BranchCompanyVehicleCountVo> getAllVehicleInfo(Map<String, Object> params);
}
\ No newline at end of file
package com.xxfc.platform.vehicle.rest.admin;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value = "/bg-vehicle/count")
public class BranchCompanyVehicleCountController extends BaseController<BranchCompanyVehicleCountBiz> {
@GetMapping(value = "/getAll")
@ResponseBody
public ObjectRestResponse getAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
return baseBiz.findAll(branchCompanyVehicleCountDTO);
}
}
......@@ -7,11 +7,15 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -30,7 +34,7 @@ import java.util.List;
public class VehicleInformationDownloadController extends BaseController<VehicleInformationDownloadBiz> {
@Autowired
UserFeign userFeign;
private UserFeign userFeign;
@Autowired
private UserAuthConfig userAuthConfig;
......@@ -39,7 +43,10 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
private VehicleBiz vehicleBiz;
@Autowired
HttpServletResponse response;
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
@Autowired
private HttpServletResponse response;
@GetMapping("/excel")
public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson", required = false) String vehiclePageQueryVoJson) throws Exception {
......@@ -70,11 +77,17 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
}
@GetMapping("/app/unauth/export")
public void exportVehicleInfo() throws Exception {
List<BranchCompanyVehicleCount> rows = baseBiz.getAllVehicleInfo();
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception {
PageDataVO<BranchCompanyVehicleCount> pageDataVO = branchCompanyVehicleCountBiz.findAll(branchCompanyVehicleCountDTO).getData();
if (pageDataVO == null || pageDataVO.getData() == null) {
throw new BaseException(ResultCode.getMsg(ResultCode.NOTEXIST_CODE), ResultCode.NOTEXIST_CODE);
}
List<BranchCompanyVehicleCount> rows = pageDataVO.getData();
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("parkBranchCompanyName", "停靠分公司");
writer.addHeaderAlias("count", "车辆数量");
writer.addHeaderAlias("id", "ID");
writer.addHeaderAlias("countDate", "日期");
writer.addHeaderAlias("companyName", "停靠分公司");
writer.addHeaderAlias("vehicleNum", "车辆数量");
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(rows, true);
//response为HttpServletResponse对象
......@@ -89,4 +102,5 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
}
<?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.BranchCompanyVehicleCountMapper" >
<resultMap id="BaseResultMap" type="com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="BIGINT" />
<result column="company_name" property="companyName" jdbcType="VARCHAR" />
<result column="vehicle_num" property="vehicleNum" jdbcType="INTEGER" />
<result column="count_date" property="countDate" jdbcType="TIMESTAMP" />
<result column="company_id" property="companyId" jdbcType="INTEGER" />
</resultMap>
<select id="getAllByParam" parameterType="Map" resultType="com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount">
SELECT company_name, CEILING((
CASE
WHEN #{type} = 1 THEN
sum(vehicle_num) / #{dayNum}
WHEN #{type} = 2 THEN
sum(vehicle_num) / #{dayNum}
WHEN #{type} = 3 THEN
sum(vehicle_num) / #{dayNum}
END
))
AS vehicleNum from branch_company_vehicle_count
<where>
<if test="companyName != null and companyName != ''">
and company_name like concat('%', #{companyName}, '%')
</if>
<if test="startTime != null and startTime != ''">
and count_date &gt; #{startTime} and count_date &lt; #{endTime}
</if>
</where>
GROUP BY company_name
</select>
</mapper>
\ No newline at end of file
......@@ -591,18 +591,16 @@
</select>
<!--导出分公司停靠所有车辆-->
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCount">
SELECT
b1. NAME AS parkBranchCompanyName,
count(v1.id) as count
FROM
branch_company b1
LEFT JOIN vehicle v1 ON v1.park_branch_company_id = b1.id
WHERE
b1.is_del = 0
AND v1.is_del = 0
GROUP BY b1.`name`
order by b1.`name`
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo" parameterType="Map">
select tmp.name as parkBranchCompanyName, COUNT(0) as count from (
select v1.number_plate, b.name from vehicle_book_record v
LEFT JOIN branch_company b on b.id = v.lift_company
LEFT JOIN vehicle v1 on v1.id = v.vehicle_id
where v.`status` != 4 and v.`status` != 6
and v.book_start_date &gt; #{startTime} and v.book_start_date &lt; #{endTime}
ORDER BY v.vehicle_id, v.book_start_date DESC
) tmp
GROUP BY name
</select>
<select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment