refactor(sip): 重构维保信息展示逻辑
- 将服务信息封装为 ServiceInfo 类,提高数据结构的可维护性- 使用列表存储多个服务信息,支持更灵活的服务展示 -优化服务开始时间和结束时间的计算逻辑 - 移除冗余代码,提高代码可读性和性能master
parent
2b67e65246
commit
57b8f6d237
|
@ -2,14 +2,11 @@ package com.ruoyi.sip.service.impl;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.sip.domain.OrderList;
|
import com.ruoyi.sip.domain.OrderList;
|
||||||
|
@ -18,7 +15,6 @@ import com.ruoyi.sip.dto.ApiDataQueryDto;
|
||||||
import com.ruoyi.sip.mapper.OrderInfoMapper;
|
import com.ruoyi.sip.mapper.OrderInfoMapper;
|
||||||
import com.ruoyi.sip.mapper.ProductInfoMapper;
|
import com.ruoyi.sip.mapper.ProductInfoMapper;
|
||||||
import com.ruoyi.sip.vo.DeliveryInfoVo;
|
import com.ruoyi.sip.vo.DeliveryInfoVo;
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.sip.mapper.DeliveryListMapper;
|
import com.ruoyi.sip.mapper.DeliveryListMapper;
|
||||||
import com.ruoyi.sip.domain.DeliveryList;
|
import com.ruoyi.sip.domain.DeliveryList;
|
||||||
|
@ -206,14 +202,14 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
|
||||||
*/
|
*/
|
||||||
private void updateDeliveryInfoVo(DeliveryInfoVo deliveryInfoVo, Map<Long, List<ProductInfo>> maintenanceTypeMap, List<ProductInfo> productInfos) {
|
private void updateDeliveryInfoVo(DeliveryInfoVo deliveryInfoVo, Map<Long, List<ProductInfo>> maintenanceTypeMap, List<ProductInfo> productInfos) {
|
||||||
List<ProductInfo> productInfoList = maintenanceTypeMap.get(deliveryInfoVo.getOrderId());
|
List<ProductInfo> productInfoList = maintenanceTypeMap.get(deliveryInfoVo.getOrderId());
|
||||||
|
List<DeliveryInfoVo.ServiceInfo> serviceInfoList = new ArrayList<>();
|
||||||
if (CollUtil.isNotEmpty(productInfoList)) {
|
if (CollUtil.isNotEmpty(productInfoList)) {
|
||||||
int year = 0;
|
Date startTime = deliveryInfoVo.getServiceStartTime();
|
||||||
StringJoiner desc=new StringJoiner(";");
|
|
||||||
if (ProductInfo.ProductTypeEnum.SOFTWARE.getType().equals(deliveryInfoVo.getProductType())) {
|
if (ProductInfo.ProductTypeEnum.SOFTWARE.getType().equals(deliveryInfoVo.getProductType())) {
|
||||||
for (ProductInfo productInfo : productInfoList) {
|
for (ProductInfo productInfo : productInfoList) {
|
||||||
if (ProductInfo.ProductTypeEnum.SOFTWARE_MAINTENANCE.getType().equals(productInfo.getType()) && StringUtils.isNotEmpty(productInfo.getValue())) {
|
if (ProductInfo.ProductTypeEnum.SOFTWARE_MAINTENANCE.getType().equals(productInfo.getType()) && StringUtils.isNotEmpty(productInfo.getValue())) {
|
||||||
year += Integer.parseInt(productInfo.getValue());
|
startTime = updateStartTimeAndAddList(deliveryInfoVo, productInfo, startTime, serviceInfoList);
|
||||||
desc.add(productInfo.getDescription());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,24 +217,33 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
|
||||||
} else {
|
} else {
|
||||||
for (ProductInfo productInfo : productInfoList) {
|
for (ProductInfo productInfo : productInfoList) {
|
||||||
if (ProductInfo.ProductTypeEnum.HARDWARE_MAINTENANCE.getType().equals(productInfo.getType()) && StringUtils.isNotEmpty(productInfo.getValue())) {
|
if (ProductInfo.ProductTypeEnum.HARDWARE_MAINTENANCE.getType().equals(productInfo.getType()) && StringUtils.isNotEmpty(productInfo.getValue())) {
|
||||||
year += Integer.parseInt(productInfo.getValue());
|
startTime = updateStartTimeAndAddList(deliveryInfoVo, productInfo, startTime, serviceInfoList);
|
||||||
desc.add(productInfo.getDescription());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (year == 0 && ProductInfo.ProductTypeEnum.HARDWARE.getType().equals(deliveryInfoVo.getProductType())
|
if (CollUtil.isEmpty(serviceInfoList) && ProductInfo.ProductTypeEnum.HARDWARE.getType().equals(deliveryInfoVo.getProductType())
|
||||||
&& CollUtil.isNotEmpty(productInfos)) {
|
&& CollUtil.isNotEmpty(productInfos)) {
|
||||||
// 判断是否硬件,如果是硬件取标准维保三年
|
// 判断是否硬件,如果是硬件取标准维保三年
|
||||||
if (StringUtils.isNotEmpty(productInfos.get(0).getValue())) {
|
if (StringUtils.isNotEmpty(productInfos.get(0).getValue())) {
|
||||||
year = Integer.parseInt(productInfos.get(0).getValue());
|
startTime = updateStartTimeAndAddList(deliveryInfoVo, productInfos.get(0), startTime, serviceInfoList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deliveryInfoVo.setServiceInfo(serviceInfoList);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deliveryInfoVo.setServiceLevel(Integer.toString(year));
|
private static Date updateStartTimeAndAddList(DeliveryInfoVo deliveryInfoVo, ProductInfo productInfo, Date startTime, List<DeliveryInfoVo.ServiceInfo> serviceInfoList) {
|
||||||
deliveryInfoVo.setServiceDescribe(desc.toString());
|
int year = Integer.parseInt(productInfo.getValue());
|
||||||
deliveryInfoVo.setServiceEndTime(DateUtils.addYears(deliveryInfoVo.getServiceStartTime(), year));
|
DeliveryInfoVo.ServiceInfo serviceInfo = deliveryInfoVo.new ServiceInfo();
|
||||||
}
|
serviceInfo.setServiceLevel(productInfo.getValue());
|
||||||
|
serviceInfo.setServiceDescribe(productInfo.getDescription());
|
||||||
|
serviceInfo.setServiceStartTime(startTime);
|
||||||
|
serviceInfo.setServiceEndTime(DateUtils.addYears(startTime, year));
|
||||||
|
startTime = DateUtils.addYears(startTime, year);
|
||||||
|
serviceInfoList.add(serviceInfo);
|
||||||
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : ch
|
* @author : ch
|
||||||
|
@ -32,8 +33,19 @@ public class DeliveryInfoVo {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String productName;
|
private String productName;
|
||||||
private String productDescription;
|
private String productDescription;
|
||||||
|
@JsonIgnore
|
||||||
|
private Date serviceStartTime;
|
||||||
|
private List<ServiceInfo> serviceInfo;
|
||||||
|
|
||||||
|
private Date lastUpdateTime;
|
||||||
|
@JsonIgnore
|
||||||
|
private Long orderId;
|
||||||
|
@JsonIgnore
|
||||||
|
private String productType;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ServiceInfo {
|
||||||
//服务级别
|
//服务级别
|
||||||
private String serviceLevel;
|
private String serviceLevel;
|
||||||
//服务描述
|
//服务描述
|
||||||
|
@ -43,9 +55,5 @@ public class DeliveryInfoVo {
|
||||||
private Date serviceStartTime;
|
private Date serviceStartTime;
|
||||||
//服务结束时间
|
//服务结束时间
|
||||||
private Date serviceEndTime;
|
private Date serviceEndTime;
|
||||||
private Date lastUpdateTime;
|
}
|
||||||
@JsonIgnore
|
|
||||||
private Long orderId;
|
|
||||||
@JsonIgnore
|
|
||||||
private String productType;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue