refactor(sip): 优化订单导入功能并增加部门名称字段- 修改 DeliveryListController 中的 importData 方法返回值类型

- 更新 DeliveryListService 接口和实现类,使用 AjaxResult 封装导入结果
- 在 OrderInfo模型中添加 orderDeptName 和 partenerDeptName 字段
- 更新 OrderInfoController 中的 edit 方法,支持显示部门名称
- 修改 OrderInfoMapper.xml,增加部门名称查询
master
chenhao 2025-04-11 18:18:22 +08:00
parent 93e854d0b8
commit f81830743d
6 changed files with 55 additions and 28 deletions

View File

@ -64,8 +64,8 @@ public class DeliveryListController extends BaseController {
ExcelUtil<DeliveryList> util = new ExcelUtil<DeliveryList>(DeliveryList.class); ExcelUtil<DeliveryList> util = new ExcelUtil<DeliveryList>(DeliveryList.class);
List<DeliveryList> deliveryList = util.importExcel(file.getInputStream()); List<DeliveryList> deliveryList = util.importExcel(file.getInputStream());
deliveryListService.importData(deliveryList, deliveryId);
return AjaxResult.success("导入成功"); return deliveryListService.importData(deliveryList, deliveryId);
} }
/** /**

View File

@ -100,6 +100,7 @@ public class OrderInfoController extends BaseController
public String edit(@PathVariable("id") Long id, ModelMap mmap) public String edit(@PathVariable("id") Long id, ModelMap mmap)
{ {
OrderInfo orderInfo = orderInfoService.selectOrderInfoById(id); OrderInfo orderInfo = orderInfoService.selectOrderInfoById(id);
mmap.put("orderInfo", orderInfo); mmap.put("orderInfo", orderInfo);
return prefix + "/edit"; return prefix + "/edit";
} }

View File

@ -55,9 +55,11 @@ public class OrderInfo extends BaseEntity
/** 代表处编码 */ /** 代表处编码 */
private Long orderDept; private Long orderDept;
private String orderDeptName;
/** 代理商编码 */ /** 代理商编码 */
private Long partenerDept; private Long partenerDept;
private String partenerDeptName;
/** 合同签定日期 */ /** 合同签定日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ -260,6 +262,22 @@ public class OrderInfo extends BaseEntity
this.orderListList = orderListList; this.orderListList = orderListList;
} }
public String getOrderDeptName() {
return orderDeptName;
}
public void setOrderDeptName(String orderDeptName) {
this.orderDeptName = orderDeptName;
}
public String getPartenerDeptName() {
return partenerDeptName;
}
public void setPartenerDeptName(String partenerDeptName) {
this.partenerDeptName = partenerDeptName;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -1,6 +1,8 @@
package com.ruoyi.sip.service; 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.DeliveryList; import com.ruoyi.sip.domain.DeliveryList;
/** /**
@ -59,5 +61,5 @@ public interface IDeliveryListService
*/ */
public int deleteDeliveryListById(Long id); public int deleteDeliveryListById(Long id);
void importData(List<DeliveryList> deliveryList, Long deliveryId); AjaxResult importData(List<DeliveryList> deliveryList, Long deliveryId);
} }

View File

@ -6,6 +6,7 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.domain.OrderList; import com.ruoyi.sip.domain.OrderList;
@ -106,19 +107,19 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
} }
@Override @Override
public void importData(List<DeliveryList> deliveryList, Long deliveryId) { public AjaxResult importData(List<DeliveryList> deliveryList, Long deliveryId) {
List<String> productCodeList = deliveryList.stream().map(DeliveryList::getProductCode).collect(Collectors.toList()); List<String> productCodeList = deliveryList.stream().map(DeliveryList::getProductCode).collect(Collectors.toList());
if (productCodeList.isEmpty()) { if (productCodeList.isEmpty()) {
throw new ServiceException("产品编码为空"); return AjaxResult.error("产品编码为空");
} }
List<OrderList> orderLists = infoMapper.listOrderListByDeliveryId(deliveryId); List<OrderList> orderLists = infoMapper.listOrderListByDeliveryId(deliveryId);
if (orderLists.isEmpty()) { if (orderLists.isEmpty()) {
throw new ServiceException("发货单中没有产品"); return AjaxResult.error("发货单中没有产品");
} }
List<String> existsProductCodeList = orderLists.stream().map(OrderList::getProductCode).collect(Collectors.toList()); List<String> existsProductCodeList = orderLists.stream().map(OrderList::getProductCode).collect(Collectors.toList());
List<String> notExistsProductCodeList = productCodeList.stream().filter(productCode -> !existsProductCodeList.contains(productCode)).collect(Collectors.toList()); List<String> notExistsProductCodeList = productCodeList.stream().filter(productCode -> !existsProductCodeList.contains(productCode)).collect(Collectors.toList());
if (!notExistsProductCodeList.isEmpty()) { if (!notExistsProductCodeList.isEmpty()) {
throw new ServiceException(StringUtils.format("产品编码为[{}]的产品在发货单中未找到,请确认后重试;", String.join(",", notExistsProductCodeList))); return AjaxResult.error(StringUtils.format("产品编码为[{}]的产品在发货单中未找到,请确认后重试;", String.join(",", notExistsProductCodeList)));
} }
for (DeliveryList list : deliveryList) { for (DeliveryList list : deliveryList) {
@ -126,10 +127,11 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
} }
List<DeliveryList> deliveryLists = deliveryListMapper.listBySerialNumberList(deliveryList); List<DeliveryList> deliveryLists = deliveryListMapper.listBySerialNumberList(deliveryList);
if (!deliveryLists.isEmpty()){ if (!deliveryLists.isEmpty()){
throw new ServiceException("产品序列号为[" + deliveryLists.stream().map(DeliveryList::getSerialNumber).collect(Collectors.joining(",")) + "]的产品已存在,请确认后重试;"); return AjaxResult.error("产品序列号为[" + deliveryLists.stream().map(DeliveryList::getSerialNumber).collect(Collectors.joining(",")) + "]的产品已存在,请确认后重试;");
} }
deliveryListMapper.insertBatch(deliveryList); deliveryListMapper.insertBatch(deliveryList);
return AjaxResult.success("导入成功");
} }
} }

View File

@ -78,26 +78,30 @@
</select> </select>
<select id="selectOrderInfoById" parameterType="Long" resultMap="OrderInfoOrderListResult"> <select id="selectOrderInfoById" parameterType="Long" resultMap="OrderInfoOrderListResult">
select id, select t1.id,
project_code, t1.project_code,
order_code, t1.order_code,
version_code, t1.version_code,
order_name, t1.order_name,
customer_name, t1.customer_name,
customer_contact, t1.customer_contact,
customer_phone, t1.customer_phone,
customer_email, t1.customer_email,
order_type, t1.order_type,
order_dept, t1.order_dept,
partener_dept, t1.partener_dept,
order_date, t1.order_date,
status, t1.status,
remark, t1.remark,
created_at, t1.created_at,
updated_at, t1. updated_at,
deleted_at t1.deleted_at,
from order_info t2.dept_name,
where id = #{id} t3.dept_name
from order_info t1
left join sys_dept t2 on t1.order_dept = t2.dept_id
left join sys_dept t3 on t1.partener_dept = t2.dept_id
where t1.id = #{id}
</select> </select>
<select id="selectOrderListList" resultMap="OrderListResult"> <select id="selectOrderListList" resultMap="OrderListResult">