Browse Source

[feat]售后管理

修改 售后确认验收后端接口:验收的同时,需要更新销售订单的出货状态,因为销售订单号是拼接的,需要遍历其每一个子表,并且要等每一个子表的订单数量和已验收数量相等才能设置该销售订单全部验收,否则部分验收;
修改 分别处理没有设备id的数据和有设备id的数据,实现:按照交付时间和当前时间的前后更新已验收数
dev
liuxiaoxu 2 weeks ago
parent
commit
ddc8b0752a
  1. 151
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOutOrderServiceImpl.java

151
ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOutOrderServiceImpl.java

@ -14,9 +14,11 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysSalesOrder; import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.domain.SysSalesShippingInform; import com.ruoyi.system.domain.SysSalesShippingInform;
import com.ruoyi.system.domain.SysSalesShippingInformDetail; import com.ruoyi.system.domain.SysSalesShippingInformDetail;
import com.ruoyi.system.domain.Vo.ConfirmReceivingDetailVo; import com.ruoyi.system.domain.Vo.ConfirmReceivingDetailVo;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.mapper.SysSalesOrderMapper; import com.ruoyi.system.mapper.SysSalesOrderMapper;
import com.ruoyi.system.mapper.SysSalesShippingInformDetailMapper; import com.ruoyi.system.mapper.SysSalesShippingInformDetailMapper;
import com.ruoyi.system.mapper.SysSalesShippingInformMapper; import com.ruoyi.system.mapper.SysSalesShippingInformMapper;
@ -33,7 +35,6 @@ import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import static com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder.log;
/** /**
* 售后维护设备出库Service业务层处理 * 售后维护设备出库Service业务层处理
@ -66,6 +67,9 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
@Autowired @Autowired
private SysSalesOrderMapper sysSalesOrderMapper; private SysSalesOrderMapper sysSalesOrderMapper;
@Autowired
private SysSalesOrderChildMapper salesOrderChildMapper;
/** /**
* 查询售后维护设备出库 * 查询售后维护设备出库
* *
@ -649,12 +653,12 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
if (!CollectionUtils.isEmpty(withoutShippingDeviceIdList)){ if (!CollectionUtils.isEmpty(withoutShippingDeviceIdList)){
// 处理没有出货设备ID的数据 // 处理没有出货设备ID的数据
allWithoutCheckFlag = processWithoutShippingDeviceId(withoutShippingDeviceIdList, allWithoutCheckFlag); allWithoutCheckFlag = processWithoutShippingDeviceId(withoutShippingDeviceIdList, allWithoutCheckFlag,sysSalesShippingInform);
} }
if (!CollectionUtils.isEmpty(withShippingDeviceIdList)){ if (!CollectionUtils.isEmpty(withShippingDeviceIdList)){
// 处理有出货设备ID的数据 // 处理有出货设备ID的数据
allWithCheckFlag = processWithShippingDeviceId(withShippingDeviceIdList, allWithCheckFlag); allWithCheckFlag = processWithShippingDeviceId(withShippingDeviceIdList, allWithCheckFlag,sysSalesShippingInform);
} }
@ -674,7 +678,40 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
salesOrderCodes = Arrays.asList(splitSalesOrderCode); salesOrderCodes = Arrays.asList(splitSalesOrderCode);
} }
// List<SysSalesOrder> sysSalesOrders = sysSalesOrderMapper.selectSysSalesOrderListByCodeList(salesOrderCodes); List<SysSalesOrder> sysSalesOrders = sysSalesOrderMapper.selectSysSalesOrderListByCodeList(salesOrderCodes);
List<SysSalesOrderChild> sysSalesOrderChildren = salesOrderChildMapper.selectBatchOrderChildListBySalesOrderCode(salesOrderCodes);
//创建映射,用于快速查找每个销售订单号对应的子表数据
Map<String, List<SysSalesOrderChild>> orderCodeToChildrenMap = sysSalesOrderChildren.stream().collect(Collectors.groupingBy(SysSalesOrderChild::getQuoteId));
//遍历每个销售订单主表的数据
for (SysSalesOrder sysSalesOrder : sysSalesOrders) {
String orderCode = sysSalesOrder.getSalesOrderCode();
List<SysSalesOrderChild> childrenList = orderCodeToChildrenMap.get(orderCode);
if (!CollectionUtils.isEmpty(childrenList)){
//检查子表数据的所有订单数量和已验收数量是否相等
boolean allNumbersEqual = childrenList.stream()
.allMatch(child -> Objects.equals(child.getMaterialNum(), child.getHasCheckNum()));
if (allNumbersEqual){
sysSalesOrder.setDeliveryStatus("8");
}else {
sysSalesOrder.setDeliveryStatus("7");
}
}else {
sysSalesOrder.setDeliveryStatus("7");
}
sysSalesOrder.setUpdateTime(new Date());
sysSalesOrder.setUpdateBy(loginName);
int updateSysSalesOrderResult = sysSalesOrderMapper.updateSysSalesOrderBySalesOrderCode(sysSalesOrder);
if (updateSysSalesOrderResult <= 0){
throw new BusinessException("更新销售订单数据失败");
}
}
//设置为全部验收 //设置为全部验收
if (allWithoutCheckFlag == 1 && allWithCheckFlag == 1){ if (allWithoutCheckFlag == 1 && allWithCheckFlag == 1){
@ -718,9 +755,10 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
} }
private Integer processWithoutShippingDeviceId(List<SysSalesShippingInformDetail> withoutShippingDeviceIdList,Integer allWithoutCheckFlag) { private Integer processWithoutShippingDeviceId(List<SysSalesShippingInformDetail> withoutShippingDeviceIdList,Integer allWithoutCheckFlag,SysSalesShippingInform sysSalesShippingInform) {
String loginName = ShiroUtils.getLoginName();
for (SysSalesShippingInformDetail sysSalesShippingInformDetail : withoutShippingDeviceIdList) { for (SysSalesShippingInformDetail sysSalesShippingInformDetail : withoutShippingDeviceIdList) {
Long shippingInformDetailId = sysSalesShippingInformDetail.getShippingInformDetailId(); Long shippingInformDetailId = sysSalesShippingInformDetail.getShippingInformDetailId();
@ -736,10 +774,50 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
throw new BusinessException("已验收数和本次验收数之和不能大于已收货数"); throw new BusinessException("已验收数和本次验收数之和不能大于已收货数");
} }
sysSalesShippingInformDetail.setThisCheckNum(null); sysSalesShippingInformDetail.setThisCheckNum(null);
sysSalesShippingInformDetail.setUpdateTime(new Date());
sysSalesShippingInformDetail.setUpdateBy(loginName);
if (Objects.equals(tempShippingInformDetail.getThisShippingNum(), sysSalesShippingInformDetail.getHasCheckNum())){ if (Objects.equals(tempShippingInformDetail.getThisShippingNum(), sysSalesShippingInformDetail.getHasCheckNum())){
allWithoutCheckFlag = 1; allWithoutCheckFlag = 1;
} }
// 当前时间
Date now = new Date();
// 从数据库中查询销售出库单信息
sysSalesShippingInform = shippingInformMapper.selectSysSalesShippingInformByCode(sysSalesShippingInform.getOutOrderCode());
String salesOrderCode = sysSalesShippingInform.getSalesOrderCode();
String materialNo = sysSalesShippingInformDetail.getMaterialNo();
List<String> salesOrderCodes = new ArrayList<>();
if (StringUtils.isNotEmpty(salesOrderCode)) {
salesOrderCodes = Arrays.asList(salesOrderCode.split(","));
}
// 存储每个销售订单详情及其计划交付时间
List<SysSalesOrderChild> orderChildren = new ArrayList<>();
for (String orderCode : salesOrderCodes) {
SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild();
sysSalesOrderChild.setMaterialCode(materialNo);
sysSalesOrderChild.setQuoteId(orderCode);
SysSalesOrderChild tempSalesOrderChild = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild);
if (tempSalesOrderChild != null) {
orderChildren.add(tempSalesOrderChild);
}
}
//按照计划交付时间与当前时间的差值排序
orderChildren.sort(Comparator.comparing(o->Math.abs(o.getDeliveryTime().getTime() - now.getTime())));
//更新 HasCheckNum 数据
for (SysSalesOrderChild orderChild : orderChildren) {
orderChild.setUpdateTime(new Date());
orderChild.setUpdateBy(loginName);
orderChild.setHasCheckNum(sysSalesShippingInformDetail.getHasCheckNum());
int updateSalesOrderChildResult = salesOrderChildMapper.updateSysSalesOrderChildByCodeAndQuoteId(orderChild);
if (updateSalesOrderChildResult <= 0) {
throw new BusinessException("更新销售订单子表数据失败");
}
}
int updateShippingInformDetailResult = shippingInformDetailMapper.updateSysSalesShippingInformDetail(sysSalesShippingInformDetail); int updateShippingInformDetailResult = shippingInformDetailMapper.updateSysSalesShippingInformDetail(sysSalesShippingInformDetail);
if (updateShippingInformDetailResult <= 0) { if (updateShippingInformDetailResult <= 0) {
@ -749,7 +827,7 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
return allWithoutCheckFlag; return allWithoutCheckFlag;
} }
private Integer processWithShippingDeviceId(List<SysSalesShippingInformDetail> withShippingDeviceIdList,Integer allWithCheckFlag) { private Integer processWithShippingDeviceId(List<SysSalesShippingInformDetail> withShippingDeviceIdList,Integer allWithCheckFlag,SysSalesShippingInform sysSalesShippingInform) {
String loginName = ShiroUtils.getLoginName(); String loginName = ShiroUtils.getLoginName();
// List<SysSalesShippingInformDetail> filterShippingDeviceIdList = withShippingDeviceIdList.stream() // List<SysSalesShippingInformDetail> filterShippingDeviceIdList = withShippingDeviceIdList.stream()
@ -795,6 +873,65 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
allWithCheckFlag = 1; allWithCheckFlag = 1;
} }
// //当前时间
// Date now = new Date();
// SysSalesShippingInform sysSalesShippingInform = shippingInformMapper.selectSysSalesShippingInformByCode(sysSalesShippingInformDetail.getOutOrderCode());
// String salesOrderCode = sysSalesShippingInform.getSalesOrderCode();
// String materialNo = sysSalesShippingInformDetail.getMaterialNo();
// List<String> salesOrderCodes = new ArrayList<>();
//
// if (StringUtils.isNotEmpty(salesOrderCode)){
// String[] splitSalesOrderCode = salesOrderCode.split(",");
// salesOrderCodes = Arrays.asList(splitSalesOrderCode);
// }
// for (String orderCode : salesOrderCodes) {
// SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild();
// sysSalesOrderChild.setMaterialCode(materialNo);
// sysSalesOrderChild.setQuoteId(orderCode);
// SysSalesOrderChild tempSalesOrderChild = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild);
// long time = tempSalesOrderChild.getDeliveryTime().getTime();
// }
// 当前时间
Date now = new Date();
// 从数据库中查询销售出库单信息
sysSalesShippingInform = shippingInformMapper.selectSysSalesShippingInformByCode(sysSalesShippingInform.getOutOrderCode());
String salesOrderCode = sysSalesShippingInform.getSalesOrderCode();
String materialNo = sysSalesShippingInformDetail.getMaterialNo();
List<String> salesOrderCodes = new ArrayList<>();
if (StringUtils.isNotEmpty(salesOrderCode)) {
salesOrderCodes = Arrays.asList(salesOrderCode.split(","));
}
// 存储每个销售订单详情及其计划交付时间
List<SysSalesOrderChild> orderChildren = new ArrayList<>();
for (String orderCode : salesOrderCodes) {
SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild();
sysSalesOrderChild.setMaterialCode(materialNo);
sysSalesOrderChild.setQuoteId(orderCode);
SysSalesOrderChild tempSalesOrderChild = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild);
if (tempSalesOrderChild != null) {
orderChildren.add(tempSalesOrderChild);
}
}
//按照计划交付时间与当前时间的差值排序
orderChildren.sort(Comparator.comparing(o->Math.abs(o.getDeliveryTime().getTime() - now.getTime())));
//更新 HasCheckNum 数据
for (SysSalesOrderChild orderChild : orderChildren) {
orderChild.setUpdateTime(new Date());
orderChild.setUpdateBy(loginName);
orderChild.setHasCheckNum(sysSalesShippingInformDetail.getHasCheckNum());
int updateSalesOrderChildResult = salesOrderChildMapper.updateSysSalesOrderChildByCodeAndQuoteId(orderChild);
if (updateSalesOrderChildResult <= 0) {
throw new BusinessException("更新销售订单子表数据失败");
}
}
int updateShippingInformDetailResult = shippingInformDetailMapper.updateSysSalesShippingInformDetail(tempShippingInformDetail); int updateShippingInformDetailResult = shippingInformDetailMapper.updateSysSalesShippingInformDetail(tempShippingInformDetail);
if (updateShippingInformDetailResult <= 0) { if (updateShippingInformDetailResult <= 0) {
throw new BusinessException("更新销售出货通知单详情数据失败"); throw new BusinessException("更新销售出货通知单详情数据失败");

Loading…
Cancel
Save