|
@ -6,6 +6,7 @@ import java.net.URLEncoder; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
@ -185,48 +186,74 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
* 通过销售发起出货生成销售出货通知单列表 |
|
|
* 通过销售发起出货生成销售出货通知单列表 |
|
|
* */ |
|
|
* */ |
|
|
@Override |
|
|
@Override |
|
|
public int generateShippingInformBySalesOrder(SysSalesOrder sysSalesOrder,String outOrderCode) { |
|
|
public int generateShippingInformBySalesOrder(SysSalesOrder sysSalesOrder,String outOrderCode,List<Long> salesOrderIdList) { |
|
|
|
|
|
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
|
|
|
|
|
SysSalesShippingInform sysSalesShippingInform = new SysSalesShippingInform(); |
|
|
SysSalesShippingInform sysSalesShippingInform = new SysSalesShippingInform(); |
|
|
String salesOrderCode = sysSalesOrder.getSalesOrderCode(); |
|
|
// String salesOrderCode = sysSalesOrder.getSalesOrderCode();
|
|
|
if (StringUtils.isEmpty(salesOrderCode)){ |
|
|
// if (StringUtils.isEmpty(salesOrderCode)){
|
|
|
log.warn("销售订单编号为空:{}",salesOrderCode); |
|
|
// log.warn("销售订单编号为空:{}",salesOrderCode);
|
|
|
} |
|
|
// }
|
|
|
//从数据库查询的数据
|
|
|
//从数据库查询的数据
|
|
|
SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderBySalesOrderCode(salesOrderCode); |
|
|
// SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderBySalesOrderCode(salesOrderCode);
|
|
|
|
|
|
|
|
|
|
|
|
List<SysSalesOrder> sysSalesOrders = sysSalesOrderMapper.selectBatchSalesOrderById(salesOrderIdList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String salesOrderCodes = getSalesOrderCodes(sysSalesOrders); |
|
|
|
|
|
|
|
|
sysSalesShippingInform.setOutOrderCode(outOrderCode); |
|
|
sysSalesShippingInform.setOutOrderCode(outOrderCode); |
|
|
//出库状态为 待仓库准备物料
|
|
|
//出库状态为 待仓库准备物料
|
|
|
sysSalesShippingInform.setWarehouseOutStatus("0"); |
|
|
sysSalesShippingInform.setWarehouseOutStatus("0"); |
|
|
sysSalesShippingInform.setSalesOrderCode(salesOrderCode); |
|
|
sysSalesShippingInform.setSalesOrderCode(salesOrderCodes); |
|
|
//订单类型设置为 销售订单
|
|
|
|
|
|
sysSalesShippingInform.setWarehouseOrderType("0"); |
|
|
|
|
|
//出库类型设置为 销售出库
|
|
|
//出库类型设置为 销售出库
|
|
|
sysSalesShippingInform.setWarehouseOutType("0"); |
|
|
sysSalesShippingInform.setWarehouseOutType("0"); |
|
|
sysSalesShippingInform.setCustomerId(sysSalesOrderVo.getEnterpriseCode()); |
|
|
sysSalesShippingInform.setCustomerId(sysSalesOrder.getEnterpriseCode()); |
|
|
sysSalesShippingInform.setCustomerName(sysSalesOrderVo.getEnterpriseName()); |
|
|
sysSalesShippingInform.setCustomerName(sysSalesOrder.getEnterpriseName()); |
|
|
sysSalesShippingInform.setDeliveryCondition(sysSalesOrderVo.getDeliveryConditions()); |
|
|
sysSalesShippingInform.setDeliveryCondition(sysSalesOrder.getDeliveryConditions()); |
|
|
sysSalesShippingInform.setCreateTime(new Date()); |
|
|
sysSalesShippingInform.setCreateTime(new Date()); |
|
|
sysSalesShippingInform.setCreateBy(loginName); |
|
|
sysSalesShippingInform.setCreateBy(loginName); |
|
|
sysSalesShippingInform.setAllPriceExcludingTaxDollar(BigDecimal.valueOf(sysSalesOrderVo.getNoUsdSum())); |
|
|
sysSalesShippingInform.setBusinessMembers(loginName); |
|
|
sysSalesShippingInform.setAllPriceExcludingTaxRmb(BigDecimal.valueOf(sysSalesOrderVo.getNoRmbSum())); |
|
|
// 计算所有订单的合计金额(美元)
|
|
|
sysSalesShippingInform.setAllPriceIncludesTax(BigDecimal.valueOf(sysSalesOrderVo.getRmbTaxSum())); |
|
|
double totalNoUsdSum = sysSalesOrders.stream() |
|
|
//更新物料合计
|
|
|
.filter(Objects::nonNull).mapToDouble(SysSalesOrder::getNoUsdSum).sum(); |
|
|
sysSalesShippingInform.setMaterialSum(Math.toIntExact(sysSalesOrderVo.getMaterialSum())); |
|
|
|
|
|
//更新数量合计
|
|
|
// 计算所有订单的合计金额(人民币)
|
|
|
sysSalesShippingInform.setEnterpriseSum(Math.toIntExact(sysSalesOrderVo.getEnterpriseSum())); |
|
|
double totalNoRmbSum = sysSalesOrders.stream() |
|
|
|
|
|
.filter(Objects::nonNull).mapToDouble(SysSalesOrder::getNoRmbSum).sum(); |
|
|
sysSalesShippingInform.setCustomerContact(sysSalesOrderVo.getCustomerDelivery()); |
|
|
|
|
|
sysSalesShippingInform.setContactNumber(sysSalesOrderVo.getDeliveryPhone()); |
|
|
// 计算所有订单的含税合计金额(人民币)
|
|
|
sysSalesShippingInform.setCustomerContactAddress(sysSalesOrderVo.getDeliveryAddress()); |
|
|
double totalRmbTaxSum = sysSalesOrders.stream() |
|
|
|
|
|
.filter(Objects::nonNull).mapToDouble(SysSalesOrder::getRmbTaxSum).sum(); |
|
|
|
|
|
|
|
|
|
|
|
// 计算所有订单的物料合计
|
|
|
|
|
|
long totalMaterialSum = sysSalesOrders.stream() |
|
|
|
|
|
.mapToLong(order -> order.getMaterialSum() != null ? order.getMaterialSum() : 0L) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
// 计算所有订单的数量合计
|
|
|
|
|
|
long totalEnterpriseSum = sysSalesOrders.stream() |
|
|
|
|
|
.mapToLong(order -> order.getEnterpriseSum() != null ? order.getEnterpriseSum() : 0L) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
// 设置到sysSalesShippingInform对象中
|
|
|
|
|
|
sysSalesShippingInform.setAllPriceExcludingTaxDollar(BigDecimal.valueOf(totalNoUsdSum)); |
|
|
|
|
|
sysSalesShippingInform.setAllPriceExcludingTaxRmb(BigDecimal.valueOf(totalNoRmbSum)); |
|
|
|
|
|
sysSalesShippingInform.setAllPriceIncludesTax(BigDecimal.valueOf(totalRmbTaxSum)); |
|
|
|
|
|
sysSalesShippingInform.setMaterialSum(Math.toIntExact(totalMaterialSum)); |
|
|
|
|
|
sysSalesShippingInform.setEnterpriseSum(Math.toIntExact(totalEnterpriseSum)); |
|
|
|
|
|
|
|
|
|
|
|
sysSalesShippingInform.setCustomerContact(sysSalesOrder.getCustomerDelivery()); |
|
|
|
|
|
sysSalesShippingInform.setContactNumber(sysSalesOrder.getDeliveryPhone()); |
|
|
|
|
|
sysSalesShippingInform.setCustomerContactAddress(sysSalesOrder.getDeliveryAddress()); |
|
|
sysSalesShippingInform.setCustomerContactBillto(sysSalesOrder.getCustomerDeliveryBillto()); |
|
|
sysSalesShippingInform.setCustomerContactBillto(sysSalesOrder.getCustomerDeliveryBillto()); |
|
|
sysSalesShippingInform.setContactNumberBillto(sysSalesOrder.getDeliveryPhoneBillto()); |
|
|
sysSalesShippingInform.setContactNumberBillto(sysSalesOrder.getDeliveryPhoneBillto()); |
|
|
sysSalesShippingInform.setContactAddressBillto(sysSalesOrder.getDeliveryAddressBillto()); |
|
|
sysSalesShippingInform.setContactAddressBillto(sysSalesOrder.getDeliveryAddressBillto()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新销售出库详情数据
|
|
|
//更新销售出货通知详情数据
|
|
|
List<SysSalesOrderChild> sysSalesOrderChildList = sysSalesOrder.getSysSalesOrderChildList(); |
|
|
List<SysSalesOrderChild> sysSalesOrderChildList = sysSalesOrder.getSysSalesOrderChildList(); |
|
|
for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildList) { |
|
|
for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildList) { |
|
|
SysSalesShippingInformDetail sysSalesShippingInformDetail = new SysSalesShippingInformDetail(); |
|
|
SysSalesShippingInformDetail sysSalesShippingInformDetail = new SysSalesShippingInformDetail(); |
|
@ -240,7 +267,15 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
sysSalesShippingInformDetail.setMaterialProcessMethod(sysSalesOrderChild.getProcessMethod()); |
|
|
sysSalesShippingInformDetail.setMaterialProcessMethod(sysSalesOrderChild.getProcessMethod()); |
|
|
sysSalesShippingInformDetail.setMakeNum(sysSalesOrderChild.getMaterialNum()); |
|
|
sysSalesShippingInformDetail.setMakeNum(sysSalesOrderChild.getMaterialNum()); |
|
|
sysSalesShippingInformDetail.setHasOutOrderNum(sysSalesOrderChild.getOutBoundQuantity()); |
|
|
sysSalesShippingInformDetail.setHasOutOrderNum(sysSalesOrderChild.getOutBoundQuantity()); |
|
|
sysSalesShippingInformDetail.setThisShippingNum(sysSalesOrderChild.getApplyShippingNum()); |
|
|
//申请出货数 <= 订单数量
|
|
|
|
|
|
//申请出货数
|
|
|
|
|
|
Integer applyShippingNum = sysSalesOrderChild.getApplyShippingNum(); |
|
|
|
|
|
if (applyShippingNum <= sysSalesOrderChild.getMaterialNum()){ |
|
|
|
|
|
sysSalesShippingInformDetail.setThisShippingNum(applyShippingNum); |
|
|
|
|
|
}else { |
|
|
|
|
|
throw new BusinessException("申请出货数不能大于订单数量"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
sysSalesShippingInformDetail.setCreateBy(loginName); |
|
|
sysSalesShippingInformDetail.setCreateBy(loginName); |
|
|
sysSalesShippingInformDetail.setCreateTime(new Date()); |
|
|
sysSalesShippingInformDetail.setCreateTime(new Date()); |
|
|
shippingInformDetailMapper.insertSysSalesShippingInformDetail(sysSalesShippingInformDetail); |
|
|
shippingInformDetailMapper.insertSysSalesShippingInformDetail(sysSalesShippingInformDetail); |
|
@ -249,6 +284,24 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
return sysSalesShippingInformMapper.insertSysSalesShippingInform(sysSalesShippingInform); |
|
|
return sysSalesShippingInformMapper.insertSysSalesShippingInform(sysSalesShippingInform); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理多个销售订单发货的单号拼接问题
|
|
|
|
|
|
private static String getSalesOrderCodes(List<SysSalesOrder> sysSalesOrders) { |
|
|
|
|
|
if (sysSalesOrders == null || sysSalesOrders.isEmpty()) { |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 使用Java 8 Stream API收集所有salesOrderCode
|
|
|
|
|
|
String result = sysSalesOrders.stream() |
|
|
|
|
|
.map(SysSalesOrder::getSalesOrderCode) |
|
|
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 修改保存确认发货 |
|
|
* 修改保存确认发货 |
|
|
*/ |
|
|
*/ |
|
|