Browse Source

1.增加散货列表导出接口

纪新园 1 month ago
parent
commit
02a96bc0a6

+ 105 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/excel/LandOrderExcel.java

@@ -0,0 +1,105 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import org.springblade.client.entity.CommonFile;
+import org.springblade.land.entity.OrderAddress;
+import org.springblade.land.entity.OrderEstimate;
+import org.springblade.land.entity.OrderFee;
+import org.springblade.land.entity.OrderItem;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 陆运订单表实体类
+ *
+ * @author BladeX
+ * @since 2022-03-07
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class LandOrderExcel implements Serializable {
+
+	/**
+	 * 货运日期
+	 */
+	@ExcelProperty(value = "货运日期")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date arrivalTime;
+
+	@ExcelProperty(value = "业务员")
+	private String salesmanName;
+
+	@ExcelProperty(value = "物流运输")
+	private String dispatchDeptName;
+
+	@ExcelProperty(value = "运输调度")
+	private String dispatcherName;
+
+	@ExcelProperty(value = "派车单号")
+	private String dispatchNumber;
+
+	@ExcelProperty(value = "装货地点")
+	private String addressDetail;
+
+	@ExcelProperty(value = "卸货地点")
+	private String unloadingPlace;
+
+	@ExcelProperty(value = "车队")
+	private String fleetShortName;
+
+	@ExcelProperty(value = "车型")
+	private String fleetVolum;
+
+	@ExcelProperty(value = "运费")
+	private BigDecimal freight;
+
+	@ExcelProperty(value = "状态")
+	private Integer status;
+
+	@ExcelProperty(value = "备注")
+	private String remarks;
+
+	@ExcelProperty(value = "公司名称")
+	private String corpShortName;
+
+	@ExcelProperty(value = "创建人")
+	private String createUserName;
+
+	@ExcelProperty(value = "创建时间")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date createTime;
+}

+ 9 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderController.java

@@ -168,6 +168,15 @@ public class OrderController extends BladeController {
 	}
 
 	/**
+	 * 陆运散货订单导出
+	 */
+	@GetMapping("/pageBulkLoadExport")
+	public void pageBulkLoadExport(LandOrder order, HttpServletResponse response) {
+		List<LandOrder> list = orderService.pageBulkLoadExport(order);
+		ExcelUtil.export(response, "散货", "散货", BeanUtil.copy(list, LandOrderExcel.class), LandOrderExcel.class);
+	}
+
+	/**
 	 * 陆运散货修改状态
 	 *
 	 * @param id     主表id

+ 2 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IOrderService.java

@@ -209,4 +209,6 @@ LandOrder addOrderEstimate(LandOrder order);
 	String orderStatus(String type);
 
 	Map<String, Object> statisticsMonthly();
+
+	List<LandOrder> pageBulkLoadExport(LandOrder order);
 }

+ 196 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderServiceImpl.java

@@ -1776,6 +1776,202 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, LandOrder> implem
 		return map;
 	}
 
+	@Override
+	public List<LandOrder> pageBulkLoadExport(LandOrder order) {
+		LambdaQueryWrapper<LandOrder> orderQueryWrapper = new LambdaQueryWrapper<>();
+		orderQueryWrapper.eq(LandOrder::getShippingMode, "散货")
+			.eq(LandOrder::getTenantId, AuthUtil.getTenantId())
+			.eq(LandOrder::getIsDeleted, 0)
+			.eq(ObjectUtil.isNotEmpty(order.getSalesman()), LandOrder::getSalesman, order.getSalesman())//业务员
+			.eq(ObjectUtil.isNotEmpty(order.getDispatchDept()), LandOrder::getDispatchDept, order.getDispatchDept())//调度部门
+			.eq(ObjectUtil.isNotEmpty(order.getCorpId()), LandOrder::getCorpId, order.getCorpId())//客户id
+			.eq(ObjectUtil.isNotEmpty(order.getFleetId()), LandOrder::getFleetId, order.getFleetId())//车队id
+			.like(ObjectUtil.isNotEmpty(order.getPlateNo()), LandOrder::getPlateNo, order.getPlateNo())//车号
+			.eq(ObjectUtil.isNotEmpty(order.getDriverId()), LandOrder::getDriverId, order.getDriverId())//司机id
+			.like(StringUtil.isNotBlank(order.getOrderNo()), LandOrder::getOrderNo, order.getOrderNo())//订单号
+			.like(StringUtil.isNotBlank(order.getContractNo()), LandOrder::getContractNo, order.getContractNo())//合同号
+			.like(StringUtil.isNotBlank(order.getDispatchNumber()), LandOrder::getDispatchNumber, order.getDispatchNumber())//派车单号
+			.like(StringUtil.isNotBlank(order.getAddressDetail()), LandOrder::getAddressDetail, order.getAddressDetail())//装货地址
+			.like(StringUtil.isNotBlank(order.getUnloadingPlace()), LandOrder::getUnloadingPlace, order.getUnloadingPlace())//卸货地址
+			.between(StringUtil.isNotBlank(order.getBeginArrivalTime()) && StringUtil.isNotBlank(order.getEndArrivalTime()), LandOrder::getArrivalTime, order.getBeginArrivalTime(), order.getEndArrivalTime())//货运日期
+			.between(StringUtil.isNotBlank(order.getBeginCrateTime()) && StringUtil.isNotBlank(order.getEndCrateTime()), LandOrder::getCreateTime, order.getBeginCrateTime(), order.getEndCrateTime());//制单日期
+
+		if (AuthUtil.getUserRole().equals(LandConst.MOLD_MANAGER)) {
+			orderQueryWrapper.eq(LandOrder::getCorpId, 1508356683997454337L);
+		}
+
+		orderQueryWrapper.orderByDesc(LandOrder::getArrivalTime);
+
+		// 获取角色 设置权限
+		String userRole = AuthUtil.getUserRole();
+		Long userId = AuthUtil.getUserId();
+		if (userRole.contains(LandConst.ROLE_CD)) {//车队
+			//未派车2,未受理3,未完工4,已关闭5
+			orderQueryWrapper.in(LandOrder::getStatus, 2, 3, 4, 5, 6);
+		}
+		if (userRole.contains(LandConst.ROLE_SJ)) {//司机
+			//未受理3,未完工4,已关闭5
+			orderQueryWrapper.in(LandOrder::getStatus, 3, 4, 5, 6);
+		}
+
+		orderQueryWrapper.in(StringUtil.isNotBlank(order.getStatusIds()), LandOrder::getStatus, Func.toIntList(order.getStatusIds()));
+
+		List<LandOrder> pages = baseMapper.selectList( orderQueryWrapper);
+
+		String corpIds = "";//客户
+		String createUserIds = "";//创建人
+		String salesmanIds = "";//业务员
+		String dispatcherIds = "";//调度员
+		String dispatchDeptIds = "";//调度部门
+		String fleetIds = "";//车队
+		String driverIds = "";//司机
+
+		for (LandOrder orders : pages) {
+			if (ObjectUtil.isNotEmpty(orders.getCorpId())) {
+				corpIds = corpIds + orders.getCorpId() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(orders.getCreateUser())) {
+				createUserIds = createUserIds + orders.getCreateUser() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(orders.getSalesman())) {
+				salesmanIds = salesmanIds + orders.getSalesman() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(orders.getDispatcher())) {
+				dispatcherIds = dispatcherIds + orders.getDispatcher() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(orders.getDispatchDept())) {
+				dispatchDeptIds = dispatchDeptIds + orders.getDispatchDept() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(orders.getFleetId())) {
+				fleetIds = fleetIds + orders.getFleetId() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(orders.getDriverId())) {
+				driverIds = driverIds + orders.getDriverId() + ",";
+			}
+		}
+
+		List<CorpsDesc> corpsDescList = corpsDescClient.selectByCorpIds(corpIds);
+		List<User> createUserList = userClient.selectUserIds(createUserIds);
+		List<User> salesmanList = userClient.selectUserIds(salesmanIds);
+		List<User> dispatcherList = userClient.selectUserIds(dispatcherIds);
+		R<List<Dept>> dispatchDeptList = sysClient.selectByDeptIds(dispatchDeptIds);
+		List<CorpsDesc> fleetList = corpsDescClient.selectByCorpIds(fleetIds);
+		List<LandDriver> driverList = landDriverClient.selectByDriverIds(driverIds);
+
+		pages.forEach(record -> {
+			//杂费客户
+			if (!ObjectUtil.isEmpty(record.getId())) {
+				LambdaQueryWrapper<OrderFee> feeLambdaQueryWrapper = new LambdaQueryWrapper<>();
+				feeLambdaQueryWrapper.eq(OrderFee::getOrderId, record.getId())
+					.eq(OrderFee::getIsDeleted, 0)
+					.eq(OrderFee::getTenantId, AuthUtil.getTenantId());
+				List<OrderFee> feeList = orderFeeMapper.selectList(feeLambdaQueryWrapper);
+
+				String feeCorpIds = "";
+				for (OrderFee orderFee : feeList) {
+					if (ObjectUtil.isNotEmpty(orderFee.getCorpId())) {
+						feeCorpIds = feeCorpIds + orderFee.getCorpId() + ",";
+					}
+				}
+
+				List<CorpsDesc> feeCorpList = corpsDescClient.selectByCorpIds(feeCorpIds);
+
+				if (!ObjectUtil.isEmpty(feeList)) {
+					feeList.forEach(list -> {
+						if (list.getCorpId() != null) {
+							if (ObjectUtil.isNotEmpty(feeCorpList)) {
+								list.setCorpName(feeCorpList.stream().filter(e -> e.getId().equals(list.getCorpId())).findFirst().get().getCname());
+							}
+						}
+					});
+					record.setOrderFeeList(feeList);
+				}
+			}
+
+			//客户
+			if (!ObjectUtil.isEmpty(record.getCorpId())) {
+				if (ObjectUtil.isNotEmpty(corpsDescList)) {
+					CorpsDesc corpsDesc = corpsDescList.stream().anyMatch(e -> e.getId().equals(record.getCorpId())) ? corpsDescList.stream().filter(e -> e.getId().equals(record.getCorpId())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(corpsDesc)) {
+						record.setCreateUserName(corpsDesc.getCname());
+						record.setCorpShortName(corpsDesc.getShortName());
+					}
+				}
+			}
+			//创建人
+			if (!ObjectUtil.isEmpty(record.getCreateUser())) {
+				if (ObjectUtil.isNotEmpty(createUserList)) {
+					User user = createUserList.stream().anyMatch(e -> e.getId().equals(record.getCreateUser())) ? createUserList.stream().filter(e -> e.getId().equals(record.getCreateUser())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(user)) {
+						record.setCreateUserName(user.getRealName());
+					}
+				}
+			}
+			//业务员
+			if (!ObjectUtil.isEmpty(record.getSalesman())) {
+				if (ObjectUtil.isNotEmpty(salesmanList)) {
+					User user = salesmanList.stream().anyMatch(e -> e.getId().equals(record.getSalesman())) ? salesmanList.stream().filter(e -> e.getId().equals(record.getSalesman())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(user)) {
+						record.setSalesmanName(user.getRealName());
+					}
+				}
+			}
+			//调度员
+			if (!ObjectUtil.isEmpty(record.getDispatcher())) {
+				if (ObjectUtil.isNotEmpty(dispatcherList)) {
+					User user = dispatcherList.stream().anyMatch(e -> e.getId().equals(record.getDispatcher())) ? dispatcherList.stream().filter(e -> e.getId().equals(record.getDispatcher())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(user)) {
+						record.setDispatcherName(user.getRealName());
+					}
+				}
+			}
+			//调度部门
+			if (!ObjectUtil.isEmpty(record.getDispatchDept())) {
+				if (ObjectUtil.isNotEmpty(dispatchDeptList)) {
+					Dept dept = dispatchDeptList.getData().stream().anyMatch(e -> e.getId().equals(record.getDispatchDept())) ? dispatchDeptList.getData().stream().filter(e -> e.getId().equals(record.getDispatchDept())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(dept)) {
+						record.setDispatchDeptName(dept.getDeptName());
+					}
+				}
+			}
+			//车队
+			if (!ObjectUtil.isEmpty(record.getFleetId())) {
+				if (ObjectUtil.isNotEmpty(fleetList)) {
+					CorpsDesc corpsDesc = fleetList.stream().anyMatch(e -> e.getId().equals(record.getFleetId())) ? fleetList.stream().filter(e -> e.getId().equals(record.getFleetId())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(corpsDesc)) {
+						record.setFleetName(corpsDesc.getCname());
+						record.setFleetShortName(corpsDesc.getShortName());
+					}
+				}
+			}
+			//司机
+			if (!ObjectUtil.isEmpty(record.getDriverId())) {
+				if (ObjectUtil.isNotEmpty(driverList)) {
+					LandDriver landDriver = driverList.stream().anyMatch(e -> e.getId().equals(record.getDriverId())) ? driverList.stream().filter(e -> e.getId().equals(record.getDriverId())).findFirst().get() : null;
+					if (ObjectUtils.isNotNull(landDriver)) {
+						record.setFleetName(landDriver.getName());
+					}
+				}
+			}
+			//装货地址货物体积总和
+			LambdaQueryWrapper<OrderAddress> orderLambdaQueryWrapper = new LambdaQueryWrapper<OrderAddress>();
+			orderLambdaQueryWrapper.eq(OrderAddress::getTenantId, AuthUtil.getTenantId())
+				.eq(OrderAddress::getIsDeleted, 0)
+				.eq(OrderAddress::getBillType, 1)
+				.eq(OrderAddress::getOrderId, record.getId());
+			List<OrderAddress> orderList = orderAddressMapper.selectList(orderLambdaQueryWrapper);
+			record.setVolumeSum(0.0);
+			if (!ObjectUtil.isEmpty(orderList)) {
+				orderList.forEach(list -> {
+					if (ObjectUtil.isNotEmpty(list.getVolume())) {
+						record.setVolumeSum(record.getVolumeSum() + list.getVolume());
+					}
+				});
+			}
+		});
+		return pages;
+	}
+
 	private List<OrderItem> getOrderItemList(Long id) {
 		List<OrderItem> orderItemList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItem>()
 			.eq(OrderItem::getOrderId, id)