refactor(sip): 重构订单导入功能并优化产品信息

- 优化了订单导入功能,增加了对不同模板的兼容性和产品库匹配校验
- 在产品信息中添加了上架编码字段并更新了相关映射
- 修改了订单列表中的产品编码、单价和总价的Excel列名
- 更新了系统首页标题和logo- 优化了Excel导入错误提示信息
master
chenhao 2025-05-20 10:13:38 +08:00
parent 93cf5399fa
commit 6c2e32f470
6 changed files with 58 additions and 17 deletions

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title>若依系统首页</title>
<title>售后服务平台(SIP)</title>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link th:href="@{favicon.ico}" rel="shortcut icon"/>
@ -27,7 +27,7 @@
</div>
<a th:href="@{/index}">
<li class="logo hidden-xs">
<span class="logo-lg">RuoYi</span>
<span class="logo-lg">SIP</span>
</li>
</a>
<div class="sidebar-collapse tab-content" id="side-menu">

View File

@ -357,7 +357,7 @@ public class ExcelUtil<T>
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
if (sheet == null)
{
throw new IOException("文件sheet不存在");
throw new IOException(StringUtils.format("文件sheet[{}]不存在",sheetName));
}
boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook);
Map<String, PictureData> pictures;

View File

@ -1,10 +1,15 @@
package com.ruoyi.sip.controller;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import com.ruoyi.sip.domain.DeliveryList;
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
import com.ruoyi.sip.domain.OrderList;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.domain.*;
import com.ruoyi.sip.service.IProductInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -12,7 +17,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sip.domain.OrderInfo;
import com.ruoyi.sip.service.IOrderInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -34,6 +38,8 @@ public class OrderInfoController extends BaseController
@Autowired
private IOrderInfoService orderInfoService;
@Autowired
private IProductInfoService productInfoService;
@RequiresPermissions("manage:order:view")
@GetMapping()
@ -165,19 +171,37 @@ public class OrderInfoController extends BaseController
@ResponseBody
public AjaxResult listImportData(MultipartFile file, Long orderId) throws Exception
{
ExcelUtil<OrderList> util = new ExcelUtil<OrderList>(OrderList.class);
List<OrderList> orderListList = util.importExcel(file.getInputStream());
List<OrderList> orderListList = getOrderLists(file);
return orderInfoService.listImportData(orderListList, orderId);
}
private List<OrderList> getOrderLists(MultipartFile file) throws Exception {
ExcelUtil<OrderList> util = new ExcelUtil<OrderList>(OrderList.class);
List<OrderList> orderListList = util.importExcel(file.getInputStream());
orderListList=orderListList.stream().filter(Objects::nonNull).collect(Collectors.toList());
if (CollUtil.isEmpty(orderListList)){
orderListList = util.importExcel("价格明细清单", file.getInputStream(), 4);
}
if (CollUtil.isEmpty(orderListList)){
throw new ServiceException("excel模板错误,导入失败");
}
//只处理当前产品表有的数据
List<ProductInfo> productInfos = productInfoService.selectProductInfoList(new ProductInfo());
Set<String> productSet = productInfos.stream().map(ProductInfo::getProductCode).collect(Collectors.toSet());
orderListList = orderListList.stream().filter(item -> item != null && StringUtils.isNotEmpty(item.getProductCode())
&& productSet.contains(item.getProductCode())).collect(Collectors.toList());
if (CollUtil.isEmpty(orderListList)){
throw new ServiceException("导入excel的产品均未在产品库中,导入失败");
}
return orderListList;
}
@PostMapping("/list/readData")
@ResponseBody
public AjaxResult listReadData(MultipartFile file, Long orderId) throws Exception
{
ExcelUtil<OrderList> util = new ExcelUtil<OrderList>(OrderList.class);
List<OrderList> orderListList = util.importExcel(file.getInputStream());
List<OrderList> orderListList = getOrderLists(file);
return AjaxResult.success(orderListList);
}

View File

@ -30,7 +30,7 @@ public class OrderList extends BaseEntity
private Long orderId;
/** 产品编码,关联产品编码表 */
@Excel(name = "BOM编码")
@Excel(name = "产品编码")
private String productCode;
// @Excel(name = "产品名称")
@ -41,14 +41,16 @@ public class OrderList extends BaseEntity
private Long quantity;
/** 单价 */
@Excel(name = "单价")
@Excel(name = "目录单价(RMB)")
private BigDecimal price;
/** 优惠 */
@Excel(name = "折扣")
private BigDecimal discount;
/** 总价 */
@Excel(name = "总价")
@Excel(name = "目录总价(RMB)")
private BigDecimal amount;
@Excel(name = "备注")
private String remark;

View File

@ -28,6 +28,8 @@ public class ProductInfo extends BaseEntity
/** 产品编码 */
@Excel(name = "产品编码")
private String productCode;
@Excel(name = "上架编码")
private String hzCode;
private String type;
private String value;

View File

@ -16,10 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="deletedAt" column="deleted_at" />
<result property="hzCode" column="hz_code" />
</resultMap>
<sql id="selectProductInfoVo">
select id, product_code, product_name, model, description, remark, created_at, updated_at, deleted_at,value,type from product_info
select id, product_code, product_name, model, description, remark, created_at, updated_at, deleted_at,value,type,hz_code from product_info
</sql>
<select id="selectProductInfoList" parameterType="ProductInfo" resultMap="ProductInfoResult">
@ -50,6 +51,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t1.id,
t1.product_code,
t1.product_name,
t1.type,
t1.value,
t1.hz_code,
t1.model,
t1.description,
t1.remark,
@ -84,6 +88,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="model != null and model != ''">model,</if>
<if test="description != null">description,</if>
<if test="remark != null">remark,</if>
<if test="type != null">type,</if>
<if test="value != null">value,</if>
<if test="hzCode != null">hz_code,</if>
created_at,status
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -92,6 +99,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="model != null and model != ''">#{model},</if>
<if test="description != null">#{description},</if>
<if test="remark != null">#{remark},</if>
<if test="type != null">#{type},</if>
<if test="value != null">#{value},</if>
<if test="hzCode != null">#{hzCode},</if>
NOW(),0
</trim>
</insert>
@ -104,6 +114,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="model != null and model != ''">model = #{model},</if>
<if test="description != null">description = #{description},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="type != null">type = #{type},</if>
<if test="value != null">value = #{value},</if>
<if test="hzCode != null">hz_code = #{hzCode},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
updated_at = NOW(),
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>