From fd05069b40e3d669d2d97583f077ea4308c8f39a Mon Sep 17 00:00:00 2001 From: chenhao <852066789@qq.com> Date: Fri, 23 May 2025 15:54:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(sip):=20=E4=BC=98=E5=8C=96=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 DeliveryList 模型中添加 productName 和 description 字段 - 更新 DeliveryListMapper.xml以包含新字段的查询 - 修改前端模板以显示产品名称和描述信息 - 优化页面样式,调整部分元素宽度 --- .../templates/manage/delivery/delivery.html | 1 + .../templates/manage/delivery/import.html | 8 ++ .../templates/system/agent/agent.html | 5 + .../templates/system/partner/partner.html | 3 + .../com/ruoyi/sip/domain/DeliveryList.java | 113 +----------------- .../mapper/manage/DeliveryListMapper.xml | 2 +- 6 files changed, 22 insertions(+), 110 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html b/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html index bc227acf..7f87a3fd 100644 --- a/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html +++ b/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html @@ -152,6 +152,7 @@ maxmin: false, full: false, index:1000, + width: 1050, callBack: doClose }; $.modal.openOptions(options) diff --git a/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html b/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html index 0e0444ba..b38b06fe 100644 --- a/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html +++ b/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html @@ -68,6 +68,14 @@ url: prefix + "/list", field: 'model', title: '产品型号' }, + { + field: 'productName', + title: '产品名称' + }, + { + field: 'description', + title: '产品描述' + }, { field: 'serialNumber', title: '产品序列号' diff --git a/ruoyi-admin/src/main/resources/templates/system/agent/agent.html b/ruoyi-admin/src/main/resources/templates/system/agent/agent.html index a2754640..0506252b 100644 --- a/ruoyi-admin/src/main/resources/templates/system/agent/agent.html +++ b/ruoyi-admin/src/main/resources/templates/system/agent/agent.html @@ -3,6 +3,11 @@ +
diff --git a/ruoyi-admin/src/main/resources/templates/system/partner/partner.html b/ruoyi-admin/src/main/resources/templates/system/partner/partner.html index 75e3c63f..53617324 100644 --- a/ruoyi-admin/src/main/resources/templates/system/partner/partner.html +++ b/ruoyi-admin/src/main/resources/templates/system/partner/partner.html @@ -10,6 +10,9 @@ justify-content: flex-start; flex-wrap: wrap; } + .select-list li p, .select-list li label:not(.radio-box){ + width: 80px; + }
diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/DeliveryList.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/DeliveryList.java index e626ad5a..751221c1 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/DeliveryList.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/DeliveryList.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.StringJoiner; import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -15,6 +16,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * @author ruoyi * @date 2025-04-11 */ +@Data public class DeliveryList extends BaseEntity { private static final long serialVersionUID = 1L; @@ -54,115 +56,8 @@ public class DeliveryList extends BaseEntity // @Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd") private Date deletedAt; + private String productName; + private String description; - public String getOrderCode() { - return orderCode; - } - - public void setOrderCode(String orderCode) { - this.orderCode = orderCode; - } - - public String getProductCode() { - return productCode; - } - - public void setProductCode(String productCode) { - this.productCode = productCode; - } - - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - - public void setDeliveryId(Long deliveryId) - { - this.deliveryId = deliveryId; - } - - public Long getDeliveryId() - { - return deliveryId; - } - - @Override - public String getRemark() { - return remark; - } - - @Override - public void setRemark(String remark) { - this.remark = remark; - } - - public void setSerialNumber(String serialNumber) - { - this.serialNumber = serialNumber; - } - - public String getSerialNumber() - { - return serialNumber; - } - - 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; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - @Override - public String toString() { - return new StringJoiner(", ", DeliveryList.class.getSimpleName() + "[", "]") - .add("id=" + id) - .add("deliveryId=" + deliveryId) - .add("model=" + model) - .add("orderCode='" + orderCode + "'") - .add("productCode='" + productCode + "'") - .add("serialNumber='" + serialNumber + "'") - .add("remark='" + remark + "'") - .add("createdAt=" + createdAt) - .add("updatedAt=" + updatedAt) - .add("deletedAt=" + deletedAt) - .toString(); - } } diff --git a/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml b/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml index 1d6c9398..38057c76 100644 --- a/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml @@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select t1.id, t1.delivery_id,t1.product_code, t1.serial_number, t1.remark, t1.created_at, t1.updated_at, t1.deleted_at, t2.delivery_code, - t3.product_code, t3.product_name,t3.model, + t3.product_code, t3.product_name,t3.model,t3.description, t4.order_code from delivery_list t1 left join order_delivery t2 on t1.delivery_id = t2.id From e43b87c17a616480113de0fcf2279ff2f932ebf5 Mon Sep 17 00:00:00 2001 From: chenhao <852066789@qq.com> Date: Mon, 26 May 2025 16:23:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(sip):=20=E6=B7=BB=E5=8A=A0=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BA=BA=E5=AD=97=E6=AE=B5=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 OrderDelivery 和 OrderInfo 模型中添加 createByName 字段 - 更新相关 mapper 和 SQL 文件以支持创建人字段 - 重构订单导入功能,提高代码复用性和异常处理能力 - 优化导入数据的校验逻辑,确保数据准确性 --- .../templates/manage/delivery/delivery.html | 4 ++ .../templates/manage/order/order.html | 4 ++ .../sip/controller/OrderInfoController.java | 52 ++++++-------- .../com/ruoyi/sip/domain/OrderDelivery.java | 1 + .../java/com/ruoyi/sip/domain/OrderInfo.java | 1 + .../ruoyi/sip/service/IOrderInfoService.java | 3 + .../service/impl/OrderInfoServiceImpl.java | 71 +++++++++++++++++++ .../mapper/manage/OrderDeliveryMapper.xml | 3 +- .../mapper/manage/OrderInfoMapper.xml | 47 +++++++++--- 9 files changed, 145 insertions(+), 41 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html b/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html index 7f87a3fd..d9bec81c 100644 --- a/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html +++ b/ruoyi-admin/src/main/resources/templates/manage/delivery/delivery.html @@ -130,6 +130,10 @@ return $.table.selectDictLabel(deliveryStatusDatas, value); } }, + { + field: 'createByName', + title: '创建人' + }, { title: '操作', align: 'center', diff --git a/ruoyi-admin/src/main/resources/templates/manage/order/order.html b/ruoyi-admin/src/main/resources/templates/manage/order/order.html index 8cacacb7..a5b87d3a 100644 --- a/ruoyi-admin/src/main/resources/templates/manage/order/order.html +++ b/ruoyi-admin/src/main/resources/templates/manage/order/order.html @@ -106,6 +106,10 @@ { field: 'orderDate', title: '合同签定日期' + }, + { + field: 'createByName', + title: '创建人' }, // { // field: 'status', diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OrderInfoController.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OrderInfoController.java index b006a992..1dd27887 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OrderInfoController.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OrderInfoController.java @@ -204,45 +204,37 @@ public class OrderInfoController extends BaseController @ResponseBody public AjaxResult listImportData(MultipartFile file, Long orderId) throws Exception { - List orderListList = getOrderLists(file); + List orderListList = null; + try { + orderListList = orderInfoService.readData(file); + } catch (ServiceException e) { + return AjaxResult.error(e.getMessage()); + }catch (Exception e) { + log.error("导入合同清单失败",e); + return AjaxResult.error("导入失败"); + } + if (CollUtil.isEmpty(orderListList)){ + return AjaxResult.error("导入数据不能为空"); + } return orderInfoService.listImportData(orderListList, orderId); } - private List getOrderLists(MultipartFile file) throws Exception { - ExcelUtil util = new ExcelUtil(OrderList.class); - List 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 productInfos = productInfoService.selectProductInfoList(new ProductInfo()); - Map productInfoMap = productInfos.stream().collect(Collectors.toMap(ProductInfo::getProductCode, Function.identity(), (v1, v2) -> v1)); - orderListList = orderListList.stream().filter(item -> item != null && StringUtils.isNotEmpty(item.getProductCode()) - && productInfoMap.containsKey(item.getProductCode())) - .collect(Collectors.toList()); - for (OrderList orderList : orderListList) { - orderList.setCreateBy(ShiroUtils.getUserId().toString()); - ProductInfo productInfo = productInfoMap.get(orderList.getProductCode()); - if (productInfo != null) { - orderList.setProductName(productInfo.getProductName()); - } - } - if (CollUtil.isEmpty(orderListList)){ - throw new ServiceException("导入excel的产品均未在产品库中,导入失败"); - } - return orderListList; - } @PostMapping("/list/readData") @ResponseBody public AjaxResult listReadData(MultipartFile file, Long orderId) throws Exception { - List orderListList = getOrderLists(file); + List orderListList = null; + try { + orderListList = orderInfoService.readData(file); + } catch (ServiceException e) { + return AjaxResult.error(e.getMessage()); + }catch (Exception e) { + log.error("导入合同清单失败",e); + return AjaxResult.error("导入失败"); + } + return AjaxResult.success(orderListList); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderDelivery.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderDelivery.java index 8384f5ef..3af068fa 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderDelivery.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderDelivery.java @@ -76,5 +76,6 @@ public class OrderDelivery extends BaseEntity private Date deletedAt; private String total; private Integer status; + private String createByName; } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderInfo.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderInfo.java index 9a51713e..a3e03b28 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderInfo.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OrderInfo.java @@ -100,6 +100,7 @@ public class OrderInfo extends BaseEntity /** 合同清单信息 */ private List orderListList; private String serialNumber; + private String createByName; diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOrderInfoService.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOrderInfoService.java index 8b16209d..ae2306b5 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOrderInfoService.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOrderInfoService.java @@ -8,6 +8,7 @@ import com.ruoyi.sip.domain.OrderInfo; import com.ruoyi.sip.domain.OrderList; import com.ruoyi.sip.dto.ApiDataQueryDto; import com.ruoyi.sip.vo.OrderInfoVo; +import org.springframework.web.multipart.MultipartFile; /** * 合同档案Service接口 @@ -78,4 +79,6 @@ public interface IOrderInfoService List listExport(OrderList orderList); AjaxResult listImportData(List orderListList, Long orderId); + + List readData(MultipartFile file); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OrderInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OrderInfoServiceImpl.java index 02644b6e..1ff0573e 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OrderInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OrderInfoServiceImpl.java @@ -8,12 +8,15 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Dict; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.sip.domain.*; import com.ruoyi.sip.dto.ApiDataQueryDto; import com.ruoyi.sip.service.IAgentInfoService; import com.ruoyi.sip.service.ICustomerInfoService; +import com.ruoyi.sip.service.IProductInfoService; import com.ruoyi.sip.vo.OrderInfoVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import com.ruoyi.sip.mapper.OrderInfoMapper; import com.ruoyi.sip.service.IOrderInfoService; import com.ruoyi.common.core.text.Convert; +import org.springframework.web.multipart.MultipartFile; /** * 合同档案Service业务层处理 @@ -42,6 +46,8 @@ public class OrderInfoServiceImpl implements IOrderInfoService private IAgentInfoService agentInfoService; @Autowired private ICustomerInfoService customerInfoService; + @Autowired + private IProductInfoService productInfoService; /** * 查询合同档案 * @@ -285,6 +291,71 @@ public class OrderInfoServiceImpl implements IOrderInfoService // } return AjaxResult.success("导入成功"); } + + @Override + public List readData(MultipartFile file) { + List orderListList = null; + try { + ExcelUtil util = new ExcelUtil(OrderList.class); + orderListList = util.importExcel(file.getInputStream()); + orderListList=orderListList.stream().filter(Objects::nonNull).collect(Collectors.toList()); + if (CollUtil.isEmpty(orderListList)){ + orderListList = util.importExcel("价格明细清单", file.getInputStream(), 4); + } + } catch (Exception e) { + throw new ServiceException("读取文件错误,导入失败"); + } + if (CollUtil.isEmpty(orderListList)){ + throw new ServiceException("excel模板错误,导入失败"); + } + //只处理当前产品表有的数据 + List productInfos = productInfoService.selectProductInfoList(new ProductInfo()); + Map productInfoMap = productInfos.stream().collect(Collectors.toMap(ProductInfo::getProductCode, Function.identity(), (v1, v2) -> v1)); + orderListList = orderListList.stream().filter(item -> item != null && StringUtils.isNotEmpty(item.getProductCode()) + && productInfoMap.containsKey(item.getProductCode())) + .collect(Collectors.toList()); + for (OrderList orderList : orderListList) { + orderList.setCreateBy(ShiroUtils.getUserId().toString()); + ProductInfo productInfo = productInfoMap.get(orderList.getProductCode()); + if (productInfo != null) { + orderList.setProductName(productInfo.getProductName()); + } + } + if (CollUtil.isEmpty(orderListList)){ + throw new ServiceException("导入excel的产品均未在产品库中,导入失败"); + } + List productCodeList = orderListList.stream() + .map(OrderList::getProductCode) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + if (productCodeList.isEmpty()) { + throw new ServiceException("文件为空或产品编码为空"); + } + for (OrderList orderList : orderListList) { + + if (orderList.getDiscount() == null) { + throw new ServiceException("折扣不能为空"); + } + if (orderList.getDiscount().compareTo(BigDecimal.ONE) > 0 || orderList.getDiscount().compareTo(BigDecimal.ZERO) <= 0) { + throw new ServiceException("折扣区间需在0-1之间"); + } + if (orderList.getPrice() == null) { + throw new ServiceException("单价不能为空"); + } + if (orderList.getQuantity() == null) { + throw new ServiceException("数量不能为空"); + } + + BigDecimal amount = orderList.getPrice().multiply(new BigDecimal(orderList.getQuantity())); + if (orderList.getDiscount()!=null){ + amount = amount.multiply(orderList.getDiscount()).setScale(2, RoundingMode.HALF_UP); + } + orderList.setAmount(amount); + } + return orderListList; + } + public Map> compareOrderLists(List orderInfoList, List orderListList) { // 创建一个映射,用于快速查找订单 Map orderInfoMap = orderInfoList.stream() diff --git a/ruoyi-sip/src/main/resources/mapper/manage/OrderDeliveryMapper.xml b/ruoyi-sip/src/main/resources/mapper/manage/OrderDeliveryMapper.xml index 8de4e1e1..b3cf65c5 100644 --- a/ruoyi-sip/src/main/resources/mapper/manage/OrderDeliveryMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/manage/OrderDeliveryMapper.xml @@ -29,11 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + select t1.id, + t1.project_code, + t1.order_code, + t1.version_code, + t1.order_name, + t1.customer_code, + t1.customer_name, + t1.customer_contact, + t1.customer_phone, + t1.customer_email, + t1.customer_address, + t1.industry_type, + t1.customer_postcode, + t1.order_type, + t1.order_agent_code, + t1.order_partner_code, + t1.bg_type, + t1.order_date, + t1.status, + t1.remark, + t1.created_at, + t1.updated_at, + t1.deleted_at, + t1.create_by, + t1.update_by, + t2.user_name as create_by_name + from order_info t1 + left join sys_user t2 on t1.create_by=t2.user_id - and status=0 - and order_code like concat('%', #{orderCode}, '%') - and order_name like concat('%', #{orderName}, '%') - and customer_name like concat('%', #{customerName}, + and t1.status=0 + and t1.order_code like concat('%', #{orderCode}, '%') + and t1.order_name like concat('%', #{orderName}, '%') + and t1.customer_name like concat('%', #{customerName}, '%') - and order_type = #{orderType} + and t1.order_type = #{orderType} - and updated_at between #{updatedAtStart} and #{updatedAtEnd} + and t1.updated_at between #{updatedAtStart} and #{updatedAtEnd} - and updated_at = ]]> #{updatedAtStart} + and t1.updated_at = ]]> #{updatedAtStart} - and updated_at #{updatedAtEnd} + and t1.updated_at #{updatedAtEnd} - and id in (SELECT order_id from order_delivery where id in ( + and t1.id in (SELECT order_id from order_delivery where id in ( select delivery_id from delivery_list where serial_number=#{serialNumber}))