refactor(sip): 优化订单导入功能并增加部门名称字段- 修改 DeliveryListController 中的 importData 方法返回值类型
- 更新 DeliveryListService 接口和实现类,使用 AjaxResult 封装导入结果 - 在 OrderInfo模型中添加 orderDeptName 和 partenerDeptName 字段 - 更新 OrderInfoController 中的 edit 方法,支持显示部门名称 - 修改 OrderInfoMapper.xml,增加部门名称查询master
parent
93e854d0b8
commit
f81830743d
|
@ -64,8 +64,8 @@ public class DeliveryListController extends BaseController {
|
|||
ExcelUtil<DeliveryList> util = new ExcelUtil<DeliveryList>(DeliveryList.class);
|
||||
List<DeliveryList> deliveryList = util.importExcel(file.getInputStream());
|
||||
|
||||
deliveryListService.importData(deliveryList, deliveryId);
|
||||
return AjaxResult.success("导入成功");
|
||||
|
||||
return deliveryListService.importData(deliveryList, deliveryId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -100,6 +100,7 @@ public class OrderInfoController extends BaseController
|
|||
public String edit(@PathVariable("id") Long id, ModelMap mmap)
|
||||
{
|
||||
OrderInfo orderInfo = orderInfoService.selectOrderInfoById(id);
|
||||
|
||||
mmap.put("orderInfo", orderInfo);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
|
|
@ -55,9 +55,11 @@ public class OrderInfo extends BaseEntity
|
|||
|
||||
/** 代表处编码 */
|
||||
private Long orderDept;
|
||||
private String orderDeptName;
|
||||
|
||||
/** 代理商编码 */
|
||||
private Long partenerDept;
|
||||
private String partenerDeptName;
|
||||
|
||||
/** 合同签定日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
|
@ -260,6 +262,22 @@ public class OrderInfo extends BaseEntity
|
|||
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
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.sip.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.sip.domain.DeliveryList;
|
||||
|
||||
/**
|
||||
|
@ -59,5 +61,5 @@ public interface IDeliveryListService
|
|||
*/
|
||||
public int deleteDeliveryListById(Long id);
|
||||
|
||||
void importData(List<DeliveryList> deliveryList, Long deliveryId);
|
||||
AjaxResult importData(List<DeliveryList> deliveryList, Long deliveryId);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.OrderList;
|
||||
|
@ -106,19 +107,19 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
|
|||
}
|
||||
|
||||
@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());
|
||||
if (productCodeList.isEmpty()) {
|
||||
throw new ServiceException("产品编码为空");
|
||||
return AjaxResult.error("产品编码为空");
|
||||
}
|
||||
List<OrderList> orderLists = infoMapper.listOrderListByDeliveryId(deliveryId);
|
||||
if (orderLists.isEmpty()) {
|
||||
throw new ServiceException("发货单中没有产品");
|
||||
return AjaxResult.error("发货单中没有产品");
|
||||
}
|
||||
List<String> existsProductCodeList = orderLists.stream().map(OrderList::getProductCode).collect(Collectors.toList());
|
||||
List<String> notExistsProductCodeList = productCodeList.stream().filter(productCode -> !existsProductCodeList.contains(productCode)).collect(Collectors.toList());
|
||||
if (!notExistsProductCodeList.isEmpty()) {
|
||||
throw new ServiceException(StringUtils.format("产品编码为[{}]的产品在发货单中未找到,请确认后重试;", String.join(",", notExistsProductCodeList)));
|
||||
return AjaxResult.error(StringUtils.format("产品编码为[{}]的产品在发货单中未找到,请确认后重试;", String.join(",", notExistsProductCodeList)));
|
||||
}
|
||||
|
||||
for (DeliveryList list : deliveryList) {
|
||||
|
@ -126,10 +127,11 @@ public class DeliveryListServiceImpl implements IDeliveryListService {
|
|||
}
|
||||
List<DeliveryList> deliveryLists = deliveryListMapper.listBySerialNumberList(deliveryList);
|
||||
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);
|
||||
return AjaxResult.success("导入成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,26 +78,30 @@
|
|||
</select>
|
||||
|
||||
<select id="selectOrderInfoById" parameterType="Long" resultMap="OrderInfoOrderListResult">
|
||||
select id,
|
||||
project_code,
|
||||
order_code,
|
||||
version_code,
|
||||
order_name,
|
||||
customer_name,
|
||||
customer_contact,
|
||||
customer_phone,
|
||||
customer_email,
|
||||
order_type,
|
||||
order_dept,
|
||||
partener_dept,
|
||||
order_date,
|
||||
status,
|
||||
remark,
|
||||
created_at,
|
||||
updated_at,
|
||||
deleted_at
|
||||
from order_info
|
||||
where id = #{id}
|
||||
select t1.id,
|
||||
t1.project_code,
|
||||
t1.order_code,
|
||||
t1.version_code,
|
||||
t1.order_name,
|
||||
t1.customer_name,
|
||||
t1.customer_contact,
|
||||
t1.customer_phone,
|
||||
t1.customer_email,
|
||||
t1.order_type,
|
||||
t1.order_dept,
|
||||
t1.partener_dept,
|
||||
t1.order_date,
|
||||
t1.status,
|
||||
t1.remark,
|
||||
t1.created_at,
|
||||
t1. updated_at,
|
||||
t1.deleted_at,
|
||||
t2.dept_name,
|
||||
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 id="selectOrderListList" resultMap="OrderListResult">
|
||||
|
|
Loading…
Reference in New Issue