提交 f53c6847 authored 作者: 刘海泉's avatar 刘海泉

增加司机运费柱形图接口

上级 c36ea033
package com.clx.performance.vo.pc;
import com.msl.common.convertor.type.MoneyOutConvert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.math.BigDecimal;
@Getter
@Setter
@NoArgsConstructor
public class DriverFreightPriceChartVO {
@ApiModelProperty("挂单运费")
@MoneyOutConvert
private BigDecimal pendingOrderFreight;
@ApiModelProperty("运费生效时间")
@MoneyOutConvert
private String creatTime;
}
\ No newline at end of file
package com.clx.performance.vo.pc;
import com.msl.common.convertor.type.MoneyOutConvert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.math.BigDecimal;
@Getter
@Setter
@NoArgsConstructor
public class DriverFreightPriceVO {
@ApiModelProperty("货单编号")
private String orderGoodsNo;
@ApiModelProperty("挂单运费")
@MoneyOutConvert
private BigDecimal pendingOrderFreight;
}
\ No newline at end of file
package com.clx.performance.vo.pc;
import com.msl.common.convertor.type.MoneyOutConvert;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.math.BigDecimal;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class HistoryLineTranVolumeChartVO {
@ApiModelProperty("挂单运费")
@MoneyOutConvert
private BigDecimal pendingOrderFreight;
@ApiModelProperty("拉运单数")
@MoneyOutConvert
private Integer number;
}
\ No newline at end of file
package com.clx.performance.vo.pc;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class OrderGoodsPendingVO {
@ApiModelProperty("货单编号")
private String orderGoodsNo;
@ApiModelProperty("挂单时间")
private String pendingOrderTime;
}
\ No newline at end of file
package com.clx.performance.dao;
import com.msl.common.dao.BaseDao;
import com.clx.performance.mapper.OrderGoodsAdjustmentPriceMapper;
import com.clx.performance.model.OrderGoodsAdjustmentPrice;
import java.util.List;
/**
* @author kavin
* Date 2024-07-18
* Time 17:04
*/
public interface OrderGoodsAdjustmentPriceDao extends BaseDao<OrderGoodsAdjustmentPriceMapper, OrderGoodsAdjustmentPrice, Integer> {
List<OrderGoodsAdjustmentPrice> selectByOrderNoList(List<String> orderNoList);
}
package com.clx.performance.dao.impl;
import com.clx.performance.dao.OrderGoodsAdjustmentPriceDao;
import com.clx.performance.mapper.OrderGoodsAdjustmentPriceMapper;
import com.clx.performance.model.OrderGoodsAdjustmentPrice;
import com.msl.common.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author kavin
* Date 2024-07-18
* Time 17:04
*/
@Repository
public class OrderGoodsAdjustmentPriceDaoImpl extends BaseDaoImpl<OrderGoodsAdjustmentPriceMapper, OrderGoodsAdjustmentPrice, Integer> implements OrderGoodsAdjustmentPriceDao {
@Override
public List<OrderGoodsAdjustmentPrice> selectByOrderNoList(List<String> orderNoList) {
return baseMapper.selectList(lQrWrapper().in(OrderGoodsAdjustmentPrice::getOrderNo, orderNoList)
.orderByAsc(OrderGoodsAdjustmentPrice :: getCreateTime)
);
}
}
package com.clx.performance.listener;
import cn.hutool.json.JSONUtil;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.model.OrderGoodsAdjustmentPrice;
import com.clx.performance.service.OrderGoodsAdjustmentPriceService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
/**
* 处理货单取消吨数回填
*/
@Slf4j
@Component
@AllArgsConstructor
public class SaveOrderGoodsAdjustmentPriceListener {
private final OrderGoodsAdjustmentPriceService orderGoodsAdjustmentPriceService;
@RabbitListener(queues = RabbitKeyConstants.SAVE_ORDER_GOODS_ADJUSTMENT_PRICE_QUEUE)
public void onMessage(String message) {
log.info("监听到保存货单挂单运费调整记录,消息内容{}", message);
OrderGoodsAdjustmentPrice data = JSONUtil.toBean(message, OrderGoodsAdjustmentPrice.class);
orderGoodsAdjustmentPriceService.saveOrderGoodsAdjustmentPrice(data);
}
}
package com.clx.performance.listener;
import cn.hutool.json.JSONUtil;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.model.OrderChild;
import com.clx.performance.service.PerformanceProgressService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
/**
* 处理货单取消吨数回填
*/
@Slf4j
@Component
@AllArgsConstructor
public class SyncPerformanceProgress4OrderChildListener {
private final PerformanceProgressService performanceProgressService;
@RabbitListener(queues = RabbitKeyConstants.SYNC_PERFORMANCE_PROGRESS_FOR_ORDER_CHILD_QUEUE)
public void onMessage(String message) {
log.info("监听到同步履约进度表---运单信息部分,消息内容{}", message);
OrderChild data = JSONUtil.toBean(message, OrderChild.class);
performanceProgressService.dealPerformanceProgress4OrderChild(data);
}
}
package com.clx.performance.listener;
import cn.hutool.json.JSONUtil;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.PerformanceProgressService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
/**
* 处理货单取消吨数回填
*/
@Slf4j
@Component
@AllArgsConstructor
public class SyncPerformanceProgress4OrderGoodsListener {
private final PerformanceProgressService performanceProgressService;
@RabbitListener(queues = RabbitKeyConstants.SYNC_PERFORMANCE_PROGRESS_FOR_ORDER_GOODS_QUEUE)
public void onMessage(String message) {
log.info("监听到同步履约进度表---货单信息部分,消息内容{}", message);
OrderGoods data = JSONUtil.toBean(message, OrderGoods.class);
performanceProgressService.dealPerformanceProgress4OrderGoods(data);
}
}
package com.clx.performance.listener;
import cn.hutool.json.JSONUtil;
import com.clx.open.sdk.callback.message.OrderInfoMessage;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.service.PerformanceProgressService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
/**
* 处理货单取消吨数回填
*/
@Slf4j
@Component
@AllArgsConstructor
public class SyncPerformanceProgress4OrderInfoListener {
private final PerformanceProgressService performanceProgressService;
@RabbitListener(queues = RabbitKeyConstants.SYNC_PERFORMANCE_PROGRESS_FOR_ORDER_INFO_QUEUE)
public void onMessage(String message) {
log.info("监听到同步履约进度表---订单信息部分,消息内容{}", message);
OrderInfoMessage data = JSONUtil.toBean(message, OrderInfoMessage.class);
performanceProgressService.dealPerformanceProgress4OrderInfo(data);
}
}
package com.clx.performance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.performance.model.OrderGoodsAdjustmentPrice;
/**
* @author kavin
* Date 2024-07-18
* Time 17:04
*/
public interface OrderGoodsAdjustmentPriceMapper extends BaseMapper<OrderGoodsAdjustmentPrice> {
}
package com.clx.performance.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.msl.common.config.KeyColumn;
import com.msl.common.model.HasKey;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author kavin
* Date 2024-07-18
* Time 17:04
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("order_goods_adjustment_price")
public class OrderGoodsAdjustmentPrice implements HasKey<Integer> {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("order_no")
@ApiModelProperty("订单编号")
private String orderNo;
@TableField("order_goods_no")
@ApiModelProperty("货单编码")
private String orderGoodsNo;
@TableField("pre_amount")
@ApiModelProperty("上次金额 ")
private BigDecimal preAmount;
@TableField("amount")
@ApiModelProperty("本次调价金额")
private BigDecimal amount;
@TableField("create_time")
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
@Override
@KeyColumn("id")
public Integer gainKey() {
return this.id;
}
}
package com.clx.performance.service;
import com.clx.performance.model.OrderGoodsAdjustmentPrice;
import com.clx.performance.vo.pc.DriverFreightPriceChartVO;
import java.math.BigDecimal;
import java.util.List;
/**
* @author kavin
* Date 2024-07-18
* Time 17:04
*/
public interface OrderGoodsAdjustmentPriceService {
void saveOrderGoodsAdjustmentPrice(OrderGoodsAdjustmentPrice item);
List<DriverFreightPriceChartVO> getDriverFreightPriceChart(String orderNo);
List<DriverFreightPriceChartVO> getAdjacentPosDuplicateRemoveAdjustmentPriceRecord(List<String> orderNoList);
List<BigDecimal> getNoRepeatAdjustmentPriceRecord(List<String> orderNoList);
}
package com.clx.performance.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.clx.order.enums.ResultEnum;
import com.clx.order.feign.OrderFeign;
import com.clx.performance.dao.OrderGoodsAdjustmentPriceDao;
import com.clx.performance.extranal.user.OrderService;
import com.clx.performance.model.OrderGoodsAdjustmentPrice;
import com.clx.performance.service.OrderGoodsAdjustmentPriceService;
import com.clx.performance.vo.pc.DriverFreightPriceChartVO;
import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author kavin
* Date 2024-07-18
* Time 17:04
*/
@Service
@Slf4j
@AllArgsConstructor
public class OrderGoodsAdjustmentPriceServiceImpl implements OrderGoodsAdjustmentPriceService {
private final OrderGoodsAdjustmentPriceDao orderGoodsAdjustmentPriceDao;
private final OrderFeign orderFeign;
private final OrderService orderService;
@Transactional(rollbackFor = Exception.class)
@Override
public void saveOrderGoodsAdjustmentPrice(OrderGoodsAdjustmentPrice item){
orderGoodsAdjustmentPriceDao.saveEntity(item);
}
@Override
public List<DriverFreightPriceChartVO> getDriverFreightPriceChart(String orderNo) {
//查询近一个月与该订单收发货地线路一致的订单
Optional<List<String>> result = orderService.getMonthSameLineOrderList(orderNo);
if(!result.isPresent()){
log.warn("通过订单号:{} 查找相同线路的订单列列表,返回结果:{}",orderNo,result);
throw new ServiceSystemException(ResultEnum.DATA_ERROR,"获取相同线路的订单列表失败");
}
//相邻位置相同则取同一条
return this.getAdjacentPosDuplicateRemoveAdjustmentPriceRecord(result.get());
}
@Override
public List<DriverFreightPriceChartVO> getAdjacentPosDuplicateRemoveAdjustmentPriceRecord(List<String> orderNoList){
List<OrderGoodsAdjustmentPrice> list = orderGoodsAdjustmentPriceDao.selectByOrderNoList(orderNoList);
List<DriverFreightPriceChartVO> chartResult = new ArrayList<>();
//相邻的多条记录调价相同,则保留一条,不相同则生成新的一条
if(CollectionUtil.isNotEmpty(list)){
DriverFreightPriceChartVO chart;
BigDecimal preAdjustmentPrice = BigDecimal.ZERO;
for (OrderGoodsAdjustmentPrice item : list) {
//上次的价格和本次的价格发生了变化
if(preAdjustmentPrice.compareTo(item.getAmount()) != 0){
chart = new DriverFreightPriceChartVO();
chart.setPendingOrderFreight(item.getAmount());
chart.setCreatTime(DateUtils.formatDateTime(item.getCreateTime()).get());
chartResult.add(chart);
preAdjustmentPrice = item.getAmount();
}
}
}
return chartResult;
}
@Override
public List<BigDecimal> getNoRepeatAdjustmentPriceRecord(List<String> orderNoList){
List<OrderGoodsAdjustmentPrice> list = orderGoodsAdjustmentPriceDao.selectByOrderNoList(orderNoList);
List<BigDecimal> chartResult = new ArrayList<>();
//相邻的多条记录调价相同,则保留一条,不相同则生成新的一条
if(CollectionUtil.isNotEmpty(list)){
for (OrderGoodsAdjustmentPrice item : list) {
//去重操作
if(!chartResult.contains(item.getAmount())){
chartResult.add(item.getAmount());
}
}
}
return chartResult;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论