Browse Source

1.修改推送运单数据存放逻辑

test
zhenghaoyu 2 years ago
parent
commit
1869760c52
  1. 77
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/WaybillDesEntity.java
  2. 20
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IWaybillDesClient.java
  3. 22
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/WaybillDesClient.java
  4. 12
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/WaybillDesMapper.java
  5. 11
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IWaybillDesService.java
  6. 27
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/WaybillDesServiceImpl.java
  7. 23
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/OldSystemPushController.java
  8. 9
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WaybillDTO.java
  9. 4
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWayBillDetailService.java
  10. 12
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWayBillDetailServiceImpl.java
  11. 87
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java

77
blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/WaybillDesEntity.java

@ -0,0 +1,77 @@
package com.logpm.oldproject.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@ApiModel(value = "运单表",description = "")
@Data
@TableName("ht_waybill_des")
public class WaybillDesEntity implements Serializable,Cloneable {
/** ID */
@TableId(
value = "id",
type = IdType.AUTO
)
private Integer id;
@ApiModelProperty(name = "运单号")
private String waybillNo;
@ApiModelProperty(name = "运单id")
private Integer wayBillId;
@ApiModelProperty(name = "二级品")
private String firstName;
@ApiModelProperty(name = "货物名称")
private String name;
@ApiModelProperty(name = "包装")
private String pocket;
@ApiModelProperty(name = "件数")
private Integer num;
@ApiModelProperty(name = "重量")
private BigDecimal weight;
@ApiModelProperty(name = "体积")
private BigDecimal volume;
@ApiModelProperty(name = "单价")
private BigDecimal price;
@ApiModelProperty(name = "单位")
private Integer pic;
@ApiModelProperty(name = "运费小计")
private BigDecimal totalDesPrice;
@ApiModelProperty(name = "创建时间")
private Date createTime;
@ApiModelProperty(name = "修改时间")
private Date updateTime;
@ApiModelProperty(name = "删除时间")
private Integer delete_time;
@ApiModelProperty(name = "")
private Integer oldId;
@ApiModelProperty(name = "价格id")
private Integer secPriceId;
@ApiModelProperty(name = "价格信息")
private String priceInfo;
}

20
blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IWaybillDesClient.java

@ -0,0 +1,20 @@
package com.logpm.oldproject.feign;
import com.logpm.oldproject.entity.WaybillDesEntity;
import org.springblade.common.constant.ModuleNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@FeignClient(
value = ModuleNameConstant.APPLICATION_OLDPROJECT_NAME
)
public interface IWaybillDesClient {
String API_PREFIX = "/client";
@GetMapping(API_PREFIX + "/getDesList")
List<WaybillDesEntity> getDesList(@RequestParam String waybillNo);
}

22
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/WaybillDesClient.java

@ -0,0 +1,22 @@
package com.logpm.oldproject.feign;
import com.logpm.oldproject.entity.WaybillDesEntity;
import com.logpm.oldproject.service.IWaybillDesService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
@ApiIgnore()
@RestController
@AllArgsConstructor
public class WaybillDesClient implements IWaybillDesClient{
private final IWaybillDesService waybillDesService;
@Override
public List<WaybillDesEntity> getDesList(String waybillNo) {
return waybillDesService.getDesList(waybillNo);
}
}

12
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/WaybillDesMapper.java

@ -0,0 +1,12 @@
package com.logpm.oldproject.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.oldproject.entity.WaybillDesEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WaybillDesMapper extends BaseMapper<WaybillDesEntity> {
}

11
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IWaybillDesService.java

@ -0,0 +1,11 @@
package com.logpm.oldproject.service;
import com.logpm.oldproject.entity.WaybillDesEntity;
import java.util.List;
public interface IWaybillDesService {
List<WaybillDesEntity> getDesList(String waybillNo);
}

27
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/WaybillDesServiceImpl.java

@ -0,0 +1,27 @@
package com.logpm.oldproject.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.oldproject.entity.WaybillDesEntity;
import com.logpm.oldproject.mapper.WaybillDesMapper;
import com.logpm.oldproject.service.IWaybillDesService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import java.util.List;
@Log4j2
@Service
@AllArgsConstructor
public class WaybillDesServiceImpl implements IWaybillDesService {
private final WaybillDesMapper waybillDesMapper;
@Override
public List<WaybillDesEntity> getDesList(String waybillNo) {
QueryWrapper<WaybillDesEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("waybill_no",waybillNo);
return waybillDesMapper.selectList(queryWrapper);
}
}

23
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/OldSystemPushController.java

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -44,25 +45,27 @@ public class OldSystemPushController {
@PostMapping("/sendWaybillData")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "运单数据推送", notes = "传入waybillDTO")
public R sendWaybillData(@Validated @RequestBody WaybillDTO waybillDTO) {
log.info("############sendWaybillData: 请求参数{}",waybillDTO);
public R sendWaybillData(@Validated @RequestBody List<WaybillDTO> waybillDTOS) {
log.info("############sendWaybillData: 请求参数{}",waybillDTOS);
try{
//先保存原始请求数据
WarehouseLog warehouseLog = new WarehouseLog();
warehouseLog.setArgs(JSONObject.toJSONString(waybillDTO));
warehouseLog.setArgs(JSONObject.toJSONString(waybillDTOS));
warehouseLog.setStatus(1);
warehouseLog.setType(1);
warehouseLogService.save(warehouseLog);
Map<String,Object> map=new HashMap<>();
map.put("messageId", CommonUtil.getUUID());
map.put("logId", warehouseLog.getId());
map.put("messageData",waybillDTO);
map.put("createTime",new Date().getTime());
for(WaybillDTO waybillDTO:waybillDTOS){
Map<String,Object> map=new HashMap<>();
map.put("messageId", CommonUtil.getUUID());
map.put("logId", warehouseLog.getId());
map.put("messageData",waybillDTO);
map.put("createTime",new Date().getTime());
//把推送数据推入队列
rabbitTemplate.convertAndSend(RabbitConstant.WAYBILL_DATA_EXCHANGE, RabbitConstant.WAYBILL_DATA_ROUTING, map);
//把推送数据推入队列
rabbitTemplate.convertAndSend(RabbitConstant.WAYBILL_DATA_EXCHANGE, RabbitConstant.WAYBILL_DATA_ROUTING, map);
}
return R.success("调用成功");
}catch (CustomerException e){

9
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WaybillDTO.java

@ -3,8 +3,6 @@ package com.logpm.warehouse.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
public class WaybillDTO implements Serializable {
@ -14,9 +12,10 @@ public class WaybillDTO implements Serializable {
*/
private String waybillNo;
private List<ProductDTO> productList = new ArrayList<>();
/**
* 实际入库数量
*/
private Integer number;
}

4
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWayBillDetailService.java

@ -12,4 +12,8 @@ public interface IWarehouseWayBillDetailService {
void update(WarehouseWayBillDetail warehouseWayBillDetail);
List<WarehouseWayBillDetail> findByWaybillId(Long waybillId);
WarehouseWayBillDetail findByWaybillIdAndGoodsName(Long waybillId, String goodsName);
void addList(List<WarehouseWayBillDetail> ls);
}

12
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWayBillDetailServiceImpl.java

@ -40,4 +40,16 @@ public class WarehouseWayBillDetailServiceImpl implements IWarehouseWayBillDetai
queryWrapper.eq("waybill_id",waybillId);
return warehouseWayBillDetailMapper.selectList(queryWrapper);
}
@Override
public WarehouseWayBillDetail findByWaybillIdAndGoodsName(Long waybillId, String goodsName) {
return null;
}
@Override
public void addList(List<WarehouseWayBillDetail> ls) {
for (WarehouseWayBillDetail warehouseWayBillDetail:ls){
warehouseWayBillDetailMapper.insert(warehouseWayBillDetail);
}
}
}

87
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java

@ -14,7 +14,9 @@ import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.distribution.feign.IDistributionParcelListClient;
import com.logpm.distribution.feign.IDistributionStockArticleClient;
import com.logpm.oldproject.entity.WayBillEntity;
import com.logpm.oldproject.entity.WaybillDesEntity;
import com.logpm.oldproject.feign.IWayBillClient;
import com.logpm.oldproject.feign.IWaybillDesClient;
import com.logpm.warehouse.dto.ProductDTO;
import com.logpm.warehouse.dto.SplitOrderDTO;
import com.logpm.warehouse.dto.WaybillDTO;
@ -50,6 +52,7 @@ import java.util.Objects;
public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybillMapper, WarehouseWaybillEntity> implements IWarehouseWaybillService {
private final WarehouseWaybillMapper warehouseWaybillMapper;
private final IWayBillClient wayBillClient;
private final IWaybillDesClient waybillDesClient;
private final IBasicdataWarehouseClient basicdataWarehouseClient;
private final IBasicdataClientClient basicdataClientClient;
private final IBasicdataStoreBusinessClient basicdataStoreBusinessClient;
@ -67,15 +70,14 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
@Transactional(rollbackFor = Exception.class)
public void waybillDataHandler(WaybillDTO waybillDTO) {
String waybillNo = waybillDTO.getWaybillNo();
List<ProductDTO> productList = waybillDTO.getProductList();
Integer allNum = waybillDTO.getNumber();
Date date = new Date();
Integer allNum = 0;
Long waybillId = null;
boolean isOrder = false;
for (ProductDTO productDTO : productList) {
Integer num = productDTO.getNum();
allNum = allNum + num;
}
// for (ProductDTO productDTO : productList) {
// Integer num = productDTO.getNum();
// allNum = allNum + num;
// }
log.info("###############waybillDataHandler: 处理数据开始 waybillNo={}", waybillNo);
//通过运单号先去查询新系统是否存在这个运单号
@ -86,7 +88,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
//如果新系统中不存在这个运单,那么就去查询老系统的运单数据
WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNo);
if (Objects.isNull(wayBillEntity)) {
log.warn("##############waybillDataHandler: 老系统中找到对应运单waybillNo={}", waybillNo);
log.warn("##############waybillDataHandler: 老系统中找到对应运单waybillNo={}", waybillNo);
throw new CustomerException("老系统中未找到对应运单");
}
String startSite = wayBillEntity.getStartSite();//始发仓名称
@ -94,6 +96,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
String warehouseName = wayBillEntity.getWarehouseName();//目的仓
BasicdataWarehouseEntity endhouse = basicdataWarehouseClient.findByName(warehouseName);
Integer number = wayBillEntity.getNumber();//运单总数量
String packname = wayBillEntity.getPackname();
String agent = wayBillEntity.getAgent();
if (allNum.compareTo(number) > 0) {
log.warn("##############waybillDataHandler: 运单的总数量异常 allNum={} number={}", allNum, number);
@ -133,7 +136,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
warehouseWaybill.setConsigneeMobile(wayBillEntity.getTakeMobile());
warehouseWaybill.setConsigneeAddress(wayBillEntity.getTakeAddress());
warehouseWaybill.setDestination(wayBillEntity.getArriveSite());
warehouseWaybill.setGoodsName(wayBillEntity.getPackname());
warehouseWaybill.setGoodsName(packname);
warehouseWaybill.setTotalCount(number);
warehouseWaybill.setStockCount(allNum);
warehouseWaybill.setTotalWeight(wayBillEntity.getWeight());
@ -152,12 +155,30 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
warehouseWaybill.setRemark(wayBillEntity.getMsg());
warehouseWaybill.setBatchNo(wayBillEntity.getStartCarsNo());
warehouseWaybill.setFreezeStatus(0);
warehouseWaybill.setStatus(1);
warehouseWaybill.setStatus(0);
warehouseWaybill.setIsDeleted(0);
warehouseWaybill.setCreateTime(date);
warehouseWaybill.setUpdateTime(date);
warehouseWaybillMapper.insert(warehouseWaybill);
waybillId = warehouseWaybill.getId();
//新增的时候存入所有的订单详情
List<WaybillDesEntity> des = waybillDesClient.getDesList(waybillNo);
List<WarehouseWayBillDetail> ls = new ArrayList<>();
for (WaybillDesEntity waybillDesEntity : des) {
WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail();
warehouseWayBillDetail.setWaybillId(waybillId);
warehouseWayBillDetail.setWaybillNo(waybillNo);
warehouseWayBillDetail.setProductName(waybillDesEntity.getName());
warehouseWayBillDetail.setNum(waybillDesEntity.getNum());
warehouseWayBillDetail.setStatus(1);
warehouseWayBillDetail.setIsDeleted(0);
warehouseWayBillDetail.setCreateTime(date);
warehouseWayBillDetail.setUpdateTime(date);
ls.add(warehouseWayBillDetail);
}
warehouseWayBillDetailService.addList(ls);
//判断是否需要创建在库订单
if (allNum.compareTo(number) == 0) {
isOrder = true;
@ -179,28 +200,32 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
isOrder = true;
}
}
//处理运单明细
for (ProductDTO productDTO : productList) {
String productName = productDTO.getProductName();
Integer num = productDTO.getNum();
WarehouseWayBillDetail warehouseWayBillDetail = warehouseWayBillDetailService.findByProductName(productName);
if (Objects.isNull(warehouseWayBillDetail)) {
warehouseWayBillDetail = new WarehouseWayBillDetail();
warehouseWayBillDetail.setWaybillId(waybillId);
warehouseWayBillDetail.setWaybillNo(waybillNo);
warehouseWayBillDetail.setProductName(productName);
warehouseWayBillDetail.setNum(num);
warehouseWayBillDetail.setStatus(1);
warehouseWayBillDetail.setIsDeleted(0);
warehouseWayBillDetail.setCreateTime(date);
warehouseWayBillDetail.setUpdateTime(date);
warehouseWayBillDetailService.save(warehouseWayBillDetail);
} else {
warehouseWayBillDetail.setNum(warehouseWayBillDetail.getNum() + num);
warehouseWayBillDetail.setUpdateTime(date);
warehouseWayBillDetailService.update(warehouseWayBillDetail);
}
}
// String goodsName = warehouseWaybill.getGoodsName();
// //处理运单明细
// WarehouseWayBillDetail warehouseWayBillDetail = warehouseWayBillDetailService.findByWaybillIdAndGoodsName(waybillId,goodsName);
//
//
// for (ProductDTO productDTO : productList) {
// String productName = productDTO.getProductName();
// Integer num = productDTO.getNum();
//
// if (Objects.isNull(warehouseWayBillDetail)) {
// warehouseWayBillDetail = new WarehouseWayBillDetail();
// warehouseWayBillDetail.setWaybillId(waybillId);
// warehouseWayBillDetail.setWaybillNo(waybillNo);
// warehouseWayBillDetail.setProductName(productName);
// warehouseWayBillDetail.setNum(num);
// warehouseWayBillDetail.setStatus(1);
// warehouseWayBillDetail.setIsDeleted(0);
// warehouseWayBillDetail.setCreateTime(date);
// warehouseWayBillDetail.setUpdateTime(date);
// warehouseWayBillDetailService.save(warehouseWayBillDetail);
// } else {
// warehouseWayBillDetail.setNum(warehouseWayBillDetail.getNum() + num);
// warehouseWayBillDetail.setUpdateTime(date);
// warehouseWayBillDetailService.update(warehouseWayBillDetail);
// }
// }
if (isOrder) {
//创建在库订单

Loading…
Cancel
Save