Browse Source

1.干线-bug修复

2.公共模块增加防重复提交自定义注解
dist.1.3.0
zhenghaoyu 11 months ago
parent
commit
a9e1c5bc75
  1. 11
      blade-biz-common/src/main/java/org/springblade/common/annotations/RepeatSubmit.java
  2. 2
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/WaybillDetailDTO.java
  3. 9
      blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWayBillDetail.java
  4. 18
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/InterceptorAdapterConfig.java
  5. 66
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/interceptor/ParameterCombinationInterceptor.java
  6. 1
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml
  7. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml
  8. 18
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java
  9. 8
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

11
blade-biz-common/src/main/java/org/springblade/common/annotations/RepeatSubmit.java

@ -0,0 +1,11 @@
package org.springblade.common.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RepeatSubmit {
}

2
blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/WaybillDetailDTO.java

@ -20,5 +20,7 @@ public class WaybillDetailDTO implements Serializable {
private BigDecimal volume;//体积
private BigDecimal price ;//单价
private BigDecimal subtotalFreight;//小计运费
private BigDecimal deliveryPrice;//配送单价
private BigDecimal subtotalDeliveryFee;//小计配送费用
}

9
blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWayBillDetail.java

@ -53,4 +53,13 @@ public class WarehouseWayBillDetail extends BaseEntity {
@ApiModelProperty(name = "计价方式 1件 2方 3公斤",notes = "")
private Integer chargeType;
/** 单价 */
@ApiModelProperty(name = "配送单价",notes = "")
private BigDecimal deliveryPrice;
/** 小计运费 */
@ApiModelProperty(name = "小计配送费用",notes = "")
private BigDecimal subtotalDeliveryFee;
}

18
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/InterceptorAdapterConfig.java

@ -0,0 +1,18 @@
package com.logpm.trunkline.config;
import com.logpm.trunkline.interceptor.ParameterCombinationInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@AllArgsConstructor
public class InterceptorAdapterConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry interceptorRegistry) {
interceptorRegistry.addInterceptor(new ParameterCombinationInterceptor())
.addPathPatterns("/**");
}
}

66
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/interceptor/ParameterCombinationInterceptor.java

@ -0,0 +1,66 @@
package com.logpm.trunkline.interceptor;
import org.apache.commons.codec.digest.DigestUtils;
import org.springblade.common.annotations.RepeatSubmit;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class ParameterCombinationInterceptor implements HandlerInterceptor {
private static final ThreadLocal<String> PROCESSED_REQUEST_HASH = new ThreadLocal<>();
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (handler instanceof HandlerMethod) {
HandlerMethod hm = (HandlerMethod) handler;
RepeatSubmit annotation = hm.getMethodAnnotation(RepeatSubmit.class);
if (annotation != null) {
// 计算当前请求参数的MD5哈希值
String currentRequestHash = calculateRequestHash(request.getParameterMap());
// 检查是否已处理过相同参数组合的请求
if (PROCESSED_REQUEST_HASH.get() != null && PROCESSED_REQUEST_HASH.get().equals(currentRequestHash)) {
// 阻止重复提交
response.sendError(HttpServletResponse.SC_CONFLICT, "Duplicate submit detected");
return false;
}
// 保存当前请求的哈希值
PROCESSED_REQUEST_HASH.set(currentRequestHash);
}
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// 清理当前请求的哈希值
PROCESSED_REQUEST_HASH.remove();
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
// 可选清理操作,postHandle中已处理
}
/**
* 计算请求参数的MD5哈希值
* @param parameters 请求参数Map
* @return 参数哈希值字符串
*/
private String calculateRequestHash(Map<String, String[]> parameters) {
// 将参数按key排序并拼接为字符串
String sortedParams = parameters.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(entry -> entry.getKey() + "=" + String.join(",", entry.getValue()))
.collect(Collectors.joining("&"));
// 计算并返回MD5摘要
return DigestUtils.md5Hex(sortedParams);
}
}

1
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml

@ -354,6 +354,7 @@
<foreach collection="orderPackageCodeGroup" index="ind" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and ltad.is_deleted = 0
</select>

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml

@ -15,7 +15,7 @@
select lta.*,
lbc.client_name htMallName
from logpm_trunkline_advance lta
left join logpm_basicdata_tripartite_mall lbtm on lbtm.tripartite_mall = lta.dealer_name and lbtm.brand_name = lta.brand and lta.dealer_code = lbtm.tripartite_coding
left join logpm_basicdata_tripartite_mall lbtm on lbtm.tripartite_mall = lta.dealer_name and lbtm.brand_name = lta.brand and IFNULL(lta.dealer_code,'') = IFNULL(lbtm.tripartite_coding,'')
left join logpm_basicdata_client lbc on lbc.id = lbtm.client_id
where lta.is_deleted = 0
and lta.waybill_status = 0

18
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java

@ -30,9 +30,9 @@ import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import com.logpm.warehouse.feign.IWarehouseWaybillClient;
import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient;
import com.logpm.warehouse.vo.WarehouseWaybillVO;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.annotations.RepeatSubmit;
import org.springblade.common.constant.CodeNumConstant;
import org.springblade.common.constant.DictBizConstant;
import org.springblade.common.constant.IncomingTypeEnum;
@ -193,10 +193,16 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
BasicdataClientVO basicdataClientEntity = basicdataClientClient.findEntityVoById(clientId);
if (!Objects.isNull(basicdataClientEntity)) {
openOrderVO.setConsigneeClientId(clientId);
TrunklineAdvanceEntity advanceEntity = list.get(0);
openOrderVO.setConsignee(basicdataClientEntity.getClientName());
openOrderVO.setConsigneeName(basicdataClientEntity.getLinkman());
openOrderVO.setConsigneeMobile(basicdataClientEntity.getPhone());
openOrderVO.setConsigneeAddress(basicdataClientEntity.getDetailedly());
if(!Objects.isNull(advanceEntity)){
openOrderVO.setConsigneeName(advanceEntity.getConsigneePerson());
openOrderVO.setConsigneeMobile(advanceEntity.getConsigneeMobile());
openOrderVO.setConsigneeAddress(advanceEntity.getConsigneeAddress());
}
List<String> destinationArray = new ArrayList<>();
String badeRegionAreaId = basicdataClientEntity.getBladeRegionAreaId();
@ -332,6 +338,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
return R.success("验证成功");
}
@RepeatSubmit
@Transactional(rollbackFor = Exception.class)
@Override
public R openWaybill(OpenOrderDTO openOrderDTO) {
@ -503,6 +510,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice());
warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight());
warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType());
warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice());
warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee());
details.add(warehouseWayBillDetail);
}
warehouseWaybillDetailClient.addList(details);
@ -631,6 +640,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
return R.data(map);
}
@RepeatSubmit
@Transactional(rollbackFor = Exception.class)
@Override
public R openZeroWaybill(OpenOrderDTO openOrderDTO) {
log.info("############openZeroWaybill: 开零担单开始 openOrderDTO={}", openOrderDTO);
@ -783,6 +794,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice());
warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight());
warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType());
warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice());
warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee());
details.add(warehouseWayBillDetail);
}
warehouseWaybillDetailClient.addList(details);
@ -3879,6 +3892,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
warehouseWayBillDetail.setSubtotalFreight(newSubtotalFreight);
}
warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice());
warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee());
warehouseWaybillDetailClient.updateEntityById(warehouseWayBillDetail);
}
}

8
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

@ -45,6 +45,7 @@ import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import org.springblade.common.annotations.RepeatSubmit;
import org.springblade.common.constant.*;
import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant;
import org.springblade.common.exception.CustomerException;
@ -233,7 +234,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
carsLoadLineEntity.setNodeStatus("20");
carsLoadLineEntity.setStartDate(date);
carsLoadLineEntity.setStartUserId(AuthUtil.getUserId());
carsLoadLineEntity.setStartUserName(AuthUtil.getUserName());
carsLoadLineEntity.setStartUserName(AuthUtil.getNickName());
trunklineCarsLoadLineService.updateById(carsLoadLineEntity);
//修改配载计划的节点状态
@ -312,7 +313,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
currentCarsLoadLineEntity.setNodeStatus("20");
currentCarsLoadLineEntity.setStartDate(date);
currentCarsLoadLineEntity.setStartUserId(AuthUtil.getUserId());
currentCarsLoadLineEntity.setStartUserName(AuthUtil.getUserName());
currentCarsLoadLineEntity.setStartUserName(AuthUtil.getNickName());
trunklineCarsLoadLineService.updateById(currentCarsLoadLineEntity);
//修改配载计划的节点状态
@ -529,7 +530,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
nextCarsLoadLineEntity.setNodeStatus("10");
nextCarsLoadLineEntity.setArriveDate(date);
nextCarsLoadLineEntity.setArriveUserId(AuthUtil.getUserId());
nextCarsLoadLineEntity.setArriveUserName(AuthUtil.getUserName());
nextCarsLoadLineEntity.setArriveUserName(AuthUtil.getNickName());
trunklineCarsLoadLineService.updateById(nextCarsLoadLineEntity);
Integer workNode = null;
if (!nodeId.equals(endNodeId)) {
@ -1039,6 +1040,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}
@RepeatSubmit
@Transactional(rollbackFor = Exception.class)
@Override
public R saveNew(TrunklineCarsLoadDTO carsLoadDTO, Long warehouseId) {

Loading…
Cancel
Save