feat(sip): 添加产品信息类型和价值字段

- 在 ProductInfo 模型中添加 type 和 value 字段
- 更新相关 mapper 和 SQL 文件以支持新字段
- 修改 OrderList 模型,关联 ProductInfo 对象
- 优化 DeliveryInfoVo 和相关服务的实现
master
chenhao 2025-05-14 14:48:25 +08:00
parent adfa574c39
commit 4988710301
11 changed files with 295 additions and 158 deletions

View File

@ -3,6 +3,8 @@ package com.ruoyi.sip.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -14,6 +16,8 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author mula
* @date 2025-04-11
*/
@Data
@ToString
public class OrderList extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -60,107 +64,5 @@ public class OrderList extends BaseEntity
@Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date deletedAt;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setOrderId(Long orderId)
{
this.orderId = orderId;
}
public Long getOrderId()
{
return orderId;
}
public void setProductCode(String productCode)
{
this.productCode = productCode;
}
public String getProductCode()
{
return productCode;
}
public String getProductName()
{
return productName;
}
public void setQuantity(Long quantity)
{
this.quantity = quantity;
}
public Long getQuantity()
{
return quantity;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setAmount(BigDecimal amount)
{
this.amount = amount;
}
public BigDecimal getAmount()
{
return amount;
}
public void setCreatedAt(Date createdAt)
{
this.createdAt = createdAt;
}
public Date getCreatedAt()
{
return createdAt;
}
public void setUpdatedAt(Date updatedAt)
{
this.updatedAt = updatedAt;
}
public Date getUpdatedAt()
{
return updatedAt;
}
public void setDeletedAt(Date deletedAt)
{
this.deletedAt = deletedAt;
}
public Date getDeletedAt()
{
return deletedAt;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderId", getOrderId())
.append("productCode", getProductCode())
.append("productName", getProductName())
.append("quantity", getQuantity())
.append("price", getPrice())
.append("amount", getAmount())
.append("remark", getRemark())
.append("createdAt", getCreatedAt())
.append("updatedAt", getUpdatedAt())
.append("deletedAt", getDeletedAt())
.toString();
}
private ProductInfo productInfo;
}

View File

@ -4,6 +4,7 @@ import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -27,6 +28,8 @@ public class ProductInfo extends BaseEntity
/** 产品编码 */
@Excel(name = "产品编码")
private String productCode;
private String type;
private String value;
/** 产品名称 */
@Excel(name = "产品名称")
@ -52,4 +55,38 @@ public class ProductInfo extends BaseEntity
private Date deletedAt;
private String serialNumber;
@Getter
public enum ProductTypeEnum {
/**
*
*/
SOFTWARE("1","软件"),
/**
*
*/
HARDWARE("2","硬件"),
/**
*
*/
SOFTWARE_MAINTENANCE("11","软件维保"),
/**
*
*/
HARDWARE_MAINTENANCE("22","硬件维保"),
/**
*
*/
OTHER("99","其它"),
;
private final String type;
private final String desc;
ProductTypeEnum(String type,String desc) {
this.type = type;
this.desc = desc;
}
}
}

View File

@ -2,6 +2,8 @@ package com.ruoyi.sip.mapper;
import java.util.List;
import com.ruoyi.sip.domain.DeliveryList;
import com.ruoyi.sip.dto.ApiDataQueryDto;
import com.ruoyi.sip.vo.DeliveryInfoVo;
/**
* Mapper
@ -61,4 +63,6 @@ public interface DeliveryListMapper
public int deleteDeliveryListByIds(String[] ids);
List<DeliveryList> listBySerialNumberList(List<DeliveryList> deliveryList);
List<DeliveryInfoVo> listNumberInfo(ApiDataQueryDto dto);
}

View File

@ -103,4 +103,6 @@ public interface OrderInfoMapper
List<OrderList> listOrderListByDeliveryId(Long deliveryId);
List<OrderInfo> selectOrderInfoByMaintenance(MaintenanceRecordsDto dto);
List<OrderList> listMaintenanceByOrderIdList(List<Long> orderIdList);
}

View File

@ -1,11 +1,15 @@
package com.ruoyi.sip.service.impl;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.domain.OrderList;
import com.ruoyi.sip.domain.ProductInfo;
@ -137,13 +141,86 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
@Override
public List<DeliveryInfoVo> getNumberInfo(ApiDataQueryDto dto) {
List<DeliveryInfoVo> deliveryInfoVos = deliveryListMapper.listNumberInfo(dto);
if (CollUtil.isEmpty(deliveryInfoVos)) {
return Collections.emptyList();
}
List<Long> orderIdList = deliveryInfoVos.stream()
.map(DeliveryInfoVo::getOrderId)
.collect(Collectors.toList());
// 根据订单ID查询合同信息
List<OrderList> orderListList = infoMapper.listMaintenanceByOrderIdList(orderIdList);
// 构建维护类型与年限的映射
Map<Long, Map<String, Integer>> maintenanceTypeYearMap = buildMaintenanceTypeYearMap(orderListList);
// 查询标准硬件维保的产品信息
ProductInfo productInfo = new ProductInfo();
productInfo.setType(ProductInfo.ProductTypeEnum.HARDWARE_MAINTENANCE.getType());
List<ProductInfo> productInfos = productInfoMapper.selectProductInfoList(productInfo);
// 设置服务等级和服务结束时间
for (DeliveryInfoVo deliveryInfoVo : deliveryInfoVos) {
updateDeliveryInfoVo(deliveryInfoVo, maintenanceTypeYearMap, productInfos);
}
return Collections.emptyList();
return deliveryInfoVos;
}
/**
*
*/
private Map<Long, Map<String, Integer>> buildMaintenanceTypeYearMap(List<OrderList> orderListList) {
return orderListList.stream()
.filter(item -> item.getProductInfo() != null)
.collect(Collectors.groupingBy(
OrderList::getOrderId,
Collectors.toMap(
item -> item.getProductInfo().getType(),
this::calculateYear,
Integer::sum
)
));
}
/**
*
*/
private Integer calculateYear(OrderList item) {
if (item.getQuantity() == null || StrUtil.isEmpty(item.getProductInfo().getValue())) {
return 0;
}
return BigDecimal.valueOf(item.getQuantity())
.multiply(new BigDecimal(item.getProductInfo().getValue()))
.intValue();
}
/**
* DeliveryInfoVo
*/
private void updateDeliveryInfoVo(DeliveryInfoVo deliveryInfoVo, Map<Long, Map<String, Integer>> maintenanceTypeYearMap, List<ProductInfo> productInfos) {
Map<String, Integer> yearMap = maintenanceTypeYearMap.get(deliveryInfoVo.getOrderId());
if (yearMap != null) {
Integer year;
if (ProductInfo.ProductTypeEnum.SOFTWARE.getType().equals(deliveryInfoVo.getProductType())) {
year = yearMap.getOrDefault(ProductInfo.ProductTypeEnum.SOFTWARE_MAINTENANCE.getType(), 0);
} else {
year = yearMap.getOrDefault(ProductInfo.ProductTypeEnum.HARDWARE_MAINTENANCE.getType(), 0);
}
if (year == 0 && ProductInfo.ProductTypeEnum.HARDWARE.getType().equals(deliveryInfoVo.getProductType())
&& CollUtil.isNotEmpty(productInfos)) {
// 判断是否硬件,如果是硬件取标准维保三年
if (StringUtils.isNotEmpty(productInfos.get(0).getValue())) {
year = Integer.valueOf(productInfos.get(0).getValue());
}
}
deliveryInfoVo.setServiceLevel(year.toString());
deliveryInfoVo.setServiceEndTime(DateUtils.addYears(deliveryInfoVo.getServiceStartTime(), year));
}
}
}

View File

@ -159,55 +159,89 @@ public class OrderInfoServiceImpl implements IOrderInfoService
queryParams.setUpdatedAtEnd(dto.getQueryEndTime());
List<OrderInfo> orderInfos = orderInfoMapper.selectOrderInfoList(queryParams);
//查询代表处信息
AgentInfo agentInfoQueryParams = new AgentInfo();
agentInfoQueryParams.setAgentCodeList(orderInfos.stream().map(OrderInfo::getOrderAgentCode).collect(Collectors.toList()));
List<AgentInfo> agentInfos = agentInfoService.selectAgentInfoList(agentInfoQueryParams);
Map<String, AgentInfo> agentInfoMap = agentInfos.stream().collect(Collectors.toMap(AgentInfo::getAgentCode, Function.identity(), (v1, v2) -> v1));
//查询客户信息
CustomerInfo customerInfoQueryParams = new CustomerInfo();
customerInfoQueryParams.setCustomerCodeList(orderInfos.stream().map(OrderInfo::getCustomerCode).collect(Collectors.toList()));
List<CustomerInfo> customerInfos = customerInfoService.selectCustomerInfoList(customerInfoQueryParams);
Map<String, CustomerInfo> customerInfoMap = customerInfos.stream().collect(Collectors.toMap(CustomerInfo::getCustomerCode, Function.identity(), (v1, v2) -> v1));
if (CollUtil.isNotEmpty(orderInfos)) {
return orderInfos.stream().map(orderInfo -> {
OrderInfoVo orderInfoVo = new OrderInfoVo();
orderInfoVo.setOrderCode(orderInfo.getOrderCode());
orderInfoVo.setOrderName(orderInfo.getOrderName());
orderInfoVo.setVersionCode(orderInfo.getVersionCode());
//todo 这里为固定值 待确认
orderInfoVo.setBgProperty("1");
AgentInfo agentInfo = agentInfoMap.get(orderInfo.getOrderAgentCode());
if (agentInfo != null) {
//目前三个代表处都是同一个
orderInfoVo.setOrderAgentCode(agentInfo.getAgentCode());
orderInfoVo.setOrderAgentName(agentInfo.getAgentName());
orderInfoVo.setDeliveredAgentCode(agentInfo.getAgentCode());
orderInfoVo.setDeliveredAgentName(agentInfo.getAgentName());
orderInfoVo.setRevenueAgentCode(agentInfo.getAgentCode());
orderInfoVo.setRevenueAgentName(agentInfo.getAgentName());
orderInfoVo.setSaleName(agentInfo.getContactPerson());
orderInfoVo.setSaleEmail(agentInfo.getContactEmail());
orderInfoVo.setSalePhone(agentInfo.getContactPhone());
}
CustomerInfo customerInfo = customerInfoMap.get(orderInfo.getCustomerCode());
if (customerInfo != null) {
orderInfoVo.setCustomerCode(customerInfo.getCustomerCode());
orderInfoVo.setCustomerName(customerInfo.getCustomerName());
orderInfoVo.setCustomerPostcode(customerInfo.getCustomerPostcode());
orderInfoVo.setIndustryType(customerInfo.getIndustryType());
orderInfoVo.setCustomerAddress(customerInfo.getAddress());
orderInfoVo.setContactPerson(customerInfo.getContactPerson());
orderInfoVo.setContactEmail(customerInfo.getContactEmail());
orderInfoVo.setContactPhone(customerInfo.getContactPhone());
}
return orderInfoVo;
}).collect(Collectors.toList());
if (CollUtil.isEmpty(orderInfos)) {
return Collections.emptyList();
}
// 查询代表处信息
Map<String, AgentInfo> agentInfoMap = queryAgentInfoMap(orderInfos);
// 查询客户信息
Map<String, CustomerInfo> customerInfoMap = queryCustomerInfoMap(orderInfos);
return Collections.emptyList();
return orderInfos.stream().map(orderInfo -> {
OrderInfoVo orderInfoVo = new OrderInfoVo();
orderInfoVo.setOrderCode(orderInfo.getOrderCode());
orderInfoVo.setOrderName(orderInfo.getOrderName());
orderInfoVo.setVersionCode(orderInfo.getVersionCode());
// 固定值待确认
orderInfoVo.setBgProperty("1");
// 设置代表处信息
setAgentInfo(orderInfoVo, agentInfoMap.get(orderInfo.getOrderAgentCode()));
// 设置客户信息
setCustomerInfo(orderInfoVo, customerInfoMap.get(orderInfo.getCustomerCode()));
return orderInfoVo;
}).collect(Collectors.toList());
}
/**
*
*/
private Map<String, AgentInfo> queryAgentInfoMap(List<OrderInfo> orderInfos) {
AgentInfo agentInfoQueryParams = new AgentInfo();
agentInfoQueryParams.setAgentCodeList(orderInfos.stream()
.map(OrderInfo::getOrderAgentCode)
.collect(Collectors.toList()));
List<AgentInfo> agentInfos = agentInfoService.selectAgentInfoList(agentInfoQueryParams);
return agentInfos.stream()
.collect(Collectors.toMap(AgentInfo::getAgentCode, Function.identity(), (v1, v2) -> v1));
}
/**
*
*/
private Map<String, CustomerInfo> queryCustomerInfoMap(List<OrderInfo> orderInfos) {
CustomerInfo customerInfoQueryParams = new CustomerInfo();
customerInfoQueryParams.setCustomerCodeList(orderInfos.stream()
.map(OrderInfo::getCustomerCode)
.collect(Collectors.toList()));
List<CustomerInfo> customerInfos = customerInfoService.selectCustomerInfoList(customerInfoQueryParams);
return customerInfos.stream()
.collect(Collectors.toMap(CustomerInfo::getCustomerCode, Function.identity(), (v1, v2) -> v1));
}
/**
*
*/
private void setAgentInfo(OrderInfoVo orderInfoVo, AgentInfo agentInfo) {
if (agentInfo != null) {
orderInfoVo.setOrderAgentCode(agentInfo.getAgentCode());
orderInfoVo.setOrderAgentName(agentInfo.getAgentName());
orderInfoVo.setDeliveredAgentCode(agentInfo.getAgentCode());
orderInfoVo.setDeliveredAgentName(agentInfo.getAgentName());
orderInfoVo.setRevenueAgentCode(agentInfo.getAgentCode());
orderInfoVo.setRevenueAgentName(agentInfo.getAgentName());
orderInfoVo.setSaleName(agentInfo.getContactPerson());
orderInfoVo.setSaleEmail(agentInfo.getContactEmail());
orderInfoVo.setSalePhone(agentInfo.getContactPhone());
}
}
/**
*
*/
private void setCustomerInfo(OrderInfoVo orderInfoVo, CustomerInfo customerInfo) {
if (customerInfo != null) {
orderInfoVo.setCustomerCode(customerInfo.getCustomerCode());
orderInfoVo.setCustomerName(customerInfo.getCustomerName());
orderInfoVo.setCustomerPostcode(customerInfo.getCustomerPostcode());
orderInfoVo.setIndustryType(customerInfo.getIndustryType());
orderInfoVo.setCustomerAddress(customerInfo.getAddress());
orderInfoVo.setContactPerson(customerInfo.getContactPerson());
orderInfoVo.setContactEmail(customerInfo.getContactEmail());
orderInfoVo.setContactPhone(customerInfo.getContactPhone());
}
}
/**

View File

@ -1,5 +1,7 @@
package com.ruoyi.sip.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.Date;
@ -19,14 +21,25 @@ import java.util.Date;
*/
@Data
public class DeliveryInfoVo {
//合同号
private String orderCode;
//版本号
private String versionCode;
//条码
private String serialNumber;
//服务级别
private String serviceLevel;
//服务描述
private String serviceDescribe;
//服务开始时间
private Date startTime;
private Date serviceStartTime;
//服务结束时间
private Date endTime;
private Date serviceEndTime;
private Date lastUpdateTime;
@JsonIgnore
private Long orderId;
@JsonIgnore
private String productType;
}

View File

@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectCustomerInfoVo">
select id, customer_code, customer_name, customer_postcode, province, city, address, contact_person, contact_phone, contact_email, Industry_tyoe, remark, create_at, update_at, delete_at, status from customer_info
select id, customer_code, customer_name, customer_postcode, province, city, address, contact_person, contact_phone, contact_email, industry_type, remark, create_at, update_at, delete_at, status from customer_info
</sql>
<select id="selectCustomerInfoList" parameterType="CustomerInfo" resultMap="CustomerInfoResult">

View File

@ -51,6 +51,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.serialNumber}
</foreach>
</select>
<select id="listNumberInfo" resultType="com.ruoyi.sip.vo.DeliveryInfoVo">
SELECT
t1.serial_number,
t1.updated_at as last_update_time,
t2.order_id,
t2.delivery_date as service_start_time,
t3.order_code,
t3.version_code,
t4.product_name as service_describe,
t4.type as product_type
FROM delivery_list t1
inner JOIN order_delivery t2 ON t1.delivery_id = t2.id
inner JOIN order_info t3 ON t2.order_id = t3.id
inner join product_info t4 on t1.product_code = t4.product_code
<where>
<choose>
<when test="queryStartTime!=null and queryEndTime!=null">
and t1.updated_at between #{queryStartTime} and #{queryEndTime}
</when>
<when test="queryStartTime!=null">
and t1.updated_at <![CDATA[ >= ]]> #{queryStartTime}
</when>
<when test="queryEndTime!=null">
and t1.updated_at <![CDATA[ <= ]]> #{queryEndTime}
</when>
</choose>
</where>
</select>
<insert id="insertDeliveryList" parameterType="DeliveryList" useGeneratedKeys="true" keyProperty="id">
insert into delivery_list

View File

@ -42,6 +42,31 @@
<result property="updatedAt" column="updated_at"/>
<result property="deletedAt" column="deleted_at"/>
</resultMap>
<resultMap type="OrderList" id="OrderListProductResult">
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="productCode" column="product_code"/>
<result property="quantity" column="quantity"/>
<result property="price" column="price"/>
<result property="amount" column="amount"/>
<result property="remark" column="remark"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="deletedAt" column="deleted_at"/>
<association property="productInfo" javaType="com.ruoyi.sip.domain.ProductInfo">
<result property="id" column="id"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<result property="model" column="model"/>
<result property="type" column="type"/>
<result property="value" column="value"/>
<result property="description" column="description"/>
<result property="remark" column="remark"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="deletedAt" column="deleted_at"/>
</association>
</resultMap>
<sql id="selectOrderInfoVo">
select id,
@ -164,6 +189,18 @@
t1.product_code=#{productCode})
</if>
</select>
<select id="listMaintenanceByOrderIdList" resultMap="OrderListProductResult">
SELECT
t1.*,t2.*
FROM
order_list t1
inner join product_info t2 on t1.product_code=t2.product_code and t2.type in (11,22)
WHERE
t1.order_id IN
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<insert id="insertOrderInfo" parameterType="OrderInfo" useGeneratedKeys="true" keyProperty="id">
insert into order_info

View File

@ -11,13 +11,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="model" column="model" />
<result property="description" column="description" />
<result property="remark" column="remark" />
<result property="value" column="value" />
<result property="type" column="type" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="deletedAt" column="deleted_at" />
</resultMap>
<sql id="selectProductInfoVo">
select id, product_code, product_name, model, description, remark, created_at, updated_at, deleted_at from product_info
select id, product_code, product_name, model, description, remark, created_at, updated_at, deleted_at,value,type from product_info
</sql>
<select id="selectProductInfoList" parameterType="ProductInfo" resultMap="ProductInfoResult">
@ -27,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productCode != null and productCode != ''"> and product_code = #{productCode}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="model != null and model != ''"> and model = #{model}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
</select>