7月新需求修改
This commit is contained in:
parent
a33c41a7e3
commit
d9ef46cfa5
@ -68,10 +68,11 @@ public class BizLogisticsQuoteController extends BaseController {
|
||||
|
||||
|
||||
@SaCheckPermission("amz:shipmentPlan:edit")
|
||||
@GetMapping("/queryWithDes/{destination}/{date}")
|
||||
@GetMapping("/queryWithDes/{destination}/{date}/{shipmentId}")
|
||||
public TableDataInfo<BizLogisticsQuoteVo> queryWithDes(@PathVariable("destination") @NotNull(message = "目的地不能为空") String destination,
|
||||
@PathVariable("date") @NotNull(message = "日期不能为空") String date) {
|
||||
return bizLogisticsQuoteService.listWithDes(destination, date);
|
||||
@PathVariable("date") @NotNull(message = "日期不能为空") String date,
|
||||
@PathVariable("shipmentId") @NotNull(message = "fba货件编号不能为空") String shipmentId) {
|
||||
return bizLogisticsQuoteService.listWithDes(destination, date,shipmentId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,5 +110,9 @@ public class BizInquiryRequest extends TenantEntity {
|
||||
|
||||
private FbaShipmentApiResponse.Address shipToAddress;
|
||||
|
||||
private String type;
|
||||
|
||||
private String shipmentId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -119,5 +119,11 @@ public class BizLogisticsQuote extends TenantEntity {
|
||||
*/
|
||||
private String backLogisticsType;
|
||||
|
||||
private String type;
|
||||
|
||||
private String shipmentId;
|
||||
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
|
||||
}
|
||||
|
@ -105,8 +105,12 @@ public class BizSendOrder extends TenantEntity {
|
||||
|
||||
private String logisticsProviderName;
|
||||
|
||||
private Long logisticsProviderId;
|
||||
private Long logisticsProviderId;
|
||||
|
||||
private String shipmentId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String shipmentIdKey;
|
||||
|
||||
|
||||
}
|
||||
|
@ -184,6 +184,12 @@ public class BizShipmentPlan extends TenantEntity {
|
||||
*/
|
||||
private Long sendOrderId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String logisticsProviderName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String address;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -117,6 +117,9 @@ public class BizLogisticsQuoteBo extends BaseEntity {
|
||||
|
||||
private String backLogisticsType;
|
||||
|
||||
private Long totalPrice;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -125,4 +125,11 @@ public class BizLogisticsQuoteMostBo extends BaseEntity {
|
||||
|
||||
private String backLogisticsType;
|
||||
|
||||
private String type;
|
||||
|
||||
private String shipmentId;
|
||||
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class BizShipForwardBo extends BaseEntity {
|
||||
@NotBlank(message = "采购单号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String orderSn;
|
||||
|
||||
@NotBlank(message = "采购单号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
@NotBlank(message = "接收方采购单号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String inOrderSn;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.asinkj.amz.domain.BizInquiryRequest;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.asinkj.amz.domain.BizSendOrder;
|
||||
import org.asinkj.asinking.entity.FbaShipmentApiResponse;
|
||||
import org.asinkj.common.excel.annotation.ExcelDictFormat;
|
||||
import org.asinkj.common.excel.convert.ExcelDictConvert;
|
||||
@ -16,6 +17,7 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -125,6 +127,14 @@ public class BizInquiryRequestVo implements Serializable {
|
||||
|
||||
private String customsFlag;
|
||||
|
||||
private String type;
|
||||
|
||||
private String shipmentId;
|
||||
|
||||
private List<BizSendOrder> sendOrders;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -129,10 +129,14 @@ public class BizLogisticsQuoteVo implements Serializable {
|
||||
@ExcelProperty(value = "单位")
|
||||
private String unit;
|
||||
|
||||
private String customsFlag;
|
||||
private String customsFlag;
|
||||
|
||||
private String backLogisticsType;
|
||||
|
||||
private String type;
|
||||
private String shipmentId;
|
||||
|
||||
private Long totalPrice;
|
||||
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class InquiryRequestItemVo implements Serializable {
|
||||
* 目的地(存储四级行政编码,如CN310115)
|
||||
*/
|
||||
@ExcelProperty(value = "目的地", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "存=储四级行政编码,如CN310115")
|
||||
@ExcelDictFormat(readConverterExp = "四个字母标识")
|
||||
private String destination;
|
||||
|
||||
|
||||
@ -57,5 +57,7 @@ public class InquiryRequestItemVo implements Serializable {
|
||||
|
||||
private FbaShipmentApiResponse.Address shipToAddress;
|
||||
|
||||
private String type;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.asinkj.amz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.asinkj.amz.domain.BizInquiryRequest;
|
||||
import org.asinkj.amz.domain.vo.BizInquiryRequestVo;
|
||||
@ -18,4 +21,15 @@ public interface BizInquiryRequestMapper extends BaseMapperPlus<BizInquiryReques
|
||||
|
||||
// 自定义查询(可选)
|
||||
List<BizInquiryRequest> selectOpenAndEffectiveInquiries(@Param("currentDate") LocalDate currentDate);
|
||||
|
||||
|
||||
/**
|
||||
* XML 分页查询方法
|
||||
* @param page 分页参数对象 (必须放在第一位)
|
||||
* @param wrapper 查询条件构造器
|
||||
*/
|
||||
Page<BizInquiryRequestVo> selectCustomPage(
|
||||
@Param("page") Page<BizInquiryRequestVo> page,
|
||||
@Param(Constants.WRAPPER) Wrapper<BizInquiryRequest> wrapper
|
||||
);
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package org.asinkj.amz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.asinkj.amz.domain.BizInquiryRequest;
|
||||
import org.asinkj.amz.domain.BizSendOrder;
|
||||
import org.asinkj.amz.domain.OrderWithShipment;
|
||||
import org.asinkj.amz.domain.vo.BizInquiryRequestVo;
|
||||
import org.asinkj.amz.domain.vo.BizSendOrderVo;
|
||||
import org.asinkj.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
@ -21,4 +26,10 @@ public interface BizSendOrderMapper extends BaseMapperPlus<BizSendOrder, BizSend
|
||||
List<OrderWithShipment> selectOrdersWithShipmentIds(
|
||||
@Param("shipmentIds") Collection<Long> shipmentIds
|
||||
);
|
||||
|
||||
|
||||
Page<BizSendOrderVo> selectCustomPage(
|
||||
@Param("page") Page<BizInquiryRequestVo> page,
|
||||
@Param(Constants.WRAPPER) Wrapper<BizSendOrder> wrapper
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package org.asinkj.amz.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.asinkj.amz.domain.BizSendOrder;
|
||||
import org.asinkj.amz.domain.BizShipmentPlan;
|
||||
import org.asinkj.amz.domain.BizShipmentPlanFileData;
|
||||
import org.asinkj.amz.domain.OrderShipmentRelation;
|
||||
@ -10,6 +12,7 @@ import org.asinkj.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -31,4 +34,14 @@ public interface BizShipmentPlanMapper extends BaseMapperPlus<BizShipmentPlan, B
|
||||
List<BizShipmentPlan> findByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
int deleteBySendOrderShipmentPlan(@Param("shipmentPlanId") Long shipmentPlanId,@Param("sendOrderId") Long sendOrderId);
|
||||
|
||||
List<Long> selectPlanIdsByRequestIds(@Param("requestIds") List<String> requestIds);
|
||||
|
||||
@MapKey("requestId") // 指定分组键
|
||||
Map<Long, List<BizSendOrder>> batchFindSendOrdersByPlanIds(
|
||||
@Param("planIds") List<Long> planIds
|
||||
);
|
||||
|
||||
|
||||
List<BizSendOrder> batchGetSendOrdersByShipmentIds(List<String> shipmentIds);
|
||||
}
|
||||
|
@ -92,5 +92,5 @@ public interface IBizLogisticsQuoteService {
|
||||
|
||||
List<BizLogisticsQuote> queryQuoteWithQuoteId(Set<Long> quoteIds);
|
||||
|
||||
TableDataInfo<BizLogisticsQuoteVo> listWithDes(String destination, String date);
|
||||
TableDataInfo<BizLogisticsQuoteVo> listWithDes(String destination, String date,String shipmentId);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.asinkj.amz.service;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.asinkj.amz.domain.BizSendOrder;
|
||||
import org.asinkj.amz.domain.BizShipmentPlan;
|
||||
import org.asinkj.amz.domain.vo.BizLogisticsQuoteVo;
|
||||
import org.asinkj.amz.domain.vo.BizShipmentPlanOrderVo;
|
||||
@ -91,4 +92,8 @@ public interface IBizShipmentPlanService {
|
||||
Boolean linkByBo(BizShipmentPlanBo bo);
|
||||
|
||||
int deleteBySendOrderShipmentPlan(Long shipmentPlanId, Long sendOrderId);
|
||||
|
||||
Map<Long, List<BizSendOrder>> batchGetSendOrdersByRequestIds(List<String> requestIds);
|
||||
|
||||
List<BizSendOrder> batchGetSendOrdersByShipmentIds(List<String> shipmentIds);
|
||||
}
|
||||
|
@ -6,23 +6,19 @@ import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.asinkj.amz.domain.BizLogisticsQuote;
|
||||
import org.asinkj.amz.domain.BizSendOrder;
|
||||
import org.asinkj.amz.domain.vo.BizLogisticsChannelVo;
|
||||
import org.asinkj.amz.domain.vo.BizLogisticsOrderDetailVo;
|
||||
import org.asinkj.amz.domain.vo.InquiryRequestItemVo;
|
||||
import org.asinkj.amz.mapper.BizLogisticsQuoteMapper;
|
||||
import org.asinkj.amz.service.IBizInquiryBlacklistService;
|
||||
import org.asinkj.amz.service.IBizLogisticsChannelService;
|
||||
import org.asinkj.amz.service.IBizShipmentPlanService;
|
||||
import org.asinkj.common.core.domain.R;
|
||||
import org.asinkj.common.core.exception.ServiceException;
|
||||
import org.asinkj.common.core.utils.MapstructUtils;
|
||||
import org.asinkj.common.core.utils.StringUtils;
|
||||
import org.asinkj.common.excel.utils.ExcelUtil;
|
||||
import org.asinkj.common.mybatis.core.page.TableDataInfo;
|
||||
import org.asinkj.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -30,13 +26,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.asinkj.common.redis.annotation.DistributedLock;
|
||||
import org.asinkj.common.redis.utils.RedisUtils;
|
||||
import org.asinkj.common.satoken.utils.LoginHelper;
|
||||
import org.asinkj.common.wp.handler.WxMessagesManager;
|
||||
import org.asinkj.resource.api.RemoteMessageService;
|
||||
import org.asinkj.system.api.RemoteUserService;
|
||||
import org.asinkj.utils.SerialNoGenerator;
|
||||
import org.redisson.api.RLock;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.asinkj.amz.domain.bo.BizInquiryRequestBo;
|
||||
@ -46,7 +40,6 @@ import org.asinkj.amz.mapper.BizInquiryRequestMapper;
|
||||
import org.asinkj.amz.service.IBizInquiryRequestService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
@ -96,9 +89,8 @@ public class BizInquiryRequestServiceImpl implements IBizInquiryRequestService {
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private IBizShipmentPlanService shipmentPlanService;
|
||||
|
||||
|
||||
/**
|
||||
@ -122,7 +114,31 @@ public class BizInquiryRequestServiceImpl implements IBizInquiryRequestService {
|
||||
@Override
|
||||
public TableDataInfo<BizInquiryRequestVo> queryPageList(BizInquiryRequestBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BizInquiryRequest> lqw = buildQueryWrapper(bo);
|
||||
Page<BizInquiryRequestVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
// Page<BizInquiryRequestVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
String customSqlSegment = lqw.getCustomSqlSegment();
|
||||
log.info("customSqlSegment: {}", customSqlSegment);
|
||||
String sqlSegment = lqw.getSqlSegment();
|
||||
log.info("sqlSegment: {}", sqlSegment);
|
||||
Page<BizInquiryRequestVo> result = baseMapper.selectCustomPage(pageQuery.build(), lqw);
|
||||
|
||||
List<String> shipmentIds = result.getRecords().stream()
|
||||
.map(BizInquiryRequestVo::getShipmentId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 3. 单个查询获取所有发货单数据(按 shipmentId 分组)
|
||||
List<BizSendOrder> bizSendOrders = shipmentPlanService.batchGetSendOrdersByShipmentIds(shipmentIds);
|
||||
if (CollectionUtil.isNotEmpty(bizSendOrders)) {
|
||||
Map<String, List<BizSendOrder>> ordersMap = bizSendOrders.stream().collect(Collectors.groupingBy(BizSendOrder::getShipmentIdKey));
|
||||
// 4. 组装发货单数据到结果对象
|
||||
|
||||
for (BizInquiryRequestVo record : result.getRecords()) {
|
||||
if ("weight".equals(record.getType())) {
|
||||
record.setSendOrders(ordersMap.getOrDefault(record.getShipmentId(), Collections.emptyList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -141,6 +157,7 @@ public class BizInquiryRequestServiceImpl implements IBizInquiryRequestService {
|
||||
private LambdaQueryWrapper<BizInquiryRequest> buildQueryWrapper(BizInquiryRequestBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<BizInquiryRequest> lqw = Wrappers.lambdaQuery();
|
||||
lqw.apply("1 = 1");
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInquiryNo()), BizInquiryRequest::getInquiryNo, bo.getInquiryNo());
|
||||
lqw.eq(bo.getRequesterId() != null, BizInquiryRequest::getRequesterId, bo.getRequesterId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTargetProviders()), BizInquiryRequest::getTargetProviders, bo.getTargetProviders());
|
||||
@ -160,6 +177,7 @@ public class BizInquiryRequestServiceImpl implements IBizInquiryRequestService {
|
||||
List<BizLogisticsQuote> bizLogisticsQuotes = logisticsQuoteMapper.selectList(queryWrapper);
|
||||
Set<Long> collect = bizLogisticsQuotes.stream().map(BizLogisticsQuote::getInquiryId).collect(Collectors.toSet());
|
||||
lqw.notIn(CollectionUtil.isNotEmpty(collect), BizInquiryRequest::getId, collect);
|
||||
lqw.orderByDesc(BizInquiryRequest::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@ -370,6 +388,8 @@ public class BizInquiryRequestServiceImpl implements IBizInquiryRequestService {
|
||||
bizInquiryRequest.setCustomsFlag(request.getCustomsFlag());
|
||||
bizInquiryRequest.setRequesterName(LoginHelper.getLoginUser().getNickname());
|
||||
bizInquiryRequest.setInquiryNo(SerialNoGenerator.generateInquiryNo());
|
||||
bizInquiryRequest.setType(request.getType());
|
||||
bizInquiryRequest.setShipmentId(request.getShipmentId());
|
||||
|
||||
// 查询渠道信息
|
||||
BizLogisticsChannelVo channelVo = bizLogisticsChannelService.queryById(request.getChannelId());
|
||||
@ -464,16 +484,13 @@ public class BizInquiryRequestServiceImpl implements IBizInquiryRequestService {
|
||||
);
|
||||
}
|
||||
|
||||
// 查询已存在的记录
|
||||
List<BizInquiryRequest> existingList = baseMapper.selectList(wrapper);
|
||||
|
||||
|
||||
// 将已存在的记录转为 Set 方便快速比对(假设三字段组合唯一)
|
||||
Set<String> existingKeys = existingList.stream()
|
||||
.map(e -> e.getDestination() + "_" + e.getChannelId() + "_" + e.getQuoteDate())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 过滤掉重复的待插入数据
|
||||
List<InquiryRequestItemVo> filteredItems = items.stream()
|
||||
.filter(item -> !existingKeys.contains(
|
||||
item.getDestination() + "_" + item.getChannelId() + "_" + item.getQuoteDate()
|
||||
|
@ -87,7 +87,7 @@ public class BizLogisticsQuoteServiceImpl implements IBizLogisticsQuoteService {
|
||||
// 2. 调用动态报表查询
|
||||
// return baseMapper.selectDynamicReport(channels);
|
||||
|
||||
return baseMapper.getQuoteReport(channels,bo.getQuoteStartDate(), bo.getQuoteEndDate(),bo.getDestination());
|
||||
return baseMapper.getQuoteReport(channels, bo.getQuoteStartDate(), bo.getQuoteEndDate(), bo.getDestination());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,6 +263,9 @@ public class BizLogisticsQuoteServiceImpl implements IBizLogisticsQuoteService {
|
||||
bizLogisticsQuote.setRemark(bo.getRemark());
|
||||
bizLogisticsQuote.setUnit(bo.getUnit());
|
||||
bizLogisticsQuote.setInquiryId(bo.getId());
|
||||
bizLogisticsQuote.setType(bo.getType());
|
||||
bizLogisticsQuote.setShipmentId(bo.getShipmentId());
|
||||
bizLogisticsQuote.setTotalPrice(bo.getTotalPrice());
|
||||
bizLogisticsQuotes.add(bizLogisticsQuote);
|
||||
}
|
||||
boolean b = baseMapper.insertBatch(bizLogisticsQuotes);
|
||||
@ -272,25 +275,52 @@ public class BizLogisticsQuoteServiceImpl implements IBizLogisticsQuoteService {
|
||||
|
||||
@Override
|
||||
public Boolean checkPriceQuoteByBo(BizLogisticsQuoteMostBo bo) {
|
||||
LambdaQueryWrapper<BizLogisticsQuote> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizLogisticsQuote::getDestination, bo.getDestination())
|
||||
.eq(BizLogisticsQuote::getChannelName, bo.getChannelName())
|
||||
.eq(BizLogisticsQuote::getQuoteDate, bo.getQuoteEndDate())
|
||||
;
|
||||
List<BizLogisticsQuote> bizLogisticsQuotes = baseMapper.selectList(queryWrapper);
|
||||
if (bizLogisticsQuotes.size() == 0) {
|
||||
if ("general".equals(bo.getType())) {
|
||||
LambdaQueryWrapper<BizLogisticsQuote> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizLogisticsQuote::getDestination, bo.getDestination())
|
||||
.eq(BizLogisticsQuote::getChannelName, bo.getChannelName())
|
||||
.eq(BizLogisticsQuote::getQuoteDate, bo.getQuoteEndDate())
|
||||
;
|
||||
|
||||
|
||||
List<BizLogisticsQuote> bizLogisticsQuotes = baseMapper.selectList(queryWrapper);
|
||||
if (bizLogisticsQuotes.size() == 0) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
BigDecimal average = bizLogisticsQuotes.stream()
|
||||
.map(BizLogisticsQuote::getPrice)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
.divide(new BigDecimal(bizLogisticsQuotes.size()), 2, RoundingMode.HALF_UP);
|
||||
|
||||
if (average.compareTo(bo.getPrice()) < 0) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
} else {
|
||||
LambdaQueryWrapper<BizLogisticsQuote> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizLogisticsQuote::getDestination, bo.getDestination())
|
||||
.eq(BizLogisticsQuote::getChannelName, bo.getChannelName())
|
||||
.eq(BizLogisticsQuote::getQuoteDate, bo.getQuoteEndDate())
|
||||
;
|
||||
|
||||
queryWrapper.eq(BizLogisticsQuote::getShipmentId, bo.getShipmentId());
|
||||
|
||||
List<BizLogisticsQuote> bizLogisticsQuotes = baseMapper.selectList(queryWrapper);
|
||||
if (bizLogisticsQuotes.size() == 0) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
BigDecimal average = bizLogisticsQuotes.stream()
|
||||
.map(BizLogisticsQuote::getTotalPrice)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
.divide(new BigDecimal(bizLogisticsQuotes.size()), 2, RoundingMode.HALF_UP);
|
||||
|
||||
if (average.compareTo(bo.getTotalPrice()) < 0) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
BigDecimal average = bizLogisticsQuotes.stream()
|
||||
.map(BizLogisticsQuote::getPrice)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
.divide(new BigDecimal(bizLogisticsQuotes.size()), 2, RoundingMode.HALF_UP);
|
||||
|
||||
if (average.compareTo(bo.getPrice()) < 0) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -346,11 +376,11 @@ public class BizLogisticsQuoteServiceImpl implements IBizLogisticsQuoteService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BizLogisticsQuoteVo> listWithDes(String destination, String date) {
|
||||
public TableDataInfo<BizLogisticsQuoteVo> listWithDes(String destination, String date, String shipmentId) {
|
||||
if (StringUtils.isNotBlank(destination)) {
|
||||
LambdaQueryWrapper<BizLogisticsQuote> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizLogisticsQuote::getDestination, destination);
|
||||
|
||||
queryWrapper.and(wp -> wp.eq(BizLogisticsQuote::getType, "general").or().eq(BizLogisticsQuote::getType, "weight").eq(BizLogisticsQuote::getShipmentId, shipmentId));
|
||||
queryWrapper.eq(BizLogisticsQuote::getQuoteDate, date);
|
||||
|
||||
return TableDataInfo.build(baseMapper.selectVoList(queryWrapper));
|
||||
|
@ -86,7 +86,7 @@ public class BizSendOrderServiceImpl implements IBizSendOrderService {
|
||||
@Override
|
||||
public TableDataInfo<BizSendOrderVo> queryPageList(BizSendOrderBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BizSendOrder> lqw = buildQueryWrapper(bo);
|
||||
Page<BizSendOrderVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
Page<BizSendOrderVo> result = baseMapper.selectCustomPage(pageQuery.build(), lqw);
|
||||
List<BizSendOrderVo> records = result.getRecords();
|
||||
Set<String> shipmentIds = records.stream().map(BizSendOrderVo::getShipmentId).collect(Collectors.toSet());
|
||||
Set<Long> ids = records.stream().map(BizSendOrderVo::getId).collect(Collectors.toSet());
|
||||
|
@ -9,6 +9,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.asinkj.amz.domain.*;
|
||||
import org.asinkj.amz.domain.bo.SysAmazonStoreBo;
|
||||
import org.asinkj.amz.domain.vo.*;
|
||||
@ -495,6 +496,31 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
|
||||
return baseMapper.deleteBySendOrderShipmentPlan(shipmentPlanId, sendOrderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, List<BizSendOrder>> batchGetSendOrdersByRequestIds(List<String> requestIds) {
|
||||
if (CollectionUtil.isEmpty(requestIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
// 1. 查询所有关联的货运计划ID
|
||||
List<Long> planIds = baseMapper.selectPlanIdsByRequestIds(requestIds);
|
||||
|
||||
// 2. 通过货运计划ID批量获取发货单
|
||||
if (!CollectionUtil.isEmpty(planIds)) {
|
||||
return baseMapper.batchFindSendOrdersByPlanIds(planIds);
|
||||
}
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BizSendOrder> batchGetSendOrdersByShipmentIds(List<String> shipmentIds) {
|
||||
if (CollectionUtil.isEmpty(shipmentIds)) {
|
||||
return null;
|
||||
}
|
||||
return baseMapper.batchGetSendOrdersByShipmentIds(shipmentIds);
|
||||
}
|
||||
|
||||
private void checkData(List<BizShipmentPlanFileData> bizShipmentPlanFileDataList) {
|
||||
boolean isAllSame = bizShipmentPlanFileDataList.stream()
|
||||
.map(BizShipmentPlanFileData::getShipmentId)
|
||||
|
@ -10,4 +10,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND del_flag = '0'
|
||||
AND #{currentDate} = deadline::date
|
||||
</select>
|
||||
<select id="selectCustomPage" resultType="org.asinkj.amz.domain.vo.BizInquiryRequestVo">
|
||||
SELECT
|
||||
req.*
|
||||
FROM biz_inquiry_request req
|
||||
<where>
|
||||
${ew.sqlSegment} <!-- MyBatis-Plus 动态条件 -->
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -40,6 +40,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectCustomPage" resultType="org.asinkj.amz.domain.vo.BizSendOrderVo">
|
||||
SELECT
|
||||
req.*
|
||||
FROM biz_send_order req
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<resultMap id="orderWithShipmentMap" type="org.asinkj.amz.domain.OrderWithShipment">
|
||||
<!-- 使用订单id作为整个OrderWithShipment对象的唯一标识 -->
|
||||
|
@ -73,6 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="setTotal" column="set_total"/>
|
||||
<result property="channelId" column="channel_id"/>
|
||||
<result property="channelName" column="channel_name"/>
|
||||
<result property="logisticsProviderName" column="logistics_provider_name"/>
|
||||
<result property="address" column="address"/>
|
||||
<!--<result property="shippedTime" column="shipped_time"/>-->
|
||||
<!--<result property="workingTime" column="working_time"/>-->
|
||||
<!--<result property="closedTime" column="closed_time"/>-->
|
||||
@ -101,46 +103,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<!-- 根据ID批量查询 shipment -->
|
||||
<select id="findByIds" resultMap="shipmentPlanMap">
|
||||
SELECT
|
||||
id,
|
||||
shipment_id,
|
||||
shipment_name,
|
||||
is_closed,
|
||||
shipment_status,
|
||||
destination,
|
||||
shipping_mode,
|
||||
shipping_solution,
|
||||
gmt_modified,
|
||||
gmt_create,
|
||||
receiving_time,
|
||||
sta_shipment_date,
|
||||
sta_delivery_start_date,
|
||||
sta_delivery_end_date,
|
||||
ship_from_address,
|
||||
ship_to_address,
|
||||
reference_id,
|
||||
sta_inbound_plan_id,
|
||||
is_sta,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
create_dept,
|
||||
tenant_id,
|
||||
shipment_unique_id,
|
||||
inbound_plan_id,
|
||||
fba_status,
|
||||
box_quantity,
|
||||
box_size,
|
||||
vendor_weight,
|
||||
set_total,
|
||||
channel_id,
|
||||
channel_name,
|
||||
shipped_time,
|
||||
working_time,
|
||||
closed_time
|
||||
FROM biz_shipment_plan
|
||||
WHERE id IN
|
||||
bsp.id,
|
||||
bsp.shipment_id,
|
||||
bsp.shipment_name,
|
||||
bsp.is_closed,
|
||||
bsp.shipment_status,
|
||||
bsp.destination,
|
||||
bsp.shipping_mode,
|
||||
bsp.shipping_solution,
|
||||
bsp.gmt_modified,
|
||||
bsp.gmt_create,
|
||||
bsp.receiving_time,
|
||||
bsp.sta_shipment_date,
|
||||
bsp.sta_delivery_start_date,
|
||||
bsp.sta_delivery_end_date,
|
||||
bsp.ship_from_address,
|
||||
bsp.ship_to_address,
|
||||
bsp.reference_id,
|
||||
bsp.sta_inbound_plan_id,
|
||||
bsp.is_sta,
|
||||
bsp.del_flag,
|
||||
bsp.create_by,
|
||||
bsp.create_time,
|
||||
bsp.update_by,
|
||||
bsp.update_time,
|
||||
bsp.create_dept,
|
||||
bsp.tenant_id,
|
||||
bsp.shipment_unique_id,
|
||||
bsp.inbound_plan_id,
|
||||
bsp.fba_status,
|
||||
bsp.box_quantity,
|
||||
bsp.box_size,
|
||||
bsp.vendor_weight,
|
||||
bsp.set_total,
|
||||
bsp.channel_id,
|
||||
bsp.channel_name,
|
||||
bsp.shipped_time,
|
||||
bsp.working_time,
|
||||
bsp.closed_time,
|
||||
blo.logistics_provider_name AS logistics_provider_name,
|
||||
su.address AS address
|
||||
FROM biz_shipment_plan bsp
|
||||
LEFT JOIN biz_logistics_order blo ON bsp.shipment_id = blo.fba_shipment_id
|
||||
LEFT JOIN sys_user su ON su.user_id = blo.logistics_provider_id
|
||||
WHERE bsp.id IN
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
@ -151,4 +157,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
DELETE FROM biz_send_shipment_rel
|
||||
WHERE send_order_id = #{sendOrderId} and shipment_plan_id = #{shipmentPlanId}
|
||||
</delete>
|
||||
|
||||
|
||||
<!-- 查询询价单对应的货运计划ID -->
|
||||
<select id="selectPlanIdsByRequestIds" resultType="java.lang.Long">
|
||||
SELECT DISTINCT plan.id
|
||||
FROM biz_shipment_plan plan
|
||||
WHERE plan.shipment_id IN
|
||||
<foreach item="id" collection="requestIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 通过货运计划ID批量查询发货单 -->
|
||||
<select id="batchFindSendOrdersByPlanIds"
|
||||
resultType="org.asinkj.amz.domain.BizSendOrder">
|
||||
SELECT
|
||||
o.*,
|
||||
rel.shipment_plan_id AS requestId <!-- 用于分组的关联ID -->
|
||||
FROM biz_send_order o
|
||||
INNER JOIN biz_send_shipment_rel rel ON o.id = rel.send_order_id
|
||||
WHERE rel.shipment_plan_id IN
|
||||
<foreach item="id" collection="planIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="batchGetSendOrdersByShipmentIds"
|
||||
resultType="org.asinkj.amz.domain.BizSendOrder">
|
||||
SELECT DISTINCT
|
||||
o.*,
|
||||
<!-- 使用 shipmentId 作为分组键 -->
|
||||
req.shipment_id AS shipmentIdKey
|
||||
FROM biz_send_order o
|
||||
|
||||
<!-- 关联路径:发货单 → 关联表 → 货运计划 → 询价单-->
|
||||
INNER JOIN biz_send_shipment_rel rel ON o.id = rel.send_order_id
|
||||
INNER JOIN biz_shipment_plan plan ON plan.id = rel.shipment_plan_id
|
||||
INNER JOIN biz_inquiry_request req ON req.shipment_id = plan.shipment_id
|
||||
|
||||
WHERE req.shipment_id IN
|
||||
<foreach item="id" collection="shipmentIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -74,7 +74,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope> <!-- 必须为provided或compile -->
|
||||
<!--<scope>provided</scope> <!– 必须为provided或compile –>-->
|
||||
</dependency>
|
||||
|
||||
<!-- 自动生成YML配置关联JSON文件 -->
|
||||
|
@ -5,9 +5,15 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.asinkj.common.core.factory.YmlPropertySourceFactory;
|
||||
import org.asinkj.common.core.utils.SpringUtils;
|
||||
import org.asinkj.common.mybatis.handler.InjectionMetaObjectHandler;
|
||||
@ -21,6 +27,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* mybatis-plus配置类(下方注释有插件介绍)
|
||||
*
|
||||
@ -47,9 +55,40 @@ public class MybatisPlusConfiguration {
|
||||
interceptor.addInnerInterceptor(paginationInnerInterceptor());
|
||||
// 乐观锁插件
|
||||
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
|
||||
// interceptor.addInnerInterceptor(new EmptyWhereInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
// 自定义拦截器实现
|
||||
public class EmptyWhereInterceptor implements InnerInterceptor {
|
||||
private static final Field SQL_FIELD;
|
||||
|
||||
static {
|
||||
try {
|
||||
SQL_FIELD = BoundSql.class.getDeclaredField("sql");
|
||||
SQL_FIELD.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException("反射获取sql字段失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter,
|
||||
RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
|
||||
String sql = boundSql.getSql();
|
||||
if (sql != null && sql.contains("WHERE") &&
|
||||
!sql.matches("(?is).*\\bWHERE\\s+[^\\s].*")) {
|
||||
try {
|
||||
// 通过反射修改原始SQL
|
||||
SQL_FIELD.set(boundSql, sql.replace("WHERE", "WHERE 1 = 1 AND"));
|
||||
} catch (IllegalAccessException e) {
|
||||
// 安全处理异常
|
||||
System.err.println("SQL修改失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据权限拦截器
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user