Browse Source

[feat]销售管理

修改销售订单新增前端页面:设置计划交付时间不能为空
修改销售出货通知前端页面:设置申请人员为只读。物料列表新增销售订单字段;提交方法新增销售订单id集合;设置申请出货数满足:申请出货数不能为空、申请出货数不能为空、申请出货数不能为空、申请出货数不能为空;修改前端查询接口,传递的参数为salesOrderIdList
修改导出销售订单子表模板类:计划交付时间为Date类型
修改销售订单实体类:新增salesOrderIdList
修改销售订单子表实体类:计划交付时间为Date类型,加上类型转换注解
销售订单子表新增 通过销售订单id集合查询销售订单子表数据集合后端方法;新增通过销售订单号批量查询销售订单子表
修改 通过销售发起出货生成销售出货通知单列表,参数新增 salesOrderIdList数据;重写generateShippingInformBySalesOrder方法;实现多订单的话,合计金额(美元)、合计金额(人民币)、含税合计金额(人民币)、订单的物料合计、订单的数量合计;出货通知的数据来这前端传入的销售订单的数据;出货通知详情的数据来自前端传入的销售订单子表的数据,并且要满足:申请出货数 <= 订单数量;新增处理多个销售订单发货的单号拼接问题后端方法,实现多个订单采用逗号分隔
修改通过销售发起出货生成仓库出库单参数新增 salesOrderIdList数据;重写generateWarehouseOutOrderBySalesOrder方法:实现多订单的话单的物料合计、订单的数量合计;关联单号填充逗号分隔的多订单号;出货库单的数据来这前端传入的销售订单的数据;出库单详情的数据来自前端传入的销售订单子表的数据,
新增 销售出货物料列表展示方法:实现相同物料料号的数据materialNum、finishNum、hasApplyShippingNum、outBoundQuantity会进行合并,其余数据不会合并
修改销售订单的发起出货前端接口:新增从后端传入销售订单id集合的数据
修改发起出货 物料详情列表后端接口
修改销售订单新增后端接口:新增自定义校验方法:物料数量不能为空、计划交付时间不能为空、质保天数不能为空
重写修改保存发起出货后端接口:实现:过滤掉申请出货数为0的数据,也就是本次不发起出货;如果子表中有申请出货数为空的数据,不能提交保存;将旧数据按物料编号分组,获取旧数据中相同物料编号的数据,按照 deliveryTime 接近当前时间排序,计算新的已申请出货数满足根据计划交付时间来分配合并的物料分配已申请出货数的要求,deliveryTime时间接近当前时间的数据,先更新已申请出货数
dev
liuxiaoxu 3 weeks ago
parent
commit
d88dfb9bd8
  1. 7
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java
  2. 13
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysSalesOrder.java
  3. 9
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysSalesOrderChild.java
  4. 3
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportSalesOrderChildVo.java
  5. 5
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysSalesOrderChildMapper.java
  6. 5
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesOrderChildService.java
  7. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesShippingInformService.java
  8. 64
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderChildServiceImpl.java
  9. 88
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java
  10. 103
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java
  11. 2
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseOutOrderService.java
  12. 92
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java
  13. 13
      ruoyi-admin/src/main/resources/mapper/system/SysSalesOrderChildMapper.xml
  14. 12
      ruoyi-admin/src/main/resources/templates/system/salesOrder/add.html
  15. 33
      ruoyi-admin/src/main/resources/templates/system/salesOrder/salesDeliverGoods.html

7
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java

@ -556,9 +556,11 @@ public class SysSalesOrderController extends BaseController
public String deliverGoods(@RequestParam List<Long> salesOrderIds, ModelMap mmap) {
List<SysSalesOrder> salesOrders = sysSalesOrderService.selectBatchSalesOrderById(salesOrderIds);
List<Long> salesOrderIdList = salesOrders.stream().map(sysSalesOrder -> sysSalesOrder.getSalesOrderId()).collect(Collectors.toList());
SysSalesOrder sysSalesOrder = salesOrders.get(0);
mmap.put("salesOrders", salesOrders);
mmap.put("sysSalesOrder", sysSalesOrder);
mmap.put("salesOrderIdList", salesOrderIdList);
return prefix + "/salesDeliverGoods";
}
@ -582,8 +584,9 @@ public class SysSalesOrderController extends BaseController
@RequestMapping("/salesDeliverGoodsDetailList")
public TableDataInfo storageMakeDetailList(SysSalesOrder sysSalesOrder){
startPage();
String salesOrderCode = sysSalesOrder.getSalesOrderCode();
List<SysSalesOrderChild> list = sysSalesOrderChildService.selectOrderChildListBySalesOrderCode(salesOrderCode);
List<Long> salesOrderIdList = sysSalesOrder.getSalesOrderIdList();
List<SysSalesOrderChild> list = sysSalesOrderChildService.selectSalesDeliverGoodsDetailList(salesOrderIdList);
//List<SysSalesOrderChild> list = sysSalesOrderChildService.selectOrderChildListBySalesOrderCode(salesOrderCode);
return getDataTable(list) ;
}

13
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysSalesOrder.java

@ -202,6 +202,10 @@ public class SysSalesOrder extends BaseEntity {
private List<SelectAftersalesNoticeVO> selectAftersalesNoticeVOList;
//用于出货的销售订单id集合
private List<Long> salesOrderIdList;
//销售子表物料号
private String materialCode;
@ -778,6 +782,15 @@ public class SysSalesOrder extends BaseEntity {
this.materialName = materialName;
}
public List<Long> getSalesOrderIdList() {
return salesOrderIdList;
}
public void setSalesOrderIdList(List<Long> salesOrderIdList) {
this.salesOrderIdList = salesOrderIdList;
}
@Override
public String toString() {
return Objects.toStringHelper(this)

9
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysSalesOrderChild.java

@ -1,11 +1,13 @@
package com.ruoyi.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.base.Objects;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.FieldCompare;
import com.ruoyi.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
* 销售订单对象 sys_sales_order
@ -138,7 +140,8 @@ public class SysSalesOrderChild extends BaseEntity {
private Double materialRmbSum;
@Excel(name = "计划交付时间")
private String deliveryTime;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date deliveryTime;
@Excel(name = "质保天数")
private String expiryDay;
/*业务人员*/
@ -427,11 +430,11 @@ public class SysSalesOrderChild extends BaseEntity {
this.materialRmbSum = materialRmbSum;
}
public String getDeliveryTime() {
public Date getDeliveryTime() {
return deliveryTime;
}
public void setDeliveryTime(String deliveryTime) {
public void setDeliveryTime(Date deliveryTime) {
this.deliveryTime = deliveryTime;
}

3
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportSalesOrderChildVo.java

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 导出销售订单子表模板类
@ -64,6 +65,6 @@ public class ExportSalesOrderChildVo {
/** 计划交付时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private String deliveryTime;
private Date deliveryTime;
}

5
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysSalesOrderChildMapper.java

@ -57,4 +57,9 @@ public interface SysSalesOrderChildMapper {
* 检查销售订单子表是否引用了物料
* */
int checkMaterialIsReferencedBySalesOrderChild(String materialNo);
/**
* 通过销售订单号批量查询销售订单子表
* */
List<SysSalesOrderChild> selectBatchOrderChildListBySalesOrderCode(List<String> salesOrderCodeList);
}

5
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesOrderChildService.java

@ -36,4 +36,9 @@ public interface ISysSalesOrderChildService {
* @return
*/
Integer deleteSysSalesOrderChildByQuoteId(String salesOrderCode);
/**
* 销售出货物料列表展示
*/
List<SysSalesOrderChild> selectSalesDeliverGoodsDetailList(List<Long> salesOrderIdList);
}

2
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesShippingInformService.java

@ -81,7 +81,7 @@ public interface ISysSalesShippingInformService
/**
* 通过销售发起出货生成销售出货通知单列表
* */
int generateShippingInformBySalesOrder(SysSalesOrder sysSalesOrder, String outOrderCode);
int generateShippingInformBySalesOrder(SysSalesOrder sysSalesOrder, String outOrderCode,List<Long> salesOrderIdList);
/**

64
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderChildServiceImpl.java

@ -1,29 +1,41 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.service.ISysSalesOrderChildService;
import com.ruoyi.system.service.ISysSalesOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class SysSalesOrderChildServiceImpl implements ISysSalesOrderChildService {
@Autowired
private SysSalesOrderChildMapper sysCustomerQuoteChildMapper;
@Autowired
private ISysSalesOrderService sysSalesOrderService;
@Override
public List<SysSalesOrderChild> selectSysSalesOrderChildList (SysSalesOrderChild sysCustomerQuoteChild) {
public List<SysSalesOrderChild> selectSysSalesOrderChildList(SysSalesOrderChild sysCustomerQuoteChild) {
List<SysSalesOrderChild> sysSalesOrderChildren = sysCustomerQuoteChildMapper.selectSysSalesOrderChildList(sysCustomerQuoteChild);
return sysSalesOrderChildren;
}
@Override
public List<SysSalesOrderChild> selectSysSalesOrderChildListAll (SysSalesOrderChild sysCustomerQuoteChild) {
public List<SysSalesOrderChild> selectSysSalesOrderChildListAll(SysSalesOrderChild sysCustomerQuoteChild) {
return sysCustomerQuoteChildMapper.selectSysSalesOrderChildListAll(sysCustomerQuoteChild);
}
@Override
public int insertSysSalesOrderChild(SysSalesOrderChild sysCustomerQuoteChild) {
return sysCustomerQuoteChildMapper.insertSysSalesOrderChild(sysCustomerQuoteChild);
@ -56,7 +68,7 @@ public class SysSalesOrderChildServiceImpl implements ISysSalesOrderChildService
@Override
public SysSalesOrderChild selectOneByQuoteIdAndMaterialCode(String quoteId, String materialCode) {
return sysCustomerQuoteChildMapper.selectOneByQuoteIdAndMaterialCode(quoteId,materialCode);
return sysCustomerQuoteChildMapper.selectOneByQuoteIdAndMaterialCode(quoteId, materialCode);
}
/*
@ -72,4 +84,50 @@ public class SysSalesOrderChildServiceImpl implements ISysSalesOrderChildService
public Integer deleteSysSalesOrderChildByQuoteId(String salesOrderCode) {
return sysCustomerQuoteChildMapper.deleteSysSalesOrderChildByQuoteId(salesOrderCode);
}
/**
* 销售出货物料列表展示
*/
@Override
public List<SysSalesOrderChild> selectSalesDeliverGoodsDetailList(List<Long> salesOrderIdList) {
List<SysSalesOrder> sysSalesOrders = sysSalesOrderService.selectBatchSalesOrderById(salesOrderIdList);
List<String> salesOrderCodeList = sysSalesOrders.stream()
.map(SysSalesOrder::getSalesOrderCode)
.collect(Collectors.toList());
List<SysSalesOrderChild> list = sysCustomerQuoteChildMapper.selectBatchOrderChildListBySalesOrderCode(salesOrderCodeList);
// 合并相同物料料号的数据
Map<String, SysSalesOrderChild> mergedMap = list.stream()
.collect(Collectors.toMap(
SysSalesOrderChild::getMaterialCode,
item -> item,
(existingItem, newItem) -> {
existingItem.setMaterialNum(
(existingItem.getMaterialNum() != null ? existingItem.getMaterialNum() : 0) +
(newItem.getMaterialNum() != null ? newItem.getMaterialNum() : 0)
);
existingItem.setFinishNum(
(existingItem.getFinishNum() != null ? existingItem.getFinishNum() : 0) +
(newItem.getFinishNum() != null ? newItem.getFinishNum() : 0)
);
existingItem.setHasApplyShippingNum(
(existingItem.getHasApplyShippingNum() != null ? existingItem.getHasApplyShippingNum() : 0) +
(newItem.getHasApplyShippingNum() != null ? newItem.getHasApplyShippingNum() : 0)
);
existingItem.setOutBoundQuantity(
(existingItem.getOutBoundQuantity() != null ? existingItem.getOutBoundQuantity() : 0) +
(newItem.getOutBoundQuantity() != null ? newItem.getOutBoundQuantity() : 0)
);
return existingItem;
}
));
// 将合并后的数据转换为列表
List<SysSalesOrderChild> mergedList = new ArrayList<>(mergedMap.values());
return mergedList;
}
}

88
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java

@ -305,6 +305,11 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
if (s == 0){
return 0;
}
List<SysSalesOrderChild> sysSalesOrderChildList = sysSalesOrder.getSysSalesOrderChildList();
// 校验子表数据
checkSysSalesOrderChildList(sysSalesOrderChildList);
for (int i = 0; i < s ;i++) {
SysSalesOrderChild sysSalesOrderChild = sysSalesOrder.getSysSalesOrderChildList().get(i);
sysSalesOrderChild.setQuoteId(sysSalesOrder.getSalesOrderCode());
@ -315,6 +320,31 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
}
//自定义校验
private void checkSysSalesOrderChildList(List<SysSalesOrderChild> sysSalesOrderChildList) {
// 检查物料数量是否为空
boolean anyMaterialNum = sysSalesOrderChildList.stream()
.anyMatch(sysSalesOrderChild -> sysSalesOrderChild.getMaterialNum() == null);
if (anyMaterialNum) {
throw new BusinessException("物料数量不能为空");
}
// 检查计划交付时间是否为空
boolean anyDeliveryTime = sysSalesOrderChildList.stream()
.anyMatch(sysSalesOrderChild -> sysSalesOrderChild.getDeliveryTime() == null);
if (anyDeliveryTime) {
throw new BusinessException("计划交付时间不能为空");
}
// 检查质保天数是否为空
boolean anyExpiryDay = sysSalesOrderChildList.stream()
.anyMatch(sysSalesOrderChild -> sysSalesOrderChild.getExpiryDay() == null);
if (anyExpiryDay) {
throw new BusinessException("质保天数不能为空");
}
}
/**
* 修改销售订单
*
@ -493,22 +523,62 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
List<SysSalesOrderChild> sysSalesOrderChildList = sysSalesOrder.getSysSalesOrderChildList();
//过滤掉申请出货数为0的数据,也就是本次不发起出货
sysSalesOrderChildList = sysSalesOrderChildList.stream().filter(sysSalesOrderChild -> sysSalesOrderChild.getApplyShippingNum() != 0 ).collect(Collectors.toList());
List<Long> salesOrderIdList = sysSalesOrder.getSalesOrderIdList();
List<SysSalesOrder> sysSalesOrders = sysSalesOrderMapper.selectBatchSalesOrderById(salesOrderIdList);
List<String> collectSalesOrderCode = sysSalesOrders.stream().map(SysSalesOrder::getSalesOrderCode).collect(Collectors.toList());
List<SysSalesOrderChild> oldSalesOrderChildList = salesOrderChildMapper.selectBatchOrderChildListBySalesOrderCode(collectSalesOrderCode);
//如果子表中有申请出货数为空的数据,不能提交保存
boolean applyShippingNumHasNull = sysSalesOrderChildList.stream().anyMatch(sysSalesOrderChild -> sysSalesOrderChild.getApplyShippingNum() == null);
if (applyShippingNumHasNull){
throw new BusinessException("申请出货数不能为空,请检查");
}
// 将旧数据按物料编号分组
Map<String, List<SysSalesOrderChild>> oldDataGroupedByMaterialCode = oldSalesOrderChildList.stream()
.collect(Collectors.groupingBy(SysSalesOrderChild::getMaterialCode));
// 当前时间
Date now = new Date();
for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildList) {
String materialCode = sysSalesOrderChild.getMaterialCode();
Integer applyShippingNum = sysSalesOrderChild.getApplyShippingNum();
// 获取旧数据中相同物料编号的数据
List<SysSalesOrderChild> oldChildren = oldDataGroupedByMaterialCode.get(materialCode);
if (oldChildren != null && !oldChildren.isEmpty()) {
// 按照 deliveryTime 接近当前时间排序
oldChildren.sort(Comparator.comparing(oldChild -> Math.abs(now.getTime() - oldChild.getDeliveryTime().getTime())));
sysSalesOrderChild.setUpdateTime(new Date());
sysSalesOrderChild.setUpdateBy(loginName);
sysSalesOrderChild.setQuoteId(sysSalesOrder.getSalesOrderCode());
sysSalesOrderChild.setHasApplyShippingNum(sysSalesOrderChild.getApplyShippingNum());
int updateSysSalesOrderChildResult = salesOrderChildMapper.updateSysSalesOrderChildByCodeAndQuoteId(sysSalesOrderChild);
if (updateSysSalesOrderChildResult <= 0){
throw new BusinessException("更新销售订单子表数据失败");
for (SysSalesOrderChild oldChild : oldChildren) {
Integer hasApplyShippingNum = oldChild.getHasApplyShippingNum();
if (hasApplyShippingNum == null) {
hasApplyShippingNum = 0; // 确保 hasApplyShippingNum 不为 null
}
// 计算新的已申请出货数
hasApplyShippingNum += applyShippingNum;
oldChild.setHasApplyShippingNum(hasApplyShippingNum);
oldChild.setUpdateTime(new Date());
oldChild.setUpdateBy(loginName);
oldChild.setQuoteId(sysSalesOrder.getSalesOrderCode());
// 更新数据库
int updateSysSalesOrderChildResult = salesOrderChildMapper.updateSysSalesOrderChild(oldChild);
if (updateSysSalesOrderChildResult <= 0) {
throw new BusinessException("更新销售订单子表数据失败");
}
// 更新完成后,跳出循环
break;
}
}
}
@ -516,10 +586,10 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
//两个表生成同一个出库单号
String outOrderCode = redisCache.generateBillNo("CK");
//通过销售发起出货生成仓库出库单
int insertWarehouseOutOrderResult = warehouseOutOrderService.generateWarehouseOutOrderBySalesOrder(sysSalesOrder,outOrderCode);
int insertWarehouseOutOrderResult = warehouseOutOrderService.generateWarehouseOutOrderBySalesOrder(sysSalesOrder,outOrderCode,salesOrderIdList);
//通过销售发起出货生成销售出货通知单列表
int insertShippingInformResult = sysSalesShippingInformService.generateShippingInformBySalesOrder(sysSalesOrder,outOrderCode);
int insertShippingInformResult = sysSalesShippingInformService.generateShippingInformBySalesOrder(sysSalesOrder,outOrderCode,salesOrderIdList);
return sysSalesOrderMapper.updateSysSalesOrderBySalesOrderCode(sysSalesOrder);
}

103
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java

@ -6,6 +6,7 @@ import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
@ -185,48 +186,74 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor
* 通过销售发起出货生成销售出货通知单列表
* */
@Override
public int generateShippingInformBySalesOrder(SysSalesOrder sysSalesOrder,String outOrderCode) {
public int generateShippingInformBySalesOrder(SysSalesOrder sysSalesOrder,String outOrderCode,List<Long> salesOrderIdList) {
String loginName = ShiroUtils.getLoginName();
SysSalesShippingInform sysSalesShippingInform = new SysSalesShippingInform();
String salesOrderCode = sysSalesOrder.getSalesOrderCode();
if (StringUtils.isEmpty(salesOrderCode)){
log.warn("销售订单编号为空:{}",salesOrderCode);
}
// String salesOrderCode = sysSalesOrder.getSalesOrderCode();
// if (StringUtils.isEmpty(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.setWarehouseOutStatus("0");
sysSalesShippingInform.setSalesOrderCode(salesOrderCode);
//订单类型设置为 销售订单
sysSalesShippingInform.setWarehouseOrderType("0");
sysSalesShippingInform.setSalesOrderCode(salesOrderCodes);
//出库类型设置为 销售出库
sysSalesShippingInform.setWarehouseOutType("0");
sysSalesShippingInform.setCustomerId(sysSalesOrderVo.getEnterpriseCode());
sysSalesShippingInform.setCustomerName(sysSalesOrderVo.getEnterpriseName());
sysSalesShippingInform.setDeliveryCondition(sysSalesOrderVo.getDeliveryConditions());
sysSalesShippingInform.setCustomerId(sysSalesOrder.getEnterpriseCode());
sysSalesShippingInform.setCustomerName(sysSalesOrder.getEnterpriseName());
sysSalesShippingInform.setDeliveryCondition(sysSalesOrder.getDeliveryConditions());
sysSalesShippingInform.setCreateTime(new Date());
sysSalesShippingInform.setCreateBy(loginName);
sysSalesShippingInform.setAllPriceExcludingTaxDollar(BigDecimal.valueOf(sysSalesOrderVo.getNoUsdSum()));
sysSalesShippingInform.setAllPriceExcludingTaxRmb(BigDecimal.valueOf(sysSalesOrderVo.getNoRmbSum()));
sysSalesShippingInform.setAllPriceIncludesTax(BigDecimal.valueOf(sysSalesOrderVo.getRmbTaxSum()));
//更新物料合计
sysSalesShippingInform.setMaterialSum(Math.toIntExact(sysSalesOrderVo.getMaterialSum()));
//更新数量合计
sysSalesShippingInform.setEnterpriseSum(Math.toIntExact(sysSalesOrderVo.getEnterpriseSum()));
sysSalesShippingInform.setCustomerContact(sysSalesOrderVo.getCustomerDelivery());
sysSalesShippingInform.setContactNumber(sysSalesOrderVo.getDeliveryPhone());
sysSalesShippingInform.setCustomerContactAddress(sysSalesOrderVo.getDeliveryAddress());
sysSalesShippingInform.setBusinessMembers(loginName);
// 计算所有订单的合计金额(美元)
double totalNoUsdSum = sysSalesOrders.stream()
.filter(Objects::nonNull).mapToDouble(SysSalesOrder::getNoUsdSum).sum();
// 计算所有订单的合计金额(人民币)
double totalNoRmbSum = sysSalesOrders.stream()
.filter(Objects::nonNull).mapToDouble(SysSalesOrder::getNoRmbSum).sum();
// 计算所有订单的含税合计金额(人民币)
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.setContactNumberBillto(sysSalesOrder.getDeliveryPhoneBillto());
sysSalesShippingInform.setContactAddressBillto(sysSalesOrder.getDeliveryAddressBillto());
//更新销售出库详情数据
//更新销售出货通知详情数据
List<SysSalesOrderChild> sysSalesOrderChildList = sysSalesOrder.getSysSalesOrderChildList();
for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildList) {
SysSalesShippingInformDetail sysSalesShippingInformDetail = new SysSalesShippingInformDetail();
@ -240,7 +267,15 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor
sysSalesShippingInformDetail.setMaterialProcessMethod(sysSalesOrderChild.getProcessMethod());
sysSalesShippingInformDetail.setMakeNum(sysSalesOrderChild.getMaterialNum());
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.setCreateTime(new Date());
shippingInformDetailMapper.insertSysSalesShippingInformDetail(sysSalesShippingInformDetail);
@ -249,6 +284,24 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor
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;
}
/**
* 修改保存确认发货
*/

2
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseOutOrderService.java

@ -108,7 +108,7 @@ public interface IWarehouseOutOrderService
/**
* 通过销售发起出货生成仓库出库单
* */
int generateWarehouseOutOrderBySalesOrder(SysSalesOrder sysSalesOrder, String outOrderCode);
int generateWarehouseOutOrderBySalesOrder(SysSalesOrder sysSalesOrder, String outOrderCode, List<Long> salesOrderIdList);
/**
* 开发修改单领料审核通过后生产出库单

92
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java

@ -742,63 +742,89 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
* 通过销售发起出货生成仓库出库单
* */
@Override
public int generateWarehouseOutOrderBySalesOrder(SysSalesOrder sysSalesOrder,String outOrderCode) {
public int generateWarehouseOutOrderBySalesOrder(SysSalesOrder sysSalesOrder,String outOrderCode,List<Long> salesOrderIdList) {
String salesOrderCode = sysSalesOrder.getSalesOrderCode();
if (StringUtils.isEmpty(salesOrderCode)){
log.warn("销售订单编号为空:{}",salesOrderCode);
}
//从数据库查询的数据
SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderBySalesOrderCode(salesOrderCode);
// String salesOrderCode = sysSalesOrder.getSalesOrderCode();
// if (StringUtils.isEmpty(salesOrderCode)){
// log.warn("销售订单编号为空:{}",salesOrderCode);
// }
// //从数据库查询的数据
// SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderBySalesOrderCode(salesOrderCode);
WarehouseOutOrder warehouseOutOrder = new WarehouseOutOrder();
warehouseOutOrder.setOutOrderCode(outOrderCode);
//添加生产单号
SysMakeOrder makeOrder = sysMakeOrderMapper.selectMakeOrderBySaleNo(salesOrderCode);
if (makeOrder == null){
log.warn("生产订单编号为空:{}",makeOrder.getMakeNo());
}
String loginName = ShiroUtils.getLoginName();
List<SysSalesOrder> sysSalesOrders = sysSalesOrderMapper.selectBatchSalesOrderById(salesOrderIdList);
warehouseOutOrder.setDeliveryName(sysSalesOrderVo.getCustomerDelivery());
warehouseOutOrder.setDeliveryNumber(sysSalesOrderVo.getDeliveryPhone());
warehouseOutOrder.setDeliveryAddress(sysSalesOrderVo.getDeliveryAddress());
String salesOrderCodes = getSalesOrderCodes(sysSalesOrders);
WarehouseOutOrder warehouseOutOrder = new WarehouseOutOrder();
warehouseOutOrder.setOutOrderCode(outOrderCode);
warehouseOutOrder.setDeliveryName(sysSalesOrder.getCustomerDelivery());
warehouseOutOrder.setDeliveryNumber(sysSalesOrder.getDeliveryPhone());
warehouseOutOrder.setDeliveryAddress(sysSalesOrder.getDeliveryAddress());
warehouseOutOrder.setMakeNo(makeOrder.getMakeNo());
//出库状态为 待仓库准备物料
warehouseOutOrder.setWarehouseOutStatus("0");
warehouseOutOrder.setRelatedOrderCode(salesOrderCode);
warehouseOutOrder.setSalesOrderCode(salesOrderCode);
warehouseOutOrder.setRelatedOrderCode(salesOrderCodes);
// warehouseOutOrder.setSalesOrderCode(salesOrderCode);
//订单类型设置为 销售订单
warehouseOutOrder.setWarehouseOrderType("0");
//出库类型设置为 销售出库
warehouseOutOrder.setWarehouseOutType("0");
// 计算所有订单的物料合计
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();
//物料合计
warehouseOutOrder.setMaterialSum(Math.toIntExact(sysSalesOrderVo.getMaterialSum()));
warehouseOutOrder.setMaterialSum(Math.toIntExact(totalMaterialSum));
//数量合计
warehouseOutOrder.setEnterpriseSum(Math.toIntExact(sysSalesOrderVo.getEnterpriseSum()));
warehouseOutOrder.setEnterpriseSum(Math.toIntExact(totalEnterpriseSum));
warehouseOutOrder.setBusinessName(sysSalesOrderVo.getBusinessMembers());
warehouseOutOrder.setCustomerId(sysSalesOrderVo.getEnterpriseCode());
warehouseOutOrder.setCustomerName(sysSalesOrderVo.getEnterpriseName());
warehouseOutOrder.setApplyName(sysSalesOrderVo.getApplyUser());
warehouseOutOrder.setDeliveryCondition(sysSalesOrderVo.getDeliveryConditions());
warehouseOutOrder.setBusinessName(loginName);
warehouseOutOrder.setCustomerId(sysSalesOrder.getEnterpriseCode());
warehouseOutOrder.setCustomerName(sysSalesOrder.getEnterpriseName());
warehouseOutOrder.setApplyName(sysSalesOrder.getApplyUser());
warehouseOutOrder.setDeliveryCondition(sysSalesOrder.getDeliveryConditions());
warehouseOutOrder.setCreateTime(new Date());
warehouseOutOrder.setCreateBy(ShiroUtils.getLoginName());
//新增出库单明细
CreateOutOrderDetailBySalesOrderChildList(sysSalesOrder, salesOrderCode, sysSalesOrderVo, outOrderCode);
CreateOutOrderDetailBySalesOrderChildList(sysSalesOrder,outOrderCode);
return warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder);
}
//处理多个销售订单发货的单号拼接问题
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;
}
//新增出库单明细
private void CreateOutOrderDetailBySalesOrderChildList(SysSalesOrder sysSalesOrder, String salesOrderCode, SysSalesOrderVo sysSalesOrderVo, String outOrderCode) {
private void CreateOutOrderDetailBySalesOrderChildList(SysSalesOrder sysSalesOrder,String outOrderCode) {
List<SysSalesOrderChild> sysSalesOrderChildList = sysSalesOrder.getSysSalesOrderChildList();
for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildList) {
WarehouseOutOrderDetail warehouseOutOrderDetail = new WarehouseOutOrderDetail();
warehouseOutOrderDetail.setOutOrderCode(outOrderCode);
warehouseOutOrderDetail.setRelatedOrderCode(salesOrderCode);
warehouseOutOrderDetail.setRelatedOrderCode(sysSalesOrderChild.getQuoteId());
warehouseOutOrderDetail.setMaterialNo(sysSalesOrderChild.getMaterialCode());
warehouseOutOrderDetail.setMaterialName(sysSalesOrderChild.getMaterialName());
warehouseOutOrderDetail.setMaterialType(sysSalesOrderChild.getMaterialType());
@ -808,9 +834,9 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
warehouseOutOrderDetail.setMaterialProcessMethod(sysSalesOrderChild.getProcessMethod());
warehouseOutOrderDetail.setMakeNum(sysSalesOrderChild.getMaterialNum());
warehouseOutOrderDetail.setApplyOutOrderSum(sysSalesOrderChild.getApplyShippingNum());
warehouseOutOrderDetail.setCustomerId(sysSalesOrderVo.getEnterpriseCode());
warehouseOutOrderDetail.setCustomerName(sysSalesOrderVo.getEnterpriseName());
warehouseOutOrderDetail.setDeliveryCondition(sysSalesOrderVo.getDeliveryConditions());
warehouseOutOrderDetail.setCustomerId(sysSalesOrder.getEnterpriseCode());
warehouseOutOrderDetail.setCustomerName(sysSalesOrder.getEnterpriseName());
warehouseOutOrderDetail.setDeliveryCondition(sysSalesOrder.getDeliveryConditions());
warehouseOutOrderDetail.setCreateTime(new Date());
warehouseOutOrderDetail.setCreateBy(ShiroUtils.getLoginName());
int insertOutOrderDetailResult = outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail);

13
ruoyi-admin/src/main/resources/mapper/system/SysSalesOrderChildMapper.xml

@ -127,6 +127,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(1) from sys_sales_order_child where materialCode = #{materialCode}
</select>
<select id="selectBatchOrderChildListBySalesOrderCode" parameterType="String" resultMap="SysSalesOrderChildResult">
select id, quoteId, materialId, materialCode, materialName, materialType, processMethod, material_model, brand, photoUrl,unit, `describe`,
warehouseDept,countTax, usdTax, materialNum,materialSole , recentQuotation_rmb, recentQuotation_usd, materialRmb, materialNoRmb, materialNoUsd, materialUsd, materialUsdSum,
materialNoUsdSum, materialNoRmbSum, materialRmbSum,delivery_time, expiry_day,
out_bound_quantity, un_bound_quantity, create_by, create_time, update_by,
update_time, remark, use_status,audit_status,finish_num,apply_shipping_num,has_apply_shipping_num, has_check_num
from sys_sales_order_child
where quoteId in
<foreach item="item" collection="list" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<insert id="insertSysSalesOrderChild" parameterType="SysSalesOrderChild" useGeneratedKeys="true" keyProperty="id">
insert into sys_sales_order_child

12
ruoyi-admin/src/main/resources/templates/system/salesOrder/add.html

@ -447,12 +447,20 @@
{ title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center',},
{ title: '物料的含税总价(美元)',field: 'materialUsdSum', align: 'center',},
{ title: '物料的不含税总价(美元)',field: 'materialNoUsdSum',align: 'center',},
{ title: '计划交付时间',field: 'deliveryTime',align: 'center',editable: {type: 'date',title: '计划交付时间',} },
{ title: '计划交付时间',field: 'deliveryTime',align: 'center',
editable: {type: 'date',title: '计划交付时间',
validate: function(value) {
if (!$.trim(value)) {
return '计划交付时间不能为空';
}
},
}
},
{title: '质保天数',align: 'center',field: 'expiryDay',
editable: {
type: 'text',emptyText: "天数",enabled:true,title: '质保天数',
validate: function (value) { //字段验证
if (!$.trim(value)) {return '不能为空';}
if (!$.trim(value)) {return '质保天数不能为空';}
}
},
format: function (value, row, index) { return value + "天数";}

33
ruoyi-admin/src/main/resources/templates/system/salesOrder/salesDeliverGoods.html

@ -30,8 +30,8 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label">申请人员:</label>
<div class="col-sm-7">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" disabled>
<div class="col-sm-8">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
@ -119,6 +119,8 @@
var sysSalesOrder = [[${sysSalesOrder}]];
var salesOrderIdList = [[${salesOrderIdList}]];
var prefix = ctx + "system/salesOrder";
$("#form-salesDeliverGoods-edit").validate({
focusCleanup: true
@ -139,6 +141,7 @@
// 根据实际字段名调整
return {
"id":item.id,
"quoteId": item.quoteId,
"materialCode": item.materialCode,
"materialName": item.materialName,
"materialType": item.materialType,
@ -158,6 +161,7 @@
const combinedData = Object.assign({}, salesOrderData, {
sysSalesOrderChildList: materialDataList,
salesOrderIdList: salesOrderIdList
});
// 合并表单数据和表格数据
console.log(combinedData)
@ -313,6 +317,11 @@
field: 'id',
visible: false
},
{
title: '销售订单号',
field: 'quoteId',
visible: false
},
{
title: '料号',
field: 'materialCode',
@ -371,7 +380,23 @@
{
title: '申请出货数',
field: 'applyShippingNum',
editable:true,
editable: {
validate: function(value) {
if ($.trim(value) === '') {
return '申请出货数不能为空';
}
if (isNaN(value)) {
return '申请出货数不能为空';
}
if (value < 0) {
return '申请出货数不能为空';
}
//不能为小数
if (value % 1 !== 0) {
return '申请出货数不能为空';
}
},
},
formatter: function (value, row) {
// 检查 row 是否存在
if (!row) {
@ -399,7 +424,7 @@
function queryParams(params) {
var curParams = {
// 传递参数查询参数
salesOrderCode: sysSalesOrder.salesOrderCode
salesOrderIdList: salesOrderIdList
};
return curParams;
}

Loading…
Cancel
Save