Browse Source

1.合并分支

dev-warehouse
pref_mail@163.com 2 years ago
parent
commit
d5d179b639
  1. 2
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/WarehouseApplication.java
  2. 40
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/WarehouseConfiguration.java
  3. 21
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/pros/WarehouseProperties.java
  4. 113
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java

2
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/WarehouseApplication.java

@ -29,7 +29,7 @@ import org.springblade.core.launch.BladeApplication;
public class WarehouseApplication {
public static void main(String[] args) {
BladeApplication.run(ModuleNameConstant.APPLICATION_WAREHOUSE_NAME, WarehouseApplication.class, args);
BladeApplication.run(ModuleNameConstant.APPLICATION_WAREHOUSE_NAME.concat("-pref"), WarehouseApplication.class, args);
}
}

40
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/WarehouseConfiguration.java

@ -0,0 +1,40 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package com.logpm.warehouse.config;
import com.logpm.warehouse.pros.WarehouseProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* 配置feignmybatis包名properties
*
* @author chaos
*/
@Configuration(proxyBeanMethods = false)
@ComponentScan({"org.springblade", "com.logpm"})
@EnableFeignClients({"org.springblade", "com.logpm"})
@MapperScan({"org.springblade.**.mapper.**", "com.logpm.**.mapper.**"})
@EnableConfigurationProperties(WarehouseProperties.class)
public class WarehouseConfiguration {
}

21
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/pros/WarehouseProperties.java

@ -0,0 +1,21 @@
package com.logpm.warehouse.pros;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* FactoryProperties
*
* @author pref
*/
@Data
@ConfigurationProperties(prefix = "logpm")
public class WarehouseProperties {
/**
* 名称
*/
private String name;
}

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

@ -20,6 +20,7 @@ import com.logpm.warehouse.entity.WarehouseWaybill;
import com.logpm.warehouse.mapper.WarehouseWaybillMapper;
import com.logpm.warehouse.service.IWarehouseWayBillDetailService;
import com.logpm.warehouse.service.IWarehouseWaybillService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.exception.CustomerException;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,29 +34,23 @@ import java.util.Objects;
/**
* 运单;(logpm_mainline_waybill)表服务实现类
*
* @author : http://www.chiner.pro
* @date : 2023-7-4
*/
@Slf4j
//@AllArgsConstructor
@Service
@AllArgsConstructor
public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
@Autowired
private WarehouseWaybillMapper warehouseWaybillMapper;
@Autowired
private IWayBillClient wayBillClient;
@Autowired
private IBasicdataWarehouseClient basicdataWarehouseClient;
@Autowired
private IBasicdataClientClient basicdataClientClient;
@Autowired
private IBasicdataStoreBusinessClient basicdataStoreBusinessClient;
@Autowired
private IWarehouseWayBillDetailService warehouseWayBillDetailService;
@Autowired
private IDistributionParcelListClient distributionParcelListClient;
@Autowired
private IDistributionStockArticleClient distributionStockArticleClient;
private final WarehouseWaybillMapper warehouseWaybillMapper;
private final IWayBillClient wayBillClient;
private final IBasicdataWarehouseClient basicdataWarehouseClient;
private final IBasicdataClientClient basicdataClientClient;
private final IBasicdataStoreBusinessClient basicdataStoreBusinessClient;
private final IWarehouseWayBillDetailService warehouseWayBillDetailService;
private final IDistributionParcelListClient distributionParcelListClient;
private final IDistributionStockArticleClient distributionStockArticleClient;
@Override
@Transactional(rollbackFor = Exception.class)
@ -65,21 +60,21 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
Integer allNum = 0;
Long waybillId = null;
boolean isOrder = false;
for (ProductDTO productDTO:productList){
for (ProductDTO productDTO : productList) {
Integer num = productDTO.getNum();
allNum = allNum + num;
}
log.info("###############waybillDataHandler: 处理数据开始 waybillNo={}",waybillNo);
log.info("###############waybillDataHandler: 处理数据开始 waybillNo={}", waybillNo);
//通过运单号先去查询新系统是否存在这个运单号
QueryWrapper<WarehouseWaybill> waybillQueryWrapper = new QueryWrapper<>();
waybillQueryWrapper.eq("waybill_no",waybillNo);
waybillQueryWrapper.eq("waybill_no", waybillNo);
WarehouseWaybill warehouseWaybill = warehouseWaybillMapper.selectOne(waybillQueryWrapper);
if(Objects.isNull(warehouseWaybill)){
if (Objects.isNull(warehouseWaybill)) {
//如果新系统中不存在这个运单,那么就去查询老系统的运单数据
WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNo);
if(Objects.isNull(wayBillEntity)){
log.warn("##############waybillDataHandler: 老系统中为找到对应运单waybillNo={}",waybillNo);
if (Objects.isNull(wayBillEntity)) {
log.warn("##############waybillDataHandler: 老系统中为找到对应运单waybillNo={}", waybillNo);
throw new CustomerException("老系统中未找到对应运单");
}
String startSite = wayBillEntity.getStartSite();//始发仓名称
@ -88,31 +83,31 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
BasicdataWarehouseEntity endhouse = basicdataWarehouseClient.findByName(warehouseName);
Integer number = wayBillEntity.getNumber();//运单总数量
String agent = wayBillEntity.getAgent();
if(allNum.compareTo(number) > 0 ){
log.warn("##############waybillDataHandler: 运单的总数量异常 allNum={} number={}",allNum,number);
if (allNum.compareTo(number) > 0) {
log.warn("##############waybillDataHandler: 运单的总数量异常 allNum={} number={}", allNum, number);
throw new CustomerException("运单的总数量异常");
}
warehouseWaybill = new WarehouseWaybill();
warehouseWaybill.setWaybillNo(waybillNo);
warehouseWaybill.setDestinationWarehouse(warehouseName);
warehouseWaybill.setDestinationWarehouseId(Objects.isNull(endhouse)?null:endhouse.getId());
warehouseWaybill.setDestinationWarehouseId(Objects.isNull(endhouse) ? null : endhouse.getId());
warehouseWaybill.setDepartureWarehouse(startSite);
warehouseWaybill.setDepartureWarehouseId(Objects.isNull(starthouse)?null:starthouse.getId());
warehouseWaybill.setDepartureWarehouseId(Objects.isNull(starthouse) ? null : starthouse.getId());
warehouseWaybill.setCustomerTrain(wayBillEntity.getCarNo());
warehouseWaybill.setBrand(wayBillEntity.getBrand());
String sendCompany = wayBillEntity.getSendCompany();//发货单位
String takeCompany = wayBillEntity.getTakeCompany();//收货单位
BasicdataClientEntity sendClient = basicdataClientClient.findByName(sendCompany);
BasicdataClientEntity takeClient = basicdataClientClient.findByName(takeCompany);
if(!Objects.isNull(sendClient)){
if (!Objects.isNull(sendClient)) {
Long clientEntityId = sendClient.getId();//基础客户
warehouseWaybill.setShipperId(clientEntityId);
}
if(!Objects.isNull(takeClient)){
if (!Objects.isNull(takeClient)) {
Long clientEntityId = takeClient.getId();//基础客户
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntityId,3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntityId, 3);
if (!Objects.isNull(basicdataStoreBusinessEntity)) {
warehouseWaybill.setServiceType(Integer.parseInt(basicdataStoreBusinessEntity.getMold()));
}
warehouseWaybill.setConsigneeId(clientEntityId);
@ -136,7 +131,7 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
warehouseWaybill.setReceiptCount(wayBillEntity.getReceiptNum());
warehouseWaybill.setReceiptRequirement(wayBillEntity.getReceiptAsk());
BasicdataClientEntity agentClient = basicdataClientClient.findByName(agent);
if(!Objects.isNull(agentClient)){
if (!Objects.isNull(agentClient)) {
Long clientEntityId = agentClient.getId();//基础客户
warehouseWaybill.setAgentId(clientEntityId);
}
@ -148,52 +143,52 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
warehouseWaybillMapper.insert(warehouseWaybill);
waybillId = warehouseWaybill.getId();
//判断是否需要创建在库订单
if(allNum.compareTo(number) == 0){
if (allNum.compareTo(number) == 0) {
isOrder = true;
}
}else{
} else {
Integer totalCount = warehouseWaybill.getTotalCount();
Integer stockCount = warehouseWaybill.getStockCount();
if(totalCount.compareTo(stockCount+allNum) < 0){
log.warn("##############waybillDataHandler: 运单的总数量异常 totalCount={} stockCount={} allNum={}",totalCount,stockCount,allNum);
if (totalCount.compareTo(stockCount + allNum) < 0) {
log.warn("##############waybillDataHandler: 运单的总数量异常 totalCount={} stockCount={} allNum={}", totalCount, stockCount, allNum);
throw new CustomerException("运单的总数量异常");
}
warehouseWaybill.setStockCount(stockCount+allNum);
warehouseWaybill.setStockCount(stockCount + allNum);
warehouseWaybillMapper.updateById(warehouseWaybill);
waybillId = warehouseWaybill.getId();
//判断是否需要创建在库订单
if(totalCount.compareTo(stockCount+allNum) == 0){
if (totalCount.compareTo(stockCount + allNum) == 0) {
isOrder = true;
}
}
//处理运单明细
for(ProductDTO productDTO:productList){
for (ProductDTO productDTO : productList) {
String productName = productDTO.getProductName();
Integer num = productDTO.getNum();
WarehouseWayBillDetail warehouseWayBillDetail = warehouseWayBillDetailService.findByProductName(productName);
if(Objects.isNull(warehouseWayBillDetail)){
if (Objects.isNull(warehouseWayBillDetail)) {
warehouseWayBillDetail = new WarehouseWayBillDetail();
warehouseWayBillDetail.setWaybillId(waybillId);
warehouseWayBillDetail.setWaybillNo(waybillNo);
warehouseWayBillDetail.setProductName(productName);
warehouseWayBillDetail.setNum(num);
warehouseWayBillDetailService.save(warehouseWayBillDetail);
}else{
warehouseWayBillDetail.setNum(warehouseWayBillDetail.getNum()+num);
} else {
warehouseWayBillDetail.setNum(warehouseWayBillDetail.getNum() + num);
warehouseWayBillDetailService.update(warehouseWayBillDetail);
}
}
if(isOrder){
if (isOrder) {
//创建在库订单
createStockArticle(warehouseWaybill);
}
log.info("###############waybillDataHandler: 处理数据结束 waybillNo={}",waybillNo);
log.info("###############waybillDataHandler: 处理数据结束 waybillNo={}", waybillNo);
}
private void createStockArticle(WarehouseWaybill warehouseWaybill) {
private final void createStockArticle(WarehouseWaybill warehouseWaybill) {
//判断新系统是否有这条订单数据
//自动生成的在库订单就用运单号作为订单号
String waybillNo = warehouseWaybill.getWaybillNo();
@ -207,7 +202,7 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findByOrderSelfNum(waybillNo);
Long id = null;
if(Objects.isNull(distributionStockArticleEntity)){
if (Objects.isNull(distributionStockArticleEntity)) {
Date date = new Date();
distributionStockArticleEntity = new DistributionStockArticleEntity();
@ -225,7 +220,7 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
distributionStockArticleEntity.setBrand(warehouseWaybill.getBrand());
distributionStockArticleEntity.setResource("零担");
if(!Objects.isNull(basicdataWarehouseEntity)){
if (!Objects.isNull(basicdataWarehouseEntity)) {
distributionStockArticleEntity.setCreateDept(Long.parseLong(basicdataWarehouseEntity.getDepartment()));
}
@ -233,10 +228,10 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
//通过客户名称去查询客户的服务类型、
distributionStockArticleEntity.setTypeService(1);//默认商配
BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findByName(customerName);
if(!Objects.isNull(basicdataClientEntity)){
if (!Objects.isNull(basicdataClientEntity)) {
Long clientEntityId = basicdataClientEntity.getId();//基础客户
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntityId,3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntityId, 3);
if (!Objects.isNull(basicdataStoreBusinessEntity)) {
distributionStockArticleEntity.setTypeService(Integer.parseInt(basicdataStoreBusinessEntity.getMold()));
}
}
@ -249,18 +244,18 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
distributionStockArticleEntity.setConsigneePerson(warehouseWaybill.getConsigneeName());//收货人
distributionStockArticleEntity.setReserve1("zero");
id = distributionStockArticleClient.addData(distributionStockArticleEntity);
if(id == 0){
log.warn("#################createStockArticle: 保存订单信息失败 orderSelfNum={}",waybillNo);
throw new CustomerException(405,"保存订单信息失败");
if (id == 0) {
log.warn("#################createStockArticle: 保存订单信息失败 orderSelfNum={}", waybillNo);
throw new CustomerException(405, "保存订单信息失败");
}
}else{
} else {
id = distributionStockArticleEntity.getId();
}
//存入包件信息
List<WarehouseWayBillDetail> details = warehouseWayBillDetailService.findByWaybillId(waybillId);
List<DistributionParcelListEntity> ls = new ArrayList<>();
for (WarehouseWayBillDetail warehouseWayBillDetail:details){
for (WarehouseWayBillDetail warehouseWayBillDetail : details) {
DistributionParcelListEntity entity = new DistributionParcelListEntity();
entity.setMaterialName(warehouseWayBillDetail.getProductName());
entity.setQuantity(warehouseWayBillDetail.getNum());
@ -270,9 +265,9 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
ls.add(entity);
}
boolean b = distributionParcelListClient.addBatch(ls);
if(!b){
log.warn("#################createStockArticle: 保存包件信息失败 orderSelfNum={}",waybillNo);
throw new CustomerException(405,"保存包件信息失败");
if (!b) {
log.warn("#################createStockArticle: 保存包件信息失败 orderSelfNum={}", waybillNo);
throw new CustomerException(405, "保存包件信息失败");
}
}
@ -280,7 +275,7 @@ public class WarehouseWaybillServiceImpl implements IWarehouseWaybillService {
@Override
public WarehouseWaybill findByWaybillNo(String waybillNo) {
QueryWrapper<WarehouseWaybill> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("waybill_no",waybillNo);
queryWrapper.eq("waybill_no", waybillNo);
return warehouseWaybillMapper.selectOne(queryWrapper);
}

Loading…
Cancel
Save