feat(sip): 添加合同清单导出导入功能
- 在 IOrderInfoService 接口中添加了 listExport 和 listImportData 方法 - 在 OrderInfoController 中添加了对应的控制器方法 - 在 OrderInfoMapper 中添加了 listExport 方法的 SQL 查询 - 在 OrderInfoServiceImpl 中实现了 listExport 和 listImportData 方法的逻辑 - 修改了 OrderList 类,将 discount 字段标记为 Excel 导出的字段master
parent
d7cc90be9d
commit
772064bee1
|
@ -24,11 +24,11 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- spring-boot-devtools -->
|
<!-- spring-boot-devtools -->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.springframework.boot</groupId>
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<!-- <artifactId>spring-boot-devtools</artifactId>-->
|
||||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
<!-- <optional>true</optional> <!– 表示依赖不会传递 –>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!-- swagger3-->
|
<!-- swagger3-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.sip.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.sip.domain.DeliveryList;
|
||||||
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
|
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
|
||||||
import com.ruoyi.sip.domain.OrderList;
|
import com.ruoyi.sip.domain.OrderList;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
@ -17,6 +18,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合同档案Controller
|
* 合同档案Controller
|
||||||
|
@ -132,4 +134,23 @@ public class OrderInfoController extends BaseController
|
||||||
{
|
{
|
||||||
return AjaxResult.success(orderInfoService.selectOrderInfoByMaintenance(dto));
|
return AjaxResult.success(orderInfoService.selectOrderInfoByMaintenance(dto));
|
||||||
}
|
}
|
||||||
|
@RequiresPermissions("sip:list:export")
|
||||||
|
@Log(title = "发货清单", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/list/export")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult listExport(OrderList orderList) {
|
||||||
|
List<OrderList> list = orderInfoService.listExport(orderList);
|
||||||
|
ExcelUtil<OrderList> util = new ExcelUtil<OrderList>(OrderList.class);
|
||||||
|
return util.exportExcel(list, "合同清单数据");
|
||||||
|
}
|
||||||
|
@PostMapping("/list/importData")
|
||||||
|
@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());
|
||||||
|
|
||||||
|
|
||||||
|
return orderInfoService.listImportData(orderListList, orderId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,14 @@ public class OrderList extends BaseEntity
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 关联合同ID */
|
/** 关联合同ID */
|
||||||
@Excel(name = "关联合同ID")
|
// @Excel(name = "关联合同ID")
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
|
|
||||||
/** 产品编码,关联产品编码表 */
|
/** 产品编码,关联产品编码表 */
|
||||||
@Excel(name = "BOM编码")
|
@Excel(name = "BOM编码")
|
||||||
private String productCode;
|
private String productCode;
|
||||||
|
|
||||||
@Excel(name = "产品名称")
|
// @Excel(name = "产品名称")
|
||||||
private String productName;
|
private String productName;
|
||||||
|
|
||||||
/** 数量 */
|
/** 数量 */
|
||||||
|
@ -43,27 +43,28 @@ public class OrderList extends BaseEntity
|
||||||
/** 单价 */
|
/** 单价 */
|
||||||
@Excel(name = "单价")
|
@Excel(name = "单价")
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
/** 优惠 */
|
||||||
|
@Excel(name = "折扣")
|
||||||
|
private BigDecimal discount;
|
||||||
/** 总价 */
|
/** 总价 */
|
||||||
@Excel(name = "总价")
|
@Excel(name = "总价")
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
/** 优惠 */
|
|
||||||
private BigDecimal discount;
|
|
||||||
|
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
// @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
|
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
|
// @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date updatedAt;
|
private Date updatedAt;
|
||||||
|
|
||||||
/** 删除时间,软删除 */
|
/** 删除时间,软删除 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd")
|
// @Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date deletedAt;
|
private Date deletedAt;
|
||||||
|
|
||||||
private ProductInfo productInfo;
|
private ProductInfo productInfo;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.sip.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
|
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
|
||||||
import com.ruoyi.sip.domain.OrderInfo;
|
import com.ruoyi.sip.domain.OrderInfo;
|
||||||
import com.ruoyi.sip.domain.OrderList;
|
import com.ruoyi.sip.domain.OrderList;
|
||||||
|
@ -105,4 +106,7 @@ public interface OrderInfoMapper
|
||||||
List<OrderInfo> selectOrderInfoByMaintenance(MaintenanceRecordsDto dto);
|
List<OrderInfo> selectOrderInfoByMaintenance(MaintenanceRecordsDto dto);
|
||||||
|
|
||||||
List<OrderList> listMaintenanceByOrderIdList(List<Long> orderIdList);
|
List<OrderList> listMaintenanceByOrderIdList(List<Long> orderIdList);
|
||||||
|
|
||||||
|
List<OrderList> listExport(OrderList orderList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.sip.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
|
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
|
||||||
import com.ruoyi.sip.domain.OrderInfo;
|
import com.ruoyi.sip.domain.OrderInfo;
|
||||||
import com.ruoyi.sip.domain.OrderList;
|
import com.ruoyi.sip.domain.OrderList;
|
||||||
|
@ -73,4 +74,8 @@ public interface IOrderInfoService
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<OrderInfoVo> getOrderInfo(ApiDataQueryDto dto);
|
List<OrderInfoVo> getOrderInfo(ApiDataQueryDto dto);
|
||||||
|
|
||||||
|
List<OrderList> listExport(OrderList orderList);
|
||||||
|
|
||||||
|
AjaxResult listImportData(List<OrderList> orderListList, Long orderId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.ruoyi.sip.service.impl;
|
package com.ruoyi.sip.service.impl;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.lang.Dict;
|
import cn.hutool.core.lang.Dict;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.DictUtils;
|
import com.ruoyi.common.utils.DictUtils;
|
||||||
import com.ruoyi.sip.domain.*;
|
import com.ruoyi.sip.domain.*;
|
||||||
import com.ruoyi.sip.dto.ApiDataQueryDto;
|
import com.ruoyi.sip.dto.ApiDataQueryDto;
|
||||||
|
@ -13,8 +16,7 @@ import com.ruoyi.sip.service.ICustomerInfoService;
|
||||||
import com.ruoyi.sip.vo.OrderInfoVo;
|
import com.ruoyi.sip.vo.OrderInfoVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -186,6 +188,41 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderList> listExport(OrderList orderList) {
|
||||||
|
return orderInfoMapper.listExport(orderList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult listImportData(List<OrderList> orderListList, Long orderId) {
|
||||||
|
Assert.notNull(orderId, "合同ID不能为空");
|
||||||
|
List<String> productCodeList = orderListList.stream().map(OrderList::getProductCode).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
if (productCodeList.isEmpty()) {
|
||||||
|
return AjaxResult.error("文件为空或产品编码为空");
|
||||||
|
}
|
||||||
|
for (OrderList orderList : orderListList) {
|
||||||
|
orderList.setOrderId(orderId);
|
||||||
|
if (orderList.getDiscount() != null && (orderList.getDiscount().compareTo(BigDecimal.ONE) > 0 || orderList.getDiscount().compareTo(BigDecimal.ZERO) <= 0)) {
|
||||||
|
return AjaxResult.error("折扣区间需在0-1之间");
|
||||||
|
}
|
||||||
|
if (orderList.getPrice() == null) {
|
||||||
|
return AjaxResult.error("单价不能为空");
|
||||||
|
}
|
||||||
|
if (orderList.getQuantity() == null) {
|
||||||
|
return AjaxResult.error("单价不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
orderInfoMapper.deleteOrderListByOrderId(orderId);
|
||||||
|
orderInfoMapper.batchOrderList(orderListList);
|
||||||
|
return AjaxResult.success("导入成功");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询代表处信息并构建映射
|
* 查询代表处信息并构建映射
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -128,6 +128,9 @@
|
||||||
t1.version_code,
|
t1.version_code,
|
||||||
t1.order_name,
|
t1.order_name,
|
||||||
t1.customer_name,
|
t1.customer_name,
|
||||||
|
t1.customer_code,
|
||||||
|
t1.customer_address,
|
||||||
|
t1.customer_postcode,
|
||||||
t1.customer_contact,
|
t1.customer_contact,
|
||||||
t1.customer_phone,
|
t1.customer_phone,
|
||||||
t1.customer_email,
|
t1.customer_email,
|
||||||
|
@ -207,6 +210,21 @@
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listExport" resultType="com.ruoyi.sip.domain.OrderList">
|
||||||
|
select id, order_id, product_code, quantity, price, amount,discount,remark, created_at, updated_at
|
||||||
|
from order_list
|
||||||
|
<where>
|
||||||
|
<if test="id!=null">
|
||||||
|
and id=#{id}
|
||||||
|
</if>
|
||||||
|
<if test="orderId!=null">
|
||||||
|
and order_id=#{orderId}
|
||||||
|
</if>
|
||||||
|
<if test="productCode!=null and productCode!=''">
|
||||||
|
and product_code=#{productCode}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertOrderInfo" parameterType="OrderInfo" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertOrderInfo" parameterType="OrderInfo" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into order_info
|
insert into order_info
|
||||||
|
@ -216,6 +234,9 @@
|
||||||
<if test="versionCode != null">version_code,</if>
|
<if test="versionCode != null">version_code,</if>
|
||||||
<if test="orderName != null and orderName != ''">order_name,</if>
|
<if test="orderName != null and orderName != ''">order_name,</if>
|
||||||
<if test="customerName != null and customerName != ''">customer_name,</if>
|
<if test="customerName != null and customerName != ''">customer_name,</if>
|
||||||
|
<if test="customerCode != null and customerCode != ''">customer_code,</if>
|
||||||
|
<if test="customerAddress != null and customerAddress != ''">customer_address,</if>
|
||||||
|
<if test="customerPostcode != null and customerPostcode != ''">customer_postcode,</if>
|
||||||
<if test="customerContact != null">customer_contact,</if>
|
<if test="customerContact != null">customer_contact,</if>
|
||||||
<if test="customerPhone != null">customer_phone,</if>
|
<if test="customerPhone != null">customer_phone,</if>
|
||||||
<if test="customerEmail != null">customer_email,</if>
|
<if test="customerEmail != null">customer_email,</if>
|
||||||
|
@ -233,6 +254,9 @@
|
||||||
<if test="versionCode != null">#{versionCode},</if>
|
<if test="versionCode != null">#{versionCode},</if>
|
||||||
<if test="orderName != null and orderName != ''">#{orderName},</if>
|
<if test="orderName != null and orderName != ''">#{orderName},</if>
|
||||||
<if test="customerName != null and customerName != ''">#{customerName},</if>
|
<if test="customerName != null and customerName != ''">#{customerName},</if>
|
||||||
|
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
|
||||||
|
<if test="customerAddress != null and customerAddress != ''">#{customerAddress},</if>
|
||||||
|
<if test="customerPostcode != null and customerPostcode != ''">#{customerPostcode},</if>
|
||||||
<if test="customerContact != null">#{customerContact},</if>
|
<if test="customerContact != null">#{customerContact},</if>
|
||||||
<if test="customerPhone != null">#{customerPhone},</if>
|
<if test="customerPhone != null">#{customerPhone},</if>
|
||||||
<if test="customerEmail != null">#{customerEmail},</if>
|
<if test="customerEmail != null">#{customerEmail},</if>
|
||||||
|
@ -257,6 +281,9 @@
|
||||||
<if test="customerContact != null">customer_contact = #{customerContact},</if>
|
<if test="customerContact != null">customer_contact = #{customerContact},</if>
|
||||||
<if test="customerPhone != null">customer_phone = #{customerPhone},</if>
|
<if test="customerPhone != null">customer_phone = #{customerPhone},</if>
|
||||||
<if test="customerEmail != null">customer_email = #{customerEmail},</if>
|
<if test="customerEmail != null">customer_email = #{customerEmail},</if>
|
||||||
|
<if test="customerCode != null and customerCode != ''">customer_code=#{customerCode},</if>
|
||||||
|
<if test="customerAddress != null and customerAddress != ''">customer_address=#{customerAddress},</if>
|
||||||
|
<if test="customerPostcode != null and customerPostcode != ''">customer_postcode=#{customerPostcode},</if>
|
||||||
<if test="orderType != null">order_type = #{orderType},</if>
|
<if test="orderType != null">order_type = #{orderType},</if>
|
||||||
<if test="orderAgentCode != null">order_agent_code = #{orderAgentCode},</if>
|
<if test="orderAgentCode != null">order_agent_code = #{orderAgentCode},</if>
|
||||||
<if test="orderPartnerCode != null">order_partner_code = #{orderPartnerCode},</if>
|
<if test="orderPartnerCode != null">order_partner_code = #{orderPartnerCode},</if>
|
||||||
|
@ -318,9 +345,9 @@
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<insert id="batchOrderList">
|
<insert id="batchOrderList">
|
||||||
insert into order_list( id, order_id, product_code, quantity, price, amount, remark, created_at, updated_at) values
|
insert into order_list(id , order_id, product_code, quantity, price, amount,discount,remark, created_at, updated_at) values
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
( #{item.id}, #{item.orderId}, #{item.productCode}, #{item.quantity}, #{item.price}, #{item.amount},
|
( #{item.id}, #{item.orderId}, #{item.productCode}, #{item.quantity}, #{item.price}, #{item.amount},#{item.discount},
|
||||||
#{item.remark}, now(),now())
|
#{item.remark}, now(),now())
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
Loading…
Reference in New Issue