新增订单导出
This commit is contained in:
parent
130a85e2c9
commit
1f9037cf85
@ -0,0 +1,59 @@
|
||||
package com.evotech.hd.common.core.Dto.order;
|
||||
|
||||
import com.evotech.hd.common.core.excel.Excel;
|
||||
import com.evotech.hd.common.core.excel.handler.impl.OrderSourceExcelHandlerAdapter;
|
||||
import com.evotech.hd.common.core.excel.handler.impl.OrderStatusExcelHandlerAdapter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* OrderExportVo
|
||||
*
|
||||
* @author andy.shi
|
||||
* @ClassName:OrderExportVo
|
||||
* @date: 2026年02月10日 10:13
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Data
|
||||
public class OrderExportVo {
|
||||
|
||||
@Excel(name="序号", needMerge=true)
|
||||
Integer serialNumber;
|
||||
@Excel(name="订单编号", needMerge=true)
|
||||
String orderNo;
|
||||
@Excel(name="站点名称", needMerge=true)
|
||||
String stationName;
|
||||
@Excel(name="订单来源", needMerge=true, handler = OrderSourceExcelHandlerAdapter.class)
|
||||
String orderSource;
|
||||
@Excel(name="换电结果", needMerge=true, handler = OrderStatusExcelHandlerAdapter.class)
|
||||
String orderType;
|
||||
@Excel(name="车牌号", needMerge=true)
|
||||
String plateNum;
|
||||
@Excel(name="拆卸电池编号", needMerge=true)
|
||||
String returnBatCode;
|
||||
@Excel(name="拆卸电池SOC", needMerge=true)
|
||||
String returnBatSoc;
|
||||
@Excel(name="安装电池编号", needMerge=true)
|
||||
String rentBatCode;
|
||||
@Excel(name="安装电池SOC", needMerge=true)
|
||||
String rentBatSoc;
|
||||
@Excel(name="车辆进站时间", dateFormat = "yyyy-MM-dd HH:mm:ss", needMerge=true)
|
||||
Date serviceTimeBegin;
|
||||
@Excel(name="服务结束时间", dateFormat = "yyyy-MM-dd HH:mm:ss", needMerge=true)
|
||||
Date serviceTimeEnd;
|
||||
@Excel(name="服务耗时", needMerge=true)
|
||||
String serviceDuration;
|
||||
@Excel(name="换电开始时间", dateFormat = "yyyy-MM-dd HH:mm:ss", needMerge=true)
|
||||
Date startTime;
|
||||
@Excel(name="换电结束时间", dateFormat = "yyyy-MM-dd HH:mm:ss", needMerge=true)
|
||||
Date closeTime;
|
||||
@Excel(name="换电耗时", needMerge=true)
|
||||
String batteryDuration;
|
||||
@Excel(name="流程是否完整", needMerge=true)
|
||||
String processComplete;
|
||||
@Excel(name="换电步骤")
|
||||
List<OrderStepExportVo> stepList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.evotech.hd.common.core.Dto.order;
|
||||
|
||||
import com.evotech.hd.common.core.excel.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* OrderDetailExportVo
|
||||
*
|
||||
* @author andy.shi
|
||||
* @ClassName:OrderDetailExportVo
|
||||
* @date: 2026年02月10日 14:18
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Data
|
||||
public class OrderStepExportVo {
|
||||
|
||||
Integer step;
|
||||
|
||||
@Excel(name="步骤")
|
||||
String name;
|
||||
@Excel(name="时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
Date stepTime;
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package com.evotech.hd.common.core.dao.cloud;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderExportVo;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
import com.evotech.hd.common.core.entity.order.Order;
|
||||
import com.evotech.hd.common.core.Dto.home.*;
|
||||
import com.evotech.hd.common.core.Dto.request.HomeRequestDto;
|
||||
@ -45,4 +47,7 @@ public interface OrderDao extends BaseMapper<Order> {
|
||||
List<HomeOrderInfo> findOrderListByStatus(@Param("status") Integer status);
|
||||
|
||||
List<Order> findBillList(@Param("companyCode") String companyCode, @Param("orderTimeEnd")String orderTimeEnd);
|
||||
|
||||
|
||||
List<OrderExportVo> findExportList(PageListSwapOrderRequest plsor);
|
||||
}
|
||||
|
||||
@ -18,13 +18,13 @@ public enum SwapBatteryStepEnum implements BaseEnum<Integer, String>{
|
||||
|
||||
INSTITUTIONS_FOR_CHINA(3, "对中机构"),
|
||||
|
||||
DISMANTLE_OLD_ELECTRICITY(4, "拆旧电"),
|
||||
GET_NEW_ELECTRICITY(4, "取新电"),
|
||||
|
||||
DISCHARGE_OLD_ELECTRICITY(5, "放旧电"),
|
||||
DISMANTLE_OLD_ELECTRICITY(5, "拆旧电"),
|
||||
|
||||
GET_NEW_ELECTRICITY(6, "取新电"),
|
||||
INSTALL_NEW_ELECTRICITY(6, "装新电"),
|
||||
|
||||
INSTALL_NEW_ELECTRICITY(7, "装新电"),
|
||||
DISCHARGE_OLD_ELECTRICITY(7, "放旧电"),
|
||||
|
||||
COMPLETED(8, "完成"),
|
||||
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.evotech.hd.common.core.excel.handler.impl;
|
||||
|
||||
import com.evotech.hd.common.core.excel.handler.ExcelHandlerAdapter;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
* OrderStatusExcelHandlerAdapter
|
||||
*
|
||||
* @author andy.shi
|
||||
* @ClassName:OrderStatusExcelHandlerAdapter
|
||||
* @date: 2026年02月11日 14:23
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
|
||||
public class OrderSourceExcelHandlerAdapter implements ExcelHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public Object format(Object value, String[] args, Cell cell, Workbook wb) {
|
||||
if(ObjectUtils.isNotEmpty(value)){
|
||||
switch (String.valueOf(value)){
|
||||
case "1":
|
||||
return "小程序";
|
||||
case "2":
|
||||
return "云端";
|
||||
case "3":
|
||||
return "站端";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.evotech.hd.common.core.excel.handler.impl;
|
||||
|
||||
import com.evotech.hd.common.core.enums.OrderStatusEnums;
|
||||
import com.evotech.hd.common.core.excel.handler.ExcelHandlerAdapter;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
* OrderStatusExcelHandlerAdapter
|
||||
*
|
||||
* @author andy.shi
|
||||
* @ClassName:OrderStatusExcelHandlerAdapter
|
||||
* @date: 2026年02月11日 14:23
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
|
||||
public class OrderStatusExcelHandlerAdapter implements ExcelHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public Object format(Object value, String[] args, Cell cell, Workbook wb) {
|
||||
if(ObjectUtils.isNotEmpty(value)){
|
||||
Integer val = Integer.valueOf(String.valueOf(value));
|
||||
for (OrderStatusEnums orderStatus : OrderStatusEnums.values()){
|
||||
if(orderStatus.getCode().equals(val)){
|
||||
return orderStatus.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.evotech.hd.common.dtos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 电池实时信息
|
||||
* @ClassName:BatData
|
||||
* @date: 2025年04月30日 9:13
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Data
|
||||
public class BatDataDto {
|
||||
//电池编号
|
||||
String batCode;
|
||||
//开始时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
Date beginTime;
|
||||
//结束时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
Date endTime;
|
||||
}
|
||||
@ -156,4 +156,13 @@ public class OrderSwapBatteryController {
|
||||
public Result<String> companyNativePay(@RequestBody NativePayVO prePay) {
|
||||
return orderService.companyNativePay(prePay);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "订单导出")
|
||||
@PostMapping("/export")
|
||||
@ApiOperationSupport(order = 6)
|
||||
public void export(@ParameterObject PageListSwapOrderRequest plsor) {
|
||||
orderService.export(plsor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ import com.evotech.hd.common.core.dao.cloud.OrderDao;
|
||||
import com.evotech.hd.common.core.dao.cloud.OrderDetailDao;
|
||||
import com.evotech.hd.common.core.dao.cloud.OrderSwapBatteryDao;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBattery;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
import com.evotech.hd.common.core.entity.order.Order;
|
||||
import com.evotech.hd.common.core.entity.order.OrderDetail;
|
||||
import com.evotech.hd.common.core.utils.Collections;
|
||||
@ -74,6 +75,14 @@ public class TestController {
|
||||
@Autowired
|
||||
private OrderDetailDao orderDetailDao;
|
||||
|
||||
@PostMapping("/order/export")
|
||||
public Result orderExport() {
|
||||
PageListSwapOrderRequest params = new PageListSwapOrderRequest();
|
||||
params.setStationCode("LN-DL-005");
|
||||
orderService.export(params);
|
||||
return new Result().success("搞定");
|
||||
}
|
||||
|
||||
@PostMapping("/mongodb/save")
|
||||
public Result mongodbSave() {
|
||||
mqttStateChargingDataRequestExchangeProcessor.exchange(null,null,JSONUtil.parseObj("{batCode:123,orderNo:123321}"));
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
package com.evotech.hd.cloud.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderStepExportVo;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zrb
|
||||
@ -9,4 +14,6 @@ import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
*/
|
||||
public interface OrderSwapBatteryStepDao extends BaseMapper<OrderSwapBatteryStep> {
|
||||
|
||||
@Select(" select step_name as name, step, step_time as stepTime from hd_cloud_manage.yt_t_order_swap_battery_step where order_no=#{orderNo} order by step asc ")
|
||||
public List<OrderStepExportVo> findListByOrderNo(@Param("orderNo") String orderNo);
|
||||
}
|
||||
|
||||
@ -35,6 +35,11 @@ public interface OrderService extends IService<Order> {
|
||||
* @return
|
||||
*/
|
||||
Result<Page<OrderListVo>> pageList(PageListSwapOrderRequest plsor);
|
||||
/***
|
||||
* 订单数据导出
|
||||
* @param plsor
|
||||
*/
|
||||
void export(PageListSwapOrderRequest plsor);
|
||||
/***
|
||||
* 订单结算
|
||||
* @param osb
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package com.evotech.hd.cloud.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderStepExportVo;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 换电步骤
|
||||
@ -16,4 +18,6 @@ import java.util.Date;
|
||||
public interface OrderSwapBatteryStepService extends IService<OrderSwapBatteryStep> {
|
||||
|
||||
public Boolean addOrderSwapBatteryStepBySwapComplete(String orderNo, Integer step, Date stepTime);
|
||||
|
||||
List<OrderStepExportVo> findListByOrderNo(String orderNo);
|
||||
}
|
||||
|
||||
@ -33,9 +33,7 @@ import com.evotech.hd.cloud.utils.ExcelUtil;
|
||||
import com.evotech.hd.cloud.utils.ParamServiceUtils;
|
||||
import com.evotech.hd.cloud.utils.components.SwapOrderBasicFeeComponent;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderBillListVo;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderDetailVo;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderListVo;
|
||||
import com.evotech.hd.common.core.Dto.order.*;
|
||||
import com.evotech.hd.common.core.constant.HDConstant;
|
||||
import com.evotech.hd.common.core.dao.cloud.OrderDao;
|
||||
import com.evotech.hd.common.core.dao.cloud.OrderDetailDao;
|
||||
@ -610,6 +608,43 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void export(PageListSwapOrderRequest plsor) {
|
||||
|
||||
List<OrderExportVo> resultList = getBaseMapper().findExportList(plsor);
|
||||
Integer i = 1;
|
||||
for (OrderExportVo orderExport : resultList){
|
||||
orderExport.setSerialNumber(i++);
|
||||
//计算时间差额
|
||||
orderExport.setServiceDuration(betweenTime(orderExport.getServiceTimeBegin(), orderExport.getServiceTimeEnd()));
|
||||
orderExport.setStepList(orderSwapBatteryStepService.findListByOrderNo(orderExport.getOrderNo()));
|
||||
//检查是否流程完整
|
||||
orderExport.setProcessComplete((Collections.isNotEmpty(orderExport.getStepList()) && orderExport.getStepList().size() ==8) ? "是" : "否");
|
||||
if(Collections.isNotEmpty(orderExport.getStepList())){
|
||||
OrderStepExportVo start = orderExport.getStepList().stream().filter(data -> SwapBatteryStepEnum.INSTITUTIONS_FOR_CHINA.getCode().equals(data.getStep())).findFirst().orElse(null);
|
||||
OrderStepExportVo end = orderExport.getStepList().stream().filter(data -> SwapBatteryStepEnum.COMPLETED.getCode().equals(data.getStep())).findFirst().orElse(null);
|
||||
if(start != null && start.getStepTime() != null && end != null && end.getStepTime() != null){
|
||||
orderExport.setStartTime(start.getStepTime());
|
||||
orderExport.setCloseTime(end.getStepTime());
|
||||
orderExport.setBatteryDuration(betweenTime(start.getStepTime(), end.getStepTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
ExcelUtil<OrderExportVo> util = new ExcelUtil<OrderExportVo>(OrderExportVo.class);
|
||||
util.exportExcel(SpringUtil.getResponse(), resultList,"换电订单导出");
|
||||
}
|
||||
|
||||
static Long dividend = (long) (60*1000);
|
||||
public static String betweenTime(Date start, Date end){
|
||||
if(start == null || end == null){
|
||||
return "";
|
||||
}
|
||||
Long between = end.getTime()-start.getTime();
|
||||
long minute = between/dividend;
|
||||
long second = between%dividend;
|
||||
return minute+"分"+(second/1000)+"秒";
|
||||
}
|
||||
|
||||
public void settlementInProgress(List<Order> list, String outTradeNo, Integer payType){
|
||||
//执行完导出后. 所有的订单信息,全部更新为结算中
|
||||
AuthUser user = RedisPermissionUtils.getUser();
|
||||
|
||||
@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.evotech.hd.cloud.dao.OrderSwapBatteryStepDao;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryStepService;
|
||||
import com.evotech.hd.cloud.utils.components.HDStepDictComponent;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderStepExportVo;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类
|
||||
@ -45,4 +47,9 @@ public class OrderSwapBatteryStepServiceImpl extends ServiceImpl<OrderSwapBatter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStepExportVo> findListByOrderNo(String orderNo) {
|
||||
return getBaseMapper().findListByOrderNo(orderNo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,6 +168,47 @@
|
||||
|
||||
|
||||
|
||||
<select id="findExportList" parameterType="com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest" resultType="com.evotech.hd.common.core.Dto.order.OrderExportVo">
|
||||
select osbp.source as orderSource, o.order_no, o.station_name, o.status as orderType, o.plate_num,
|
||||
od.return_bat_code,
|
||||
od.return_bat_soc,
|
||||
od.rent_bat_code,
|
||||
od.rent_bat_soc,
|
||||
od.service_time_begin,
|
||||
od.service_time_end
|
||||
from hd_cloud_manage.yt_t_order o
|
||||
left join hd_cloud_manage.yt_t_order_detail od on od.order_id = o.pk_id
|
||||
left join hd_cloud_manage.yt_t_order_swap_battery_pre osbp on osbp.pk_id = o.order_pre_id
|
||||
where o.del_flag != 1
|
||||
<if test="orderNo!= null and orderNo!= ''">
|
||||
and o.order_no=#{orderNo}
|
||||
</if>
|
||||
<if test="plateNum!= null and plateNum!= ''">
|
||||
and o.plate_num=#{plateNum}
|
||||
</if>
|
||||
<if test="orderTimeBegin!= null ">
|
||||
and o.order_time <![CDATA[ >= ]]> #{orderTimeBegin}
|
||||
</if>
|
||||
<if test="orderTimeEnd!= null">
|
||||
and o.order_time <![CDATA[ <= ]]> #{orderTimeEnd}
|
||||
</if>
|
||||
<if test="stationCode!= null and stationCode!= ''">
|
||||
and o.station_code = #{stationCode}
|
||||
</if>
|
||||
<if test="tradeNo!= null and tradeNo!= ''">
|
||||
and o.trade_no=#{tradeNo}
|
||||
</if>
|
||||
<if test="status!= null and status!= ''">
|
||||
and o.status=#{status}
|
||||
</if>
|
||||
<if test="userId!= null and userId!= ''">
|
||||
and o.user_id=#{userId}
|
||||
</if>
|
||||
order by order_time desc
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user