Browse Source

1.同步订单数据更新

training
zhenghaoyu 1 year ago
parent
commit
a4e148605f
  1. 5
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java
  2. 80
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/OrderLocationEntity.java
  3. 2
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOldSystemDataPushClient.java
  4. 22
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderLocationClient.java
  5. 6
      blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseUpdownTypeClient.java
  6. 13
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java
  7. 22
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderLocationClient.java
  8. 9
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderLocationMapper.java
  9. 9
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderLocationService.java
  10. 29
      blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderLocationServiceImpl.java
  11. 34
      blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java
  12. 158
      blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncWarehouseData.java
  13. 5
      blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java
  14. 2
      blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/AsyncDataServiceImpl.java
  15. 529
      blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java
  16. 3
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseTrayTypeClient.java
  17. 34
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseUpdownTypeClient.java

5
blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java

@ -25,6 +25,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 货位 Feign接口类
*
@ -58,4 +60,7 @@ public interface IBasicdataGoodsAllocationClient {
void updateAllocationStatus(@RequestParam("allocationId") Long allocationId, @RequestParam("allocationStatus") String allocationStatus);
@GetMapping(API_PREFIX+"/getEntityByAllocationId")
BasicdataGoodsAllocationEntity getEntityByAllocationId(@RequestParam("allocationId") Long allocationId);
@GetMapping(API_PREFIX+"/findListByNewWarehouseId")
List<BasicdataGoodsAllocationEntity> findListByNewWarehouseId(@RequestParam Long newWarehouseId);
}

80
blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/OrderLocationEntity.java

@ -0,0 +1,80 @@
package com.logpm.oldproject.entity;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@TableName("ht_order_location")
@ApiModel(value = "订单货位对象", description = "订单信息")
public class OrderLocationEntity {
/** ID */
@TableId(
value = "id",
type = IdType.AUTO
)
private Integer id ;
/** 货位标识符 */
@ApiModelProperty(name = "货位标识符",notes = "")
private Integer locationId ;
/** 状态:1启用,0释放 */
@ApiModelProperty(name = "状态:1启用,0释放",notes = "")
private Integer status ;
/** 上架时间 */
@ApiModelProperty(name = "上架时间",notes = "")
private Date createTime ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date updateTime ;
/** 删除时间 */
@ApiModelProperty(name = "删除时间",notes = "")
private Integer deleteTime ;
/** 创建人 */
@ApiModelProperty(name = "创建人",notes = "")
private Integer administratorsId ;
/** 修改人 */
@ApiModelProperty(name = "修改人",notes = "")
private Integer updateAdministrators ;
/** 合同号 */
@ApiModelProperty(name = "合同号",notes = "")
private String serviceNum ;
/** 下架时间 */
@ApiModelProperty(name = "下架时间",notes = "")
private Date outTime ;
/** 下架备注 */
@ApiModelProperty(name = "下架备注",notes = "")
private String outRemark ;
/** 上架类型:1,按服务号上架,2按自编号上架,3,按包条码上架,4托盘码上架 */
@ApiModelProperty(name = "上架类型:1,按服务号上架,2按自编号上架,3,按包条码上架,4托盘码上架",notes = "")
private Integer type ;
/** 自编号 */
@ApiModelProperty(name = "自编号",notes = "")
private String selfnumber ;
/** 托盘码id */
@ApiModelProperty(name = "托盘码id",notes = "")
private Integer trayId ;
/** 包条码 */
@ApiModelProperty(name = "包条码",notes = "")
@TableField("unitNo")
private String unitNo ;
/** 托盘扫码id */
@ApiModelProperty(name = "托盘扫码id",notes = "")
private Integer trayScanId ;
/** */
@ApiModelProperty(name = "",notes = "")
private Integer oldId ;
/** 是否为零担:1=是,2=否 */
@ApiModelProperty(name = "是否为零担:1=是,2=否",notes = "")
private Integer isZero ;
/** 备注 */
@ApiModelProperty(name = "备注",notes = "")
private String remark ;
}

2
blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOldSystemDataPushClient.java

@ -24,6 +24,6 @@ public interface IOldSystemDataPushClient {
@PostMapping(API_PREFIX + "/pushOldSystemSignInfo")
@PostMapping(API_PREFIX + "/sendPackageData")
boolean sendPackageData(@RequestBody Map<String,Object> dataMap);
}

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

@ -0,0 +1,22 @@
package com.logpm.oldproject.feign;
import com.logpm.oldproject.entity.OrderLocationEntity;
import org.springblade.common.constant.ModuleNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(
value = ModuleNameConstant.APPLICATION_OLDPROJECT_NAME
)
public interface IOrderLocationClient {
String API_PREFIX = "/client";
String TOP = API_PREFIX + "/top3";
@GetMapping(API_PREFIX + "/findListByLocationId")
List<OrderLocationEntity> findListByLocationId(@RequestParam Integer locationId);
}

6
blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseUpdownTypeClient.java

@ -59,4 +59,10 @@ public interface IWarehouseUpdownTypeClient {
@GetMapping(TOP + "/downTray")
R downTray(@RequestParam("trayCode") String trayCode, @RequestParam("warehouseId") Long warehouseId);
@GetMapping(TOP + "/upShelfTray")
boolean upShelfTray(@RequestParam("trayCode") String trayCode, @RequestParam("locationId") Long locationId, @RequestParam("warehouseId") Long warehouseId);
@GetMapping(TOP + "/upShelfPackage")
boolean upShelfPackage(@RequestParam String orderPackageCode, @RequestParam Long locationId, @RequestParam Long warehouseId);
}

13
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java

@ -16,6 +16,7 @@
*/
package com.logpm.basicdata.feign;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataGoodsAllocationEntity;
@ -28,6 +29,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* 货位 Feign实现类
*
@ -79,4 +82,14 @@ public class BasicdataGoodsAllocationClient implements IBasicdataGoodsAllocation
return BasicdataGoodsAllocationService.getById(allocationId);
}
@Override
public List<BasicdataGoodsAllocationEntity> findListByNewWarehouseId(Long newWarehouseId) {
QueryWrapper<BasicdataGoodsAllocationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("warehouse_id",newWarehouseId)
.eq("enable_status","1")
.eq("allocation_status","1")
.eq("is_deleted",0);
return BasicdataGoodsAllocationService.list(queryWrapper);
}
}

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

@ -0,0 +1,22 @@
package com.logpm.oldproject.feign;
import com.logpm.oldproject.entity.OrderLocationEntity;
import com.logpm.oldproject.service.IOrderLocationService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
@ApiIgnore()
@RestController
@AllArgsConstructor
public class OrderLocationClient implements IOrderLocationClient{
private final IOrderLocationService orderLocationService;
@Override
public List<OrderLocationEntity> findListByLocationId(Integer locationId) {
return orderLocationService.findListByLocationId(locationId);
}
}

9
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderLocationMapper.java

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

9
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderLocationService.java

@ -0,0 +1,9 @@
package com.logpm.oldproject.service;
import com.logpm.oldproject.entity.OrderLocationEntity;
import java.util.List;
public interface IOrderLocationService {
List<OrderLocationEntity> findListByLocationId(Integer locationId);
}

29
blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderLocationServiceImpl.java

@ -0,0 +1,29 @@
package com.logpm.oldproject.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.oldproject.entity.OrderLocationEntity;
import com.logpm.oldproject.mapper.OrderLocationMapper;
import com.logpm.oldproject.service.IOrderLocationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@AllArgsConstructor
public class OrderLocationServiceImpl implements IOrderLocationService {
private final OrderLocationMapper orderLocationMapper;
@Override
public List<OrderLocationEntity> findListByLocationId(Integer locationId) {
QueryWrapper<OrderLocationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status",1)
.eq("is_zero",2)
.eq("location_id",locationId)
.orderByDesc("type");
return orderLocationMapper.selectList(queryWrapper);
}
}

34
blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java

@ -51,7 +51,6 @@ public class SyncOrderInfoToPlatform {
for (WarehouseMappingDataEntity mappingDataEntity:warehouseMappingDataEntityList){
Integer oldWarehouseId = mappingDataEntity.getOldWarehouseId();//老系统仓库id
Long newWarehouseId = mappingDataEntity.getNewWarehouseId();//新系统仓库id
Integer inventoryId = mappingDataEntity.getInventoryId();
//查询新系统是否已有仓库信息
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(newWarehouseId);
@ -106,7 +105,7 @@ public class SyncOrderInfoToPlatform {
try{
List<String> orderCodeList = orderClient.findOrderCodeListByPage(param,oldWarehouseId,j,pageSize);
syncOrderInfoService.handleData(orderCodeList,oldWarehouseId,newWarehouseId,inventoryId);
syncOrderInfoService.handleData(orderCodeList,oldWarehouseId,newWarehouseId);
log.info("################syncOrderInfo: 同步成功{}个订单",orderCodeList.size());
one.setCurrentPage(j+1);
@ -130,6 +129,37 @@ public class SyncOrderInfoToPlatform {
return ReturnT.SUCCESS;
}
@XxlJob("syncUpdownData")
public ReturnT<String> syncUpdownData(String param) {
//查询需要同步的仓库
List<WarehouseMappingDataEntity> warehouseMappingDataEntityList = warehouseMappingDataService.getWarehouseMapping();
if(warehouseMappingDataEntityList.isEmpty()){
log.warn("###############syncUpdownData: 当前没有配置需要同步的仓库信息");
return ReturnT.FAIL;
}
for (WarehouseMappingDataEntity mappingDataEntity:warehouseMappingDataEntityList){
Long newWarehouseId = mappingDataEntity.getNewWarehouseId();
Integer oldWarehouseId = mappingDataEntity.getOldWarehouseId();
try{
//同步上架信息
syncOrderInfoService.syncUpdownData(oldWarehouseId,newWarehouseId);
}catch (CustomerException e){
log.error(e.message,e);
return ReturnT.FAIL;
}catch (Exception e){
log.error("#############syncUpdownData: 同步数据失败",e);
return ReturnT.FAIL;
}
}
log.error("#############syncUpdownData: 同步上架数据完成");
return ReturnT.SUCCESS;
}
@XxlJob("syncZeroOrderInfo")

158
blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncWarehouseData.java

@ -0,0 +1,158 @@
package com.logpm.patch.jobhandle;
import com.logpm.basicdata.entity.BasicdataGoodsAllocationEntity;
import com.logpm.basicdata.entity.BasicdataGoodsAreaEntity;
import com.logpm.basicdata.entity.BasicdataGoodsShelfEntity;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.*;
import com.logpm.oldproject.entity.CargoEntity;
import com.logpm.oldproject.entity.LocationEntity;
import com.logpm.oldproject.entity.ShelfEntity;
import com.logpm.oldproject.feign.*;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
@AllArgsConstructor
@Component
public class SyncWarehouseData {
//-----------------新系统
private final IBasicdataWarehouseClient basicdataWarehouseClient;//仓库
private final IBasicdataGoodsAreaClient basicdataGoodsAreaClient;//货区
private final IBasicdataGoodsShelfClient basicdataGoodsShelfClient;//货架
private final IBasicdataGoodsAllocationClient basicdataGoodsAllocationClient;//货位
private final IBasicdataTrayClient basicdataTrayClient;//托盘
//-----------------老系统
private final IWarehouseClient warehouseClient;//仓库
private final ICargoClient cargoClient;//货区
private final IShelfClient shelfClient;//货架
private final ILocationClient locationClient;//货位
private final ITrayClient trayClient;//托盘
@XxlJob("syncAllocationInfo")
public ReturnT<String> syncAllocationInfo(String param) {
log.info("####################syncAllocationInfo: 同步库位信息开始");
if(StringUtil.isBlank(param)){
log.warn("#############syncAllocationInfo: 仓库参数为空");
return ReturnT.FAIL;
}
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(Long.parseLong(param));
Long warehouseId = basicdataWarehouseEntity.getId();
Integer oldId = basicdataWarehouseEntity.getOldId();
boolean b = saveAllocationData(warehouseId, oldId);
if(!b){
return ReturnT.FAIL;
}else {
return ReturnT.SUCCESS;
}
}
private boolean saveAllocationData(Long newWarehouseId, Integer oldWarehouseId) {
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(newWarehouseId);
//通过老系统仓库id去查有哪些货区
List<CargoEntity> cargoEntityList = cargoClient.getAllByWarehouseId(oldWarehouseId);
for (CargoEntity cargoEntity:cargoEntityList){
//货区数据存储
Integer cargoId = cargoEntity.getId();//老系统货区id
BasicdataGoodsAreaEntity goodsAreaEntity = new BasicdataGoodsAreaEntity();
goodsAreaEntity.setTenantId("627683");
goodsAreaEntity.setCreateUser(1714696768639311873L);
goodsAreaEntity.setUpdateUser(1714696768639311873L);
goodsAreaEntity.setCreateDept(1649331096241836033L);
goodsAreaEntity.setWarehouseId(newWarehouseId);
goodsAreaEntity.setHeadline(cargoEntity.getTitle());
goodsAreaEntity.setEnableStatus("1");
goodsAreaEntity.setAreaType("2");
goodsAreaEntity.setOldId(cargoId);
Long newAreaId = basicdataGoodsAreaClient.addCargo(goodsAreaEntity);
if(Objects.isNull(newAreaId)){
log.warn("#################saveAllocationData: 保存货区信息失败cargoId={},oldWarehouseId={}",cargoId,oldWarehouseId);
return false;
}else{
//货架数据存储
//通过老系统货区id查询所有货架
Map<Integer,Integer> shelfIsEmptyMap = new HashMap<>();
shelfIsEmptyMap.put(1,1);
shelfIsEmptyMap.put(0,2);
List<ShelfEntity> shelfEntityList = shelfClient.getAllByWarehouseIdAndCargoId(cargoId);
for (ShelfEntity shelfEntity:shelfEntityList){
Integer oldShelfId = shelfEntity.getId();
//通过货架id查询最大行数和列数
Map<String,Integer> storeyAndRow = locationClient.getStoreyAndRowByShelfId(oldShelfId);
//存入新系统货架信息
BasicdataGoodsShelfEntity goodsShelfEntity = new BasicdataGoodsShelfEntity();
goodsShelfEntity.setTenantId("627683");
goodsShelfEntity.setCreateUser(1714696768639311873L);
goodsShelfEntity.setUpdateUser(1714696768639311873L);
goodsShelfEntity.setCreateDept(1649331096241836033L);
goodsShelfEntity.setGoodsAreaId(newAreaId);
goodsShelfEntity.setGoodsShelfName(shelfEntity.getTitle());
goodsShelfEntity.setWarehouseId(newWarehouseId);
goodsShelfEntity.setWarehouseCode(warehouseEntity.getWarehouseCode());
goodsShelfEntity.setGoodsShelfStatus(2);
goodsShelfEntity.setEnableStatus(1);
goodsShelfEntity.setStoreyNum(storeyAndRow.get("storey"));
goodsShelfEntity.setRowNum(storeyAndRow.get("row"));
goodsShelfEntity.setRemarks("");
goodsShelfEntity.setOldId(oldShelfId);
Long newShelfId = basicdataGoodsShelfClient.addShelf(goodsShelfEntity);
if(Objects.isNull(newShelfId)){
log.warn("#################saveAllocationData: 保存货架信息失败oldShelfId={},oldWarehouseId={}",oldShelfId,oldWarehouseId);
return false;
}else{
//货位数据存储
Map<Integer,Integer> locationIsEmptyMap = new HashMap<>();
locationIsEmptyMap.put(1,2);
locationIsEmptyMap.put(0,1);
List<LocationEntity> locationEntities = locationClient.getAllByShelfId(oldShelfId);
// List<BasicdataGoodsAllocationEntity> newLocations = new ArrayList<>();
for (LocationEntity locationEntity:locationEntities){
Integer locationId = locationEntity.getId();
BasicdataGoodsAllocationEntity entity = new BasicdataGoodsAllocationEntity();
entity.setTenantId("627683");
entity.setId(locationId.longValue());
entity.setCreateUser(1714696768639311873L);
entity.setUpdateUser(1714696768639311873L);
entity.setCreateDept(1649331096241836033L);
entity.setGoodsAreaId(newAreaId);
entity.setGoodsAllocationName(locationEntity.getTitle());
entity.setWarehouseId(newWarehouseId);
entity.setGoodsShelfId(newShelfId);
entity.setEnableStatus("1");
entity.setAllocationStatus("1");
entity.setLayerNum(locationEntity.getFloor());
entity.setColumnNum(locationEntity.getRow());
entity.setOldId(locationId);
Long newLocationId = basicdataGoodsAllocationClient.addLocation(entity);
if(Objects.isNull(newLocationId)){
log.warn("#################saveAllocationData: 保存货位信息失败locationId={},oldWarehouseId={}",locationId,oldWarehouseId);
return false;
}else{
log.info("#################saveAllocationData: 保存货位信息成功locationId={},oldWarehouseId={}",locationId,oldWarehouseId);
}
}
}
}
}
}
return true;
}
}

5
blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java

@ -3,7 +3,7 @@ package com.logpm.patch.service;
import java.util.List;
public interface ISyncOrderInfoService {
void handleData(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId,Integer inventoryId);
void handleData(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId);
void handleDataZero(List<String> orderCodeList, Integer oldWarehouseId, Long newWarehouseId);
@ -13,4 +13,7 @@ public interface ISyncOrderInfoService {
void supplementOrderInfo(String orderCode, Long newWarehouseId, Integer oldWarehouseId);
void handleDataAndInventoryId(List<String> orderCodeList, Integer oldWarehouseId, Long newWarehouseId, Integer inventoryId);
void syncUpdownData(Integer oldWarehouseId, Long newWarehouseId);
}

2
blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/AsyncDataServiceImpl.java

@ -106,7 +106,7 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
try{
List<String> orderCodeList = orderClient.findOrderCodeListByPage("",oldWarehouseId,j,pageSize);
syncOrderInfoService.handleData(orderCodeList,oldWarehouseId,newWarehouseId,inventoryId);
syncOrderInfoService.handleDataAndInventoryId(orderCodeList,oldWarehouseId,newWarehouseId,inventoryId);
log.info("################syncOrderInfo: 同步成功{}个订单",orderCodeList.size());
one.setCurrentPage(j+1);

529
blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java

@ -4,14 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.logpm.basic.entity.BasicMaterialEntity;
import com.logpm.basic.feign.IBasicMaterialClient;
import com.logpm.basicdata.entity.BasicdataClientEntity;
import com.logpm.basicdata.entity.BasicdataStoreBusinessEntity;
import com.logpm.basicdata.entity.BasicdataTrayEntity;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataClientClient;
import com.logpm.basicdata.feign.IBasicdataStoreBusinessClient;
import com.logpm.basicdata.feign.IBasicdataTrayClient;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.basicdata.entity.*;
import com.logpm.basicdata.feign.*;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionParcelNumberEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
@ -25,6 +19,7 @@ import com.logpm.patch.service.ISyncOrderInfoService;
import com.logpm.warehouse.entity.WarehouseWayBillDetail;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import com.logpm.warehouse.feign.IWarehouseTrayTypeClient;
import com.logpm.warehouse.feign.IWarehouseUpdownTypeClient;
import com.logpm.warehouse.feign.IWarehouseWaybillClient;
import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient;
import lombok.AllArgsConstructor;
@ -69,29 +64,32 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
private final IInventoryDetailClient inventoryDetailClient;
private final IBasicdataTrayClient basicdataTrayClient;
private final ITrayClient trayClient;
private final IBasicdataGoodsAllocationClient basicdataGoodsAllocationClient;
private final IOrderLocationClient orderLocationClient;
private final IWarehouseUpdownTypeClient warehouseUpdownTypeClient;
@Transactional(rollbackFor = Exception.class)
@Override
public void handleData(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId,Integer inventoryId) {
public void handleData(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId) {
log.info("#############handleData: 处理订单开始");
for (String orderCode:orderCodeList){
log.info("#############handleData: 当前处理orderCode={}的订单 盘点任务 inventoryId={}",orderCode,inventoryId);
log.info("#############handleData: 当前处理orderCode={}的订单 ",orderCode);
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode);
// if(!Objects.isNull(stockArticleEntity)){
// log.info("#############handleData: 订单orderCode={}已存在",orderCode);
// continue;
// }
//查询订单是否在盘点任务中有被盘点到
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode,inventoryId);
if(!Objects.isNull(inventoryDetailEntity)){
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode,inventoryId);
// if(!Objects.isNull(inventoryDetailEntity)){
try{
//定单
saveOrderInfo(orderCode,oldWarehouseId,newWarehouseId,inventoryId);
saveOrderInfo(orderCode,oldWarehouseId,newWarehouseId);
//存入打托信息
// saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId);
saveTrayTypeInfoPackageNew(orderCode,oldWarehouseId,newWarehouseId,inventoryId);
saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId);
}catch (CustomerException e){
log.error("同步订单"+orderCode+"失败: "+e.message,e);
@ -99,10 +97,84 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
log.error("同步订单"+orderCode+"失败",e);
}
// }
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public void handleDataAndInventoryId(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId,Integer inventoryId) {
log.info("#############handleData: 处理订单开始");
for (String orderCode:orderCodeList){
log.info("#############handleData: 当前处理orderCode={}的订单 盘点任务 inventoryId={}",orderCode,inventoryId);
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode);
// if(!Objects.isNull(stockArticleEntity)){
// log.info("#############handleData: 订单orderCode={}已存在",orderCode);
// continue;
// }
//查询订单是否在盘点任务中有被盘点到
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode,inventoryId);
// if(!Objects.isNull(inventoryDetailEntity)){
try{
//定单
saveOrderInfoAndInventoryId(orderCode,oldWarehouseId,newWarehouseId,inventoryId);
//存入打托信息
// saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId);
saveTrayTypeInfoPackageNew(orderCode,oldWarehouseId,newWarehouseId,inventoryId);
}catch (CustomerException e){
log.error("同步订单"+orderCode+"失败: "+e.message,e);
}catch (Exception e){
log.error("同步订单"+orderCode+"失败",e);
}
// }
}
}
@Override
public void syncUpdownData(Integer oldWarehouseId, Long newWarehouseId) {
//先查询有多少个货位
List<BasicdataGoodsAllocationEntity> ls = basicdataGoodsAllocationClient.findListByNewWarehouseId(newWarehouseId);
for (BasicdataGoodsAllocationEntity basicdataGoodsAllocationEntity:ls){
Long locationId = basicdataGoodsAllocationEntity.getId();
List<OrderLocationEntity> orderLocationEntityList = orderLocationClient.findListByLocationId(locationId.intValue());
for (OrderLocationEntity orderLocationEntity:orderLocationEntityList){
Integer type = orderLocationEntity.getType();
if(type == 4){
//整托上架
Integer trayId = orderLocationEntity.getTrayId();
String trayCode = "T"+trayId;
boolean a=warehouseUpdownTypeClient.upShelfTray(trayCode,locationId,newWarehouseId);
if(a){
log.info("#############syncUpdownData: 上架托盘成功 trayCode={} locationId={}",trayCode,locationId);
}else{
log.error("#############syncUpdownData: XXXX上架托盘失败 trayCode={} locationId={}",trayCode,locationId);
}
}else{
String orderPackageCode = orderLocationEntity.getUnitNo();
boolean a=warehouseUpdownTypeClient.upShelfPackage(orderPackageCode,locationId,newWarehouseId);
if(a){
log.info("#############syncUpdownData: 上架包件成功 orderPackageCode={} locationId={}",orderPackageCode,locationId);
}else{
log.error("#############syncUpdownData: XXXX上架包件失败 orderPackageCode={} locationId={}",orderPackageCode,locationId);
}
}
}
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public void handleDataZero(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId) {
@ -459,15 +531,31 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
Integer trayScanId = trayScanDesEntity.getTrayScanId();
String unitNo = trayScanDesEntity.getUnitNo();//包条码
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo);
// if(Objects.isNull(inventoryDetailEntity)){
// log.info("###########saveTrayTypeInfoPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo);
// continue;
// }
//查询打托方式信息
TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId);
Integer type = trayScanEntity.getType();
Integer trayId = trayScanEntity.getTrayId();
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.getTrayByTrayCode("T" + trayId);
if(Objects.isNull(basicdataTrayEntity)){
log.info("############syncTrayTypeData: 托盘信息不存在");
//如果托盘不存在就去同步该托盘
TrayEntity trayEntity = trayClient.getTrayById(trayId);
basicdataTrayEntity = new BasicdataTrayEntity();
basicdataTrayEntity.setTenantId("627683");
basicdataTrayEntity.setCreateUser(1714696768639311873L);
basicdataTrayEntity.setUpdateUser(1714696768639311873L);
basicdataTrayEntity.setCreateDept(1649331096241836033L);
basicdataTrayEntity.setPalletName(trayEntity.getTrayNo());
basicdataTrayEntity.setPalletCode("T"+trayId);
basicdataTrayEntity.setWarehouseId(newWarehouseId);
basicdataTrayEntity.setTrayStatus(trayEntity.getStatus()+"");
basicdataTrayEntity.setType(1);
basicdataTrayEntity.setOldId(trayId);
// basicdataTrayEntity.setNowWarehouseId(nowNewWarehouseId);
basicdataTrayClient.addTray(basicdataTrayEntity);
}
String customerName = trayScanEntity.getCustomerName();
String customerPhone = trayScanEntity.getCustomerPhone();
@ -880,7 +968,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
private void saveOrderInfo(String orderCode, Integer oldWarehouseId, Long newWarehouseId,Integer inventoryId) {
private void saveOrderInfoAndInventoryId(String orderCode, Integer oldWarehouseId, Long newWarehouseId,Integer inventoryId) {
//通过订单号查询暂存单
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderCode);
@ -890,7 +978,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
Integer advanceId = advanceEntity.getId();
//判断新系统是否有这条订单数据
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findByAdvanceId(advanceId);
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode,newWarehouseId);
OrderCountEntity orderCountEntity = orderCountClient.getEntityByOrderCode(orderCode,oldWarehouseId);
if(Objects.isNull(orderCountEntity)){
@ -900,17 +988,12 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
Integer total = orderCountEntity.getTotal();
WayBillEntity wayBillEntity = wayBillClient.getByWayBillByAdvanceId(advanceId);
// if(Objects.isNull(wayBillEntity)){
// log.warn("#################saveOrderInfo: 未查询到运单信息 advanceId={}",advanceId);
// throw new CustomerException(403,"未查询到运单信息");
// }
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(newWarehouseId);
if(Objects.isNull(basicdataWarehouseEntity)){
log.warn("#################saveOrderInfo: 未查询到仓库信息 newWarehouseId={}",newWarehouseId);
throw new CustomerException(403,"未查询到仓库信息");
}
Long id;
String wayBillNo = null;
@ -919,34 +1002,15 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
distributionStockArticleEntity = new DistributionStockArticleEntity();
distributionStockArticleEntity.setOrderCode(orderCode);
// 其实是客户
// distributionStockArticleEntity.setMallName(advanceEntity.getDealerName());
distributionStockArticleEntity.setWarehouseEntryTime(orderCountEntity.getCreateTime());
distributionStockArticleEntity.setWarehouseEntryTimeEnd(orderCountEntity.getLatestInTime());
distributionStockArticleEntity.setTotalNumber(total);
distributionStockArticleEntity.setHandQuantity(orderCountEntity.getInNum());
distributionStockArticleEntity.setHandQuantity(0);
distributionStockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID
// distributionStockArticleEntity.setWaybillNumber();// 运单号
//判断是否齐套 查询该订单自编号下面的包件是都全部都交由汇通了
Integer allNum = advanceDetailClient.getAllNumByOrderNo(orderCode);
if (total.equals(allNum)) {
//如果数据库中的数据和订单上的数量相等就是齐套
distributionStockArticleEntity.setCompleteSet(1);
} else {
distributionStockArticleEntity.setCompleteSet(0);
}
log.info("############saveOrderInfo {}", basicdataWarehouseEntity);
distributionStockArticleEntity.setCreateDept(basicdataWarehouseEntity.getDepartment());
distributionStockArticleEntity.setConsigneeUnit(advanceEntity.getDealerName());//收货单位(经销商)
distributionStockArticleEntity.setConsigneePerson(advanceEntity.getCustomerName());//收货人
distributionStockArticleEntity.setConsigneeAddress(advanceEntity.getCustomerRoad());//收货人地址
distributionStockArticleEntity.setConsigneeMobile(advanceEntity.getCustomerPhone());//收货人电话
distributionStockArticleEntity.setWarehouse(basicdataWarehouseEntity.getName());
distributionStockArticleEntity.setWarehouseId(basicdataWarehouseEntity.getId());
distributionStockArticleEntity.setDealerCode(advanceEntity.getDealerCode());
@ -975,14 +1039,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
if(ObjectUtils.isNotNull(t)){
distributionStockArticleEntity.setAcceptWarehouseName(t.getName());
distributionStockArticleEntity.setAcceptWarehouseId(t.getId());
// TODO 这里存在问题 后需要知道当前作业仓库
// distributionStockArticleEntity.setWarehouse(t.getName());
// distributionStockArticleEntity.setWarehouseId(t.getId());
}
String customerName = wayBillEntity.getTakeCompany();//客户名称
distributionStockArticleEntity.setTypeService("1");//默认商配
BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findByName(customerName);
log.info("订单同步出现的客户编号{} 匹配的客户", basicdataClientEntity);
if (!Objects.isNull(basicdataClientEntity)) {
@ -991,11 +1052,6 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
distributionStockArticleEntity.setMallName(basicdataClientEntity.getClientName());
distributionStockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
// distributionStockArticleEntity.setDealerCode(basicdataClientEntity.getClientCode());
// distributionStockArticleEntity.setDealerName(basicdataClientEntity.getClientName());
// todo 这里需要去查询门店 和新系统的门店ID 进行绑定
String peisongType = getPeisongTypeByClientId(basicdataClientEntity.getId());
log.info("订单同步peisongType {} ", peisongType);
@ -1004,69 +1060,270 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
}
}
distributionStockArticleEntity.setGenre(1);
distributionStockArticleEntity.setAdvanceId(advanceId);
//--------------2023-07-06 新增字段处理
// 增加订单 经销商信息 和门店信息
buildDealerAndStore(distributionStockArticleEntity, advanceEntity);
//通过客户名称去查询客户的服务类型、
distributionStockArticleEntity.setTypeService("1");//默认商配
distributionStockArticleEntity.setCreateUser(1714696768639311873L);
distributionStockArticleEntity.setUpdateUser(1714696768639311873L);
distributionStockArticleEntity.setCreateDept(1649331096241836033L);
distributionStockArticleEntity.setSortingQuantity(0); //分拣件数
distributionStockArticleEntity.setDeliveryQuantity(0); //配送件数
distributionStockArticleEntity.setTransferQuantity(0); //中转件数
distributionStockArticleEntity.setSigninQuantity(0); //签收件数
//1=部分入库,2=已入库,3=已出库,4=部分签收,5=待出库,6=已上架,7=已分拣,8=部分出库,9=部分装车,10=已装车,11=已签收,12=部分配送,13=已配送
distributionStockArticleEntity.setFreezeStatus(OrderFreezeStatusConstant.weidongjie.getValue()); //冻结状态
distributionStockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue()); //预约状态
distributionStockArticleEntity.setStockupStatus(OrderStockupStatusConstant.daibeihuo.getValue()); //备货状态
distributionStockArticleEntity.setGroundingStatus(OrderGroundingStatusConstant.daishangjia.getValue()); //上架状态
// BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findByName(customerName);
// log.info("订单同步出现的客户编号{} 匹配的客户", basicdataClientEntity);
// if (!Objects.isNull(basicdataClientEntity)) {
// //商城
// distributionStockArticleEntity.setMallId(basicdataClientEntity.getId());
// distributionStockArticleEntity.setMallName(basicdataClientEntity.getClientName());
// distributionStockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
//
// distributionStockArticleEntity.setDealerCode(basicdataClientEntity.getClientCode());
// distributionStockArticleEntity.setDealerName(basicdataClientEntity.getClientName());
//
//
// // todo 这里需要去查询门店 和新系统的门店ID 进行绑定
// String peisongType = getPeisongTypeByClientId(basicdataClientEntity.getId());
// log.info("订单同步peisongType {} ", peisongType);
//
// if (StringUtil.isNoneBlank(peisongType)) {
// distributionStockArticleEntity.setTypeService(peisongType);
// }
distributionStockArticleEntity.setWarehouseEntryTime(date);
id = distributionStockArticleClient.addData(distributionStockArticleEntity);
distributionStockArticleEntity.setId(id);
if (id == 0) {
log.warn("#################handleDataToPlatform: 保存订单信息失败 orderCode={}", orderCode);
throw new CustomerException(405, "保存订单信息失败");
}
}else{
id = distributionStockArticleEntity.getId();
}
//保存包件信息
saveOrderPackageAndInventoryId(distributionStockArticleEntity,basicdataWarehouseEntity,wayBillNo,CommonUtil.dateToString(new Date()),oldWarehouseId,inventoryId);
}
private void saveOrderPackageAndInventoryId(DistributionStockArticleEntity distributionStockArticleEntity, BasicdataWarehouseEntity basicdataWarehouseEntity, String waybillNo,String operationTime,Integer oldWarehouseId,Integer inventoryId) {
String orderCode = distributionStockArticleEntity.getOrderCode();
//查询订单下的所有包件
List<OrderDetailEntity> orderDetailList = orderDetailClient.findByOrderCode(orderCode,oldWarehouseId);
for (OrderDetailEntity orderDetailEntity:orderDetailList){
String unitNo = orderDetailEntity.getUnitNo();
DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCode(unitNo);
if(!Objects.isNull(parcelListEntity)){
log.info("###########saveOrderPackageAndInventoryId: 包条已存在,不同步 unitNo={}",unitNo);
continue;
}
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo,inventoryId);
if(Objects.isNull(inventoryDetailEntity)){
log.info("###########saveOrderPackageAndInventoryId: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo);
continue;
}
Integer status = orderDetailEntity.getStatus();
Integer carsType = orderDetailEntity.getCarsType();
Integer signState = orderDetailEntity.getSignState();
waybillNo = orderDetailEntity.getWaybillNo();
//存入运单信息
WayBillEntity waybillEntity = saveWaybillEntity(waybillNo);
DistributionParcelListEntityVO vo = advanceDetailClient.getByUnitNoAndWarehouseId(unitNo,oldWarehouseId);
DistributionParcelListEntity entity = new DistributionParcelListEntity();
BeanUtil.copyProperties(vo, entity);
entity.setOrderPackageCode(vo.getPacketBarCode());
entity.setConditions(1);
entity.setWarehouse(distributionStockArticleEntity.getWarehouse());
entity.setWarehouseId(distributionStockArticleEntity.getWarehouseId());
entity.setStockArticleId(distributionStockArticleEntity.getId());
entity.setOrderPackageStatus(OrderPackageStatusConstant.yiruku.getValue());
//状态:1到货,2分拣,3装车,4卸货,5出库,6配送
// if(1 == status){
// entity.setOrderPackageStatus(OrderPackageStatusConstant.yiruku.getValue());
// }
// if(3==carsType||4 == carsType){
// entity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue());
// }
if(2 == signState){
entity.setOrderPackageStatus(OrderPackageStatusConstant.yiqianshou.getValue());
}
entity.setOrderPackageFreezeStatus(OrderPackageFreezeStatusConstant.weidongjie.getValue());
entity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue());
entity.setOrderPackageGroundingStatus(OrderPackageGroundingStatusConstant.daishangjia.getValue());
entity.setOrderPackageStockupStatus(OrderPackageStockupStatusConstant.daibeihuo.getValue());
entity.setOrderCode(distributionStockArticleEntity.getOrderCode());
entity.setServiceNumber(distributionStockArticleEntity.getServiceNumber());
entity.setWaybillNumber(waybillNo);
// 增加 进销商 名称 编码 发站仓
entity.setSendWarehouseName(distributionStockArticleEntity.getSendWarehouseName());
entity.setSendWarehouseId(distributionStockArticleEntity.getSendWarehouseId());
//收货仓库
entity.setAcceptWarehouseName(distributionStockArticleEntity.getAcceptWarehouseName());
entity.setAcceptWarehouseId(distributionStockArticleEntity.getAcceptWarehouseId());
//进销售
entity.setDealerCode(distributionStockArticleEntity.getDealerCode());
entity.setDealerName(distributionStockArticleEntity.getDealerName());
entity.setWarehouseEntryTimeEnd(CommonUtil.StringToDate(operationTime));
entity.setMaterialCode(vo.getMaterialCode());
entity.setMaterialName(vo.getMaterialName());
entity.setCreateUser(1714696768639311873L);
entity.setUpdateUser(1714696768639311873L);
entity.setCreateDept(1649331096241836033L);
entity.setTenantId(TenantNum.HUITONGCODE);
if (StringUtil.isNotBlank(entity.getMaterialName()) && StringUtil.isNotBlank(entity.getMaterialCode())) {
// 查询物料信息
String sku = "";
BasicMaterialEntity basicMaterialEntity = basicMaterialClient.getMaterialOwn(entity.getMaterialCode(), entity.getMaterialName(), sku);
if (ObjectUtils.isNotNull(basicMaterialEntity)) {
entity.setMaterialId(basicMaterialEntity.getId());
entity.setMaterialCode(basicMaterialEntity.getProductCode());
entity.setMaterialUnit(basicMaterialEntity.getLogpmUnit());
}
}
boolean b = distributionParcelListClient.add(entity);
if (!b) {
log.warn("#################saveOrderPackageAndInventoryId: 保存包件信息失败 orderCode={}", entity.getOrderCode());
}else{
log.info("################saveOrderPackageAndInventoryId: 保存包件成功 OrderPackageCode={}",vo.getPacketBarCode());
Integer handQuantity = distributionStockArticleEntity.getHandQuantity();
Integer totalNumber = distributionStockArticleEntity.getTotalNumber();
if(handQuantity+1 >= totalNumber){
distributionStockArticleEntity.setCompleteSet(1);
distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.yishouhuo.getValue());
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue());
}else{
distributionStockArticleEntity.setCompleteSet(0);
distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.bufenshouhuo.getValue());
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.bufenruku.getValue());
}
distributionStockArticleClient.saveOrUpdate(distributionStockArticleEntity);
}
}
}
private void saveOrderInfo(String orderCode, Integer oldWarehouseId, Long newWarehouseId) {
//通过订单号查询暂存单
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderCode);
if(Objects.isNull(advanceEntity)){
log.warn("#################saveOrderInfo: 未查询单订单信息 orderCode={}",orderCode);
throw new CustomerException(403,"未查询单订单信息");
}
Integer advanceId = advanceEntity.getId();
//判断新系统是否有这条订单数据
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode,newWarehouseId);
OrderCountEntity orderCountEntity = orderCountClient.getEntityByOrderCode(orderCode,oldWarehouseId);
if(Objects.isNull(orderCountEntity)){
log.warn("#################saveOrderInfo: 未查询单订单信息 orderCode={}",orderCode);
throw new CustomerException(403,"未查询单订单信息");
}
Integer total = orderCountEntity.getTotal();
WayBillEntity wayBillEntity = wayBillClient.getByWayBillByAdvanceId(advanceId);
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(newWarehouseId);
if(Objects.isNull(basicdataWarehouseEntity)){
log.warn("#################saveOrderInfo: 未查询到仓库信息 newWarehouseId={}",newWarehouseId);
throw new CustomerException(403,"未查询到仓库信息");
}
Long id;
String wayBillNo = null;
if (Objects.isNull(distributionStockArticleEntity)) {
Date date = new Date();
distributionStockArticleEntity = new DistributionStockArticleEntity();
distributionStockArticleEntity.setOrderCode(orderCode);
distributionStockArticleEntity.setWarehouseEntryTime(orderCountEntity.getCreateTime());
distributionStockArticleEntity.setWarehouseEntryTimeEnd(orderCountEntity.getLatestInTime());
distributionStockArticleEntity.setTotalNumber(total);
distributionStockArticleEntity.setHandQuantity(0);
distributionStockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID
log.info("############saveOrderInfo {}", basicdataWarehouseEntity);
distributionStockArticleEntity.setCreateDept(basicdataWarehouseEntity.getDepartment());
distributionStockArticleEntity.setWarehouse(basicdataWarehouseEntity.getName());
distributionStockArticleEntity.setWarehouseId(basicdataWarehouseEntity.getId());
distributionStockArticleEntity.setDealerCode(advanceEntity.getDealerCode());
distributionStockArticleEntity.setDealerName(advanceEntity.getDealerName());
if (ObjectUtils.isNotNull(wayBillEntity)) {
distributionStockArticleEntity.setConsigneeUnit(wayBillEntity.getTakeCompany());//收货单位(经销商)
distributionStockArticleEntity.setConsigneePerson(wayBillEntity.getTakePerson());//收货人
distributionStockArticleEntity.setConsigneeAddress(wayBillEntity.getTakeAddress());//收货人地址
distributionStockArticleEntity.setConsigneeMobile(wayBillEntity.getTakePhone());//收货人电话
wayBillNo = wayBillEntity.getWaybillNo();
distributionStockArticleEntity.setWaybillNumber(wayBillNo);
// 根据老运单上的仓库名称找寻新的仓库名称
// 发站
String warehouseName = wayBillEntity.getStartSite();
BasicdataWarehouseEntity t = basicdataWarehouseClient.findByName(warehouseName);
if(ObjectUtils.isNotNull(t)){
distributionStockArticleEntity.setSendWarehouseName(t.getName());
distributionStockArticleEntity.setSendWarehouseId(t.getId());
}
//收货仓库
warehouseName = wayBillEntity.getWarehouseName();
t = basicdataWarehouseClient.findByName(warehouseName);
if(ObjectUtils.isNotNull(t)){
distributionStockArticleEntity.setAcceptWarehouseName(t.getName());
distributionStockArticleEntity.setAcceptWarehouseId(t.getId());
}
String customerName = wayBillEntity.getTakeCompany();//客户名称
distributionStockArticleEntity.setTypeService("1");//默认商配
BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findByName(customerName);
log.info("订单同步出现的客户编号{} 匹配的客户", basicdataClientEntity);
if (!Objects.isNull(basicdataClientEntity)) {
//商城
distributionStockArticleEntity.setMallId(basicdataClientEntity.getId());
distributionStockArticleEntity.setMallName(basicdataClientEntity.getClientName());
distributionStockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
String peisongType = getPeisongTypeByClientId(basicdataClientEntity.getId());
log.info("订单同步peisongType {} ", peisongType);
if (StringUtil.isNoneBlank(peisongType)) {
distributionStockArticleEntity.setTypeService(peisongType);
}
}
}
distributionStockArticleEntity.setGenre(1);
distributionStockArticleEntity.setAdvanceId(advanceId);
//--------------2023-07-06 新增字段处理
// 增加订单 经销商信息 和门店信息
buildDealerAndStore(distributionStockArticleEntity, advanceEntity);
distributionStockArticleEntity.setCreateUser(1123598821738675201L);
distributionStockArticleEntity.setSortingQuantity(orderCountEntity.getSorting()); //分拣件数
distributionStockArticleEntity.setDeliveryQuantity(orderCountEntity.getDeliveNum()); //配送件数
distributionStockArticleEntity.setTransferQuantity(orderCountEntity.getTransNum()); //中转件数
distributionStockArticleEntity.setSigninQuantity(orderCountEntity.getSignNum()); //签收件数
distributionStockArticleEntity.setCreateUser(1714696768639311873L);
distributionStockArticleEntity.setUpdateUser(1714696768639311873L);
distributionStockArticleEntity.setCreateDept(1649331096241836033L);
distributionStockArticleEntity.setSortingQuantity(0); //分拣件数
distributionStockArticleEntity.setDeliveryQuantity(0); //配送件数
distributionStockArticleEntity.setTransferQuantity(0); //中转件数
distributionStockArticleEntity.setSigninQuantity(0); //签收件数
//1=部分入库,2=已入库,3=已出库,4=部分签收,5=待出库,6=已上架,7=已分拣,8=部分出库,9=部分装车,10=已装车,11=已签收,12=部分配送,13=已配送
distributionStockArticleEntity.setFreezeStatus(OrderFreezeStatusConstant.weidongjie.getValue()); //冻结状态
distributionStockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue()); //预约状态
distributionStockArticleEntity.setStockupStatus(OrderStockupStatusConstant.daibeihuo.getValue()); //备货状态
distributionStockArticleEntity.setGroundingStatus(OrderGroundingStatusConstant.daishangjia.getValue()); //上架状态
Integer status = orderCountEntity.getStatus();
if(1 == status){
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.bufenruku.getValue());
}else if(2 == status){
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue());
}else if(3 == status || 10 == status){
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue());
}else if(4 == status){
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.bufenqianshou.getValue());
}else if(8 == status || 9 == status){
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue());
}else if(11 == status){
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.qianshou.getValue());
}else{
distributionStockArticleEntity.setOrderStatus("100");
}
distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.yishouhuo.getValue());
distributionStockArticleEntity.setWarehouseEntryTime(date);
id = distributionStockArticleClient.addData(distributionStockArticleEntity);
@ -1080,11 +1337,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
//保存包件信息
saveOrderPackage(distributionStockArticleEntity,basicdataWarehouseEntity,wayBillNo,CommonUtil.dateToString(new Date()),oldWarehouseId,inventoryId);
saveOrderPackage(distributionStockArticleEntity,basicdataWarehouseEntity,wayBillNo,CommonUtil.dateToString(new Date()),oldWarehouseId);
}
private void saveOrderPackage(DistributionStockArticleEntity distributionStockArticleEntity, BasicdataWarehouseEntity basicdataWarehouseEntity, String waybillNo,String operationTime,Integer oldWarehouseId,Integer inventoryId) {
private void saveOrderPackage(DistributionStockArticleEntity distributionStockArticleEntity, BasicdataWarehouseEntity basicdataWarehouseEntity, String waybillNo,String operationTime,Integer oldWarehouseId) {
String orderCode = distributionStockArticleEntity.getOrderCode();
@ -1098,11 +1355,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
continue;
}
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo,inventoryId);
if(Objects.isNull(inventoryDetailEntity)){
log.info("###########saveOrderPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo);
continue;
}
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo,inventoryId);
// if(Objects.isNull(inventoryDetailEntity)){
// log.info("###########saveOrderPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo);
// continue;
// }
Integer status = orderDetailEntity.getStatus();
Integer carsType = orderDetailEntity.getCarsType();
@ -1121,13 +1378,14 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
entity.setWarehouse(distributionStockArticleEntity.getWarehouse());
entity.setWarehouseId(distributionStockArticleEntity.getWarehouseId());
entity.setStockArticleId(distributionStockArticleEntity.getId());
entity.setOrderPackageStatus(OrderPackageStatusConstant.yiruku.getValue());
//状态:1到货,2分拣,3装车,4卸货,5出库,6配送
if(1 == status){
entity.setOrderPackageStatus(OrderPackageStatusConstant.yiruku.getValue());
}
if(3==carsType||4 == carsType){
entity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue());
}
// if(1 == status){
// entity.setOrderPackageStatus(OrderPackageStatusConstant.yiruku.getValue());
// }
// if(3==carsType||4 == carsType){
// entity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue());
// }
if(2 == signState){
entity.setOrderPackageStatus(OrderPackageStatusConstant.yiqianshou.getValue());
}
@ -1138,12 +1396,8 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
entity.setOrderCode(distributionStockArticleEntity.getOrderCode());
entity.setServiceNumber(distributionStockArticleEntity.getServiceNumber());
entity.setWaybillNumber(waybillNo);
// if(ObjectUtil.isNotEmpty(warehouseWaybill)){
// entity.setWarehouseId(warehouseWaybill.getId());
// }
// 增加 进销商 名称 编码 发站仓
entity.setSendWarehouseName(distributionStockArticleEntity.getSendWarehouseName());
entity.setSendWarehouseId(distributionStockArticleEntity.getSendWarehouseId());
@ -1154,22 +1408,17 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
//进销售
entity.setDealerCode(distributionStockArticleEntity.getDealerCode());
entity.setDealerName(distributionStockArticleEntity.getDealerName());
// if(Objects.isNull(waybillEntity)){
// entity.setDealerCode(distributionStockArticleEntity.getDealerCode());
// entity.setDealerName(distributionStockArticleEntity.getDealerName());
// }else{
// entity.setDealerCode(distributionStockArticleEntity.getDealerCode());
// entity.setDealerName(waybillEntity.getTakeCompany());
// }
entity.setWarehouseEntryTimeEnd(CommonUtil.StringToDate(operationTime));
// 绑定部门--仓库
if (!Objects.isNull(basicdataWarehouseEntity)) {
entity.setCreateDept(basicdataWarehouseEntity.getDepartment());
}
entity.setCreateUser(1123598821738675201L);
entity.setMaterialCode(vo.getMaterialCode());
entity.setMaterialName(vo.getMaterialName());
entity.setCreateUser(1714696768639311873L);
entity.setUpdateUser(1714696768639311873L);
entity.setCreateDept(1649331096241836033L);
entity.setTenantId(TenantNum.HUITONGCODE);
if (StringUtil.isNoneBlank(entity.getMaterialName()) && StringUtil.isNoneBlank(entity.getMaterialCode())) {
if (StringUtil.isNotBlank(entity.getMaterialName()) && StringUtil.isNotBlank(entity.getMaterialCode())) {
// 查询物料信息
String sku = "";
BasicMaterialEntity basicMaterialEntity = basicMaterialClient.getMaterialOwn(entity.getMaterialCode(), entity.getMaterialName(), sku);
@ -1182,6 +1431,21 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
boolean b = distributionParcelListClient.add(entity);
if (!b) {
log.warn("#################handleDataToPlatform: 保存包件信息失败 orderCode={}", entity.getOrderCode());
}else{
log.info("################handleDataToPlatform: 保存包件成功 OrderPackageCode={}",vo.getPacketBarCode());
Integer handQuantity = distributionStockArticleEntity.getHandQuantity();
Integer totalNumber = distributionStockArticleEntity.getTotalNumber();
if(handQuantity+1 >= totalNumber){
distributionStockArticleEntity.setCompleteSet(1);
distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.yishouhuo.getValue());
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue());
}else{
distributionStockArticleEntity.setCompleteSet(0);
distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.bufenshouhuo.getValue());
distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.bufenruku.getValue());
}
distributionStockArticleClient.saveOrUpdate(distributionStockArticleEntity);
}
}
@ -1196,9 +1460,6 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
distributionStockArticleEntity.setStoreName(advanceEntity.getStoreName());
distributionStockArticleEntity.setStoreCode(advanceEntity.getStoreNo());
// distributionStockArticleEntity.setDealerCode(advanceEntity.getDealerCode());
// distributionStockArticleEntity.setDealerName(advanceEntity.getDealerName());
// 最终客户
distributionStockArticleEntity.setCustomerName(advanceEntity.getCustomerName());
distributionStockArticleEntity.setCustomerAddress(advanceEntity.getCustomerRoad());
@ -1211,7 +1472,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
// 品牌
distributionStockArticleEntity.setBrand(advanceEntity.getType());
distributionStockArticleEntity.setResource(advanceEntity.getType());
distributionStockArticleEntity.setResource(advanceEntity.getSystemType());
}

3
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseTrayTypeClient.java

@ -4,6 +4,7 @@ import com.logpm.warehouse.dto.ZeroOrderVO;
import com.logpm.warehouse.service.IWarehouseTrayTypeService;
import com.logpm.warehouse.vo.TrayTypeDataVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@ -12,6 +13,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@ApiIgnore()
@RestController
@AllArgsConstructor
@ -43,6 +45,7 @@ public class WarehouseTrayTypeClient implements IWarehouseTrayTypeClient {
if(r.getCode() == 200){
return true;
}else{
log.error("############orderScanOrderPackageCode: orderPackageCode={} code={} msg={}",orderPackageCode,r.getCode(),r.getMsg());
return false;
}
}

34
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseUpdownTypeClient.java

@ -22,6 +22,7 @@ import com.logpm.warehouse.dto.UpShelfStockDTO;
import com.logpm.warehouse.dto.UpShelfZeroOrderDTO;
import com.logpm.warehouse.service.IWarehouseUpdownTypeService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@ -35,6 +36,7 @@ import java.util.List;
* @author lmy
* @since 2023-08-15
*/
@Slf4j
@ApiIgnore()
@RestController
@AllArgsConstructor
@ -80,6 +82,38 @@ public class WarehouseUpdownTypeClient implements IWarehouseUpdownTypeClient {
return warehouseUpdownTypeService.downTrayCode(trayCode,warehouseId);
}
@Override
public boolean upShelfTray(String trayCode, Long locationId,Long warehouseId) {
R r = warehouseUpdownTypeService.upShelfTray(trayCode, locationId, warehouseId);
int code = r.getCode();
if(code == 200){
return true;
}else{
log.error("############upShelfTray: trayCode={} locationId={} code={} msg={}",trayCode,locationId,r.getCode(),r.getMsg());
return false;
}
}
@Override
public boolean upShelfPackage(String orderPackageCode, Long locationId, Long warehouseId) {
String[] split = orderPackageCode.split(",");
List<UpShelfPackageDTO> ls = new ArrayList<>();
for (String packageCode:split){
UpShelfPackageDTO upShelfPackageDTO = new UpShelfPackageDTO();
upShelfPackageDTO.setOrderPackageCode(packageCode);
ls.add(upShelfPackageDTO);
}
R r = warehouseUpdownTypeService.upShelfPackage(ls,locationId,warehouseId);
int code = r.getCode();
if(code == 200){
return true;
}else{
log.error("############upShelfTray: ls={} locationId={} code={} msg={}",ls,locationId,r.getCode(),r.getMsg());
return false;
}
}
@Override
public R downZeroOrder(List<JSONObject> zeroOrders) {

Loading…
Cancel
Save